Added auto support for online notifications.
This commit is contained in:
parent
f1e66c3973
commit
09a49b0a48
4 changed files with 70 additions and 8 deletions
|
@ -39,7 +39,6 @@ class Index extends App.Controller
|
||||||
{
|
{
|
||||||
name: 'Xylo'
|
name: 'Xylo'
|
||||||
file: 'Xylo.mp3'
|
file: 'Xylo.mp3'
|
||||||
selected: true
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -84,10 +83,15 @@ class Index extends App.Controller
|
||||||
config['group_ids'] = []
|
config['group_ids'] = []
|
||||||
config['group_ids'].push group_id.toString()
|
config['group_ids'].push group_id.toString()
|
||||||
|
|
||||||
|
for sound in @sounds
|
||||||
|
if sound.file is App.OnlineNotification.soundFile()
|
||||||
|
sound.selected = true
|
||||||
|
|
||||||
@html App.view('profile/notification')
|
@html App.view('profile/notification')
|
||||||
groups: groups
|
groups: groups
|
||||||
config: config
|
config: config
|
||||||
sounds: @sounds
|
sounds: @sounds
|
||||||
|
notification_sound_enabled: App.OnlineNotification.soundEnabled()
|
||||||
|
|
||||||
update: (e) =>
|
update: (e) =>
|
||||||
|
|
||||||
|
@ -147,6 +151,10 @@ class Index extends App.Controller
|
||||||
params.notification_config.group_ids = ['-']
|
params.notification_config.group_ids = ['-']
|
||||||
@formDisable(e)
|
@formDisable(e)
|
||||||
|
|
||||||
|
params.notification_sound = form_params.notification_sound
|
||||||
|
if !params.notification_sound.enabled
|
||||||
|
params.notification_sound.enabled = false
|
||||||
|
|
||||||
# get data
|
# get data
|
||||||
@ajax(
|
@ajax(
|
||||||
id: 'preferences'
|
id: 'preferences'
|
||||||
|
@ -179,8 +187,11 @@ class Index extends App.Controller
|
||||||
msg: App.i18n.translateContent(data.message)
|
msg: App.i18n.translateContent(data.message)
|
||||||
)
|
)
|
||||||
|
|
||||||
previewSound: (event) ->
|
previewSound: (e) =>
|
||||||
sound = new Audio("assets/sounds/#{ @sounds[event.currentTarget.value].file }")
|
params = @formParam(e.target)
|
||||||
sound.play()
|
return if !params.notification_sound
|
||||||
|
return if !params.notification_sound.file
|
||||||
|
App.OnlineNotification.play(params.notification_sound.file)
|
||||||
|
|
||||||
|
|
||||||
App.Config.set( 'Notifications', { prio: 2600, name: 'Notifications', parent: '#profile', target: '#profile/notifications', role: ['Agent'], controller: Index }, 'NavBarProfile' )
|
App.Config.set( 'Notifications', { prio: 2600, name: 'Notifications', parent: '#profile', target: '#profile/notifications', role: ['Agent'], controller: Index }, 'NavBarProfile' )
|
||||||
|
|
|
@ -201,6 +201,7 @@ class App.OnlineNotificationWidget extends App.Controller
|
||||||
url: item.link
|
url: item.link
|
||||||
title: title
|
title: title
|
||||||
)
|
)
|
||||||
|
App.OnlineNotification.play()
|
||||||
|
|
||||||
# execute controller again of already open (because hash hasn't changed, we need to do it manually)
|
# execute controller again of already open (because hash hasn't changed, we need to do it manually)
|
||||||
notificationsContainer.find('.js-locationVerify').on('click', (e) =>
|
notificationsContainer.find('.js-locationVerify').on('click', (e) =>
|
||||||
|
|
|
@ -5,6 +5,56 @@ class App.OnlineNotification extends App.Model
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
|
App.OnlineNotification.play()
|
||||||
|
|
||||||
|
App.OnlineNotification.play('bell.mp3')
|
||||||
|
|
||||||
|
###
|
||||||
|
|
||||||
|
@play: (file) ->
|
||||||
|
if file
|
||||||
|
sound = new Audio("assets/sounds/#{file}")
|
||||||
|
sound.play()
|
||||||
|
return
|
||||||
|
preferences = App.Session.get('preferences')
|
||||||
|
return if !preferences
|
||||||
|
return if !App.OnlineNotification.soundEnabled()
|
||||||
|
file = App.OnlineNotification.soundFile()
|
||||||
|
sound = new Audio("assets/sounds/#{file}")
|
||||||
|
sound.play()
|
||||||
|
|
||||||
|
###
|
||||||
|
|
||||||
|
App.OnlineNotification.soundEnabled()
|
||||||
|
|
||||||
|
###
|
||||||
|
|
||||||
|
@soundEnabled: ->
|
||||||
|
preferences = App.Session.get('preferences')
|
||||||
|
return false if !preferences
|
||||||
|
if !preferences.notification_sound
|
||||||
|
preferences.notification_sound = {}
|
||||||
|
if preferences.notification_sound.enabled is undefined
|
||||||
|
preferences.notification_sound.enabled = true
|
||||||
|
return false if preferences.notification_sound.enabled.toString() is 'false'
|
||||||
|
true
|
||||||
|
|
||||||
|
###
|
||||||
|
|
||||||
|
App.OnlineNotification.soundFile()
|
||||||
|
|
||||||
|
###
|
||||||
|
|
||||||
|
@soundFile: ->
|
||||||
|
file = 'Xylo.mp3'
|
||||||
|
preferences = App.Session.get('preferences')
|
||||||
|
return file if !preferences
|
||||||
|
return file if !preferences.notification_sound
|
||||||
|
return file if !preferences.notification_sound.file
|
||||||
|
preferences.notification_sound.file
|
||||||
|
|
||||||
|
###
|
||||||
|
|
||||||
App.OnlineNotification.seen( 'Ticket', 123 )
|
App.OnlineNotification.seen( 'Ticket', 123 )
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
|
@ -81,9 +81,9 @@
|
||||||
<label for="notification-sound"><%- @T('Notification Sound') %></label>
|
<label for="notification-sound"><%- @T('Notification Sound') %></label>
|
||||||
</div>
|
</div>
|
||||||
<div class="controls controls--select">
|
<div class="controls controls--select">
|
||||||
<select class="form-control js-notificationSound" id="notification-sound">
|
<select class="form-control js-notificationSound" id="notification-sound" name="notification_sound::file">
|
||||||
<% for sound, i in @sounds: %>
|
<% for sound in @sounds: %>
|
||||||
<option value="<%= i %>"<%= ' selected' if sound.selected %>><%= sound.name %></option>
|
<option value="<%= sound.file %>"<%= ' selected' if sound.selected %>><%= sound.name %></option>
|
||||||
<% end %>
|
<% end %>
|
||||||
</select>
|
</select>
|
||||||
<%- @Icon('arrow-down') %>
|
<%- @Icon('arrow-down') %>
|
||||||
|
@ -92,7 +92,7 @@
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="inline-label">
|
<label class="inline-label">
|
||||||
<span class="checkbox-replacement checkbox-replacement--inline">
|
<span class="checkbox-replacement checkbox-replacement--inline">
|
||||||
<input type="checkbox" name="enable_sound" value="true" checked>
|
<input type="checkbox" name="notification_sound::enabled" value="true" <% if @notification_sound_enabled: %> checked<% end %> class="js-SoundEnableDisable">
|
||||||
<%- @Icon('checkbox', 'icon-unchecked') %>
|
<%- @Icon('checkbox', 'icon-unchecked') %>
|
||||||
<%- @Icon('checkbox-checked', 'icon-checked') %>
|
<%- @Icon('checkbox-checked', 'icon-checked') %>
|
||||||
</span>
|
</span>
|
||||||
|
|
Loading…
Reference in a new issue