From d5c32e991ff427fbceff9a0b3518026e557fb3bf Mon Sep 17 00:00:00 2001 From: Joris Tirado Date: Thu, 27 Jul 2017 15:54:59 -0700 Subject: [PATCH] UI-2843: Fix ESLint erros/warnings (#32) --- app.js | 8 +- submodules/callLogs/callLogs.js | 146 +++-- submodules/featureCodes/featureCodes.js | 73 ++- submodules/groups/groups.js | 772 +++++++++++------------- submodules/myOffice/myOffice.js | 561 +++++++++-------- submodules/numbers/numbers.js | 4 +- submodules/strategy/strategy.js | 8 +- submodules/vmboxes/vmboxes.js | 178 +++--- views/myOffice-layout.html | 2 +- 9 files changed, 848 insertions(+), 904 deletions(-) diff --git a/app.js b/app.js index 952add8..e39b2ca 100644 --- a/app.js +++ b/app.js @@ -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')); diff --git a/submodules/callLogs/callLogs.js b/submodules/callLogs/callLogs.js index 5840abb..11e327a 100644 --- a/submodules/callLogs/callLogs.js +++ b/submodules/callLogs/callLogs.js @@ -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; } diff --git a/submodules/featureCodes/featureCodes.js b/submodules/featureCodes/featureCodes.js index 2b6525b..c46e1a3 100644 --- a/submodules/featureCodes/featureCodes.js +++ b/submodules/featureCodes/featureCodes.js @@ -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(); diff --git a/submodules/groups/groups.js b/submodules/groups/groups.js index ed3856f..e9fcca0 100644 --- a/submodules/groups/groups.js +++ b/submodules/groups/groups.js @@ -1,8 +1,7 @@ -define(function(require){ +define(function(require) { var $ = require('jquery'), _ = require('underscore'), monster = require('monster'), - timezone = require('monster-timezone'), toastr = require('toastr'); var app = { @@ -21,8 +20,7 @@ define(function(require){ args = args || {}, parent = args.parent || $('.right-content'), _groupId = args.groupId, - callback = args.callback, - noGroup = true; + callback = args.callback; self.groupsRemoveOverlay(); @@ -31,7 +29,7 @@ define(function(require){ return !callflow.hasOwnProperty('type'); }); - if(hasOldData) { + if (hasOldData) { monster.ui.alert('error', self.i18n.active().groups.outdatedGroupsError); } else { var dataTemplate = self.groupsFormatListData(data), @@ -53,13 +51,13 @@ define(function(require){ self.groupsCheckWalkthrough(); - if(_groupId) { - var cells = parent.find('.grid-row[data-id=' + _groupId + '] .grid-cell'); + if (_groupId) { + var cells = parent.find('.grid-row[data-id=' + _groupId + '] .grid-cell'); monster.ui.highlight(cells); } - if ( countGroups === 0 ) { + if (countGroups === 0) { parent.find('.grid-row.title').css('display', 'none'); parent.find('.no-groups-row').css('display', 'block'); } else { @@ -84,8 +82,8 @@ define(function(require){ }); _.each(data.callflows, function(callflow) { - if(callflow.group_id in mapGroups) { - if(callflow.type === 'userGroup') { + if (callflow.group_id in mapGroups) { + if (callflow.type === 'userGroup') { var listExtensions = [], listNumbers = []; @@ -95,7 +93,7 @@ define(function(require){ mapGroups[callflow.group_id].extra.listCallerId = []; - if(listExtensions.length > 0) { + if (listExtensions.length > 0) { mapGroups[callflow.group_id].extra.extension = listExtensions[0]; _.each(listExtensions, function(number) { @@ -104,7 +102,7 @@ define(function(require){ } mapGroups[callflow.group_id].extra.additionalExtensions = listExtensions.length > 1; - if(listNumbers.length > 0) { + if (listNumbers.length > 0) { mapGroups[callflow.group_id].extra.mainNumber = listNumbers[0]; _.each(listNumbers, function(number) { @@ -113,7 +111,7 @@ define(function(require){ } mapGroups[callflow.group_id].extra.additionalNumbers = listNumbers.length > 1; mapGroups[callflow.group_id].extra.callflowId = callflow.id; - } else if(callflow.type === 'baseGroup') { + } else if (callflow.type === 'baseGroup') { mapGroups[callflow.group_id].extra.baseCallflowId = callflow.id; } } @@ -123,7 +121,7 @@ define(function(require){ arrayGroups.push(group); }); - arrayGroups.sort(function(a,b) { + arrayGroups.sort(function(a, b) { return a.name > b.name ? 1 : -1; }); @@ -166,7 +164,7 @@ define(function(require){ }; _.each(result.mapFeatures, function(val, key) { - if(('features' in group && group.features.indexOf(key) >= 0) // If data from view + if (('features' in group && group.features.indexOf(key) >= 0) // If data from view || ('smartpbx' in group && key in group.smartpbx && group.smartpbx[key].enabled)) { // If data from document val.active = true; result.hasFeatures = true; @@ -193,11 +191,11 @@ define(function(require){ row = cell.parents('.grid-row'), groupId = row.data('id'); - template.find('.edit-groups').slideUp("400", function() { + template.find('.edit-groups').slideUp(400, function() { $(this).empty(); }); - if(cell.hasClass('active')) { + if (cell.hasClass('active')) { template.find('.grid-cell').removeClass('active'); template.find('.grid-row').removeClass('active'); @@ -212,8 +210,7 @@ define(function(require){ 'z-index': '0', 'border-top-color': '#a6a7a9' }); - } - else { + } else { template.find('.grid-cell').removeClass('active'); template.find('.grid-row').removeClass('active'); cell.toggleClass('active'); @@ -403,22 +400,17 @@ define(function(require){ }, groupsGetTemplate: function(type, groupId, callbackAfterData) { - var self = this, - template; + var self = this; - if(type === 'name') { + if (type === 'name') { self.groupsGetNameTemplate(groupId, callbackAfterData); - } - else if(type === 'numbers') { + } else if (type === 'numbers') { self.groupsGetNumbersTemplate(groupId, callbackAfterData); - } - else if(type === 'extensions') { + } else if (type === 'extensions') { self.groupsGetExtensionsTemplate(groupId, callbackAfterData); - } - else if(type === 'features') { + } else if (type === 'features') { self.groupsGetFeaturesTemplate(groupId, callbackAfterData); - } - else if(type === 'members') { + } else if (type === 'members') { self.groupsGetMembersTemplate(groupId, callbackAfterData); } }, @@ -427,7 +419,7 @@ define(function(require){ var self = this; self.groupsGetFeaturesData(groupId, function(data) { - template = $(monster.template(self, 'groups-features', data.group)); + var template = $(monster.template(self, 'groups-features', data.group)); self.groupsBindFeatures(template, data); @@ -439,7 +431,7 @@ define(function(require){ var self = this; self.groupsGetNameData(groupId, function(data) { - template = $(monster.template(self, 'groups-name', data)); + var template = $(monster.template(self, 'groups-name', data)); self.groupsBindName(template, data); @@ -452,7 +444,7 @@ define(function(require){ self.groupsGetNumbersData(groupId, function(data) { self.groupsFormatNumbersData(data, function(data) { - template = $(monster.template(self, 'groups-numbers', data)); + var template = $(monster.template(self, 'groups-numbers', data)); _.each(data.assignedNumbers, function(numberData, numberId) { numberData.phoneNumber = numberId; @@ -481,7 +473,7 @@ define(function(require){ self.groupsGetNumbersData(groupId, function(data) { self.groupsFormatNumbersData(data, function(data) { - template = $(monster.template(self, 'groups-extensions', data)); + var template = $(monster.template(self, 'groups-extensions', data)); self.groupsBindExtensions(template, data); @@ -494,9 +486,8 @@ define(function(require){ var self = this; self.groupsGetMembersData(groupId, function(results) { - var results = self.groupsFormatMembersData(results); - - template = $(monster.template(self, 'groups-members', results)); + var results = self.groupsFormatMembersData(results), + template = $(monster.template(self, 'groups-members', results)); monster.pub('common.ringingDurationControl.render', { container: template.find('.members-container'), @@ -538,14 +529,13 @@ define(function(require){ var self = this, recordCallNode = monster.util.findCallflowNode(data.callflow, 'record_call'), templateData = $.extend(true, { - group: data.group - }, - (data.group.extra.mapFeatures.call_recording.active && recordCallNode ? { - url: recordCallNode.data.url, - format: recordCallNode.data.format, - timeLimit: recordCallNode.data.time_limit - } : {}) - ), + group: data.group + }, + (data.group.extra.mapFeatures.call_recording.active && recordCallNode ? { + url: recordCallNode.data.url, + format: recordCallNode.data.format, + timeLimit: recordCallNode.data.time_limit + } : {})), featureTemplate = $(monster.template(self, 'groups-feature-call_recording', templateData)), switchFeature = featureTemplate.find('.switch-state'), featureForm = featureTemplate.find('#call_recording_form'), @@ -568,36 +558,35 @@ define(function(require){ }); featureTemplate.find('.save').on('click', function() { - if(monster.ui.valid(featureForm)) { + if (monster.ui.valid(featureForm)) { var formData = monster.ui.getFormData('call_recording_form'), enabled = switchFeature.prop('checked'); - if(!('smartpbx' in data.group)) { data.group.smartpbx = {}; } - if(!('call_recording' in data.group.smartpbx)) { + if (!('smartpbx' in data.group)) { data.group.smartpbx = {}; } + if (!('call_recording' in data.group.smartpbx)) { data.group.smartpbx.call_recording = { enabled: false }; } - if(data.group.smartpbx.call_recording.enabled || enabled) { + if (data.group.smartpbx.call_recording.enabled || enabled) { data.group.smartpbx.call_recording.enabled = enabled; var newCallflow = $.extend(true, {}, data.callflow), currentNode = monster.util.findCallflowNode(newCallflow, 'record_call') || monster.util.findCallflowNode(newCallflow, 'callflow'); - if(enabled) { - - if(currentNode.module === 'record_call') { - currentNode.data = $.extend(true, { action: "start" }, formData); + if (enabled) { + if (currentNode.module === 'record_call') { + currentNode.data = $.extend(true, { action: 'start' }, formData); } else { currentNode.children = { - "_": $.extend(true, {}, currentNode) + _: $.extend(true, {}, currentNode) }; - currentNode.module = "record_call"; - currentNode.data = $.extend(true, { action: "start" }, formData); + currentNode.module = 'record_call'; + currentNode.data = $.extend(true, { action: 'start' }, formData); } - } else if(currentNode.module === 'record_call') { - currentNode.module = currentNode.children["_"].module; - currentNode.data = currentNode.children["_"].data; - currentNode.children = currentNode.children["_"].children; + } else if (currentNode.module === 'record_call') { + currentNode.module = currentNode.children._.module; + currentNode.data = currentNode.children._.data; + currentNode.children = currentNode.children._.children; } self.groupsUpdateCallflow(newCallflow, function(updatedCallflow) { self.groupsUpdate(data.group, function(updatedGroup) { @@ -622,10 +611,10 @@ define(function(require){ var self = this, silenceMediaId = 'silence_stream://300000', ringGroupNode = data.baseCallflow.flow, - mediaToUpload = undefined; + mediaToUpload; - while(ringGroupNode.module !== 'ring_group' && '_' in ringGroupNode.children) { - ringGroupNode = ringGroupNode.children['_']; + while (ringGroupNode.module !== 'ring_group' && '_' in ringGroupNode.children) { + ringGroupNode = ringGroupNode.children._; } self.groupsListMedias(function(medias) { @@ -644,9 +633,9 @@ define(function(require){ featureTemplate.find('.upload-div').slideUp(function() { featureTemplate.find('.upload-toggle').removeClass('active'); }); - if(newMedia) { + if (newMedia) { var mediaSelect = featureTemplate.find('.media-dropdown'); - mediaSelect.append(''); + mediaSelect.append(''); mediaSelect.val(newMedia.id); } }; @@ -661,7 +650,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().groups.ringback.fileTooBigAlert); } featureTemplate.find('.upload-div input').val(''); @@ -678,7 +667,7 @@ define(function(require){ }); featureTemplate.find('.upload-toggle').on('click', function() { - if($(this).hasClass('active')) { + if ($(this).hasClass('active')) { featureTemplate.find('.upload-div').stop(true, true).slideUp(); } else { featureTemplate.find('.upload-div').stop(true, true).slideDown(); @@ -690,7 +679,7 @@ define(function(require){ }); featureTemplate.find('.upload-submit').on('click', function() { - if(mediaToUpload) { + if (mediaToUpload) { self.callApi({ resource: 'media.create', data: { @@ -698,7 +687,7 @@ define(function(require){ data: { streamable: true, name: mediaToUpload.name, - media_source: "upload", + media_source: 'upload', description: mediaToUpload.name } }, @@ -737,13 +726,13 @@ define(function(require){ var selectedMedia = featureTemplate.find('.media-dropdown option:selected').val(), enabled = switchFeature.prop('checked'); - if(!('smartpbx' in data.group)) { + if (!('smartpbx' in data.group)) { data.group.smartpbx = {}; } - if(enabled) { + if (enabled) { ringGroupNode.data.ringback = selectedMedia; - if('ringback' in data.group.smartpbx) { + if ('ringback' in data.group.smartpbx) { data.group.smartpbx.ringback.enabled = true; } else { data.group.smartpbx.ringback = { @@ -757,9 +746,9 @@ define(function(require){ self.groupsRender({ groupId: data.group.id }); }); }); - } else if(ringGroupNode.data.ringback || (data.group.smartpbx.ringback && data.group.smartpbx.ringback.enabled)) { + } else if (ringGroupNode.data.ringback || (data.group.smartpbx.ringback && data.group.smartpbx.ringback.enabled)) { delete ringGroupNode.data.ringback; - if('ringback' in data.group.smartpbx) { + if ('ringback' in data.group.smartpbx) { data.group.smartpbx.ringback.enabled = false; } @@ -784,14 +773,13 @@ define(function(require){ flow = data.callflow.flow, selectedEntity = null; - while(flow.module != 'callflow') { - flow = flow.children['_']; + while (flow.module !== 'callflow') { + flow = flow.children._; } //Go to the first callflow (i.e. base ring group) - if('_' in flow.children) { - selectedEntity = flow.children['_'].data.id; + if ('_' in flow.children) { + selectedEntity = flow.children._.data.id; } //Find the existing Next Action if there is one - var templateData = $.extend(true, {selectedEntity: selectedEntity}, data), featureTemplate = $(monster.template(self, 'groups-feature-next_action', templateData)), switchFeature = featureTemplate.find('.switch-state'), @@ -811,31 +799,31 @@ define(function(require){ var selectedOption = featureTemplate.find('.next-action-select option:selected'), enabled = switchFeature.prop('checked'); - if(!('smartpbx' in data.group)) { data.group.smartpbx = {}; } - if(!('next_action' in data.group.smartpbx)) { + if (!('smartpbx' in data.group)) { data.group.smartpbx = {}; } + if (!('next_action' in data.group.smartpbx)) { data.group.smartpbx.next_action = { enabled: false }; } - if(data.group.smartpbx.next_action.enabled || enabled) { + if (data.group.smartpbx.next_action.enabled || enabled) { data.group.smartpbx.next_action.enabled = enabled; var newCallflow = $.extend(true, {}, data.callflow), callflowNode = monster.util.findCallflowNode(newCallflow, 'callflow'); - if(_.isArray(callflowNode)) { + if (_.isArray(callflowNode)) { callflowNode = callflowNode[0]; } callflowNode.children = {}; - if(enabled) { - callflowNode.children['_'] = { + if (enabled) { + callflowNode.children._ = { children: {}, module: selectedOption.data('module'), data: { id: selectedOption.val() } - } + }; } else { - callflowNode.children['_'] = { + callflowNode.children._ = { module: 'play', children: {}, data: { @@ -883,22 +871,20 @@ define(function(require){ data.baseCallflow.flow.data.ignore_forward = ignore_forward; monster.parallel({ - groups: function(callback) { - self.groupsUpdate(data.group, function(updatedGroup) { - callback(null, updatedGroup); - }); - }, - ringGroup: function(callback) { - self.groupsUpdateCallflow(data.baseCallflow, function(callflow) { - callback(null, callflow); - }); - } + groups: function(callback) { + self.groupsUpdate(data.group, function(updatedGroup) { + callback(null, updatedGroup); + }); }, - function(err, results) { - popup.dialog('close').remove(); - self.groupsRender({ groupId: results.groups.id }); + ringGroup: function(callback) { + self.groupsUpdateCallflow(data.baseCallflow, function(callflow) { + callback(null, callflow); + }); } - ); + }, function(err, results) { + popup.dialog('close').remove(); + self.groupsRender({ groupId: results.groups.id }); + }); }); popup = monster.ui.dialog(featureTemplate, { @@ -911,13 +897,12 @@ define(function(require){ var self = this, prependNode = monster.util.findCallflowNode(data.callflow, 'prepend_cid'), templateData = $.extend(true, { - group: data.group - }, - (data.group.extra.mapFeatures.prepend.active && prependNode ? { - caller_id_name_prefix: prependNode.data.caller_id_name_prefix, - caller_id_number_prefix: prependNode.data.caller_id_number_prefix - } : {}) - ), + group: data.group + }, + (data.group.extra.mapFeatures.prepend.active && prependNode ? { + caller_id_name_prefix: prependNode.data.caller_id_name_prefix, + caller_id_number_prefix: prependNode.data.caller_id_number_prefix + } : {})), featureTemplate = $(monster.template(self, 'groups-feature-prepend', templateData)), switchFeature = featureTemplate.find('.switch-state'), popup; @@ -934,32 +919,31 @@ define(function(require){ var enabled = switchFeature.prop('checked'), prependData = $.extend(true, { action: 'prepend' }, monster.ui.getFormData('prepend_form')); - if(!('smartpbx' in data.group)) { data.group.smartpbx = {}; } - if(!('prepend' in data.group.smartpbx)) { + if (!('smartpbx' in data.group)) { data.group.smartpbx = {}; } + if (!('prepend' in data.group.smartpbx)) { data.group.smartpbx.prepend = { enabled: false }; } - if(data.group.smartpbx.prepend.enabled || enabled) { + if (data.group.smartpbx.prepend.enabled || enabled) { data.group.smartpbx.prepend.enabled = enabled; var newCallflow = $.extend(true, {}, data.callflow); - if(enabled) { - if(newCallflow.flow.module !== 'prepend_cid') { + if (enabled) { + if (newCallflow.flow.module !== 'prepend_cid') { newCallflow.flow = { children: { '_': $.extend(true, {}, data.callflow.flow) }, module: 'prepend_cid', data: prependData - } - } - else { + }; + } else { newCallflow.flow.data = prependData; } } else { - if(prependNode) { - newCallflow.flow = $.extend(true, {}, prependNode.children["_"]); + if (prependNode) { + newCallflow.flow = $.extend(true, {}, prependNode.children._); } } self.groupsUpdateCallflow(newCallflow, function(updatedCallflow) { @@ -987,7 +971,7 @@ define(function(require){ monster.ui.validate(nameForm); template.find('.save-group').on('click', function() { - if(monster.ui.valid(nameForm)) { + if (monster.ui.valid(nameForm)) { var formData = monster.ui.getFormData('form-name'); //formData = self.groupsCleanNameData(formData); @@ -1040,12 +1024,12 @@ define(function(require){ // var rows = template.find('.list-assigned-items .item-row'); // /* If no rows beside the clicked one, display empty row */ - // if(rows.is(':visible') === false) { + // if (rows.is(':visible') === false) { // template.find('.list-assigned-items .empty-row').show(); // } // /* If it matches the search string, show it */ - // if(row.data('search').indexOf(currentNumberSearch) >= 0) { + // if (row.data('search').indexOf(currentNumberSearch) >= 0) { // row.show(); // unassignedList.find('.empty-search-row').hide(); // } @@ -1060,7 +1044,7 @@ define(function(require){ row.slideUp(function() { row.remove(); - if ( !template.find('.list-assigned-items .item-row').is(':visible') ) { + if (!template.find('.list-assigned-items .item-row').is(':visible')) { template.find('.list-assigned-items .empty-row').slideDown(); } @@ -1080,7 +1064,7 @@ define(function(require){ currentRow.data('search').toLowerCase().indexOf(currentNumberSearch) < 0 ? currentRow.hide() : currentRow.show(); }); - if(rows.size() > 0) { + if (rows.size() > 0) { rows.is(':visible') ? emptySearch.hide() : emptySearch.show(); } }); @@ -1088,9 +1072,8 @@ define(function(require){ template.on('click', '.actions .spare-link:not(.disabled)', function(e) { e.preventDefault(); - var $this = $(this), - args = { - accountName: monster.apps['auth'].currentAccount.name, + var args = { + accountName: monster.apps.auth.currentAccount.name, accountId: self.accountId, ignoreNumbers: $.map(template.find('.item-row'), function(row) { return $(row).data('id'); @@ -1099,14 +1082,14 @@ define(function(require){ callback: function(numberList, remainingQuantity) { template.find('.empty-row').hide(); - _.each(numberList, function(val, idx) { + _.each(numberList, function(val) { template .find('.list-assigned-items') .append($(monster.template(self, 'groups-numbersItemRow', { number: val }))); - var numberDiv = template.find('[data-id="'+val.phoneNumber+'"]'), + var numberDiv = template.find('[data-id="' + val.phoneNumber + '"]'), args = { target: numberDiv.find('.edit-features'), numberData: val, @@ -1115,14 +1098,14 @@ define(function(require){ } }; - monster.pub('common.numberFeaturesMenu.render', args); + monster.pub('common.numberFeaturesMenu.render', args); extraSpareNumbers = _.without(extraSpareNumbers, val.phoneNumber); }); monster.ui.tooltips(template); - if(remainingQuantity === 0) { + if (remainingQuantity === 0) { template.find('.spare-link').addClass('disabled'); } } @@ -1138,7 +1121,7 @@ define(function(require){ searchType: $(this).data('type'), callbacks: { success: function(numbers) { - _.each(numbers, function(number, k) { + _.each(numbers, function(number) { number.phoneNumber = number.id; var rowTemplate = $(monster.template(self, 'groups-numbersItemRow', { @@ -1168,7 +1151,7 @@ define(function(require){ var $this = $(this), parentRow = $this.parents('.grid-row'), callflowId = parentRow.data('callflow_id'), - name = parentRow.data('name'); + name = parentRow.data('name'), dataNumbers = []; template.find('.item-row').each(function(k, row) { @@ -1225,14 +1208,13 @@ define(function(require){ $listExtensions.append(newLineTemplate); }; - if(_.isEmpty(listExtension)) { + if (_.isEmpty(listExtension)) { self.groupsListExtensions(function(arrayExtension) { listExtension = arrayExtension; renderNewRow(); }); - } - else { + } else { renderNewRow(); } }); @@ -1241,7 +1223,7 @@ define(function(require){ var phoneRow = $(this).parents('.item-row'), emptyRow = phoneRow.siblings('.empty-row'); - if(phoneRow.siblings('.item-row').size() === 0) { + if (phoneRow.siblings('.item-row').size() === 0) { emptyRow.show(); } @@ -1252,7 +1234,7 @@ define(function(require){ var extension = parseInt($(this).siblings('input').val()), index = listExtension.indexOf(extension); - if(index > -1) { + if (index > -1) { listExtension.splice(index, 1); } @@ -1266,7 +1248,7 @@ define(function(require){ template.find('.save-groups').on('click', function() { var groupId = data.id; - monster.pub('common.ringingDurationControl.getEndpoints', { + monster.pub('common.ringingDurationControl.getEndpoints', { container: template, callback: function(endpoints) { _.each(endpoints, function(endpoint) { @@ -1295,12 +1277,12 @@ define(function(require){ okCallback: function(users) { _.each(users, function(user) { var newEndpoint = { - id: user.id, - timeout: 20, - delay: 0, - endpoint_type: 'user', - name: user.name - }; + id: user.id, + timeout: 20, + delay: 0, + endpoint_type: 'user', + name: user.name + }; monster.pub('common.ringingDurationControl.addEndpoint', { container: template.find('.members-container'), @@ -1365,81 +1347,79 @@ define(function(require){ var self = this; monster.parallel({ - devices: function(callback) { - self.groupsListDevices(function(data) { - callback(null, data); - }); - }, - group: function(callback) { - self.groupsGetGroup(groupId, function(data) { - callback(null, data); - }); - }, - users: function(callback) { - self.groupsListUsers(function(data) { - callback(null, data); - }); - }, - callflow: function(callback) { - self.groupsGetRingGroup(groupId, function(data) { - callback(null, data); - }); - }, - baseCallflow: function(callback) { - self.groupsGetBaseRingGroup(groupId, function(data) { - callback(null, data); - }); - }, - voicemails: function(callback) { - self.groupsListVMBoxes(function(data) { - callback(null, data); - }); - }, - mainMenu: function(callback) { - self.callApi({ - resource: 'callflow.list', - data: { - accountId: self.accountId, - filters: { - filter_type:'main', - paginate: 'false' - } - }, - success: function(data) { - callback(null, data.data && data.data.length > 0 ? _.find(data.data, function(callflow) { return callflow.numbers[0] === "MainOpenHoursMenu" }) : null); - } - }); - }, - userCallflows: function(callback) { - self.callApi({ - resource: 'callflow.list', - data: { - accountId: self.accountId, - filters: { - has_key: 'owner_id', - filter_type: 'mainUserCallflow', - paginate: 'false' - } - }, - success: function(data) { - callback(null, data.data); + devices: function(callback) { + self.groupsListDevices(function(data) { + callback(null, data); + }); + }, + group: function(callback) { + self.groupsGetGroup(groupId, function(data) { + callback(null, data); + }); + }, + users: function(callback) { + self.groupsListUsers(function(data) { + callback(null, data); + }); + }, + callflow: function(callback) { + self.groupsGetRingGroup(groupId, function(data) { + callback(null, data); + }); + }, + baseCallflow: function(callback) { + self.groupsGetBaseRingGroup(groupId, function(data) { + callback(null, data); + }); + }, + voicemails: function(callback) { + self.groupsListVMBoxes(function(data) { + callback(null, data); + }); + }, + mainMenu: function(callback) { + self.callApi({ + resource: 'callflow.list', + data: { + accountId: self.accountId, + filters: { + filter_type: 'main', + paginate: 'false' } - }); - } + }, + success: function(data) { + callback(null, data.data && data.data.length > 0 ? _.find(data.data, function(callflow) { return callflow.numbers[0] === 'MainOpenHoursMenu'; }) : null); + } + }); }, - function(err, results) { - results.group.extra = self.groupsGetGroupFeatures(results.group); - results.userCallflows = _.filter(results.userCallflows, function(userCallflow) { - var user = _.find(results.users, function(user) { return userCallflow.owner_id === user.id }); - if(user) { - userCallflow.userName = user.first_name + ' ' + user.last_name; - return true; + userCallflows: function(callback) { + self.callApi({ + resource: 'callflow.list', + data: { + accountId: self.accountId, + filters: { + has_key: 'owner_id', + filter_type: 'mainUserCallflow', + paginate: 'false' + } + }, + success: function(data) { + callback(null, data.data); } - return false; }); - callback && callback(results); } - ); + }, function(err, results) { + results.group.extra = self.groupsGetGroupFeatures(results.group); + results.userCallflows = _.filter(results.userCallflows, function(userCallflow) { + var user = _.find(results.users, function(user) { return userCallflow.owner_id === user.id; }); + if (user) { + userCallflow.userName = user.first_name + ' ' + user.last_name; + return true; + } + return false; + }); + callback && callback(results); + }); }, groupsGetNameData: function(groupId, callback) { @@ -1466,18 +1446,17 @@ define(function(require){ /* TODO: Once locality is enabled, we need to remove it */ number.localityEnabled = 'locality' in number ? true : false; - if(!number.hasOwnProperty('used_by') || number.used_by === '') { + if (!number.hasOwnProperty('used_by') || number.used_by === '') { response.unassignedNumbers[id] = number; response.countSpare++; } }); - if('groupCallflow' in data.callflow && 'numbers' in data.callflow.groupCallflow) { + if ('groupCallflow' in data.callflow && 'numbers' in data.callflow.groupCallflow) { _.each(data.callflow.groupCallflow.numbers, function(number) { - if(!(number in data.numbers.numbers)) { + if (!(number in data.numbers.numbers)) { response.extensions.push(number); - } - else { + } else { data.numbers.numbers[number].isLocal = data.numbers.numbers[number].features.indexOf('local') > -1; response.assignedNumbers[number] = data.numbers.numbers[number]; } @@ -1494,77 +1473,72 @@ define(function(require){ var self = this; monster.parallel({ - callflow: function(callbackParallel) { - var response = {}; + callflow: function(callbackParallel) { + var response = {}; - self.callApi({ - resource: 'callflow.list', - data: { - accountId: self.accountId, - filters: { - filter_group_id: groupId, - filter_type: 'userGroup', - paginate: 'false' - } - }, - success: function(data) { - if(data.data.length > 0) { - self.groupsGetCallflow(data.data[0].id, function(callflow) { - response.groupCallflow = callflow; - callbackParallel && callbackParallel(null, response); - }); - } else { - callbackParallel && callbackParallel(null, null); - } + self.callApi({ + resource: 'callflow.list', + data: { + accountId: self.accountId, + filters: { + filter_group_id: groupId, + filter_type: 'userGroup', + paginate: 'false' } - }); - }, - numbers: function(callbackParallel) { - self.callApi({ - resource: 'numbers.list', - data: { - accountId: self.accountId, - filters: { - paginate: 'false' - } - }, - success: function(numbers) { - callbackParallel && callbackParallel(null, numbers.data); + }, + success: function(data) { + if (data.data.length > 0) { + self.groupsGetCallflow(data.data[0].id, function(callflow) { + response.groupCallflow = callflow; + callbackParallel && callbackParallel(null, response); + }); + } else { + callbackParallel && callbackParallel(null, null); } - }); - } + } + }); }, - function(err, results) { - callback && callback(results); + numbers: function(callbackParallel) { + self.callApi({ + resource: 'numbers.list', + data: { + accountId: self.accountId, + filters: { + paginate: 'false' + } + }, + success: function(numbers) { + callbackParallel && callbackParallel(null, numbers.data); + } + }); } - ); + }, function(err, results) { + callback && callback(results); + }); }, groupsGetMembersData: function(groupId, globalCallback) { var self = this; monster.parallel({ - users: function(callback) { - self.groupsListUsers(function(data) { - callback(null, data); - }); - }, - group: function(callback) { - self.groupsGetGroup(groupId, function(data) { - callback(null, data); - }); - }, - baseCallflow: function(callback) { - self.groupsGetBaseRingGroup(groupId, function(data) { - callback(null, data); - }); - } + users: function(callback) { + self.groupsListUsers(function(data) { + callback(null, data); + }); }, - function(err, results) { - globalCallback && globalCallback(results); + group: function(callback) { + self.groupsGetGroup(groupId, function(data) { + callback(null, data); + }); + }, + baseCallflow: function(callback) { + self.groupsGetBaseRingGroup(groupId, function(data) { + callback(null, data); + }); } - ); - + }, function(err, results) { + globalCallback && globalCallback(results); + }); }, groupsFormatMembersData: function(data) { @@ -1582,7 +1556,7 @@ define(function(require){ endpoint.delay = parseInt(endpoint.delay); endpoint.timeout = parseInt(endpoint.timeout); - if(endpoint.id in mapUsers) { + if (endpoint.id in mapUsers) { endpoint.name = mapUsers[endpoint.id].first_name + ' ' + mapUsers[endpoint.id].last_name; } else { endpoint.name = self.i18n.active().groups.userDeleted; @@ -1603,7 +1577,7 @@ define(function(require){ self.groupsGetCallflow(callflowId, function(callflow) { _.each(callflow.numbers, function(number) { - if(number.length < 7) { + if (number.length < 7) { newNumbers.push(number); } }); @@ -1621,7 +1595,7 @@ define(function(require){ self.groupsGetCallflow(callflowId, function(callflow) { _.each(callflow.numbers, function(number) { - if(number.length > 6) { + if (number.length > 6) { newNumbers.push(number); } }); @@ -1641,10 +1615,10 @@ define(function(require){ self.groupsListCallflows(function(callflowList) { _.each(callflowList, function(callflow) { _.each(callflow.numbers, function(number) { - if(number.length < 7) { + if (number.length < 7) { var extension = parseInt(number); - if(extension > 1) { + if (extension > 1) { extensionList.push(extension); } } @@ -1656,7 +1630,7 @@ define(function(require){ parsedB = parseInt(b), result = -1; - if(parsedA > 0 && parsedB > 0) { + if (parsedA > 0 && parsedB > 0) { result = parsedA > parsedB; } @@ -1681,7 +1655,7 @@ define(function(require){ var self = this, flag = self.uiFlags.user.get('showGroupsWalkthrough'); - if(flag !== false) { + if (flag !== false) { callback && callback(); } }, @@ -1699,7 +1673,7 @@ define(function(require){ var self = this, mainTemplate = $('#voip_container'), rowFirstGroup = mainTemplate.find('.grid-row:not(.title):first'), - steps = [ + steps = [ { element: mainTemplate.find('.add-group')[0], intro: self.i18n.active().groups.walkthrough.steps['1'], @@ -1751,9 +1725,9 @@ define(function(require){ resource: 'media.list', data: { accountId: self.accountId, - filters: { - 'paginate': 'false', - 'key_missing':'type' + filters: { + paginate: false, + key_missing: 'type' } }, success: function(medias) { @@ -1855,12 +1829,11 @@ define(function(require){ } }, success: function(data) { - if(data.data.length > 0) { + if (data.data.length > 0) { self.groupsGetCallflow(data.data[0].id, function(callflow) { callback && callback(callflow); }); - } - else { + } else { callbackError && callbackError(data); toastr.error(self.i18n.active().groups.ringGroupMissing); @@ -1886,12 +1859,11 @@ define(function(require){ } }, success: function(data) { - if(data.data.length > 0) { + if (data.data.length > 0) { self.groupsGetCallflow(data.data[0].id, function(callflow) { callback && callback(callflow); }); - } - else { + } else { callbackError && callbackError(data); toastr.error(self.i18n.active().groups.ringGroupMissing); @@ -1911,7 +1883,7 @@ define(function(require){ timeout = parseInt(endpoint.timeout), total = delay + timeout; - if(total > globalTimeout) { + if (total > globalTimeout) { globalTimeout = total; } }); @@ -1923,55 +1895,51 @@ define(function(require){ var self = this; monster.parallel({ - group: function(callback) { - self.groupsGetGroup(groupId, function(data) { - var areDifferent = false; + group: function(callback) { + self.groupsGetGroup(groupId, function(data) { + var areDifferent = false; - _.each(endpoints, function(endpoint) { - if(endpoint.id in data.endpoints) { - delete data.endpoints[endpoint.id]; - } - else { - areDifferent = true; - return false; - } - }); - - if(!_.isEmpty(data.endpoints)) { + _.each(endpoints, function(endpoint) { + if (endpoint.id in data.endpoints) { + delete data.endpoints[endpoint.id]; + } else { areDifferent = true; + return false; } + }); - if(areDifferent) { - data.endpoints = {}; + if (!_.isEmpty(data.endpoints)) { + areDifferent = true; + } - _.each(endpoints, function(v) { - data.endpoints[v.id] = { type: 'user' }; - }); + if (areDifferent) { + data.endpoints = {}; - self.groupsUpdate(data, function(data) { - callback && callback(null, data); - }); - } - else { - callback && callback(null, data); - } - }); - }, - callflow: function(callback) { - self.groupsGetBaseRingGroup(groupId, function(ringGroup) { - ringGroup.flow.data.endpoints = endpoints; - ringGroup.flow.data.timeout = self.groupsComputeTimeout(endpoints); + _.each(endpoints, function(v) { + data.endpoints[v.id] = { type: 'user' }; + }); - self.groupsUpdateCallflow(ringGroup, function(data) { + self.groupsUpdate(data, function(data) { callback && callback(null, data); }); - }); - }, + } else { + callback && callback(null, data); + } + }); }, - function(error, results) { - callback && callback(results); + callflow: function(callback) { + self.groupsGetBaseRingGroup(groupId, function(ringGroup) { + ringGroup.flow.data.endpoints = endpoints; + ringGroup.flow.data.timeout = self.groupsComputeTimeout(endpoints); + + self.groupsUpdateCallflow(ringGroup, function(data) { + callback && callback(null, data); + }); + }); } - ); + }, function(error, results) { + callback && callback(results); + }); }, groupsUpdate: function(group, callback) { @@ -2029,57 +1997,55 @@ define(function(require){ var self = this; monster.parallel({ - group: function(callback) { + group: function(callback) { + self.callApi({ + resource: 'group.delete', + data: { + accountId: self.accountId, + groupId: groupId + }, + success: function(data) { + callback && callback(null, data.data); + } + }); + }, + callflow: function(callback) { + self.groupsGetRingGroup(groupId, function(data) { self.callApi({ - resource: 'group.delete', + resource: 'callflow.delete', data: { accountId: self.accountId, - groupId: groupId + callflowId: data.id }, success: function(data) { - callback && callback(null, data.data); + callback && callback(null, data); } }); }, - callflow: function(callback) { - self.groupsGetRingGroup(groupId, function(data) { - self.callApi({ - resource: 'callflow.delete', - data: { - accountId: self.accountId, - callflowId: data.id - }, - success: function(data) { - callback && callback(null, data); - } - }); - }, - function(data) { - callback && callback(null, data); + function(data) { + callback && callback(null, data); + }); + }, + baseCallflow: function(callback) { + self.groupsGetBaseRingGroup(groupId, function(data) { + self.callApi({ + resource: 'callflow.delete', + data: { + accountId: self.accountId, + callflowId: data.id + }, + success: function(data) { + callback && callback(null, data); + } }); }, - baseCallflow: function(callback) { - self.groupsGetBaseRingGroup(groupId, function(data) { - self.callApi({ - resource: 'callflow.delete', - data: { - accountId: self.accountId, - callflowId: data.id - }, - success: function(data) { - callback && callback(null, data); - } - }); - }, - function(data) { - callback && callback(null, data); - }); - } - }, - function(err, results) { - callback && callback(results); + function(data) { + callback && callback(null, data); + }); } - ); + }, function(err, results) { + callback && callback(results); + }); }, groupsGetCallflow: function(callflowId, callback) { @@ -2101,40 +2067,38 @@ define(function(require){ var self = this; monster.parallel({ - groups: function(callback) { - self.callApi({ - resource: 'group.list', - data: { - accountId: self.accountId, - filters: { - paginate: 'false' - } - }, - success: function(dataGroups) { - callback(null, dataGroups.data); - } - }); - }, - callflows: function(callback) { - self.callApi({ - resource: 'callflow.list', - data: { - accountId: self.accountId, - filters: { - has_key: 'group_id', - paginate: 'false' - } - }, - success: function(dataCallflows) { - callback(null, dataCallflows.data); + groups: function(callback) { + self.callApi({ + resource: 'group.list', + data: { + accountId: self.accountId, + filters: { + paginate: 'false' } - }); - } + }, + success: function(dataGroups) { + callback(null, dataGroups.data); + } + }); }, - function(err, results) { - callback && callback(results); + callflows: function(callback) { + self.callApi({ + resource: 'callflow.list', + data: { + accountId: self.accountId, + filters: { + has_key: 'group_id', + paginate: 'false' + } + }, + success: function(dataCallflows) { + callback(null, dataCallflows.data); + } + }); } - ); + }, function(err, results) { + callback && callback(results); + }); }, groupsRemoveOverlay: function() { diff --git a/submodules/myOffice/myOffice.js b/submodules/myOffice/myOffice.js index bb25ee7..5ac7121 100644 --- a/submodules/myOffice/myOffice.js +++ b/submodules/myOffice/myOffice.js @@ -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(''); + mediaSelect.append(''); 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); diff --git a/submodules/numbers/numbers.js b/submodules/numbers/numbers.js index a542643..fa5542b 100644 --- a/submodules/numbers/numbers.js +++ b/submodules/numbers/numbers.js @@ -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; diff --git a/submodules/strategy/strategy.js b/submodules/strategy/strategy.js index df7c751..3e265f8 100644 --- a/submodules/strategy/strategy.js +++ b/submodules/strategy/strategy.js @@ -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); } } diff --git a/submodules/vmboxes/vmboxes.js b/submodules/vmboxes/vmboxes.js index 12ba2bf..a889645 100644 --- a/submodules/vmboxes/vmboxes.js +++ b/submodules/vmboxes/vmboxes.js @@ -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(''); + mediaSelect.append(''); 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); + }); } }; diff --git a/views/myOffice-layout.html b/views/myOffice-layout.html index bd25a92..71d77c2 100644 --- a/views/myOffice-layout.html +++ b/views/myOffice-layout.html @@ -23,7 +23,7 @@
{{#if topMessage}} -
+
{{topMessage.message}}
{{/if}}