From cc92bd6947563433a3235491d36c1717c5e25e22 Mon Sep 17 00:00:00 2001 From: Jean-Roch Maitre Date: Thu, 28 Jul 2016 11:31:35 -0700 Subject: [PATCH] UI-2329: now using interaction api to list cdrs in smart pbx --- submodules/callLogs/callLogs.js | 57 +++------------------------------ views/callLogs-cdrsList.html | 49 +--------------------------- 2 files changed, 6 insertions(+), 100 deletions(-) diff --git a/submodules/callLogs/callLogs.js b/submodules/callLogs/callLogs.js index 3b85aba..24b1b6d 100644 --- a/submodules/callLogs/callLogs.js +++ b/submodules/callLogs/callLogs.js @@ -42,6 +42,7 @@ define(function(require){ delete self.loneBLegs; self.callLogsGetCdrs(fromDate, toDate, function(cdrs, nextStartKey) { cdrs = self.callLogsFormatCdrs(cdrs); + dataTemplate.cdrs = cdrs; template = $(monster.template(self, 'callLogs-layout', dataTemplate)); @@ -285,49 +286,13 @@ define(function(require){ } self.callApi({ - resource: 'cdrs.list', + resource: 'cdrs.listByInteraction', data: { accountId: self.accountId, filters: filters }, success: function(data, status) { - var cdrs = {}, - groupedLegs = _.groupBy(data.data, function(val) { return (val.direction === 'inbound' || !val.bridge_id) ? 'aLegs' : 'bLegs' }); - - if(self.lastALeg) { - groupedLegs.aLegs.splice(0, 0, self.lastALeg); - } - // if(self.loneBLegs && self.loneBLegs.length) { - // groupedLegs.bLegs = self.loneBLegs.concat(groupedLegs.bLegs); - // } - if(data['next_start_key']) { - self.lastALeg = groupedLegs.aLegs.pop(); - } - - _.each(groupedLegs.aLegs, function(val) { - var call_id = val.call_id || val.id; - cdrs[call_id] = { aLeg: val, bLegs: {} }; - }); - - if(self.loneBLegs && self.loneBLegs.length > 0) { - _.each(self.loneBLegs, function(val) { - if('other_leg_call_id' in val && val.other_leg_call_id in cdrs) { - cdrs[val.other_leg_call_id].bLegs[val.id] = val; - } - }); - } - self.loneBLegs = []; - _.each(groupedLegs.bLegs, function(val) { - if('other_leg_call_id' in val) { - if(val.other_leg_call_id in cdrs) { - cdrs[val.other_leg_call_id].bLegs[val.id] = val; - } else { - self.loneBLegs.push(val); - } - } - }); - - callback(cdrs, data['next_start_key']); + callback(data.data, data['next_start_key']); } }); }, @@ -387,20 +352,8 @@ define(function(require){ }; }; - _.each(cdrs, function(val, key) { - if(!('aLeg' in val)) { - // Handling lone b-legs as standalone a-legs - _.each(val.bLegs, function(v, k) { - result.push($.extend({ bLegs: [] }, formatCdr(v))); - }); - } else { - var cdr = formatCdr(val.aLeg); - cdr.bLegs = []; - _.each(val.bLegs, function(v, k) { - cdr.bLegs.push(formatCdr(v)); - }); - result.push(cdr); - } + _.each(cdrs, function(v) { + result.push(formatCdr(v)); }); result.sort(function(a, b) { diff --git a/views/callLogs-cdrsList.html b/views/callLogs-cdrsList.html index 8ac4e2c..e6cdfb3 100644 --- a/views/callLogs-cdrsList.html +++ b/views/callLogs-cdrsList.html @@ -1,6 +1,6 @@ {{#each cdrs}}
-
+
{{#if this.isOutboundCall}} @@ -53,52 +53,5 @@
{{/if}}
- {{#each this.bLegs}} -
-
-
-
-
-
{{this.date}}
-
{{this.time}}
-
-
- {{#if this.fromName}} -
{{formatPhoneNumber this.fromNumber}}
-
{{this.fromName}}
- {{else}} -
{{formatPhoneNumber this.fromNumber}}
- {{/if}} -
-
- {{#if this.toName}} -
{{formatPhoneNumber this.toNumber}}
-
{{this.toName}}
- {{else}} -
{{formatPhoneNumber this.toNumber}}
- {{/if}} -
-
-
- {{this.duration}} -
-
-
-
- {{this.hangupCause}} -
-
-
-
- -
-
- {{#if ../../showReport}} -
-
-
- {{/if}} -
- {{/each}}
{{/each}} \ No newline at end of file