From 9c46aa799336bef621bc5f927fbcd47c72de44a5 Mon Sep 17 00:00:00 2001 From: Maxime Roux Date: Tue, 20 Jan 2015 10:10:03 -0800 Subject: [PATCH] UI-904: Added red & green colors on user devices to show registration --- submodules/users/users.css | 6 +++++ submodules/users/users.js | 52 +++++++++++++++++++++++++++----------- views/users-row.html | 24 ++---------------- 3 files changed, 45 insertions(+), 37 deletions(-) diff --git a/submodules/users/users.css b/submodules/users/users.css index 6f3318d..7012602 100644 --- a/submodules/users/users.css +++ b/submodules/users/users.css @@ -787,4 +787,10 @@ #find_me_follow_me_form .grid-time .grid-time-row-placeholder { height: 52px; background-color: inherit; +} + +/********* CSS for device popovers (appended directly on the body) *********/ +.device-popover-icon { + margin-right: 10px; + vertical-align: text-bottom; } \ No newline at end of file diff --git a/submodules/users/users.js b/submodules/users/users.js index 83e6f1a..a1d3db9 100644 --- a/submodules/users/users.js +++ b/submodules/users/users.js @@ -14,6 +14,18 @@ define(function(require){ 'voip.users.render': 'usersRender' }, + deviceIcons: { + 'cellphone': 'icon-phone', + 'smartphone': 'icon-telicon-mobile-phone', + 'landline': 'icon-telicon-home-phone', + 'mobile': 'icon-telicon-sprint-phone', + 'softphone': 'icon-telicon-soft-phone', + 'sip_device': 'icon-telicon-voip-phone', + 'sip_uri': 'icon-telicon-voip-phone', + 'fax': 'icon-telicon-fax', + 'ata': 'icon-telicon-fax' + }, + /* Users */ /* args: parent and userId */ usersRender: function(args) { @@ -37,6 +49,7 @@ define(function(require){ }); template.find('[data-toggle="tooltip"]').tooltip({ container: 'body'}); + template.find('[data-toggle="popover"]').popover({ container: 'body'}); self.usersBindEvents(template, parent, dataTemplate); @@ -253,21 +266,27 @@ define(function(require){ var userId = device.owner_id; if(userId in mapUsers) { + var isRegistered = _.find(data.deviceStatus, function(status){ return (status.device_id === device.id && status.registered === true); }) ? true : false; if(mapUsers[userId].extra.devices.length == 2) { if(mapUsers[userId].extra.additionalDevices) { mapUsers[userId].extra.additionalDevices.count++; - mapUsers[userId].extra.additionalDevices.tooltip += '
'+device.name + ' (' + device.device_type.replace('_', ' ') + ')'; + mapUsers[userId].extra.additionalDevices.tooltip += '
' + + device.name + ' (' + device.device_type.replace('_', ' ') + ')'; } else { mapUsers[userId].extra.additionalDevices = { count: 1, - tooltip: device.name + ' (' + device.device_type.replace('_', ' ') + ')' + tooltip: '' + + device.name + ' (' + device.device_type.replace('_', ' ') + ')' }; } } else { mapUsers[userId].extra.devices.push({ + id: device.id, name: device.name + ' (' + device.device_type.replace('_', ' ') + ')', - type: device.device_type + type: device.device_type, + registered: isRegistered, + icon: self.deviceIcons[device.device_type] }); } } @@ -438,7 +457,7 @@ define(function(require){ }, function(err, results) { var originalData = self.usersFormatAddUser(results), - userTemplate = $(monster.template(self, 'users-creation', originalData)); + userTemplate = $(monster.template(self, 'users-crefation', originalData)); timezone.populateDropdown(userTemplate.find('#user_creation_timezone')); monster.ui.prettyCheck.create(userTemplate); @@ -1713,15 +1732,7 @@ define(function(require){ }, usersRenderFindMeFollowMe: function(params) { - var self = this, - deviceIcons = { - 'softphone': 'icon-telicon-soft-phone', - 'cellphone': 'icon-telicon-mobile-phone', - 'smartphone': 'icon-telicon-sprint-phone', - 'sip_device': 'icon-telicon-voip-phone', - 'fax': 'icon-telicon-fax', - 'landline': 'icon-telicon-home-phone' - }; + var self = this; if(!params.userCallflow) { monster.ui.alert('error', self.i18n.active().users.find_me_follow_me.noNumber); @@ -1755,7 +1766,7 @@ define(function(require){ delay: endpoint.delay, timeout: endpoint.timeout, name: device.name, - icon: deviceIcons[device.device_type], + icon: self.deviceIcons[device.device_type], disabled: false } } @@ -1767,7 +1778,7 @@ define(function(require){ delay: 0, timeout: 0, name: device.name, - icon: deviceIcons[device.device_type], + icon: self.deviceIcons[device.device_type], disabled: true }) }); @@ -3315,6 +3326,17 @@ define(function(require){ self.usersGetDevicesData(function(devices) { callback(null, devices); }); + }, + deviceStatus: function(callback) { + self.callApi({ + resource: 'device.getStatus', + data: { + accountId: self.accountId + }, + success: function(data, status) { + callback(null, data.data); + } + }); } }, function(err, results) { diff --git a/views/users-row.html b/views/users-row.html index 11011a8..48266ab 100644 --- a/views/users-row.html +++ b/views/users-row.html @@ -25,33 +25,13 @@
{{#each extra.devices}} - {{#compare this.type '===' 'softphone'}} - - {{/compare}} - {{#compare this.type '===' 'cellphone'}} - - {{/compare}} - {{#compare this.type '===' 'smartphone'}} - - {{/compare}} - {{#compare this.type '===' 'mobile'}} - - {{/compare}} - {{#compare this.type '===' 'sip_device'}} - - {{/compare}} - {{#compare this.type '===' 'fax'}} - - {{/compare}} - {{#compare this.type '===' 'landline'}} - - {{/compare}} + {{else}} {{ i18n.users.noUserDevices }} {{/each}} {{#if extra.additionalDevices}} - (+{{extra.additionalDevices.count}}) + (+{{extra.additionalDevices.count}}) {{/if}}
" 5}} smaller{{/compare}}" data-type="features">