|
|
|
@ -47,17 +47,17 @@ define(function(require) { |
|
|
|
|
|
|
|
self.getFaxData(function(results) { |
|
|
|
self.appFlags.faxboxes = _.keyBy(results.faxboxes, 'id'); |
|
|
|
|
|
|
|
console.log(_.size(self.appFlags.faxboxes)); |
|
|
|
var menus = [ |
|
|
|
{ |
|
|
|
tabs: [ |
|
|
|
{ |
|
|
|
text: self.i18n.active().fax.menuTitles.inbound, |
|
|
|
callback: self.renderInbound |
|
|
|
callback: self.renderNewInbound |
|
|
|
}, |
|
|
|
{ |
|
|
|
text: self.i18n.active().fax.menuTitles.outbound, |
|
|
|
callback: self.renderOutbound |
|
|
|
callback: self.renderNewOutbound |
|
|
|
}, |
|
|
|
{ |
|
|
|
text: self.i18n.active().fax.menuTitles.logs, |
|
|
|
@ -102,83 +102,31 @@ define(function(require) { |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
getStorage: function(callback) { |
|
|
|
renderNewInbound: function(pArgs) { |
|
|
|
var self = this; |
|
|
|
|
|
|
|
self.callApi({ |
|
|
|
resource: 'storage.get', |
|
|
|
data: { |
|
|
|
accountId: self.accountId, |
|
|
|
generateError: false |
|
|
|
}, |
|
|
|
success: function(data) { |
|
|
|
callback(data.data); |
|
|
|
}, |
|
|
|
error: function(data, error, globalHandler) { |
|
|
|
if (error.status === 404) { |
|
|
|
callback(undefined); |
|
|
|
} else { |
|
|
|
globalHandler(data); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
renderStorage: function(pArgs) { |
|
|
|
var self = this, |
|
|
|
args = pArgs || {}, |
|
|
|
parent = args.container || $('#fax_app_container .app-content-wrapper'); |
|
|
|
|
|
|
|
self.getStorage(function(storage) { |
|
|
|
var formattedData = self.storageFormatData(storage), |
|
|
|
template = $(monster.template(self, 'storage', formattedData)); |
|
|
|
|
|
|
|
self.storageBindEvents(template); |
|
|
|
|
|
|
|
monster.pub('common.storagePlanManager.render', { |
|
|
|
container: template.find('.control-container'), |
|
|
|
forceTypes: ['fax'], |
|
|
|
hideOtherTypes: true |
|
|
|
}); |
|
|
|
|
|
|
|
parent |
|
|
|
.fadeOut(function() { |
|
|
|
$(this) |
|
|
|
.empty() |
|
|
|
.append(template) |
|
|
|
.fadeIn(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
self.renderCommon(pArgs, 'inbound'); |
|
|
|
}, |
|
|
|
|
|
|
|
storageBindEvents: function(template) { |
|
|
|
renderNewOutbound: function(pArgs) { |
|
|
|
var self = this; |
|
|
|
}, |
|
|
|
|
|
|
|
storageFormatData: function(data) { |
|
|
|
return data; |
|
|
|
self.renderCommon(pArgs, 'outbound'); |
|
|
|
}, |
|
|
|
|
|
|
|
renderFaxes: function(pArgs) { |
|
|
|
renderCommon: function(pArgs, type) { |
|
|
|
var self = this, |
|
|
|
args = pArgs || {}, |
|
|
|
parent = args.container || $('#fax_app_container .app-content-wrapper'), |
|
|
|
dates = monster.util.getDefaultRangeDates(self.appFlags.ranges.default), |
|
|
|
fromDate = dates.from, |
|
|
|
toDate = dates.to, |
|
|
|
type = pArgs.type; |
|
|
|
|
|
|
|
var template = $(monster.template(self, type + '-faxes', { faxboxes: self.appFlags.faxboxes })); |
|
|
|
|
|
|
|
self.bindCommon(template); |
|
|
|
dataTemplate = { |
|
|
|
faxboxes: self.appFlags.faxboxes, |
|
|
|
count: _.size(self.appFlags.faxboxes) |
|
|
|
}, |
|
|
|
template = $(monster.template(self, type + '-faxes', dataTemplate)); |
|
|
|
|
|
|
|
if (type === 'inbound') { |
|
|
|
self.bindInbound(template); |
|
|
|
} else { |
|
|
|
self.bindOutbound(template); |
|
|
|
} |
|
|
|
self.initDatePickerFaxboxes(type, parent, template); |
|
|
|
|
|
|
|
self.initDatePicker(template, fromDate, toDate); |
|
|
|
self.bindFaxboxes(type, template); |
|
|
|
|
|
|
|
parent |
|
|
|
.fadeOut(function() { |
|
|
|
@ -187,174 +135,130 @@ define(function(require) { |
|
|
|
.append(template) |
|
|
|
.fadeIn(); |
|
|
|
}); |
|
|
|
|
|
|
|
self.displayFaxesList(type, template, fromDate, toDate); |
|
|
|
}, |
|
|
|
|
|
|
|
renderInbound: function(pArgs) { |
|
|
|
var self = this; |
|
|
|
|
|
|
|
pArgs.type = 'inbound'; |
|
|
|
|
|
|
|
self.renderFaxes(pArgs); |
|
|
|
}, |
|
|
|
|
|
|
|
renderOutbound: function(pArgs) { |
|
|
|
var self = this; |
|
|
|
|
|
|
|
pArgs.type = 'outbound'; |
|
|
|
|
|
|
|
self.renderFaxes(pArgs); |
|
|
|
}, |
|
|
|
|
|
|
|
displayFaxesList: function(type, container, fromDate, toDate, selectedFaxbox) { |
|
|
|
var self = this; |
|
|
|
|
|
|
|
container |
|
|
|
.find('.data-state') |
|
|
|
.hide(); |
|
|
|
|
|
|
|
container |
|
|
|
.find('.loading-state') |
|
|
|
.show(); |
|
|
|
initDatePickerFaxboxes: function(type, parent, template) { |
|
|
|
var self = this, |
|
|
|
dates = monster.util.getDefaultRangeDates(self.appFlags.ranges.default), |
|
|
|
fromDate = dates.from, |
|
|
|
toDate = dates.to; |
|
|
|
|
|
|
|
self.getTemplateData(type, container, fromDate, toDate, selectedFaxbox, function(template) { |
|
|
|
monster.ui.footable(template.find('.footable')); |
|
|
|
self.bindTableCommon(template); |
|
|
|
var optionsDatePicker = { |
|
|
|
container: template, |
|
|
|
range: self.appFlags.ranges.max |
|
|
|
}; |
|
|
|
|
|
|
|
container.removeClass('empty'); |
|
|
|
monster.ui.initRangeDatepicker(optionsDatePicker); |
|
|
|
|
|
|
|
container.find('.main-select-message').prop('checked', false); |
|
|
|
template.find('#startDate').datepicker('setDate', fromDate); |
|
|
|
template.find('#endDate').datepicker('setDate', toDate); |
|
|
|
|
|
|
|
container |
|
|
|
.find('.data-state') |
|
|
|
.empty() |
|
|
|
.append(template) |
|
|
|
.show(); |
|
|
|
template.find('.apply-filter').on('click', function(e) { |
|
|
|
var faxboxId = template.find('#select_faxbox').val(); |
|
|
|
|
|
|
|
container |
|
|
|
.find('.loading-state') |
|
|
|
.hide(); |
|
|
|
self.displayListFaxes(type, parent, faxboxId); |
|
|
|
}); |
|
|
|
|
|
|
|
if (selectedFaxbox && selectedFaxbox !== 'none') { |
|
|
|
container.find('#select_faxbox').val(selectedFaxbox).trigger('change'); |
|
|
|
} |
|
|
|
template.find('.toggle-filter').on('click', function() { |
|
|
|
template.find('.filter-by-date').toggleClass('active'); |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
getTemplateData: function(type, container, fromDate, toDate, selectedFaxbox, callback) { |
|
|
|
var self = this; |
|
|
|
|
|
|
|
if (type === 'inbound') { |
|
|
|
self.getInboundData(fromDate, toDate, function(data) { |
|
|
|
var dataTemplate = self.formatInboundData(data), |
|
|
|
template = $(monster.template(self, 'inbound-faxes-list', { faxes: dataTemplate })); |
|
|
|
bindFaxboxes: function(type, template) { |
|
|
|
var self = this, |
|
|
|
$selectFaxbox = template.find('.select-faxbox'); |
|
|
|
|
|
|
|
callback && callback(template); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
self.getOutboundData(fromDate, toDate, function(data) { |
|
|
|
var dataTemplate = self.formatOutboundData(data), |
|
|
|
template = $(monster.template(self, 'outbound-faxes-list', { faxes: dataTemplate })); |
|
|
|
monster.ui.tooltips(template); |
|
|
|
monster.ui.footable(template.find('.footable')); |
|
|
|
|
|
|
|
callback && callback(template); |
|
|
|
}); |
|
|
|
} |
|
|
|
}, |
|
|
|
$selectFaxbox.chosen({ search_contains: true, placeholder_text_single: self.i18n.active().fax.actionBar.selectFaxbox.none }); |
|
|
|
|
|
|
|
bindTableCommon: function(template) { |
|
|
|
var self = this; |
|
|
|
$selectFaxbox.on('change', function() { |
|
|
|
var faxboxId = $(this).val(); |
|
|
|
|
|
|
|
template.find('#fax_list').on('click', '.details-fax', function() { |
|
|
|
var $this = $(this), |
|
|
|
type = $this.parents('.faxes-table').data('type'), |
|
|
|
id = $(this).parents('tr').data('id'); |
|
|
|
template.find('.select-faxbox').val(faxboxId).trigger('chosen:updated'); |
|
|
|
|
|
|
|
self.renderDetailsFax(type, id); |
|
|
|
self.displayListFaxes(type, template, faxboxId); |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
renderDetailsFax: function(type, id) { |
|
|
|
var self = this; |
|
|
|
template.find('#refresh_faxbox').on('click', function() { |
|
|
|
var faxboxId = $selectFaxbox.val(); |
|
|
|
|
|
|
|
self.getFaxDetails(type, id, function(faxDetails) { |
|
|
|
var template = $(monster.template(self, 'fax-CDRDialog')); |
|
|
|
if (faxboxId !== 'none') { |
|
|
|
self.displayListFaxes(type, template, faxboxId); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
monster.ui.renderJSON(faxDetails, template.find('#jsoneditor')); |
|
|
|
template.find('#delete_faxes').on('click', function() { |
|
|
|
var faxboxId = $selectFaxbox.val(), |
|
|
|
listSelected = [], |
|
|
|
type = $(this).data('type'); |
|
|
|
|
|
|
|
monster.ui.dialog(template, { title: self.i18n.active().fax.CDRPopup.title }); |
|
|
|
}); |
|
|
|
}, |
|
|
|
template.find('.select-fax:checked').each(function(a, el) { |
|
|
|
listSelected.push($(el).data('id')); |
|
|
|
}); |
|
|
|
var content = monster.template(self, '!' + self.i18n.active().fax.deleteConfirm.content, { variable: listSelected.length }); |
|
|
|
|
|
|
|
initDatePicker: function(template, fromDate, toDate) { |
|
|
|
var self = this; |
|
|
|
monster.ui.confirm(content, function() { |
|
|
|
template.find('.select-fax:checked').each(function(a, el) { |
|
|
|
listSelected.push($(el).data('id')); |
|
|
|
}); |
|
|
|
|
|
|
|
var optionsDatePicker = { |
|
|
|
container: template, |
|
|
|
range: self.appFlags.ranges.max |
|
|
|
}; |
|
|
|
template.find('.data-state') |
|
|
|
.hide(); |
|
|
|
|
|
|
|
monster.ui.initRangeDatepicker(optionsDatePicker); |
|
|
|
template.find('.loading-state') |
|
|
|
.show(); |
|
|
|
|
|
|
|
template.find('#startDate').datepicker('setDate', fromDate); |
|
|
|
template.find('#endDate').datepicker('setDate', toDate); |
|
|
|
self.deleteFaxes(listSelected, type, function() { |
|
|
|
toastr.success(self.i18n.active().fax.deleteConfirm.success); |
|
|
|
|
|
|
|
template.find('.apply-filter').on('click', function(e) { |
|
|
|
self.refreshFaxes(template); |
|
|
|
self.displayListFaxes(type, template, faxboxId); |
|
|
|
}); |
|
|
|
}, undefined, { |
|
|
|
title: self.i18n.active().fax.deleteConfirm.title, |
|
|
|
confirmButtonText: self.i18n.active().fax.deleteConfirm.confirmButtonText, |
|
|
|
confirmButtonClass: 'monster-button-danger' |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
refreshFaxes: function(template) { |
|
|
|
var self = this, |
|
|
|
type = template.hasClass('inbound-faxes') ? 'inbound' : 'outbound', |
|
|
|
fromDate = template.find('input.filter-from').datepicker('getDate'), |
|
|
|
toDate = template.find('input.filter-to').datepicker('getDate'), |
|
|
|
selectedFaxbox = template.find('#select_faxbox').val(); |
|
|
|
|
|
|
|
self.displayFaxesList(type, template, fromDate, toDate, selectedFaxbox); |
|
|
|
}, |
|
|
|
template.find('#resend_faxes').on('click', function() { |
|
|
|
var faxboxId = $selectFaxbox.val(), |
|
|
|
listSelected = []; |
|
|
|
|
|
|
|
bindCommon: function(template) { |
|
|
|
var self = this, |
|
|
|
$selectFaxbox = template.find('#select_faxbox'); |
|
|
|
template.find('.select-fax:checked').each(function(a, el) { |
|
|
|
listSelected.push($(el).data('id')); |
|
|
|
}); |
|
|
|
|
|
|
|
monster.ui.tooltips(template); |
|
|
|
var content = monster.template(self, '!' + self.i18n.active().fax.resendConfirm.content, { variable: listSelected.length }); |
|
|
|
monster.ui.confirm(content, function() { |
|
|
|
self.resendFaxes(listSelected, function() { |
|
|
|
toastr.success(self.i18n.active().fax.resendConfirm.success); |
|
|
|
|
|
|
|
$selectFaxbox.chosen({ |
|
|
|
search_contains: true, |
|
|
|
width: '220px', |
|
|
|
placeholder_text_single: self.i18n.active().fax.actionBar.selectFax.none |
|
|
|
self.displayListFaxes(type, template, faxboxId); |
|
|
|
}); |
|
|
|
}, undefined, { |
|
|
|
title: self.i18n.active().fax.resendConfirm.title, |
|
|
|
confirmButtonText: self.i18n.active().fax.resendConfirm.confirmButtonText |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
$selectFaxbox.on('change', function(e) { |
|
|
|
var filtering = FooTable.get('#fax_list').use(FooTable.Filtering), |
|
|
|
filter = $(this).val(); |
|
|
|
|
|
|
|
if (filter === 'all') { |
|
|
|
filtering.removeFilter('faxbox_filter'); |
|
|
|
} else { |
|
|
|
filtering.addFilter('faxbox_filter', filter, [0]); |
|
|
|
} |
|
|
|
|
|
|
|
filtering.filter(); |
|
|
|
template.on('click', '.details-fax', function() { |
|
|
|
var id = $(this).parents('tr').data('id'); |
|
|
|
|
|
|
|
afterSelect(); |
|
|
|
self.renderDetailsFax(type, id); |
|
|
|
}); |
|
|
|
|
|
|
|
function afterSelect() { |
|
|
|
if (template.find('.select-fax:checked').length) { |
|
|
|
template.find('.hidable').removeClass('hidden'); |
|
|
|
template.find('.main-select-fax').prop('checked', true); |
|
|
|
template.find('.actionable').show(); |
|
|
|
} else { |
|
|
|
template.find('.hidable').addClass('hidden'); |
|
|
|
template.find('.main-select-fax').prop('checked', false); |
|
|
|
template.find('.actionable').hide(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
template.find('#refresh_faxbox').on('click', function() { |
|
|
|
self.refreshFaxes(template); |
|
|
|
}); |
|
|
|
|
|
|
|
template.on('click', '.select-fax', function() { |
|
|
|
afterSelect(); |
|
|
|
}); |
|
|
|
@ -385,91 +289,95 @@ define(function(require) { |
|
|
|
afterSelect(); |
|
|
|
}); |
|
|
|
|
|
|
|
template.find('#delete_faxes').on('click', function() { |
|
|
|
var listSelected = [], |
|
|
|
type = $(this).data('type'); |
|
|
|
|
|
|
|
template.find('.select-fax:checked').each(function(a, el) { |
|
|
|
listSelected.push($(el).data('id')); |
|
|
|
}); |
|
|
|
var content = monster.template(self, '!' + self.i18n.active().fax.deleteConfirm.content, { variable: listSelected.length }); |
|
|
|
template.on('click', '.select-line', function() { |
|
|
|
var cb = $(this).parents('.fax-row').find('.select-fax'); |
|
|
|
|
|
|
|
monster.ui.confirm(content, function() { |
|
|
|
template.find('.select-fax:checked').each(function(a, el) { |
|
|
|
listSelected.push($(el).data('id')); |
|
|
|
}); |
|
|
|
|
|
|
|
self.deleteFaxes(listSelected, type, function() { |
|
|
|
toastr.success(self.i18n.active().fax.deleteConfirm.success); |
|
|
|
|
|
|
|
self.refreshFaxes(template); |
|
|
|
}); |
|
|
|
}, undefined, { |
|
|
|
title: self.i18n.active().fax.deleteConfirm.title, |
|
|
|
confirmButtonText: self.i18n.active().fax.deleteConfirm.confirmButtonText, |
|
|
|
confirmButtonClass: 'monster-button-danger' |
|
|
|
}); |
|
|
|
cb.prop('checked', !cb.prop('checked')); |
|
|
|
afterSelect(); |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
bindInbound: function(template) { |
|
|
|
var self = this; |
|
|
|
}, |
|
|
|
displayListFaxes: function(type, container, faxboxId) { |
|
|
|
var self = this, |
|
|
|
fromDate = container.find('input.filter-from').datepicker('getDate'), |
|
|
|
toDate = container.find('input.filter-to').datepicker('getDate'), |
|
|
|
filterByDate = container.find('.filter-by-date').hasClass('active'); |
|
|
|
|
|
|
|
bindOutbound: function(template) { |
|
|
|
var self = this; |
|
|
|
container.removeClass('empty'); |
|
|
|
|
|
|
|
template.find('#resend_faxes').on('click', function() { |
|
|
|
var listSelected = []; |
|
|
|
template.find('.select-fax:checked').each(function(a, el) { |
|
|
|
listSelected.push($(el).data('id')); |
|
|
|
}); |
|
|
|
var content = monster.template(self, '!' + self.i18n.active().fax.resendConfirm.content, { variable: listSelected.length }); |
|
|
|
// Gives a better feedback to the user if we empty it as we click... showing the user something is happening.
|
|
|
|
container.find('.data-state') |
|
|
|
.hide(); |
|
|
|
|
|
|
|
monster.ui.confirm(content, function() { |
|
|
|
self.resendFaxes(listSelected, function() { |
|
|
|
toastr.success(self.i18n.active().fax.resendConfirm.success); |
|
|
|
container.find('.loading-state') |
|
|
|
.show(); |
|
|
|
|
|
|
|
self.refreshFaxes(template); |
|
|
|
}); |
|
|
|
}, undefined, { |
|
|
|
title: self.i18n.active().fax.resendConfirm.title, |
|
|
|
confirmButtonText: self.i18n.active().fax.resendConfirm.confirmButtonText |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
container.find('.hidable').addClass('hidden'); |
|
|
|
container.find('.main-select-fax').prop('checked', false); |
|
|
|
|
|
|
|
getInboundData: function(fromDate, toDate, callback) { |
|
|
|
var self = this; |
|
|
|
monster.ui.footable(container.find('.faxbox-table .footable'), { |
|
|
|
getData: function(filters, callback) { |
|
|
|
if (filterByDate) { |
|
|
|
filters = $.extend(true, filters, { |
|
|
|
created_from: monster.util.dateToBeginningOfGregorianDay(fromDate), |
|
|
|
created_to: monster.util.dateToEndOfGregorianDay(toDate) |
|
|
|
}); |
|
|
|
} |
|
|
|
// we do this to keep context
|
|
|
|
self.getRowsFaxes(type, filters, faxboxId, callback); |
|
|
|
}, |
|
|
|
afterInitialized: function() { |
|
|
|
container.find('.data-state') |
|
|
|
.show(); |
|
|
|
|
|
|
|
self.getInboundFaxes(fromDate, toDate, function(faxes) { |
|
|
|
callback && callback(faxes); |
|
|
|
container.find('.loading-state') |
|
|
|
.hide(); |
|
|
|
}, |
|
|
|
backendPagination: { |
|
|
|
enabled: false |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
getOutboundData: function(fromDate, toDate, callback) { |
|
|
|
getRowsFaxes: function(type, filters, faxboxId, callback) { |
|
|
|
var self = this; |
|
|
|
|
|
|
|
self.getOutboundFaxes(fromDate, toDate, function(faxes) { |
|
|
|
callback && callback(faxes); |
|
|
|
self.getFaxMessages(type, filters, faxboxId, function(data) { |
|
|
|
var formattedData = self.formatFaxData(data.data, type), |
|
|
|
dataTemplate = { |
|
|
|
faxes: formattedData |
|
|
|
}, |
|
|
|
$rows = $(monster.template(self, type + '-faxes-rows', dataTemplate)); |
|
|
|
|
|
|
|
callback && callback($rows, data); |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
formatInboundData: function(data) { |
|
|
|
getFaxMessages: function(type, filters, faxboxId, callback) { |
|
|
|
var self = this, |
|
|
|
formattedFaxes = self.formatFaxes(data, 'inbound'); |
|
|
|
resource = type === 'inbound' ? 'faxes.listInbound' : 'faxes.listOutbound'; |
|
|
|
|
|
|
|
return formattedFaxes; |
|
|
|
}, |
|
|
|
self.callApi({ |
|
|
|
resource: resource, |
|
|
|
data: { |
|
|
|
accountId: self.accountId, |
|
|
|
//faxboxId: faxboxId, API Doesn't allow filter here for now, we'll do it in JS instead
|
|
|
|
filters: filters |
|
|
|
}, |
|
|
|
success: function(data) { |
|
|
|
var formattedData = data, |
|
|
|
filteredData = _.filter(data.data, function(a) { |
|
|
|
return a.faxbox_id === faxboxId; |
|
|
|
}); |
|
|
|
|
|
|
|
formatOutboundData: function(data) { |
|
|
|
var self = this, |
|
|
|
formattedFaxes = self.formatFaxes(data, 'outbound'); |
|
|
|
formattedData.data = filteredData; |
|
|
|
|
|
|
|
return formattedFaxes; |
|
|
|
callback && callback(formattedData); |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
formatFaxes: function(data, type) { |
|
|
|
formatFaxData: function(data, type) { |
|
|
|
var self = this; |
|
|
|
|
|
|
|
_.each(data, function(fax) { |
|
|
|
@ -501,14 +409,56 @@ define(function(require) { |
|
|
|
return self.apiUrl + 'accounts/' + self.accountId + '/faxes/' + type + '/' + mediaId + '/attachment?auth_token=' + self.getAuthToken(); |
|
|
|
}, |
|
|
|
|
|
|
|
oldRenderLogs: function(pArgs) { |
|
|
|
renderDetailsFax: function(type, id) { |
|
|
|
var self = this; |
|
|
|
|
|
|
|
self.getFaxDetails(type, id, function(faxDetails) { |
|
|
|
var template = $(monster.template(self, 'fax-CDRDialog')); |
|
|
|
|
|
|
|
monster.ui.renderJSON(faxDetails, template.find('#jsoneditor')); |
|
|
|
|
|
|
|
monster.ui.dialog(template, { title: self.i18n.active().fax.CDRPopup.title }); |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
getStorage: function(callback) { |
|
|
|
var self = this; |
|
|
|
|
|
|
|
self.callApi({ |
|
|
|
resource: 'storage.get', |
|
|
|
data: { |
|
|
|
accountId: self.accountId, |
|
|
|
generateError: false |
|
|
|
}, |
|
|
|
success: function(data) { |
|
|
|
callback(data.data); |
|
|
|
}, |
|
|
|
error: function(data, error, globalHandler) { |
|
|
|
if (error.status === 404) { |
|
|
|
callback(undefined); |
|
|
|
} else { |
|
|
|
globalHandler(data); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
renderStorage: function(pArgs) { |
|
|
|
var self = this, |
|
|
|
args = pArgs || {}, |
|
|
|
parent = args.container || $('#fax_app_container .app-content-wrapper'), |
|
|
|
template = $(monster.template(self, 'logs-layout')); |
|
|
|
parent = args.container || $('#fax_app_container .app-content-wrapper'); |
|
|
|
|
|
|
|
self.logsInitTable(template, function() { |
|
|
|
self.logsBindEvents(template); |
|
|
|
self.getStorage(function(storage) { |
|
|
|
var formattedData = self.storageFormatData(storage), |
|
|
|
template = $(monster.template(self, 'storage', formattedData)); |
|
|
|
|
|
|
|
self.storageBindEvents(template); |
|
|
|
|
|
|
|
monster.pub('common.storagePlanManager.render', { |
|
|
|
container: template.find('.control-container'), |
|
|
|
forceTypes: ['fax'], |
|
|
|
hideOtherTypes: true |
|
|
|
}); |
|
|
|
|
|
|
|
parent |
|
|
|
.fadeOut(function() { |
|
|
|
@ -520,6 +470,14 @@ define(function(require) { |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
storageBindEvents: function(template) { |
|
|
|
var self = this; |
|
|
|
}, |
|
|
|
|
|
|
|
storageFormatData: function(data) { |
|
|
|
return data; |
|
|
|
}, |
|
|
|
|
|
|
|
renderLogs: function(pArgs) { |
|
|
|
var self = this, |
|
|
|
args = pArgs || {}, |
|
|
|
@ -638,44 +596,6 @@ define(function(require) { |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
getInboundFaxes: function(fromDate, toDate, callback) { |
|
|
|
var self = this; |
|
|
|
|
|
|
|
self.callApi({ |
|
|
|
resource: 'faxes.listInbound', |
|
|
|
data: { |
|
|
|
accountId: self.accountId, |
|
|
|
filters: { |
|
|
|
created_from: monster.util.dateToBeginningOfGregorianDay(fromDate), |
|
|
|
created_to: monster.util.dateToEndOfGregorianDay(toDate), |
|
|
|
paginate: false |
|
|
|
} |
|
|
|
}, |
|
|
|
success: function(data) { |
|
|
|
callback && callback(data.data); |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
getOutboundFaxes: function(fromDate, toDate, callback) { |
|
|
|
var self = this; |
|
|
|
|
|
|
|
self.callApi({ |
|
|
|
resource: 'faxes.listOutbound', |
|
|
|
data: { |
|
|
|
accountId: self.accountId, |
|
|
|
filters: { |
|
|
|
created_from: monster.util.dateToBeginningOfGregorianDay(fromDate), |
|
|
|
created_to: monster.util.dateToEndOfGregorianDay(toDate), |
|
|
|
paginate: false |
|
|
|
} |
|
|
|
}, |
|
|
|
success: function(data) { |
|
|
|
callback && callback(data.data); |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
listFaxboxes: function(callback) { |
|
|
|
var self = this; |
|
|
|
|
|
|
|
|