Browse Source

UI-2329: now using interaction api to list cdrs in smart pbx

4.3
Jean-Roch Maitre 10 years ago
parent
commit
cc92bd6947
2 changed files with 6 additions and 100 deletions
  1. +5
    -52
      submodules/callLogs/callLogs.js
  2. +1
    -48
      views/callLogs-cdrsList.html

+ 5
- 52
submodules/callLogs/callLogs.js View File

@ -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) {


+ 1
- 48
views/callLogs-cdrsList.html View File

@ -1,6 +1,6 @@
{{#each cdrs}}
<div class="grid-row-group">
<div class="grid-row a-leg {{#if this.bLegs.length}}has-b-legs{{/if}}" data-id="{{this.id}}">
<div class="grid-row" data-id="{{this.id}}">
<div class="grid-cell direction">
<div class="sub-cell single-cell">
{{#if this.isOutboundCall}}
@ -53,52 +53,5 @@
</div>
{{/if}}
</div>
{{#each this.bLegs}}
<div class="grid-row b-leg" data-id={{this.id}}>
<div class="grid-cell direction">
<div class="sub-cell single-cell"></div>
</div>
<div class="grid-cell datetime">
<div class="sub-cell cell-top">{{this.date}}</div>
<div class="sub-cell cell-bottom">{{this.time}}</div>
</div>
<div class="grid-cell from">
{{#if this.fromName}}
<div class="sub-cell cell-top">{{formatPhoneNumber this.fromNumber}}</div>
<div class="sub-cell cell-bottom">{{this.fromName}}</div>
{{else}}
<div class="sub-cell single-cell">{{formatPhoneNumber this.fromNumber}}</div>
{{/if}}
</div>
<div class="grid-cell to">
{{#if this.toName}}
<div class="sub-cell cell-top">{{formatPhoneNumber this.toNumber}}</div>
<div class="sub-cell cell-bottom">{{this.toName}}</div>
{{else}}
<div class="sub-cell single-cell">{{formatPhoneNumber this.toNumber}}</div>
{{/if}}
</div>
<div class="grid-cell duration">
<div class="sub-cell single-cell">
{{this.duration}}
</div>
</div>
<div class="grid-cell hangup">
<div class="sub-cell single-cell" title="{{this.hangupCause}}">
{{this.hangupCause}}
</div>
</div>
<div class="grid-cell details">
<div class="sub-cell single-cell">
<i class="fa fa-cog fa-lg"></i>
</div>
</div>
{{#if ../../showReport}}
<div class="grid-cell report">
<div class="sub-cell single-cell"></div>
</div>
{{/if}}
</div>
{{/each}}
</div>
{{/each}}

Loading…
Cancel
Save