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'
|
||||
file: 'Xylo.mp3'
|
||||
selected: true
|
||||
}
|
||||
]
|
||||
|
||||
|
@ -84,10 +83,15 @@ class Index extends App.Controller
|
|||
config['group_ids'] = []
|
||||
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')
|
||||
groups: groups
|
||||
config: config
|
||||
sounds: @sounds
|
||||
notification_sound_enabled: App.OnlineNotification.soundEnabled()
|
||||
|
||||
update: (e) =>
|
||||
|
||||
|
@ -147,6 +151,10 @@ class Index extends App.Controller
|
|||
params.notification_config.group_ids = ['-']
|
||||
@formDisable(e)
|
||||
|
||||
params.notification_sound = form_params.notification_sound
|
||||
if !params.notification_sound.enabled
|
||||
params.notification_sound.enabled = false
|
||||
|
||||
# get data
|
||||
@ajax(
|
||||
id: 'preferences'
|
||||
|
@ -179,8 +187,11 @@ class Index extends App.Controller
|
|||
msg: App.i18n.translateContent(data.message)
|
||||
)
|
||||
|
||||
previewSound: (event) ->
|
||||
sound = new Audio("assets/sounds/#{ @sounds[event.currentTarget.value].file }")
|
||||
sound.play()
|
||||
previewSound: (e) =>
|
||||
params = @formParam(e.target)
|
||||
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' )
|
||||
|
|
|
@ -201,6 +201,7 @@ class App.OnlineNotificationWidget extends App.Controller
|
|||
url: item.link
|
||||
title: title
|
||||
)
|
||||
App.OnlineNotification.play()
|
||||
|
||||
# execute controller again of already open (because hash hasn't changed, we need to do it manually)
|
||||
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 )
|
||||
|
||||
###
|
||||
|
|
|
@ -81,9 +81,9 @@
|
|||
<label for="notification-sound"><%- @T('Notification Sound') %></label>
|
||||
</div>
|
||||
<div class="controls controls--select">
|
||||
<select class="form-control js-notificationSound" id="notification-sound">
|
||||
<% for sound, i in @sounds: %>
|
||||
<option value="<%= i %>"<%= ' selected' if sound.selected %>><%= sound.name %></option>
|
||||
<select class="form-control js-notificationSound" id="notification-sound" name="notification_sound::file">
|
||||
<% for sound in @sounds: %>
|
||||
<option value="<%= sound.file %>"<%= ' selected' if sound.selected %>><%= sound.name %></option>
|
||||
<% end %>
|
||||
</select>
|
||||
<%- @Icon('arrow-down') %>
|
||||
|
@ -92,7 +92,7 @@
|
|||
<div class="form-group">
|
||||
<label class="inline-label">
|
||||
<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-checked', 'icon-checked') %>
|
||||
</span>
|
||||
|
|
Loading…
Reference in a new issue