Browse Source

UI-1624: Now render JSON in a more user-friendly way

4.3
Jean-Roch Maitre 10 years ago
parent
commit
555bc61161
2 changed files with 5 additions and 39 deletions
  1. +3
    -23
      submodules/callLogs/callLogs.js
  2. +2
    -16
      views/callLogs-detailsPopup.html

+ 3
- 23
submodules/callLogs/callLogs.js View File

@ -419,31 +419,11 @@ define(function(require){
cdrId: callLogId
},
success: function(data, status) {
function objToArray(obj, prefix) {
var prefix = prefix || "",
result = [];
_.each(obj, function(val, key) {
if(typeof val === "object") {
result = result.concat(objToArray(val, prefix+key+"."));
} else {
result.push({
key: prefix+key,
value: val
});
}
});
return result;
}
var template = $(monster.template(self, 'callLogs-detailsPopup'));
var detailsArray = objToArray(data.data);
detailsArray.sort(function(a, b) {
return a.key < b.key ? -1 : a.key > b.key ? 1 : 0;
})
monster.ui.renderJSON(data.data, template.find('#jsoneditor'));
monster.ui.dialog(
monster.template(self, 'callLogs-detailsPopup', { details: detailsArray }),
{ title: self.i18n.active().callLogs.detailsPopupTitle }
);
monster.ui.dialog(template, { title: self.i18n.active().callLogs.detailsPopupTitle });
},
error: function(data, status) {
monster.ui.alert('error', self.i18n.active().callLogs.alertMessages.getDetailsError);


+ 2
- 16
views/callLogs-detailsPopup.html View File

@ -1,18 +1,4 @@
<div id="call_logs_details_popup">
<table class="monster-details-table">
<thead>
<tr>
<td>{{i18n.callLogs.key}}</td>
<td>{{i18n.callLogs.value}}</td>
</tr>
</thead>
<tbody>
{{#each details}}
<tr>
<td title="{{this.key}}">{{this.key}}</td>
<td>{{this.value}}</td>
</tr>
{{/each}}
</tbody>
</table>
<div id="jsoneditor">
</div>
</div>

Loading…
Cancel
Save