Browse Source

UI-2865: now adds device name if available in interaction legs

4.3
Jean-Roch Maitre 8 years ago
parent
commit
864f487a83
3 changed files with 86 additions and 9 deletions
  1. +4
    -0
      submodules/callLogs/callLogs.css
  2. +69
    -2
      submodules/callLogs/callLogs.js
  3. +13
    -7
      views/callLogs-interactionLegs.html

+ 4
- 0
submodules/callLogs/callLogs.css View File

@ -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;
}


+ 69
- 2
submodules/callLogs/callLogs.js View File

@ -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);
}
});
}
};


+ 13
- 7
views/callLogs-interactionLegs.html View File

@ -1,5 +1,5 @@
{{#each cdrs}}
<div class="grid-row extra-leg" data-id={{this.id}}>
<div class="grid-row extra-leg" data-id={{this.id}} data-search="{{searchString}}">
<div class="grid-cell direction">
<div class="sub-cell single-cell"></div>
</div>
@ -7,21 +7,27 @@
<div class="sub-cell cell-top">{{this.date}}</div>
<div class="sub-cell cell-bottom">{{this.time}}</div>
</div>
<div class="grid-cell from">
<div class="grid-cell from{{#if formatted.fromDeviceName}} high-cell{{/if}}">
{{#if this.fromName}}
<div class="sub-cell cell-top">{{formatPhoneNumber this.fromNumber}}</div>
<div class="sub-cell cell-bottom">{{this.fromName}}</div>
<div class="sub-cell">{{formatPhoneNumber this.fromNumber}}</div>
<div class="sub-cell">{{this.fromName}}</div>
{{else}}
<div class="sub-cell single-cell">{{formatPhoneNumber this.fromNumber}}</div>
{{/if}}
{{#if formatted.fromDeviceName}}
<div class="sub-cell"><i class="{{ formatted.deviceIcon }}" data-placement="top" data-toggle="tooltip" data-original-title="{{ formatted.deviceTooltip }}"></i>{{formatted.fromDeviceName}}</div>
{{/if}}
</div>
<div class="grid-cell to">
<div class="grid-cell to{{#if formatted.toDeviceName}} high-cell{{/if}}">
{{#if this.toName}}
<div class="sub-cell cell-top">{{formatPhoneNumber this.toNumber}}</div>
<div class="sub-cell cell-bottom">{{this.toName}}</div>
<div class="sub-cell">{{formatPhoneNumber this.toNumber}}</div>
<div class="sub-cell">{{this.toName}}</div>
{{else}}
<div class="sub-cell single-cell">{{formatPhoneNumber this.toNumber}}</div>
{{/if}}
{{#if formatted.toDeviceName}}
<div class="sub-cell"><i class="{{ formatted.deviceIcon }}" data-placement="top" data-toggle="tooltip" data-original-title="{{ formatted.deviceTooltip }}"></i>{{formatted.toDeviceName}}</div>
{{/if}}
</div>
<div class="grid-cell duration">
<div class="sub-cell single-cell">


Loading…
Cancel
Save