diff --git a/submodules/callLogs/callLogs.css b/submodules/callLogs/callLogs.css index 2090de6..854187c 100644 --- a/submodules/callLogs/callLogs.css +++ b/submodules/callLogs/callLogs.css @@ -152,6 +152,10 @@ text-align: center; vertical-align: bottom; } +#call_logs_container .grid-cell.high-cell { + padding-top: 0; + padding-bottom: 0; +} #call_logs_container .grid-cell:not(:first-of-type) { border-left: solid 1px #e3e3e3; } diff --git a/submodules/callLogs/callLogs.js b/submodules/callLogs/callLogs.js index 542c744..95d670c 100644 --- a/submodules/callLogs/callLogs.js +++ b/submodules/callLogs/callLogs.js @@ -6,6 +6,12 @@ define(function(require) { var app = { requests: {}, + appFlags: { + callLogs: { + devices: [] + } + }, + subscribe: { 'voip.callLogs.render': 'callLogsRender' }, @@ -13,7 +19,25 @@ define(function(require) { callLogsRender: function(args) { var self = this; - self.callLogsRenderContent(args.parent, args.fromDate, args.toDate, args.type, args.callback); + self.callLogsGetData(function() { + self.callLogsRenderContent(args.parent, args.fromDate, args.toDate, args.type, args.callback); + }); + }, + + callLogsGetData: function(globalCallback) { + var self = this; + + monster.parallel({ + devices: function(callback) { + self.callLogsListDevices(function(devices) { + callback && callback(null, devices); + }); + } + }, function(err, results) { + self.appFlags.callLogs.devices = _.keyBy(results.devices, 'id'); + + globalCallback && globalCallback(); + }); }, callLogsRenderContent: function(parent, fromDate, toDate, type, callback) { @@ -89,7 +113,7 @@ define(function(require) { fromDate = params.fromDate, toDate = params.toDate, startKey = params.nextStartKey; - +console.log(cdrs); setTimeout(function() { template.find('.search-query').focus(); }); @@ -316,6 +340,18 @@ define(function(require) { callLogsFormatCdrs: function(cdrs) { var self = this, result = [], + deviceIcons = { + 'cellphone': 'fa fa-phone', + 'smartphone': 'icon-telicon-mobile-phone', + 'landline': 'icon-telicon-home', + '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-ata', + 'unknown': 'fa fa-circle' + }, formatCdr = function(cdr) { var date = cdr.hasOwnProperty('channel_created_time') ? monster.util.unixToDate(cdr.channel_created_time, true) : monster.util.gregorianToDate(cdr.timestamp), shortDate = monster.util.toFriendlyDate(date, 'shortDate'), @@ -370,6 +406,20 @@ define(function(require) { call.channelCreatedTime = cdr.channel_created_time; } + if (cdr.hasOwnProperty('custom_channel_vars') && cdr.custom_channel_vars.hasOwnProperty('authorizing_id') && self.appFlags.callLogs.devices.hasOwnProperty(cdr.custom_channel_vars.authorizing_id)) { + var device = self.appFlags.callLogs.devices[cdr.custom_channel_vars.authorizing_id]; + + call.formatted = call.formatted || {}; + call.formatted.deviceIcon = deviceIcons[device.device_type]; + call.formatted.deviceTooltip = self.i18n.active().devices.types[device.device_type]; + + if (cdr.call_direction === 'inbound') { + call.formatted.fromDeviceName = device.name; + } else { + call.formatted.toDeviceName = device.name; + } + } + return call; }; @@ -406,6 +456,23 @@ define(function(require) { monster.ui.alert('error', self.i18n.active().callLogs.alertMessages.getDetailsError); } }); + }, + + callLogsListDevices: function(callback) { + var self = this; + + self.callApi({ + resource: 'device.list', + data: { + accountId: self.accountId, + filters: { + paginate: false + } + }, + success: function(data) { + callback && callback(data.data); + } + }); } }; diff --git a/views/callLogs-interactionLegs.html b/views/callLogs-interactionLegs.html index 2094d49..a22953a 100644 --- a/views/callLogs-interactionLegs.html +++ b/views/callLogs-interactionLegs.html @@ -1,5 +1,5 @@ {{#each cdrs}} -
+
@@ -7,21 +7,27 @@
{{this.date}}
{{this.time}}
-
+
{{#if this.fromName}} -
{{formatPhoneNumber this.fromNumber}}
-
{{this.fromName}}
+
{{formatPhoneNumber this.fromNumber}}
+
{{this.fromName}}
{{else}}
{{formatPhoneNumber this.fromNumber}}
{{/if}} + {{#if formatted.fromDeviceName}} +
{{formatted.fromDeviceName}}
+ {{/if}}
-
+
{{#if this.toName}} -
{{formatPhoneNumber this.toNumber}}
-
{{this.toName}}
+
{{formatPhoneNumber this.toNumber}}
+
{{this.toName}}
{{else}}
{{formatPhoneNumber this.toNumber}}
{{/if}} + {{#if formatted.toDeviceName}} +
{{formatted.toDeviceName}}
+ {{/if}}