Browse Source

UI-2843: Fix ESLint erros/warnings (#32)

4.3
Joris Tirado 8 years ago
committed by GitHub
parent
commit
d5c32e991f
9 changed files with 848 additions and 904 deletions
  1. +4
    -4
      app.js
  2. +71
    -75
      submodules/callLogs/callLogs.js
  3. +36
    -37
      submodules/featureCodes/featureCodes.js
  4. +368
    -404
      submodules/groups/groups.js
  5. +274
    -287
      submodules/myOffice/myOffice.js
  6. +2
    -2
      submodules/numbers/numbers.js
  7. +4
    -4
      submodules/strategy/strategy.js
  8. +88
    -90
      submodules/vmboxes/vmboxes.js
  9. +1
    -1
      views/myOffice-layout.html

+ 4
- 4
app.js View File

@ -1,4 +1,4 @@
define(function(require){
define(function(require) {
var $ = require('jquery'),
_ = require('underscore'),
monster = require('monster');
@ -20,7 +20,7 @@ define(function(require){
css: [ 'app' ],
i18n: {
i18n: {
'en-US': { customCss: false },
'fr-FR': { customCss: false },
'ru-RU': { customCss: false },
@ -32,7 +32,7 @@ define(function(require){
subModules: ['devices', 'groups', 'numbers', 'strategy', 'callLogs', 'users', 'myOffice', 'featureCodes', 'vmboxes'],
load: function(callback){
load: function(callback) {
var self = this;
self.initApp(function() {
@ -49,7 +49,7 @@ define(function(require){
});
},
render: function(container){
render: function(container) {
var self = this,
parent = container || $('#monster_content'),
template = $(monster.template(self, 'app'));


+ 71
- 75
submodules/callLogs/callLogs.js View File

@ -1,4 +1,4 @@
define(function(require){
define(function(require) {
var $ = require('jquery'),
_ = require('underscore'),
monster = require('monster');
@ -22,7 +22,7 @@ define(function(require){
defaultDateRange = 1,
maxDateRange = 31;
if(!toDate && !fromDate) {
if (!toDate && !fromDate) {
var dates = monster.util.getDefaultRangeDates(defaultDateRange);
fromDate = dates.from;
toDate = dates.to;
@ -44,7 +44,7 @@ define(function(require){
template = $(monster.template(self, 'callLogs-layout', dataTemplate));
monster.ui.tooltips(template);
if(cdrs && cdrs.length) {
if (cdrs && cdrs.length) {
var cdrsTemplate = $(monster.template(self, 'callLogs-cdrsList', {cdrs: cdrs, showReport: monster.config.whitelabel.callReportEmail ? true : false}));
template.find('.call-logs-grid .grid-row-container')
.append(cdrsTemplate);
@ -60,7 +60,7 @@ define(function(require){
template.find('#startDate').datepicker('setDate', fromDate);
template.find('#endDate').datepicker('setDate', toDate);
if(!nextStartKey) {
if (!nextStartKey) {
template.find('.call-logs-loader').hide();
}
@ -90,11 +90,13 @@ define(function(require){
toDate = params.toDate,
startKey = params.nextStartKey;
setTimeout(function() { template.find('.search-query').focus() });
setTimeout(function() {
template.find('.search-query').focus();
});
template.find('.apply-filter').on('click', function(e) {
var fromDate = template.find('input.filter-from').datepicker("getDate"),
toDate = template.find('input.filter-to').datepicker("getDate");
var fromDate = template.find('input.filter-from').datepicker('getDate'),
toDate = template.find('input.filter-to').datepicker('getDate');
self.callLogsRenderContent(template.parents('.right-content'), fromDate, toDate, 'custom');
});
@ -107,15 +109,14 @@ define(function(require){
template.find('.fixed-ranges button').removeClass('active');
$this.addClass('active');
if(type !== 'custom') {
if (type !== 'custom') {
// Without this, it doesn't look like we're refreshing the data.
// GOod way to solve it would be to separate the filters from the call logs view, and only refresh the call logs.
template.find('.call-logs-content').empty();
var dates = self.callLogsGetFixedDatesFromType(type);
self.callLogsRenderContent(template.parents('.right-content'), dates.from, dates.to, type);
}
else {
} else {
template.find('.fixed-ranges-date').hide();
template.find('.custom-range').addClass('active');
}
@ -126,34 +127,33 @@ define(function(require){
toDateTimestamp = monster.util.dateToEndOfGregorianDay(toDate),
url = self.apiUrl + 'accounts/' + self.accountId + '/cdrs?created_from=' + fromDateTimestamp + '&created_to=' + toDateTimestamp + '&accept=text/csv&auth_token=' + self.getAuthToken();
window.open(url,'_blank');
window.open(url, '_blank');
});
template.find('.search-div input.search-query').on('keyup', function(e) {
if(template.find('.grid-row-container .grid-row').length > 0) {
var searchValue = $(this).val().replace(/\|/g,'').toLowerCase(),
if (template.find('.grid-row-container .grid-row').length > 0) {
var searchValue = $(this).val().replace(/\|/g, '').toLowerCase(),
matchedResults = false;
if(searchValue.length <= 0) {
if (searchValue.length <= 0) {
template.find('.grid-row-group').show();
matchedResults = true;
}
else {
} else {
_.each(cdrs, function(cdr) {
var searchString = (cdr.date + "|" + cdr.fromName + "|" + cdr.fromNumber + "|" + cdr.toName + "|"
+ cdr.toNumber + "|" + cdr.hangupCause + "|" + cdr.id).toLowerCase(),
rowGroup = template.find('.grid-row.main-leg[data-id="'+cdr.id+'"]').parents('.grid-row-group');
var searchString = (cdr.date + '|' + cdr.fromName + '|' + cdr.fromNumber + '|' + cdr.toName + '|'
+ cdr.toNumber + '|' + cdr.hangupCause + '|' + cdr.id).toLowerCase(),
rowGroup = template.find('.grid-row.main-leg[data-id="' + cdr.id + '"]').parents('.grid-row-group');
if(searchString.indexOf(searchValue) >= 0) {
if (searchString.indexOf(searchValue) >= 0) {
matchedResults = true;
rowGroup.show();
} else {
rowGroup.hide();
}
})
});
}
if(matchedResults) {
if (matchedResults) {
template.find('.grid-row.no-match').hide();
} else {
template.find('.grid-row.no-match').show();
@ -167,7 +167,7 @@ define(function(require){
callId = $this.data('id'),
extraLegs = rowGroup.find('.extra-legs');
if(rowGroup.hasClass('open')) {
if (rowGroup.hasClass('open')) {
rowGroup.removeClass('open');
extraLegs.slideUp();
} else {
@ -179,7 +179,7 @@ define(function(require){
rowGroup.addClass('open');
extraLegs.slideDown();
if(!extraLegs.hasClass('data-loaded')) {
if (!extraLegs.hasClass('data-loaded')) {
self.callLogsGetLegs(callId, function(cdrs) {
var formattedCdrs = self.callLogsFormatCdrs(cdrs);
@ -203,16 +203,21 @@ define(function(require){
});
function loadMoreCdrs() {
var loaderDiv = template.find('.call-logs-loader');
if(startKey) {
var loaderDiv = template.find('.call-logs-loader'),
cdrsTemplate;
if (startKey) {
loaderDiv.toggleClass('loading');
loaderDiv.find('.loading-message > i').toggleClass('fa-spin');
self.callLogsGetCdrs(fromDate, toDate, function(newCdrs, nextStartKey) {
newCdrs = self.callLogsFormatCdrs(newCdrs);
cdrsTemplate = $(monster.template(self, 'callLogs-cdrsList', {cdrs: newCdrs, showReport: monster.config.whitelabel.callReportEmail ? true : false}));
cdrsTemplate = $(monster.template(self, 'callLogs-cdrsList', {
cdrs: newCdrs,
showReport: monster.config.whitelabel.callReportEmail ? true : false
}));
startKey = nextStartKey;
if(!startKey) {
if (!startKey) {
template.find('.call-logs-loader').hide();
}
@ -220,13 +225,12 @@ define(function(require){
cdrs = cdrs.concat(newCdrs);
var searchInput = template.find('.search-div input.search-query');
if(searchInput.val()) {
if (searchInput.val()) {
searchInput.keyup();
}
loaderDiv.toggleClass('loading');
loaderDiv.find('.loading-message > i').toggleClass('fa-spin');
}, startKey);
} else {
loaderDiv.hide();
@ -235,8 +239,8 @@ define(function(require){
template.find('.call-logs-grid').on('scroll', function(e) {
var $this = $(this);
if($this.scrollTop() === $this[0].scrollHeight - $this.innerHeight()) {
loadMoreCdrs();
if ($this.scrollTop() === $this[0].scrollHeight - $this.innerHeight()) {
loadMoreCdrs();
}
});
@ -251,22 +255,15 @@ define(function(require){
from = new Date(),
to = new Date();
switch(type) {
case 'today':
break;
case 'thisWeek':
// First we need to know how many days separate today and monday.
if (type === 'thisWeek') {
// First we need to know how many days separate today and monday.
// Since Sunday is 0 and Monday is 1, we do this little substraction to get the result.
var day = from.getDay(),
countDaysFromMonday = (day||7) - 1;
from.setDate(from.getDate() - countDaysFromMonday);
break;
case 'thisMonth':
from.setDate(1);
break;
default:
break;
var day = from.getDay(),
countDaysFromMonday = (day || 7) - 1;
from.setDate(from.getDate() - countDaysFromMonday);
} else if (type === 'thisMonth') {
from.setDate(1);
}
return {
@ -285,8 +282,8 @@ define(function(require){
'page_size': 50
};
if(pageStartKey) {
filters['start_key'] = pageStartKey;
if (pageStartKey) {
filters.start_key = pageStartKey;
}
self.callApi({
@ -296,7 +293,7 @@ define(function(require){
filters: filters
},
success: function(data, status) {
callback(data.data, data['next_start_key']);
callback(data.data, data.next_start_key);
}
});
},
@ -323,18 +320,17 @@ define(function(require){
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'),
time = monster.util.toFriendlyDate(date, 'time'),
durationMin = parseInt(cdr.duration_seconds/60).toString(),
durationSec = (cdr.duration_seconds % 60 < 10 ? "0" : "") + (cdr.duration_seconds % 60),
durationMin = parseInt(cdr.duration_seconds / 60).toString(),
durationSec = (cdr.duration_seconds % 60 < 10 ? '0' : '') + (cdr.duration_seconds % 60),
hangupI18n = self.i18n.active().hangupCauses,
hangupHelp = '',
isOutboundCall = "authorizing_id" in cdr && cdr.authorizing_id.length > 0;
isOutboundCall = 'authorizing_id' in cdr && cdr.authorizing_id.length > 0;
// Only display help if it's in the i18n.
if(hangupI18n.hasOwnProperty(cdr.hangup_cause)) {
if(isOutboundCall && hangupI18n[cdr.hangup_cause].hasOwnProperty('outbound')) {
if (hangupI18n.hasOwnProperty(cdr.hangup_cause)) {
if (isOutboundCall && hangupI18n[cdr.hangup_cause].hasOwnProperty('outbound')) {
hangupHelp += hangupI18n[cdr.hangup_cause].outbound;
}
else if(!isOutboundCall && hangupI18n[cdr.hangup_cause].hasOwnProperty('inbound')) {
} else if (!isOutboundCall && hangupI18n[cdr.hangup_cause].hasOwnProperty('inbound')) {
hangupHelp += hangupI18n[cdr.hangup_cause].inbound;
}
}
@ -348,29 +344,29 @@ define(function(require){
fromName: cdr.caller_id_name,
fromNumber: cdr.caller_id_number || cdr.from.replace(/@.*/, ''),
toName: cdr.callee_id_name,
toNumber: cdr.callee_id_number || ("request" in cdr) ? cdr.request.replace(/@.*/, '') : cdr.to.replace(/@.*/, ''),
duration: durationMin + ":" + durationSec,
toNumber: cdr.callee_id_number || ('request' in cdr) ? cdr.request.replace(/@.*/, '') : cdr.to.replace(/@.*/, ''),
duration: durationMin + ':' + durationSec,
hangupCause: cdr.hangup_cause,
hangupHelp: hangupHelp,
isOutboundCall: isOutboundCall,
mailtoLink: "mailto:" + monster.config.whitelabel.callReportEmail
+ "?subject=Call Report: " + cdr.call_id
+ "&body=Please describe the details of the issue:%0D%0A%0D%0A"
+ "%0D%0A____________________________________________________________%0D%0A"
+ "%0D%0AAccount ID: " + self.accountId
+ "%0D%0AFrom (Name): " + (cdr.caller_id_name || "")
+ "%0D%0AFrom (Number): " + (cdr.caller_id_number || cdr.from.replace(/@.*/, ''))
+ "%0D%0ATo (Name): " + (cdr.callee_id_name || "")
+ "%0D%0ATo (Number): " + (cdr.callee_id_number || ("request" in cdr) ? cdr.request.replace(/@.*/, '') : cdr.to.replace(/@.*/, ''))
+ "%0D%0ADate: " + shortDate
+ "%0D%0ADuration: " + durationMin + ":" + durationSec
+ "%0D%0AHangup Cause: " + (cdr.hangup_cause || "")
+ "%0D%0ACall ID: " + cdr.call_id
+ "%0D%0AOther Leg Call ID: " + (cdr.other_leg_call_id || "")
+ "%0D%0AHandling Server: " + (cdr.media_server || "")
mailtoLink: 'mailto:' + monster.config.whitelabel.callReportEmail
+ '?subject=Call Report: ' + cdr.call_id
+ '&body=Please describe the details of the issue:%0D%0A%0D%0A'
+ '%0D%0A____________________________________________________________%0D%0A'
+ '%0D%0AAccount ID: ' + self.accountId
+ '%0D%0AFrom (Name): ' + (cdr.caller_id_name || '')
+ '%0D%0AFrom (Number): ' + (cdr.caller_id_number || cdr.from.replace(/@.*/, ''))
+ '%0D%0ATo (Name): ' + (cdr.callee_id_name || '')
+ '%0D%0ATo (Number): ' + (cdr.callee_id_number || ('request' in cdr) ? cdr.request.replace(/@.*/, '') : cdr.to.replace(/@.*/, ''))
+ '%0D%0ADate: ' + shortDate
+ '%0D%0ADuration: ' + durationMin + ':' + durationSec
+ '%0D%0AHangup Cause: ' + (cdr.hangup_cause || '')
+ '%0D%0ACall ID: ' + cdr.call_id
+ '%0D%0AOther Leg Call ID: ' + (cdr.other_leg_call_id || '')
+ '%0D%0AHandling Server: ' + (cdr.media_server || '')
};
if(cdr.hasOwnProperty('channel_created_time')) {
if (cdr.hasOwnProperty('channel_created_time')) {
call.channelCreatedTime = cdr.channel_created_time;
}


+ 36
- 37
submodules/featureCodes/featureCodes.js View File

@ -1,4 +1,4 @@
define(function(require){
define(function(require) {
var $ = require('jquery'),
_ = require('underscore'),
monster = require('monster'),
@ -20,42 +20,42 @@ define(function(require){
'qubicle logout'
],
call_forward: [
"call_forward[action=activate]",
"call_forward[action=deactivate]",
"call_forward[action=toggle]",
"call_forward[action=update]",
"call_forward[action=on_busy_enable]",
"call_forward[action=on_busy_disable]",
"call_forward[action=no_answer_enable]",
"call_forward[action=no_answer_disable]"
'call_forward[action=activate]',
'call_forward[action=deactivate]',
'call_forward[action=toggle]',
'call_forward[action=update]',
'call_forward[action=on_busy_enable]',
'call_forward[action=on_busy_disable]',
'call_forward[action=no_answer_enable]',
'call_forward[action=no_answer_disable]'
],
hotdesk: [
"hotdesk[action=login]",
"hotdesk[action=logout]",
"hotdesk[action=toggle]"
'hotdesk[action=login]',
'hotdesk[action=logout]',
'hotdesk[action=toggle]'
],
parking: [
"park_and_retrieve",
"valet",
"retrieve"
'park_and_retrieve',
'valet',
'retrieve'
],
do_not_disturb: [
"donotdisturb[action=\"enable\"]",
"donotdisturb[action=\"disable\"]",
"donotdisturb[action=\"toggle\"]"
'donotdisturb[action="enable"]',
'donotdisturb[action="disable"]',
'donotdisturb[action="toggle"]'
],
misc: [
"voicemail[action=check]",
"voicemail[action=\"direct\"]",
"intercom",
"privacy[mode=full]",
"directory",
"time",
"call_waiting[action=enable]",
"call_waiting[action=disable]",
"sound_test_service",
"call_recording",
"move"
'voicemail[action=check]',
'voicemail[action="direct"]',
'intercom',
'privacy[mode=full]',
'directory',
'time',
'call_waiting[action=enable]',
'call_waiting[action=disable]',
'sound_test_service',
'call_recording',
'move'
]
},
@ -104,19 +104,19 @@ define(function(require){
_.each(featureCodeData, function(callflow) {
// Some old callflows have been created with the feature code key, so we had the check to make sure they also have a name associated
if(callflow.featurecode.hasOwnProperty('name')) {
if (callflow.featurecode.hasOwnProperty('name')) {
var category = 'misc',
hasStar = (callflow.hasOwnProperty('numbers') && callflow.numbers.length && callflow.numbers[0].substr(0,1) === '*') || (callflow.hasOwnProperty('patterns') && callflow.patterns.length && callflow.patterns[0].substr(0,3) === '^\\*');
hasStar = (callflow.hasOwnProperty('numbers') && callflow.numbers.length && callflow.numbers[0].substr(0, 1) === '*') || (callflow.hasOwnProperty('patterns') && callflow.patterns.length && callflow.patterns[0].substr(0, 3) === '^\\*');
_.find(self.categories, function(cat, key) {
if(cat.indexOf(callflow.featurecode.name) >= 0) {
if (cat.indexOf(callflow.featurecode.name) >= 0) {
category = key;
return true;
}
return false;
return false;
});
if(!featureCodes.hasOwnProperty(category)) {
if (!featureCodes.hasOwnProperty(category)) {
featureCodes[category] = {
category: self.i18n.active().featureCodes.categories[category],
codes: []
@ -126,7 +126,7 @@ define(function(require){
featureCodes[category].codes.push({
key: callflow.featurecode.name,
name: self.i18n.active().featureCodes.labels[callflow.featurecode.name] || callflow.featurecode.name,
number: callflow.featurecode.number ? callflow.featurecode.number.replace(/\\/g,'') : '',
number: callflow.featurecode.number ? callflow.featurecode.number.replace(/\\/g, '') : '',
hasStar: hasStar
});
}
@ -144,8 +144,7 @@ define(function(require){
featureCodesBindEvents: function(args) {
var self = this,
parent = args.parent,
template = args.template,
featureCodes = args.featureCodes;
template = args.template;
template.find('.main-number-link').on('click', function(e) {
e.preventDefault();


+ 368
- 404
submodules/groups/groups.js
File diff suppressed because it is too large
View File


+ 274
- 287
submodules/myOffice/myOffice.js View File

@ -1,4 +1,4 @@
define(function(require){
define(function(require) {
var $ = require('jquery'),
_ = require('underscore'),
monster = require('monster'),
@ -27,15 +27,15 @@ define(function(require){
},
chartColors: [
"#B588B9", // Purple ~ Mauve
"#698BF7", // Purple ~ Dark Blue
"#009AD6", // Blue
"#6CC5E9", // Light Blue
"#719B11", // Dark Green
"#BDE55F", // Light Green
"#F1E87C", // Pale Yellow
"#EF8F25", // Orange
"#6F7C7D" // Grey
'#B588B9', // Purple ~ Mauve
'#698BF7', // Purple ~ Dark Blue
'#009AD6', // Blue
'#6CC5E9', // Light Blue
'#719B11', // Dark Green
'#BDE55F', // Light Green
'#F1E87C', // Pale Yellow
'#EF8F25', // Orange
'#6F7C7D' // Grey
],
/* My Office */
@ -59,8 +59,8 @@ define(function(require){
faxingNumbers: myOfficeData.faxingNumbers || [],
faxNumbers: myOfficeData.faxNumbers || [],
topMessage: myOfficeData.topMessage,
devicesList: _.toArray(myOfficeData.devicesData).sort(function(a, b) { return b.count - a.count ; }),
assignedNumbersList: _.toArray(myOfficeData.assignedNumbersData).sort(function(a, b) { return b.count - a.count ; }),
devicesList: _.toArray(myOfficeData.devicesData).sort(function(a, b) { return b.count - a.count; }),
assignedNumbersList: _.toArray(myOfficeData.assignedNumbersData).sort(function(a, b) { return b.count - a.count; }),
// numberTypesList: _.toArray(myOfficeData.numberTypesData).sort(function(a, b) { return b.count - a.count ; }),
classifiedNumbers: myOfficeData.classifiedNumbers,
directoryUsers: myOfficeData.directory.users && myOfficeData.directory.users.length || 0,
@ -72,52 +72,52 @@ define(function(require){
segmentShowStroke: false,
// segmentStrokeWidth: 1,
animationSteps: 50,
animationEasing: "easeOutCirc",
animationEasing: 'easeOutCirc',
percentageInnerCutout: 60
},
devicesChart = new Chart(template.find('#dashboard_devices_chart').get(0).getContext("2d")).Doughnut(
myOfficeData.devicesData.totalCount > 0 ?
$.map(myOfficeData.devicesData, function(val) {
devicesChart = new Chart(template.find('#dashboard_devices_chart').get(0).getContext('2d')).Doughnut(
myOfficeData.devicesData.totalCount > 0
? $.map(myOfficeData.devicesData, function(val) {
return typeof val === 'object' ? {
value: val.count,
color: val.color
} : null;
}).sort(function(a, b) { return b.value - a.value ; }) :
[{ value:1, color:"#DDD" }],
}).sort(function(a, b) { return b.value - a.value; })
: [{ value: 1, color: '#DDD' }],
chartOptions
),
assignedNumbersChart = new Chart(template.find('#dashboard_assigned_numbers_chart').get(0).getContext("2d")).Doughnut(
myOfficeData.assignedNumbersData.totalCount > 0 ?
$.map(myOfficeData.assignedNumbersData, function(val) {
assignedNumbersChart = new Chart(template.find('#dashboard_assigned_numbers_chart').get(0).getContext('2d')).Doughnut(
myOfficeData.assignedNumbersData.totalCount > 0
? $.map(myOfficeData.assignedNumbersData, function(val) {
return typeof val === 'object' ? {
value: val.count,
color: val.color
} : null;
}).sort(function(a, b) { return b.value - a.value ; }) :
[{ value:1, color:"#DDD" }],
}).sort(function(a, b) { return b.value - a.value; })
: [{ value: 1, color: '#DDD' }],
chartOptions
),
numberTypesChart = new Chart(template.find('#dashboard_number_types_chart').get(0).getContext("2d")).Doughnut(
numberTypesChart = new Chart(template.find('#dashboard_number_types_chart').get(0).getContext('2d')).Doughnut(
// $.map(myOfficeData.numberTypesData, function(val) {
// return {
// value: val.count,
// color: val.color
// };
// }).sort(function(a, b) { return b.value - a.value ; }),
myOfficeData.classifiedNumbers.length > 0 ?
$.map(myOfficeData.classifiedNumbers, function(val, index) {
myOfficeData.classifiedNumbers.length > 0
? $.map(myOfficeData.classifiedNumbers, function(val, index) {
return typeof val === 'object' ? {
value: val.count,
color: val.color
} : null;
}) :
[{ value:1, color:"#DDD" }],
})
: [{ value: 1, color: '#DDD' }],
chartOptions
);
// Trick to adjust the vertical positioning of the number types legend
if(myOfficeData.classifiedNumbers.length <= 3) {
template.find('.number-types-legend').addClass('size-'+myOfficeData.classifiedNumbers.length);
if (myOfficeData.classifiedNumbers.length <= 3) {
template.find('.number-types-legend').addClass('size-' + myOfficeData.classifiedNumbers.length);
}
self.myOfficeBindEvents({
@ -138,13 +138,13 @@ define(function(require){
// we check if we have to display the walkthrough:
// first make sure it's not a trial, then
// only show it if we've already shown the walkthrough in myaccount
// only show it if we've already shown the walkthrough in myaccount
myOfficeCheckWalkthrough: function() {
var self = this;
if(!monster.apps.auth.currentAccount.hasOwnProperty('trial_time_left')) {
if (!monster.apps.auth.currentAccount.hasOwnProperty('trial_time_left')) {
monster.pub('myaccount.hasToShowWalkthrough', function(response) {
if(response === false) {
if (response === false) {
self.myOfficeWalkthroughRender();
}
});
@ -156,7 +156,7 @@ define(function(require){
// If it's not a trial, we show the Walkthrough the first time
// because if it's a trial, myOfficeWalkthroughRender will be called by another event
if(!monster.apps.auth.currentAccount.hasOwnProperty('trial_time_left')) {
if (!monster.apps.auth.currentAccount.hasOwnProperty('trial_time_left')) {
self.myOfficeWalkthroughRender();
}
},
@ -171,7 +171,7 @@ define(function(require){
function() {
self.myOfficeCreateMainVMBox(function(vmbox) {
callback(vmbox);
})
});
}
);
},
@ -205,14 +205,13 @@ define(function(require){
data: {
accountId: self.accountId,
filters: {
'filter_type':'mainVMBox'
filter_type: 'mainVMBox'
}
},
success: function(vmboxes) {
if(vmboxes.data.length > 0) {
if (vmboxes.data.length > 0) {
hasVMBoxCallback && hasVMBoxCallback(vmboxes[0]);
}
else {
} else {
noVMBoxCallback && noVMBoxCallback();
}
}
@ -223,202 +222,200 @@ define(function(require){
var self = this;
monster.parallel({
account: function(parallelCallback) {
self.callApi({
resource: 'account.get',
data: {
accountId: self.accountId
},
success: function(dataAccount) {
parallelCallback && parallelCallback(null, dataAccount.data);
}
});
},
mainVoicemailBox: function(parallelCallback) {
self.myOfficeCreateMainVMBoxIfMissing(function(vmbox) {
parallelCallback(null, vmbox);
});
},
users: function(parallelCallback) {
self.callApi({
resource: 'user.list',
data: {
accountId: self.accountId,
filters: {
paginate: 'false'
}
},
success: function(dataUsers) {
parallelCallback && parallelCallback(null, dataUsers.data);
}
});
},
devices: function(parallelCallback) {
self.callApi({
resource: 'device.list',
data: {
accountId: self.accountId,
filters: {
paginate: 'false'
}
},
success: function(data) {
parallelCallback && parallelCallback(null, data.data);
}
});
},
devicesStatus: function(parallelCallback) {
self.callApi({
resource: 'device.getStatus',
data: {
accountId: self.accountId,
filters: {
paginate: 'false'
}
},
success: function(data) {
parallelCallback && parallelCallback(null, data.data);
account: function(parallelCallback) {
self.callApi({
resource: 'account.get',
data: {
accountId: self.accountId
},
success: function(dataAccount) {
parallelCallback && parallelCallback(null, dataAccount.data);
}
});
},
mainVoicemailBox: function(parallelCallback) {
self.myOfficeCreateMainVMBoxIfMissing(function(vmbox) {
parallelCallback(null, vmbox);
});
},
users: function(parallelCallback) {
self.callApi({
resource: 'user.list',
data: {
accountId: self.accountId,
filters: {
paginate: 'false'
}
});
},
numbers: function(parallelCallback) {
self.callApi({
resource: 'numbers.list',
data: {
accountId: self.accountId,
filters: {
paginate: 'false'
}
},
success: function(data) {
parallelCallback && parallelCallback(null, data.data.numbers);
},
success: function(dataUsers) {
parallelCallback && parallelCallback(null, dataUsers.data);
}
});
},
devices: function(parallelCallback) {
self.callApi({
resource: 'device.list',
data: {
accountId: self.accountId,
filters: {
paginate: 'false'
}
});
},
channels: function(parallelCallback) {
self.callApi({
resource: 'channel.list',
data: {
accountId: self.accountId,
filters: {
paginate: 'false'
}
},
success: function(data) {
parallelCallback && parallelCallback(null, data.data);
},
success: function(data) {
parallelCallback && parallelCallback(null, data.data);
}
});
},
devicesStatus: function(parallelCallback) {
self.callApi({
resource: 'device.getStatus',
data: {
accountId: self.accountId,
filters: {
paginate: 'false'
}
});
},
callflows: function(parallelCallback) {
self.callApi({
resource: 'callflow.list',
data: {
filters: {
has_type: 'type',
paginate: 'false'
},
accountId: self.accountId
},
success: function(data) {
parallelCallback && parallelCallback(null, data.data);
},
success: function(data) {
parallelCallback && parallelCallback(null, data.data);
}
});
},
numbers: function(parallelCallback) {
self.callApi({
resource: 'numbers.list',
data: {
accountId: self.accountId,
filters: {
paginate: 'false'
}
});
},
classifiers: function(parallelCallback) {
self.callApi({
resource: 'numbers.listClassifiers',
data: {
accountId: self.accountId
},
success: function(data) {
parallelCallback && parallelCallback(null, data.data);
},
success: function(data) {
parallelCallback && parallelCallback(null, data.data.numbers);
}
});
},
channels: function(parallelCallback) {
self.callApi({
resource: 'channel.list',
data: {
accountId: self.accountId,
filters: {
paginate: 'false'
}
});
},
directory: function(parallelCallback) {
self.callApi({
resource: 'directory.list',
data: {
accountId: self.accountId
},
success: function(data) {
parallelCallback && parallelCallback(null, data.data);
}
});
},
callflows: function(parallelCallback) {
self.callApi({
resource: 'callflow.list',
data: {
filters: {
has_type: 'type',
paginate: 'false'
},
success: function(data, status) {
var mainDirectory = _.find(data.data, function(val) {
return val.name === 'SmartPBX Directory';
accountId: self.accountId
},
success: function(data) {
parallelCallback && parallelCallback(null, data.data);
}
});
},
classifiers: function(parallelCallback) {
self.callApi({
resource: 'numbers.listClassifiers',
data: {
accountId: self.accountId
},
success: function(data) {
parallelCallback && parallelCallback(null, data.data);
}
});
},
directory: function(parallelCallback) {
self.callApi({
resource: 'directory.list',
data: {
accountId: self.accountId
},
success: function(data, status) {
var mainDirectory = _.find(data.data, function(val) {
return val.name === 'SmartPBX Directory';
});
if (mainDirectory) {
self.callApi({
resource: 'directory.get',
data: {
accountId: self.accountId,
directoryId: mainDirectory.id
},
success: function(data, status) {
parallelCallback && parallelCallback(null, data.data);
},
error: function(data, status) {
parallelCallback && parallelCallback(null, {});
}
});
if(mainDirectory) {
self.callApi({
resource: 'directory.get',
data: {
accountId: self.accountId,
directoryId: mainDirectory.id
},
success: function(data, status) {
parallelCallback && parallelCallback(null, data.data);
},
error: function(data, status) {
parallelCallback && parallelCallback(null, {});
}
});
} else {
parallelCallback && parallelCallback(null, {});
}
},
error: function(data, status) {
} else {
parallelCallback && parallelCallback(null, {});
}
});
}
},
function(error, results) {
callback && callback(self.myOfficeFormatData(results));
},
error: function(data, status) {
parallelCallback && parallelCallback(null, {});
}
});
}
);
}, function(error, results) {
callback && callback(self.myOfficeFormatData(results));
});
},
myOfficeFormatData: function(data) {
var self = this,
devices = {
"sip_device": {
sip_device: {
label: self.i18n.active().devices.types.sip_device,
count: 0,
color: self.chartColors[5]
},
"cellphone": {
cellphone: {
label: self.i18n.active().devices.types.cellphone,
count: 0,
color: self.chartColors[3]
},
"smartphone": {
smartphone: {
label: self.i18n.active().devices.types.smartphone,
count: 0,
color: self.chartColors[2]
},
"mobile": {
mobile: {
label: self.i18n.active().devices.types.mobile,
count: 0,
color: self.chartColors[1]
},
"softphone": {
softphone: {
label: self.i18n.active().devices.types.softphone,
count: 0,
color: self.chartColors[0]
},
"landline": {
landline: {
label: self.i18n.active().devices.types.landline,
count: 0,
color: self.chartColors[6]
},
"fax": {
fax: {
label: self.i18n.active().devices.types.fax,
count: 0,
color: self.chartColors[7]
},
"ata": {
ata: {
label: self.i18n.active().devices.types.ata,
count: 0,
color: self.chartColors[8]
},
"sip_uri": {
sip_uri: {
label: self.i18n.active().devices.types.sip_uri,
count: 0,
color: self.chartColors[4]
@ -426,12 +423,12 @@ define(function(require){
totalCount: 0
},
assignedNumbers = {
"spare": {
spare: {
label: self.i18n.active().myOffice.numberChartLegend.spare,
count: 0,
color: self.chartColors[8]
},
"assigned": {
assigned: {
label: self.i18n.active().myOffice.numberChartLegend.assigned,
count: 0,
color: self.chartColors[3]
@ -439,20 +436,20 @@ define(function(require){
totalCount: 0
},
// numberTypes = {
// "local": {
// local: {
// label: self.i18n.active().myOffice.numberChartLegend.local,
// count: 0,
// color: "#6cc5e9"
// color: '#6cc5e9'
// },
// "tollfree": {
// tollfree: {
// label: self.i18n.active().myOffice.numberChartLegend.tollfree,
// count: 0,
// color: "#bde55f"
// color: '#bde55f'
// },
// "international": {
// international: {
// label: self.i18n.active().myOffice.numberChartLegend.international,
// count: 0,
// color: "#b588b9"
// color: '#b588b9'
// }
// },
totalConferences = 0,
@ -462,11 +459,11 @@ define(function(require){
_.each(data.numbers, function(numData, num) {
_.find(data.classifiers, function(classifier, classifierKey) {
if(!(classifierKey in classifierRegexes)) {
if (!(classifierKey in classifierRegexes)) {
classifierRegexes[classifierKey] = new RegExp(classifier.regex);
}
if(classifierRegexes[classifierKey].test(num)) {
if(classifierKey in classifiedNumbers) {
if (classifierRegexes[classifierKey].test(num)) {
if (classifierKey in classifiedNumbers) {
classifiedNumbers[classifierKey] ++;
} else {
classifiedNumbers[classifierKey] = 1;
@ -479,19 +476,19 @@ define(function(require){
});
data.classifiedNumbers = _.map(classifiedNumbers, function(val, key) {
return {
return {
key: key,
label: key in data.classifiers ? data.classifiers[key].friendly_name : key,
count: val
};
}).sort(function(a,b) { return b.count - a.count });
}).sort(function(a, b) { return b.count - a.count; });
var maxLength = self.chartColors.length;
if(data.classifiedNumbers.length > maxLength) {
data.classifiedNumbers[maxLength-1].key = 'merged_others';
data.classifiedNumbers[maxLength-1].label = 'Others';
while(data.classifiedNumbers.length > maxLength) {
data.classifiedNumbers[maxLength-1].count += data.classifiedNumbers.pop().count;
if (data.classifiedNumbers.length > maxLength) {
data.classifiedNumbers[maxLength - 1].key = 'merged_others';
data.classifiedNumbers[maxLength - 1].label = 'Others';
while (data.classifiedNumbers.length > maxLength) {
data.classifiedNumbers[maxLength - 1].count += data.classifiedNumbers.pop().count;
}
}
@ -500,19 +497,19 @@ define(function(require){
});
_.each(data.devices, function(val) {
if(val.device_type in devices) {
if (val.device_type in devices) {
devices[val.device_type].count++;
devices.totalCount++;
} else {
console.log('Unknown device type: '+val.device_type);
console.log('Unknown device type: ' + val.device_type);
}
});
_.each(data.numbers, function(val) {
if("used_by" in val && val["used_by"].length > 0) {
assignedNumbers["assigned"].count++;
if ('used_by' in val && val.used_by.length > 0) {
assignedNumbers.assigned.count++;
} else {
assignedNumbers["spare"].count++;
assignedNumbers.spare.count++;
}
assignedNumbers.totalCount++;
@ -521,29 +518,29 @@ define(function(require){
});
_.each(data.users, function(val) {
if(val.features.indexOf("conferencing") >= 0) {
if (val.features.indexOf('conferencing') >= 0) {
totalConferences++;
}
});
_.each(data.callflows, function(val) {
var numberArrayName = '';
if(val.type === "main" && val.name === "MainCallflow") {
if (val.type === 'main' && val.name === 'MainCallflow') {
numberArrayName = 'mainNumbers';
} else if(val.type === "conference" && val.name === "MainConference") {
} else if (val.type === 'conference' && val.name === 'MainConference') {
numberArrayName = 'confNumbers';
} else if (val.type === "faxing" && val.name === "MainFaxing") {
numberArrayName = "faxingNumbers";
} else if (val.type === 'faxing' && val.name === 'MainFaxing') {
numberArrayName = 'faxingNumbers';
}
if(numberArrayName.length > 0) {
if(!(numberArrayName in data)) { data[numberArrayName] = []; }
if (numberArrayName.length > 0) {
if (!(numberArrayName in data)) { data[numberArrayName] = []; }
_.each(val.numbers, function(num) {
if(num !== '0' && num !== 'undefined' && num !== 'undefinedconf' && num !== 'undefinedfaxing') {
if (num !== '0' && num !== 'undefined' && num !== 'undefinedconf' && num !== 'undefinedfaxing') {
var number = {
number: num
};
if(num in data.numbers) {
if (num in data.numbers) {
number.features = data.numbers[num].features;
}
data[numberArrayName].push(number);
@ -553,30 +550,28 @@ define(function(require){
});
_.each(data.channels, function(val) {
if(channelsArray.indexOf(val.bridge_id) < 0) {
if (channelsArray.indexOf(val.bridge_id) < 0) {
channelsArray.push(val.bridge_id);
}
});
if( data.mainNumbers && data.mainNumbers.length > 0 ) {
if (data.mainNumbers && data.mainNumbers.length > 0) {
var hasValidCallerId = monster.util.isNumberFeatureEnabled('cnam') === false || data.account.hasOwnProperty('caller_id') && data.account.caller_id.hasOwnProperty('emergency') && data.account.caller_id.emergency.hasOwnProperty('number') && data.numbers.hasOwnProperty(data.account.caller_id.emergency.number),
hasValidE911 = monster.util.isNumberFeatureEnabled('e911') === false || data.account.hasOwnProperty('caller_id') && data.account.caller_id.hasOwnProperty('emergency') && data.account.caller_id.emergency.hasOwnProperty('number') && data.numbers.hasOwnProperty(data.account.caller_id.emergency.number) && data.numbers[data.account.caller_id.emergency.number].features.indexOf('e911') >= 0;
if (!hasValidCallerId && !hasValidE911) {
data.topMessage = {
class: 'btn-danger',
cssClass: 'btn-danger',
message: self.i18n.active().myOffice.missingCnamE911Message
};
}
else if (!hasValidCallerId) {
} else if (!hasValidCallerId) {
data.topMessage = {
class: 'btn-danger',
cssClass: 'btn-danger',
message: self.i18n.active().myOffice.missingCnamMessage
};
}
else if (!hasValidE911) {
} else if (!hasValidE911) {
data.topMessage = {
class: 'btn-danger',
cssClass: 'btn-danger',
message: self.i18n.active().myOffice.missingE911Message
};
}
@ -588,8 +583,8 @@ define(function(require){
// data.numberTypesData = numberTypes;
data.totalConferences = totalConferences;
if(data.directory && data.directory.id) {
data.directoryLink = self.apiUrl + 'accounts/' + self.accountId +'/directories/' + data.directory.id + '?accept=pdf&auth_token=' + self.getAuthToken();
if (data.directory && data.directory.id) {
data.directoryLink = self.apiUrl + 'accounts/' + self.accountId + '/directories/' + data.directory.id + '?accept=pdf&auth_token=' + self.getAuthToken();
}
return data;
@ -607,20 +602,20 @@ define(function(require){
subcategory = $this.data('subcategory');
$('.category').removeClass('active');
switch(category) {
case "users":
switch (category) {
case 'users':
$('.category#users').addClass('active');
monster.pub('voip.users.render', { parent: parent });
break;
case "devices":
case 'devices':
$('.category#devices').addClass('active');
monster.pub('voip.devices.render', { parent: parent });
break;
case "numbers":
case 'numbers':
$('.category#numbers').addClass('active');
monster.pub('voip.numbers.render', { parent: parent });
break;
case "strategy":
case 'strategy':
$('.category#strategy').addClass('active');
monster.pub('voip.strategy.render', { parent: parent, openElement: subcategory });
break;
@ -664,15 +659,15 @@ define(function(require){
},
popupTemplate = $(monster.template(self, 'myOffice-musicOnHoldPopup', templateData)),
popup = monster.ui.dialog(popupTemplate, {
title: self.i18n.active().myOffice.musicOnHold.title,
position: ['center', 20]
});
title: self.i18n.active().myOffice.musicOnHold.title,
position: ['center', 20]
});
self.myOfficeMusicOnHoldPopupBindEvents({
popupTemplate: popupTemplate,
popup: popup,
account: account
})
});
});
},
@ -687,12 +682,13 @@ define(function(require){
popupTemplate.find('.upload-div').slideUp(function() {
popupTemplate.find('.upload-toggle').removeClass('active');
});
if(newMedia) {
if (newMedia) {
var mediaSelect = popupTemplate.find('.media-dropdown');
mediaSelect.append('<option value="'+newMedia.id+'">'+newMedia.name+'</option>');
mediaSelect.append('<option value="' + newMedia.id + '">' + newMedia.name + '</option>');
mediaSelect.val(newMedia.id);
}
};
},
mediaToUpload;
popupTemplate.find('.upload-input').fileUpload({
inputOnly: true,
@ -704,7 +700,7 @@ define(function(require){
mediaToUpload = results[0];
},
error: function(errors) {
if(errors.hasOwnProperty('size') && errors.size.length > 0) {
if (errors.hasOwnProperty('size') && errors.size.length > 0) {
monster.ui.alert(self.i18n.active().myOffice.musicOnHold.fileTooBigAlert);
}
popupTemplate.find('.upload-div input').val('');
@ -717,7 +713,7 @@ define(function(require){
});
popupTemplate.find('.upload-toggle').on('click', function() {
if($(this).hasClass('active')) {
if ($(this).hasClass('active')) {
popupTemplate.find('.upload-div').stop(true, true).slideUp();
} else {
popupTemplate.find('.upload-div').stop(true, true).slideDown();
@ -729,7 +725,7 @@ define(function(require){
});
popupTemplate.find('.upload-submit').on('click', function() {
if(mediaToUpload) {
if (mediaToUpload) {
self.callApi({
resource: 'media.create',
data: {
@ -737,7 +733,7 @@ define(function(require){
data: {
streamable: true,
name: mediaToUpload.name,
media_source: "upload",
media_source: 'upload',
description: mediaToUpload.name
}
},
@ -775,11 +771,11 @@ define(function(require){
popupTemplate.find('.save').on('click', function() {
var selectedMedia = popupTemplate.find('.media-dropdown option:selected').val();
if(!('music_on_hold' in account)) {
if (!('music_on_hold' in account)) {
account.music_on_hold = {};
}
if(selectedMedia && selectedMedia.length > 0) {
if (selectedMedia && selectedMedia.length > 0) {
account.music_on_hold = {
media_id: selectedMedia
};
@ -856,11 +852,11 @@ define(function(require){
callback = function(features) {
popupTemplate.find('.number-feature').hide();
_.each(features, function(featureName) {
popupTemplate.find('.number-feature[data-feature="'+ featureName + '"]').slideDown();
popupTemplate.find('.number-feature[data-feature="' + featureName + '"]').slideDown();
});
};
if(number) {
if (number) {
self.myOfficeGetNumber(number, function(numberData) {
var availableFeatures = numberData.hasOwnProperty('_read_only') && numberData._read_only.hasOwnProperty('features_available') ? numberData._read_only.features_available : [],
activatedFeatures = numberData.hasOwnProperty('_read_only') && numberData._read_only.hasOwnProperty('features') ? numberData._read_only.features : [],
@ -868,41 +864,39 @@ define(function(require){
hasE911 = allFeatures.indexOf('e911') >= 0,
hasCNAM = allFeatures.indexOf('cnam') >= 0;
if(hasE911) {
if (hasE911) {
if (monster.util.isNumberFeatureEnabled('e911')) {
allowedFeatures.push('e911');
if("e911" in numberData) {
if ('e911' in numberData) {
emergencyZipcodeInput.val(numberData.e911.postal_code);
emergencyAddress1Input.val(numberData.e911.street_address);
emergencyAddress2Input.val(numberData.e911.extended_address);
emergencyCityInput.val(numberData.e911.locality);
emergencyStateInput.val(numberData.e911.region);
} else {
emergencyZipcodeInput.val("");
emergencyAddress1Input.val("");
emergencyAddress2Input.val("");
emergencyCityInput.val("");
emergencyStateInput.val("");
emergencyZipcodeInput.val('');
emergencyAddress1Input.val('');
emergencyAddress2Input.val('');
emergencyCityInput.val('');
emergencyStateInput.val('');
}
}
}
if(hasCNAM) {
if (hasCNAM) {
allowedFeatures.push('cnam');
if("cnam" in numberData) {
if ('cnam' in numberData) {
callerIdNameInput.val(numberData.cnam.display_name);
}
else {
callerIdNameInput.val("");
} else {
callerIdNameInput.val('');
}
}
callback && callback(allowedFeatures);
});
}
else {
} else {
callback && callback(allowedFeatures);
}
};
@ -911,10 +905,6 @@ define(function(require){
popup.dialog('close').remove();
});
popupTemplate.find('.upload-cancel').on('click', function() {
closeUploadDiv();
});
callerIdNumberSelect.on('change', function() {
loadNumberDetails($(this).val(), popupTemplate);
});
@ -931,7 +921,7 @@ define(function(require){
if (!_.isEmpty(results)) {
var length = results[0].address_components.length;
emergencyCityInput.val(results[0].address_components[1].long_name);
emergencyStateInput.val(results[0].address_components[length-2].short_name);
emergencyStateInput.val(results[0].address_components[length - 2].short_name);
}
}
});
@ -948,7 +938,7 @@ define(function(require){
});
});
},
setNumberData = function (e911Data) {
setNumberData = function(e911Data) {
var callerIdName = callerIdNameInput.val(),
setCNAM = popupTemplate.find('.number-feature[data-feature="cnam"]').is(':visible'),
setE911 = popupTemplate.find('.number-feature[data-feature="e911"]').is(':visible');
@ -963,19 +953,17 @@ define(function(require){
});
self.myOfficeGetNumber(callerIdNumber, function(numberData) {
if(setCNAM && callerIdName.length) {
if (setCNAM && callerIdName.length) {
$.extend(true, numberData, { cnam: { display_name: callerIdName } });
}
else {
} else {
delete numberData.cnam;
}
if(setE911) {
if (setE911) {
$.extend(true, numberData, {
e911: e911Data
});
}
else {
} else {
delete numberData.e911;
}
@ -990,19 +978,16 @@ define(function(require){
e911Form = popupTemplate.find('.emergency-form > form');
}
if(callerIdNumber) {
if (callerIdNumber) {
if (monster.util.isNumberFeatureEnabled('e911')) {
if (monster.ui.valid(e911Form)) {
var e911Data = monster.ui.getFormData(e911Form[0]);
setNumberData(e911Data);
}
else {
} else {
monster.ui.alert(self.i18n.active().myOffice.callerId.mandatoryE911Alert);
}
}
else {
} else {
setNumberData();
}
} else {
@ -1018,7 +1003,7 @@ define(function(require){
myOfficeWalkthroughRender: function() {
var self = this;
if(self.isActive()) {
if (self.isActive()) {
// First we check if the user hasn't seen the walkthrough already
// if he hasn't we show the walkthrough, and once they're done with it, we update their user doc so they won't see the walkthrough again
self.myOfficeHasWalkthrough(function() {
@ -1033,7 +1018,7 @@ define(function(require){
var self = this,
flag = self.uiFlags.user.get('showDashboardWalkthrough');
if(flag !== false) {
if (flag !== false) {
callback && callback();
}
},
@ -1042,7 +1027,7 @@ define(function(require){
myOfficeShowWalkthrough: function(callback) {
var self = this,
mainTemplate = $('#voip_container'),
steps = [
steps = [
{
element: mainTemplate.find('.category#myOffice')[0],
intro: self.i18n.active().myOffice.walkthrough.steps['1'],
@ -1124,7 +1109,9 @@ define(function(require){
resource: 'media.list',
data: {
accountId: self.accountId,
filters: { 'key_missing':'type' }
filters: {
key_missing: 'type'
}
},
success: function(medias) {
callback && callback(medias.data);


+ 2
- 2
submodules/numbers/numbers.js View File

@ -1,4 +1,4 @@
define(function(require){
define(function(require) {
var $ = require('jquery'),
monster = require('monster');
@ -11,7 +11,7 @@ define(function(require){
'voip.numbers.render': 'numbersRender'
},
numbersRender: function(args){
numbersRender: function(args) {
var self = this,
parent = args.parent || $('#ws_content'),
callback = args.callback;


+ 4
- 4
submodules/strategy/strategy.js View File

@ -351,7 +351,7 @@ define(function(require) {
popup.dialog('close');
} else {
self.strategyChangeEmergencyCallerId(number, function() {
toastr.success(monster.template(self, '!'+ self.i18n.active().strategy.updateE911Dialog.success, { number: monster.util.formatPhoneNumber(number) }));
toastr.success(monster.template(self, '!' + self.i18n.active().strategy.updateE911Dialog.success, { number: monster.util.formatPhoneNumber(number) }));
popup.dialog('close');
});
}
@ -420,7 +420,7 @@ define(function(require) {
// Update data we have about features for main numbers
_.each(templateNumbers, function(dataLoop, index) {
if(dataLoop.number.id === number) {
if (dataLoop.number.id === number) {
dataLoop.number.features = features;
}
});
@ -430,7 +430,7 @@ define(function(require) {
}), function(number) {
return number.number.id;
});
var currAcc = monster.apps.auth.currentAccount,
hasEmergencyCallerId = currAcc.hasOwnProperty('caller_id') && currAcc.caller_id.hasOwnProperty('emergency') && currAcc.caller_id.emergency.hasOwnProperty('number') && currAcc.caller_id.emergency.number !== '',
hasE911Feature = (features || []).indexOf('e911') >= 0;
@ -445,7 +445,7 @@ define(function(require) {
}
} else {
// If they removed e911 from their current emergency caller id number, then we let them select the new one from the list of numbers with e911 configured
if(hasEmergencyCallerId && currAcc.caller_id.emergency.number === number) {
if (hasEmergencyCallerId && currAcc.caller_id.emergency.number === number) {
self.strategyShowE911Choices(undefined, e911Numbers);
}
}


+ 88
- 90
submodules/vmboxes/vmboxes.js View File

@ -1,4 +1,4 @@
define(function(require){
define(function(require) {
var $ = require('jquery'),
_ = require('underscore'),
monster = require('monster'),
@ -39,7 +39,7 @@ define(function(require){
.empty()
.append(template);
if(_voicemailId) {
if (_voicemailId) {
var row = parent.find('.grid-row[data-id=' + _voicemailId + ']');
monster.ui.highlight(row, {
@ -47,7 +47,7 @@ define(function(require){
});
}
if (dataTemplate.vmboxes.length == 0 ) {
if (dataTemplate.vmboxes.length === 0) {
parent.find('.no-vmboxes-row').css('display', 'block');
} else {
parent.find('.no-vmboxes-row').css('display', 'none');
@ -84,7 +84,7 @@ define(function(require){
row.data('search').toLowerCase().indexOf(searchString) < 0 ? row.hide() : row.show();
});
if(rows.size() > 0) {
if (rows.size() > 0) {
rows.is(':visible') ? emptySearch.hide() : emptySearch.show();
}
});
@ -103,13 +103,13 @@ define(function(require){
vmboxesMigrateData: function(data) {
var self = this;
if(data.hasOwnProperty('notify_email_address')) {
if (data.hasOwnProperty('notify_email_address')) {
data.notify_email_addresses = data.notify_email_address;
}
return data;
},
vmboxesRenderVmbox: function(data, callback) {
var self = this,
mode = data.id ? 'edit' : 'add',
@ -121,7 +121,7 @@ define(function(require){
callback && callback(vmbox);
},
afterDelete: function(vmbox) {
afterDelete: function() {
popup.dialog('close').remove();
self.vmboxesRender();
@ -132,8 +132,9 @@ define(function(require){
};
_.each(data.notify_email_addresses, function(recipient) {
templateVMBox.find('.saved-entities')
.append(monster.template(self, 'vmboxes-emailRow', { name: recipient }));
templateVMBox
.find('.saved-entities')
.append(monster.template(self, 'vmboxes-emailRow', { name: recipient }));
});
self.vmboxesEditBindEvents(templateVMBox, data, callbacks);
@ -159,13 +160,16 @@ define(function(require){
monster.ui.tabs(templateVMBox);
timezone.populateDropdown(templateVMBox.find('#timezone'), data.timezone||'inherit', {inherit: self.i18n.active().defaultTimezone});
templateVMBox.find('#timezone').chosen({search_contains: true, width: "220px"});
timezone.populateDropdown(templateVMBox.find('#timezone'), data.timezone || 'inherit', {inherit: self.i18n.active().defaultTimezone});
templateVMBox.find('#timezone').chosen({
search_contains: true,
width: '220px'
});
monster.ui.tooltips(templateVMBox);
templateVMBox.find('.actions .save').on('click', function() {
if(monster.ui.valid(vmboxForm)) {
if (monster.ui.valid(vmboxForm)) {
var dataToSave = self.vmboxesMergeData(data, templateVMBox);
self.vmboxesSaveVmbox(dataToSave, function(data) {
@ -197,16 +201,17 @@ define(function(require){
event.preventDefault();
var inputName = templateVMBox.find('#entity_name'),
name = inputName.val();
name = inputName.val(),
templateFlag = monster.template(self, 'vmboxes-emailRow', { name: name });
templateVMBox.find('.saved-entities').prepend(templateFlag);
inputName.val('')
.focus();
inputName
.val('')
.focus();
};
templateVMBox.find('.entity-wrapper.placeholder:not(.active)').on('click', function(){
templateVMBox.find('.entity-wrapper.placeholder:not(.active)').on('click', function() {
$(this).addClass('active');
templateVMBox.find('#entity_name').focus();
});
@ -227,7 +232,7 @@ define(function(require){
templateVMBox.find('#entity_name').on('keypress', function(e) {
var code = e.keyCode || e.which;
if(code === 13) {;
if (code === 13) {
addEntity(e);
}
});
@ -245,9 +250,9 @@ define(function(require){
greetingContainer.find('.upload-div').slideUp(function() {
greetingContainer.find('.upload-toggle').removeClass('active');
});
if(newMedia) {
if (newMedia) {
var mediaSelect = greetingContainer.find('.media-dropdown');
mediaSelect.append('<option value="'+newMedia.id+'">'+newMedia.name+'</option>');
mediaSelect.append('<option value="' + newMedia.id + '">' + newMedia.name + '</option>');
mediaSelect.val(newMedia.id);
}
};
@ -262,7 +267,7 @@ define(function(require){
mediaToUpload = results[0];
},
error: function(errors) {
if(errors.hasOwnProperty('size') && errors.size.length > 0) {
if (errors.hasOwnProperty('size') && errors.size.length > 0) {
monster.ui.alert(self.i18n.active().vmboxes.popupSettings.greeting.fileTooBigAlert);
}
greetingContainer.find('.upload-div input').val('');
@ -271,7 +276,7 @@ define(function(require){
});
greetingContainer.find('.upload-toggle').on('click', function() {
if($(this).hasClass('active')) {
if ($(this).hasClass('active')) {
greetingContainer.find('.upload-div').stop(true, true).slideUp();
} else {
greetingContainer.find('.upload-div').stop(true, true).slideDown();
@ -283,7 +288,7 @@ define(function(require){
});
greetingContainer.find('.upload-submit').on('click', function() {
if(mediaToUpload) {
if (mediaToUpload) {
self.callApi({
resource: 'media.create',
data: {
@ -291,7 +296,7 @@ define(function(require){
data: {
streamable: true,
name: mediaToUpload.name,
media_source: "upload",
media_source: 'upload',
description: mediaToUpload.name
}
},
@ -340,20 +345,20 @@ define(function(require){
mergedData.not_configurable = !formData.extra.configurable;
if(mergedData.pin === '') {
if (mergedData.pin === '') {
delete mergedData.pin;
}
// Delete data that is obsolete (migrated to notify_email_addresses)
if(mergedData.hasOwnProperty('notify_email_address')) {
if (mergedData.hasOwnProperty('notify_email_address')) {
delete mergedData.notify_email_address;
}
if(mergedData.timezone && mergedData.timezone === 'inherit') {
if (mergedData.timezone && mergedData.timezone === 'inherit') {
delete mergedData.timezone;
}
if(mergedData.media && mergedData.media.unavailable === 'none') {
if (mergedData.media && mergedData.media.unavailable === 'none') {
delete mergedData.media.unavailable;
}
@ -393,15 +398,14 @@ define(function(require){
mapUsers[user.id] = user;
});
formattedData.vmboxes.sort(function(a,b) {
formattedData.vmboxes.sort(function(a, b) {
return parseInt(a.mailbox) > parseInt(b.mailbox) ? 1 : -1;
});
_.each(formattedData.vmboxes, function(vmbox) {
if(vmbox.hasOwnProperty('owner_id') && mapUsers.hasOwnProperty(vmbox.owner_id)) {
if (vmbox.hasOwnProperty('owner_id') && mapUsers.hasOwnProperty(vmbox.owner_id)) {
vmbox.friendlyOwnerName = mapUsers[vmbox.owner_id].first_name + ' ' + mapUsers[vmbox.owner_id].last_name;
}
else {
} else {
vmbox.friendlyOwnerName = '-';
}
});
@ -430,34 +434,31 @@ define(function(require){
var self = this;
monster.parallel({
vmbox: function(callback) {
if(id) {
self.vmboxesGetVmbox(id, function(dataVmbox) {
callback(null, dataVmbox);
});
}
else {
callback(null, {});
}
},
mediaList: function(callback) {
self.callApi({
resource: 'media.list',
data: {
accountId: self.accountId
},
success: function(data) {
callback(null, data.data);
}
vmbox: function(callback) {
if (id) {
self.vmboxesGetVmbox(id, function(dataVmbox) {
callback(null, dataVmbox);
});
} else {
callback(null, {});
}
},
function(error, results) {
var formattedData = self.vmboxesFormatData(results);
callback && callback(formattedData);
mediaList: function(callback) {
self.callApi({
resource: 'media.list',
data: {
accountId: self.accountId
},
success: function(data) {
callback(null, data.data);
}
});
}
);
}, function(error, results) {
var formattedData = self.vmboxesFormatData(results);
callback && callback(formattedData);
});
},
vmboxesGetVmbox: function(voicemailId, callbackSuccess, callbackError) {
@ -481,10 +482,9 @@ define(function(require){
vmboxesSaveVmbox: function(vmboxData, callback) {
var self = this;
if(vmboxData.id) {
if (vmboxData.id) {
self.vmboxesUpdateVmbox(vmboxData, callback);
}
else {
} else {
self.vmboxesCreateVmbox(vmboxData, callback);
}
},
@ -527,41 +527,39 @@ define(function(require){
var self = this;
monster.parallel({
users: function(callback) {
self.callApi({
resource: 'user.list',
data: {
accountId: self.accountId,
filters: {
paginate: 'false'
}
},
success: function(dataUsers) {
callback && callback(null, dataUsers.data);
}
});
},
vmboxes: function(callback) {
self.callApi({
resource: 'voicemail.list',
data: {
accountId: self.accountId,
filters: {
paginate: 'false'
}
},
success: function(datavmboxes) {
callback(null, datavmboxes.data);
users: function(callback) {
self.callApi({
resource: 'user.list',
data: {
accountId: self.accountId,
filters: {
paginate: 'false'
}
});
}
},
success: function(dataUsers) {
callback && callback(null, dataUsers.data);
}
});
},
function(err, results) {
self.vmboxesFormatListData(results);
callback && callback(results);
vmboxes: function(callback) {
self.callApi({
resource: 'voicemail.list',
data: {
accountId: self.accountId,
filters: {
paginate: 'false'
}
},
success: function(datavmboxes) {
callback(null, datavmboxes.data);
}
});
}
);
}, function(err, results) {
self.vmboxesFormatListData(results);
callback && callback(results);
});
}
};


+ 1
- 1
views/myOffice-layout.html View File

@ -23,7 +23,7 @@
<div class="dashboard-content">
{{#if topMessage}}
<div class="dashboard-top-message {{topMessage.class}}">
<div class="dashboard-top-message {{topMessage.cssClass}}">
<i class="fa fa-exclamation-triangle"></i>{{topMessage.message}}<!-- {{i18n.myOffice.missingE911Message}} -->
</div>
{{/if}}


Loading…
Cancel
Save