Browse Source

Add do not disturb user feature (#44)

4.3
mira-t 8 years ago
committed by JRMaitre
parent
commit
f061be784e
3 changed files with 80 additions and 0 deletions
  1. +4
    -0
      i18n/en-US.json
  2. +56
    -0
      submodules/users/users.js
  3. +20
    -0
      views/users-feature-do_not_disturb.html

+ 4
- 0
i18n/en-US.json View File

@ -611,6 +611,10 @@
"help": "You can create a conference call by providing a conferencing phone number and your personal room number to the participants",
"noConfNumbers": "You need to add a Main Conference Number (in the Main number section on the left of the SmartPBX) in order to enable the Personnals Conference Bridges"
},
"do_not_disturb": {
"headline": "User DND Settings",
"title": "Do Not Disturb"
},
"faxing": {
"trialError": "You're currently using a trial version of the UI. Please upgrade your account to have access to the Faxing feature!",
"title": "Faxbox",


+ 56
- 0
submodules/users/users.js View File

@ -232,6 +232,11 @@ define(function(require) {
icon: 'fa fa-microphone',
iconColor: 'monster-blue',
title: self.i18n.active().users.callRecording.title
},
do_not_disturb: {
icon: 'fa fa-ban',
iconColor: 'monster-red',
title: self.i18n.active().users.do_not_disturb.title
}
}
};
@ -1389,6 +1394,10 @@ define(function(require) {
}
});
template.on('click', '.feature[data-feature="do_not_disturb"]', function() {
self.usersRenderDoNotDisturb(currentUser);
});
template.on('click', '.feature[data-feature="call_forward"]', function() {
if (currentUser.features.indexOf('find_me_follow_me') < 0) {
var featureUser = $.extend(true, {}, currentUser);
@ -2191,6 +2200,53 @@ define(function(require) {
popup.find('.monster-button').blur();
},
usersRenderDoNotDisturb: function(featureUser) {
var self = this,
featureTemplate = $(monster.template(self, 'users-feature-do_not_disturb', featureUser)),
switchFeature = featureTemplate.find('#checkbox_do_not_disturb');
featureTemplate.find('.cancel-link').on('click', function() {
popup.dialog('close').remove();
});
featureTemplate.find('.save').on('click', function() {
var userToSave = featureUser;
//update data.data.do_not_disturb depending on the switch status
if (typeof userToSave.do_not_disturb === 'undefined') {
userToSave.do_not_disturb = {};
}
if (typeof userToSave.do_not_disturb.enabled === 'undefined') {
userToSave.do_not_disturb.enabled = false;
}
userToSave.do_not_disturb.enabled = switchFeature.prop('checked');
self.usersUpdateUser(userToSave, function(data) {
self.callApi({
resource: 'user.updatePresence',
data: {
accountId: self.accountId,
userId: userToSave.id,
data: {
action: 'set',
state: userToSave.do_not_disturb.enabled ? 'confirmed' : 'terminated'
}
},
error: function() {
console.log('Failed to update presence state');
}
});
popup.dialog('close').remove();
self.usersRender({
userId: userToSave.id,
openedTab: 'features'
});
});
});
var popup = monster.ui.dialog(featureTemplate, {
title: featureUser && featureUser.extra && featureUser.extra.mapFeatures.do_not_disturb.title,
position: ['center', 20]
});
},
usersRenderFindMeFollowMe: function(params) {
var self = this;


+ 20
- 0
views/users-feature-do_not_disturb.html View File

@ -0,0 +1,20 @@
<div class="monster-feature-popup-container" data-feature="do_not_disturb">
<div class="feature-popup-title">
<div class="feature-fa-wrapper">
<i class="{{extra.mapFeatures.do_not_disturb.icon}}"></i>
</div>
{{ i18n.users.do_not_disturb.headline }}
<div class="switch">
{{#monsterSwitch}}
<input class="switch-state" type="checkbox" name="enabled" id="checkbox_do_not_disturb" data-on="{{i18n.enabled}}" data-off="{{i18n.disabled}}"{{#if extra.mapFeatures.do_not_disturb.active}} checked="checked"{{/if}}></input>
{{/monsterSwitch}}
</div>
</div>
<div class="actions clearfix">
<div class="pull-right">
<a class="cancel-link monster-link blue" href="javascript:void(0);">{{ i18n.cancel }}</a>
<button type="button" class="monster-button monster-button-success save">{{ i18n.saveChanges }}</button>
</div>
</div>
</div>

Loading…
Cancel
Save