diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..87f4e7c --- /dev/null +++ b/LICENSE @@ -0,0 +1,471 @@ + MOZILLA PUBLIC LICENSE + Version 1.1 + + --------------- + +1. Definitions. + + 1.0.1. "Commercial Use" means distribution or otherwise making the + Covered Code available to a third party. + + 1.1. "Contributor" means each entity that creates or contributes to + the creation of Modifications. + + 1.2. "Contributor Version" means the combination of the Original + Code, prior Modifications used by a Contributor, and the Modifications + made by that particular Contributor. + + 1.3. "Covered Code" means the Original Code or Modifications or the + combination of the Original Code and Modifications, in each case + including portions thereof. + + 1.4. "Electronic Distribution Mechanism" means a mechanism generally + accepted in the software development community for the electronic + transfer of data. + + 1.5. "Executable" means Covered Code in any form other than Source + Code. + + 1.6. "Initial Developer" means the individual or entity identified + as the Initial Developer in the Source Code notice required by Exhibit + A. + + 1.7. "Larger Work" means a work which combines Covered Code or + portions thereof with code not governed by the terms of this License. + + 1.8. "License" means this document. + + 1.8.1. "Licensable" means having the right to grant, to the maximum + extent possible, whether at the time of the initial grant or + subsequently acquired, any and all of the rights conveyed herein. + + 1.9. "Modifications" means any addition to or deletion from the + substance or structure of either the Original Code or any previous + Modifications. When Covered Code is released as a series of files, a + Modification is: + A. Any addition to or deletion from the contents of a file + containing Original Code or previous Modifications. + + B. Any new file that contains any part of the Original Code or + previous Modifications. + + 1.10. "Original Code" means Source Code of computer software code + which is described in the Source Code notice required by Exhibit A as + Original Code, and which, at the time of its release under this + License is not already Covered Code governed by this License. + + 1.10.1. "Patent Claims" means any patent claim(s), now owned or + hereafter acquired, including without limitation, method, process, + and apparatus claims, in any patent Licensable by grantor. + + 1.11. "Source Code" means the preferred form of the Covered Code for + making modifications to it, including all modules it contains, plus + any associated interface definition files, scripts used to control + compilation and installation of an Executable, or source code + differential comparisons against either the Original Code or another + well known, available Covered Code of the Contributor's choice. The + Source Code can be in a compressed or archival form, provided the + appropriate decompression or de-archiving software is widely available + for no charge. + + 1.12. "You" (or "Your") means an individual or a legal entity + exercising rights under, and complying with all of the terms of, this + License or a future version of this License issued under Section 6.1. + For legal entities, "You" includes any entity which controls, is + controlled by, or is under common control with You. For purposes of + this definition, "control" means (a) the power, direct or indirect, + to cause the direction or management of such entity, whether by + contract or otherwise, or (b) ownership of more than fifty percent + (50%) of the outstanding shares or beneficial ownership of such + entity. + +2. Source Code License. + + 2.1. The Initial Developer Grant. + The Initial Developer hereby grants You a world-wide, royalty-free, + non-exclusive license, subject to third party intellectual property + claims: + (a) under intellectual property rights (other than patent or + trademark) Licensable by Initial Developer to use, reproduce, + modify, display, perform, sublicense and distribute the Original + Code (or portions thereof) with or without Modifications, and/or + as part of a Larger Work; and + + (b) under Patents Claims infringed by the making, using or + selling of Original Code, to make, have made, use, practice, + sell, and offer for sale, and/or otherwise dispose of the + Original Code (or portions thereof). + + (c) the licenses granted in this Section 2.1(a) and (b) are + effective on the date Initial Developer first distributes + Original Code under the terms of this License. + + (d) Notwithstanding Section 2.1(b) above, no patent license is + granted: 1) for code that You delete from the Original Code; 2) + separate from the Original Code; or 3) for infringements caused + by: i) the modification of the Original Code or ii) the + combination of the Original Code with other software or devices. + + 2.2. Contributor Grant. + Subject to third party intellectual property claims, each Contributor + hereby grants You a world-wide, royalty-free, non-exclusive license + + (a) under intellectual property rights (other than patent or + trademark) Licensable by Contributor, to use, reproduce, modify, + display, perform, sublicense and distribute the Modifications + created by such Contributor (or portions thereof) either on an + unmodified basis, with other Modifications, as Covered Code + and/or as part of a Larger Work; and + + (b) under Patent Claims infringed by the making, using, or + selling of Modifications made by that Contributor either alone + and/or in combination with its Contributor Version (or portions + of such combination), to make, use, sell, offer for sale, have + made, and/or otherwise dispose of: 1) Modifications made by that + Contributor (or portions thereof); and 2) the combination of + Modifications made by that Contributor with its Contributor + Version (or portions of such combination). + + (c) the licenses granted in Sections 2.2(a) and 2.2(b) are + effective on the date Contributor first makes Commercial Use of + the Covered Code. + + (d) Notwithstanding Section 2.2(b) above, no patent license is + granted: 1) for any code that Contributor has deleted from the + Contributor Version; 2) separate from the Contributor Version; + 3) for infringements caused by: i) third party modifications of + Contributor Version or ii) the combination of Modifications made + by that Contributor with other software (except as part of the + Contributor Version) or other devices; or 4) under Patent Claims + infringed by Covered Code in the absence of Modifications made by + that Contributor. + +3. Distribution Obligations. + + 3.1. Application of License. + The Modifications which You create or to which You contribute are + governed by the terms of this License, including without limitation + Section 2.2. The Source Code version of Covered Code may be + distributed only under the terms of this License or a future version + of this License released under Section 6.1, and You must include a + copy of this License with every copy of the Source Code You + distribute. You may not offer or impose any terms on any Source Code + version that alters or restricts the applicable version of this + License or the recipients' rights hereunder. However, You may include + an additional document offering the additional rights described in + Section 3.5. + + 3.2. Availability of Source Code. + Any Modification which You create or to which You contribute must be + made available in Source Code form under the terms of this License + either on the same media as an Executable version or via an accepted + Electronic Distribution Mechanism to anyone to whom you made an + Executable version available; and if made available via Electronic + Distribution Mechanism, must remain available for at least twelve (12) + months after the date it initially became available, or at least six + (6) months after a subsequent version of that particular Modification + has been made available to such recipients. You are responsible for + ensuring that the Source Code version remains available even if the + Electronic Distribution Mechanism is maintained by a third party. + + 3.3. Description of Modifications. + You must cause all Covered Code to which You contribute to contain a + file documenting the changes You made to create that Covered Code and + the date of any change. You must include a prominent statement that + the Modification is derived, directly or indirectly, from Original + Code provided by the Initial Developer and including the name of the + Initial Developer in (a) the Source Code, and (b) in any notice in an + Executable version or related documentation in which You describe the + origin or ownership of the Covered Code. + + 3.4. Intellectual Property Matters + (a) Third Party Claims. + If Contributor has knowledge that a license under a third party's + intellectual property rights is required to exercise the rights + granted by such Contributor under Sections 2.1 or 2.2, + Contributor must include a text file with the Source Code + distribution titled "LEGAL" which describes the claim and the + party making the claim in sufficient detail that a recipient will + know whom to contact. If Contributor obtains such knowledge after + the Modification is made available as described in Section 3.2, + Contributor shall promptly modify the LEGAL file in all copies + Contributor makes available thereafter and shall take other steps + (such as notifying appropriate mailing lists or newsgroups) + reasonably calculated to inform those who received the Covered + Code that new knowledge has been obtained. + + (b) Contributor APIs. + If Contributor's Modifications include an application programming + interface and Contributor has knowledge of patent licenses which + are reasonably necessary to implement that API, Contributor must + also include this information in the LEGAL file. + + (c) Representations. + Contributor represents that, except as disclosed pursuant to + Section 3.4(a) above, Contributor believes that Contributor's + Modifications are Contributor's original creation(s) and/or + Contributor has sufficient rights to grant the rights conveyed by + this License. + + 3.5. Required Notices. + You must duplicate the notice in Exhibit A in each file of the Source + Code. If it is not possible to put such notice in a particular Source + Code file due to its structure, then You must include such notice in a + location (such as a relevant directory) where a user would be likely + to look for such a notice. If You created one or more Modification(s) + You may add your name as a Contributor to the notice described in + Exhibit A. You must also duplicate this License in any documentation + for the Source Code where You describe recipients' rights or ownership + rights relating to Covered Code. You may choose to offer, and to + charge a fee for, warranty, support, indemnity or liability + obligations to one or more recipients of Covered Code. However, You + may do so only on Your own behalf, and not on behalf of the Initial + Developer or any Contributor. You must make it absolutely clear than + any such warranty, support, indemnity or liability obligation is + offered by You alone, and You hereby agree to indemnify the Initial + Developer and every Contributor for any liability incurred by the + Initial Developer or such Contributor as a result of warranty, + support, indemnity or liability terms You offer. + + 3.6. Distribution of Executable Versions. + You may distribute Covered Code in Executable form only if the + requirements of Section 3.1-3.5 have been met for that Covered Code, + and if You include a notice stating that the Source Code version of + the Covered Code is available under the terms of this License, + including a description of how and where You have fulfilled the + obligations of Section 3.2. The notice must be conspicuously included + in any notice in an Executable version, related documentation or + collateral in which You describe recipients' rights relating to the + Covered Code. You may distribute the Executable version of Covered + Code or ownership rights under a license of Your choice, which may + contain terms different from this License, provided that You are in + compliance with the terms of this License and that the license for the + Executable version does not attempt to limit or alter the recipient's + rights in the Source Code version from the rights set forth in this + License. If You distribute the Executable version under a different + license You must make it absolutely clear that any terms which differ + from this License are offered by You alone, not by the Initial + Developer or any Contributor. You hereby agree to indemnify the + Initial Developer and every Contributor for any liability incurred by + the Initial Developer or such Contributor as a result of any such + terms You offer. + + 3.7. Larger Works. + You may create a Larger Work by combining Covered Code with other code + not governed by the terms of this License and distribute the Larger + Work as a single product. In such a case, You must make sure the + requirements of this License are fulfilled for the Covered Code. + +4. Inability to Comply Due to Statute or Regulation. + + If it is impossible for You to comply with any of the terms of this + License with respect to some or all of the Covered Code due to + statute, judicial order, or regulation then You must: (a) comply with + the terms of this License to the maximum extent possible; and (b) + describe the limitations and the code they affect. Such description + must be included in the LEGAL file described in Section 3.4 and must + be included with all distributions of the Source Code. Except to the + extent prohibited by statute or regulation, such description must be + sufficiently detailed for a recipient of ordinary skill to be able to + understand it. + +5. Application of this License. + + This License applies to code to which the Initial Developer has + attached the notice in Exhibit A and to related Covered Code. + +6. Versions of the License. + + 6.1. New Versions. + Netscape Communications Corporation ("Netscape") may publish revised + and/or new versions of the License from time to time. Each version + will be given a distinguishing version number. + + 6.2. Effect of New Versions. + Once Covered Code has been published under a particular version of the + License, You may always continue to use it under the terms of that + version. You may also choose to use such Covered Code under the terms + of any subsequent version of the License published by Netscape. No one + other than Netscape has the right to modify the terms applicable to + Covered Code created under this License. + + 6.3. Derivative Works. + If You create or use a modified version of this License (which you may + only do in order to apply it to code which is not already Covered Code + governed by this License), You must (a) rename Your license so that + the phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape", + "MPL", "NPL" or any confusingly similar phrase do not appear in your + license (except to note that your license differs from this License) + and (b) otherwise make it clear that Your version of the license + contains terms which differ from the Mozilla Public License and + Netscape Public License. (Filling in the name of the Initial + Developer, Original Code or Contributor in the notice described in + Exhibit A shall not of themselves be deemed to be modifications of + this License.) + +7. DISCLAIMER OF WARRANTY. + + COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF + DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. + THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE + IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, + YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE + COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER + OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF + ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER. + +8. TERMINATION. + + 8.1. This License and the rights granted hereunder will terminate + automatically if You fail to comply with terms herein and fail to cure + such breach within 30 days of becoming aware of the breach. All + sublicenses to the Covered Code which are properly granted shall + survive any termination of this License. Provisions which, by their + nature, must remain in effect beyond the termination of this License + shall survive. + + 8.2. If You initiate litigation by asserting a patent infringement + claim (excluding declatory judgment actions) against Initial Developer + or a Contributor (the Initial Developer or Contributor against whom + You file such action is referred to as "Participant") alleging that: + + (a) such Participant's Contributor Version directly or indirectly + infringes any patent, then any and all rights granted by such + Participant to You under Sections 2.1 and/or 2.2 of this License + shall, upon 60 days notice from Participant terminate prospectively, + unless if within 60 days after receipt of notice You either: (i) + agree in writing to pay Participant a mutually agreeable reasonable + royalty for Your past and future use of Modifications made by such + Participant, or (ii) withdraw Your litigation claim with respect to + the Contributor Version against such Participant. If within 60 days + of notice, a reasonable royalty and payment arrangement are not + mutually agreed upon in writing by the parties or the litigation claim + is not withdrawn, the rights granted by Participant to You under + Sections 2.1 and/or 2.2 automatically terminate at the expiration of + the 60 day notice period specified above. + + (b) any software, hardware, or device, other than such Participant's + Contributor Version, directly or indirectly infringes any patent, then + any rights granted to You by such Participant under Sections 2.1(b) + and 2.2(b) are revoked effective as of the date You first made, used, + sold, distributed, or had made, Modifications made by that + Participant. + + 8.3. If You assert a patent infringement claim against Participant + alleging that such Participant's Contributor Version directly or + indirectly infringes any patent where such claim is resolved (such as + by license or settlement) prior to the initiation of patent + infringement litigation, then the reasonable value of the licenses + granted by such Participant under Sections 2.1 or 2.2 shall be taken + into account in determining the amount or value of any payment or + license. + + 8.4. In the event of termination under Sections 8.1 or 8.2 above, + all end user license agreements (excluding distributors and resellers) + which have been validly granted by You or any distributor hereunder + prior to termination shall survive termination. + +9. LIMITATION OF LIABILITY. + + UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT + (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL + DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE, + OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR + ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY + CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, + WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER + COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN + INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF + LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY + RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW + PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE + EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO + THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU. + +10. U.S. GOVERNMENT END USERS. + + The Covered Code is a "commercial item," as that term is defined in + 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer + software" and "commercial computer software documentation," as such + terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 + C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), + all U.S. Government End Users acquire Covered Code with only those + rights set forth herein. + +11. MISCELLANEOUS. + + This License represents the complete agreement concerning subject + matter hereof. If any provision of this License is held to be + unenforceable, such provision shall be reformed only to the extent + necessary to make it enforceable. This License shall be governed by + California law provisions (except to the extent applicable law, if + any, provides otherwise), excluding its conflict-of-law provisions. + With respect to disputes in which at least one party is a citizen of, + or an entity chartered or registered to do business in the United + States of America, any litigation relating to this License shall be + subject to the jurisdiction of the Federal Courts of the Northern + District of California, with venue lying in Santa Clara County, + California, with the losing party responsible for costs, including + without limitation, court costs and reasonable attorneys' fees and + expenses. The application of the United Nations Convention on + Contracts for the International Sale of Goods is expressly excluded. + Any law or regulation which provides that the language of a contract + shall be construed against the drafter shall not apply to this + License. + +12. RESPONSIBILITY FOR CLAIMS. + + As between Initial Developer and the Contributors, each party is + responsible for claims and damages arising, directly or indirectly, + out of its utilization of rights under this License and You agree to + work with Initial Developer and Contributors to distribute such + responsibility on an equitable basis. Nothing herein is intended or + shall be deemed to constitute any admission of liability. + +13. MULTIPLE-LICENSED CODE. + + Initial Developer may designate portions of the Covered Code as + "Multiple-Licensed". "Multiple-Licensed" means that the Initial + Developer permits you to utilize portions of the Covered Code under + Your choice of the NPL or the alternative licenses, if any, specified + by the Initial Developer in the file described in Exhibit A. + +EXHIBIT A -Mozilla Public License. + + ``The contents of this file are subject to the Mozilla Public License + Version 1.1 (the "License"); you may not use this file except in + compliance with the License. You may obtain a copy of the License at + http://www.mozilla.org/MPL/ + + Software distributed under the License is distributed on an "AS IS" + basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the + License for the specific language governing rights and limitations + under the License. + + The Original Code is ___Monster_____________________________. + + The Initial Developer of the Original Code is ___VoIP INC___. + Portions created by ______________________ are Copyright (C) _2015_ + _______________________. All Rights Reserved. + + Contributor(s): __Jean-Roch Maitre____________________________. + __Maxime Roux______________________________. + __Joris Tirado______________________________. + + Alternatively, the contents of this file may be used under the terms + of the _____ license (the "[___] License"), in which case the + provisions of [______] License are applicable instead of those + above. If you wish to allow use of your version of this file only + under the terms of the [____] License and not to allow others to use + your version of this file under the MPL, indicate your decision by + deleting the provisions above and replace them with the notice and + other provisions required by the [___] License. If you do not delete + the provisions above, a recipient may use your version of this file + under either the MPL or the [___] License." + + [NOTE: The text of this Exhibit A may differ slightly from the text of + the notices in the Source Code files of the Original Code. You should + use the text of this Exhibit A rather than the text found in the + Original Code Source Code for Your Modifications.] diff --git a/src/apps/callflows/app.js b/src/apps/callflows/app.js new file mode 100644 index 0000000..1574125 --- /dev/null +++ b/src/apps/callflows/app.js @@ -0,0 +1,1922 @@ +define(function(require){ + var $ = require('jquery'), + _ = require('underscore'), + monster = require('monster'); + + require([ + './submodules/misc/misc', + './submodules/blacklist/blacklist', + './submodules/conference/conference', + './submodules/device/device', + './submodules/directory/directory', + './submodules/faxbox/faxbox', + './submodules/groups/groups', + './submodules/media/media', + './submodules/menu/menu', + './submodules/qubicle/qubicle', + './submodules/resource/resource', + './submodules/timeofday/timeofday', + './submodules/user/user', + './submodules/vmbox/vmbox', + './submodules/featurecodes/featurecodes', + './submodules/temporalset/temporalset' + ]); + + var app = { + name: 'callflows', + + css: [ 'app', 'icons' ], + + i18n: { + 'en-US': { customCss: false } + }, + + // Defines API requests not included in the SDK + requests: {}, + + // Define the events available for other apps + subscribe: { + 'callflows.fetchActions': 'define_callflow_nodes' + }, + + subModules: ['misc', 'blacklist', 'conference', 'device', 'directory', 'faxbox', 'groups', 'media', 'menu', 'qubicle', 'resource', 'timeofday', 'user', 'vmbox', 'featurecodes', 'temporalset'], + + appFlags: { + flow: {}, + + // For now we use that to only load the numbers classifiers the first time we load the app, since it is very unlikely to change often + appData: {}, + + showAllCallflows: (monster.config.hasOwnProperty('developerFlags') && monster.config.developerFlags.showAllCallflows) || monster.apps.auth.originalAccount.superduper_admin + }, + + actions: {}, + categories: {}, + flow: {}, + + // Method used by the Monster-UI Framework, shouldn't be touched unless you're doing some advanced kind of stuff! + load: function(callback){ + var self = this; + + self.initApp(function() { + callback && callback(self); + }); + }, + + // Method used by the Monster-UI Framework, shouldn't be touched unless you're doing some advanced kind of stuff! + initApp: function(callback) { + var self = this; + + /* Used to init the auth token and account id of self app */ + monster.pub('auth.initApp', { + app: self, + callback: callback + }); + }, + + // Entry Point of the app + render: function(container){ + var self = this, + parent = _.isEmpty(container) ? $('#monster_content') : container; + + monster.pub('callflows.fetchActions', { actions: self.actions }); + + self.renderEntityManager(parent); + }, + + renderCallflows: function(container){ + var self = this, + callflowsTemplate = $(monster.template(self, 'callflow-manager', { + canToggleCallflows: (monster.config.hasOwnProperty('developerFlags') && monster.config.developerFlags.showAllCallflows) || monster.apps.auth.originalAccount.superduper_admin, + hasAllCallflows: self.appFlags.showAllCallflows + })); + + self.bindCallflowsEvents(callflowsTemplate, container); + + monster.ui.tooltips(callflowsTemplate); + + self.repaintList({ + template: callflowsTemplate, + callback: function() { + (container) + .empty() + .append(callflowsTemplate); + + container.find('.search-query').focus(); + + self.hackResize(callflowsTemplate); + } + }); + }, + + bindCallflowsEvents: function(template, container) { + var self = this, + callflowList = template.find('.list-container .list'), + isLoading = false, + loader = $('
  • '), + searchLink = $(monster.template(self, 'callflowList-searchLink')); + + template.find('.superadmin-mode #switch_role').on('change', function(e) { + self.appFlags.showAllCallflows = $(this).is(':checked'); + + self.renderCallflows(container); + }); + + // Add Callflow + template.find('.list-add').on('click', function() { + template.find('.callflow-content') + .removeClass('listing-mode') + .addClass('edition-mode'); + + self.editCallflow(); + }); + + // Edit Callflow + callflowList.on('click', '.list-element', function() { + var $this = $(this), + callflowId = $this.data('id'); + + template.find('.callflow-content') + .removeClass('listing-mode') + .addClass('edition-mode'); + + self.editCallflow({ id: callflowId }); + }); + + callflowList.on('scroll', function() { + if(!isLoading && callflowList.data('next-key') && (callflowList.scrollTop() >= (callflowList[0].scrollHeight - callflowList.innerHeight() - 100))) { + isLoading = true; + callflowList.append(loader); + + self.listData({ + callback: function(callflowData) { + var listCallflows = monster.template(self, 'callflowList', { callflows: callflowData.data }); + + loader.remove(); + + callflowList + .append(listCallflows) + .data('next-key', callflowData.next_start_key || null); + + isLoading = false; + }, + nextStartKey: callflowList.data('next-key'), + searchValue: callflowList.data('search-value') + }); + } + }); + + // Search list + template.find('.search-query').on('keyup', function() { + var search = $(this).val(); + + searchLink.find('.search-value').text(search); + if(search) { + $.each(template.find('.list-element'), function() { + var $elem = $(this); + if($elem.data('search').toLowerCase().indexOf(search.toLowerCase()) >= 0) { + $elem.show(); + } else { + $elem.hide(); + } + }); + callflowList.prepend(searchLink); + } else { + template.find('.list-element').show(); + searchLink.remove(); + } + }); + + callflowList.on('click', '.search-link', function() { + if(searchLink.hasClass('active')) { + callflowList.data('search-value', null); + searchLink.removeClass('active') + .remove(); + template.find('.search-query').prop('disabled', false) + .val(''); + self.repaintList({template: template}); + } else { + var searchValue = searchLink.find('.search-value').text(); + searchLink.addClass('active') + .remove(); + callflowList.data('search-value', searchValue); + + template.find('.search-query').prop('disabled', true); + + self.repaintList({ + template: template, + searchValue: searchValue, + callback: function() { + callflowList.prepend(searchLink); + } + }); + } + }); + }, + + renderEntityManager: function(container) { + var self = this, + entityActions = _.indexBy(_.filter(self.actions, function(action) { + return action.hasOwnProperty('listEntities'); + }), 'module'), + template = $(monster.template(self, 'layout', { actions: entityActions })); + + self.bindEntityManagerEvents({ + parent: container, + template: template, + actions: entityActions + }); + + container + .empty() + .append(template); + }, + + bindEntityManagerEvents: function(args) { + var self = this, + parent = args.parent, + template = args.template, + actions = args.actions, + editEntity = function(type, id) { + + monster.pub(actions[type].editEntity, { + data: id ? { id: id } : {}, + parent: template, + target: template.find('.entity-edition .entity-content'), + callbacks: { + after_render: function() { + $(window).trigger('resize'); + template.find('.entity-edition .callflow-content').animate({ scrollTop: 0 }); + }, + save_success: function(data) { + self.refreshEntityList({ + template: template, + actions: actions, + entityType: type + }); + editEntity(type, data.id); + }, + delete_success: function(data) { + self.refreshEntityList({ + template: template, + actions: actions, + entityType: type + }); + template.find('.entity-edition .entity-content').empty(); + } + } + }); + }; + + self.hackResize(template.find('.entity-edition')); + + template.find('.entity-manager .entity-element').on('click', function() { + var $this = $(this); + if($this.hasClass('callflow-element')) { + self.renderCallflows(template.find('.callflow-edition')); + + template.find('.callflow-app-section').hide(); + template.find('.callflow-edition').show(); + } + else if($this.hasClass('account-element')) { + self.renderAccountSettings(template.find('.callflow-edition')); + + template.find('.callflow-app-section').hide(); + template.find('.callflow-edition').show(); + } + else if($this.hasClass('feature-code-element')) { + monster.pub('callflows.featurecode.render', template.find('.callflow-edition')); + + template.find('.callflow-app-section').hide(); + template.find('.callflow-edition').show(); + } + else { + var entityType = $this.data('type'); + template.find('.entity-edition .entity-header .entity-title').text(actions[entityType].name); + self.refreshEntityList({ + template: template, + actions: actions, + entityType: entityType + }); + } + }); + + template.on('click', '.entity-header .back-button', function() { + template.find('.entity-edition .entity-content').empty(); + template.find('.entity-edition .list-container .list').empty(); + template.find('.entity-edition .search-query').val(''); + template.find('.callflow-edition').empty(); + + template.find('.callflow-app-section').hide(); + template.find('.entity-manager').show(); + }); + + template.find('.entity-edition .list-add').on('click', function() { + var type = template.find('.entity-edition .list-container .list').data('type'); + editEntity(type); + }); + + template.find('.entity-edition .list-container .list').on('click', '.list-element', function() { + var $this = $(this), + id = $this.data('id'), + type = $this.parents('.list').data('type'); + + editEntity(type, id); + }); + + template.find('.entity-edition .search-query').on('keyup', function() { + var search = $(this).val(); + if(search) { + $.each(template.find('.entity-edition .list-element'), function() { + var $elem = $(this); + if($elem.data('search').toLowerCase().indexOf(search.toLowerCase()) >= 0) { + $elem.show(); + } else { + $elem.hide(); + } + }); + } else { + template.find('.entity-edition .list-element').show(); + } + }); + }, + + refreshEntityList: function(args) { + var self = this, + template = args.template, + actions = args.actions, + entityType = args.entityType, + callback = args.callbacks; + + actions[entityType].listEntities(function(entities) { + self.formatEntityData(entities, entityType); + var listEntities = $(monster.template(self, 'entity-list', { entities: entities })); + + monster.ui.tooltips(listEntities); + + template.find('.entity-edition .list-container .list') + .empty() + .append(listEntities) + .data('type', entityType); + + template.find('.callflow-app-section').hide(); + template.find('.entity-edition').show(); + template.find('.search-query').focus(); + + $(window).trigger('resize'); + + callback && callback(); + }); + }, + + formatEntityData: function(entities, entityType) { + var self = this; + _.each(entities, function(entity) { + if(entity.first_name && entity.last_name) { + entity.displayName = entity.first_name + ' ' + entity.last_name; + } else if(entity.name) { + entity.displayName = entity.name; + } else { + entity.displayName = entity.id; + } + + switch(entityType) { + case 'play': //media + if(entity.media_source) { + entity.additionalInfo = self.i18n.active().callflows.media.mediaSources[entity.media_source] + } + break; + } + }); + }, + + renderAccountSettings: function(container) { + var self = this; + + self.loadAccountSettingsData(function(accountSettingsData) { + var formattedData = self.formatAccountSettingsData(accountSettingsData), + template = $(monster.template(self, 'accountSettings', formattedData)), + widgetBlacklist = self.renderBlacklists(template, accountSettingsData); + + monster.ui.tooltips(template); + + template.find('.cid-number-select, .preflow-callflows-dropdown').chosen({ search_contains: true, width: '220px' }); + container.empty().append(template); + self.bindAccountSettingsEvents(template, accountSettingsData, widgetBlacklist); + }); + }, + + formatAccountSettingsData: function(data) { + var formattedData = data; + + formattedData.silenceMedia = 'silence_stream://300000'; + + formattedData.extra = formattedData.extra || {}; + formattedData.extra.isShoutcast = false; + + formattedData.extra.preflowCallflows = []; + _.each(formattedData.callflows, function(callflow) { + if (callflow.featurecode === false && callflow.numbers && callflow.numbers.length && callflow.numbers.indexOf('no_match') < 0) { + formattedData.extra.preflowCallflows.push({ + id: callflow.id, + friendlyName: callflow.name || callflow.numbers.toString() + }); + } + }); + + formattedData.extra.preflowCallflows = _.sortBy(formattedData.extra.preflowCallflows, 'friendlyName'); + + delete formattedData.callflows; + + if (formattedData.account.hasOwnProperty('music_on_hold') && formattedData.account.music_on_hold.hasOwnProperty('media_id')) { + if (formattedData.account.music_on_hold.media_id.indexOf('://') >= 0) { + if (formattedData.account.music_on_hold.media_id !== formattedData.silenceMedia) { + formattedData.extra.isShoutcast = true; + } + } + } + + if (formattedData.hasOwnProperty('outbound_flags')) { + if (formattedData.outbound_flags.hasOwnProperty('dynamic')) { + formattedData.outbound_flags.dynamic = formattedData.outbound_flags.dynamic.join(','); + } + if (formattedData.outbound_flags.hasOwnProperty('static')) { + formattedData.outbound_flags.static = formattedData.outbound_flags.static.join(','); + } + } + + return formattedData; + }, + + renderBlacklists: function(template, accountSettingsData) { + var self = this, + items = [], + selectedBlacklists = []; + + _.each(accountSettingsData.blacklists, function(blacklist) { + items.push({ + key: blacklist.id, + value: blacklist.name + }); + }); + selectedBlacklists = _.filter(items, function(bl) { + return (accountSettingsData.account.blacklists || []).indexOf(bl.key) >= 0; + }); + + // we return it so we can use the getSelectedItems() method later + return monster.ui.linkedColumns(template.find('.blacklists-wrapper'), items, selectedBlacklists); + }, + + bindAccountSettingsEvents: function(template, data, widgetBlacklist) { + var self = this, + // account = args.account, + mediaToUpload, + closeUploadDiv = function(newMedia) { + mediaToUpload = undefined; + template.find('.upload-div input').val(''); + template.find('.upload-div').slideUp(function() { + template.find('.upload-toggle').removeClass('active'); + }); + if(newMedia) { + var mediaSelect = template.find('.media-dropdown'); + mediaSelect.append(''); + mediaSelect.val(newMedia.id); + } + }; + + template.find('.account-settings-tabs a').click(function(e) { + e.preventDefault(); + + $(this).tab('show'); + }); + + monster.ui.validate(template.find('#account_settings_form'), { + rules: { + 'extra.shoutcastUrl': { + protocol: true, + required: true + } + } + }); + + template.find('.media-dropdown').on('change', function() { + template.find('.shoutcast-div').toggleClass('active', $(this).val() === 'shoutcast').find('input').val(''); + }); + + template.find('.upload-input').fileUpload({ + inputOnly: true, + wrapperClass: 'file-upload input-append', + btnText: self.i18n.active().callflows.accountSettings.musicOnHold.audioUploadButton, + btnClass: 'monster-button', + maxSize: 5, + success: function(results) { + mediaToUpload = results[0]; + }, + error: function(errors) { + if(errors.hasOwnProperty('size') && errors.size.length > 0) { + monster.ui.alert(self.i18n.active().callflows.accountSettings.musicOnHold.fileTooBigAlert); + } + template.find('.upload-div input').val(''); + mediaToUpload = undefined; + } + }); + + template.find('.upload-toggle').on('click', function() { + if($(this).hasClass('active')) { + template.find('.upload-div').stop(true, true).slideUp(); + } else { + template.find('.upload-div').stop(true, true).slideDown(); + } + }); + + template.find('.upload-cancel').on('click', function() { + closeUploadDiv(); + }); + + template.find('.upload-submit').on('click', function() { + template.find('.shoutcast-div').removeClass('active'); + if(mediaToUpload) { + self.callApi({ + resource: 'media.create', + data: { + accountId: self.accountId, + data: { + streamable: true, + name: mediaToUpload.name, + media_source: "upload", + description: mediaToUpload.name + } + }, + success: function(data, status) { + var media = data.data; + self.callApi({ + resource: 'media.upload', + data: { + accountId: self.accountId, + mediaId: media.id, + data: mediaToUpload.file + }, + success: function(data, status) { + closeUploadDiv(media); + }, + error: function(data, status) { + self.callApi({ + resource: 'media.delete', + data: { + accountId: self.accountId, + mediaId: media.id, + data: {} + }, + success: function(data, status) {} + }); + } + }); + } + }); + } else { + monster.ui.alert(self.i18n.active().callflows.accountSettings.musicOnHold.emptyUploadAlert); + } + }); + + template.find('.account-settings-update').on('click', function() { + if (monster.ui.valid(template.find('#account_settings_form'))) { + var formData = monster.ui.getFormData('account_settings_form'), + newData = $.extend(true, {}, data.account, formData); + + if (formData.music_on_hold.media_id === '') { + delete newData.music_on_hold.media_id; + } else if (formData.music_on_hold.media_id === 'shoutcast') { + newData.music_on_hold.media_id = template.find('.shoutcast-url-input').val(); + } + + if (formData.caller_id.external.name === '') { + delete newData.caller_id.external.name; + } + if (formData.caller_id.external.number === '') { + delete newData.caller_id.external.number; + } + + if (formData.preflow.always === '_disabled') { + delete newData.preflow.always; + } + + if (newData.hasOwnProperty('outbound_flags')) { + newData.outbound_flags.dynamic = newData.outbound_flags.dynamic ? newData.outbound_flags.dynamic.split(',') : []; + newData.outbound_flags.static = newData.outbound_flags.static ? newData.outbound_flags.static.split(',') : []; + _.isEmpty(newData.outbound_flags.dynamic) && delete newData.outbound_flags.dynamic; + _.isEmpty(newData.outbound_flags.static) && delete newData.outbound_flags.static; + _.isEmpty(newData.outbound_flags) && delete newData.outbound_flags; + } + + newData.blacklists = widgetBlacklist.getSelectedItems(); + + delete newData.extra; + + self.callApi({ + resource: 'account.update', + data: { + accountId: newData.id, + data: newData + }, + success: function(data, status) { + self.render(); + } + }); + } + }); + }, + + loadAccountSettingsData: function(callback) { + var self = this; + monster.parallel({ + account: function(parallelCallback) { + self.callApi({ + resource: 'account.get', + data: { + accountId: self.accountId + }, + success: function(data, status) { + parallelCallback && parallelCallback(null, data.data); + } + }); + }, + callflows: function(parallelCallback) { + self.callApi({ + resource: 'callflow.list', + data: { + accountId: self.accountId, + filters: { + paginate: false + } + }, + success: function(data, status) { + parallelCallback && parallelCallback(null, data.data); + } + }); + }, + mediaList: function(parallelCallback) { + self.callApi({ + resource: 'media.list', + data: { + accountId: self.accountId, + filters: { + paginate: false + } + }, + success: function(data, status) { + parallelCallback && parallelCallback(null, data.data); + } + }); + }, + numberList: function(parallelCallback) { + self.callApi({ + resource: 'numbers.list', + data: { + accountId: self.accountId, + filters: { + paginate: false + } + }, + success: function(data, status) { + parallelCallback && parallelCallback(null, data.data.numbers); + } + }); + }, + blacklists: function(parallelCallback) { + self.callApi({ + resource: 'blacklist.list', + data: { + accountId: self.accountId, + filters: { + paginate: false + } + }, + success: function(data, status) { + parallelCallback && parallelCallback(null, data.data); + } + }); + } + }, function(err, results) { + callback && callback(results); + }); + }, + + hackResize: function(container) { + var self = this; + + // Adjusting the layout divs height to always fit the window's size + $(window).resize(function(e) { + var $listContainer = container.find('.list-container'), + $mainContent = container.find('.callflow-content'), + $tools = container.find('.tools'), + $flowChart = container.find('.flowchart'), + contentHeight = window.innerHeight - $('.core-topbar-wrapper').outerHeight(), + contentHeightPx = contentHeight + 'px', + innerContentHeightPx = (contentHeight-71) + 'px'; + + $listContainer.css('height', window.innerHeight - $listContainer.position().top + 'px'); + $mainContent.css('height', contentHeightPx); + $tools.css('height', innerContentHeightPx); + $flowChart.css('height', innerContentHeightPx); + }); + $(window).resize(); + }, + + repaintList: function(args) { + var self = this, + args = args || {}, + template = args.template || $('#callflow_container'), + callback = args.callback; + + self.listData({ + callback: function(callflowData) { + var listCallflows = monster.template(self, 'callflowList', { callflows: callflowData.data }); + + template.find('.list-container .list') + .empty() + .append(listCallflows) + .data('next-key', callflowData.next_start_key || null); + + callback && callback(callflowData.data); + }, + searchValue: args.searchValue + }); + }, + + listData: function(args) { + var self = this, + nextStartKey = args.nextStartKey, + searchValue = args.searchValue, + callback = args.callback, + apiResource = 'callflow.list', + apiData = { + accountId: self.accountId + }; + + if(nextStartKey) { + $.extend(true, apiData, { + filters: { + 'start_key': encodeURIComponent(nextStartKey) + } + }); + } + + if(!self.appFlags.showAllCallflows) { + $.extend(true, apiData, { + filters: { + 'filter_not_ui_metadata.origin': [ + 'voip', + 'callqueues' + ] + } + }); + } + + if(searchValue) { + apiResource = 'callflow.searchByNameAndNumber'; + apiData.value = encodeURIComponent(searchValue); + } + + self.callApi({ + resource: apiResource, + data: apiData, + success: function(callflowData) { + var returnedCallflowData = self.formatData(callflowData); + + callback && callback(returnedCallflowData); + } + }); + }, + + listNumbers: function(callback) { + var self = this; + + self.callApi({ + resource: 'numbers.list', + data: { + accountId: self.accountId, + filters: { + paginate: false + } + }, + success: function(numbers) { + numbers = self.formatListSpareNumbers(numbers.data.numbers); + + callback && callback(numbers); + } + }); + }, + + formatListSpareNumbers: function(numbers) { + var self = this, + listSpareNumbers = []; + + _.each(numbers, function(numberData, phoneNumber) { + if(!numberData.hasOwnProperty('used_by') || numberData.used_by === '') { + numberData.phoneNumber = phoneNumber; + listSpareNumbers.push(numberData); + } + }); + + return listSpareNumbers; + }, + + formatData: function(data) { + var formattedList = []; + + _.each(data.data, function(callflow) { + var formattedNumbers = _.map(callflow.numbers || '-', function(number) { + return monster.util.formatPhoneNumber(number); + }), + listNumbers = formattedNumbers.toString(), + isFeatureCode = callflow.featurecode !== false && !_.isEmpty(callflow.featurecode); + + if (!isFeatureCode) { + if (callflow.name) { + callflow.description = listNumbers; + callflow.title = callflow.name; + } else { + callflow.title = listNumbers; + } + + formattedList.push(callflow); + } + }); + + formattedList.sort(function(a, b) { + return a.title.toLowerCase() < b.title.toLowerCase() ? -1 : 1; + }); + + data.data = formattedList; + + return data; + }, + + editCallflow: function(data) { + var self = this; + + delete self.original_flow; // clear original_flow + + $('#callflow-view .callflow_help').hide(); + + self.resetFlow(); + + if(data && data.id) { + self.callApi({ + resource: 'callflow.get', + data: { + accountId: self.accountId, + callflowId: data.id + }, + success: function(callflow) { + var callflow = callflow.data; + + //self.resetFlow(); + self.dataCallflow = callflow; + + self.flow.id = callflow.id; + self.flow.name = callflow.name; + self.flow.contact_list = { exclude: 'contact_list' in callflow ? callflow.contact_list.exclude || false : false }; + self.flow.caption_map = callflow.metadata; + + if(callflow.flow.module != undefined) { + self.flow.root = self.buildFlow(callflow.flow, self.flow.root, 0, '_'); + } + + self.flow.numbers = callflow.numbers || []; + + self.repaintFlow(); + } + }); + } + else { + self.resetFlow(); + self.dataCallflow = {}; + self.repaintFlow(); + } + + self.renderButtons(); + self.renderTools(); + }, + + renderButtons: function() { + var self = this, + buttons = $(monster.template(self, 'buttons')); + + $('.buttons').empty(); + + $('.save', buttons).click(function() { + if(self.flow.numbers && self.flow.numbers.length > 0) { + self.save(); + } + else { + monster.ui.alert(self.i18n.active().oldCallflows.invalid_number + '

    ' + self.i18n.active().oldCallflows.please_select_valid_number); + } + }); + + $('.delete', buttons).click(function() { + if(self.flow.id) { + monster.ui.confirm(self.i18n.active().oldCallflows.are_you_sure, function() { + self.callApi({ + resource: 'callflow.delete', + data: { + accountId: self.accountId, + callflowId: self.flow.id + }, + success: function() { + $('#ws_cf_flow').empty(); + $('.buttons').empty(); + $('#ws_cf_tools').empty(); + $('#hidden_callflow_warning').hide() + + self.repaintList(); + self.resetFlow(); + } + }); + + self.show_pending_change(false); + }); + } + else { + monster.ui.alert(self.i18n.active().oldCallflows.this_callflow_has_not_been_created); + } + }); + + $('.buttons').append(buttons); + }, + + // Callflow JS code + buildFlow: function (json, parent, id, key) { + var self = this, + branch = self.branch(self.construct_action(json)); + + branch.data.data = ('data' in json) ? json.data : {}; + branch.id = ++id; + branch.key = key; + + branch.caption = self.actions.hasOwnProperty(branch.actionName) ? self.actions[branch.actionName].caption(branch, self.flow.caption_map) : ''; + + if(self.actions.hasOwnProperty(parent.actionName) && self.actions[parent.actionName].hasOwnProperty('key_caption')) { + branch.key_caption = self.actions[parent.actionName].key_caption(branch, self.flow.caption_map); + } + + if(json.hasOwnProperty('children')) { + $.each(json.children, function(key, child) { + branch = self.buildFlow(child, branch, id, key); + }); + } + + parent.addChild(branch); + + return parent; + }, + + construct_action: function(json) { + var action = ''; + + if('data' in json) { + if('id' in json.data) { + action = 'id=*,'; + } + + if('action' in json.data) { + action += 'action=' + json.data.action + ','; + } + } + + if(action != '') { + action = '[' + action.replace(/,$/, ']'); + } + else { + action = '[]'; + } + + return json.module + action; + }, + + resetFlow: function() { + var self = this; + + self.flow = {}; + self.flow.root = self.branch('root'); // head of the flow tree + self.flow.root.key = 'flow'; + self.flow.numbers = []; + self.flow.caption_map = {}; + self.formatFlow(); + }, + + formatFlow: function() { + var self = this; + + self.flow.root.index(0); + self.flow.nodes = self.flow.root.nodes(); + }, + + // Create a new branch node for the flow + branch: function(actionName) { + var self = this; + + function branch(actionName) { + var that = this, + action = self.actions[actionName] || {}; + + this.id = -1; + this.actionName = actionName; + this.module = action.module; + this.key = '_'; + this.parent = null; + this.children = []; + this.data = { + data: $.extend(true, {}, action.data) + }; + this.caption = ''; + this.key_caption = ''; + + this.potentialChildren = function() { + var list = []; + + for(var i in self.actions) { + if(self.actions[i].isUsable) { + list[i] = i; + } + } + + for(var i in action.rules) { + var rule = action.rules[i]; + + switch (rule.type) { + case 'quantity': + if(this.children.length >= rule.maxSize) { + list = []; + } + break; + } + } + + return list; + } + + this.contains = function(branch) { + var toCheck = branch; + + while(toCheck.parent) { + if(this.id == toCheck.id) { + return true; + } + else { + toCheck = toCheck.parent; + } + } + + return false; + } + + this.removeChild = function(branch) { + $.each(this.children, function(i, child) { + if(child.id == branch.id) { + that.children.splice(i,1); + return false; + } + }); + } + + this.addChild = function(branch) { + if(!(branch.actionName in this.potentialChildren())) { + return false; + } + + if(branch.contains(this)) { + return false; + } + + if(branch.parent) { + branch.parent.removeChild(branch); + } + + branch.parent = this; + + this.children.push(branch); + + return true; + } + + this.getMetadata = function(key) { + var value; + + if('data' in this.data && key in this.data.data) { + value = this.data.data[key]; + + return (value == 'null') ? null : value; + } + + return false; + } + + this.setMetadata = function(key, value) { + if(!('data' in this.data)) { + this.data.data = {}; + } + + this.data.data[key] = (value == null) ? 'null' : value; + } + + this.deleteMetadata = function(key) { + if('data' in this.data && key in this.data.data) { + delete this.data.data[key]; + } + } + + this.index = function (index) { + this.id = index; + + $.each(this.children, function() { + index = this.index(index+1); + }); + + return index; + } + + this.nodes = function() { + var nodes = {}; + + nodes[this.id] = this; + + $.each(this.children, function() { + var buf = this.nodes(); + + $.each(buf, function() { + nodes[this.id] = this; + }); + }); + + return nodes; + } + + this.serialize = function () { + var json = $.extend(true, {}, this.data); + + json.module = this.module; + + json.children = {}; + + $.each(this.children, function() { + json.children[this.key] = this.serialize(); + }); + + return json; + } + } + + return new branch(actionName); + }, + + repaintFlow: function() { + var self = this; + + // Let it there for now, if we need to save callflows automatically again. + /*if('savable' in THIS.flow) { + THIS.save_callflow_no_loading(); + }*/ + + self.flow.savable = true; + + var target = $('#ws_cf_flow').empty(); + + target.append(this.getUIFlow()); + + var current_flow = self.stringify_flow(self.flow); + + if (!('original_flow' in self) || self.original_flow.split('|')[0] !== current_flow.split('|')[0]) { + self.original_flow = current_flow; + self.show_pending_change(false); + } else { + self.show_pending_change(self.original_flow !== current_flow); + } + + var metadata = self.dataCallflow.hasOwnProperty('ui_metadata') ? self.dataCallflow.ui_metadata : false, + isHiddenCallflow = metadata && metadata.hasOwnProperty('origin') && _.contains(['voip','migration','mobile', 'callqueues'], metadata.origin); + + isHiddenCallflow ? $('#hidden_callflow_warning').show() : $('#hidden_callflow_warning').hide(); + }, + + show_pending_change: function(pending_change) { + var self = this; + if(pending_change) { + $('#pending_change', '#ws_callflow').show(); + $('.save', '#ws_callflow').addClass('pulse-box'); + } else { + $('#pending_change', '#ws_callflow').hide(); + $('.save', '#ws_callflow').removeClass('pulse-box'); + } + }, + + // We add this function because today the stringify flow doesn't handle arrays well + // For instance in ring groups, if we change the timeout of a member, it won't toggle the "pending changes" warning + stringify_obj: function(obj) { + var self = this, + str = '['; + + _.each(obj, function(v, k) { + // Had to add this check since when we list objects with sortable, we usually just add items with .data(), but it includes sortableItem from the jQuery plugin for a short time. + // If we don't avoid it, then we run into a JS Exception + if (k !== 'sortableItem') { + if (typeof v === 'object') { + str += k + ':' + self.stringify_obj(v); + } else if (['boolean', 'string', 'number'].indexOf(typeof v) >= 0) { + str += k + ':' + v; + } + + str += '|'; + } + }); + + str += ']'; + + return str; + }, + + stringify_flow: function(flow) { + var self = this, + s_flow = flow.id + '|' + (!flow.name ? 'undefined' : flow.name), + first_iteration; + s_flow += "|NUMBERS"; + $.each(flow.numbers, function(key, value) { + s_flow += "|" + value; + }); + s_flow += "|NODES"; + $.each(flow.nodes, function(key, value) { + s_flow += "|" + key + "::"; + first_iteration = true; + + $.each(value.data.data, function(k, v) { + if (!first_iteration) { + s_flow += '//'; + } else { + first_iteration = false; + } + + if (typeof v !== 'object') { + s_flow += k + ':' + v; + } else { + s_flow += k + ':' + self.stringify_obj(v); + } + }); + }); + + return s_flow; + }, + + getUIFlow: function() { + var self = this; + + self.formatFlow(); + + var layout = self.renderBranch(self.flow.root); + + $('.node', layout).hover(function() { + $(this).addClass('over'); + }, + function() { + $(this).removeClass('over'); + } + ); + + $('.node', layout).each(function() { + var node = self.flow.nodes[$(this).attr('id')], + $node = $(this), + node_html; + + if (node.actionName == 'root') { + $node.removeClass('icons_black root'); + node_html = $(monster.template(self, 'root', { name: self.flow.name || 'Callflow' })); + + $('.edit_icon', node_html).click(function() { + self.flow = $.extend(true, { contact_list: { exclude: false }} , self.flow); + + var dialogTemplate = monster.template(self, 'editName', { + name: self.flow.name, + exclude: self.flow.contact_list.exclude, + ui_is_main_number_cf: self.dataCallflow.hasOwnProperty('ui_is_main_number_cf') ? self.dataCallflow.ui_is_main_number_cf : false + }), + popup = monster.ui.dialog(dialogTemplate, { + title: self.i18n.active().oldCallflows.popup_title + }); + + $('#add', popup).click(function() { + var $callflow_name = $('#callflow_name', popup); + if($callflow_name.val() != '') { + self.flow.name = $callflow_name.val(); + $('.root .top_bar .name', layout).html(self.flow.name); + } + else { + self.flow.name = ''; + $('.root .top_bar .name', layout).html('Callflow'); + } + self.flow.contact_list = { + exclude: $('#callflow_exclude', popup).prop('checked') + }; + self.dataCallflow.ui_is_main_number_cf = $('#ui_is_main_number_cf', popup).prop('checked'); + //self.save_callflow_no_loading(); + self.repaintFlow(); + popup.dialog('close'); + }); + }); + + $('.tooltip', node_html).click(function() { + monster.ui.dialog(monster.template(self, 'help_callflow')); + }); + + for(var x, size = self.flow.numbers.length, j = Math.floor((size) / 2) + 1, i = 0; i < j; i++) { + x = i * 2; + + var numbers = self.flow.numbers.slice(x, (x + 2 < size) ? x + 2 : size), + row = monster.template(self, 'rowNumber', { numbers: numbers }); + + node_html.find('.content') + .append(row); + } + + $('.number_column.empty', node_html).click(function() { + self.listNumbers(function(phoneNumbers) { + var parsedNumbers = []; + + _.each(phoneNumbers, function(number) { + if($.inArray(number.phoneNumber,self.flow.numbers) < 0) { + parsedNumbers.push(number); + } + }); + + var popup_html = $(monster.template(self, 'addNumber', { phoneNumbers: parsedNumbers })), + popup = monster.ui.dialog(popup_html, { + title: self.i18n.active().oldCallflows.add_number + }); + + popup_html.find('#list_numbers').chosen({ search_contains: true, width: '160px' }); + // Have to do that so that the chosen dropdown isn't hidden. + popup_html.parent().css('overflow', 'visible'); + + if(parsedNumbers.length === 0) { + $('#list_numbers', popup_html).attr('disabled', 'disabled'); + $('').appendTo($('#list_numbers', popup_html)); + } + + var refresh_numbers = function() { + self.listNumbers(function(refreshedNumbers) { + $('#list_numbers', popup).empty(); + + if(refreshedNumbers.length === 0) { + $('#list_numbers', popup).attr('disabled', 'disabled'); + $('').appendTo($('#list_numbers', popup)); + } + else { + $('#list_numbers', popup).removeAttr('disabled'); + $.each(refreshedNumbers, function(k, v) { + $('').appendTo($('#list_numbers', popup)); + }); + } + }); + }; + + $('.extensions_content', popup).hide(); + + $('input[name="number_type"]', popup).click(function() { + if($(this).val() === 'your_numbers') { + $('.list_numbers_content', popup).show(); + $('.extensions_content', popup).hide(); + } + else { + $('.extensions_content', popup).show(); + $('.list_numbers_content', popup).hide(); + } + }); + + popup.find('.buy-link').on('click', function(e) { + e.preventDefault(); + monster.pub('common.buyNumbers', { + searchType: $(this).data('type'), + callbacks: { + success: function(numbers) { + var lastNumber; + + _.each(numbers, function(number, k) { + popup.find('#list_numbers').append($('')); + lastNumber = k; + }); + + popup.find('#list_numbers').val(lastNumber).trigger('chosen:updated'); + } + } + }); + }); + + popup.find('.search-extension-link').on('click', function() { + monster.pub('common.extensionTools.select', { + callback: function(number) { + popup.find('#add_number_text').val(number); + } + }); + }); + + $('.add_number', popup).click(function(event) { + event.preventDefault(); + var number = $('input[name="number_type"]:checked', popup).val() === 'your_numbers' ? $('#list_numbers option:selected', popup).val() : $('#add_number_text', popup).val(); + + if(number !== 'select_none' && number !== '') { + self.flow.numbers.push(number); + popup.dialog('close'); + + self.repaintFlow(); + } + else { + monster.ui.alert(self.i18n.active().oldCallflows.you_didnt_select); + } + }); + }); + }); + + $('.number_column .delete', node_html).click(function() { + var number = $(this).parent('.number_column').data('number') + '', + index = $.inArray(number, self.flow.numbers); + + if(index >= 0) { + self.flow.numbers.splice(index, 1); + } + + self.repaintFlow(); + }); + + } + else { + node_html = $(monster.template(self, 'node', { + node: node, + callflow: self.actions[node.actionName] + })); + + // If an API request takes some time, the user can try to re-click on the element, we do not want to let that re-fire a request to the back-end. + // So we set a 500ms timer that will prevent any other interaction with the callflow element. + var isAlreadyClicked = false; + + node_html.find('.module').on('click', function() { + if(!isAlreadyClicked) { + self.actions[node.actionName].edit(node, function() { + self.repaintFlow(); + }); + + isAlreadyClicked = true; + + setTimeout(function() { + isAlreadyClicked = false; + }, 500); + } + }); + } + + $(this).append(node_html); + + $(this).droppable({ + drop: function (event, ui) { + var target = self.flow.nodes[$(this).attr('id')], + action; + + if (ui.draggable.hasClass('action')) { + action = ui.draggable.attr('name'), + + branch = self.branch(action); + branch.caption = self.actions[action].caption(branch, self.flow.caption_map); + + if (target.addChild(branch)) { + if(branch.parent && ('key_caption' in self.actions[branch.parent.actionName])) { + branch.key_caption = self.actions[branch.parent.actionName].key_caption(branch, self.flow.caption_map); + + self.actions[branch.parent.actionName].key_edit(branch, function() { + self.actions[action].edit(branch, function() { + self.repaintFlow(); + }); + }); + } + else { + self.actions[action].edit(branch, function() { + self.repaintFlow(); + }); + } + + //This is just in case something goes wrong with the dialog + self.repaintFlow(); + } + } + + if (ui.draggable.hasClass('node')) { + var branch = self.flow.nodes[ui.draggable.attr('id')]; + + if (target.addChild(branch)) { + // If we move a node, destroy its key + branch.key = '_'; + + if(branch.parent && ('key_caption' in self.actions[branch.parent.actionName])) { + branch.key_caption = self.actions[branch.parent.actionName].key_caption(branch, self.flow.caption_map); + } + + ui.draggable.remove(); + self.repaintFlow(); + } + } + } + }); + + // dragging the whole branch + if($(this).attr('name') != 'root') { + $(this).draggable({ + start: function () { + var children = $(this).next(), + t = children.offset().top - $(this).offset().top, + l = children.offset().left - $(this).offset().left; + + self.enableDestinations($(this)); + + $(this).attr('t', t); $(this).attr('l', l); + }, + drag: function () { + var children = $(this).next(), + t = $(this).offset().top + parseInt($(this).attr('t')), + l = $(this).offset().left + parseInt($(this).attr('l')); + + children.offset({ top: t, left: l }); + }, + stop: function () { + self.disableDestinations(); + + self.repaintFlow(); + } + }); + } + }); + + $('.node-options .delete', layout).click(function() { + var node = self.flow.nodes[$(this).attr('id')]; + + if (node.parent) { + node.parent.removeChild(node); + + self.repaintFlow(); + } + }); + + return layout; + }, + + renderBranch: function(branch) { + var self = this, + flow = $(monster.template(self, 'branch', { + node: branch, + display_key: branch.parent && ('key_caption' in self.actions[branch.parent.actionName]) + })), + children; + + if(branch.parent && ('key_edit' in self.actions[branch.parent.actionName])) { + $('.div_option', flow).click(function() { + self.actions[branch.parent.actionName].key_edit(branch, function() { + self.repaintFlow(); + }); + }); + } + + // This need to be evaluated before the children start adding content + children = $('.children', flow); + + $.each(branch.children, function() { + children.append(self.renderBranch(this)); + }); + + return flow; + }, + + renderTools: function() { + var self = this, + advanced_cat = self.i18n.active().oldCallflows.advanced_cat, + basic_cat = self.i18n.active().oldCallflows.basic_cat, + dataTemplate = { categories: [] }, + categories = {}, + target, + tools; + + categories[basic_cat] = []; + categories[advanced_cat] = []; + + $.each(self.actions, function(i, data) { + if('category' in data && (!data.hasOwnProperty('isListed') || data.isListed)) { + data.category in categories ? true : categories[data.category] = []; + data.key = i; + categories[data.category].push(data); + } + }); + + $.each(categories, function(key, val) { + if (key !== basic_cat && key !== advanced_cat) { + dataTemplate.categories.push({ key: key, actions: val }); + } + }); + + dataTemplate.categories.sort(function(a, b){ + return a.key < b.key ? 1 : -1; + }); + + dataTemplate.categories.unshift({ + key: basic_cat, + actions: categories[basic_cat] + }, + { + key: advanced_cat, + actions: categories[advanced_cat] + } + ); + + $.each(categories, function(idx, val) { + val.sort(function(a, b){ + if (a.hasOwnProperty('weight')) { + return a.weight > b.weight ? 1 : -1; + } + }); + }); + + tools = $(monster.template(self, 'tools', dataTemplate)); + + $('.tooltip', tools).click(function() { + monster.ui.dialog(monster.template(self, 'help_callflow')); + }); + + // Set the basic drawer to open + $('#Basic', tools).removeClass('inactive').addClass('active'); + + $('.category .open', tools).click(function () { + tools.find('.category') + .removeClass('active') + .addClass('inactive'); + + $(this).parent('.category') + .removeClass('inactive') + .addClass('active'); + }); + + var help_box = $('.callflow_helpbox_wrapper', '#callflow-view').first(), + $allActions = tools.find('.tool'); + + tools.find('.search-query').on('keyup', function() { + // debounce executes a function after a delay if it hasn't been called again + _.debounce(function(arg) { + var $this = arg, + val = $this.val().toLowerCase(), + categories = []; + + if (val) { + tools.find('.category').removeClass('active').addClass('inactive'); + + $allActions.each(function() { + var $thisAction = $(this); + + if ($thisAction.data('name').toLowerCase().indexOf(val) >= 0) { + $thisAction.show(); + categories.push($thisAction.parents('.category').attr('id')); + } else { + $thisAction.hide(); + } + }); + } else { + tools.find('.category').removeClass('active').addClass('inactive'); + tools.find('.category').first().removeClass('inactive').addClass('active'); + tools.find('.tool').show(); + } + + categories = _.uniq(categories); + _.each(categories, function(category) { + tools.find('.category[name="' + category + '"]').addClass('active').removeClass('inactive'); + }); + }, 200)($(this)); + }); + + $('.tool', tools).hover( + function() { + var $this = $(this); + if ($this.attr('help')) { + tools.find('.callflow_helpbox_wrapper #help_box').html($this.attr('help')); + tools.find('.callflow_helpbox_wrapper').css('top', $this.offset().top).css('left', $('#ws_cf_tools').offset().left - 162).show(); + } + }, + function () { + tools.find('.callflow_helpbox_wrapper').hide(); + } + ); + + function action (el) { + el.draggable({ + start: function () { + self.enableDestinations($(this)); + $(this).addClass('inactive'); + }, + drag: function () { + $('.callflow_helpbox_wrapper', '#callflow-view').hide(); + }, + stop: function () { + self.disableDestinations(); + $(this).removeClass('inactive'); + }, + containment: $('body'), + helper: 'clone' + }); + } + + + + $('.action', tools).each(function() { + action($(this)); + }); + + target = $('#ws_cf_tools').empty(); + target.append(tools); + + $('#ws_cf_tools', '#callflow-view').disableSelection(); + }, + + enableDestinations: function(el) { + var self = this; + + $('.node').each(function () { + var activate = true, + target = self.flow.nodes[$(this).attr('id')]; + + if (el.attr('name') in target.potentialChildren()) { + if (el.hasClass('node') && self.flow.nodes[el.attr('id')].contains(target)) { + activate = false; + } + } + else { + activate = false; + } + + if (activate) { + $(this).addClass('active'); + } + else { + $(this).addClass('inactive'); + $(this).droppable('disable'); + } + }); + }, + + disableDestinations: function() { + $('.node').each(function () { + $(this).removeClass('active'); + $(this).removeClass('inactive'); + $(this).droppable('enable'); + }); + + $('.tool').removeClass('active'); + }, + + save: function() { + var self = this; + + if(self.flow.numbers && self.flow.numbers.length > 0) { + var data_request = { + numbers: self.flow.numbers, + flow: (self.flow.root.children[0] == undefined) ? {} : self.flow.root.children[0].serialize() + }; + + if(self.flow.name !== '') { + data_request.name = self.flow.name; + } + else { + delete data_request.name; + delete self.dataCallflow.name; + } + + if('contact_list' in self.flow) { + data_request.contact_list = { exclude: self.flow.contact_list.exclude || false }; + } + + // We don't want to keep the old data from the flow, so we override it with what's on the current screen before the extend. + self.dataCallflow.flow = data_request.flow; + // Change dictated by the new field added by monster-ui. THis way we can potentially update callflows in Kazoo UI without breaking monster. + data_request = $.extend(true, {}, self.dataCallflow, data_request); + delete data_request.metadata; + + if(self.flow.id) { + self.callApi({ + resource: 'callflow.update', + data: { + accountId: self.accountId, + callflowId: self.flow.id, + data: data_request + }, + success: function(json) { + self.repaintList(); + self.editCallflow({id: json.data.id}); + } + }); + } + else { + self.callApi({ + resource: 'callflow.create', + data: { + accountId: self.accountId, + data: data_request + }, + success: function(json) { + self.repaintList(); + self.editCallflow({id: json.data.id}); + } + }); + } + } + else { + monster.ui.alert(self.i18n.active().oldCallflows.you_need_to_select_a_number); + } + }, + + winkstartTabs: function(template, advanced) { + var buttons = template.find('.view-buttons'), + tabs = template.find('.tabs'); + + if(advanced) { + buttons.find('.btn').removeClass('activate'); + buttons.find('.advanced').addClass('activate'); + } else { + if(monster.config.advancedView) { + buttons.find('.btn').removeClass('activate'); + buttons.find('.advanced').addClass('activate'); + } else { + tabs.hide('blind'); + } + } + + if(tabs.find('li').length < 2){ + buttons.hide(); + } + + buttons.find('.basic').on('click', function(){ + var $this = $(this); + + if(!$this.hasClass('activate')){ + buttons.find('.btn').removeClass('activate'); + $this.addClass('activate'); + tabs.find('li:first-child > a').trigger('click'); + tabs.hide('blind'); + } + }); + + buttons.find('.advanced').click(function(){ + var $this = $(this); + + if(!$this.hasClass('activate')){ + buttons.find('.btn').removeClass('activate'); + $this.addClass('activate'); + tabs.show('blind'); + } + }); + + tabs.find('li').on('click', function(ev) { + ev.preventDefault(); + + var $this = $(this), + link = $this.find('a').attr('href'); + + tabs.find('li').removeClass('active'); + template.find('.pill-content >').removeClass('active'); + + $this.addClass('active'); + template.find(link).addClass('active'); + }); + }, + + winkstartLinkForm: function(html) { + $('input', html).bind('change.link keyup.link focus.link', function() { + var input = $(this), + name = input.attr('name'), + type = input.attr('type'), + value = input.val(), + id = input.attr('id'), + input_fields = $('input[name="' + name + '"]', html); + + if(input_fields.size() > 1) { + if(type == 'checkbox'){ + input_fields = input_fields.filter('[value='+value+']'); + (input.attr('checked')) ? input_fields.attr('checked', 'checked') : input_fields.removeAttr('checked'); + } + else { + $.each(input_fields, function(k, v) { + var element = $(v); + + if(element.attr('id') !== id) { + element.val(value); + } + }); + } + } + else { + input.unbind('.link'); + } + }); + } + }; + + return app; +}); diff --git a/src/apps/callflows/i18n/en-US.json b/src/apps/callflows/i18n/en-US.json new file mode 100644 index 0000000..8bfdc83 --- /dev/null +++ b/src/apps/callflows/i18n/en-US.json @@ -0,0 +1,1268 @@ +{ + "callflows": { + "addCallflow": "Add Callfow", + "searchDatabase": "Search Database", + "buyNumbers": "Buy Numbers", + "buyLocal": "Local", + "buyTollfree": "Toll-Free", + "buyVanity": "Vanity", + "qubicle": { + "qubicle": "Qubicle", + "qubicle_tip": "Route to a queue", + "which_queue": "Which queue?" + }, + "conference": { + "conference": "Conference", + "conference_tip": "Connect a caller to a Meet-Me conference bridge", + "conference_service": "Conference Service", + "conference_service_tip": "Transfer the caller to the conference call service, prompting for both a conference number and a pin", + "connect_caller_to_conference": "Connect caller to conference...", + "which_conference": "Which conference?", + "edit_conference_options": "Edit conference options", + "add_conference": "Add a conference", + "edit_conference": "Edit Conference", + "create_conference": "Create Conference", + "basic": "Basic", + "advanced": "Advanced", + "options": "Options", + "conference_server": "Conference Server", + "conference_name": "Conference Name:", + "conference_name_data_content": "Friendly name for this conference", + "assign_to": "Assign To", + "assign_to_data_content": "Select the user who owns this conference", + "edit": "Edit", + "create": "Create", + "pins": "PINs", + "pins_data_content": "A comma separated list of pins, that can be entered to join the conference", + "join_the_conference_muted": "Join the conference muted", + "join_the_conference_muted_data_content": "Check to join the conference muted", + "join_the_conference_deaf": "Join the conference deaf", + "join_the_conference_deaf_data_content": "Check to join the conference deaf", + "numbers": "Numbers", + "numbers_placeholder": "Numbers", + "numbers_data_content": "A comma separated list of numbers, that will be assigned to the conference. Unless you plan to use the 'Conference Service' callflow node - don't worry about this field", + "delete": "Delete", + "save": "Save", + "there_were_errors_on_the_form": "There were errors on the form, please correct!", + "are_you_sure_you_want_to_delete": "Are you sure you want to delete this conference?", + "name": "(name)", + "conferences_label": "Conferences", + "add_conference_label": "Add Conference", + "validation": { + "member_pins_string": "Please only enter alphanumeric characters, space or comma", + "member_numbers_string": "Please only enter numeric characters and space" + }, + "__comment": "UI-1787: Adding play entry tone / play exit tone", + "__version": "3.22", + "play_entry_tone": "Play Entry Tone", + "play_entry_tone_help": "Will play a tone whenever a caller joins the conference if checked", + "play_exit_tone": "Play Exit Tone", + "play_exit_tone_help": "Will play a tone whenever a caller exits the conference if checked" + }, + "device": { + "device": "Device", + "device_tip": "Ring a VoIP or cell phone or other device", + "connect_caller_to_device": "Connect a caller to a device...", + "which_device": "Which Device?", + "edit_phone_options": "Edit phone options", + "add_new_device": "Add a new device", + "ring_this_device_for": "Ring this device for", + "seconds": "seconds", + "allow_this_device_to_call_itself": "Allow this device to call itself.", + "when_you_check_this_box": "When you check this box, calls from the user's own extension to themselves will not ring the extension. This allows them to dial their own number to get to voicemail.", + "device_title": "Device", + "voip_phone": "VoIP Phone", + "cell_phone": "Cell Phone", + "cellphone": "Cell Phone", + "smart_phone": "Smart Phone", + "landline": "Landline", + "soft_phone": "Soft Phone", + "mobile": "Mobile", + "ata": "ATA", + "fax": "Fax", + "sip_uri": "SIP URI", + "add_a_smart_phone": "Add a Smart Phone", + "edit_smart_phone": "Edit Smart Phone", + "basic": "Basic", + "advanced": "Advanced", + "options": "Options", + "wifi_calling": "Wifi Calling", + "restrictions": "Restrictions", + "name": "Name", + "name_data_content": "Friendly name for this device", + "belongs_to": "Belongs To", + "belongs_to_data_content": "Select the owner of this device", + "edit": "Edit", + "create": "Create", + "number": "Number", + "number_data_content": "Outside number you wish to reach", + "enabled": "Enabled", + "enabled_data_content": "Check to enable device.", + "require_key_press": "Require Key Press", + "require_key_press_data_content": "Do you want to require a key press to answer this call", + "keep_caller_id": "Keep Original Caller ID", + "keep_caller_id_data_content": "If set to true it will use the caller-id of the caller", + "hide_from_contact_list": "Hide from Contact List", + "hide_from_contact_list_data_content": "By checking this box, this endpoint will not be added automatically to the contact list of the devices of this platform", + "realm": "Realm", + "authentication_method": "Authentication Method", + "authentication_method_data_content": "Select your authentication method", + "ip_address": "IP Address", + "ip_address_data_content": "Enter the IP Address", + "username": "Username", + "username_data_content": "Enter your SIP Username", + "password": "Password", + "invite_format": "Invite Format", + "invite_format_data_content": "Enter your SIP Invite Format", + "expire_seconds": "Expire Seconds", + "expire_seconds_data_content": "Enter the expiration time of this device (in seconds)", + "closed_groups": "Closed Groups", + "closed_groups_data_content": "If checked, this device will only be able to call the devices that are part of the same groups", + "allow": "Allow", + "deny": "Deny", + "inherit": "Inherit", + "delete": "Delete", + "save": "Save", + "add_a_landline": "Add a Landline", + "edit_landline": "Edit Landline", + "edit_cell_phone": "Edit Cell Phone", + "add_a_cell_phone": "Add a Cell Phone", + "edit_soft_phone": "Edit Soft Phone", + "add_a_soft_phone": "Add a Soft Phone", + "caller_id": "Caller ID", + "sip_settings": "SIP Settings", + "audio_settings": "Audio Settings", + "video_settings": "Video Settings", + "presence_id_title": "", + "presence_id": "Presence ID", + "presence_id_help": "", + "presence_id_placeholder": "", + "device_nickname": "Device Nickname", + "assign_to": "Assign To", + "in_house_calls": "In-House Calls", + "caller_id_name": "Caller ID Name", + "caller_id_name_data_content": "Define the Caller ID Name of this Device for In-House Calls (max. 30 chars).", + "caller_id_number": "Caller ID Number", + "caller_id_number_data_content": "Define the Caller ID Number of this Device for In-House Calls.", + "outbound_calls": "Outbound Calls", + "caller_id_name_data_content2": "Define the Caller ID Name of this Device for Outbound Calls (max. 30 chars).", + "caller_id_number_data_content2": "Define the Caller ID Number of this Device for Outbound Calls.", + "emergency": "Emergency", + "caller_id_name_data_content3": "Define the Caller ID Name of this Device for Emergency Calls (max. 30 chars).", + "caller_id_number_data_content3": "Define the Caller ID Number of this Device for Emergency Calls.", + "music_on_hold": "Music on Hold", + "music_on_hold_data_content": "Select the media file that you want to be played by default when it's not set on a user or a device.", + "peer_to_peer_audio": "Peer to Peer Audio", + "peer_to_peer_audio_data_content": "Select the kind of Peer-to-Peer that you would like to set on this device", + "secure_rtp": "Secure RTP", + "none": "None", + "srtp": "SRTP", + "zrtp": "ZRTP", + "secure_rtp_help": "Select if you want to enable SRTP or ZRTP to encrypt the audio for this device", + "t_38": "T.38", + "t_38_data_content": "When this option is enabled the media servers will attempt to use T.38 between this device/resource and the server.", + "ignore_completed_elsewhere": "Ignore Complete Elsewhere", + "ignore_completed_elsewhere_data_content": "When checked supporting phones will show a call missed if it was part of a ring group answered elsewhere.", + "edit_voip_phone": "Edit VoIP Phone", + "add_a_voip_phone": "Add a VoIP Phone", + "sip": "SIP", + "audio": "Audio", + "video": "Video", + "device_mac_address": "Device MAC Address", + "device_mac_address_data_content": "Enter the MAC Address of this device formatted like: 1A:B2:C6:78:F0:3B", + "notify_when_unregistered": "Notify when unregistered", + "notify_when_unregistered_data_content": "Do you want to notify the administrator each time this device unregisters", + "outbound_flags": "Outbound Flags", + "outbound_flags_data_content": "Enter outbound flags this device requires to be present on the carrier(s). Type a comma between each flag in order to have multiple outbound flags (ex: flag1, flag2, flag3)", + "internal_ringtones": "Internal Ringtones", + "internal_ringtones_data_content": "The alert info SIP header added when the call is from internal sources", + "external_ringtones": "External Ringtones", + "external_ringtones_data_content": "The alert info SIP header added when the call is from external sources", + "edit_fax": "Edit Fax", + "add_a_fax": "Add a Fax", + "edit_ata": "Edit ATA", + "add_a_ata": "Add an ATA", + "edit_sip_uri": "Edit SIP URI", + "add_a_sip_uri": "Add a SIP URI", + "url": "URL", + "url_data_content": "Enter the SIP url. Must look like 'sip:support@company.com'", + "devices_label": "Devices", + "this_mac_address_is_already_in_use": "This MAC Address is already in use, please verify that it is correct.", + "automatic": "Automatic", + "always": "Always", + "never": "Never", + "auto_detect": "Auto-detect", + "always_force": "Always Force", + "disabled": "Disabled", + "default_music": "Default Music", + "silence": "Silence", + "there_were_errors_on_the_form": "There were errors on the form, please correct!", + "are_you_sure_you_want_to_delete": "Are you sure you want to delete this device?", + "no_name": "(no name)", + "add_device_label": "Add Device", + "edit_device": "Edit Device", + "create_device": "Create Device", + "sip_uri_name_regex": "/^[a-zA-Z0-9\\s_']+$/", + "name_regex": "/^[a-zA-Z0-9\\s_'\\-]+$/", + "caller_id_name_regex": "/^[0-9A-Za-z ,]{0,30}$/", + "__comment": "UI-1887: Internationalize the Mobile device view", + "__version": "v3.23", + "view_mobile_phone": "View Mobile", + "mdn": "MDN", + "mdn_data_content": "Mobile Device Number", + "__version": "3.22", + "__comment": "UI-2135: Add an empty option for SIP device brands to support SmartPBX devices", + "none": "- Not set -", + "mediaWebrtc": { + "content": "If checked, forces a WebRTC compatible SDP on the INVITE.", + "label": "WebRTC" + } + }, + "disa": { + "title": "DISA", + "default": "Default", + "pin": { + "label": "PIN" + }, + "retries": { + "label": "Retries", + "help": "The number of times to attempt to collect a pin number after an invalid attempt " + }, + "interdigit": { + "label": "Interdigit", + "help": "The amount of time (in seconds) to wait for the next digit before considering the entry complete " + }, + "max_digits": { + "label": "Max Digits", + "help": "The max digits to collect for the destination number " + }, + "use_account_caller_id": { + "label": "Keep the original Caller-ID", + "help": "If 'checked' then the caller id of the call to disa will be used on the outbound call" + }, + "preconnect_audio": { + "label": "Preconnect Audio", + "help": "This sets what the user should hear after entering a destination number until the outbound call is established", + "ringing": "Ringing", + "dialtone": "Dialtone" + } + }, + "directory": { + "directory": "Directory", + "directory_tip": "Ask the caller to input the first letters of the name of the person that he wants to reach.", + "connect_caller_to_directory": "Connect caller to directory...", + "edit_directory_options": "Edit directory options", + "create": "Create", + "directory_title": "Directory", + "create_directory": "Create Directory", + "edit_directory": "Edit Directory", + "basic": "Basic", + "advanced": "Advanced", + "options": "Options", + "name": "Name", + "name_data_content": "Friendly name for this Directory", + "user": "User", + "callflow": "Callflow", + "remove": "Remove", + "add_user": "Add User", + "select": "Select", + "add_this_user": "Add this user to the directory", + "minimum_number_of_input": "Minimum number of input", + "minimum_number_of_input_placeholder": "Min of input", + "minimum_number_of_input_data_content": "Count of how many DTMFs must be collected before processing begins", + "max_number_of_input": "Max number of input", + "max_number_of_input_placeholder": "Max of input", + "max_number_of_input_data_content": "Count of the most DTMFs collected, once reached the list of matches is played. If set to 0, then there is no limit to the number of DTMFs collected.", + "confirm_match": "Confirm Match", + "confirm_match_data_content": "If only one match is found, is the caller prompted to confirm the match before connecting", + "sort_by": "Sort by", + "sort_by_data_content": "Select your sort method", + "delete": "Delete", + "save": "Save", + "there_is_currently_no_user": "There is currently no user in this directory", + "directory_label": "Directory", + "first_name": "First Name", + "last_name": "Last Name", + "there_were_errors_on_the_form": "There were errors on the form, please correct!", + "are_you_sure_you_want_to_delete": "Are you sure you want to delete this directory?", + "no_name": "(no name)", + "directories_label": "Directories", + "add_directory_label": "Add Directory", + "__comment": "UI-1462: Show errors properly", + "__version": "v3.20_s5", + "noDataSelected": "You need to select a User AND its associated callflow, in order to add it to the directory, make sure both dropdowns have an item selected!", + "__comment": "UI-2712: Handle UX issues with directories", + "__version": "4.1", + "empty": "Empty" + }, + "faxbox": { + "faxboxes_label": "Fax Boxes", + "add_faxbox_label": "Add Fax Box", + "create_faxbox": "Create Fax Box", + "edit_faxbox": "Edit Fax Box", + "basic": "Basic", + "advanced": "Advanced", + "smtp": "SMTP", + "google": "Google", + "options": "Options", + "no_name": "(no name)", + "assign_to": "Assign to", + "no": "- No", + "owner": "owner -", + "edit_user": "Edit", + "create_user": "Create", + "belongs_to_data_content": "Select the owner of this faxbox", + "name": "Faxbox name", + "name_placeholder": "Name", + "name_data_content": "Friendly name for this faxbox", + "caller_name": "Caller name", + "caller_name_placeholder": "Caller name", + "caller_name_data_content": "Caller name for this fax box", + "caller_id": "Caller ID", + "caller_id_placeholder": "Caller ID", + "caller_id_data_content": "Caller ID for this fax box", + "fax_header": "Fax header", + "fax_header_placeholder": "Fax header", + "fax_header_data_content": "Information imprinted on the fax", + "smtp_permission_list": "SMTP permission list", + "smtp_permission_list_placeholder": "@domain1.com, noreply@domain2.com", + "smtp_permission_list_data_content": "", + "fax_identity": "Fax identity", + "fax_identity_placeholder": "Fax identity", + "fax_identity_data_content": "Phone number imprinted on the fax", + "fax_timezone": "Fax timezone", + "fax_timezone_data_content": "Timezone used to imprint time on the fax", + "retries": "Retries", + "retries_placeholder": "0", + "retries_data_content": "Number of retries for a fax", + "notification_emails": "Notifications emails", + "inbound_notification_email": "Inbound faxes", + "inbound_notification_email_placeholder": "mail@domain1.com, mail@domain2.com", + "inbound_notification_email_data_content": "List of email addresses separated by a comma that will receive a notification when a fax is received by the faxbox", + "outbound_notification_email": "Fax sent receipts", + "outbound_notification_email_data_content": "List of email addresses separated by a comma that will receive a notification when a fax is sent by the faxbox", + "custom_smtp_address": "Custom SMTP address", + "custom_smtp_address_placeholder": "domain.com", + "custom_smtp_address_data_content": "", + "smtp_email_address": "SMTP email address", + "cloud_connector_claim_url": "Link to printer", + "cloud_connector_installer_url": "Windows driver", + "are_you_sure_you_want_to_delete": "Are you sure you want to delete this fax box?", + "connect_call_to_faxbox": "Connect call to faxbox", + "faxbox_tip": "", + "which_faxbox": "Which Faxbox?", + "edit_faxbox_options": "Edit faxbox options", + "add_new_faxbox": "Add a new faxbox", + "default_settings_name_extension": "'s Faxbox", + "default_settings_header_extension": " Fax Printer", + "ok": "OK", + "save": "Save", + "delete": "Delete", + "validation": { + "retries": "Please enter a numeric value between 0 and 4", + "words": "Please only enter alphanumeric characters, space or - '" + } + }, + "groups": { + "title": "Groups", + "edit_group": "Edit Group", + "create_group": "Create Group", + "basic": "Basic", + "advanced": "Advanced", + "name": "Name", + "endpoints": "Endpoints", + "remove": "Remove", + "add_user": "Add User", + "select": "Select", + "first_name": "First Name", + "last_name": "Last Name", + "add_device": "Add Device", + "delete": "Delete", + "save": "Save", + "there_are_currently_no_endpoint": "There is currently no endpoint in this group", + "there_were_errors_on_the_form": "There were errors on the form, please correct!", + "are_you_sure_you_want_to_delete": "Are you sure you want to delete this group?" + }, + "media": { + "play_media": "Play Media", + "play_media_tip": "Play an audio file such as a greeting", + "connect_caller_to_media": "Connect caller to media...", + "media": "Media", + "edit_media_options": "Edit media options", + "add_a_media": "Add a media", + "create_media": "Create Media", + "edit_media": "Edit Media", + "basic": "Basic", + "advanced": "Advanced", + "options": "Options", + "name": "Name", + "name_data_content": "Friendly name for this media file", + "media_type": "Media Type", + "file": "File", + "tts": "TTS", + "file_input": "File input", + "change_file": "Change File", + "download_file": "Download File", + "text": "Text", + "text_placeholder": "Text To Speech", + "select": "Select", + "streamable": "Streamable", + "streamable_data_content": "Check to enable streaming of media.", + "delete": "Delete", + "save": "Save", + "media_label": "Media", + "the_file_you_want_to_apply": "The file you want to apply is still being processed by the page. Please wait a couple of seconds and try again.", + "there_were_errors_on_the_form": "There were errors on the form, please correct!", + "are_you_sure_you_want_to_delete": "Are you sure you want to delete this media?", + "no_name": "(no name)", + "add_media_label": "Add Media", + "mediaSources": { + "tts": "Text to Speech", + "upload": "Uploaded file", + "recording": "Recorded over the phone" + }, + "__comment": "UI-2812: allow for shoutcast url and silence in adv. callflows", + "__version": "4.1", + "shoutcastURL": "Stream URL", + "shoutcastURLHelp": "You can type any URL including :// (http, https, shout...)", + "silence": "Silence" + }, + "menu": { + "menu": "Menu", + "menu_tip": "Ask a caller to push a menu option or dial an extension number", + "connect_caller_to_menu": "Connect caller to menu...", + "which_menu": "Which Menu?", + "edit_menu_options": "Edit menu options", + "add_new_menu": "Add a new menu", + "menu_title": "Menu", + "create_menu": "Create Menu", + "edit_menu": "Edit Menu", + "basic": "Basic", + "advanced": "Advanced", + "extension_dialing": "Extension Dialing", + "options": "Options", + "name": "Name", + "name_data_content": "Friendly name for this Menu", + "prompt_record_pin": "Prompt Record PIN", + "prompt_record_pin_placeholder": "Record PIN", + "prompt_record_pin_data_content": "PIN to enter in order to allow users to record their own greetings", + "allow_caller_to_dial_extensions": "Allow caller to dial extensions", + "allow_caller_to_dial_extensions_data_content": "Check to allow the user to dial extensions from this menu", + "greeting_message": "Greeting Message", + "greeting_message_data_content": "Select the Greeting message that you want to use for this menu. If you select - Not set -, then no media file will be played.", + "edit": "Edit", + "create": "Create", + "whitelist_of_numbers": "Whitelist of numbers", + "whitelist_of_numbers_placeholder": "Regex", + "whitelist_of_numbers_data_content": "List of numbers that users are allowed to dial when hunting (ex: ^[0-9]{0,11}$ is a simple regex catching a group of 0 to 11 numbers)", + "blacklist_of_numbers": "Blacklist of numbers", + "blacklist_of_numbers_placeholder": "Regex", + "blacklist_of_numbers_data_content": "List of numbers that users are not allowed to dial when hunting (ex: ^[0-9]{0,11}$ is a simple regex catching a group of 0 to 11 numbers)", + "number_of_retries_on_misdial": "Number of retries on misdial", + "retries": "Retries", + "number_of_retries_on_misdial_data_content": "Number of allowed retries when misdialing in this menu.", + "timeout_for_dialing": "Timeout for dialing (s)", + "timeout_for_dialing_placeholder": "Timeout in seconds", + "timeout_for_dialing_data_content": "Number of seconds allowed without pressing any key.", + "extension_number_length": "Extension Number Length", + "length": "Length", + "extension_number_length_data_content": "The maximum length of an extension. By default, it is set to the Record PIN number length.", + "allow_outside_recording": "Allow outside recording", + "allow_outside_recording_data_content": "This option allows someone to dial into a menu from an outside number (i.e. their cell phone, landline, etc.) and enter the PIN for the menu to be able to re-record it.", + "suppress_playing_of_invalid_entry": "Suppress playing of Invalid Entry", + "suppress_playing_of_invalid_entry_data_content": "This option, when checked, will suppress the playing of 'Invalid Entry'.", + "delete": "Delete", + "save": "Save", + "menu_option": "Menu option", + "menus_label": "Menus", + "not_set": "- Not set -", + "there_were_errors_on_the_form": "There were errors on the form, please correct!", + "are_you_sure_you_want_to_delete": "Are you sure you want to delete this menu?", + "no_name": "(no name)", + "add_menu_label": "Add Menu", + "default_action": "Default action", + "menu_option_title": "Menu Option", + "__comment": "UI-2764: adding interdigit timeout field", + "__version": "4.1", + "interdigit_timeout": "Interdigit Timeout (s)", + "interdigit_timeout_placeholder": "2", + "interdigit_timeout_data_content": "Number of seconds to wait after a digit has been pressed before considering the entry complete." + }, + "resource": { + "global_carrier": "Global Carrier", + "global_carrier_tip": "Route calls to the phone network through pre-configured service providers", + "account_carrier": "Account Carrier", + "account_carrier_tip": "Route calls to the phone network through a configured SIP provider, Google Voice or physical digital/analog line", + "account_carrier_title": "Account Carrier", + "use_carriers_from_specific_account": "Use carriers from a specific account", + "account_id": "Account ID" + }, + "timeofday": { + "time_of_day": "Time of Day", + "time_of_day_cat": "Time of Day", + "disable_time_of_day": "Disable Time of Day", + "enable_time_of_day": "Enable Time of Day", + "reset_time_of_day": "Reset Time of Day", + "timezone": "Timezone", + "select_a_timezone_title": "Select a Timezone", + "unselected_time_of_day_rules": "Unselected time of day rules", + "selected_time_of_day_rules": "Selected time of day rules", + "disable_time_of_day_rules_title": "Disable Time of Day rules", + "save": "Save", + "enable_time_of_day_rules": "Enable Time of Day rules", + "reset_time_of_day_rules": "Reset Time of Day rules", + "create_time_of_day": "Create Time of Day", + "edit_time_of_day": "Edit Time of Day", + "basic": "Basic", + "advanced": "Advanced", + "name": "Name", + "name_data_content": "Name of this Time of Day Rule", + "repeats": "Repeats", + "repeats_data_content": "Select the recurrence of this time based route", + "every": "Every:", + "every_data_content": "Depending on the cycle, define the recurrence of this rule", + "months": "month(s)", + "weeks": "week(s)", + "on": "On:", + "select_which_days": "Select which days to apply this rule", + "start_date": "Start Date", + "start_date_data_content": "Select the starting date of this rule", + "enabled": "Enabled", + "enabled_data_content": "Select when this rule should be enabled", + "enabled_based_on_time": "Based on time", + "enabled_forced_on": "Forced On", + "enabled_forced_off": "Forced Off", + "time": "Time:", + "delete": "Delete", + "which_time_of_day": "Which Time of Day?", + "edit_time_of_day_options": "Edit time of day options", + "add_a_time_of_day": "Add a time of day", + "time_of_day_label": "Time Of Day", + "sunday": { + "friendlyName": "Sunday", + "shortName": "S" + }, + "monday": { + "friendlyName": "Monday", + "shortName": "M" + }, + "tuesday": { + "friendlyName": "Tuesday", + "shortName": "T" + }, + "wednesday": { + "friendlyName": "Wednesday", + "shortName": "W" + }, + "thursday": { + "friendlyName": "Thursday", + "shortName": "T" + }, + "friday": { + "friendlyName": "Friday", + "shortName": "F" + }, + "saturday": { + "friendlyName": "Saturday", + "shortName": "S" + }, + "there_were_errors_on_the_form": "There were errors on the form, please correct!", + "are_you_sure_you_want_to_delete": "Are you sure you want to delete this time of day rule?", + "no_name": "(no name)", + "add_time_of_day_label": "Add Time of Day", + "all_other_times": "All other times", + "name_regex": "/^[a-zA-Z0-9\\s_']+$/", + "__comment": "UI-1929: adding time of day sets to options in time of days", + "__version": "4.1", + "types": { + "rules": "Rules", + "sets": "Sets" + }, + "to": "To", + "__comment": "UI-2939: add all day field to time of day settings", + "__version": "4.1", + "allDay": "All Day" + }, + "user": { + "user": "User", + "user_tip": "Direct a caller to a specific user", + "hot_desk_login": "Hot Desk login", + "hot_desk_login_tip": "Enable Hot desking", + "hot_desk_logout": "Hot Desk logout", + "hot_desk_logout_tip": "Disable Hot desking", + "hot_desk_toggle": "Hot Desk toggle", + "hot_desk_toggle_tip": "Toggle Hot desking", + "hotdesking_cat": "Hotdesking", + "connect_caller_to_user": "Connect a caller to a user...", + "which_user": "Which user?", + "edit_user_options": "Edit user options", + "add_user": "Add a user", + "ring_this_users_devices_for": "Ring this user's devices for", + "seconds": "seconds", + "allow_this_user_to_call_himself": "Allow this user to call himself.", + "when_you_check_this_box": "When you check this box, calls from the user's own extension to themselves will ring the extension. If this box isn't checked, calls from the user's own extension to themselves will go to their voicemail.", + "select_user": "Select User", + "create_user": "Create User", + "edit_user": "Edit User", + "basic": "Basic", + "advanced": "Advanced", + "caller_id": "Caller ID", + "options": "Options", + "call_forward": "Call Forward", + "password_management": "Password Management", + "hot_desking": "Hot Desking", + "restrictions": "Restrictions", + "basic_settings": "Basic Settings", + "username": "Username", + "username_placeholder": "Username", + "username_data_content": "Username", + "first_name": "First Name", + "first_name_placeholder": "First Name", + "first_name_data_content": "First Name", + "last_name": "Last Name", + "last_name_placeholder": "Last Name", + "last_name_data_content": "Last Name", + "email": "Email", + "email_placeholder": "user@company.com", + "email_data_content": "Email Address like: user@company.com", + "user_privilege_level": "User privilege level", + "user_privilege_level_data_content": "The user privilege level", + "administrator": "Administrator", + "email_notifications": "Email Notifications", + "voicemail": "Voicemail", + "voicemail_data_content": "By checking this option, an email will be sent to the specified e-mail address each time this user gets a voicemail.", + "fax": "Fax", + "fax_data_content": "By checking this option, an email will be sent to the specified e-mail address each time you get a Fax.", + "in_house_calls": "In-House Calls", + "caller_id_name": "Caller ID Name", + "caller_id_name_placeholder": "Name", + "caller_id_name_data_content": "Define the Caller ID Name of this User for In-House Calls (max. 30 chars). If the Caller ID Name of the device and of the user is not set, this Caller ID Name will be used.", + "caller_id_number": "Caller ID Number", + "caller_id_number_data_content": "Define the Caller ID Number of this User for In-House Calls. If the Caller ID Number of the device and of the user is not set, this Caller ID Number will be used.", + "outbound_calls": "Outbound Calls", + "caller_id_name_data_content2": "Define the Caller ID Name of this User for Outbound Calls (max. 30 chars). If the Caller ID Name of the device and of the user is not set, this Caller ID Name will be used.", + "caller_id_number_data_content2": "Define the Caller ID Number of this User for Outbound Calls. If the Caller ID Number of the device and of the user is not set, this Caller ID Number will be used.", + "devices": "Devices", + "the_following_devices_are_mapped": "The following devices are mapped to this user. If you're creating a user, you can add a Device and it will be automatically assigned to this new user once the user creation is completed.", + "presence_id_title": "", + "presence_id": "Presence ID", + "presence_id_help": "", + "presence_id_placeholder": "", + "device_name": "Device Name", + "type": "Type", + "status": "Status", + "enabled": "Enabled", + "actions": "Actions", + "add_a_new_device": "Add a new device for this user", + "emergency": "Emergency", + "caller_id_name_data_content3": "Define the Caller ID Name of this User for Emergency Calls.", + "caller_id_number_data_content3": "Define the Caller ID Number of this User for Emergency Calls (max. 30 chars).", + "standard_options": "Standard Options", + "user_has_been_verified": "User has been verified", + "user_has_been_verified_data_content": "Verify User ?", + "time_zone": "Time zone", + "time_zone_data_content": "Select the time zone of this user.", + "music_on_hold": "Music on Hold", + "music_on_hold_data_content": "Select the media file that you want to be played by default when it 's not set on a user or a device.", + "edit": "Edit", + "create": "Create", + "hide_from_contact_list": "Hide from Contact List", + "hide_from_contact_list_data_content": "By checking this box, this endpoint will not be added automatically to the contact list of the devices of this platform", + "queue_options": "Queue Options", + "record_this_agent": "Record this agent(user)", + "record_this_agent_data_content": "By checking this box, this agent will be recorded even if the global setting for the queue is set to not record agents.", + "enable_call_forward": "Enable Call-Forward", + "enable_call_forward_data_content": "If checked, call forwarding feature will be enabled for user.", + "redirect_calls_to": "Redirect calls to", + "redirect_calls_to_data_content": "Number to redirect calls to for the call-forwarding feature", + "bypass_users_phones": "Bypass user's phones", + "bypass_users_phones_data_content": "If this box is checked, it will prevent the user's phones from ringing. For example: If you want to ONLY ring a user's cellphone (and not their desk phone) - check this box.", + "require_key_press": "Require Key Press", + "require_key_press_data_content": "Do you want this user to press a key to answer a call that has been call-forwarded", + "keep_caller_id": "Keep Original Caller ID", + "keep_caller_id_data_content": "If checked, the caller-ID of the person being forwarded will display. If not checked the caller-ID of the user will display.", + "direct_calls_only": "Direct Calls Only", + "direct_calls_only_data_content": "If checked, it will only use the call forwarding if the user/device is rung directly and not when rung as a member of a group (ring group, ect).", + "new_password": "New Password", + "confirm_password": "Confirm Password", + "enable_hot_desking": "Enable Hot Desking", + "enable_hot_desking_data_content": "Check to enable Hot Desking", + "id": "ID", + "id_placeholder": "ID", + "id_data_content": "In order to enable Hot Desking from another device, you'll need to provide an ID", + "require_pin": "Require PIN", + "require_pin_data_content": "If checked the user will be required to enter their ID and a PIN", + "pin": "PIN", + "pin_placeholder": "PIN", + "pin_data_content": "PIN required to sign into a device.", + "check_if_you_want": "Check if you want to stay logged in", + "check_if_you_want_data_content": "Tick if you want to stay logged in on your other devices", + "devices_where_this_user": "Devices where this user is currently logged in", + "this_user_is_not_logged": "This user is not logged in to any other endpoints.", + "closed_groups": "Closed Groups", + "closed_groups_data_content": "If checked the user will only be able to call the Users in his groups.", + "deny": "Deny", + "inherit": "Inherit", + "delete": "Delete", + "save": "Save", + "there_is_currently_no_devices": "There is currently no devices linked to this user", + "users_label": "Users", + "sip_device_type": "SIP Device", + "cell_phone_type": "Cell Phone", + "fax_type": "Fax", + "smartphone_type": "Smartphone", + "landline_type": "landline", + "softphone_type": "Softphone", + "sip_uri_type": "SIP URI", + "default_music": "Default Music", + "silence": "Silence", + "voip_services_label": "VoIP Services", + "user_portal_label": "User Portal", + "there_were_errors_on_the_form": "There were errors on the form, please correct!", + "are_you_sure_you_want_to_delete": "Are you sure you want to delete this user?", + "do_you_really_want_to_delete": "Do you really want to delete this device?", + "add_user_label": "Add User", + "validation": { + "username": "Please only enter alphanumeric characters or + @ . _ -", + "name": "Please only enter alphanumeric characters, space or - '", + "hotdesk": { + "pin": "Please only enter numeric characters", + "id": "Please only enter numeric characters or + # *" + }, + "caller_id": { + "name": "Please only enter alphanumeric characters, space or comma", + "number": "Please enter a valid phone number" + } + }, + "__version": "4.0", + "__comment": "UI-2475: add a failover option to callforward", + "failover_callforward": "Failover", + "failover_callforward_content": "When checked, if all this user's devices are unregistered, then the system will automatically call-forward (even if the Enable Call-Forward setting isn't enabled)" + }, + "vmbox": { + "voicemail": "Voicemail", + "voicemail_title": "Voicemail", + "voicemail_tip": "Direct a caller to leave a voicemail message", + "check_voicemail": "Check Voicemail", + "check_voicemail_tip": "Prompt the caller for a mailbox number and password so they can check voicemails", + "connect_caller_to_voicemail": "Connect caller to voicemail...", + "which_voicemail_box": "Which Voicemail Box?", + "edit_mailbox_options": "Edit mailbox options", + "add_new_mailbox": "Add a new mailbox", + "create_voicemail_box": "Create Voicemail Box", + "edit_voicemail_box": "Edit Voicemail Box", + "basic": "Basic", + "advanced": "Advanced", + "options": "Options", + "name": "Name", + "name_placeholder": "Name", + "name_data_content": "Friendly Name for this voicemail box", + "voicemail_number": "Voicemail Number", + "voicemail_number_placeholder": "Number", + "voicemail_number_data_content": "Number of this voicemail box", + "assign_to": "Assign To", + "assign_to_data_content": "Chose the owner of this voicemail box", + "edit": "Edit", + "create": "Create", + "pin_number": "PIN number", + "pin_number_data_content": "Enter the PIN Number of this voicemail box (must be at least 4 digits)", + "unavailable_message": "Unavailable Message", + "unavailable_message_data_content": "Select the Unavailable message that you want to use for this this device. If you select - Not set -, then no media file will be played.", + "timezone": "Timezone", + "already_setup": "Already Setup", + "already_setup_data_content": "Is this voicemail box already considered initialized? If not, the first time the user logs in they will be forced to change their PIN and setup a greeting.", + "require_pin": "Require PIN", + "require_pin_data_content": "Check if voicemail requires a PIN.", + "auto_login_enabled": "Auto-login enabled", + "auto_login_enabled_data_content": "Check to enable auto-login for this voicemail box? (If the user call his own voicemail, it goes straight to his messages)", + "skip_greeting": "Skip Greeting", + "skip_greeting_data_content": "Check to skip greetings by default", + "skip_instructions": "Skip Instructions", + "skip_instructions_data_content": "Check to skip instructions by default", + "delete_after_notification": "Delete After Notification", + "delete_after_notification_data_content": "Delete the voicemail after the notification has been sent", + "not_configurable": "Configurable via menu?", + "not_configurable_data_content": " If unchecked, it will disallow the user to configure voicemail via the menu", + "delete": "Delete", + "save": "Save", + "voicemail_boxes_label": "Voicemail Boxes", + "not_set": "- Not set -", + "no": "- No", + "owner": "owner -", + "there_were_errors_on_the_form": "There were errors on the form, please correct!", + "are_you_sure_you_want_to_delete": "Are you sure you want to delete this voicemail box?", + "no_name": "(no name)", + "add_voicemail_box_label": "Add Voicemail Box", + "edit_voicemail_box_title": "Edit voicemail box", + "create_voicemail_box_title": "Create voicemail box", + "__comment": "UI-2558: add field for recipients", + "__version": "4.0", + "recipients": "Email Recipients", + "__comment": "UI-2634: add support for wav/mp4/mp3 for voicemail media extensions", + "extension": "Media Extension", + "mp3": "mp3", + "mp4": "mp4", + "wav": "wav", + "default": "Account Default" + }, + "__comment": "UI-1493: Adding accountSettings to advanced callflows app", + "__version": "3.22", + "accountSettings": { + "title": "Account Settings", + "callerId": { + "titleOutbound": "Account's Outbound Caller ID", + "titleInbound": "Account's Inbound Caller ID", + "titleEmergency": "Account's Emergency Caller ID", + "nameLabel": "Caller ID Name:", + "numberLabel": "Caller ID Number:", + "defaultNumber": "Default" + }, + "musicOnHold": { + "title": "Account's Music on Hold", + "dropdownLabel": "Music on Hold:", + "silence": "Silence", + "default": "Default Music", + "emptyUploadAlert": "Please select a file to upload", + "fileTooBigAlert": "You can not upload a file with a size exceeding 5MB", + "audioUploadButton": "Browse", + "__comment": "UI-2654: Allow shoutcast URL for MoH", + "__version": "v4.1", + "shoutcastURL": "Stream URL", + "shoutcastURLHelp": "You can type any URL including :// (http, https, shout...)" + }, + "blacklist": { + "title": "Blacklists" + }, + "preflow": { + "title": "Preflow", + "help": "Preflow is an option to execute a callflow before any other callflow. It is set on the account level and will apply on any call using callflow for that account. It can be useful to activate call recording, or the missed call alert feature for example.", + "dropdownLabel": "Select Callflow", + "empty": "- None -" + }, + "outboundFlags": { + "title": "Outbound Flags", + "labels": { + "dynamic": "Dynamic", + "static": "Static" + }, + "help": "Comma separated values (my_custom_properties,comma separated,in-whatever-case-style)" + } + }, + "__comment": "UI-1667: Adding way to customize Feature codes", + "__version": "v3.22", + + "featureCodes": { + "successUpdate": "You successfully updated your Feature Codes", + "title": "Feature Codes", + "showAll": "Show All", + "show": "Show", + "hide": "Hide", + "star_data_content": "The star is mandatory for any feature code, that's why it has been added by default.", + "feature_codes_label": "Feature Codes", + "nothing_to_save": "Nothing to save", + "enable_call_forward": "Enable Call-Forward", + "call_forward_cat": "Call-Forward", + "disable_call_forward": "Disable Call-Forward", + "toggle_call_forward": "Toggle Call-Forward", + "update_call_forward": "Update Call-Forward", + "enable_hot_desking": "Enable Hot Desking", + "hot_desking_cat": "Hot-Desking", + "disable_hot_desking": "Disable Hot Desking", + "toggle_hot_desking": "Toggle Hot Desking", + "check_voicemail": "Check Voicemail", + "miscellaneous_cat": "Miscellaneous", + "direct_to_voicemail": "Direct to Voicemail", + "intercom": "Intercom", + "privacy": "Privacy", + "park_and_retrieve": "Park and Retrieve", + "parking_cat": "Parking", + "valet": "Valet", + "retrieve": "Retrieve", + "single_mailbox_login": "Check Voicemail (auto login)", + "callMove": "Move", + "infoSettings": "Leave the fields empty to use default system values", + "parkingParkAndRetrievePopup": { + "title": "Edit Park And Retrieve Configuration", + "ringBackTimeout": { + "label": "Ring Back Timeout", + "tooltip": "How long, in seconds, before ringing back" + }, + "callbackTimeout": { + "label": "Call BackTimeout", + "tooltip": "When a parked call has remained parked for the Ring Back Timeout duration, the parker will be called for that duration (in seconds)" + }, + "successUpdate": "You successfully updated settings of the Park And Retrieve Feature Code" + }, + "parkingValetPopup": { + "title": "Edit Valet Configuration", + "ringBackTimeout": { + "label": "Ring Back Timeout", + "tooltip": "How long, in seconds, before ringing back" + }, + "callbackTimeout": { + "label": "Call Back Timeout", + "tooltip": "When a parked call has remained parked for the Ring Back Timeout duration, the parker will be called for that duration (in seconds)" + }, + "successUpdate": "You successfully updated settings of the Valet Feature Code" + } + }, + "hiddenCallflowWarning": "It looks like you're editing a callflow that wasn't meant to be edited by end-users. Usually we hide those callflows in this app, but since you're a superduper admin, we're showing it to you. Saving changes to this Callflow, could break features in SmartPBX/Mobile or the Migration app, so make sure you know what you're doing!", + + "__comment": "UI-2216: adding blacklists", + "__version": "v4.0", + + "blacklist": { + "title": "Blacklist", + "addNumber": "Add Number", + "create": "Create Blacklist", + "edit": "Edit Blacklist", + "name": "Name", + "blockAnonymous": "Block Anonymous", + "listNumbers": "List of existing numbers", + "are_you_sure_you_want_to_delete": "Are you sure you want to delete this blacklist?", + "help": "In order to activate this blacklist, head to the Account Settings section" + }, + + "__comment": "UI-2216: adding tts to adv. callflows", + "__version": "v4.0", + "tts": { + "default": "Default", + "title": "Text To Speech", + "name": "TTS", + "tip": "TTS allows you to enter a text that will be spoken by a Text-To-Speech engine over the phone.", + "voice": { + "label": "Voice", + "female": "Female", + "male": "Male" + }, + "language": { + "label": "Language", + "en": "English", + "fr": "French" + }, + "text": { + "label": "Text" + } + }, + + "__comment": "UI-439: adding sleep to adv. callflows", + "__version": "v4.1", + "sleep": { + "default": "Default", + "title": "Sleep", + "name": "Sleep", + "tip": "Allows you to set a pause before continuing the callflow.", + "duration": { + "label": "Duration (s)" + } + }, + + "__comment": "UI-439: adding sleep to adv. callflows", + "__version": "v4.0", + "pageGroup": { + "audio": { + "label": "Audio", + "help": "What kind of audio for the group members", + "oneWay": "One-way", + "twoWay": "Two-way" + } + }, + "missedCallAlert": { + "title": "Missed Call Alert", + "tip": "Allows users to receive an email notification for unanswered inbound calls that do not result in a voicemail message.", + "help": "This feature allows you to let users receive email notification for unanswered inbound calls that do not result in a voicemail message. Please type a list of emails, separated by commas, or select users from the list below, then press Save, to create a callflow with this feature.", + "emails": "Emails", + "emailsHelp": "List of email addresses separated by a comma that will receive a notification", + "popupTitle": "Missed Call Alert", + "unselectedUsers": "Unselected Users", + "selectedUsers": "Selected Users" + }, + + "__comment": "UI-2646: adding ring group togle to adv. callflows", + "__version": "v4.1", + "ringGroupToggle": { + "loginTitle": "Ring Group Login", + "logoutTitle": "Ring Group Logout", + "loginDialogTitle": "Login to callflow with a ring group in it", + "logoutDialogTitle": "Login to callflow with a ring group in it", + "name": "Ring Group Toggle", + "loginTip": "Ring Group Toggle allows a user to log in a ring group dynamically.", + "logoutTip": "Ring Group Toggle allows a user to log out of a ring group dynamically.", + "callflow": "Which Callflow?", + "category": "Ring Group Toggle" + }, + + "__comment": "UI-2723: adding way to find extension easily", + "__version": "v4.1", + "findExtension": "Find Extension", + + "__comment": "UI-755: adding collect dtmf to adv. callflows", + "__version": "v4.1", + "collectDTMF": { + "default": "Default", + "title": "Collect DTMF", + "name": "Collect DTMF", + "tip": "Allows you to collect DTMF.", + "collectionName": { + "label": "Collection Name", + "help": "Store collected DTMF in a named key. Leave empty to leave it to set it to the back-end default value." + }, + "interdigitTimeout": { + "label": "Interdigit Timeout", + "help": "How long, in milliseconds, to wait for the next DTMF. Leave empty to leave it to set it to the back-end default value." + }, + "terminator": { + "label": "Terminator", + "help": "What DTMF will terminate collection before the timeout occurs" + }, + "maxDigits": { + "label": "Max Digits", + "help": "How many DTMFs to collect from the caller" + }, + "timeout": { + "label": "Timeout", + "help": "How long, in milliseconds, to wait for the first DTMF" + } + }, + + "__comment": "UI-413: adding eavesdrop to adv. callflows", + "__version": "v4.1", + "eavesdrop": { + "none": "None", + "default": "Default", + "title": "Eavesdrop", + "name": "Eavesdrop", + "tip": "Allows you to eavesdrop on a call for a specific user or device.", + "endpoint": { + "label": "Endpoint" + }, + "approvedEndpoint": { + "label": "Approved Endpoint", + "help": "You can force the eavesdropper to be a specific user/device/group by selecting an endpoint in this list." + } + }, + + "__comment": "UI-431: adding intercept to adv. callflows", + "__version": "v4.1", + "intercept": { + "none": "None", + "default": "Default", + "title": "Intercept", + "name": "Intercept", + "tip": "Allows you to intercept a call.", + "endpoint": { + "label": "Endpoint" + }, + "approvedEndpoint": { + "label": "Approved Endpoint", + "help": "You can force the intercepter to be a specific user/device/group by selecting an endpoint in this list." + } + }, + + "__comment": "UI-1929: adding time of day sets to adv. callflows", + "__version": "v4.1", + "temporalset": { + "name": "Time of Day Sets", + "nameKey": { + "label": "Name", + "help": "Name of the Set" + }, + "createSet": "Create Time of Day Set", + "editSet": "Edit Time of Day Set", + "there_were_errors_on_the_form": "There were errors on the form, please correct!", + "are_you_sure_you_want_to_delete": "Are you sure you want to delete this time of day set?", + "selectedTOD": "Selected Rules", + "unselectedTOD": "Unselected Rules", + "noSave": "You can not update this set because it was created in Smart PBX." + }, + + "__comment": "UI-2763: expose dnd callflow action", + "__version": "v4.1", + "doNotDisturb": { + "categoryName": "Do Not Disturb", + "activate": { + "label": "Activate Do Not Disturb", + "tip": "Activates Do Not Disturb" + }, + "deactivate": { + "label": "Dectivate Do Not Disturb", + "tip": "Dectivates Do Not Disturb" + }, + "toggle": { + "label": "Toggle Do Not Disturb", + "tip": "Toggles Do Not Disturb" + } + } + }, + "oldCallflows": { + "call_forwarding_cat": "Call Forwarding", + "basic_cat": "Basic", + "advanced_cat": "Advanced", + "call_recording_cat": "Call Recording", + "caller_id_cat": "Caller-ID", + "delete_callflow": "Delete callflow", + "save_changes": "Save changes", + "invalid_number": "Invalid number!", + "basic": "'Basic'", + "advanced": "'Advanced'", + "please_select_valid_number": "Please select a valid number by click in the grey boxes of the Callflow box.", + "this_callflow_has_not_been_created": "This callflow has not been created or doesn\\'t exist anymore.", + "monster_callflow_error": "This callflow was created via the Monster UI. At this time, the Kazoo UI callflow editor is not compatible to edit Monster-UI Callflows.", + "are_you_sure": "Are you sure you want to delete this callflow?", + "callflow_name": "Callflow Name:", + "hide_from_contact_list": "Hide from Contact List", + "giving_a_name_to_a_callflow": "Giving a name to a callflow isn't mandatory. Leave the field blank and the callflow will be displayed in the left listing as the list of numbers used in this callflow.", + "popup_title": "Edit Callflow Name", + "add_number": "Add number", + "add_a_number": "Add a number", + "available_numbers": "Spare Numbers", + "extension": "Extension", + "add": "Add", + "no_phone_numbers": "No Phone Numbers", + "you_didnt_select": "You didn\\'t select a valid phone number.", + "this_number_is_already_attached": "This number is already attached to a callflow", + "ring_group": "Ring Group", + "ring_group_tip": "Ring several VoIP or cell phones in order or at the same time", + "callflow": "Callflow", + "callflow_tip": "Transfer the call to another call flow", + "page_group": "Page Group", + "page_group_tip": "Ring several VoIP or cell phones", + "manual_presence": "Manual Presence", + "manual_presence_tip": "Manual Presence Help", + "group_pickup": "Group Pickup", + "group_pickup_tip": "Setup the group pickup feature for a user, device or a group.", + "receive_fax": "Receive Fax", + "receive_fax_tip": "Directs a fax to a specific user", + "pivot": "Pivot", + "pivot_tip": "!", + "disa": "DISA", + "disa_tip": "DISA allows external callers to make outbound calls as though they originated from the system", + "response": "Response", + "response_tip": "Return a custom SIP error code", + "enable_call_forwarding": "Enable call forwarding", + "enable_call_forwarding_tip": "Enable call forwarding (using the last forwaded number)", + "disable_call_forwarding": "Disable call forwarding", + "disable_call_forwarding_tip": "Disable call forwarding", + "update_call_forwarding": "Update call forwarding", + "update_call_forwarding_tip": "Update the call forwarding number", + "dynamic_cid": "Dynamic cid", + "dynamic_cid_tip": "Set your CallerId by entering it on the phone", + "prepend": "Prepend", + "prepend_tip": "Prepend Caller ID with a text.", + "reset_prepend": "Reset Prepend", + "reset_prepend_tip": "Reset all the prepended texts before the Caller ID.", + "start_call_recording": "Start Call Recording", + "start_call_recording_tip": "Start Call Recording", + "stop_call_recording": "Stop Call Recording", + "stop_call_recording_tip": "Stop Call Recording", + "name_this_ring_group": "Name this ring group", + "ring_strategy": "Ring Strategy", + "at_the_same_time": "At the same time", + "in_order": "In order", + "ringback": "Ringback", + "default": "Default", + "silence": "Silence", + "users": "Users", + "devices": "Devices", + "groups": "Groups", + "device_name": "Device Name", + "user_name": "User Name", + "group_name": "Group Name", + "delete": "Delete", + "you_have_modified_this_callflow": "You have modified this Callflow, don't forget to save it!", + "drag_items_below_on_top": "Drag items below on top of other items on the left", + "connect_caller_to_another_callflow": "Connect a caller to another callflow...", + "which_callflow": "Which callflow?", + "callflow_title": "Callflow", + "name_this_page_group": "Name this page group", + "page_group_title": "Page Group", + "ID": "ID:", + "status": "Status", + "idle": "Idle", + "ringing": "Ringing", + "busy": "Busy", + "manual_presence_title": "Manual Presence", + "setting_group_pickup": "Setting group pick-up...", + "which_endpoint": "Which endpoint?", + "select_endpoint_title": "Select Endpoint", + "sends_fax_to_user": "Sends a fax to a user...", + "which_user": "Which user?", + "edit_user_options": "Edit user options", + "add_a_user": "Add a user", + "select_user_title": "Select User", + "t_38_checkbox": "Enable T.38?", + "voice_url": "Voice URL", + "method": "Method", + "format": "Format", + "pivot_title": "Pivot", + "sip_code": "SIP Code", + "message": "Message", + "media": "Media", + "no_media": "No Media", + "edit_media_options": "Edit media options", + "add_a_media": "Add a media", + "response_title": "Response", + "prepend_caller_id": "Prepend Caller ID", + "callerid_name_prefix": "Caller-ID Name Prefix", + "callerid_number_prefix": "Caller-ID Number Prefix", + "prepend_caller_id_title": "Prepend Caller-ID", + "call_recording": "Call Recording", + "url": "URL", + "time_limit": "Time Limit (s)", + "actions": "Actions", + "catch_all": "Catch all", + "no_number": "(no number)", + "click_to_add_number": "Click to add number", + "delays": "Delay(s)", + "timeouts": "Timeout(s)", + "by_checking_this_box": "By checking this box, this endpoint will not be added automatically to the contact list of the devices of this platform", + "callflows_label": "Callflows", + "you_need_to_select_a_number": "You need to select a number for this callflow before saving it.", + "callflow_module_label": "Callflow Module", + "add_callflow_label": "Add Callflow", + "the_owner_of_this_device_is_already": "The owner of this device is already in the ring group. By adding this device, you will remove the User from this ring group. Would you like to continue anyway?", + "this_user_has_already_some_devices": "This user has already some devices belonging to him in this ring group. By adding him to the ring group, you will remove devices that were already in the ring group. Would you like to continue anyway?", + "undefined_device": "Undefined Device", + "ring_group_val": "Ring Group - ", + "not_setting_a_pin": "Not setting a PIN is a security risk, are you sure you don\\'t want to set a PIN?", + "sip_code_caption": "SIP Code: ", + "please_enter_a_valide_sip_code": "Please enter a valide SIP code.", + "resource_name": "Resource", + "this_callflow_is_outdated": "This callflow is outdated, please resave this callflow before continuing.", + "hot_desking_name": "Hot Desking", + "language_title": "Language", + "language": "Language", + "language_tip": "This callflow action lets you change the language of the prompts used in this callflow!", + "searchLink": "Search on the server for", + "searchReset": "Click again to clear the search", + "__comment": "UI-1742: Add a flag to list callflows in Main Numbers", + "__version": "3.22", + "list_this_callflow": "List this callflow in Main Number", + "numberOfTries": "Number of times to ring members", + "__comment": "UI-2910: add prepend id fields", + "__version": "4.1", + "applyTo": { + "label": "Apply To", + "tooltip": "Setting this field to \"original\" will revert the caller id and then apply the prepend, IE: if the caller id is already prepend'd then that will be lost. Setting it to \"current\" will keep the caller id as is, including any existing prepend, and simply add to it.", + "options": { + "current": "Current", + "original": "Original" + } + } + }, + "__comment": "UI-1260: created common control for carrier selection", + "__version": "v3.20_s2", + "entityManager": { + "header": "Click on what you would you like to configure:", + "callflowsTitle": "Callflows", + "backButton": "Return to Callflows Home", + "accountTitle": "Account Settings", + "featureCodeTitle": "Feature Codes", + "__comment": "UI-2612: add toggle to hide/view system callflows", + "__version": "v4.1", + "showSystemCallflows": { + "title": "Show All Callflows", + "help": "As an admin, you're allowed to see all the existing callflows in this page. This include \"Applications\" Callflows that are created by other apps, but that you don't necesserarily want to update. If you wish to reduce clutter, you can switch this off to hide these callflows." + } + } +} diff --git a/src/apps/callflows/metadata/app.json b/src/apps/callflows/metadata/app.json new file mode 100644 index 0000000..09eb561 --- /dev/null +++ b/src/apps/callflows/metadata/app.json @@ -0,0 +1,33 @@ +{ + "name": "callflows", + "i18n": { + "en-US": { + "label": "Callflows", + "description": "The Callflow Manager allows you manage Callflows as well as various VOIP entities.", + "extended_description": "Advanced Callflows features a drag and drop interface which allows users to select from over 50 items in our “call handling toolbox” to chain together. These chains, known as callflows, allow you to manipulate the flow a call takes as a caller traverses various features, menus and call routing decisions in the system. Use the Advanced Callflow editor to configure every step a caller can take when calling a phone number or extension. Route calls to menus, ring groups, voicemails, conference bridges, call queues, call recordings and more.", + "features": [ + "Drag and drop management", + "50+ call handling actions such as: Time of Day Routing, Device/User Routing, Menus/IVRs, Call Pickup, BLF/Presence Manipulation, Outbound Call Routing...", + "Create custom call flows", + "Customize feature codes" + ] + } + }, + "tags": [], + "icon": "Callflows_app.png", + "api_url": "http://10.26.0.41:8000/v2", + "author": "2600Hz", + "version": "1.0", + "license": "-", + "price": 0, + "screenshots": [ + "callflows_1.png", + "callflows_2.png", + "callflows_3.png" + ], + "urls": { + "documentation": "{documentation_url}", + "howto": "{howto_video_url}" + }, + "pvt_type": "app" +} diff --git a/src/apps/callflows/metadata/icon/Callflows_app.png b/src/apps/callflows/metadata/icon/Callflows_app.png new file mode 100644 index 0000000..77280e6 Binary files /dev/null and b/src/apps/callflows/metadata/icon/Callflows_app.png differ diff --git a/src/apps/callflows/metadata/screenshots/callflows_1.png b/src/apps/callflows/metadata/screenshots/callflows_1.png new file mode 100644 index 0000000..5faddbf Binary files /dev/null and b/src/apps/callflows/metadata/screenshots/callflows_1.png differ diff --git a/src/apps/callflows/metadata/screenshots/callflows_2.png b/src/apps/callflows/metadata/screenshots/callflows_2.png new file mode 100644 index 0000000..d365627 Binary files /dev/null and b/src/apps/callflows/metadata/screenshots/callflows_2.png differ diff --git a/src/apps/callflows/metadata/screenshots/callflows_3.png b/src/apps/callflows/metadata/screenshots/callflows_3.png new file mode 100644 index 0000000..31a9a2e Binary files /dev/null and b/src/apps/callflows/metadata/screenshots/callflows_3.png differ diff --git a/src/apps/callflows/style/app.css b/src/apps/callflows/style/app.css new file mode 100644 index 0000000..a74607d --- /dev/null +++ b/src/apps/callflows/style/app.css @@ -0,0 +1,1588 @@ +@import url('../submodules/blacklist/blacklist.css'); +@import url('../submodules/device/device.css'); +@import url('../submodules/user/user.css'); +@import url('../submodules/misc/misc.css'); +@import url('../submodules/device/device.css'); +@import url('../submodules/faxbox/faxbox.css'); +@import url('../submodules/directory/directory.css'); +@import url('../submodules/timeofday/timeofday.css'); +@import url('../submodules/groups/groups.css'); +@import url('../submodules/featurecodes/featurecodes.css'); +@import url('../submodules/temporalset/temporalset.css'); +/* style.css */ +#ws_callflow > .callflow { + float: left; + width: 85%; +} +#ws_callflow .callflow .root { + width: 322px; +} + +#ws_callflow .callflow .root > .top_bar { + background-image: url(static/images/blue_bar.png); + height: 25px; + text-align: left; +} + +#ws_callflow .callflow .root > .top_bar > span { + line-height: 25px; +} + +#ws_callflow .callflow .root > .top_bar .name { + float: left; + margin-left: 10px; + font-weight: bold; + cursor: default; +} + +#ws_callflow .callflow .root > .top_bar .add_number { + float: right; +} + +#ws_callflow .callflow .root > .content .number_row { + background-image: url(static/images/nav_line_horizontal.jpg); + background-position: bottom; + background-repeat: repeat-x; + height: 32px; + background-color: #424242; +} + +#ws_callflow .callflow .root > .content .number_row:last-child { + background: none; + background-color: #424242; + height: 30px; + border-radius: 0px 0px 2px 2px; +} + +#ws_callflow .callflow .root > .content .number_column { + float: left; + height: 30px; + line-height: 30px; + font-size: 11px; + text-indent: 15px; + text-align: left; + position: relative; +} + +#ws_callflow .callflow .root > .content .number_column.full { + width: 312px; + text-align: center; +} + +#ws_callflow .callflow .root > .content .number_column.second { + width: 163px; + background-image: url(static/images/nav_line.jpg); + background-position: left; + background-repeat: repeat-y; +} + +#ws_callflow .callflow .root > .content .number_column.first { + width: 159px; +} + +#ws_callflow .callflow .root > .content .number_column.empty { + color: #A0A0A0; + cursor: default; +} + +#ws_callflow .callflow .root > .content .number_column .delete { + background-image: url(static/images/btn_delete.png); + background-repeat: no-repeat; + background-position: center; + width: 6px; + height: 6px; + display: inline-block; + position: absolute; + padding: 5px; + right: 0px; + top: 0px; + cursor: pointer; +} + +#ws_callflow .callflow .root > .content .number_column .delete:hover { + background-image: url(static/images/btn_delete_blue.png); +} + +#ws_callflow .callflow .node { + display: inline-block; + cursor: -moz-grab; + cursor: -webkit-grab; + cursor: grab; +} + +#ws_callflow .callflow .node[name="root"] { + cursor: default; +} + +#ws_callflow .callflow .node .node-options .delete { + background-image: url(static/images/btn_delete.png); + background-repeat: no-repeat; + background-position: center; + width: 6px; + height: 6px; + position: absolute; + top: 0px; + right: 0px; + padding: 5px; + cursor: pointer; +} + +#ws_callflow .callflow .node .node-options .delete:hover { + background-image: url(static/images/btn_delete_blue.png); +} + +#ws_callflow .tool .icon { + margin: 2px; + display: inline-block; +} + +#ws_callflow .tools .category { + text-align: center; + background: url(static/images/background_category.png) no-repeat; + background-position: top center; + cursor: default; +} + +#ws_callflow .tools .category .content { + background-color: #777777; + border: 1px solid #333333; +} + +#ws_callflow .tools .open { + font-size: 12px; + height: 26px; + line-height: 26px; + background-repeat: no-repeat; + background-position: 5px center; +} + +#ws_callflow .tools .active .open { + background-image: url(static/images/arrow_active.png); + color: #22A5FF; +} + +#ws_callflow .tools .inactive .open{ + background-image: url(static/images/arrow_inactive.png); +} + +#ws_callflow .tools .tool { + background: #777777; + float: left; + width: 82px; + padding-left: 1px; + padding-top: 1px; + cursor: -moz-grab; + cursor: -webkit-grab; + cursor: grab; +} + +#ws_callflow .destination { + border-radius: 2px; + border: 3px solid #22A5FF; +} + +#ws_callflow .tools .tool .action { + z-index: 19; + height:56px; + background: url(static/images/blackbox_small.png) no-repeat; + min-width: 82px; +} + +#ws_callflow .tools .app_list_nav { + background: #777777; + padding-top: 1px; +} + +#ws_callflow .callflow .icons_black.node { + width: 143px; + height: 84px; + background: url(static/images/blackbox.png) no-repeat; +} + +#ws_callflow #ws_cf_flow .children .child:last-child:not(:first-child) { + padding-right: 10px; +} + +#ws_callflow #ws_cf_flow .children .child:first-child:not(:last-child) { + padding-left: 10px; +} + +#ws_callflow .children > .child > .div_line { + display: inline-block; + height: 6px; + width: 100%; + background-image: url(static/images/line_callflow.png); + background-repeat: repeat-x; + margin-top: -33px; + margin-right: 0px; + margin-left: 0px; + padding: 0px; + float: left; +} +#ws_callflow .children > .child:first-child > .div_line { + width: 50%; + float: right; +} +#ws_callflow .children > .child:last-child > .div_line { + width: 50%; + float: left; +} + +#ws_callflow .children > .child:first-child:last-child > .div_line { + display: none; +} + +#ws_callflow .children > .child > .span_arrow { + display: inline-block; + width: 145px; + background-repeat: no-repeat; + background-position: center center; + margin: 2px 0px 2px; + padding: 0px; + position: relative; +} + +#ws_callflow .children > .child > .span_arrow.small { + height: 31px; + background-image: url(static/images/center_arrow.png); +} + +#ws_callflow .children > .child:first-child > .span_arrow.small { + background-image: url(static/images/left_arrow.png); +} + +#ws_callflow .children > .child:last-child > .span_arrow.small { + background-image: url(static/images/right_arrow.png); +} + +#ws_callflow .children > .child:first-child:last-child > .span_arrow.small { + background-image: url(static/images/small_arrow.png); +} + +#ws_callflow .children > .child > .span_arrow.large { + float: none; + height: 48px; + background-image: url(static/images/tall_arrow.png); +} + +#ws_callflow .a_link_option { + color: #EEE; + font-size: 12px; +} + +#ws_callflow .div_option { + display: inline-block; + height: 15px; + line-height: 15px; + width: 131px; + background-color: #474747; + margin: 0; + padding: 0; + border: 1px solid #303030; + border-radius: 2px; +} + +#ws_callflow .div_icon { + height: 50px; +} + +#ws_callflow .div_icon > span { + display: inline-block; + max-width: 100px; + vertical-align: middle; +} + +#ws_callflow .module { + font-size: 13px; + height: 59px; + margin-top: 25px; + cursor: default; +} + +#ws_callflow .div_icon .module_name { + text-transform: uppercase; + text-align: center; +} + +#ws_callflow .details { + font-size: 10px; + margin-top: -10px; + overflow: hidden; +} + +/* Add number and Edit name popups */ +.dialog_popup_new { + padding: 15px; +} + +.dialog_popup_new .popup_field { + height: 40px; + line-height: 40px; + margin-bottom: 10px; +} + +.dialog_popup_new .popup_field > * { + margin-right: 10px; +} + +.dialog_popup_new .buttons { + text-align: center; +} + +.dialog_popup_new form { + margin: 0; +} + +.dialog_popup_new.edit_name { + width: 350px; +} + +.dialog_popup_new.edit_name .fancy_help_text { + font-size: 12px; + margin-bottom: 10px; +} + +.dialog_popup_new.edit_name input[type="checkbox"] { + margin: 0; +} + +.dialog_popup_new.add_number_popup { + width: 475px; +} + +.add_number_popup .popup_field label { + width: 110px; +} + +.add_number_popup .number-selection-sidelink { + margin-left: 15px; +} + +.add_number_popup input[type=radio] { + margin: -5px 5px 0 10px; +} + +.add_number_popup #list_numbers { + width: 157px; +} + +.add_number_popup #add_number_text { + width: 172px; +} + +.add_number_popup .extensions_content, +.add_number_popup .list_numbers_content { + display: inline-block; +} + +/* has to match setting in js */ +.add_number_popup .list_numbers_content .chosen-drop { + width: 160px; +} + +.add_number_popup .list_numbers_content .nav { + margin-top: 7px; +} + +.fax_callflow_popup .checkbox_field, +.fax_callflow_popup .checkbox_field label { + padding: 0px; +} + +.fax_callflow_popup .checkbox_field #t_38_checkbox { + float: left; +} + +#callflow-content .ui-draggable-dragging { + cursor: -moz-grabbing !important; + cursor: -webkit-grabbing !important; + cursor: grabbing !important; +} + +#ws_callflow .root .top_bar .edit_icon { + background: url('static/images/edit_icon.png') no-repeat scroll center center transparent; + cursor: pointer; + display: inline-block; + height: 18px; + margin: 3px 0px 0px 7px; + width: 20px; +} + +/* callflow.css */ +#callflow_container .callflow-help, .popup_help .callflow-help { + background: url(static/images/callflow_help.gif) no-repeat center; + height: 644px; + width: 847px; + margin: 20px auto auto; + border-radius: 10px; +} + +#callflow_container .callflow-content.edition-mode .callflow-help { + display: none; +} + +#callflow_container .callflow-content.listing-mode #ws_callflow { + display: none; +} + +#ws_callflow { + width: 100%; +} + +#ws_callflow #hidden_callflow_warning { + color: red; + display: none; + font-style: italic; + font-weight: lighter; + margin: auto auto 15px; + text-align: center; + width: 50%; +} + +#ws_callflow #callflow_header { + height: 30px; + margin-top: 15px; + width: 100%; +} + +#ws_callflow #callflow_header #pending_change { + text-align: center; + display: none; +} + +#ws_callflow #callflow_header #pending_change span { + color: #22A5FF; + font-weight: lighter; + font-style: italic; +} + +#ws_callflow #ws_cf_flow { + width: 100%; + overflow-x: auto; + padding-top: 10px; + text-align: center; +} + +#ws_callflow span.flow { + width: 80%; +} + +#ws_callflow .child { + display: inline-block; + vertical-align: top; + text-align: center; + white-space: normal; +} + +#ws_callflow .branch { + display: block; + text-align: center; +} + +#ws_callflow .node.active { + background-color: #fff; + border-radius: 2px; + border: 3px solid #22A5FF; +} + +#ws_callflow .node.inactive { + filter:alpha(opacity=50); + -moz-opacity:0.5; + -khtml-opacity: 0.5; + opacity: 0.5; +} + +#ws_callflow .children { + display: block; + white-space: pre; +} + +#ws_callflow .flowchart { + margin-right: 180px; + overflow: auto; +} + +#ws_callflow .tools { + float: right; + overflow-y: auto; + overflow-x: hidden; +} + +#ws_callflow .tools #ws_cf_tools { + padding-right: 10px; + padding-top: 10px; + padding-bottom:30px; + width: 168px; +} + +#ws_callflow .tools .search-box { + background: #444; +} + +#ws_callflow .tools .search-box input { + width: 120px; + height: 15px; + border-radius: 20px; + margin-top: 3px; + margin-bottom: 3px; + margin-left: 3px; +} + +#ws_callflow .tool { + text-align: center; + vertical-align: middle; +} + +#ws_callflow .tool_name { + font-size: 11px; + line-height: 11px; +} + +#ws_callflow .tools .category.inactive .content { + display: none; +} + +#ws_callflow .tool .action.inactive { + display: none; +} + +#ws_callflow .tool .action.active { + z-index: 10000; +} + +#ws_callflow .title { + background: url("static/images/blue_bar.png"); + font-size: 12px; + height: 25px; + line-height: 25px; + border-radius: 2px 2px 0px 0px; + text-align: center; + color: #fff; + font-weight: bold; +} + +#callflow_container .wrapper_callflow_buttons { + display: block; + width: 322px; + margin: auto; + margin-bottom: 5px; +} + +#callflow_container .wrapper_callflow_buttons .monster-button { + width: 114px; + text-align: center; + display: inline-block; + margin-left: 0px; +} + +#callflow_container .wrapper_callflow_buttons .monster-button:first-child { + margin-right: 10px; +} + +#callflow_container .callflow_helpbox_wrapper { + position: absolute; + right: 185px; + width: 160px; + top: 100px; + display: none; +} + +#callflow_container .callflow_helpbox_wrapper .tip_box { + background-color: #3D3D3D; + border: 1px solid #333333; + border-radius: 2px; + opacity: 80%; + padding: 5px 2px 5px 9px; + text-align: left; + font-size: 10px; + line-height: 12px; +} + +#callflow_container .tooltip { + float: right; + margin-top: 6px; + cursor: pointer; +} + +#callflow_container .pulse-box { + -webkit-animation: "pulse-box" 1s ease-in-out 0 infinite alternate; + + animation-name: pulse-box; + animation-duration: 1s; + animation-timing-function: ease-in-out; + animation-delay: 0; + animation-iteration-count: infinite; + animation-direction: alternate; +} + +@-webkit-keyframes pulse-box { + 0% { box-shadow: 0px 0px 0px #73F03C inset, 0px 0px 0px #14FF00; } + 100% { box-shadow: 0px 0px 30px #73F03C inset, 0px 0px 10px #14FF00; } +} + +@keyframes pulse-box { + 0% { box-shadow: 0px 0px 0px #73F03C inset, 0px 0px 0px #14FF00; } + 100% { box-shadow: 0px 0px 30px #73F03C inset, 0px 0px 10px #14FF00; } +} + +/* JR's customization */ +#callflow_container { + color: #ebebeb; + min-height: 100%; +} + + +/* JR's work for left bar, from accountBrowser */ +#callflow_container .callflow-content { + margin-left: 241px; + background-color: #fff; + overflow-y: auto; +} + +#callflow_container .left-bar-container { + float: left; + background-color: #F3F3F3; + border-right: solid 1px #999; + width: 241px; + overflow: hidden; + border-radius: inherit; +} + +#callflow_container .left-bar-container .search-box { + width: 221px; + padding: 18px 10px; + border-bottom: solid 1px #999; +} + +#callflow_container .left-bar-container .search-box .search-query { + width: 178px; +} + +#callflow_container .left-bar-container.ab-dropdown .list-container { + max-height: 300px; +} + +#callflow_container .left-bar-container .list { + margin: 0; + list-style: none; + float: left; + overflow-y: auto; + overflow-x: hidden; + width: 241px; + height: 100%; + max-height: inherit; +} + +#callflow_container .left-bar-container .list-add { + line-height: 50px; + max-height: 50px; + font-weight: 600; + background-color: #ddd; + width: 241px; + + background-image: -webkit-linear-gradient(top, hsl(0, 0%, 90%) 0%, hsl(0, 0%, 80%) 100%); + background-image: -moz-linear-gradient(top, hsl(0, 0%, 90%) 0%, hsl(0, 0%, 80%) 100%); + background-image: -ms-linear-gradient(top, hsl(0, 0%, 90%) 0%, hsl(0, 0%, 80%) 100%); + background-image: -o-linear-gradient(top, hsl(0, 0%, 90%) 0%, hsl(0, 0%, 80%) 100%); + background-image: linear-gradient(top, hsl(0, 0%, 90%) 0%, hsl(0, 0%, 80%) 100%); + color: #555; +} + +#callflow_container .left-bar-container .list-add i { + margin: 10px; +} + +#callflow_container .left-bar-container .list-add:hover { + background: #ccc; + /*color: #22a5ff;*/ + cursor: pointer; +} + +#callflow_container .left-bar-container .list-add:hover i { + /*color: #22a5ff;*/ +} + +#callflow_container .left-bar-container .list-loader { + padding: 10px; + border-bottom: solid 1px #ccc; +} + +#callflow_container .left-bar-container .list-element { + line-height: 60px; + max-height: 60px; + overflow: hidden; + border-bottom: solid 1px #ccc; +} + +#callflow_container .left-bar-container .list-element > div { + background-color: #f6f6f6; + background-image: -webkit-linear-gradient(top, hsl(0, 0%, 98%) 0%, hsl(0, 0%, 95%) 100%); + background-image: -moz-linear-gradient(top, hsl(0, 0%, 98%) 0%, hsl(0, 0%, 95%) 100%); + background-image: -ms-linear-gradient(top, hsl(0, 0%, 98%) 0%, hsl(0, 0%, 95%) 100%); + background-image: -o-linear-gradient(top, hsl(0, 0%, 98%) 0%, hsl(0, 0%, 95%) 100%); + background-image: linear-gradient(top, hsl(0, 0%, 98%) 0%, hsl(0, 0%, 95%) 100%); + color: #555; + padding-left: 10px; +} + +#callflow_container .left-bar-container .list-element > div:hover { + background: #eee; + cursor: pointer; + /*color: #22a5ff;*/ +} + +#callflow_container .left-bar-container .search-link { + border-bottom: solid 1px #ccc; + text-align: center; + font-size: 12px; + line-height: 15px; + padding: 5px; + color: #555; + background-color: #f6f6f6; + background-image: -webkit-linear-gradient(top, hsl(0, 0%, 90%) 0%, hsl(0, 0%, 85%) 100%); + background-image: -moz-linear-gradient(top, hsl(0, 0%, 90%) 0%, hsl(0, 0%, 85%) 100%); + background-image: -ms-linear-gradient(top, hsl(0, 0%, 90%) 0%, hsl(0, 0%, 85%) 100%); + background-image: -o-linear-gradient(top, hsl(0, 0%, 90%) 0%, hsl(0, 0%, 85%) 100%); + background-image: linear-gradient(top, hsl(0, 0%, 90%) 0%, hsl(0, 0%, 85%) 100%); +} +#callflow_container .left-bar-container .search-link:hover { + background: #eee; + cursor: pointer; +} + +#callflow_container .left-bar-container .search-link .search-value { + font-weight: 600; + text-shadow: 1px 1px 0px #ccc; +} + +#callflow_container .left-bar-container .search-link .search-reset { + color: #22a5ff; + line-height: 30px; + font-weight: 600; +} + +#callflow_container .left-bar-container .search-link:not(.active) .search-reset { + display: none; +} +#callflow_container .left-bar-container .search-link.active > *:not(.search-reset) { + display: none; +} + +#callflow_container .list-container .link .title { + font-size: 16px; + height: 40px; + line-height: 40px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} +#callflow_container .list-container .link .title.standalone { + height: 60px; + line-height: 60px; +} + +#callflow_container .list-container .link .description { + font-size: 10px; + height: 20px; + line-height: 10px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +/* Popups.css */ +.dialog_popup { + padding: 10px 20px; + text-align: center; +} + +.dialog_popup h1 { + padding: 0 0 10px 0; + text-shadow: none; + font-size: 24px; + font-weight: bold; + color: #29ABE1; +} + +.dialog_popup .btn_wrapper_popup { + float: left; + width: 100%; + padding: 30px 0px 10px 0px; +} + +.dialog_popup .form_content { + display: inline-block; +} + +.dialog_popup .form_content label { + font-weight: bold; + width: auto; + margin-right: 10px; + color: #333; + float: left; + padding-top: 5px; +} + +.dialog_popup .form_content select { + width: 100%; + max-width: 200px; +} + +.dialog_popup .form_content .select_wrapper { + float: left; +} + +.dialog_popup .form_content .select_wrapper .action_links_div a { + float: right; + width: 100%; + text-align: right; + text-decoration: underline; + color: #22A5FF; + margin-top: 3px; +} + +.dialog_popup .form_content .popup_field { + padding-bottom: 15px; +} + +.dialog_popup .parameter_div { + padding: 10px 0px 10px 0px; + width: auto; + max-width: 300px; + margin: auto; + display: block; +} + +.dialog_popup .parameter_div .parameter_description { + font-size: 10px; + border-radius: 2px; +} + +.dialog_popup input.size2 { + width: 20px; +} + +.inline_popup { + padding: 0 20px; +} + +.inline_popup.small .main_content { + width: 450px; +} + +.inline_popup.small .main_content .pill-content .clearfix { + display: block; +} + +.dialog_popup .fancy_help_text { + font-size: 12px; +} + +/* Whapps.css */ +.callflows-port .reset_all { + margin:0; + padding:0; + border:0; + font-weight:normal; + font-style:normal; + font-size:100%; + line-height:1; + font-family:inherit; +} + +.callflows-port .reset_margin { + margin:0; +} + +.callflows-port .reset_padding { + padding:0; +} + +.callflows-port .reset_border { + border:0; + background-color:none; +} + +.callflows-port .gradient_strong { + background:#434343; + background:-moz-linear-gradient(top, #434343 0, #353535 50%, #282828 100%); + background:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #434343), color-stop(50%, #353535), color-stop(100%, #282828)); + background:-webkit-linear-gradient(top, #434343 0, #353535 50%, #282828 100%); + background:-o-linear-gradient(top, #434343 0, #353535 50%, #282828 100%); + background:-ms-linear-gradient(top, #434343 0, #353535 50%, #282828 100%); + background:linear-gradient(top, #434343 0, #353535 50%, #282828 100%); + filter:progid:dximagetransform.microsoft.gradient(startColorstr='#434343', endColorstr='#282828', GradientType=0); +} + +.callflows-port .gradient_light { + background:#373737; + background:-moz-linear-gradient(top, #373737 0, #2e2e2e 50%, #2f2f2f 100%); + background:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #373737), color-stop(50%, #2e2e2e), color-stop(100%, #2f2f2f)); + background:-webkit-linear-gradient(top, #373737 0, #2e2e2e 50%, #2f2f2f 100%); + background:-o-linear-gradient(top, #373737 0, #2e2e2e 50%, #2f2f2f 100%); + background:-ms-linear-gradient(top, #373737 0, #2e2e2e 50%, #2f2f2f 100%); + background:linear-gradient(top, #373737 0, #2e2e2e 50%, #2f2f2f 100%); + filter:progid:dximagetransform.microsoft.gradient(startColorstr='#373737', endColorstr='#2f2f2f', GradientType=0); +} + +.callflows-port h1, +.callflows-port h2, +.callflows-port h3, +.callflows-port h4, +.callflows-port h5 { + color:#22A5FF; + font-weight:lighter; +} + +.callflows-port h3 { + font-size:14px; +} + +.callflows-port h1 { + font-size:24px; + letter-spacing: 1px; + margin-top: 0; +} + +.callflows-port hr { + margin:0; + border-top:1px solid #404040; + border-bottom:1px solid #202020; +} + +.callflows-port .monster-button { + min-width:100px; +} + +.callflows-port input[type="file"] { + background-color:transparent; + padding-top:5px; +} + +.callflows-port input { + color:#555; +} + +.callflows-port ul, ol { + list-style: none; + margin: 0; +} + +.callflows-port form .clearfix:last-child { + margin-bottom:0; +} + +.callflows-port .toggled { + margin-bottom:30px; + margin-top:30px; +} + +.callflows-port .whapp-header>h1, .whapp-header>h2, .whapp-header>h3 { + float:left; +} + +.callflows-port .whapp-header>.buttons-right { + margin-top:10px; +} + +.callflows-port .input-append>span.add-on { + -webkit-border-top-left-radius:2px; + -webkit-border-top-right-radius:0; + -webkit-border-bottom-right-radius:0; + -webkit-border-bottom-left-radius:2px; + -moz-border-radius-topleft:2px; + -moz-border-radius-topright:0; + -moz-border-radius-bottomright:0; + -moz-border-radius-bottomleft:2px; + border-top-left-radius:2px; + border-top-right-radius:0; + border-bottom-right-radius:0; + border-bottom-left-radius:2px; + margin:0; + margin-right:-1px; + font-size:16px; + font-weight:bold; +} + +.callflows-port .input-append>input { + -webkit-border-top-left-radius:0; + -webkit-border-top-right-radius:0; + -webkit-border-bottom-right-radius:0; + -webkit-border-bottom-left-radius:0; + -moz-border-radius-topleft:0; + -moz-border-radius-topright:0; + -moz-border-radius-bottomright:0; + -moz-border-radius-bottomleft:0; + border-top-left-radius:0; + border-top-right-radius:0; + border-bottom-right-radius:0; + border-bottom-left-radius:0; +} + +.callflows-port .pill-content { + background:#373737; + background:-moz-linear-gradient(top, #373737 0, #2e2e2e 50%, #2f2f2f 100%); + background:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #373737), color-stop(50%, #2e2e2e), color-stop(100%, #2f2f2f)); + background:-webkit-linear-gradient(top, #373737 0, #2e2e2e 50%, #2f2f2f 100%); + background:-o-linear-gradient(top, #373737 0, #2e2e2e 50%, #2f2f2f 100%); + background:-ms-linear-gradient(top, #373737 0, #2e2e2e 50%, #2f2f2f 100%); + background:linear-gradient(top, #373737 0, #2e2e2e 50%, #2f2f2f 100%); + filter:progid:dximagetransform.microsoft.gradient(startColorstr='#373737', endColorstr='#2f2f2f', GradientType=0); + color: #EEE; + padding:30px; + border:1px solid #22A5FF; + box-shadow:1px 2px 5px 0px #363636; + -moz-box-shadow:4px 5px 10px 1px #262626; + -webkit-box-shadow:4px 5px 10px 1px #262626; +} + +.callflows-port .pill-content h3, +.callflows-port .row h3 { + margin-bottom:20px; + color:#0ac9ff; +} + +.callflows-port .pill-content .edit_create { + margin-left:20px; + display:inline; +} +.callflows-port .pill-content .edit_create a { + color: #EEE; +} + +.callflows-port .pill-content .edit_create > a:not(:first-child) { + margin-left:5px; +} + +.callflows-port .btn.black:first-child { + border-radius: 2px 0 0 2px; +} + +.callflows-port .btn.black:last-child { + border-radius: 0 2px 2px 0; +} + +.callflows-port .btn.black { + background:#434343; + background:-moz-linear-gradient(top, #434343 0, #353535 50%, #282828 100%); + background:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #434343), color-stop(50%, #353535), color-stop(100%, #282828)); + background:-webkit-linear-gradient(top, #434343 0, #353535 50%, #282828 100%); + background:-o-linear-gradient(top, #434343 0, #353535 50%, #282828 100%); + background:-ms-linear-gradient(top, #434343 0, #353535 50%, #282828 100%); + background:linear-gradient(top, #434343 0, #353535 50%, #282828 100%); + filter:progid:dximagetransform.microsoft.gradient(startColorstr='#434343', endColorstr='#282828', GradientType=0); + color:#e6e6e6; + text-shadow:none; + font-size:12px; + border:1px solid #1a1a1a; + border-radius: 0; +} + +.callflows-port .btn.black.activate { + box-shadow:inset 0 0 10px 1px #000; + -moz-box-shadow:inset 0 0 10px 1px #000; + -webkit-box-shadow:inset 0 0 10px 1px #000; +} + +.callflows-port .btn.black:hover { + color:#e6e6e6; + background:#434343; + background:-moz-linear-gradient(top, #434343 0, #353535 50%, #282828 100%); + background:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #434343), color-stop(50%, #353535), color-stop(100%, #282828)); + background:-webkit-linear-gradient(top, #434343 0, #353535 50%, #282828 100%); + background:-o-linear-gradient(top, #434343 0, #353535 50%, #282828 100%); + background:-ms-linear-gradient(top, #434343 0, #353535 50%, #282828 100%); + background:linear-gradient(top, #434343 0, #353535 50%, #282828 100%); + filter:progid:dximagetransform.microsoft.gradient(startColorstr='#434343', endColorstr='#282828', GradientType=0); + box-shadow:inset 0 0 10px 1px #000; + -moz-box-shadow:inset 0 0 10px 1px #000; + -webkit-box-shadow:inset 0 0 10px 1px #000; +} + +.callflows-port .buttons-right { + text-align: right; +} + +.callflows-port .buttons-right>.monster-button:not(:last-child) { + margin-right:6px; +} + +.callflows-port .pasted>.monster-button:first-child { + -webkit-border-top-left-radius:2px; + -webkit-border-top-right-radius:0; + -webkit-border-bottom-right-radius:0; + -webkit-border-bottom-left-radius:2px; + -moz-border-radius-topleft:2px; + -moz-border-radius-topright:0; + -moz-border-radius-bottomright:0; + -moz-border-radius-bottomleft:2px; + border-top-left-radius:2px; + border-top-right-radius:0; + border-bottom-right-radius:0; + border-bottom-left-radius:2px; + margin-right:-4px; +} + +.callflows-port .pasted>.monster-button:last-child { + -webkit-border-top-left-radius:0; + -webkit-border-top-right-radius:2px; + -webkit-border-bottom-right-radius:2px; + -webkit-border-bottom-left-radius:0; + -moz-border-radius-topleft:0; + -moz-border-radius-topright:2px; + -moz-border-radius-bottomright:2px; + -moz-border-radius-bottomleft:0; + border-top-left-radius:0; + border-top-right-radius:2px; + border-bottom-right-radius:2px; + border-bottom-left-radius:0; +} + +/* From layout.css */ +.callflows-port .main_content { + margin: 0 auto; + padding: 10px 0 15px 0; + width: 800px; +} + +/* Custom specific bootstrap */ +.callflows-port input[type="checkbox"] { + margin: 0 5px 0 0; +} + +/* Hack for callflow quick edit popup */ +.dialog_popup.callflows-port form label:not(.monster-invalid) { + color: #333; +} + +.callflows-port form label:not(.monster-invalid) { + float: left; + font-size: 13px; + line-height: 18px; + padding-top: 6px; + text-align: right; + width: 130px; + color:#e6e6e6; +} + +.callflows-port form label.monster-switch { + padding-top: 0; + width: auto; +} + +.callflows-port label.monster-invalid { + position: relative; + color: orange; + margin-top: -10px; +} + +.callflows-port form .input { + margin-left: 150px; +} + +.callflows-port form .clearfix { + margin-bottom: 10px; +} + +.callflows-port form .inputs-list label { + display: block; + float: none; + line-height: 18px; + margin-left: 20px; + padding: 0; + text-align: left; + white-space: normal; + width: auto; +} + +.callflows-port form .inputs-list input[type="radio"], +.callflows-port form .inputs-list input[type="checkbox"] { + float: left; + margin-bottom: 0; + margin-left: -20px; +} + +.callflows-port form input.span4, +.callflows-port form textarea.span4 { + display: inline-block; + float: none; + margin-left: 0; + width: 210px; +} + +.callflows-port li { + color: #808080; + line-height: 18px; +} + +/* Still Bootstrap, but Tabs */ +.callflows-port .tab-content > .tab-pane, +.callflows-port .pill-content > .pill-pane, +.callflows-port .tab-content > div, +.callflows-port .pill-content > div { + display: none; +} + +.callflows-port .tab-content > .active, +.callflows-port .pill-content > .active { + display: block; +} + +.callflows-port .tabs:after, +.callflows-port .pills:after { + clear: both; +} + +.callflows-port .tabs:before, +.callflows-port .pills:before, +.callflows-port .tabs:after, +.callflows-port .pills:after { + content: ""; + display: table; +} + +.callflows-port .pills { + list-style: outside none none; + margin: 0 0 18px; + padding: 0; +} + +.callflows-port .pills > li { + float: left; +} + +.callflows-port .pills > li > a { + display: block; +} + +.callflows-port .tabs { + list-style: none; + padding: 0; + background-color:none; +} + +.callflows-port .tabs > li { + background:#434343; + background:-moz-linear-gradient(top, #434343 0, #353535 50%, #282828 100%); + background:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #434343), color-stop(50%, #353535), color-stop(100%, #282828)); + background:-webkit-linear-gradient(top, #434343 0, #353535 50%, #282828 100%); + background:-o-linear-gradient(top, #434343 0, #353535 50%, #282828 100%); + background:-ms-linear-gradient(top, #434343 0, #353535 50%, #282828 100%); + background:linear-gradient(top, #434343 0, #353535 50%, #282828 100%); + filter:progid:dximagetransform.microsoft.gradient(startColorstr='#434343', endColorstr='#282828', GradientType=0); + border-top:1px solid; + border-top-color:#262626; + border-left:1px solid; + border-left-color:#2f2f2f; + float: left; + font-size: 12px; + margin-bottom: -1px; + position: relative; +} + +.callflows-port .tabs > li:first-child { + border-radius: 2px 0 0 0; + border-left: 1px solid; + border-left-color:#1a1a1a; +} + +.callflows-port .tabs > li:last-child { + border-radius: 0 2px 0 0; + border-right: 1px solid; + border-right-color: #1a1a1a; +} + +.callflows-port .tabs > li > a { + border-radius: 2px 2px 0 0; + display: block; + line-height: 34px; + padding: 0 15px; + color: #fff; +} + +.callflows-port .tabs > li > a:hover { + text-decoration: none; +} + +.callflows-port .tabs .active { + border-top:0; + border-bottom:1px solid #373737; +} + +.callflows-port .tabs > li:first-child.active { + border-left:1px solid #22A5FF; +} + +.callflows-port .tabs > li:last-child.active { + border-right:0; +} + +.callflows-port .tabs > li > a > .icon { + margin-right:3px; +} + +.callflows-port .tabs > li > a:hover { + color:#fff; + background-color:transparent; +} + +.callflows-port .tabs .active > a, +.callflows-port .tabs .active > a:hover { + border:0; + background-color:none; + border-radius: 2px 2px 0 0; + color:#fff; + background:#373737; + border-top:1px solid; + border-top-color:#22A5FF; + border-left:1px solid; + border-left-color:#22A5FF; + border-right:1px solid; + border-right-color:#22A5FF; + font-weight:bold; + text-decoration: none; +} + +.callflows-port .tabs li:first-child.active > a { + border-left : none; +} + +.callflows-port .popover-content { + color: #333; +} + +.callflows-port .help_box { + margin-bottom: 10px; + padding: 10px; + padding-bottom: 10px; + border: 1px solid #363636; + border-radius: 2px 2px 2px 2px; + background: #22A5FF; + background: -webkit-gradient(linear, left top, left bottom, from(#22A5FF), to(#036884)) !important; + background: -moz-linear-gradient(top, #22A5FF, #036884) !important; + box-shadow: 1px 1px 1px #333333; + text-align: center; + font-style: italic; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#22A5FF', endColorstr='#036884') !important; +} + +/********** Misc images **********/ + +.callflows-port#ring_group_popup #two_columns .column.right ul.connect.no_element { + background: url(static/images/empty_ring_group.png) no-repeat center; +} + +.callflows-port #two_columns .wrapper li a.drag_btn { + background-image: url(static/images/drag_btn_28.png); +} + +.callflows-port .search_box .searchsubmit1 { + background: url(static/images/search_left.png) no-repeat top left; +} +.callflows-port .search_box .searchsubmit2 { + background: url(static/images/search_right.png) no-repeat top right; +} +.callflows-port .search_box .searchfield { + background: url(static/images/search_mid.png) repeat-x; +} + + +#callflow_container .entity-manager { + padding: 10px; + max-width: 1280px; + margin: auto; + color: #303039; +} + +#callflow_container .entity-manager .grid-header { + font-size: 34px; + line-height: 40px; + margin: 20px 10px; +} + +#callflow_container .entity-manager .entity-element { + display: inline-block; + margin: 10px; + text-align: center; + width: 120px; + height: 120px; + padding: 0px; + font-size: 20px; + cursor: pointer; + border: solid 1px #303039; + box-sizing: border-box; + border-radius: 2px; + vertical-align: top; +} +#callflow_container .entity-manager .entity-element.callflow-element { + width: 260px; + height: 260px; + float: left; + font-size: 50px; + font-weight: 300; +} +#callflow_container .entity-manager .entity-element:hover { + background-color: #f0f0f9; +} + +#callflow_container .entity-manager .entity-element > div { + position: relative; + top: 50%; + -webkit-transform: translateY(-50%); + -ms-transform: translateY(-50%); + transform: translateY(-50%); +} + +#callflow_container .entity-edition, +#callflow_container .entity-manager .callflow-edition { + display: none; +} + +#callflow_container .entity-edition .left-bar-container { + box-sizing: border-box; +} + +#callflow_container .entity-edition .callflow-content { + margin: 0; + float: left; + box-sizing: border-box; + width: 800px; /* Arbitrary width if calc not supported */ + width: -webkit-calc(100% - 241px); + width: -moz-calc(100% - 241px); + width: -o-calc(100% - 241px); + width: calc(100%-241px); +} + + +#callflow_container .entity-header{ + padding: 18px 40px; + height: 71px; + box-sizing: border-box; + border-bottom: solid 1px #999; +} +#callflow_container .entity-header .entity-title { + color: #22a5ff; + font-size: 30px; + line-height: 36px; + float:left; +} +#callflow_container .entity-header .back-button { + float: right; +} + +#callflow_container .entity-header .superadmin-mode { + float: right; + line-height: 35px; + margin-right: 50px; + display: inline-block; +} + +#callflow_container .entity-header .superadmin-mode .switch-title { + color: #22a5ff; + margin-right: 5px; +} + +#callflow_container .entity-content { + padding: 20px 40px; +} + +/* Account Settings */ +#callflow_container .account-settings-container { + color: #303039; +} + +#callflow_container .account-settings-container .settings-section .section-title { + font-size: 22px; + font-weight: 600; + margin-bottom: 20px; +} + +#callflow_container .account-settings-container .entity-content { + padding: 40px; +} + +#callflow_container .account-settings-container #account_settings_form { + min-width: 400px; + max-width: 1140px; + margin: auto; +} + +#callflow_container .account-settings-container .tab-content { + background-color: #f0f0f9; + padding: 20px; +} + +#callflow_container .account-settings-container .upload-toggle { + margin-left: 10px; +} +#callflow_container .account-settings-container .upload-div { + display: none; + margin-top: 20px; +} +#callflow_container .account-settings-container .upload-div .upload-input { + margin: 0; + width: 330px; +} +#callflow_container .account-settings-container .upload-div button.upload-action { + margin-left: 10px; + min-width: 20px; + padding-right: 10px; +} +#callflow_container .account-settings-container .upload-div .file-upload { + margin: 0; + display: inline-block; +} +#callflow_container .account-settings-container .upload-div .file-upload > input { + margin: 0; + margin-left: 180px; + width: 110px; + padding: 6px; +} +#callflow_container .account-settings-container .upload-div .file-upload > button { + width: 100px; + min-width: initial; +} +#callflow_container .account-settings-container .action-bar { + padding-top: 15px; +} + + +.media-edit-callflow-popup .shoutcast-div, +#callflow_container .account-settings-container .shoutcast-div { + display: none; +} + +.media-edit-callflow-popup .shoutcast-div.active, +#callflow_container .account-settings-container .shoutcast-div.active { + display: block; +} + +/* Blacklist part */ +/* We can't name space it because some dialogs from callflow use the clear... If we were to change it we'd have to update those popups too */ +.clear { + clear: both; +} + +#callflow_container .blacklists-wrapper { + padding: 20px; + background: #FFF; + border: 1px solid #ccc; + width: 800px; +} + +#callflow_container .blacklists-wrapper .items-selector .box-selector ul { + height: 250px; +} + +/* Media shoutcast addition */ +.media-edit-callflow-popup .form_content { + width: 360px; +} + +.media-edit-callflow-popup #edit_link { + display: none; +} + +.media-edit-callflow-popup #edit_link.active { + display: block; +} \ No newline at end of file diff --git a/src/apps/callflows/style/icons.css b/src/apps/callflows/style/icons.css new file mode 100644 index 0000000..3eb1d30 --- /dev/null +++ b/src/apps/callflows/style/icons.css @@ -0,0 +1,1328 @@ +/* + Document : icons + Created on : Jun 6, 2011, 7:19:19 AM + Author : Darren Schreiber + Description: + This stylesheet allows you to load a single image map and specify an icon type and color to have it appear. + + Examples include +
    <-- Show a picture of a phone --> +
    <-- Show a picture of a phone, as current selection (typically blue) --> +
    <-- Show a picture of a phone and explicitly force it to appear in dark grey --> +*/ + +/* Can't namespace as it's also used outside of the callflow container scope: in dialogs; */ + +.icon { + display: inline-block; + width: 32px; + height: 32px; + background-image: url(static/images/icons/icons_32x32_gradient.png); + background-repeat: no-repeat; + background-position: center center; + vertical-align: middle; +} + +.icon.medium { + width: 24px; + height: 24px; + background-image: url(static/images/icons/icons_24x24_gradient.png); +} + +/* Color overrides */ +.icon.gradient { + background-image: url(static/images/icons/icons_32x32_gradient.png); +} + +.icon.blue { + background-image: url(static/images/icons/icons_32x32_blue.png); +} + +.icon.darkgrey { + background-image: url(static/images/icons/icons_32x32_darkgrey.png); +} + +.icon.green { + background-image: url(static/images/icons/icons_32x32_green.png); +} + +.icon.lightgrey { + background-image: url(static/images/icons/icons_32x32_lightgrey.png); +} + +.icon.red { + background-image: url(static/images/icons/icons_32x32_red.png); +} + +.icon.white { + background-image: url(static/images/icons/icons_32x32_white.png); +} + +.icon.yellow { + background-image: url(static/images/icons/icons_32x32_yellow.png); +} + +.icon.medium.blue { + background-image: url(static/images/icons/icons_24x24_blue.png); +} + +.icon.medium.red { + background-image: url(static/images/icons/icons_24x24_blue.png); +} + +.icon.medium.gradient { + background-image: url(static/images/icons/icons_24x24_blue.png); +} + +/************** ICONS APPNAV *****/ + +.icon.voip_services { /* 4, 5 */ + background-position: -128px -160px; +} + +.icon.cluster_manager { /* 23, 0 */ + background-position: -730px 0px; +} + +.icon.connectivity { /* 8, 13 */ + background-position: -256px -416px; +} + +.icon.dashboard { /* 10, 13 */ + background-position: -320px -416px; +} + +.icon.user_portal { + background-position: -478px -192px; +} + +.icon.userportal { + background-position: -478px -192px; +} + +/************** ICONS SUBNAV *****/ + +.icon.account { /* 0, 11 */ + background-position: 0 -357px; +} + +.icon.callflow { /* 5, 0 */ + background-position: -160px -5px; +} + +.icon.conference { /* 14, 3 */ + background-position: -448px -101px; +} + +.icon.device { /* 16, 5 */ + background-position: -512px -165px; +} + +.icon.media { /* 10, 9 */ + background-position: -320px -293px; +} + +.icon.play { /* 10, 9 */ + background-position: -320px -293px; +} + +.icon.menu1 { /* 20, 5 */ + background-position: -640px -165px; +} + +.icon.registration { /* 18, 7 */ + background-position: -576px -229px; +} + +.icon.resource { /* 0, 7 */ + background-position: 0 -229px ; +} + +.icon.offnet { /* 0, 7 */ + background-position: 0 -229px ; +} + +.icon.user { /* 17, 6 */ + background-position: -544px -197px; +} + +.icon.vmbox { /* 30, 5 */ + background-position: -960px -160px; +} + +.icon.voicemail { /* 30, 5 */ + background-position: -960px -165px; +} + +.icon.timeofday { /* 15, 8 */ + background-position: -448px -229px; +} + +.icon.temporal_route { /* 15, 8 */ + background-position: -448px -229px; +} + +.icon.ring_group { /* 10, 5 Needs to change to a better one */ + background-position: -320px -165px; +} + +.icon.settings { + background-position: -480px -131px; +} + +.icon.advanced { + background-position: -576px -421px; +} + +/************** ICONS ************/ +.icon.phone { + background-position: -507px -161px; +} + +.icon.active_phone { + background-position: -192px -163px; +} + +.icon.cellphone { + background-position: 5px -163px; +} + +.icon.landline { + background-position: -192px -165px; +} + +.icon.sip_device { + background-position: -511px -165px; +} + +.icon.softphone { + background-position: -640px -165px; +} + +.icon.legal { + background-position: -736px -323px; +} + +.icon.help { + background-position: -608px -195px; +} + +.icon.book { + background-position: -320px -355px; +} + +.icon.small_edit { + background-position: -368px -64px; +} + +.icon.download { + background-position: -732px -0px; +} + +.icon.trash { + background-position: -32px -64px; +} + +.icon.queue { + background-position: -384px -418px; +} + +.icon.support { + background-position: -416px -195px; +} + +.icon.price_tag { + background-position: -416px -259px; +} + +.icon.sip { + background-position: -705px -160px; +} + +.icon.audio { + background-position: -320px -293px; +} + +.icon.video { + background-position: -96px -389px; +} + +.icon.fax { + background-position: -512px -353px; +} + +.icon.cc { + background-position: -577px -357px; +} + +.icon.cdr { + background-position: -192px -165px; +} + +.icon.billing { + background-position: -769px -357px; +} + +.icon.location { + background-position: -24px -255px; +} + +.icon.limit { + background-position: -830px -290px; +} + +.icon.charge { + background-position: -192px -356px; +} + +.icon.monitoring { + background-position: -321px -419px; +} + +.icon.robot { + background-position: -736px -387px; +} + +.icon.rightarrow { + background-position: -860px -2px; +} + +.icon.cart { + background-position: -700px -292px; +} + +.icon.authentication { + background-position: 0 -290px; +} + +.icon.recharge { + background-position: -473px 0; +} + +.icon.dollar { + background-position: -960px -419px; +} + +.icon.search { + background-position: -895px -424px; +} + +.icon.question { + background-position: -131px -40px; +} + +.icon.puzzle { + background-position: -480px -451px; +} + +.icon.account { + background-position: 0 -357px; +} + +.icon.credit_card { + background-position: -577px -357px; +} + +.icon.billing { + background-position: -769px -357px; +} + + +.icon.authentication { + background-position: 0 -290px; +} + +.icon.location { + background-position: -32px -260px; +} + +.icon.limit { + background-position: -830px -290px; +} + +.icon.monitoring { + background-position: -321px -419px; +} + +.icon.robot { + background-position: -736px -387px; +} + +.icon.search { + background-position: -895px -424px; +} + +.icon.v_phone { + background-position: -448px -163px; +} + +.icon.hotdesk_login { + background-position: -64px -288px; +} + +.icon.hotdesk_logout { + background-position: 0 -288px; +} + +.icon.hotdesk_toggle { + background-position: -288px 0px; +} + +/**** The 'real' icons ****/ + +.icon.crossed_arrow { + background-position: -32px 0px; +} + +.icon.loop1 { + background-position: -96px 0px; +} + +.icon.squiggly_arrow { + background-position: -160px 0px; +} + +.icon.crossed_loop { + background-position: -224px 0px; +} + +.icon.refresh { + background-position: -288px 0px; +} + +.icon.stair_arrow { + background-position: -352px 0px; +} + +.icon.uturn_arrow { + background-position: -416px 0px; +} + +.icon.loop2 { + background-position: -480px 0px; +} + +.icon.loop3 { + background-position: -544px 0px; +} + +.icon.to_cloud { + background-position: -608px 0px; +} + +.icon.from_cloud { + background-position: -672px 0px; +} + +.icon.box_arrow_down { + background-position: -736px 0px; +} + +.icon.map_arrow { + background-position: -800px 0px; +} + +.icon.right_arrow { + background-position: -864px 0px; +} + +.icon.left_arrow { + background-position: -928px 0px; +} + +.icon.right_turn { + background-position: -992px 0px; +} + +.icon.magnify { + background-position: 0px -32px; +} + +.icon.magnify_circle { + background-position: -64px -32px; +} + +.icon.question_circle { + background-position: -128px -32px; +} + +.icon.minus_circle { + background-position: -192px -32px; +} + +.icon.plus_circle { + background-position: -256px -32px; +} + +.icon.wifi_circle { + background-position: -320px -32px; +} + +.icon.exclaim_circle { + background-position: -384px -32px; +} + +.icon.info_circle { + background-position: -448px -32px; +} + +.icon.right_arrow_circle { + background-position: -512px -32px; +} + +.icon.down_arrow_circle { + background-position: -576px -32px; +} + +.icon.left_arrow_circle { + background-position: -640px -32px; +} + +.icon.up_arrow_circle { + background-position: -704px -32px; +} + +.icon.short_right_arrow_circle { + background-position: -768px -32px; +} + +.icon.short_left_arrow_circle { + background-position: -832px -32px; +} + +.icon.check_circle { + background-position: -896px -32px; +} + +.icon.x_circle { + background-position: -960px -32px; +} + +.icon.trash1 { + background-position: -32px -64px; +} + +.icon.recycle { + background-position: -96px -64px; +} + +.icon.trash2 { + background-position: -160px -64px; +} + +.icon.wind { + background-position: -224px -64px; +} + +.icon.bluetooth { + background-position: -288px -64px; +} + +.icon.home1 { + background-position: -352px -64px; +} + +.icon.home2 { + background-position: -416px -64px; +} + +.icon.speaker_off { + background-position: -480px -64px; +} + +.icon.speaker_on { + background-position: -544px -64px; +} + +.icon.battery_empty { + background-position: -608px -64px; +} + +.icon.battery_full { + background-position: -672px -64px; +} + +.icon.power { + background-position: -736px -64px; +} + +.icon.on { + background-position: -800px -64px; +} + +.icon.check_box { + background-position: -864px -64px; +} + +.icon.check { + background-position: -928px -64px; +} + +.icon.x { + background-position: -992px -64px; +} + +.icon.human_chat { + background-position: 0px -96px; +} + +.icon.chat1 { + background-position: -64px -96px; +} + +.icon.dot_chat { + background-position: -128px -96px; +} + +.icon.chat_box { + background-position: -192px -96px; +} + +.icon.chat_circle { + background-position: -256px -96px; +} + +.icon.chat_bubble { + background-position: -320px -96px; +} + +.icon.chat_bubble2 { + background-position: -384px -96px; +} + +.icon.convo_chat { + background-position: -448px -96px; +} + +.icon.line_globe { + background-position: -512px -96px; +} + +.icon.saturn { + background-position: -576px -96px; +} + +.icon.earth { + background-position: -640px -100px; +} + +.icon.globe_stand { + background-position: -704px -96px; +} + +.icon.thumb_up { + background-position: -768px -96px; +} + +.icon.thumb_down { + /* background-position: -832px -96px; */ + background-position: -832px -99px; +} + +.icon.peace_sign { + background-position: -896px -96px; +} + +.icon.hand { + /* background-position: -960px -96px; */ + background-position: -960px -99px; +} + +.icon.wrench_left { + background-position: -32px -128px; +} + +.icon.wrench_right { + background-position: -96px -128px; +} + +.icon.wrench3 { + background-position: -160px -128px; +} + +.icon.gavel { + background-position: -224px -128px; +} + +.icon.wrench_hammer { + background-position: -288px -128px; +} + +.icon.hammer { + background-position: -352px -128px; +} + +.icon.wrench_screw { + background-position: -416px -128px; +} + +.icon.settings1 { + background-position: -480px -128px; +} + +.icon.settings2 { + background-position: -544px -128px; +} + +.icon.settings3 { + background-position: -608px -128px; +} + +.icon.comb { + background-position: -672px -128px; +} + +.icon.pencil { + background-position: -736px -128px; +} + +.icon.paperclip1 { + background-position: -800px -128px; +} + +.icon.paperclip2 { + background-position: -864px -128px; +} + +.icon.scissors { + background-position: -928px -128px; +} + +.icon.bow_arrow { + background-position: -992px -128px; +} + +.icon.iphone { + background-position: 0px -160px; +} + +.icon.handset1 { + background-position: -64px -160px; +} + +.icon.handset2 { + background-position: -128px -160px; +} + +.icon.handset3 { + background-position: -192px -160px; +} + +.icon.phone_set1 { + background-position: -256px -160px; +} + +.icon.phone_trio { + background-position: -320px -160px; +} + +.icon.handset4 { + background-position: -384px -160px; +} + +.icon.cordless1 { + background-position: -448px -160px; +} + +.icon.cordless2 { + background-position: -512px -160px; +} + +.icon.mobile1 { + background-position: -576px -160px; +} + +.icon.dial_pad1 { + background-position: -640px -160px; +} + +.icon.dial_pad2 { + background-position: -704px -160px; +} + +.icon.two_circles { + background-position: -768px -160px; +} + +.icon.headset { + background-position: -832px -160px; +} + +.icon.mail1 { + background-position: -896px -160px; +} + +.icon.mail2 { + background-position: -960px -160px; +} + +.icon.person_run { + background-position: -32px -192px; +} + +.icon.person_walk { + background-position: -96px -192px; +} + +.icon.man_stand { + background-position: -160px -192px; +} + +.icon.woman_stand { + background-position: -224px -192px; +} + +.icon.person_yay { + background-position: -288px -192px; +} + +.icon.open_arms { + background-position: -352px -192px; +} + +.icon.tech_support { + background-position: -416px -192px; +} + +.icon.head1 { + /* background-position: -480px -192px; */ + background-position: -478px -196px; +} + +.icon.head2 { + background-position: -544px -192px; +} + +.icon.head3 { + background-position: -608px -192px; +} + +.icon.smiley { + background-position: -672px -192px; +} + +.icon.skull1 { + background-position: -736px -192px; +} + +.icon.skull2 { + background-position: -800px -192px; +} + +.icon.baby { + background-position: -864px -192px; +} + +.icon.mouth_face { + background-position: -928px -192px; +} + +.icon.sad_face { + background-position: -992px -192px; +} + +.icon.internet_box { + background-position: 0px -224px; +} + +.icon.black_box { + background-position: -64px -224px; +} + +.icon.scale { + background-position: -128px -224px; +} + +.icon.compass { + background-position: -192px -224px; +} + +.icon.stopwatch1 { + background-position: -256px -224px; +} + +.icon.stopwatch2 { + background-position: -320px -224px; +} + +.icon.clock1 { + background-position: -384px -224px; +} + +.icon.clock2 { + background-position: -448px -224px; +} + +.icon.internet1 { + background-position: -512px -224px; +} + +.icon.internet2 { + background-position: -576px -224px; +} + +.icon.internet3 { + background-position: -640px -224px; +} + +.icon.outlet1 { + background-position: -704px -224px; +} + +.icon.outlet2 { + background-position: -768px -224px; +} + +.icon.lightbulb_off { + background-position: -832px -224px; +} + +.icon.lightbulb_on { + background-position: -896px -224px; +} + +.icon.semi_circle { + background-position: -960px -224px; +} + +.icon.place { + background-position: -32px -256px; +} + +.icon.bell1 { + background-position: -96px -256px; +} + +.icon.bell2 { + background-position: -160px -256px; +} + +.icon.flag1 { + background-position: -224px -256px; +} + +.icon.arrow_sign { + background-position: -288px -256px; +} + +.icon.tag1 { + background-position: -352px -256px; +} + +.icon.price_tag { + background-position: -416px -256px; +} + +.icon.piggy_bank { + background-position: -480px -256px; +} + +.icon.eyelash { + background-position: -544px -256px; +} + +.icon.glasses { + background-position: -608px -256px; +} + +.icon.plane { + background-position: -672px -256px; +} + +.icon.luggage1 { + background-position: -736px -256px; +} + +.icon.luggage2 { + background-position: -800px -256px; +} + +.icon.exclamation1 { + background-position: -864px -256px; +} + +.icon.storm1 { + background-position: -928px -256px; +} + +.icon.shirt1 { + background-position: -992px -256px; +} + +.icon.lock { + background-position: 0px -288px; +} + +.icon.unlock { + background-position: -64px -288px; +} + +.icon.key { + background-position: -128px -288px; +} + +.icon.lightning1 { + background-position: -192px -288px; +} + +.icon.music1 { + background-position: -256px -288px; +} + +.icon.music2 { + background-position: -320px -288px; +} + +.icon.music3 { + background-position: -384px -288px; +} + +.icon.infinity { + background-position: -448px -288px; +} + +.icon.mic1 { + background-position: -512px -288px; +} + +.icon.speaker1 { + background-position: -576px -288px; +} + +.icon.mic2 { + background-position: -640px -288px; +} + +.icon.shop_cart { + background-position: -704px -288px; +} + +.icon.toxic1 { + background-position: -768px -288px; +} + +.icon.exclamation2 { + background-position: -832px -288px; +} + +.icon.gift1 { + background-position: -896px -288px; +} + +.icon.bird_fly { + background-position: -960px -288px; +} + +.icon.bird_stand { + background-position: -32px -320px; +} + +.icon.ying_yang { + background-position: -96px -320px; +} + +.icon.hand_out { + background-position: -160px -320px; +} + +.icon.thumb_up2 { + background-position: -224px -320px; +} + +.icon.tree { + background-position: -288px -320px; +} + +.icon.plant { + background-position: -352px -320px; +} + +.icon.paint_roller { + background-position: -416px -320px; +} + +.icon.paint1 { + background-position: -480px -320px; +} + +.icon.winners_cup { + background-position: -544px -320px; +} + +.icon.stein { + background-position: -608px -320px; +} + +.icon.martini { + background-position: -672px -320px; +} + +.icon.scale1 { + background-position: -736px -320px; +} + +.icon.dice { + background-position: -800px -320px; +} + +.icon.weight { + background-position: -864px -320px; +} + +.icon.guitar { + background-position: -928px -320px; +} + +.icon.tie { + background-position: -992px -320px; +} + +.icon.polaroid { + background-position: 0px -352px; +} + +.icon.painting { + background-position: -64px -352px; +} + +.icon.calendar { + background-position: -128px -352px; +} + +.icon.receipt { + background-position: -192px -352px; +} + +.icon.calculator1 { + background-position: -256px -352px; +} + +.icon.book { + background-position: -320px -352px; +} + +.icon.upload { + background-position: -384px -352px; +} + +.icon.black_paper { + background-position: -448px -352px; +} + +.icon.printer1 { + background-position: -512px -352px; +} + +.icon.credit_card { + background-position: -576px -352px; +} + +.icon.right_arrow_box { + background-position: -640px -352px; +} + +.icon.hand_box { + background-position: -704px -352px; +} + +.icon.id { + background-position: -768px -352px; +} + +.icon.arrow_up_box { + background-position: -832px -352px; +} + +.icon.arrow_down_box { + background-position: -896px -352px; +} + +.icon.notepad { + background-position: -960px -352px; +} + +.icon.camera1 { + background-position: -32px -384px; +} + +.icon.camera2 { + background-position: -96px -384px; +} + +.icon.ipod { + background-position: -160px -384px; +} + +.icon.ipad { + background-position: -224px -384px; +} + +.icon.laptop { + background-position: -288px -384px; +} + +.icon.monitor1 { + background-position: -352px -384px; +} + +.icon.monitor2 { + background-position: -416px -384px; +} + +.icon.monitor3 { + background-position: -480px -384px; +} + +.icon.television { + background-position: -544px -384px; +} + +.icon.keyboard { + background-position: -608px -384px; +} + +.icon.calculator2 { + background-position: -672px -384px; +} + +.icon.robot { + background-position: -736px -384px; +} + +.icon.usb_drive { + background-position: -800px -384px; +} + +.icon.printer2 { + background-position: -864px -384px; +} + +.icon.floppy { + background-position: -928px -384px; +} + +.icon.graph1_box { + /*background-position: 0px -416px;*/ + background-position: -3px -420px; +} + +.icon.barcode { + background-position: -64px -416px; +} + +.icon.outline1 { + background-position: -128px -416px; +} + +.icon.outline2 { + background-position: -192px -416px; +} + +.icon.graph2 { + background-position: -256px -416px; +} + +.icon.graph3 { + background-position: -320px -416px; +} + +.icon.circle_graph { + background-position: -384px -416px; +} + +.icon.display1 { + background-position: -448px -416px; +} + +.icon.outline3 { + background-position: -512px -416px; +} + +.icon.connector1 { + background-position: -576px -416px; +} + +.icon.graph4_box { + background-position: -640px -416px; +} + +.icon.graph5_box { + background-position: -704px -416px; +} + +.icon.circle_stack { + background-position: -768px -416px; +} + +.icon.square_stack { + background-position: -832px -416px; +} + +.icon.rolodex { + background-position: -896px -416px; +} + +.icon.heart { + background-position: -32px -448px; +} + +.icon.eye { + background-position: -96px -448px; +} + +.icon.target1 { + background-position: -160px -448px; +} + +.icon.bold_target { + background-position: -224px -448px; +} + +.icon.star { + background-position: -288px -448px; +} + +.icon.line_circle { + background-position: -352px -448px; +} + +.icon.star_burst1 { + background-position: -416px -448px; +} + +.icon.puzzle1 { + background-position: -480px -448px; +} + +.icon.puzzle2 { + background-position: -544px -448px; +} + +.icon.puzzle3 { + background-position: -608px -448px; +} + +.icon.puzzle4 { + background-position: -672px -448px; +} + +.icon.black_cloud { + background-position: -736px -448px; +} + +.icon.outline_cloud { + background-position: -800px -448px; +} + +.icon.asterisk1 { + background-position: -864px -448px; +} + +.icon.asterisk2 { + background-position: -928px -448px; +} + +.icon.starburst2 { + background-position: -992px -448px; +} + diff --git a/src/apps/callflows/style/static/images/arrow_active.png b/src/apps/callflows/style/static/images/arrow_active.png new file mode 100644 index 0000000..eb1ae9f Binary files /dev/null and b/src/apps/callflows/style/static/images/arrow_active.png differ diff --git a/src/apps/callflows/style/static/images/arrow_category.png b/src/apps/callflows/style/static/images/arrow_category.png new file mode 100644 index 0000000..6d8ab41 Binary files /dev/null and b/src/apps/callflows/style/static/images/arrow_category.png differ diff --git a/src/apps/callflows/style/static/images/arrow_inactive.png b/src/apps/callflows/style/static/images/arrow_inactive.png new file mode 100644 index 0000000..72fe5e9 Binary files /dev/null and b/src/apps/callflows/style/static/images/arrow_inactive.png differ diff --git a/src/apps/callflows/style/static/images/background_category.png b/src/apps/callflows/style/static/images/background_category.png new file mode 100644 index 0000000..4433728 Binary files /dev/null and b/src/apps/callflows/style/static/images/background_category.png differ diff --git a/src/apps/callflows/style/static/images/black_bar.png b/src/apps/callflows/style/static/images/black_bar.png new file mode 100644 index 0000000..46999ad Binary files /dev/null and b/src/apps/callflows/style/static/images/black_bar.png differ diff --git a/src/apps/callflows/style/static/images/black_box.png b/src/apps/callflows/style/static/images/black_box.png new file mode 100644 index 0000000..07b5868 Binary files /dev/null and b/src/apps/callflows/style/static/images/black_box.png differ diff --git a/src/apps/callflows/style/static/images/blackbox.png b/src/apps/callflows/style/static/images/blackbox.png new file mode 100644 index 0000000..116561d Binary files /dev/null and b/src/apps/callflows/style/static/images/blackbox.png differ diff --git a/src/apps/callflows/style/static/images/blackbox_small.png b/src/apps/callflows/style/static/images/blackbox_small.png new file mode 100644 index 0000000..ba5202c Binary files /dev/null and b/src/apps/callflows/style/static/images/blackbox_small.png differ diff --git a/src/apps/callflows/style/static/images/blue_bar.png b/src/apps/callflows/style/static/images/blue_bar.png new file mode 100644 index 0000000..c85ac07 Binary files /dev/null and b/src/apps/callflows/style/static/images/blue_bar.png differ diff --git a/src/apps/callflows/style/static/images/btn_delete.png b/src/apps/callflows/style/static/images/btn_delete.png new file mode 100644 index 0000000..8274bb2 Binary files /dev/null and b/src/apps/callflows/style/static/images/btn_delete.png differ diff --git a/src/apps/callflows/style/static/images/btn_delete_blue.png b/src/apps/callflows/style/static/images/btn_delete_blue.png new file mode 100644 index 0000000..176cd3b Binary files /dev/null and b/src/apps/callflows/style/static/images/btn_delete_blue.png differ diff --git a/src/apps/callflows/style/static/images/callflow_help.gif b/src/apps/callflows/style/static/images/callflow_help.gif new file mode 100644 index 0000000..73747f7 Binary files /dev/null and b/src/apps/callflows/style/static/images/callflow_help.gif differ diff --git a/src/apps/callflows/style/static/images/center_arrow.png b/src/apps/callflows/style/static/images/center_arrow.png new file mode 100644 index 0000000..234f923 Binary files /dev/null and b/src/apps/callflows/style/static/images/center_arrow.png differ diff --git a/src/apps/callflows/style/static/images/drag_btn.png b/src/apps/callflows/style/static/images/drag_btn.png new file mode 100644 index 0000000..deed2e7 Binary files /dev/null and b/src/apps/callflows/style/static/images/drag_btn.png differ diff --git a/src/apps/callflows/style/static/images/drag_btn_28.png b/src/apps/callflows/style/static/images/drag_btn_28.png new file mode 100644 index 0000000..a3370f2 Binary files /dev/null and b/src/apps/callflows/style/static/images/drag_btn_28.png differ diff --git a/src/apps/callflows/style/static/images/edit_icon.png b/src/apps/callflows/style/static/images/edit_icon.png new file mode 100644 index 0000000..37c0579 Binary files /dev/null and b/src/apps/callflows/style/static/images/edit_icon.png differ diff --git a/src/apps/callflows/style/static/images/empty_ring_group.png b/src/apps/callflows/style/static/images/empty_ring_group.png new file mode 100644 index 0000000..c530851 Binary files /dev/null and b/src/apps/callflows/style/static/images/empty_ring_group.png differ diff --git a/src/apps/callflows/style/static/images/gray_phone.png b/src/apps/callflows/style/static/images/gray_phone.png new file mode 100644 index 0000000..3447d75 Binary files /dev/null and b/src/apps/callflows/style/static/images/gray_phone.png differ diff --git a/src/apps/callflows/style/static/images/green_phone.png b/src/apps/callflows/style/static/images/green_phone.png new file mode 100644 index 0000000..27c0ab5 Binary files /dev/null and b/src/apps/callflows/style/static/images/green_phone.png differ diff --git a/src/apps/callflows/style/static/images/icons/icons_24x24_blue.png b/src/apps/callflows/style/static/images/icons/icons_24x24_blue.png new file mode 100644 index 0000000..556254f Binary files /dev/null and b/src/apps/callflows/style/static/images/icons/icons_24x24_blue.png differ diff --git a/src/apps/callflows/style/static/images/icons/icons_24x24_gradient.png b/src/apps/callflows/style/static/images/icons/icons_24x24_gradient.png new file mode 100644 index 0000000..63cc2da Binary files /dev/null and b/src/apps/callflows/style/static/images/icons/icons_24x24_gradient.png differ diff --git a/src/apps/callflows/style/static/images/icons/icons_24x24_red.png b/src/apps/callflows/style/static/images/icons/icons_24x24_red.png new file mode 100644 index 0000000..1661d23 Binary files /dev/null and b/src/apps/callflows/style/static/images/icons/icons_24x24_red.png differ diff --git a/src/apps/callflows/style/static/images/icons/icons_32x32_blue.png b/src/apps/callflows/style/static/images/icons/icons_32x32_blue.png new file mode 100644 index 0000000..e29f9fd Binary files /dev/null and b/src/apps/callflows/style/static/images/icons/icons_32x32_blue.png differ diff --git a/src/apps/callflows/style/static/images/icons/icons_32x32_darkgrey.png b/src/apps/callflows/style/static/images/icons/icons_32x32_darkgrey.png new file mode 100644 index 0000000..8ad5ed7 Binary files /dev/null and b/src/apps/callflows/style/static/images/icons/icons_32x32_darkgrey.png differ diff --git a/src/apps/callflows/style/static/images/icons/icons_32x32_gradient.png b/src/apps/callflows/style/static/images/icons/icons_32x32_gradient.png new file mode 100644 index 0000000..f486a72 Binary files /dev/null and b/src/apps/callflows/style/static/images/icons/icons_32x32_gradient.png differ diff --git a/src/apps/callflows/style/static/images/icons/icons_32x32_green.png b/src/apps/callflows/style/static/images/icons/icons_32x32_green.png new file mode 100644 index 0000000..d6590de Binary files /dev/null and b/src/apps/callflows/style/static/images/icons/icons_32x32_green.png differ diff --git a/src/apps/callflows/style/static/images/icons/icons_32x32_lightgrey.png b/src/apps/callflows/style/static/images/icons/icons_32x32_lightgrey.png new file mode 100644 index 0000000..fe313aa Binary files /dev/null and b/src/apps/callflows/style/static/images/icons/icons_32x32_lightgrey.png differ diff --git a/src/apps/callflows/style/static/images/icons/icons_32x32_red.png b/src/apps/callflows/style/static/images/icons/icons_32x32_red.png new file mode 100644 index 0000000..555880f Binary files /dev/null and b/src/apps/callflows/style/static/images/icons/icons_32x32_red.png differ diff --git a/src/apps/callflows/style/static/images/icons/icons_32x32_white.png b/src/apps/callflows/style/static/images/icons/icons_32x32_white.png new file mode 100644 index 0000000..4014903 Binary files /dev/null and b/src/apps/callflows/style/static/images/icons/icons_32x32_white.png differ diff --git a/src/apps/callflows/style/static/images/icons/icons_32x32_yellow.png b/src/apps/callflows/style/static/images/icons/icons_32x32_yellow.png new file mode 100644 index 0000000..8eb4c3d Binary files /dev/null and b/src/apps/callflows/style/static/images/icons/icons_32x32_yellow.png differ diff --git a/src/apps/callflows/style/static/images/left_arrow.png b/src/apps/callflows/style/static/images/left_arrow.png new file mode 100644 index 0000000..8eab587 Binary files /dev/null and b/src/apps/callflows/style/static/images/left_arrow.png differ diff --git a/src/apps/callflows/style/static/images/line_callflow.png b/src/apps/callflows/style/static/images/line_callflow.png new file mode 100644 index 0000000..0fdaf2e Binary files /dev/null and b/src/apps/callflows/style/static/images/line_callflow.png differ diff --git a/src/apps/callflows/style/static/images/nav_line.jpg b/src/apps/callflows/style/static/images/nav_line.jpg new file mode 100644 index 0000000..7278b78 Binary files /dev/null and b/src/apps/callflows/style/static/images/nav_line.jpg differ diff --git a/src/apps/callflows/style/static/images/nav_line_horizontal.jpg b/src/apps/callflows/style/static/images/nav_line_horizontal.jpg new file mode 100644 index 0000000..ef3c0f0 Binary files /dev/null and b/src/apps/callflows/style/static/images/nav_line_horizontal.jpg differ diff --git a/src/apps/callflows/style/static/images/red_phone.png b/src/apps/callflows/style/static/images/red_phone.png new file mode 100644 index 0000000..96d1dfd Binary files /dev/null and b/src/apps/callflows/style/static/images/red_phone.png differ diff --git a/src/apps/callflows/style/static/images/regular_btn.png b/src/apps/callflows/style/static/images/regular_btn.png new file mode 100644 index 0000000..bb84b14 Binary files /dev/null and b/src/apps/callflows/style/static/images/regular_btn.png differ diff --git a/src/apps/callflows/style/static/images/right_arrow.png b/src/apps/callflows/style/static/images/right_arrow.png new file mode 100644 index 0000000..5c8b674 Binary files /dev/null and b/src/apps/callflows/style/static/images/right_arrow.png differ diff --git a/src/apps/callflows/style/static/images/search_left.png b/src/apps/callflows/style/static/images/search_left.png new file mode 100644 index 0000000..5757c09 Binary files /dev/null and b/src/apps/callflows/style/static/images/search_left.png differ diff --git a/src/apps/callflows/style/static/images/search_mid.png b/src/apps/callflows/style/static/images/search_mid.png new file mode 100644 index 0000000..6c33533 Binary files /dev/null and b/src/apps/callflows/style/static/images/search_mid.png differ diff --git a/src/apps/callflows/style/static/images/search_right.png b/src/apps/callflows/style/static/images/search_right.png new file mode 100644 index 0000000..4a45cf8 Binary files /dev/null and b/src/apps/callflows/style/static/images/search_right.png differ diff --git a/src/apps/callflows/style/static/images/small_arrow.png b/src/apps/callflows/style/static/images/small_arrow.png new file mode 100644 index 0000000..6d16e80 Binary files /dev/null and b/src/apps/callflows/style/static/images/small_arrow.png differ diff --git a/src/apps/callflows/style/static/images/tall_arrow.png b/src/apps/callflows/style/static/images/tall_arrow.png new file mode 100644 index 0000000..1e8b3bd Binary files /dev/null and b/src/apps/callflows/style/static/images/tall_arrow.png differ diff --git a/src/apps/callflows/submodules/blacklist/blacklist.css b/src/apps/callflows/submodules/blacklist/blacklist.css new file mode 100644 index 0000000..943951a --- /dev/null +++ b/src/apps/callflows/submodules/blacklist/blacklist.css @@ -0,0 +1,79 @@ +#blacklist_wrapper .list-numbers { + display: block; + margin-left: 100px; + width: 470px; +} + +#blacklist_wrapper .list-numbers .delete-number { + margin-bottom: 8px; +} + +#blacklist_wrapper .list-numbers .add-number { + margin-bottom: 10px; + border-radius: 4px; +} + +#blacklist_wrapper .list-numbers .add-number input { + margin: 0 20px 0 0; +} + +#blacklist_wrapper .list-numbers .add-number #cancel_number { + margin-left: 20px; +} + +#blacklist_wrapper .list-numbers .saved-numbers { + max-height: 300px; + overflow: auto; +} + +#blacklist_wrapper .number-wrapper { + background: #444; + border-top: 1px solid #22ccff; + border-right: 1px solid #22ccff; + border-left: 1px solid #22ccff; + line-height: 30px; +} + +#blacklist_wrapper .number-wrapper.placeholder > div, +#blacklist_wrapper .number-wrapper:not(.placeholder) { + padding: 5px 10px; +} + +#blacklist_wrapper .number-wrapper.placeholder .create-text:hover { + background: #222; + cursor: pointer; +} + +#blacklist_wrapper .saved-numbers .number-wrapper:first-child { + border-top-right-radius: 4px; + border-top-left-radius: 4px; +} + +#blacklist_wrapper .saved-numbers .number-wrapper:last-child { + border-bottom-right-radius: 4px; + border-bottom-left-radius: 4px; + + border-bottom: 1px solid #22ccff; +} + +#blacklist_wrapper .number-wrapper.placeholder { + background: none; + border: 1px dashed #999; +} + +#blacklist_wrapper .number-wrapper.placeholder .create-inputs, +#blacklist_wrapper .number-wrapper.placeholder.active .create-text { + display: none; +} + +#blacklist_wrapper .number-wrapper.placeholder.active .create-inputs, +#blacklist_wrapper .number-wrapper.placeholder .create-text { + display: inherit; +} + +#blacklist_wrapper .help-text-icon { + color: white; + margin-right: 10px; + margin-left: 100px; + margin-top :15px; +} \ No newline at end of file diff --git a/src/apps/callflows/submodules/blacklist/blacklist.js b/src/apps/callflows/submodules/blacklist/blacklist.js new file mode 100644 index 0000000..661551f --- /dev/null +++ b/src/apps/callflows/submodules/blacklist/blacklist.js @@ -0,0 +1,310 @@ +define(function(require){ + var $ = require('jquery'), + _ = require('underscore'), + monster = require('monster'); + + var app = { + requests: {}, + + subscribe: { + 'callflows.blacklist.edit': 'blacklistEdit', + 'callflows.fetchActions': 'blacklistDefineActions', + }, + + blacklistDefineActions: function(args) { + var self = this, + callflow_nodes = args.actions; + + $.extend(callflow_nodes, { + 'blacklist': { + name: self.i18n.active().callflows.blacklist.title, + module: 'blacklist', + listEntities: function(callback) { + self.callApi({ + resource: 'blacklist.list', + data: { + accountId: self.accountId, + filters: { paginate:false } + }, + success: function(data, status) { + callback && callback(data.data); + } + }); + }, + editEntity: 'callflows.blacklist.edit' + } + }); + }, + + // Added for the subscribed event to avoid refactoring conferenceEdit + blacklistEdit: function(args) { + var self = this, + afterGetData = function(data) { + var template = $(monster.template(self, 'blacklist-edit', {data: data})), + blacklistForm = template.find('#blacklist-form'), + $listNumbers = template.find('.saved-numbers'); + + monster.ui.validate(blacklistForm, { + rules: { + 'name': { required: true }, + } + }); + + _.each(data.numbers, function(v, number) { + $listNumbers.append(monster.template(self, 'blacklist-addNumber', {number: number})); + }); + + self.blacklistBindEvents(data, template, args.callbacks); + + (args.target) + .empty() + .append(template); + }; + + if(args.data.id) { + self.blacklistGet(args.data.id, function(data) { + afterGetData(data); + }); + } + else { + afterGetData({}); + } + }, + +/* blacklistBindEvents: function(data, template, callbacks) { + var self = this, + addNumber = function(e) { + var number = template.find('#number_value').val(); + + if (number) { + $('.list-numbers .saved-numbers', template).prepend(monster.template(self, 'blacklist-addNumber', { number: number })); + + $('#number_value', template).val(''); + } + }; + + $('.number-wrapper.placeholder:not(.active)', template).on('click', function() { + var $this = $(this); + + $this.addClass('active'); + + $('#number_value', template).focus(); + }); + + $('#add_number', template).on('click', function(e) { + e.preventDefault(); + addNumber(e); + }); + + $('.add-number', template).bind('keypress', function(e) { + var code = e.keyCode || e.which; + + if (code === 13) { + addNumber(e); + } + }); + + $(template).delegate('.delete-number', 'click', function(e) { + $(this).parents('.number-wrapper').remove(); + }); + + $('#cancel_number', template).on('click', function(e) { + e.stopPropagation(); + + $('.number-wrapper.placeholder.active', template).removeClass('active'); + $('#number_value', template).val(''); + }); + + $('.blacklist-save', template).on('click', function() { + var formData = form2object('blacklist-form'), + cleanData = self.blacklistCleanFormData(formData), + mapNumbers = {}; + + $('.saved-numbers .number-wrapper', template).each(function(k, wrapper) { + var number = $(wrapper).attr('data-number'); + mapNumbers[number] = {}; + }); + + cleanData.numbers = mapNumbers; + + if (data.id) { + cleanData.id = data.id; + } + + self.blacklistSave(cleanData, callbacks.save_success); + }); + + $('.blacklist-delete', template).on('click', function() { + monster.ui.confirm(self.i18n.active().callflows.blacklist.are_you_sure_you_want_to_delete, function() { + self.blacklistDelete(data.id, callbacks.delete_success); + }); + }); + },*/ + + + blacklistBindEvents: function(data, template, callbacks) { + var self = this, + addNumber = function(e) { + var number = template.find('#number_value').val(); + + if(number) { + $('.list-numbers .saved-numbers', template).prepend(monster.template(self,'blacklist-addNumber', { number: number })); + + $('#number_value', template).val(''); + } + }; + + $('.number-wrapper.placeholder:not(.active)', template).click(function() { + var $this = $(this); + + $this.addClass('active'); + + $('#number_value', template).focus(); + }); + + $('#add_number', template).click(function(e) { + e.preventDefault(); + addNumber(); + }); + + $('.add-number', template).bind('keypress', function(e) { + var code = e.keyCode || e.which; + + if(code === 13) {; + addNumber(e); + } + }); + + $(template).delegate('.delete-number', 'click', function(e) { + $(this).parents('.number-wrapper').remove(); + }); + + $('#cancel_number', template).click(function(e) { + e.stopPropagation(); + + $('.number-wrapper.placeholder.active', template).removeClass('active'); + $('#number_value', template).val(''); + }); + + $('.blacklist-save', template).click(function() { + var formData = form2object('blacklist-form'), + cleanData = self.blacklistCleanFormData(formData), + mapNumbers = {}; + + $('.saved-numbers .number-wrapper', template).each(function(k, wrapper) { + var number = $(wrapper).attr('data-number'); + mapNumbers[number] = {}; + }); + + cleanData.numbers = mapNumbers; + + if(data.id) { + cleanData.id = data.id; + } + + self.blacklistSave(cleanData, callbacks.save_success); + }); + + $('.blacklist-delete', template).click(function() { + monster.ui.confirm(self.i18n.active().callflows.blacklist.are_you_sure_you_want_to_delete, function() { + self.blacklistDelete(data.id, callbacks.delete_success); + }); + }); + }, + + blacklistCleanFormData: function(data) { + delete data.extra; + + return data; + }, + + blacklistSave: function(data, callback) { + var self = this; + + if(data.id) { + self.blacklistUpdate(data, callback); + } + else { + self.blacklistCreate(data, callback); + } + }, + + blacklistList: function(callback) { + var self = this; + + self.callApi({ + resource: 'blacklist.list', + data: { + accountId: self.accountId, + filters: { paginate:false } + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + blacklistGet: function(id, callback) { + var self = this; + + self.callApi({ + resource: 'blacklist.get', + data: { + accountId: self.accountId, + blacklistId: id + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + blacklistCreate: function(data, callback) { + var self = this; + + self.callApi({ + resource: 'blacklist.create', + data: { + accountId: self.accountId, + data: data + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + blacklistUpdate: function(data, callback) { + var self = this; + + self.callApi({ + resource: 'blacklist.update', + data: { + accountId: self.accountId, + blacklistId: data.id, + data: data + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + blacklistDelete: function(id, callback) { + var self = this; + + self.callApi({ + resource: 'blacklist.delete', + data: { + accountId: self.accountId, + blacklistId: id + }, + success: function(data) { + callback && callback(data.data); + } + }); + } + }; + + return app; +}); diff --git a/src/apps/callflows/submodules/conference/conference.js b/src/apps/callflows/submodules/conference/conference.js new file mode 100644 index 0000000..0c7ddbb --- /dev/null +++ b/src/apps/callflows/submodules/conference/conference.js @@ -0,0 +1,654 @@ +define(function(require){ + var $ = require('jquery'), + _ = require('underscore'), + monster = require('monster'); + + var app = { + requests: {}, + + subscribe: { + 'callflows.conference.popupEdit': 'conferencePopupEdit', + 'callflows.fetchActions': 'conferenceDefineActions', + 'callflows.conference.edit': '_conferenceEdit' + }, + + conferenceDefineActions: function(args) { + var self = this, + callflow_nodes = args.actions; + + $.extend(callflow_nodes, { + 'conference[id=*]': { + name: self.i18n.active().callflows.conference.conference, + icon: 'conference', + category: self.i18n.active().oldCallflows.basic_cat, + module: 'conference', + tip: self.i18n.active().callflows.conference.conference_tip, + data: { + id: 'null' + }, + rules: [ + { + type: 'quantity', + maxSize: '1' + } + ], + isUsable: 'true', + weight: 30, + caption: function(node, caption_map) { + var id = node.getMetadata('id'), + returned_value = ''; + + if(id in caption_map) { + returned_value = caption_map[id].name; + } + + return returned_value; + }, + edit: function(node, callback) { + self.conferenceList(function(data, status) { + var popup_html = $(monster.template(self, 'conference-callflowEdit', { + items: _.sortBy(data, 'name'), + selected: node.getMetadata('id') || '' + })), + popup; + + if($('#conference_selector option:selected', popup_html).val() == undefined) { + $('#edit_link', popup_html).hide(); + } + + $('.inline_action', popup_html).click(function(ev) { + var _data = ($(this).data('action') == 'edit') ? { id: $('#conference_selector', popup_html).val() } : {}; + + ev.preventDefault(); + + self.conferencePopupEdit(_data, function(_data) { + node.setMetadata('id', _data.id || 'null'); + + node.caption = _data.name || ''; + + popup.dialog('close'); + }); + }); + + $('#add', popup_html).click(function() { + node.setMetadata('id', $('#conference_selector', popup_html).val()); + + node.caption = $('#conference_selector option:selected', popup_html).text(); + + popup.dialog('close'); + }); + + popup = monster.ui.dialog(popup_html, { + title: self.i18n.active().callflows.conference.conference, + minHeight: '0', + beforeClose: function() { + if(typeof callback == 'function') { + callback(); + } + } + }); + }); + }, + listEntities: function(callback) { + self.callApi({ + resource: 'conference.list', + data: { + accountId: self.accountId, + filters: { paginate:false } + }, + success: function(data, status) { + callback && callback(data.data); + } + }); + }, + editEntity: 'callflows.conference.edit' + }, + + 'conference[]': { + name: self.i18n.active().callflows.conference.conference_service, + icon: 'conference', + category: self.i18n.active().oldCallflows.advanced_cat, + module: 'conference', + tip: self.i18n.active().callflows.conference.conference_service_tip, + data: {}, + rules: [ + { + type: 'quantity', + maxSize: '1' + } + ], + isUsable: 'true', + weight: 110, + caption: function(node) { + return ''; + }, + edit: function(node, callback) { + if(typeof callback == 'function') { + callback(); + } + } + } + }); + }, + + conferencePopupEdit: function(data, callback, data_defaults) { + var self = this, + popup_html = $('
    '), + popup; + + self.conferenceEdit(data, popup_html, $('.inline_content', popup_html), { + save_success: function(_data) { + popup.dialog('close'); + + if(typeof callback == 'function') { + callback(_data); + } + }, + delete_success: function() { + popup.dialog('close'); + + if(typeof callback == 'function') { + callback({ data: {} }); + } + }, + after_render: function() { + popup = monster.ui.dialog(popup_html, { + title: (data.id) ? self.i18n.active().callflows.conference.edit_conference : self.i18n.active().callflows.conference.create_conference + }); + } + }, data_defaults); + }, + + // Added for the subscribed event to avoid refactoring conferenceEdit + _conferenceEdit: function(args) { + var self = this; + self.conferenceEdit(args.data, args.parent, args.target, args.callbacks, args.data_defaults); + }, + + conferenceEdit: function(data, _parent, _target, _callbacks, data_defaults) { + var self = this, + parent = _parent || $('#conference-content'), + target = _target || $('#conference-view', parent), + _callbacks = _callbacks || {}, + callbacks = { + save_success: _callbacks.save_success || function(_data) { + self.conferenceRenderList(parent); + + self.conferenceEdit({ id: _data.id }, parent, target, callbacks); + }, + + save_error: _callbacks.save_error, + + delete_success: _callbacks.delete_success || function() { + target.empty(), + + self.conferenceRenderList(parent); + }, + + delete_error: _callbacks.delete_error, + + after_render: _callbacks.after_render + }, + defaults = { + data: $.extend(true, { + member: {}, + play_entry_tone: true, + play_exit_tone: true + }, data_defaults || {}), + field_data: { + users: [] + } + }; + + monster.parallel({ + user_list: function(callback) { + self.callApi({ + resource: 'user.list', + data: { + accountId: self.accountId, + filters: { paginate:false } + }, + success: function(_data, status) { + _data.data.unshift({ + id: '', + first_name: '- No', + last_name: 'owner -' + }); + + defaults.field_data.users = _data.data; + + callback(null, _data); + } + }); + }, + get_conference: function(callback) { + if(typeof data == 'object' && data.id) { + self.conferenceGet(data.id, function(_data, status) { + self.conferenceMigrateData(_data); + + self.conferenceFormatData(_data); + + callback(null, _data); + }); + } + else { + callback(null, {}); + } + } + }, + function(err, results) { + var render_data = defaults; + + if(typeof data === 'object' && data.id) { + render_data = $.extend(true, defaults, { data: results.get_conference }); + } + + self.conferenceRender(render_data, target, callbacks); + + if(typeof callbacks.after_render == 'function') { + callbacks.after_render(); + } + } + ); + }, + + conferenceRender: function(data, target, callbacks){ + var self = this, + conference_html = $(monster.template(self, 'conference-edit', data)), + conference_form = conference_html.find('#conference_form'); + + monster.ui.validate(conference_form, { + rules: { + name: { + required: true, + }, + 'member.pins_string': { + regex: /^[a-z0-9A-Z,\s]*$/ + }, + 'conference_numbers_string': { + regex: /^[0-9,\s]*$/ + } + }, + messages: { + 'member.pins_string': { regex: self.i18n.active().callflows.conference.validation.member_pins_string }, + 'conference_numbers_string': { regex: self.i18n.active().callflows.conference.validation.member_numbers_string } + } + }); + + $('*[rel=popover]:not([type="text"])', conference_html).popover({ + trigger: 'hover' + }); + + $('*[rel=popover][type="text"]', conference_html).popover({ + trigger: 'focus' + }); + + self.winkstartTabs(conference_html); + + if(!$('#owner_id', conference_html).val()) { + $('#edit_link', conference_html).hide(); + } + + $('#owner_id', conference_html).change(function() { + !$('#owner_id option:selected', conference_html).val() ? $('#edit_link', conference_html).hide() : $('#edit_link', conference_html).show(); + }); + + $('.inline_action', conference_html).click(function(ev) { + var _data = ($(this).data('action') == 'edit') ? { id: $('#owner_id', conference_html).val() } : {}, + _id = _data.id; + + ev.preventDefault(); + + monster.pub('callflows.user.popupEdit', { + data: _data, + callback: function(_data) { + /* Create */ + if(!_id) { + $('#owner_id', conference_html).append(''); + $('#owner_id', conference_html).val(_data.id); + $('#edit_link', conference_html).show(); + } + else { + /* Update */ + if('id' in _data) { + $('#owner_id #'+_data.id, conference_html).text(_data.first_name + ' ' + _data.last_name); + } + /* Delete */ + else { + $('#owner_id #'+_id, conference_html).remove(); + $('#edit_link', conference_html).hide(); + } + } + } + }); + }); + + $('.conference-save', conference_html).click(function(ev) { + ev.preventDefault(); + var $this = $(this); + + if(!$this.hasClass('disabled')) { + $this.addClass('disabled'); + if (monster.ui.valid(conference_form)) { + var form_data = monster.ui.getFormData('conference_form'); + + self.conferenceCleanFormData(form_data); + + data.data.member.pins = form_data.member.pins; + + if('field_data' in data) { + delete data.field_data; + } + + self.conferenceSave(form_data, data, callbacks.save_success, function(data) { + $this.removeClass('disabled'); + callbacks && callbacks.hasOwnProperty('save_error') && callbacks.save_error(data); + }); + } + else { + $this.removeClass('disabled'); + monster.ui.alert(self.i18n.active().callflows.conference.there_were_errors_on_the_form); + }; + } + }); + + $('.conference-delete', conference_html).click(function(ev) { + ev.preventDefault(); + + monster.ui.confirm(self.i18n.active().callflows.conference.are_you_sure_you_want_to_delete, function() { + self.conferenceDelete(data.data.id, callbacks.delete_success, callbacks.delete_error); + }); + }); + + (target) + .empty() + .append(conference_html); + }, + + conferenceRenderList: function(parent) { + var self = this; + + self.conferenceList(function(data, status) { + var map_crossbar_data = function(data) { + var new_list = []; + + if(data.length > 0) { + $.each(data, function(key, val) { + new_list.push({ + id: val.id, + title: val.name || self.i18n.active().callflows.conference.name + }); + }); + } + + new_list.sort(function(a, b) { + return a.title.toLowerCase() < b.title.toLowerCase() ? -1 : 1; + }); + + return new_list; + }; + + // $('#conference-listpanel', parent) + // .empty() + // .listpanel({ + // label: self.i18n.active().callflows.conference.conferences_label, + // identifier: 'conference-listview', + // new_entity_label: self.i18n.active().callflows.conference.add_conference_label, + // data: map_crossbar_data(data), + // publisher: monster.pub, + // notifyMethod: 'callflows.conference.edit', + // notifyCreateMethod: 'callflows.conference.edit', + // notifyParent: parent + // }); + }); + }, + + conferenceMigrateData: function(data) { + if(data.member_play_name) { + if(data.play_name_on_join == undefined) { + data.play_name_on_join = data.member_play_name; + } + + delete data.member_play_name; + } + + if(data.member_join_muted) { + if(data.member.join_muted == undefined) { + data.member.join_muted = data.member_join_muted; + } + + delete data.member_join_muted; + } + + if(data.member_join_deaf) { + if(data.member.join_deaf == undefined) { + data.member.join_deaf = data.member_join_deaf; + } + + delete data.member_join_deaf; + } + + return data; + }, + + conferenceFormatData: function(data) { + if(typeof data.member == 'object') { + if($.isArray(data.member.pins)) { + data.member.pins_string = data.member.pins.join(', '); + } + + if($.isArray(data.conference_numbers)) { + data.conference_numbers_string = data.conference_numbers.join(', '); + } + } + + return data; + }, + + conferenceCleanFormData: function(form_data){ + var self = this; + form_data.member.pins_string = self.conferenceLettersToNumbers(form_data.member.pins_string); + + form_data.member.pins = $.map(form_data.member.pins_string.split(','), function(val) { + var pin = $.trim(val); + + if(pin != '') { + return pin; + } + else { + return null; + } + }); + + form_data.conference_numbers = $.map(form_data.conference_numbers_string.split(','), function(val) { + var number = $.trim(val); + + if(number != '') { + return number; + } + else { + return null; + } + }); + + return form_data; + }, + + conferenceLettersToNumbers: function(string) { + var result = ''; + + $.each(string.split(''), function(index, value) { + if(value.match(/^[aAbBcC]$/)) { + result += '2'; + } + else if(value.match(/^[dDeEfF]$/)) { + result += '3'; + } + else if(value.match(/^[gGhHiI]$/)) { + result += '4'; + } + else if(value.match(/^[jJkKlL]$/)) { + result += '5'; + } + else if(value.match(/^[mMnNoO]$/)) { + result += '6'; + } + else if(value.match(/^[pPqQrRsS]$/)) { + result += '7'; + } + else if(value.match(/^[tTuUvV]$/)) { + result += '8'; + } + else if(value.match(/^[wWxXyYzZ]$/)) { + result += '9'; + } + else { + result += value; + } + }); + + return result; + }, + + conferenceSave: function(form_data, data, success, error) { + var self = this, + normalized_data = self.conferenceFixArrays(self.conferenceNormalizeData($.extend(true, {}, data.data, form_data)), form_data); + + if(typeof data.data == 'object' && data.data.id) { + self.conferenceUpdate(normalized_data, function(_data, status) { + if(typeof success == 'function') { + success(_data, status, 'update'); + } + }, + function(_data, status) { + if(typeof error == 'function') { + error(_data, status, 'update'); + } + } + ); + } + else { + self.conferenceCreate(normalized_data, function(_data, status) { + if(typeof success == 'function') { + success(_data, status, 'create'); + } + }, + function(_data, status) { + if(typeof error == 'function') { + error(_data, status, 'create'); + } + } + ); + } + }, + + /* Since the extend function doesn't override arrays, we need to do that */ + conferenceFixArrays: function(merged_data, form_data) { + var self = this; + + if('conference_numbers' in form_data) { + merged_data.conference_numbers = form_data.conference_numbers; + } + + return merged_data; + }, + + conferenceNormalizeData: function(data) { + if(!data.member.pins.length) { + delete data.member.pins; + } + + if(data.hasOwnProperty('member') && data.member.hasOwnProperty('numbers') && !data.member.numbers.length) { + delete data.member.numbers; + } + + if(!data.owner_id) { + delete data.owner_id; + } + + delete data.member.pins_string; + delete data.conference_numbers_string; + + return data; + }, + + + conferenceList: function(callback) { + var self = this; + + self.callApi({ + resource: 'conference.list', + data: { + accountId: self.accountId, + filters: { paginate:false } + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + conferenceGet: function(conferenceId, callback) { + var self = this; + + self.callApi({ + resource: 'conference.get', + data: { + accountId: self.accountId, + conferenceId: conferenceId + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + conferenceCreate: function(data, callback) { + var self = this; + + self.callApi({ + resource: 'conference.create', + data: { + accountId: self.accountId, + data: data + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + conferenceUpdate: function(data, callback) { + var self = this; + + self.callApi({ + resource: 'conference.update', + data: { + accountId: self.accountId, + conferenceId: data.id, + data: data + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + conferenceDelete: function(conferenceId, callback) { + var self = this; + + self.callApi({ + resource: 'conference.delete', + data: { + accountId: self.accountId, + conferenceId: conferenceId + }, + success: function(data) { + callback && callback(data.data); + } + }); + } + }; + + return app; +}); diff --git a/src/apps/callflows/submodules/device/device.css b/src/apps/callflows/submodules/device/device.css new file mode 100644 index 0000000..5d6602c --- /dev/null +++ b/src/apps/callflows/submodules/device/device.css @@ -0,0 +1,98 @@ +/************************** +----TOP TABS MEDIA--------- +****************************/ +.callflows-port .media_tabs { + background-color: #555555; + border: 1px solid #363636; + min-height: 90px; + padding: 10px; + position:relative; + overflow-x: auto; + white-space: nowrap; +} + +.callflows-port .media_tabs .buttons { + width: 128px; + height: 90px; + + line-height: 90px; + display: inline-block; + position: relative; + margin: 0 10px 0 0; + + text-align: center; + + -moz-border-radius: 12px; + -webkit-border-radius: 12px; + border-radius: 4px; + + cursor: pointer; + opacity: 0.4; + + background: #05addc; + background: -moz-linear-gradient(top, #05addc 0%, #0099b7 25%, #008ca8 50%, #0099b7 75%, #05addc 100%); + background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#05addc), color-stop(25%,#0099b7), color-stop(50%,#008ca8), color-stop(75%,#0099b7), color-stop(100%,#05addc)); + background: -webkit-linear-gradient(top, #05addc 0%,#0099b7 25%,#008ca8 50%,#0099b7 75%,#05addc 100%); + background: -o-linear-gradient(top, #05addc 0%,#0099b7 25%,#008ca8 50%,#0099b7 75%,#05addc 100%); + background: -ms-linear-gradient(top, #05addc 0%,#0099b7 25%,#008ca8 50%,#0099b7 75%,#05addc 100%); + background: linear-gradient(to bottom, #05addc 0%,#0099b7 25%,#008ca8 50%,#0099b7 75%,#05addc 100%); + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#05addc', endColorstr='#05addc',GradientType=0 ); + +} + +.callflows-port .media_tabs .buttons:hover { + -moz-box-shadow: 3px 5px 10px #383838; + -webkit-box-shadow: 3px 5px 10px #383838; + box-shadow: 3px 5px 10px #383838; + opacity: 0.6; +} + +.callflows-port .media_tabs .buttons.current, +.callflows-port .media_tabs .buttons.current:hover { + -moz-box-shadow: 3px 5px 10px #383838; + -webkit-box-shadow: 3px 5px 10px #383838; + box-shadow: 3px 5px 10px #383838; + opacity: 1; +} + +.callflows-port .media_tabs .buttons .label_device { + font-size: 12px; + text-transform: uppercase; + font-weight: bold; + color: white; +} + +.callflows-port #device-view .realm_label { + line-height: 22px; +} + +.callflows-port .media_pane { + margin-left: 0; + margin-top: 30px; +} + +.callflows-port #device-form .provisioner select { + width: 100px; + margin-left: 10px; +} + +.callflows-port #device-form .provisioner { + display: inline-block; + margin-left: 22px; +} + +.callflows-port .input .text { + display: inline-block; + width: 210px; + height: 20px; + margin-bottom: 10px; + padding: 4px 6px; +} + +.callflows-port #device-form .shoutcast-div { + display: none; +} + +.callflows-port #device-form .shoutcast-div.active { + display: block; +} diff --git a/src/apps/callflows/submodules/device/device.js b/src/apps/callflows/submodules/device/device.js new file mode 100644 index 0000000..067874a --- /dev/null +++ b/src/apps/callflows/submodules/device/device.js @@ -0,0 +1,1256 @@ +define(function(require){ + var $ = require('jquery'), + _ = require('underscore'), + monster = require('monster'); + + var app = { + requests: { + 'callflows.device.getProvisionerPhones': { + 'apiRoot': monster.config.api.provisioner, + 'url': 'phones/', + 'verb': 'GET', + 'headers': { + 'Accept': '*/*' + } + } + }, + + subscribe: { + 'callflows.fetchActions': 'deviceDefineActions', + 'callflows.device.popupEdit': 'devicePopupEdit', + 'callflows.device.edit': '_deviceEdit' + }, + + devicePopupEdit: function(args) { + var self = this, + popup, + popup_html, + data = args.data, + callback = args.callback, + data_defaults = args.data_defaults; + + popup_html = $('
    '); + + self.deviceEdit(data, popup_html, $('.inline_content', popup_html), { + save_success: function(_data) { + popup.dialog('close'); + + if(typeof callback == 'function') { + callback(_data); + } + }, + delete_success: function() { + popup.dialog('close'); + + if(typeof callback == 'function') { + callback({ data: {} }); + } + }, + after_render: function() { + popup = monster.ui.dialog(popup_html, { + title: (data.id) ? self.i18n.active().callflows.device.edit_device : self.i18n.active().callflows.device.create_device + }); + } + }, data_defaults); + }, + + // Added for the subscribed event to avoid refactoring deviceEdit + _deviceEdit: function(args) { + var self = this; + self.deviceEdit(args.data, args.parent, args.target, args.callbacks, args.data_defaults); + }, + + deviceEdit: function(data, _parent, _target, _callbacks, data_defaults) { + var self = this, + parent = _parent || $('#device-content'), + target = _target || $('#device-view', parent), + _callbacks = _callbacks || {}, + callbacks = { + save_success: _callbacks.save_success, + save_error: _callbacks.save_error || function(_data, status, type) { + if(status == 200 && type == 'mac_address') { + monster.ui.alert(self.i18n.active().callflows.device.this_mac_address_is_already_in_use); + } + }, + delete_success: _callbacks.delete_success, + delete_error: _callbacks.delete_error, + after_render: _callbacks.after_render + }, + defaults = { + data: $.extend(true, { + enabled: true, + caller_id: { + external: {}, + internal: {}, + emergency: {} + }, + ringtones: {}, + ignore_completed_elsewhere: true, + call_restriction: { closed_groups: 'inherit' }, + media: { + secure_rtp: 'none', + peer_to_peer: 'auto', + audio: { + codecs: ['PCMU', 'PCMA'] + }, + video: { + codecs: [] + }, + fax: { + option: 'false' + }, + fax_option: false + }, + sip: { + method: 'password', + invite_format: 'contact', + username: 'user_' + monster.util.randomString(6), + password: monster.util.randomString(12), + expire_seconds: '360' + }, + contact_list: { + exclude: false + }, + call_forward: {}, + music_on_hold: {} + }, data_defaults || {}), + + field_data: { + users: [], + call_restriction: {}, + sip: { + methods: { + 'password': self.i18n.active().callflows.device.password, + 'ip': 'IP' + }, + invite_formats: { + 'username': 'Username', + 'npan': 'NPA NXX XXXX', + 'e164': 'E. 164', + '1npan': '1npan', + 'route': 'Route', + 'contact': 'Contact' + } + }, + media: { + secure_rtp: { + value: 'none', + options: { + 'none': self.i18n.active().callflows.device.none, + 'srtp': self.i18n.active().callflows.device.srtp, + 'zrtp': self.i18n.active().callflows.device.zrtp + } + }, + peer_to_peer_options: { + 'auto': self.i18n.active().callflows.device.automatic, + 'true': self.i18n.active().callflows.device.always, + 'false': self.i18n.active().callflows.device.never + }, + fax: { + options: { + 'auto': self.i18n.active().callflows.device.auto_detect, + 'true': self.i18n.active().callflows.device.always_force, + 'false': self.i18n.active().callflows.device.disabled + } + }, + audio: { + codecs: { + 'OPUS': 'OPUS', + 'CELT@32000h': 'Siren @ 32Khz', + 'G7221@32000h': 'G722.1 @ 32khz', + 'G7221@16000h': 'G722.1 @ 16khz', + 'G722': 'G722', + 'speex@32000h': 'Speex @ 32khz', + 'speex@16000h': 'Speex @ 16khz', + 'PCMU': 'G711u / PCMU - 64kbps (North America)', + 'PCMA': 'G711a / PCMA - 64kbps (Elsewhere)', + 'G729':'G729 - 8kbps (Requires License)', + 'GSM':'GSM', + 'CELT@48000h': 'Siren (HD) @ 48kHz', + 'CELT@64000h': 'Siren (HD) @ 64kHz' + } + }, + video: { + codecs: { + 'VP8': 'VP8', + 'H264': 'H264', + 'H263': 'H263', + 'H261': 'H261' + } + } + }, + hide_owner: data.hide_owner || false, + outbound_flags: data.outbound_flags ? data.outbound_flags.join(", ") : data.outbound_flags + }, + functions: { + inArray: function(value, array) { + if(array) { + return ($.inArray(value, array) == -1) ? false : true; + } + else return false; + } + } + }, + parallelRequests = function (deviceData) { + monster.parallel({ + list_classifier: function(callback){ + self.callApi({ + resource: 'numbers.listClassifiers', + data: { + accountId: self.accountId, + filters: { paginate:false } + }, + success: function(_data_classifiers) { + if('data' in _data_classifiers) { + $.each(_data_classifiers.data, function(k, v) { + defaults.field_data.call_restriction[k] = { + friendly_name: v.friendly_name + }; + + defaults.data.call_restriction[k] = { action: 'inherit' }; + }); + } + callback(null, _data_classifiers); + } + }); + }, + account: function(callback){ + self.callApi({ + resource: 'account.get', + data: { + accountId: self.accountId + }, + success: function(_data, status) { + $.extend(defaults.field_data.sip, { + realm: _data.data.realm, + }); + + callback(null, _data); + } + }); + }, + user_list: function(callback) { + self.callApi({ + resource: 'user.list', + data: { + accountId: self.accountId, + filters: { paginate:false } + }, + success: function(_data, status) { + _data.data.sort(function(a, b) { + return (a.first_name + a.last_name).toLowerCase() < (b.first_name + b.last_name).toLowerCase() ? -1 : 1; + }); + + _data.data.unshift({ + id: '', + first_name: '- No', + last_name: 'owner -', + }); + + if (deviceData.hasOwnProperty('device_type') && deviceData.device_type === 'mobile') { + var userData = _.find(_data.data, function(user, idx) { return user.id === deviceData.owner_id; }); + + if (userData) { + defaults.field_data.users = userData; + } + else { + defaults.field_data.users = { + first_name: '- No', + last_name: 'owner -' + }; + } + } + else { + defaults.field_data.users = _data.data; + } + + callback(null, _data); + } + }); + }, + media_list: function(callback) { + self.callApi({ + resource: 'media.list', + data: { + accountId: self.accountId, + filters: { paginate:false } + }, + success: function(_data, status) { + _data.data.unshift( + { + id: '', + name: self.i18n.active().callflows.device.default_music + }, + { + id: 'silence_stream://300000', + name: self.i18n.active().callflows.device.silence + }, + { + id: 'shoutcast', + name: self.i18n.active().callflows.accountSettings.musicOnHold.shoutcastURL + } + ); + + defaults.field_data.music_on_hold = _data.data; + + callback(null, _data); + } + }); + }, + provisionerData: function(callback) { + if(monster.config.api.hasOwnProperty('provisioner') && monster.config.api.provisioner) { + self.deviceGetDataProvisoner(function(data) { + callback(null, data); + }); + } + else { + callback(null, {}); + } + } + }, + function(err, results){ + var render_data = self.devicePrepareDataForTemplate(data, defaults, $.extend(true, results, { + get_device: deviceData + })); + + self.deviceRender(render_data, target, callbacks); + + if(typeof callbacks.after_render == 'function') { + callbacks.after_render(); + } + }); + }; + + if(typeof data == 'object' && data.id) { + self.deviceGet(data.id, function(_data, status) { + defaults.data.device_type = 'sip_device'; + + if('media' in _data && 'encryption' in _data.media) { + defaults.field_data.media.secure_rtp.value = _data.media.encryption.enforce_security ? _data.media.encryption.methods[0] : 'none'; + } + + if('sip' in _data && 'realm' in _data.sip) { + defaults.field_data.sip.realm = _data.sip.realm; + } + + self.deviceMigrateData(_data); + + parallelRequests(_data); + }); + } + else { + parallelRequests(defaults); + } + }, + + devicePrepareDataForTemplate: function(data, dataGlobal, results) { + var self = this, + dataDevice = results.get_device, + dataProvisioner = results.provisionerData; + + if(typeof data === 'object' && data.id) { + dataGlobal = $.extend(true, dataGlobal, { data: dataDevice }); + } + + if(dataDevice.hasOwnProperty('media') && dataDevice.media.hasOwnProperty('audio')) { + // If the codecs property is defined, override the defaults with it. Indeed, when an empty array is set as the + // list of codecs, it gets overwritten by the extend function otherwise. + if(dataDevice.media.audio.hasOwnProperty('codecs')) { + dataGlobal.data.media.audio.codecs = dataDevice.media.audio.codecs; + } + + if(dataDevice.media.video.hasOwnProperty('codecs')) { + dataGlobal.data.media.video.codecs = dataDevice.media.video.codecs; + } + } + + _.each(dataGlobal.field_data.call_restriction, function(restriction, key) { + restriction.value = dataGlobal.data.call_restriction[key].action; + }); + + dataGlobal.field_data.provisioner = dataProvisioner; + dataGlobal.field_data.provisioner.isEnabled = !_.isEmpty(dataProvisioner); + + if(dataGlobal.field_data.provisioner.isEnabled) { + var default_provision_data = { + voicemail_beep: 1, //ie enabled + time_format: '12', + hotline: '', + vlan: { + enable: false, + number: '' + }, + date_format: 'middle-endian' + } + + dataGlobal.data.provision = $.extend(true, {}, default_provision_data, dataGlobal.data.provision); + } + + dataGlobal.extra = dataGlobal.extra || {}; + dataGlobal.extra.isShoutcast = false; + + // if the value is set to a stream, we need to set the value of the media_id to shoutcast so it gets selected by the old select mechanism, + // but we also need to store the value so we can display it + if (dataGlobal.data.hasOwnProperty('music_on_hold') && dataGlobal.data.music_on_hold.hasOwnProperty('media_id')) { + if (dataGlobal.data.music_on_hold.media_id.indexOf('://') >= 0) { + if (dataGlobal.data.music_on_hold.media_id !== 'silence_stream://300000') { + dataGlobal.extra.isShoutcast = true; + dataGlobal.extra.shoutcastValue = dataGlobal.data.music_on_hold.media_id; + dataGlobal.data.music_on_hold.media_id = 'shoutcast'; + } + } + } + + return dataGlobal; + }, + + deviceGetValidationByDeviceType: function(deviceType) { + var validation = { + sip_uri: {}, + sip_device : { + 'mac_address': { mac: true }, + 'sip_expire_seconds': { digits: true }, + 'extra.shoutcastUrl': { protocol: true } + }, + fax : { + 'mac_address': { mac: true }, + 'sip_expire_seconds': { digits: true } + }, + cellphone: {}, + smartphone: { + 'sip_expire_seconds': { digits: true } + }, + landline: {}, + softphone: { + 'sip_expire_seconds': { digits: true }, + 'extra.shoutcastUrl': { protocol: true } + }, + mobile: { + 'mdn': { digits: true }, + 'sip_expire_seconds': { digits: true }, + 'extra.shoutcastUrl': { protocol: true } + } + }; + + return { rules: validation[deviceType] }; + }, + + deviceRender: function(data, target, callbacks){ + var self = this, + device_html, + render; + + if('media' in data.data && 'fax_option' in data.data.media) { + data.data.media.fax_option = (data.data.media.fax_option === 'auto' || data.data.media.fax_option === true); + } + + if(typeof data.data == 'object' && data.data.device_type) { + device_html = $(monster.template(self, 'device-' + data.data.device_type, data)); + + var deviceForm = device_html.find('#device-form'); + + if(monster.config.api.hasOwnProperty('provisioner') && monster.config.api.provisioner) { + self.deviceSetProvisionerStuff(device_html, data); + } + + /* Do device type specific things here */ + if($.inArray(data.data.device_type, ['fax', 'softphone', 'sip_device', 'smartphone', 'mobile', 'ata']) > -1) { + monster.ui.protectField(device_html.find('#sip_password'), device_html); + } + + monster.ui.validate(deviceForm, self.deviceGetValidationByDeviceType(data.data.device_type)); + + if(!$('#owner_id', device_html).val()) { + $('#edit_link', device_html).hide(); + } + + + monster.ui.mask(device_html.find('#mac_address'), 'macAddress'); + + $('#owner_id', device_html).change(function() { + !$('#owner_id option:selected', device_html).val() ? $('#edit_link', device_html).hide() : $('#edit_link', device_html).show(); + }); + + $('.inline_action', device_html).click(function(ev) { + var _data = ($(this).data('action') == 'edit') ? { id: $('#owner_id', device_html).val() } : {}, + _id = _data.id; + + ev.preventDefault(); + + monster.pub('callflows.user.popupEdit', { + data: _data, + callback: function(user) { + /* Create */ + if(!_id) { + $('#owner_id', device_html).append(''); + $('#owner_id', device_html).val(user.id); + $('#edit_link', device_html).show(); + } + else { + /* Update */ + if(_data.hasOwnProperty('id')) { + $('#owner_id #'+user.id, device_html).text(user.first_name + ' ' + user.last_name); + } + /* Delete */ + else { + $('#owner_id #'+_id, device_html).remove(); + $('#edit_link', device_html).hide(); + } + } + } + }); + }); + + $('.device-save', device_html).click(function(ev) { + ev.preventDefault(); + + var $this = $(this); + + if(!$this.hasClass('disabled')) { + $this.addClass('disabled'); + if(monster.ui.valid(deviceForm)) { + var form_data = monster.ui.getFormData('device-form'); + + if (form_data.hasOwnProperty('music_on_hold') && form_data.music_on_hold.media_id === 'shoutcast') { + form_data.music_on_hold.media_id = device_html.find('.shoutcast-url-input').val(); + } + + self.deviceCleanFormData(form_data); + + if(form_data.hasOwnProperty('provision') && form_data.provision.hasOwnProperty('endpoint_brand') && form_data.provision.endpoint_brand !== 'none') { + // We have to set this manually since we have 3 dropdown with the same name we don't know which selected one is the correct one.. + form_data.provision.endpoint_model = $('.dropdown_family[data-brand="'+form_data.provision.endpoint_brand+'"]', device_html).val(); + form_data.provision.endpoint_family = $('#'+form_data.provision.endpoint_model, device_html).parents('optgroup').data('family'); + } + + self.deviceSave(form_data, data, callbacks.save_success); + } + else { + $this.removeClass('disabled'); + monster.ui.alert('error', self.i18n.active().callflows.device.there_were_errors_on_the_form); + } + } + }); + + if (data.device_type !== 'mobile') { + $('.device-delete', device_html).click(function(ev) { + ev.preventDefault(); + + monster.ui.confirm(self.i18n.active().callflows.device.are_you_sure_you_want_to_delete, function() { + self.deviceDelete(data.data.id, callbacks.delete_success); + }); + }); + } + + if(!$('#music_on_hold_media_id', device_html).val()) { + $('#edit_link_media', device_html).hide(); + } + + if(data.data.sip && data.data.sip.method === 'ip') { + $('#username_block', device_html).hide(); + } + else { + $('#ip_block', device_html).hide(); + } + + device_html.find('#sip_method').on('change', function() { + if($('#sip_method option:selected', device_html).val() === 'ip') { + $('#ip_block', device_html).slideDown(); + $('#username_block', device_html).slideUp(); + } + else { + $('#username_block', device_html).slideDown(); + $('#ip_block', device_html).slideUp(); + } + }); + + $('#music_on_hold_media_id', device_html).change(function() { + !$('#music_on_hold_media_id option:selected', device_html).val() ? $('#edit_link_media', device_html).hide() : $('#edit_link_media', device_html).show(); + + device_html.find('.shoutcast-div').toggleClass('active', $(this).val() === 'shoutcast'); + }); + + $('.inline_action_media', device_html).click(function(ev) { + var _data = ($(this).data('action') == 'edit') ? { id: $('#music_on_hold_media_id', device_html).val() } : {}, + _id = _data.id; + + ev.preventDefault(); + + monster.pub('callflows.media.editPopup', { + data: _data, + callback: function(media) { + /* Create */ + if(!_id) { + $('#music_on_hold_media_id', device_html).append(''); + $('#music_on_hold_media_id', device_html).val(media.id); + + $('#edit_link_media', device_html).show(); + } + else { + /* Update */ + if(media.hasOwnProperty('id')) { + $('#music_on_hold_media_id #'+ media.id, device_html).text(media.name); + } + /* Delete */ + else { + $('#music_on_hold_media_id #'+_id, device_html).remove(); + $('#edit_link_media', device_html).hide(); + } + } + } + }); + }); + } + else { + device_html = $(monster.template(self, 'device-general_edit')); + + $('.media_pane', device_html).hide(); + $('.media_tabs .buttons', device_html).click(function() { + var $this = $(this); + $('.media_pane', device_html).show(); + + if(!$this.hasClass('current')) { + $('.media_tabs .buttons').removeClass('current'); + $this.addClass('current'); + + data.data.device_type = $this.attr('device_type'); + + self.deviceFormatData(data); + + self.deviceRender(data, $('.media_pane', device_html), callbacks); + } + }); + } + + $('*[rel=popover]:not([type="text"])', device_html).popover({ + trigger: 'hover' + }); + + $('*[rel=popover][type="text"]', device_html).popover({ + trigger: 'focus' + }); + + self.winkstartTabs(device_html); + + (target) + .empty() + .append(device_html); + + $('.media_tabs .buttons[device_type="sip_device"]', device_html).trigger('click'); + }, + + deviceSetProvisionerStuff: function(device_html, data) { + var self = this, + set_value = function(brand_name, model_name) { + device_html.find('.dropdown_family').hide(); + if(brand_name in data.field_data.provisioner.brands) { + device_html.find('#dropdown_brand').val(brand_name); + device_html.find('.dropdown_family[data-brand="'+brand_name+'"]').show() + .val(model_name); + } + }, + provisionData = data.data.provision, + regex_brands = { + "00085d": "aastra", + "0010bc": "aastra", + "00036b": "cisco", + "00000c": "cisco", + "000142": "cisco", + "000143": "cisco", + "000163": "cisco", + "000164": "cisco", + "000196": "cisco", + "000197": "cisco", + "0001c7": "cisco", + "0001c9": "cisco", + "000f23": "cisco", + "0013c4": "cisco", + "0016c8": "cisco", + "001818": "cisco", + "00175a": "cisco", + "001795": "cisco", + "001A2f": "cisco", + "001c58": "cisco", + "001dA2": "cisco", + "002155": "cisco", + "000e84": "cisco", + "000e38": "cisco", + "00070e": "cisco", + "001bd4": "cisco", + "001930": "cisco", + "0019aa": "cisco", + "001d45": "cisco", + "001ef7": "cisco", + "000e08": "cisco", + "1cdf0f": "cisco", + "e05fb9": "cisco", + "5475d0": "cisco", + "c46413": "cisco", + "000Ffd3": "digium", + "000b82": "grandstream", + "08000f": "mitel", + "1045bE": "norphonic", + "0050c2": "norphonic", + "0004f2": "polycom", + "00907a": "polycom", + "000413": "snom", + "001f9f": "thomson", + "00147f": "thomson", + "642400": "xorcom", + "001565": "yealink" + }; + + set_value(provisionData.endpoint_brand, provisionData.endpoint_model); + + device_html.find('#dropdown_brand').on('change', function() { + set_value($(this).val()); + }); + + device_html.find('#mac_address').on('keyup', function() { + var mac_address = $(this).val().replace(/[^0-9a-fA-F]/g, ''); + + if(mac_address in regex_brands) { + set_value(regex_brands[mac_address]); + } + }); + }, + + deviceFormatData: function(data) { + if(data.data.device_type === 'smartphone' || data.data.device_type === 'landline' || data.data.device_type === 'cellphone') { + data.data.call_forward = { + enabled: true, + require_keypress: true, + keep_caller_id: true + }; + } + else { + data.data.call_forward = { + enabled: false + }; + } + + if(data.data.device_type === 'sip_uri') { + data.data.sip.invite_format = 'route'; + } + + if(data.data.device_type === 'mobile') { + if(!('mobile' in data.data)) { + data.data.mobile = { + mdn: '' + }; + } + } + + if(data.data.device_type === 'fax') { + data.data.media.fax_option = true; + data.data.media.fax.option = 'true'; + } + else { + data.data.media.fax_option = false; + data.data.media.fax.option = 'false'; + } + }, + + deviceMigrateData: function(data) { + var self = this; + + if(data.hasOwnProperty('media') && data.media.hasOwnProperty('audio') && data.media.audio.hasOwnProperty('codecs')) { + var mapMigrateCodec = { + 'Speex': 'speex@16000h', + 'G722_16': 'G7221@16000h', + 'G722_32': 'G7221@32000h', + 'CELT_48': 'CELT@48000h', + 'CELT_64': 'CELT@64000h' + }, + newCodecList = []; + + _.each(data.media.audio.codecs, function(codec) { + mapMigrateCodec.hasOwnProperty(codec) ? newCodecList.push(mapMigrateCodec[codec]) : newCodecList.push(codec); + }); + + data.media.audio.codecs = newCodecList; + } + + if(data.device_type == 'cell_phone') { + data.device_type = 'cellphone'; + } + + if(typeof data.media == 'object' && typeof data.media.fax == 'object' && 'codecs' in data.media.fax) { + delete data.media.fax.codecs; + } + + if('status' in data) { + data.enabled = data.status; + delete data.status; + } + + if(data.hasOwnProperty('ignore_complete_elsewhere')) { + data.ignore_completed_elsewhere = data.ignore_complete_elsewhere; + + delete data.ignore_complete_elsewhere; + } + + return data; + }, + + deviceNormalizeData: function(data) { + if(data.hasOwnProperty('provision')) { + if(data.provision.endpoint_brand === 'none') { + delete data.provision; + } + else { + if(data.provision.voicemail_beep !== 0) { + delete data.provision.voicemail_beep; + } + } + } + + if(data.hasOwnProperty('media') && data.media.hasOwnProperty('fax_option') && data.media.fax_option === 'auto') { + delete data.media.fax_option; + } + + if('media' in data && 'fax' in data.media && 'fax_option' in data.media) { + data.media.fax.option = data.media.fax_option.toString(); + } + + if('media' in data && 'secure_rtp' in data.media) { + delete data.media.secure_rtp; + } + + if('media' in data && 'bypass_media' in data.media) { + delete data.media.bypass_media; + } + + if(data.caller_id.internal.number == '' && data.caller_id.internal.name == '') { + delete data.caller_id.internal; + } + + if(data.caller_id.external.number == '' && data.caller_id.external.name == '') { + delete data.caller_id.external; + } + + if(data.caller_id.emergency.number == '' && data.caller_id.emergency.name == '') { + delete data.caller_id.emergency; + } + + if(!data.music_on_hold.media_id) { + delete data.music_on_hold.media_id; + } + + if(!data.owner_id) { + delete data.owner_id; + } + + if($.isEmptyObject(data.call_forward)) { + delete data.call_forward; + } + + if(!data.mac_address) { + delete data.mac_address; + } + + if(data.sip.method != 'ip') { + delete data.sip.ip; + } + + if(typeof data.outbound_flags == "string") { + data.outbound_flags = data.outbound_flags.split(/,/); + + /* Get rid of empty string */ + var new_flags = []; + $.each(data.outbound_flags, function(k, v) { + if(v.replace(/\s/g, '') !== '') { + new_flags.push(v); + } + }); + data.outbound_flags = new_flags; + } + if(data.device_type === 'fax') { + if(!('outbound_flags' in data)) { + data.outbound_flags = ['fax']; + } else if(data.outbound_flags.indexOf('fax') < 0) { + data.outbound_flags.splice(0,0,'fax'); + } + } + + if(data.ringtones && 'internal' in data.ringtones && data.ringtones.internal === '') { + delete data.ringtones.internal; + } + + if(data.ringtones && 'external' in data.ringtones && data.ringtones.external === '') { + delete data.ringtones.external; + } + + // For devices who don't have sip creds, we need to use username, for sip url we already set it to "route", and for the others, the default is applied: "contact" + if ($.inArray(data.device_type, ['landline', 'cellphone']) >= 0) { + data.sip.invite_format = 'username'; + } + + if ($.inArray(data.device_type, ['fax', 'mobile', 'softphone', 'sip_device', 'smartphone']) < 0) { + delete data.call_restriction; + } + + if(data.hasOwnProperty('presence_id') && data.presence_id === '') { + delete data.presence_id; + } + + return data; + }, + + deviceCleanFormData: function(form_data) { + if('provision' in form_data && form_data.provision.voicemail_beep === true) { + form_data.provision.voicemail_beep = 0; + } + + if(form_data.mac_address) { + form_data.mac_address = form_data.mac_address.toLowerCase(); + + if(form_data.mac_address.match(/^(((\d|([a-f]|[A-F])){2}-){5}(\d|([a-f]|[A-F])){2})$/)) { + form_data.mac_address = form_data.mac_address.replace(/-/g,':'); + } + else if(form_data.mac_address.match(/^(((\d|([a-f]|[A-F])){2}){5}(\d|([a-f]|[A-F])){2})$/)) { + form_data.mac_address = form_data.mac_address.replace(/(.{2})/g,'$1:').slice(0, -1); + } + } + + if(form_data.caller_id) { + form_data.caller_id.internal.number = form_data.caller_id.internal.number.replace(/\s|\(|\)|\-|\./g,''); + form_data.caller_id.external.number = form_data.caller_id.external.number.replace(/\s|\(|\)|\-|\./g,''); + form_data.caller_id.emergency.number = form_data.caller_id.emergency.number.replace(/\s|\(|\)|\-|\./g,''); + } + + if('media' in form_data && 'audio' in form_data.media) { + form_data.media.audio.codecs = $.map(form_data.media.audio.codecs, function(val) { return (val) ? val : null }); + } + + if('media' in form_data && 'video' in form_data.media) { + form_data.media.video.codecs = $.map(form_data.media.video.codecs, function(val) { return (val) ? val : null }); + } + + if(form_data.device_type == 'smartphone' || form_data.device_type == 'landline' || form_data.device_type == 'cellphone') { + form_data.call_forward.number = form_data.call_forward.number.replace(/\s|\(|\)|\-|\./g,''); + form_data.enabled = form_data.call_forward.enabled; + } + + if('extra' in form_data && form_data.extra.notify_unregister === true) { + form_data.suppress_unregister_notifications = false; + } + else { + form_data.suppress_unregister_notifications = true; + } + + if('extra' in form_data && 'closed_groups' in form_data.extra) { + form_data.call_restriction.closed_groups = { action: form_data.extra.closed_groups ? 'deny' : 'inherit' }; + } + + if($.inArray(form_data.device_type, ['sip_device', 'mobile', 'softphone']) > -1) { + if('extra' in form_data) { + form_data.media.encryption = form_data.media.encryption || {}; + + if($.inArray(form_data.extra.encryptionMethod, ['srtp', 'zrtp']) > -1) { + form_data.media.encryption.enforce_security = true; + form_data.media.encryption.methods = [form_data.extra.encryptionMethod]; + } + else { + form_data.media.encryption.methods = []; + form_data.media.encryption.enforce_security = false; + } + } + } + + delete form_data.extra; + + return form_data; + }, + + deviceFixArrays: function(data, data2) { + if(typeof data.media == 'object' && typeof data2.media == 'object') { + (data.media.audio || {}).codecs = (data2.media.audio || {}).codecs; + (data.media.video || {}).codecs = (data2.media.video || {}).codecs; + } + + if('media' in data2 && 'encryption' in data2.media && 'methods' in data2.media.encryption) { + data.media.encryption = data.media.encryption || {}; + data.media.encryption.methods = data2.media.encryption.methods; + } + + return data; + }, + + deviceSave: function(form_data, data, success) { + var self = this, + id = (typeof data.data == 'object' && data.data.id) ? data.data.id : undefined, + normalized_data = self.deviceFixArrays(self.deviceNormalizeData($.extend(true, {}, data.data, form_data)), form_data); + + if(id) { + self.deviceUpdate(normalized_data, function(_data, status) { + success && success(_data, status, 'update'); + }); + } + else { + self.deviceCreate(normalized_data, function(_data, status) { + success && success(_data, status, 'create'); + }); + } + }, + + deviceList: function(callback) { + var self = this; + + self.callApi({ + resource: 'device.list', + data: { + accountId: self.accountId, + filters: { paginate:false } + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + deviceGet: function(deviceId, callback) { + var self = this; + + self.callApi({ + resource: 'device.get', + data: { + accountId: self.accountId, + deviceId: deviceId + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + deviceCreate: function(data, callback) { + var self = this; + + self.callApi({ + resource: 'device.create', + data: { + accountId: self.accountId, + data: data + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + deviceUpdate: function(data, callback) { + var self = this; + + self.callApi({ + resource: 'device.update', + data: { + accountId: self.accountId, + deviceId: data.id, + data: data + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + deviceDelete: function(deviceId, callback) { + var self = this; + + self.callApi({ + resource: 'device.delete', + data: { + accountId: self.accountId, + deviceId: deviceId + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + deviceGetDataProvisoner: function(callback) { + var self = this; + + monster.request({ + resource: 'callflows.device.getProvisionerPhones', + data: { + }, + success: function(data) { + data = self.deviceFormatDataProvisioner(data.data); + + callback && callback(data) + } + }); + }, + + deviceFormatDataProvisioner: function(data) { + var self = this, + formattedData = { + brands: data + }; + + return formattedData; + }, + + deviceDefineActions: function(args) { + var self = this, + callflow_nodes = args.actions; + + $.extend(callflow_nodes, { + 'device[id=*]': { + name: self.i18n.active().callflows.device.device, + icon: 'phone', + category: self.i18n.active().oldCallflows.advanced_cat, + module: 'device', + tip: self.i18n.active().callflows.device.device_tip, + data: { + id: 'null' + }, + rules: [ + { + type: 'quantity', + maxSize: '1' + } + ], + isUsable: 'true', + weight: 10, + caption: function(node, caption_map) { + var id = node.getMetadata('id'), + returned_value = ''; + + if(id in caption_map) { + returned_value = caption_map[id].name; + } + + return returned_value; + }, + edit: function(node, callback) { + var _this = this; + + self.deviceList(function(devices) { + var popup, popup_html; + + popup_html = $(monster.template(self, 'device-callflowEdit', { + can_call_self: node.getMetadata('can_call_self') || false, + parameter: { + name: 'timeout (s)', + value: node.getMetadata('timeout') || '20' + }, + objects: { + items: _.sortBy(devices, 'name'), + selected: node.getMetadata('id') || '' + } + })); + + if($('#device_selector option:selected', popup_html).val() == undefined) { + $('#edit_link', popup_html).hide(); + } + + $('.inline_action', popup_html).click(function(ev) { + var _data = ($(this).data('action') === 'edit') ? + { id: $('#device_selector', popup_html).val() } : {}; + + ev.preventDefault(); + + self.devicePopupEdit({ + data: _data, + callback: function(device) { + node.setMetadata('id', device.id || 'null'); + node.setMetadata('timeout', $('#parameter_input', popup_html).val()); + node.setMetadata('can_call_self', $('#device_can_call_self', popup_html).is(':checked')); + + node.caption = device.name || ''; + + popup.dialog('close'); + } + }); + }); + + $('#add', popup_html).click(function() { + node.setMetadata('id', $('#device_selector', popup_html).val()); + node.setMetadata('timeout', $('#parameter_input', popup_html).val()); + node.setMetadata('can_call_self', $('#device_can_call_self', popup_html).is(':checked')); + + node.caption = $('#device_selector option:selected', popup_html).text(); + + popup.dialog('close'); + }); + + popup = monster.ui.dialog(popup_html, { + title: self.i18n.active().callflows.device.device_title, + beforeClose: function() { + if(typeof callback == 'function') { + callback(); + } + } + }); + }); + }, + listEntities: function(callback) { + monster.parallel({ + device: function(callback) { + self.callApi({ + resource: 'device.list', + data: { + accountId: self.accountId, + filters: { + paginate: false + } + }, + success: function(data, status) { + callback && callback(null, data.data); + } + }); + }, + status: function(callback) { + self.callApi({ + resource: 'device.getStatus', + data: { + accountId: self.accountId, + filters: { + paginate: false + } + }, + success: function(data, status) { + callback && callback(null, data.data); + } + }); + } + }, + function(err, results) { + var registeredDevices = _.map(results.status, function(registration) { if (registration.registered === true) { return registration.device_id; } }), + deviceIcons = { + 'cellphone': 'fa fa-phone', + 'smartphone': 'icon-telicon-mobile-phone', + 'landline': 'icon-telicon-home', + 'mobile': 'icon-telicon-sprint-phone', + 'softphone': 'icon-telicon-soft-phone', + 'sip_device': 'icon-telicon-voip-phone', + 'sip_uri': 'icon-telicon-voip-phone', + 'fax': 'icon-telicon-fax', + 'ata': 'icon-telicon-ata', + 'unknown': 'fa fa-circle' + }; + + _.each(results.device, function(device) { + var dataTemplate = device; + dataTemplate.extra = { + deviceIcon: deviceIcons.hasOwnProperty(device.device_type) ? deviceIcons[device.device_type] : deviceIcons.unknown, + isRegistered: device.enabled ? (['sip_device', 'smartphone', 'softphone', 'fax', 'ata'].indexOf(device.device_type) >= 0 ? registeredDevices.indexOf(device.id) >= 0 : true) : false + }; + device.customEntityTemplate = monster.template(self, 'device-entity-element', dataTemplate); + }); + + callback && callback(results.device); + }); + }, + editEntity: 'callflows.device.edit' + } + }); + } + }; + + return app; +}); diff --git a/src/apps/callflows/submodules/directory/directory.css b/src/apps/callflows/submodules/directory/directory.css new file mode 100644 index 0000000..b7898b6 --- /dev/null +++ b/src/apps/callflows/submodules/directory/directory.css @@ -0,0 +1,158 @@ +.callflows-port #directory-form #basic #tab_users { + border: 2px solid #666666; + border-radius: 15px 15px 0px 0px; + color: #666666; + margin: 20px auto auto; + width: 480px; + max-height: 342px; + float: left; +} + +.callflows-port #directory-form #basic #tab_users .rows { + max-height: 310px; + overflow: auto; +} + +.callflows-port #directory-form #basic #tab_users .action_user { + color: #666666; + cursor: pointer; + text-decoration: underline; + line-height: 32px; +} + +.callflows-port #directory-form #basic #tab_users .action_user:not(:first-child) { + margin-left: 10px; +} +.callflows-port #directory-form #basic #tab_users .action_user:hover { + color: #05addc; +} + +.callflows-port #directory-form #basic #tab_users .column.first:not(:last-child) { + border-right: 1px solid #A6A6A6; +} + +.callflows-port #directory-form #basic #tab_users .column { + float: left; + text-align: center; + height: 32px; + line-height: 32px; +} + +.callflows-port #directory-form #basic #tab_users select { + height: 22px; +} + +.callflows-port #directory-form #basic #tab_users .column.first { + width: 230px; + overflow: hidden; + text-align:center; +} + +.callflows-port #directory-form #basic #tab_users .column.third { + width: 69px; +} + +.callflows-port #directory-form #basic #tab_users .column.second { + min-width: 159px; + border-right: 1px solid #A6A6A6; +} + +.callflows-port #directory-form #basic #tab_users .column.second select { + margin: 0; + max-width: 140px; + padding: 0; +} + +.callflows-port #directory-form #basic #tab_users .column.merged { + width: 480px; +} + +.callflows-port #directory-form #basic #tab_users .row-user { + height: 32px; + margin-left: 0px; +} + +.callflows-port #directory-form #basic #tab_users .row-user.title { + background-color: #dddddd !important; + border-bottom: 2px solid #666666 !important; + border-radius: 13px 13px 0px 0px; + font-weight: bold; +} + +.callflows-port #directory-form #basic #tab_users .row-user:not(:last-child) { + border-bottom: 1px solid #A6A6A6; +} + +.callflows-port #directory-form #basic #tab_users .row-user:nth-child(odd) { + background-color: #eeeeee; +} + +.callflows-port #directory-form #basic #tab_users .row-user:nth-child(even) { + background-color: #dddddd; +} + +.callflows-port #directory-form #basic .add_user { + margin: 20px 0 0 20px; + color: #666666; + background: #666666; + width: 230px; + border-radius: 15px 15px 15px 15px; + float: right; +} + +.callflows-port #directory-form #basic .add_user .add_content_wrapper { + background: #EEEEEE; + border-radius: 0 0 15px 15px; +} + +.callflows-port #directory-form #basic .add_user .add_user_title { + color: #eeeeee; + font-weight: bold; + height: 25px; + line-height: 25px; + text-align: center; + border-radius: 10px 10px 0 0; +} + +.callflows-port #directory-form #basic .add_user select { + width: 180px; +} + +.callflows-port #directory-form #basic .add_user .add_user_fields { + margin: auto; + width: 200px; +} + +.callflows-port #directory-form #basic .add_user .add_user_fields .tooltip-wrapper { + margin-left: 0px; +} + +.callflows-port #directory-form #basic .add_user .add_user_fields ul { + list-style-type: none; +} + +.callflows-port #directory-form #basic .add_user .add_user_div { + margin: 10px auto auto auto; + width: 200px; + padding-bottom: 15px; +} + +.callflows-port #directory-form #basic .add_user .add_user_div a { + color: #333333; +} + +.callflows-port #directory-form #basic .add_user label { + color: #404040; + width: auto; +} + + + +.callflows-port #directory-form #basic .add_user .add_user_div:hover a { + color: #05addc; +} + +.callflows-port #directory-form #basic .add_user .add_user_div:hover .add_user_icon { + background-position: 0 -24px; + cursor: pointer; +} \ No newline at end of file diff --git a/src/apps/callflows/submodules/directory/directory.js b/src/apps/callflows/submodules/directory/directory.js new file mode 100644 index 0000000..d2cc109 --- /dev/null +++ b/src/apps/callflows/submodules/directory/directory.js @@ -0,0 +1,618 @@ +define(function(require){ + var $ = require('jquery'), + _ = require('underscore'), + monster = require('monster'); + + var app = { + requests: {}, + + subscribe: { + 'callflows.fetchActions': 'directoryDefineActions', + 'callflows.directory.edit': '_directoryEdit' + }, + + directoryRender: function(data, target, callbacks){ + var self = this, + directory_html = $(monster.template(self, 'directory-edit', data)), + directoryForm = directory_html.find('#directory-form'); + + self.directoryRenderUserList(data, directory_html); + + monster.ui.validate(directoryForm, { + rules: { + 'min_dtmf': { digits: true }, + 'max_dtmf': { digits: true } + } + }); + + $('*[rel=popover]:not([type="text"])', directory_html).popover({ + trigger: 'hover' + }); + + $('*[rel=popover][type="text"]', directory_html).popover({ + trigger: 'focus' + }); + + self.winkstartTabs(directory_html); + + $('.directory-save', directory_html).click(function(ev) { + ev.preventDefault(); + var $this = $(this); + + if (!$this.hasClass('disabled')) { + $this.addClass('disabled'); + if (monster.ui.valid(directoryForm)) { + var form_data = monster.ui.getFormData('directory-form'); + + self.directoryCleanFormData(form_data); + + var old_list = {}, + new_list = {}, + userCallflowId; + + $('.rows .row:not(#row_no_data)', directory_html).each(function() { + userCallflowId = $('#user_callflow_id', $(this)).val(); + + if (userCallflowId !== '_empty') { + new_list[$(this).data('id')] = userCallflowId; + } + }); + + data.field_data.user_list = { + old_list: data.field_data.old_list, + new_list: new_list + }; + + self.directorySave(form_data, data, callbacks.save_success); + } else { + $this.removeClass('disabled'); + monster.ui.alert(self.i18n.active().callflows.directory.there_were_errors_on_the_form); + } + } + }); + + $('.directory-delete', directory_html).click(function(ev) { + ev.preventDefault(); + + monster.ui.confirm(self.i18n.active().callflows.directory.are_you_sure_you_want_to_delete, function() { + self.directoryDelete(data.data.id, callbacks.delete_success); + }); + }); + + $('.add_user_div', directory_html).click(function() { + var $user = $('#select_user_id', directory_html); + var $callflow = $('#callflow_id', directory_html); + + if($user.val() != 'empty_option_user' && $callflow.val() != 'empty_option_callflow') { + var user_id = $user.val(), + user_data = { + user_id: user_id, + user_name: $('#option_user_'+user_id, directory_html).text(), + callflow_id: $callflow.val(), + field_data: { + callflows: data.field_data.callflows + }, + _t: function(param){ + return window.translate['directory'][param]; + } + }; + + if($('#row_no_data', directory_html).size() > 0) { + $('#row_no_data', directory_html).remove(); + } + + $('.rows', directory_html).prepend(monster.template(self, 'directory-userRow', user_data)); + $('#option_user_'+user_id, directory_html).hide(); + + $user.val('empty_option_user'); + $callflow.val('empty_option_callflow'); + } + else { + monster.ui.alert('warning', self.i18n.active().callflows.directory.noDataSelected); + } + }); + + $(directory_html).delegate('.action_user.delete', 'click', function() { + var user_id = $(this).data('id'); + //removes it from the grid + $('#row_user_'+user_id, directory_html).remove(); + //re-add it to the dropdown + $('#option_user_'+user_id, directory_html).show(); + //if grid empty, add no data line + if($('.rows .row', directory_html).size() == 0) { + $('.rows', directory_html).append(monster.template(self, 'directory-userRow')); + } + }); + + (target) + .empty() + .append(directory_html); + }, + + directoryRenderUserList: function(data, parent) { + var self = this; + + if(data.data.id) { + if('users' in data.data && data.data.users.length > 0) { + var user_item; + $.each(data.field_data.users, function(k, v) { + if(v.id in data.field_data.old_list) { + user_item = { + user_id: v.id, + user_name: v.first_name + ' ' + v.last_name, + callflow_id: data.field_data.old_list[v.id], + field_data: { + callflows: data.field_data.callflows + } + }; + + $('.rows', parent).append(monster.template(self, 'directory-userRow', user_item)); + $('#option_user_'+v.id, parent).hide(); + } + }); + } + else { + $('.rows', parent).empty() + .append(monster.template(self, 'directory-userRow')); + } + } + else { + $('.rows', parent).empty() + .append(monster.template(self,'directory-userRow')); + } + }, + + // Added for the subscribed event to avoid refactoring directoryEdit + _directoryEdit: function(args) { + var self = this; + self.directoryEdit(args.data, args.parent, args.target, args.callbacks, args.data_defaults); + }, + + directoryEdit: function(data, _parent, _target, _callbacks, data_defaults){ + var self = this, + parent = _parent || $('#directory-content'), + target = _target || $('#directory-view', parent), + _callbacks = _callbacks || {}, + callbacks = { + save_success: _callbacks.save_success, + save_error: _callbacks.save_error, + delete_success: _callbacks.delete_success, + delete_error: _callbacks.delete_error, + after_render: _callbacks.after_render + }, + defaults = { + data: $.extend(true, { + min_dtmf: '3', + max_dtmf: '0', + sort_by: 'last_name', + confirm_match: false + }, data_defaults || {}), + field_data: { + sort_by: { + 'first_name': self.i18n.active().callflows.directory.first_name, + 'last_name': self.i18n.active().callflows.directory.last_name + } + } + }; + + monster.parallel({ + callflow_list: function(callback) { + self.callApi({ + resource: 'callflow.list', + data: { + accountId: self.accountId, + filters: { + paginate: 'false' + } + }, + success: function(callflows) { + var list_callflows = []; + $.each(callflows.data, function() { + if(this.featurecode == false) { + list_callflows.push(this); + } + }); + + list_callflows.sort(function(a, b) { + var aName = (a.name || (a.numbers[0] + '')).toLowerCase(), + bName = (b.name || (b.numbers[0] + '')).toLowerCase(); + + return aName > bName ? 1 : -1; + }); + + defaults.field_data.callflows = list_callflows; + + callback(null, callflows); + } + }); + }, + user_list: function(callback) { + self.callApi({ + resource: 'user.list', + data: { + accountId: self.accountId, + filters: { + paginate: 'false' + } + }, + success: function(users) { + users.data.sort(function(a,b) { + var aName = (a.first_name + ' ' + a.last_name).toLowerCase(), + bName = (b.first_name + ' ' + b.last_name).toLowerCase(); + + return aName > bName ? 1 : -1; + }); + + defaults.field_data.users = users.data; + + callback(null, users); + } + }); + }, + directory_get: function(callback) { + if(typeof data === 'object' && data.id) { + self.directoryGet(data.id, function(directory, status) { + defaults.field_data.old_list = {}; + + if('users' in directory) { + $.each(directory.users, function(k, v) { + defaults.field_data.old_list[v.user_id] = v.callflow_id; + }); + } + + callback(null, directory); + } + ); + } + else { + callback(null, {}); + } + } + }, + function(err, results) { + var render_data = defaults; + + if(typeof data === 'object' && data.id) { + render_data = $.extend(true, defaults, { data: results.directory_get }); + } + + self.directoryRender(render_data, target, callbacks); + + if(typeof callbacks.after_render == 'function') { + callbacks.after_render(); + } + } + ); + }, + + directoryPopupEdit: function(args) { + var self = this, + popup, + popup_html, + data = args.data, + callback = args.callback, + data_defaults = args.data_defaults; + + popup_html = $('
    '); + + self.directoryEdit(data, popup_html, $('.inline_content', popup_html), { + save_success: function(_data) { + popup.dialog('close'); + + if(typeof callback == 'function') { + callback(_data); + } + }, + delete_success: function() { + popup.dialog('close'); + + if(typeof callback == 'function') { + callback({ data: {} }); + } + }, + after_render: function() { + popup = monster.ui.dialog(popup_html, { + title: (data.id) ? self.i18n.active().callflows.directory.edit_directory : self.i18n.active().callflows.directory.create_directory + }); + } + }, data_defaults); + }, + + directoryNormalizeData: function(form_data) { + delete form_data.users; + return form_data; + }, + + directoryCleanFormData: function(form_data) { + if(!(form_data.max_dtmf > 0)) { + delete form_data.max_dtmf; + } + + delete form_data.user_callflow_id; + delete form_data.user_id; + delete form_data.callflow_id; + }, + + directorySave: function(form_data, data, success) { + var self = this, + normalized_data = self.directoryNormalizeData($.extend(true, {}, data.data, form_data)); + + if (typeof data.data == 'object' && data.data.id) { + self.directoryUpdate(normalized_data, function(_data, status) { + self.directoryUpdateUsers(data.field_data.user_list, _data.id, function() { + success && success(_data, status, 'update'); + }); + }) + } + else { + self.directoryCreate(normalized_data, function(_data, status) { + self.directoryUpdateUsers(data.field_data.user_list, _data.id, function() { + success && success(_data, status, 'create'); + }); + }); + } + }, + + directoryUpdateSingleUser: function(user_id, directory_id, callflow_id, callback) { + var self = this; + + self.callApi({ + resource: 'user.get', + data: { + accountId: self.accountId, + userId: user_id + }, + success: function(_data, status) { + if(callflow_id) { + if(!_data.data.directories || $.isArray(_data.data.directories)) { + _data.data.directories = {}; + } + _data.data.directories[directory_id] = callflow_id; + } + else { + delete _data.data.directories[directory_id]; + } + + self.callApi({ + resource: 'user.update', + data: { + accountId: self.accountId, + userId: user_id, + data: _data.data + }, + success: callback + }); + } + }); + }, + + directoryUpdateUsers: function(data, directory_id, success) { + var old_directory_user_list = data.old_list, + new_directory_user_list = data.new_list, + self = this, + users_updated_count = 0, + users_count = 0, + callback = function() { + users_updated_count++; + if(users_updated_count >= users_count) { + success(); + } + }; + + if(old_directory_user_list) { + $.each(old_directory_user_list, function(k, v) { + if(!(k in new_directory_user_list)) { + //Request to update user without this directory. + users_count++; + self.directoryUpdateSingleUser(k, directory_id, undefined, callback); + } + }); + + $.each(new_directory_user_list, function(k, v) { + if(k in old_directory_user_list) { + if(old_directory_user_list[k] != v) { + //Request to update user + users_count++; + self.directoryUpdateSingleUser(k, directory_id, v, callback); + } + //else it has not been updated + } + else { + users_count++; + self.directoryUpdateSingleUser(k, directory_id, v, callback); + } + }); + } + else { + if(new_directory_user_list) { + $.each(new_directory_user_list, function(k, v) { + users_count++; + self.directoryUpdateSingleUser(k, directory_id, v, callback); + }); + } + } + + if(users_count === 0) { + success(); + } + }, + + directoryDefineActions: function(args) { + var self = this, + callflow_nodes = args.actions; + + $.extend(callflow_nodes, { + 'directory[id=*]': { + name: self.i18n.active().callflows.directory.directory, + icon: 'book', + category: self.i18n.active().oldCallflows.advanced_cat, + module: 'directory', + tip: self.i18n.active().callflows.directory.directory_tip, + data: { + id: 'null' + }, + rules: [ + { + type: 'quantity', + maxSize: '1' + } + ], + isUsable: 'true', + weight: 160, + caption: function(node, caption_map) { + var id = node.getMetadata('id'), + returned_value = ''; + + if(id in caption_map) { + returned_value = caption_map[id].name; + } + + return returned_value; + }, + edit: function(node, callback) { + var _this = this; + + self.directoryList(function(directories) { + var popup, popup_html; + + popup_html = $(monster.template(self, 'directory-callflowEdit', { + items: _.sortBy(directories, 'name'), + selected: node.getMetadata('id') || '' + })); + + if($('#directory_selector option:selected', popup_html).val() == undefined) { + $('#edit_link', popup_html).hide(); + } + + $('.inline_action', popup_html).click(function(ev) { + var _data = ($(this).data('action') == 'edit') ? + { id: $('#directory_selector', popup_html).val() } : {}; + + ev.preventDefault(); + + self.directoryPopupEdit({ + data: _data, + callback: function(_data) { + node.setMetadata('id', _data.id || 'null'); + + node.caption = _data.name || ''; + + popup.dialog('close'); + } + }); + }); + + $('#add', popup_html).click(function() { + node.setMetadata('id', $('#directory_selector', popup).val()); + + node.caption = $('#directory_selector option:selected', popup).text(); + + popup.dialog('close'); + }); + + popup = monster.ui.dialog(popup_html, { + title: self.i18n.active().callflows.directory.directory_title, + beforeClose: function() { + if(typeof callback == 'function') { + callback(); + } + } + }); + }); + }, + listEntities: function(callback) { + self.callApi({ + resource: 'directory.list', + data: { + accountId: self.accountId, + filters: { paginate:false } + }, + success: function(data, status) { + callback && callback(data.data); + } + }); + }, + editEntity: 'callflows.directory.edit' + } + }); + }, + + directoryList: function(callback) { + var self = this; + + self.callApi({ + resource: 'directory.list', + data: { + accountId: self.accountId, + filters: { paginate:false } + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + directoryGet: function(directoryId, callback) { + var self = this; + + self.callApi({ + resource: 'directory.get', + data: { + accountId: self.accountId, + directoryId: directoryId + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + directoryCreate: function(data, callback) { + var self = this; + + self.callApi({ + resource: 'directory.create', + data: { + accountId: self.accountId, + data: data + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + directoryUpdate: function(data, callback) { + var self = this; + + self.callApi({ + resource: 'directory.update', + data: { + accountId: self.accountId, + directoryId: data.id, + data: data + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + directoryDelete: function(directoryId, callback) { + var self = this; + + self.callApi({ + resource: 'directory.delete', + data: { + accountId: self.accountId, + directoryId: directoryId + }, + success: function(data) { + callback && callback(data.data); + } + }); + } + }; + + return app; +}); diff --git a/src/apps/callflows/submodules/faxbox/faxbox.css b/src/apps/callflows/submodules/faxbox/faxbox.css new file mode 100644 index 0000000..03fde60 --- /dev/null +++ b/src/apps/callflows/submodules/faxbox/faxbox.css @@ -0,0 +1,18 @@ +.callflows-port form .input a { + color: #05ADDC; + font-size: 13px; + line-height: 30px; +} + +.callflows-port #faxbox-form .tooltip { + display: inline-block; + float: none; + margin-left: 5px; +} + +.callflows-port #faxbox-form span.text { + color: #22a5ff; + font-size: 13px; + font-weight: bold; + line-height: 30px; +} \ No newline at end of file diff --git a/src/apps/callflows/submodules/faxbox/faxbox.js b/src/apps/callflows/submodules/faxbox/faxbox.js new file mode 100644 index 0000000..741364e --- /dev/null +++ b/src/apps/callflows/submodules/faxbox/faxbox.js @@ -0,0 +1,680 @@ +define(function(require){ + var $ = require('jquery'), + _ = require('underscore'), + monster = require('monster'), + timezone = require('monster-timezone'); + + var app = { + requests: {}, + + subscribe: { + 'callflows.fetchActions': 'faxboxDefineActions', + 'callflows.faxbox.edit': '_faxboxEdit' + }, + + faxboxDefineActions: function(args) { + var self = this, + callflow_nodes = args.actions; + + $.extend(callflow_nodes, { + 'faxbox[id=*]': { + name: self.i18n.active().callflows.faxbox.faxboxes_label, + icon: 'printer2', + category: self.i18n.active().oldCallflows.advanced_cat, + module: 'faxbox', + tip: self.i18n.active().callflows.faxbox.faxbox_tip, + data: { + }, + rules: [ + { + type: 'quantity', + maxSize: '1' + } + ], + isUsable: 'true', + weight: 130, + caption: function(node, caption_map) { + var id = node.getMetadata('id'), + returned_value = ''; + + if(id in caption_map) { + returned_value = caption_map[id].name; + } + + return returned_value; + }, + edit: function(node, callback) { + var _this = this; + + self.faxboxList(function(data, status) { + var popup_html = $(monster.template(self, 'faxbox-callflowEdit', { + items: _.sortBy(data, 'name'), + selected: node.getMetadata('id') || '' + })), + popup; + + if($('#faxbox_selector option:selected', popup_html).val() == undefined) { + $('#edit_link', popup_html).hide(); + } + + $('.inline_action', popup_html).click(function(ev) { + var _data = ($(this).data('action') == 'edit') ? + { id: $('#faxbox_selector', popup_html).val() } : {}; + + ev.preventDefault(); + + self.faxboxPopupEdit({ + data: _data, + callback: function(_data) { + node.setMetadata('id', _data.id || 'null'); + + node.caption = _data.name || ''; + + popup.dialog('close'); + } + }); + }); + + $('#add', popup_html).click(function() { + node.setMetadata('id', $('#faxbox_selector', popup_html).val()); + + node.caption = $('#faxbox_selector option:selected', popup_html).text(); + + popup.dialog('close'); + }); + + popup = monster.ui.dialog(popup_html, { + title: self.i18n.active().callflows.faxbox.voicemail_title, + minHeight: '0', + beforeClose: function() { + if(typeof callback == 'function') { + callback(); + } + } + }); + }); + }, + listEntities: function(callback) { + self.callApi({ + resource: 'faxbox.list', + data: { + accountId: self.accountId, + filters: { paginate:false } + }, + success: function(data, status) { + callback && callback(data.data); + } + }); + }, + editEntity: 'callflows.faxbox.edit' + } + }); + }, + + faxboxPopupEdit: function(args) { + var self = this, + popup_html = popup_html = $('
    '), + data = args.data, + callback = args.callback, + data_defaults = args.data_defaults || {}, + popup; + + self.faxboxEdit(data, popup_html, $('.inline_content', popup_html), { + save_success: function(_data) { + popup.dialog('close'); + + if ( typeof callback == 'function' ) { + callback(_data); + } + }, + delete_success: function() { + popup.dialog('close'); + + if ( typeof callback == 'function' ) { + callback({ data: {} }); + } + }, + after_render: function() { + popup = monster.ui.dialog(popup_html, { + title: self.i18n.active().callflows.faxbox[(data.id ? 'edit' : 'create').concat('_faxbox')] + }); + } + }, data_defaults); + }, + + // Added for the subscribed event to avoid refactoring faxboxEdit + _faxboxEdit: function(args) { + var self = this; + self.faxboxEdit(args.data, args.parent, args.target, args.callbacks, args.data_defaults); + }, + + faxboxEdit: function(data, _parent, _target, _callbacks) { + var self = this, + parent = _parent || $('#faxbox-content'), + target = _target || $('#faxbox-view', parent), + _callbacks = _callbacks || {}, + callbacks = { + save_success: _callbacks.save_success || function(_data) { + self.faxboxRenderList(parent); + + self.faxboxEdit({ id: _data.id }, parent, target, callbacks); + }, + delete_success: _callbacks.delete_success || function() { + target.empty(); + + self.faxboxRenderList(parent); + }, + delete_error: _callbacks.delete_error, + after_render: _callbacks.after_render + }; + + monster.parallel({ + faxbox: function(callback) { + if (typeof data === 'object' && data.id) { + self.faxboxGet(data.id, function(_data, status) { + _data.id = data.id; + + callback(null, _data); + }); + } else { + callback(null, {}); + } + }, + user_list: function(callback) { + self.callApi({ + resource: 'user.list', + data: { + accountId: self.accountId, + filters: { paginate:false } + }, + success: function(_data, status) { + _data.data.sort(function(a, b){ + if(a.hasOwnProperty('first_name') && a.hasOwnProperty('last_name') && b.hasOwnProperty('first_name') && b.hasOwnProperty('last_name')) { + return a.first_name.concat(' ', a.last_name).toLowerCase() > b.first_name.concat(' ', b.last_name).toLowerCase() ? 1 : -1; + } + else { + return 1; + } + }); + + _data.data.unshift({ + id: '', + first_name: self.i18n.active().callflows.faxbox.no, + last_name: self.i18n.active().callflows.faxbox.owner + }); + + callback(null, _data.data); + } + }); + }, + current_user: function(callback) { + if (!monster.util.isMasquerading()) { + self.faxboxGetUser(self.userId, function(_data, status) { + callback(null, _data); + }); + } + else { + callback(null, {}); + } + } + }, + function(err, results) { + if (!data.hasOwnProperty('id')) { + if (_.size(results.current_user) === 0) { + results.faxbox = $.extend(true, self.faxboxGetDefaultSettings(), results.faxbox); + } + else { + results.faxbox = $.extend(true, self.faxboxGetDefaultSettings(results.current_user), results.faxbox); + } + } + + delete results.current_user; + + self.faxboxRender(results, target, callbacks); + + if (typeof callbacks.after_render === 'function') { + callbacks.after_render(); + } + } + ); + }, + + faxboxRender: function(data, target, callbacks) { + var self = this, + faxbox_html = $(monster.template(self, 'faxbox-edit', { + faxbox: self.faxboxNormalizedData(data.faxbox), + users: data.user_list + })); + + timezone.populateDropdown($('#fax_timezone', faxbox_html), data.faxbox.fax_timezone||'inherit', {inherit: self.i18n.active().defaultTimezone}); + + $('*[rel=popover]:not([type="text"])', faxbox_html).popover({ + trigger: 'hover' + }); + + $('*[rel=popover][type="text"]', faxbox_html).popover({ + trigger: 'focus' + }); + + self.winkstartTabs(faxbox_html); + + if (!data.faxbox.hasOwnProperty('id')) { + $('#owner_id', faxbox_html).change(function(ev) { + if ($(this).val()) { + self.faxboxGetUser($(this).val(),function(_data, status) { + data.faxbox = self.faxboxGetDefaultSettings(_data); + $('#edit_link', faxbox_html).show(); + self.faxboxRender(data, target, callbacks); + }); + } else { + data.faxbox = self.faxboxGetDefaultSettings(); + $('#edit_link', faxbox_html).hide(); + self.faxboxRender(data, target, callbacks); + } + }); + } + else { + $('#owner_id', faxbox_html).change(function(ev) { + var currentFaxbox = monster.ui.getFormData('faxbox_form'); + + if ($(this).val()) { + $('[id$="bound_notification_email"]', faxbox_html).each(function(idx, el) { + $(el).attr('disabled', true); + }); + + self.faxboxGetUser($(this).val(), function(_data, status) { + data.faxbox = $.extend(true, {}, self.faxboxGetDefaultSettings(), data.faxbox, currentFaxbox, { + cloud_connector_claim_url: faxbox_html.find('#cloud_connector_claim_url').attr('href'), + notifications: { + inbound: { + email: { + send_to: _data.email || _data.username + } + }, + outbound: { + email: { + send_to: _data.email || _data.username + } + } + } + }); + + $('#edit_link', faxbox_html).hide(); + self.faxboxRender(data, target, callbacks); + }); + } + else { + $('[id$="bound_notification_email"]', faxbox_html).each(function(idx, el) { + $(el).attr('disabled', false); + }); + } + }); + } + + if(!$('#owner_id', faxbox_html).val()) { + $('#edit_link', faxbox_html).hide(); + } + + $('.inline-action', faxbox_html).click(function(ev) { + var _data = $(this).data('action') == 'edit' ? { id: $('#owner_id', faxbox_html).val() } : {}, + _id = _data.id; + + monster.pub('callflows.user.popupEdit', { + data: _data, + callflow: function(_data) { + /* Create */ + if(!_id) { + $('#owner_id', faxbox_html).append('') + $('#owner_id', faxbox_html).val(_data.id); + } + else { + /* Update */ + if('id' in _data) { + $('#owner_id #'+_data.id, faxbox_html).text(_data.first_name + ' ' + _data.last_name); + } + /* Delete */ + else { + $('#owner_id #'+_id, faxbox_html).remove(); + } + } + } + }); + }); + + $('#caller_id', faxbox_html).change(function(ev) { + var number = $(this).val(), + fax_identity = $('#fax_identity', faxbox_html); + + if (/^(\+1|1)([0-9]{10})$|^([0-9]{10})$/.test(number)) { + if (/^(\+1)/.test(number)) { + fax_identity.val(number.replace(/^\+1([0-9]{3})([0-9]{3})([0-9]{4})$/, '+1 ($1) $2-$3')); + } else if (/^1([0-9]{10})$/.test(number)) { + fax_identity.val(number.replace(/^1([0-9]{3})([0-9]{3})([0-9]{4})$/, '+1 ($1) $2-$3')); + } else { + fax_identity.val(number.replace(/^([0-9]{3})([0-9]{3})([0-9]{4})$/, '+1 ($1) $2-$3')); + } + } else { + fax_identity.val(''); + } + }); + + $('.faxbox-save', faxbox_html).click(function(ev) { + ev.preventDefault(); + + var form_html = $('#faxbox_form', faxbox_html), + form_data = monster.ui.getFormData('faxbox_form'), + word_reg = /^[\w\s'-]+/ + + monster.ui.validate(form_html, { + rules: { + name: { + required: true + }, + 'caller_name': { + regex: word_reg + }, + 'fax_header': { + regex: word_reg + }, + retries: { + regex: /^[0-4]/ + } + }, + messages: { + 'caller_name': { + regex: self.i18n.active().callflows.faxbox.validation.words + }, + 'fax_header': { + regex: self.i18n.active().callflows.faxbox.validation.words + }, + retries: { + regex: 'Please enter a numeric value between 0 and 4' + } + } + }); + + var $this = $(this); + + if(!$this.hasClass('disabled')) { + $this.addClass('disabled'); + + if (monster.ui.valid(form_html)) { + self.faxboxSave(form_data, data.faxbox, function(data) { + $this.removeClass('disabled'); + callbacks && callbacks.hasOwnProperty('save_success') && callbacks.save_success(data); + }, function(data) { + $this.removeClass('disabled'); + }); + } + else { + $this.removeClass('disabled'); + } + } + }); + + $('.faxbox-delete', faxbox_html).click(function(ev) { + ev.preventDefault(); + + monster.ui.confirm(self.i18n.active().callflows.faxbox.are_you_sure_you_want_to_delete, function() { + self.faxboxDelete(data.faxbox, callbacks.delete_success, callbacks.delete_error); + }); + }); + + target + .empty() + .append(faxbox_html); + }, + + faxboxRenderList: function(parent) { + var self = this; + + self.faxboxList(function(data, status) { + var map_crossbar_data = function(data) { + var new_list = []; + + if(data.length > 0) { + $.each(data, function(key, val) { + new_list.push({ + id: val.id, + title: val.name || self.i18n.active().callflows.faxbox.no_name + }); + }); + } + + new_list.sort(function(a, b) { + return a.title.toLowerCase() < b.title.toLowerCase() ? -1 : 1; + }); + + return new_list; + }; + }); + }, + + faxboxGetDefaultSettings: function(user) { + var self = this, + default_faxbox = { + name: '', + caller_name: '', + fax_header: '', + fax_timezone: 'inherit', + retries: 1, + notifications: { + inbound: { + email: { + send_to: '' + } + }, + outbound: { + email: { + send_to: '' + } + } + } + }; + + if (typeof user === 'undefined') { + return default_faxbox; + } else { + return $.extend(true, {}, default_faxbox, { + name: user.first_name.concat(' ', user.last_name, self.i18n.active().callflows.faxbox.default_settings_name_extension), + caller_name: user.first_name.concat(' ', user.last_name), + fax_header: monster.config.whitelabel.companyName.concat(self.i18n.active().callflows.faxbox.default_settings_header_extension), + owner_id: user.id, + notifications: { + inbound: { + email: { + send_to: user.email || user.username + } + }, + outbound: { + email: { + send_to: user.email || user.username + } + } + } + } + ); + } + }, + + faxboxSave: function(form_data, data, success, error) { + var self = this, + normalized_data = self.faxboxNormalizedData($.extend(true, {}, data, form_data)); + + if(typeof data == 'object' && data.id) { + self.faxboxUpdate(normalized_data, function(_data, status) { + if(typeof success == 'function') { + success(_data, status, 'update'); + } + }, + function(_data, status) { + if(typeof error == 'function') { + error(_data, status, 'update'); + } + } + ); + } else { + self.faxboxCreate(normalized_data, function(_data, status) { + if(typeof success == 'function') { + success(_data, status, 'create'); + } + }, + function(_data, status) { + if(typeof error == 'function') { + error(_data, status, 'create'); + } + } + ); + } + }, + + faxboxNormalizedData: function(form_data) { + if (form_data.hasOwnProperty('notifications')) { + if (form_data.notifications.hasOwnProperty('inbound') && form_data.notifications.inbound.hasOwnProperty('email') && form_data.notifications.inbound.email.hasOwnProperty('send_to') && form_data.notifications.inbound.email.send_to.length) { + var inbound = form_data.notifications.inbound.email.send_to; + form_data.notifications.inbound.email.send_to = inbound instanceof Array ? inbound.join(',') : inbound.replace(/\s/g, '').split(','); + } else { + delete form_data.notifications.inbound.email.send_to; + } + + if (form_data.notifications.hasOwnProperty('outbound') && form_data.notifications.outbound.hasOwnProperty('email') && form_data.notifications.outbound.email.hasOwnProperty('send_to') && form_data.notifications.outbound.email.send_to.length) { + var outbound = form_data.notifications.outbound.email.send_to; + form_data.notifications.outbound.email.send_to = outbound instanceof Array ? outbound.join(',') : outbound.replace(/\s/g, '').split(','); + } else { + delete form_data.notifications.outbound.email.send_to; + } + } + + if (form_data.hasOwnProperty('smtp_permission_list')) { + if (form_data.smtp_permission_list === '') { + delete form_data.smtp_permission_list; + } else { + var list = form_data.smtp_permission_list; + + form_data.smtp_permission_list = list instanceof Array ? list.join(',') : list.replace(/\s/g, '').split(','); + } + } + + if (form_data.hasOwnProperty('custom_smtp_email_address') && form_data.custom_smtp_email_address === '') { + delete form_data.custom_smtp_email_address; + } + + if (form_data.hasOwnProperty('owner_id') && form_data.owner_id === '') { + delete form_data.owner_id; + } + + if(form_data.fax_timezone && form_data.fax_timezone === 'inherit') { + delete form_data.fax_timezone; + } + + return form_data; + }, + + faxboxList: function(callback) { + var self = this; + + self.callApi({ + resource: 'faxbox.list', + data: { + accountId: self.accountId, + filters: { paginate:false } + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + faxboxGet: function(faxboxId, callback) { + var self = this; + + self.callApi({ + resource: 'faxbox.get', + data: { + accountId: self.accountId, + faxboxId: faxboxId + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + faxboxCreate: function(data, callback, error) { + var self = this; + + self.callApi({ + resource: 'faxbox.create', + data: { + accountId: self.accountId, + data: data + }, + success: function(data) { + callback && callback(data.data); + }, + error: function(data) { + error && error(data.data); + } + }); + }, + + faxboxUpdate: function(data, callback, error) { + var self = this; + + self.callApi({ + resource: 'faxbox.update', + data: { + accountId: self.accountId, + faxboxId: data.id, + data: data + }, + success: function(data) { + callback && callback(data.data); + }, + error: function(data) { + error && error(data.data); + } + }); + }, + + faxboxDelete: function(data, callbackSuccess, callbackError) { + var self = this; + + if (typeof data === 'object' && data.hasOwnProperty('id')) { + self.callApi({ + resource: 'faxbox.delete', + data: { + accountId: self.accountId, + faxboxId: data.id + }, + success: function(data) { + callbackSuccess && callbackSuccess(data.data); + }, + error: function(error) { + callbackError && callbackError(); + } + }); + } + }, + + faxboxGetUser: function(userId, callbackSuccess, callbackError) { + var self = this; + + self.callApi({ + resource: 'user.get', + data: { + accountId: self.accountId, + userId: userId + }, + success: function(data, status) { + callbackSuccess && callbackSuccess(data.data); + }, + error: function(data, status) { + callbackError && callbackError(); + } + }); + } + }; + + return app; +}); diff --git a/src/apps/callflows/submodules/featurecodes/featurecodes.css b/src/apps/callflows/submodules/featurecodes/featurecodes.css new file mode 100644 index 0000000..65b2d23 --- /dev/null +++ b/src/apps/callflows/submodules/featurecodes/featurecodes.css @@ -0,0 +1,48 @@ +#featurecode_view form { + background-color: #f0f0f9; + border: 1px solid #909099; + border-radius: 2px; + margin: auto; + max-width: 1080px; + min-width: 400px; + padding: 20px; +} + +#featurecode_view .action-bar { + border-top: 1px solid #c0c0c9; + margin-top: 40px; + padding-top: 20px; +} + + +#featurecode_view .add-on .featurecode_enabled { + margin-top: 0; +} + +#featurecode_view .add-on.empty { + border: 1px solid #dadada; +} + +#featurecode_view .input-append { + display: inline-block; +} + +#featurecode_view .edit-configuration-link { + margin-left: 10px; +} + +#parking_settings_popup { + width: 450px; +} + +#parking_settings_popup form { + margin: 0; +} + +#parking_settings_popup form .controls > * { + display: block; +} + +#parking_settings_popup label.monster-invalid { + margin-top: 0; +} \ No newline at end of file diff --git a/src/apps/callflows/submodules/featurecodes/featurecodes.js b/src/apps/callflows/submodules/featurecodes/featurecodes.js new file mode 100644 index 0000000..43b5e44 --- /dev/null +++ b/src/apps/callflows/submodules/featurecodes/featurecodes.js @@ -0,0 +1,983 @@ +define(function(require){ + var $ = require('jquery'), + _ = require('underscore'), + monster = require('monster'), + toastr = require('toastr'); + + var app = { + requests: {}, + + subscribe: { + 'callflows.featurecode.render': 'featureCodeRender' + }, + + featureCodeRender: function(pContainer) { + var self = this, + container = pContainer || $('.callflow-edition'); + + self.featureCodeGetData(function(featureCodes) { + var formattedData = self.featureCodeFormatData(featureCodes), + template = $(monster.template(self, 'featurecodes-view', formattedData)); + + self.featureCodeBindEvents(template, formattedData.actions); + + container.empty() + .append(template); + }); + }, + + featureCodeGetData: function(callback) { + var self = this; + + self.featureCodeList(function(data) { + callback && callback(data); + }); + }, + + featureCodeFormatData: function(data) { + var self = this, + actions = {}, + categories = {}, + formattedData = { + categories: {}, + actions: {} + }; + + self.featureCodesDefine(actions); + + _.each(data, function(callflow) { + if (callflow.hasOwnProperty('featurecode') && callflow.featurecode !== false) { + if (actions.hasOwnProperty(callflow.featurecode.name)) { + actions[callflow.featurecode.name].id = callflow.id; + actions[callflow.featurecode.name].enabled = true; + actions[callflow.featurecode.name].number = callflow.featurecode.number.replace('\\', ''); + } + } + }); + + $.each(actions, function(i, action) { + this.tag = i; + this.number = typeof action.number === 'undefined' ? action.default_number : action.number; + this.hasConfig = this.hasOwnProperty('editConfiguration'); + + if (action.hasOwnProperty('category')) { + categories[action.category] = categories[action.category] || []; + categories[action.category].push(action); + } + }); + + formattedData.categories = categories; + formattedData.actions = actions; + + return formattedData; + }, + + featureCodeBindEvents: function(template, actions) { + var self = this; + + monster.ui.tooltips(template); + + template.find('.featurecode_enabled').each(function() { + var action_wrapper = $(this).parents('.action_wrapper'), + number_field = action_wrapper.find('.featurecode-number'); + + !$(this).is(':checked') ? $(number_field).attr('disabled', '') : $(number_field).removeAttr('disabled'); + }); + + template.find('.featurecode-number').on('blur keyup focus', function() { + var action_wrapper = $(this).parents('.action_wrapper'); + + action_wrapper.data('number', $(this).val()); + + $(this).val() !== actions[action_wrapper.data('action')].number ? action_wrapper.addClass('changed') : action_wrapper.removeClass('changed'); + }); + + template.find('.featurecode_enabled').on('change', function() { + //$('.featurecode_enabled', template).change(function() { + var $this = $(this), + action_wrapper = $this.parents('.action_wrapper'), + number_field = action_wrapper.find('.featurecode-number'); + + if(!$this.is(':checked') && action_wrapper.data('enabled') === true) { + action_wrapper.addClass('disabled'); + } else if($this.is(':checked') && action_wrapper.data('enabled') === false){ + action_wrapper.addClass('enabled'); + } else { + action_wrapper.removeClass('enabled'); + action_wrapper.removeClass('disabled'); + } + + !$this.is(':checked') ? number_field.attr('disabled', '') : number_field.removeAttr('disabled'); + }); + + template.find('.featurecode-save').on('click', function(e) { + var $this = $(this); + e.preventDefault(); + if(!$this.hasClass('disabled')) { + var formData = self.featureCodeCleanFormData(template, actions); + + $this.addClass('disabled'); + + self.featureCodeMassUpdate(formData, function() { + toastr.success(self.i18n.active().callflows.featureCodes.successUpdate); + $this.removeClass('disabled'); + + self.featureCodeRender(); + }, + function() { + $this.removeClass('disabled'); + }); + } + }); + + _.each(actions, function(item) { + if (item.hasOwnProperty('editConfiguration')) { + template.find('[data-id="' + item.id + '"] .edit-configuration-link').on('click', function() { + item.editConfiguration(); + }); + } + }); + }, + + featureCodeList: function(callback) { + var self = this; + + self.callApi({ + resource: 'callflow.list', + data: { + accountId: self.accountId, + filters: { + paginate: false + } + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + featureCodeGet: function(id, callback) { + var self = this; + + self.callApi({ + resource: 'callflow.get', + data: { + accountId: self.accountId, + callflowId: id + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + featureCodeCleanFormData: function(template, actions) { + var self = this, + form_data = { + created_callflows: [], + deleted_callflows: [], + updated_callflows: [] + }; + + template.find('.enabled').each(function() { + var callflow = $(this).data(); + + // Casting in String, as back-end requires a String + callflow.number += ''; + + callflow.flow = { + data: actions[callflow.action].data, + module: actions[callflow.action].module, + children: {} + }; + + /* if(callflow.type === 'number') { callflow.type = 'numbers'} + if(callflow.type === 'pattern') { callflow.type = 'patterns'}*/ + + /* if a star is in the pattern, then we need to escape it */ + if(callflow.type === 'patterns' && typeof callflow.number === 'string') { + callflow.number = callflow.number.replace(/([*])/g,'\\$1'); + } + + callflow[callflow.type] = [actions[callflow.action].build_regex(callflow.number)]; + form_data.created_callflows.push(callflow); + }); + + + template.find('.disabled').each(function() { + var callflow = $(this).data(); + + callflow.number += ''; + + form_data.deleted_callflows.push(callflow); + }); + + template.find('.changed:not(.enabled, .disabled)').each(function() { + if($(this).data('enabled')) { + var callflow = $(this).data(); + + // Casting in String, as back-end requires a String + callflow.number += ''; + + callflow.flow = { + data: actions[callflow.action].data, + module: actions[callflow.action].module, + children: {} + }; + + /* if a star is in the pattern, then we need to escape it */ + if(callflow.type === 'patterns') { + callflow.number = callflow.number.replace(/([*])/g,'\\$1'); + } + + callflow[callflow.type] = [actions[callflow.action].build_regex(callflow.number)]; + + form_data.updated_callflows.push(callflow); + } + }); + + return form_data; + }, + + featureCodeCreate: function(data, callback) { + var self = this; + + self.callApi({ + resource: 'callflow.create', + data: { + accountId: self.accountId, + data: data + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + featureCodeDelete: function(callflowId, callback) { + var self = this; + + self.callApi({ + resource: 'callflow.delete', + data: { + accountId: self.accountId, + callflowId: callflowId + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + featureCodeUpdate: function(callflowId, data, callback) { + var self = this; + + self.callApi({ + resource: 'callflow.update', + data: { + accountId: self.accountId, + callflowId: callflowId, + data: data + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + featureCodeMassUpdate: function(form_data, callback, errorCallback) { + var self = this, + count = form_data.created_callflows.length + form_data.deleted_callflows.length + form_data.updated_callflows.length; + + if(count) { + var parallelRequests = {}; + + _.each(form_data.created_callflows, function(callflow) { + parallelRequests['create_' + callflow.action] = function(callback) { + var dataCallflow = { + flow: callflow.flow, + patterns: callflow.patterns, + numbers: callflow.numbers, + featurecode: { + name: callflow.action, + number: callflow.number + } + }; + + self.featureCodeCreate(dataCallflow, function(data) { + callback && callback(null, data); + }); + }; + }); + + _.each(form_data.updated_callflows, function(callflow) { + parallelRequests['update_' + callflow.action] = function(callback) { + var dataCallflow = { + flow: callflow.flow, + patterns: callflow.patterns, + numbers: callflow.numbers, + featurecode: { + name: callflow.action, + number: callflow.number + } + }; + + self.featureCodeUpdate(callflow.id, dataCallflow, function(data) { + callback && callback(null, data); + }); + }; + }); + + _.each(form_data.deleted_callflows, function(callflow) { + parallelRequests['delete_' + callflow.action] = function(callback) { + self.featureCodeDelete(callflow.id, function(data) { + callback && callback(null, data); + }); + }; + }); + + monster.parallel(parallelRequests, function(err, results) { + callback && callback(); + }); + } + else { + errorCallback && errorCallback(); + toastr.error(self.i18n.active().callflows.featureCodes.nothing_to_save); + } + }, + + featureCodesDefine: function(featurecodes) { + var self = this; + + $.extend(featurecodes, { + 'call_forward[action=activate]': { + name: self.i18n.active().callflows.featureCodes.enable_call_forward, + icon: 'phone', + category: self.i18n.active().callflows.featureCodes.call_forward_cat, + module: 'call_forward', + number_type: 'numbers', + data: { + action: 'activate' + }, + enabled: false, + hasStar: true, + default_number: '72', + number: this.default_number, + build_regex: function(number) { + return '*'+number; + } + }, + 'call_forward[action=deactivate]': { + name: self.i18n.active().callflows.featureCodes.disable_call_forward, + icon: 'phone', + category: self.i18n.active().callflows.featureCodes.call_forward_cat, + module: 'call_forward', + number_type: 'numbers', + data: { + action: 'deactivate' + }, + enabled: false, + hasStar: true, + default_number: '73', + number: this.default_number, + build_regex: function(number) { + return '*'+number; + } + }, + 'call_forward[action=toggle]': { + name: self.i18n.active().callflows.featureCodes.toggle_call_forward, + icon: 'phone', + category: self.i18n.active().callflows.featureCodes.call_forward_cat, + module: 'call_forward', + number_type: 'patterns', + data: { + action: 'toggle' + }, + enabled: false, + hasStar: true, + default_number: '74', + number: this.default_number, + build_regex: function(number) { + return '^\\*'+number+'([0-9]*)$'; + } + }, + 'call_forward[action=update]': { + name: self.i18n.active().callflows.featureCodes.update_call_forward, + icon: 'phone', + category: self.i18n.active().callflows.featureCodes.call_forward_cat, + module: 'call_forward', + number_type: 'numbers', + data: { + action: 'update' + }, + enabled: false, + hasStar: true, + default_number: '56', + number: this.default_number, + build_regex: function(number) { + return '*'+number; + } + }, + + 'hotdesk[action=login]': { + name: self.i18n.active().callflows.featureCodes.enable_hot_desking, + icon: 'phone', + category: self.i18n.active().callflows.featureCodes.hot_desking_cat, + module: 'hotdesk', + number_type: 'numbers', + data: { + action: 'login' + }, + enabled: false, + hasStar: true, + default_number: '11', + number: this.default_number, + build_regex: function(number) { + return '*'+number; + } + }, + 'hotdesk[action=logout]': { + name: self.i18n.active().callflows.featureCodes.disable_hot_desking, + icon: 'phone', + category: self.i18n.active().callflows.featureCodes.hot_desking_cat, + module: 'hotdesk', + number_type: 'numbers', + data: { + action: 'logout' + }, + enabled: false, + hasStar: true, + default_number: '12', + number: this.default_number, + build_regex: function(number) { + return '*'+number; + } + }, + 'hotdesk[action=toggle]': { + name: self.i18n.active().callflows.featureCodes.toggle_hot_desking, + icon: 'phone', + category: self.i18n.active().callflows.featureCodes.hot_desking_cat, + module: 'hotdesk', + number_type: 'numbers', + data: { + action: 'toggle' + }, + enabled: false, + hasStar: true, + default_number: '13', + number: this.default_number, + build_regex: function(number) { + return '*'+number; + } + }, + 'voicemail[action=check]': { + name: self.i18n.active().callflows.featureCodes.check_voicemail, + icon: 'phone', + category: self.i18n.active().callflows.featureCodes.miscellaneous_cat, + module: 'voicemail', + number_type: 'patterns', + data: { + action: 'check' + }, + enabled: false, + hasStar: true, + default_number: '97', + number: this.default_number, + build_regex: function(number) { + return '^\\*'+number+'([0-9]*)$'; + } + }, + 'voicemail[single_mailbox_login]': { + name: self.i18n.active().callflows.featureCodes.single_mailbox_login, + icon: 'phone', + category: self.i18n.active().callflows.featureCodes.miscellaneous_cat, + module: 'voicemail', + number_type: 'patterns', + data: { + action: 'check', + single_mailbox_login: true + }, + enabled: false, + hasStar: true, + default_number: '98', + number: this.default_number, + build_regex: function(number) { + return '^\\*'+number+'([0-9]*)$'; + } + }, + 'voicemail[action="direct"]': { + name: self.i18n.active().callflows.featureCodes.direct_to_voicemail, + category: self.i18n.active().callflows.featureCodes.miscellaneous_cat, + module: 'voicemail', + number_type: 'patterns', + data: { + action: 'compose' + }, + enabled: false, + hasStar: true, + default_number: '*', + number: this.default_number, + build_regex: function(number) { + return '^\\*'+number+'([0-9]*)$'; + } + }, + 'intercom': { + name: self.i18n.active().callflows.featureCodes.intercom, + icon: 'phone', + category: self.i18n.active().callflows.featureCodes.miscellaneous_cat, + module: 'intercom', + number_type: 'patterns', + data: { + }, + enabled: false, + hasStar: true, + default_number: '0', + number: this.default_number, + build_regex: function(number) { + return '^\\*'+number+'([0-9]*)$'; + } + }, + 'privacy[mode=full]': { + name: self.i18n.active().callflows.featureCodes.privacy, + icon: 'phone', + category: self.i18n.active().callflows.featureCodes.miscellaneous_cat, + module: 'privacy', + number_type: 'patterns', + data: { + mode: 'full' + }, + enabled: false, + hasStar: true, + default_number: '67', + number: this.default_number, + build_regex: function(number) { + return '^\\*'+number+'([0-9]*)$'; + } + }, + 'park_and_retrieve': { + name: self.i18n.active().callflows.featureCodes.park_and_retrieve, + icon: 'phone', + category: self.i18n.active().callflows.featureCodes.parking_cat, + module: 'park', + number_type: 'patterns', + data: { + action: 'auto' + }, + enabled: false, + hasStar: true, + editConfiguration: function() { + self.featureCodesEditParkingParkAndRetrieve(this); + }, + default_number: '3', + number: this.default_number, + build_regex: function(number) { + return '^\\*'+number+'([0-9]*)$'; + } + }, + 'valet': { + name: self.i18n.active().callflows.featureCodes.valet, + icon: 'phone', + category: self.i18n.active().callflows.featureCodes.parking_cat, + module: 'park', + number_type: 'numbers', + data: { + action: 'park' + }, + enabled: false, + hasStar: true, + editConfiguration: function() { + self.featureCodesEditParkingValet(this); + }, + default_number: '4', + number: this.default_number, + build_regex: function(number) { + return '*'+number; + } + }, + 'retrieve': { + name: self.i18n.active().callflows.featureCodes.retrieve, + icon: 'phone', + category: self.i18n.active().callflows.featureCodes.parking_cat, + module: 'park', + number_type: 'patterns', + data: { + action: 'retrieve' + }, + enabled: false, + hasStar: true, + default_number: '5', + number: this.default_number, + build_regex: function(number) { + return '^\\*'+number+'([0-9]*)$'; + } + }, + 'move': { + name: self.i18n.active().callflows.featureCodes.callMove, + icon: 'phone', + category: self.i18n.active().callflows.featureCodes.miscellaneous_cat, + module: 'move', + number_type: 'numbers', + data: { + }, + enabled: false, + hasStar: false, + default_number: '6683', + number: this.default_number, + build_regex: function(number) { + return number; + } + }, + /*'call_forward[action=on_busy_enable]': { + name: 'Enable Call-Forward on Busy', + icon: 'phone', + category: 'Call-Forward', + module: 'call_forward', + number_type: 'patterns', + data: { + action: 'on_busy_enable' + }, + enabled: false, + hasStar: true, + default_number: '90', + number: this.default_number, + build_regex: function(number) { + return '^\\*'+number+'([0-9]*)$'; + } + }, + 'call_forward[action=on_busy_disable]': { + name: 'Disable Call-Forward on Busy', + icon: 'phone', + category: 'Call-Forward', + module: 'call_forward', + number_type: 'numbers', + data: { + action: 'on_busy_disable' + }, + enabled: false, + hasStar: true, + default_number: '91', + number: this.default_number, + build_regex: function(number) { + return '*'+number; + } + }, + 'call_forward[action=no_answer_enable]': { + name: 'Enable Call-Forward No Answer', + icon: 'phone', + category: 'Call-Forward', + module: 'call_forward', + number_type: 'patterns', + data: { + action: 'no_answer_enable' + }, + enabled: false, + hasStar: true, + default_number: '53', + number: this.default_number, + build_regex: function(number) { + return '^\\*'+number+'([0-9]*)$'; + } + }, + 'call_forward[action=no_answer_disable]': { + name: 'Disable Call-Forward No Answer', + icon: 'phone', + category: 'Call-Forward', + module: 'call_forward', + number_type: 'numbers', + data: { + action: 'no_answer_disable' + }, + enabled: false, + hasStar: true, + default_number: '52', + number: this.default_number, + build_regex: function(number) { + return '*'+number; + } + }, + 'donotdisturb[action="enable"]': { + name: 'Enable Do not disturb', + icon: 'phone', + category: 'Do not disturb', + module: 'do_not_disturb', + number_type: 'patterns', + data: { + action: 'enable' + }, + enabled: false, + hasStar: true, + default_number: '78', + number: this.default_number, + build_regex: function(number) { + return '^\\*'+number+'([0-9]*)$'; + } + }, + 'donotdisturb[action="disable"]': { + name: 'Disable Do not disturb', + icon: 'phone', + category: 'Do not disturb', + module: 'do_not_disturb', + number_type: 'numbers', + data: { + action: 'disable' + }, + enabled: false, + hasStar: true, + default_number: '79', + number: this.default_number, + build_regex: function(number) { + return '*'+number; + } + }, + 'donotdisturb[action="toggle"]': { + name: 'Toggle Do not disturb', + icon: 'phone', + category: 'Do not disturb', + module: 'do_not_disturb', + number_type: 'patterns', + data: { + action: 'toggle' + }, + enabled: false, + hasStar: true, + default_number: '76', + number: this.default_number, + build_regex: function(number) { + return '^\\*'+number+'([0-9]*)$'; + } + }, + 'directory': { + name: 'Directory', + icon: 'phone', + category: 'Miscellaneous', + module: 'directory', + number_type: 'patterns', + data: { + action: '' + }, + enabled: false, + hasStar: true, + default_number: '411', + number: this.default_number, + build_regex: function(number) { + return '^\\*'+number+'([0-9]*)$'; + } + }, + 'time': { + name: 'Check Time', + icon: 'phone', + category: 'Miscellaneous', + module: 'time', + number_type: 'patterns', + data: { + action: '' + }, + enabled: false, + hasStar: true, + default_number: '60', + number: this.default_number, + build_regex: function(number) { + return '^\\*'+number+'([0-9]*)$'; + } + }, + 'call_waiting[action=enable]': { + name: 'Enable Call-Waiting', + icon: 'phone', + category: 'Miscellaneous', + module: 'call_waiting', + number_type: 'patterns', + data: { + action: 'enable' + }, + enabled: false, + hasStar: true, + default_number: '70', + number: this.default_number, + build_regex: function(number) { + return '^\\*'+number+'([0-9]*)$'; + } + }, + 'call_waiting[action=disable]': { + name: 'Disable Call-Waiting', + icon: 'phone', + category: 'Miscellaneous', + module: 'call_waiting', + number_type: 'numbers', + data: { + action: 'disable' + }, + enabled: false, + hasStar: true, + default_number: '71', + number: this.default_number, + build_regex: function(number) { + return '*'+number; + } + }, + + 'sound_test_service': { + name: 'Sound Test Service', + icon: 'phone', + category: 'Miscellaneous', + module: '', + number_type: 'patterns', + data: { + action: '' + }, + enabled: false, + hasStar: true, + default_number: '43', + number: this.default_number, + build_regex: function(number) { + return '^\\*'+number+'([0-9]*)$'; + } + }, + + 'call_recording': { + name: 'Call Recording', + icon: 'phone', + category: 'Miscellaneous', + module: 'call_recording', + number_type: 'patterns', + data: { + action: '' + }, + enabled: false, + hasStar: true, + default_number: '1', + number: this.default_number, + build_regex: function(number) { + return '^\\*'+number+'([0-9]*)$'; + } + }*/ + }); + }, + + featureCodesEditParkingParkAndRetrieve: function(featureCode) { + var self = this; + + self.featureCodeGet(featureCode.id, function(data) { + var popup, + formattedData = self.featureCodesFormatParkingData(data), + template = $(self.getTemplate({ + name: 'featurecodes-parking-parkandretrieve', + submodule: 'featurecodes', + data: formattedData + })); + + monster.ui.validate(template.find('#form_park_retrieve'), { + rules: { + 'default_ringback_timeout': { + 'digits': true + }, + 'default_callback_timeout': { + 'digits': true + } + } + }); + + monster.ui.tooltips(template); + + template.find('#save').on('click', function(e) { + e.preventDefault(); + + if (monster.ui.valid(template.find('#form_park_retrieve'))) { + var formData = monster.ui.getFormData('form_park_retrieve'), + dataToUpdate = self.featureCodesNormalizeData(data, formData); + + self.featureCodeUpdate(dataToUpdate.id, dataToUpdate, function() { + toastr.success(self.i18n.active().callflows.featureCodes.parkingParkAndRetrievePopup.successUpdate); + popup.dialog('close'); + }); + } + }); + + popup = monster.ui.dialog(template, { + title: self.i18n.active().callflows.featureCodes.parkingParkAndRetrievePopup.title + }); + }); + }, + + featureCodesEditParkingValet: function(featureCode) { + var self = this; + + self.featureCodeGet(featureCode.id, function(data) { + var popup, + formattedData = self.featureCodesFormatParkingData(data), + template = $(self.getTemplate({ + name: 'featurecodes-parking-valet', + submodule: 'featurecodes', + data: formattedData + })); + + monster.ui.validate(template.find('#form_valet'), { + rules: { + 'default_ringback_timeout': { + 'digits': true + }, + 'default_callback_timeout': { + 'digits': true + } + } + }); + + monster.ui.tooltips(template); + + template.find('#save').on('click', function(e) { + e.preventDefault(); + + if (monster.ui.valid(template.find('#form_valet'))) { + var formData = monster.ui.getFormData('form_valet'), + dataToUpdate = self.featureCodesNormalizeData(data, formData); + + self.featureCodeUpdate(dataToUpdate.id, dataToUpdate, function() { + toastr.success(self.i18n.active().callflows.featureCodes.parkingValetPopup.successUpdate); + popup.dialog('close'); + }); + } + }); + + popup = monster.ui.dialog(template, { + title: self.i18n.active().callflows.featureCodes.parkingValetPopup.title + }); + }); + }, + + featureCodesNormalizeData: function(data, formData) { + var self = this, + dataToUpdate = $.extend(true, {}, data); + + // If user leaves field empty, we want to delete the field, so it goes back to system default. + // Otherwise we transform seconds into milliseconds for back-end + if (formData.default_callback_timeout.length) { + dataToUpdate.flow.data.default_callback_timeout = parseInt(formData.default_callback_timeout) * 1000; + } else { + delete dataToUpdate.flow.data.default_callback_timeout; + } + + if (formData.default_ringback_timeout.length) { + dataToUpdate.flow.data.default_ringback_timeout = parseInt(formData.default_ringback_timeout) * 1000; + } else { + delete dataToUpdate.flow.data.default_ringback_timeout; + } + + return dataToUpdate; + }, + + featureCodesFormatParkingData: function(data) { + var formattedData = $.extend(true, {}, data.flow.data); + + if (formattedData.hasOwnProperty('default_callback_timeout')) { + formattedData.default_callback_timeout /= 1000; + } + + if (formattedData.hasOwnProperty('default_ringback_timeout')) { + formattedData.default_ringback_timeout /= 1000; + } + + return formattedData; + } + }; + + return app; +}); diff --git a/src/apps/callflows/submodules/featurecodes/views/featurecodes-parking-parkandretrieve.html b/src/apps/callflows/submodules/featurecodes/views/featurecodes-parking-parkandretrieve.html new file mode 100644 index 0000000..6abb8dd --- /dev/null +++ b/src/apps/callflows/submodules/featurecodes/views/featurecodes-parking-parkandretrieve.html @@ -0,0 +1,28 @@ +
    +
    + {{#monsterText 'info'}} + {{ i18n.callflows.featureCodes.infoSettings }} + {{/monsterText}} +
    + +
    +
    +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    +
    + diff --git a/src/apps/callflows/submodules/featurecodes/views/featurecodes-parking-valet.html b/src/apps/callflows/submodules/featurecodes/views/featurecodes-parking-valet.html new file mode 100644 index 0000000..d4508e7 --- /dev/null +++ b/src/apps/callflows/submodules/featurecodes/views/featurecodes-parking-valet.html @@ -0,0 +1,28 @@ +
    +
    + {{#monsterText 'info'}} + {{ i18n.callflows.featureCodes.infoSettings }} + {{/monsterText}} +
    + +
    +
    +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    +
    + diff --git a/src/apps/callflows/submodules/groups/groups.css b/src/apps/callflows/submodules/groups/groups.css new file mode 100644 index 0000000..797efe5 --- /dev/null +++ b/src/apps/callflows/submodules/groups/groups.css @@ -0,0 +1,289 @@ +.callflows-port#ring_group_popup .form_content .popup_field .media_action { + color: #05addc; + margin-left: 10px; +} + +.callflows-port#ring_group_popup #two_columns .wrapper { + width: 700px; +} + +.callflows-port#ring_group_popup #two_columns .sortable_li a.drag_btn { + margin-right: 0px; +} + +.callflows-port#ring_group_popup #two_columns .sortable_li .icon { + float: left; + margin-top: 3px; +} + +.callflows-port#ring_group_popup #two_columns .sortable_li .icon.head1 { + background-position: -477px -197px; +} + +.callflows-port#ring_group_popup #two_columns .sortable_li .icon.device { + background-position: -508px -166px; +} + +.callflows-port#ring_group_popup #two_columns .sortable_li .icon.trash { + background-position: -32px -68px; + margin-left: 10px; +} + +.callflows-port#ring_group_popup #two_columns .column.left { + border-radius: 0px 0px 5px 5px; + padding: 0px 0px 5px; +} + +.callflows-port#ring_group_popup #two_columns .column.left .search_box { + background: #AFAFAF; + height: 27px; +} + +.callflows-port#ring_group_popup #two_columns .column.left .search_box .searchsubmit1 { + margin-left: 18px; +} + +.callflows-port#ring_group_popup #two_columns .column.right { + width: 420px; +} + +.callflows-port#ring_group_popup.page_group #two_columns .column.right .item_name { + width: 315px; +} + +.callflows-port#ring_group_popup #two_columns .column.right .item_name { + width: 205px; + padding-left: 6px; +} + +.callflows-port#ring_group_popup #two_columns .actions_item { + font-size: 10px; + width: 39px; + float: left; + line-height: 28px; + height: 28px; + border-left: 1px solid #444444; +} + +.callflows-port#ring_group_popup #two_columns .options { + font-size: 10px; + width: 110px; + line-height: 28px; + height: 28px; + float: left; +} + +.callflows-port#ring_group_popup #two_columns .options .option { + height: 12px; + margin: 2px 5px 0; +} + +.callflows-port#ring_group_popup #two_columns .column.right ul.connect { + width: 420px; +} + +.callflows-port#ring_group_popup #two_columns .column.right .title_column .title{ + float: left; + width: 243px; + height: 28px; + line-height: 28px; +} + +.callflows-port#ring_group_popup.page_group #two_columns .column.right .title_column .title{ + width: 353px; +} + +.callflows-port#ring_group_popup .form_content .popup_field input { + margin: 0px; +} + +.callflows-port#ring_group_popup .form_content .popup_field select { + margin: 0px; + width: auto; +} + +.callflows-port#ring_group_popup .form_content .popup_field { + text-align: left; +} + +.callflows-port#ring_group_popup #two_columns .wrapper .settings_tabs { + margin: 0px; +} + +.callflows-port#ring_group_popup #two_columns .wrapper .settings_tabs > li { + width: 71px; + height: 22px; + line-height: 22px; + border: 1px solid #888; + float: left; + border-radius: 0px; + color: #fff; + background: #b2b2b2; /* Old browsers */ + background: -moz-linear-gradient(top, #b2b2b2 1%, #7c7c7c 50%, #333333 100%); /* FF3.6+ */ + background: -webkit-gradient(linear, left top, left bottom, color-stop(1%,#b2b2b2), color-stop(50%,#7c7c7c), color-stop(100%,#333333)); /* Chrome,Safari4+ */ + background: -webkit-linear-gradient(top, #b2b2b2 1%,#7c7c7c 50%,#333333 100%); /* Chrome10+,Safari5.1+ */ + background: -o-linear-gradient(top, #b2b2b2 1%,#7c7c7c 50%,#333333 100%); /* Opera 11.10+ */ + background: -ms-linear-gradient(top, #b2b2b2 1%,#7c7c7c 50%,#333333 100%); /* IE10+ */ + background: linear-gradient(top, #b2b2b2 1%,#7c7c7c 50%,#333333 100%); /* W3C */ + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#b2b2b2', endColorstr='#333333',GradientType=0 ); /* IE6-9 */ +} + +.callflows-port#ring_group_popup #two_columns .wrapper .settings_tabs > li:first-child { + border-radius: 5px 0px 0px 0px; +} + +.callflows-port#ring_group_popup #two_columns .wrapper .settings_tabs > li:last-of-type { + border-radius: 0px 5px 0px 0px; + width: 72px; +} + +.callflows-port#ring_group_popup #two_columns .wrapper .settings_tabs > li.current{ + background: #05addc; /* Old browsers */ + background: -moz-linear-gradient(top, #05addc 0%, #2989d8 50%, #203838 100%); /* FF3.6+ */ + background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#05addc), color-stop(50%,#2989d8), color-stop(100%,#203838)); /* Chrome,Safari4+ */ + background: -webkit-linear-gradient(top, #05addc 0%,#2989d8 50%,#203838 100%); /* Chrome10+,Safari5.1+ */ + background: -o-linear-gradient(top, #05addc 0%,#2989d8 50%,#203838 100%); /* Opera 11.10+ */ + background: -ms-linear-gradient(top, #05addc 0%,#2989d8 50%,#203838 100%); /* IE10+ */ + background: linear-gradient(top, #05addc 0%,#2989d8 50%,#203838 100%); /* W3C */ + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#05addc', endColorstr='#203838',GradientType=0 ); /* IE6-9 */ +} + +.callflows-port#ring_group_popup #two_columns .wrapper .settings_tabs > li > a{ + outline: none; + text-decoration: none; + color: #fff; + display: block; + height: 22px; +} + +/* Groups entity */ +#group-form #table_wrapper { + display: inline-block; + text-align: center; + width: 100%; +} + +#group-form #tab_users { + border: 2px solid #666666; + border-radius: 5px 5px 0px 0px; + color: #666666; + width: 330px; + max-height: 342px; + display: inline-block; +} + +#group-form #tab_users .rows { + max-height: 310px; + overflow: auto; +} + +#group-form #tab_users .action_user { + color: #666666; + cursor: pointer; + text-decoration: underline; + line-height: 30px; +} + +#group-form #tab_users .action_user:not(:first-child) { + margin-left: 10px; +} +#group-form #tab_users .action_user:hover { + color: #05addc; +} + +#group-form #tab_users .column.first:not(:last-child) { + border-right: 1px solid #A6A6A6; +} + +#group-form #tab_users .column { + float: left; + text-align: center; + height: 30px; + line-height: 30px; +} + +#group-form #tab_users .column.first { + width: 250px; + overflow: hidden; + text-align:center; + cursor: move; +} + +#group-form #tab_users .column.second { + width: 59px; +} + +#group-form #tab_users .column.merged { + width: 330px; +} + +#group-form #tab_users .row { + height: 30px; + margin-left: 0px; +} + +#group-form #tab_users .row.title { + background-color: #dddddd !important; + border-bottom: 2px solid #666666 !important; + border-radius: 5px 5px 0px 0px; + font-weight: bold; +} + +#group-form #tab_users .row:not(:last-child) { + border-bottom: 1px solid #A6A6A6; +} + +#group-form #tab_users .row:nth-child(odd) { + background-color: #eeeeee; +} + +#group-form #tab_users .row:nth-child(even) { + background-color: #dddddd; +} + +#group-form #tab_users .icon.userportal { + background-position: -476px -196px; +} + +#group-form .add_endpoint_wrapper{ + float: right; + width: 230px; +} + +#group-form .add_endpoint { + color: #666666; + background: #666666; + border-radius: 5px 5px 5px 5px; +} + +#group-form .add_endpoint:not(:last-child) { + margin-bottom: 15px; +} + +#group-form .add_endpoint .add_content_wrapper { + background: #EEEEEE; + border-radius: 0 0 5px 5px; + padding: 10px; + text-align: center; +} + +#group-form .add_endpoint .add_endpoint_title { + color: #eeeeee; + font-weight: bold; + height: 25px; + line-height: 25px; + text-align: center; + border-radius: 5px 5px 0 0; +} + +#group-form .add_endpoint .add_endpoint_div { + margin-top: 10px; +} + +#group-form .add_endpoint .add_endpoint_div a { + color: #333333; +} + +#group-form .add_endpoint .add_endpoint_div:hover a { + color: #05addc; +} diff --git a/src/apps/callflows/submodules/groups/groups.js b/src/apps/callflows/submodules/groups/groups.js new file mode 100644 index 0000000..bf8752d --- /dev/null +++ b/src/apps/callflows/submodules/groups/groups.js @@ -0,0 +1,1530 @@ +define(function(require){ + var $ = require('jquery'), + _ = require('underscore'), + monster = require('monster'); + + var app = { + requests: {}, + + subscribe: { + 'callflows.fetchActions': 'groupsDefineActions', + 'callflows.groups.edit': '_groupsEdit', + }, + + groupsRender: function(data, target, callbacks){ + var self = this, + groups_html = $(monster.template(self, 'groups-edit', data)), + groupForm = groups_html.find('#group-form'); + + monster.ui.validate(groupForm, { + rules: { + 'name': { + required: true + } + } + }); + + self.winkstartTabs(groups_html); + + $('#tab_users > .rows', groups_html).sortable({ + handle: '.column.first' + }); + + self.groupsRenderEndpointList(data, groups_html); + + $('.group-save', groups_html).click(function(ev) { + ev.preventDefault(); + + var $this = $(this); + + if(!$this.hasClass('disabled')) { + $this.addClass('disabled'); + + if(monster.ui.valid(groupForm)) { + var form_data = monster.ui.getFormData('group-form'); + self.groupsCleanFormData(form_data, data.field_data); + + form_data.endpoints = {}; + + $('.rows .row:not(#row_no_data)', groups_html).each(function(k, v) { + form_data.endpoints[$(v).data('id')] = { + type: $(v).data('type'), + weight: k+1 + }; + }); + + delete data.data.resources; + delete data.data.endpoints; + + self.groupsSave(form_data, data, callbacks.save_success); + } + else { + $this.removeClass('disabled'); + monster.ui.alert(self.i18n.active().callflows.groups.there_were_errors_on_the_form); + } + } + }); + + $('.group-delete', groups_html).click(function(ev) { + ev.preventDefault(); + + monster.ui.confirm(self.i18n.active().callflows.groups.are_you_sure_you_want_to_delete, function() { + self.groupsDelete(data, callbacks.delete_success); + }); + }); + + var add_user = function() { + var $user = $('#select_user_id', groups_html); + + if($user.val() != 'empty_option_user') { + var user_id = $user.val(); + + $.each(data.field_data.users, function(k, v) { + if(user_id === v.id) { + var user_data = { + endpoint_id: user_id, + endpoint_type: 'user', + endpoint_name: v.first_name + ' ' + v.last_name, + }; + + data.data.endpoints.push(user_data); + + data.data.endpoints.sort(function(a,b){ + return a.endpoint_name.toLowerCase() > b.endpoint_name.toLowerCase(); + }); + + self.groupsRenderEndpointList(data, groups_html); + $user.val('empty_option_user'); + } + }); + } + }, + add_device = function() { + var $device = $('#select_device_id', groups_html); + + if($device.val() != 'empty_option_device') { + var device_id = $device.val(); + + $.each(data.field_data.devices, function(k, v){ + if(device_id === v.id) { + var device_data = { + endpoint_id: device_id, + endpoint_type: 'device', + endpoint_name: v.name, + }; + + data.data.endpoints.push(device_data); + + data.data.endpoints.sort(function(a,b){ + return a.endpoint_name.toLowerCase() > b.endpoint_name.toLowerCase(); + }); + + self.groupsRenderEndpointList(data, groups_html); + + $device.val('empty_option_device'); + } + + }); + } + }; + + $('#select_user_id', groups_html).change(function() { + add_user(); + }); + $('#select_device_id', groups_html).change(function() { + add_device(); + }); + + groups_html.find('#group-form').on('click', '.action_endpoint.delete', function() { + var endpoint_id = $(this).data('id'); + //removes it from the grid + $('#row_endpoint_'+endpoint_id, groups_html).remove(); + //re-add it to the dropdown + $('#option_endpoint_'+endpoint_id, groups_html).show(); + //if grid empty, add no data line + if($('.rows .row', groups_html).size() === 0) { + $('.rows', groups_html).append(monster.template(self, 'groups-endpoint_row')); + } + + /* TODO For some reason splice doesn't work and I don't have time to make it better for now */ + var new_list = []; + + $.each(data.data.endpoints, function(k, v) { + if(!(v.endpoint_id === endpoint_id)) { + new_list.push(v); + } + }); + + data.data.endpoints = new_list; + }); + + (target) + .empty() + .append(groups_html); + }, + + // Added for the subscribed event to avoid refactoring mediaEdit + _groupsEdit: function(args) { + var self = this; + self.groupsEdit(args.data, args.parent, args.target, args.callbacks, args.data_defaults); + }, + + groupsEdit: function(data, _parent, _target, _callbacks, data_defaults){ + var self = this, + parent = _parent || $('#groups-content'), + target = _target || $('#groups-view', parent), + callbacks = { + save_success: _callbacks.save_success, + save_error: _callbacks.save_error, + delete_success: _callbacks.delete_success, + delete_error: _callbacks.delete_error, + after_render: _callbacks.after_render + }, + defaults = { + data: $.extend(true, { + endpoints: {}, + music_on_hold: {} + }, data_defaults || {}), + field_data: {} + }; + + monster.parallel({ + 'device_list': function(callback) { + self.callApi({ + resource: 'device.list', + data: { + accountId: self.accountId + }, + success: function(data) { + defaults.field_data.devices = data.data; + callback(null, data) + } + }); + }, + + 'user_list': function(callback) { + self.callApi({ + resource: 'user.list', + data: { + accountId: self.accountId + }, + success: function(data) { + defaults.field_data.users = data.data; + callback(null, data) + } + }); + }, + + 'groups_get': function(callback) { + if(typeof data === 'object' && data.id) { + self.callApi({ + resource: 'group.get', + data: { + accountId: self.accountId, + groupId: data.id + }, + success: function(data) { + callback(null, data) + } + }); + } + else { + callback(null, {}); + } + }, + }, + function(err, results) { + var render_data = defaults; + + if(typeof data === 'object' && data.id) { + render_data = $.extend(true, defaults, results.groups_get); + } + + render_data = self.groupsFormatData(render_data); + + self.groupsRender(render_data, target, callbacks); + } + ); + }, + + groupsRenderEndpointList: function(data, parent) { + var self = this; + + $('.rows', parent).empty(); + + if('endpoints' in data.data && data.data.endpoints.length > 0) { + $.each(data.data.endpoints, function(k, item){ + $('.rows', parent).append(monster.template(self, 'groups-endpoint_row', item)); + $('#option_endpoint_'+item.endpoint_id, parent).hide(); + }); + } + else { + $('.rows', parent).empty() + .append(monster.template(self, 'groups-endpoint_row')); + } + }, + + groupsCleanFormData: function(form_data, field_data) { + delete form_data.extra; + }, + + groupsFormatData: function(data) { + var user_item, + endpoint_item, + list_endpoint = []; + + $.each(data.field_data.users, function(k, v) { + if(v.id in data.data.endpoints) { + endpoint_item = { + endpoint_type: 'user', + endpoint_id: v.id, + endpoint_name: v.first_name + ' ' + v.last_name, + endpoint_weight: data.data.endpoints[v.id].weight || 0 + }; + + list_endpoint.push(endpoint_item); + } + }); + + $.each(data.field_data.devices, function(k, v) { + if(v.id in data.data.endpoints) { + endpoint_item = { + endpoint_type: 'device', + endpoint_id: v.id, + endpoint_name: v.name, + endpoint_weight: data.data.endpoints[v.id].weight || 0 + }; + + list_endpoint.push(endpoint_item); + } + }); + + list_endpoint.sort(function(a,b){ + return a.endpoint_weight - b.endpoint_weight; + }); + + data.data.endpoints = list_endpoint; + + return data; + }, + + groupsDefineActions: function(args) { + var self = this, + callflow_nodes = args.actions; + + $.extend(callflow_nodes, { + 'ring_group[]': { + name: self.i18n.active().oldCallflows.ring_group, + icon: 'ring_group', + category: self.i18n.active().oldCallflows.basic_cat, + module: 'ring_group', + tip: self.i18n.active().oldCallflows.ring_group_tip, + data: { + name: '' + }, + rules: [ + { + type: 'quantity', + maxSize: '1' + } + ], + isUsable: 'true', + weight: 20, + caption: function(node, caption_map) { + return node.getMetadata('name') || ''; + }, + edit: function(node, callback) { + self.groupsEditRingGroup(node, callback); + } + }, + 'groups': { + name: self.i18n.active().callflows.groups.title, + module: 'groups', + listEntities: function(callback) { + self.callApi({ + resource: 'group.list', + data: { + accountId: self.accountId, + filters: { paginate:false } + }, + success: function(data, status) { + callback && callback(data.data); + } + }); + }, + editEntity: 'callflows.groups.edit' + }, + 'page_group[]': { + name: self.i18n.active().oldCallflows.page_group, + icon: 'ring_group', + category: self.i18n.active().oldCallflows.advanced_cat, + module: 'page_group', + tip: self.i18n.active().oldCallflows.page_group_tip, + data: { + name: '' + }, + rules: [ + { + type: 'quantity', + maxSize: '1' + } + ], + isUsable: 'true', + weight: 30, + caption: function(node, caption_map) { + return node.getMetadata('name') || ''; + }, + edit: function(node, callback) { + self.groupsEditPageGroup(node, callback); + } + }, + + /*'eavesdrop[]': { + name: self.i18n.active().callflows.eavesdrop.name, + icon: 'headset', + category: self.i18n.active().oldCallflows.advanced_cat, + module: 'eavesdrop', + tip: self.i18n.active().callflows.eavesdrop.tip, + data: {}, + rules: [ + { + type: 'quantity', + maxSize: '1' + } + ], + isUsable: 'true', + weight: 48, + caption: function(node) { + return ''; + }, + edit: function(node, callback) { + self.groupsGetEndpoints(function(formattedData) { + var popup, popup_html; + + popup_html = $(monster.template(self, 'misc-eavesdrop', { + fieldData: formattedData, + data: { + 'selectedId': node.getMetadata('device_id') || node.getMetadata('user_id') || '', + 'approvedId': node.getMetadata('approved_device_id') || node.getMetadata('approved_user_id') || node.getMetadata('approved_group_id') || '' + } + })); + + monster.ui.tooltips(popup_html); + + $('#add', popup_html).click(function() { + var setData = function(field, value) { + if (value === 'endpoint_empty') { + node.deleteMetadata('user_id'); + node.deleteMetadata('device_id'); + } else if (value === 'approved_empty') { + node.deleteMetadata('approved_user_id'); + node.deleteMetadata('approved_group_id'); + node.deleteMetadata('approved_device_id'); + } else { + node.setMetadata(field, value); + } + }; + + var endpointField = $('#endpoint_selector option:selected').data('type') + '_id', + endpointVal = $('#endpoint_selector option:selected').val(), + approvedEndpointField = 'approved_' + $('#approved_endpoint_selector option:selected').data('type') + '_id', + approvedEndpointVal = $('#approved_endpoint_selector option:selected').val(); + + setData(endpointField, endpointVal); + setData(approvedEndpointField, approvedEndpointVal); + + popup.dialog('close'); + }); + + popup = monster.ui.dialog(popup_html, { + title: self.i18n.active().callflows.eavesdrop.title, + beforeClose: function() { + if (typeof callback === 'function') { + callback(); + } + } + }); + }); + } + },*/ + + /*'intercept[]': { + name: self.i18n.active().callflows.intercept.name, + icon: 'uturn_arrow', + category: self.i18n.active().oldCallflows.advanced_cat, + module: 'intercept', + tip: self.i18n.active().callflows.intercept.tip, + data: {}, + rules: [ + { + type: 'quantity', + maxSize: '1' + } + ], + isUsable: 'true', + weight: 48, + caption: function(node) { + return ''; + }, + edit: function(node, callback) { + self.groupsGetEndpoints(function(formattedData) { + var popup, popup_html; + + popup_html = $(monster.template(self, 'misc-intercept', { + fieldData: formattedData, + data: { + 'selectedId': node.getMetadata('device_id') || node.getMetadata('user_id') || '', + 'approvedId': node.getMetadata('approved_device_id') || node.getMetadata('approved_user_id') || node.getMetadata('approved_group_id') || '' + } + })); + + monster.ui.tooltips(popup_html); + + $('#add', popup_html).click(function() { + var setData = function(field, value) { + if (value === 'endpoint_empty') { + node.deleteMetadata('user_id'); + node.deleteMetadata('device_id'); + } else if (value === 'approved_empty') { + node.deleteMetadata('approved_user_id'); + node.deleteMetadata('approved_group_id'); + node.deleteMetadata('approved_device_id'); + } else { + node.setMetadata(field, value); + } + }; + + var endpointField = $('#endpoint_selector option:selected').data('type') + '_id', + endpointVal = $('#endpoint_selector option:selected').val(), + approvedEndpointField = 'approved_' + $('#approved_endpoint_selector option:selected').data('type') + '_id', + approvedEndpointVal = $('#approved_endpoint_selector option:selected').val(); + + setData(endpointField, endpointVal); + setData(approvedEndpointField, approvedEndpointVal); + + popup.dialog('close'); + }); + + popup = monster.ui.dialog(popup_html, { + title: self.i18n.active().callflows.intercept.title, + beforeClose: function() { + if (typeof callback === 'function') { + callback(); + } + } + }); + }); + } + },*/ + + 'ring_group_toggle[action=login]': { + name: self.i18n.active().callflows.ringGroupToggle.loginTitle, + icon: 'ring_group', + category: self.i18n.active().callflows.ringGroupToggle.category, + module: 'ring_group_toggle', + tip: self.i18n.active().callflows.ringGroupToggle.loginTip, + data: { + action: 'login', + callflow_id: 'null' + }, + rules: [ + { + type: 'quantity', + maxSize: '1' + } + ], + isUsable: 'true', + weight: 1, + caption: function(node, caption_map) { + var id = node.getMetadata('callflow_id'), + return_value = ''; + + if (id in caption_map) { + if (caption_map[id].hasOwnProperty('name')) { + return_value = caption_map[id].name; + } else if (caption_map[id].hasOwnProperty('numbers')) { + return_value = caption_map[id].numbers.toString(); + } + } + + return return_value; + }, + edit: function(node, callback) { + self.callApi({ + resource: 'callflow.list', + data: { + accountId: self.accountId, + filters: { paginate: false } + }, + success: function(data, status) { + var popup, popup_html, _data = []; + + $.each(data.data, function() { + if (!this.featurecode && this.id !== self.flow.id) { + this.name = this.name ? this.name : ((this.numbers) ? this.numbers.toString() : self.i18n.active().oldCallflows.no_numbers); + + _data.push(this); + } + }); + + popup_html = $(monster.template(self, 'groups-ring_group_login_dialog', { + objects: { + type: 'callflow', + items: _.sortBy(_data, 'name'), + selected: node.getMetadata('callflow_id') || '' + } + })); + + $('#add', popup_html).click(function() { + node.setMetadata('callflow_id', $('#object-selector', popup_html).val()); + + node.caption = $('#object-selector option:selected', popup_html).text(); + + popup.dialog('close'); + }); + + popup = monster.ui.dialog(popup_html, { + title: self.i18n.active().oldCallflows.callflow_title, + beforeClose: function() { + if (typeof callback === 'function') { + callback(); + } + } + }); + } + }); + } + }, + + 'ring_group_toggle[action=logout]': { + name: self.i18n.active().callflows.ringGroupToggle.logoutTitle, + icon: 'ring_group', + category: self.i18n.active().callflows.ringGroupToggle.category, + module: 'ring_group_toggle', + tip: self.i18n.active().callflows.ringGroupToggle.logoutTip, + data: { + action: 'logout', + callflow_id: 'null' + }, + rules: [ + { + type: 'quantity', + maxSize: '1' + } + ], + isUsable: 'true', + weight: 2, + caption: function(node, caption_map) { + var id = node.getMetadata('callflow_id'), + return_value = ''; + + if (id in caption_map) { + if (caption_map[id].hasOwnProperty('name')) { + return_value = caption_map[id].name; + } else if (caption_map[id].hasOwnProperty('numbers')) { + return_value = caption_map[id].numbers.toString(); + } + } + + return return_value; + }, + edit: function(node, callback) { + self.callApi({ + resource: 'callflow.list', + data: { + accountId: self.accountId, + filters: { paginate: false } + }, + success: function(data, status) { + var popup, popup_html, _data = []; + + $.each(data.data, function() { + if (!this.featurecode && this.id !== self.flow.id) { + this.name = this.name ? this.name : ((this.numbers) ? this.numbers.toString() : self.i18n.active().oldCallflows.no_numbers); + + _data.push(this); + } + }); + + popup_html = $(monster.template(self, 'groups-ring_group_logout_dialog', { + objects: { + type: 'callflow', + items: _.sortBy(_data, 'name'), + selected: node.getMetadata('callflow_id') || '' + } + })); + + $('#add', popup_html).click(function() { + node.setMetadata('callflow_id', $('#object-selector', popup_html).val()); + + node.caption = $('#object-selector option:selected', popup_html).text(); + + popup.dialog('close'); + }); + + popup = monster.ui.dialog(popup_html, { + title: self.i18n.active().oldCallflows.callflow_title, + beforeClose: function() { + if (typeof callback === 'function') { + callback(); + } + } + }); + } + }); + } + } + }); + }, + + groupsGetEndpoints: function(callback) { + var self = this; + + monster.parallel({ + 'group': function(callback) { + self.groupsGroupList(function(data) { + callback(null, data); + }); + }, + 'user': function(callback) { + self.groupsUserList(function(data) { + callback(null, data); + }); + }, + 'device': function(callback) { + self.groupsDeviceList(function(data) { + callback(null, data); + }); + } + }, function(err, results) { + var data = self.groupsFormatEndpoints(results); + + callback(data); + }); + }, + + groupsFormatEndpoints: function(data) { + _.each(data.user, function(user) { + user.name = user.first_name + ' ' + user.last_name; + }); + + return data; + }, + + groupsEditPageGroup: function(node, callback) { + var self = this; + + self.groupsDeviceList(function(data) { + var popup, popup_html, index, endpoints, + selected_endpoints = {}, + unselected_endpoints = [], + unselected_groups = [], + unselected_devices = [], + unselected_users = []; + + if(endpoints = node.getMetadata('endpoints')) { + // We need to translate the endpoints to prevent nasty O(N^2) time complexities, + // we also need to clone to prevent managing of objects + $.each($.extend(true, {}, endpoints), function(i, obj) { + obj.name = 'Undefined Device'; + selected_endpoints[obj.id] = obj; + }); + } + + $.each(data, function(i, obj) { + obj.endpoint_type = 'device'; + if(obj.id in selected_endpoints) { + selected_endpoints[obj.id].endpoint_type = 'device'; + selected_endpoints[obj.id].owner_id = obj.owner_id; + selected_endpoints[obj.id].name = obj.name; + } + else { + unselected_devices.push(obj); + } + }); + + unselected_devices = _.sortBy(unselected_devices, 'name'); + + self.groupsGroupList(function(_data) { + $.each(_data, function(i, obj) { + obj.endpoint_type = 'group'; + if(obj.id in selected_endpoints) { + selected_endpoints[obj.id].endpoint_type = 'group', + selected_endpoints[obj.id].name = obj.name; + } + else { + unselected_groups.push(obj); + } + }); + + unselected_groups = _.sortBy(unselected_groups, 'name'); + + self.groupsUserList(function(_data) { + $.each(_data, function(i, obj) { + obj.name = obj.first_name + ' ' + obj.last_name; + obj.endpoint_type = 'user'; + if(obj.id in selected_endpoints) { + selected_endpoints[obj.id].endpoint_type = 'user', + selected_endpoints[obj.id].name = obj.name; + } + else { + unselected_users.push(obj); + } + }); + unselected_users = _.sortBy(unselected_users, 'name'); + + popup_html = $(monster.template(self, 'groups-page_group_dialog', { + form: { + name: node.getMetadata('name') || '', + audio: node.getMetadata('audio') || 'one-way' + } + })); + $.each(unselected_groups, function() { + $('#groups_pane .connect.left', popup_html).append($(monster.template(self, 'groups-page_group_element', this))); + }); + + $.each(unselected_devices, function() { + $('#devices_pane .connect.left', popup_html).append($(monster.template(self, 'groups-page_group_element', this))); + }); + + $.each(unselected_users, function() { + $('#users_pane .connect.left', popup_html).append($(monster.template(self, 'groups-page_group_element', this))); + }); + + $.each(selected_endpoints, function() { + //Check if user/device exists. + if(this.endpoint_type) { + $('.connect.right', popup_html).append($(monster.template(self, 'groups-page_group_element', this))); + } + }); + + $('#name', popup_html).bind('keyup blur change', function() { + $('.column.right .title', popup_html).html('Page Group - ' + $(this).val()); + }); + + $('ul.settings1 > li > a', popup_html).click(function(item) { + $('.pane_content', popup_html).hide(); + + //Reset Search field + $('.searchfield', popup_html).val(''); + $('.column.left li', popup_html).show(); + + $('ul.settings1 > li', popup_html).removeClass('current'); + + var tab_id = $(this).attr('id'); + + if(tab_id === 'users_tab_link') { + $('#users_pane', popup_html).show(); + } + else if(tab_id === 'devices_tab_link') { + $('#devices_pane', popup_html).show(); + } + else if(tab_id === 'groups_tab_link') { + $('#groups_pane', popup_html).show(); + } + + $(this).parent().addClass('current'); + }); + + $('.searchsubmit2', popup_html).click(function() { + $('.searchfield', popup_html).val(''); + $('.column li', popup_html).show(); + }); + + $('#devices_pane .searchfield', popup_html).keyup(function() { + $('#devices_pane .column.left li').each(function() { + if($('.item_name', $(this)).html().toLowerCase().indexOf($('#devices_pane .searchfield', popup_html).val().toLowerCase()) == -1) { + $(this).hide(); + } + else { + $(this).show(); + } + }); + }); + + $('#users_pane .searchfield', popup_html).keyup(function() { + $('#users_pane .column.left li').each(function() { + if($('.item_name', $(this)).html().toLowerCase().indexOf($('#users_pane .searchfield', popup_html).val().toLowerCase()) == -1) { + $(this).hide(); + } + else { + $(this).show(); + } + }); + }); + + $('#groups_pane .searchfield', popup_html).keyup(function() { + $('#groups_pane .column.left li').each(function() { + if($('.item_name', $(this)).html().toLowerCase().indexOf($('#groups_pane .searchfield', popup_html).val().toLowerCase()) == -1) { + $(this).hide(); + } + else { + $(this).show(); + } + }); + }); + + if($.isEmptyObject(selected_endpoints)) { + $('.column.right .connect', popup_html).addClass('no_element'); + } + else { + $('.column.right .connect', popup_html).removeClass('no_element'); + } + + $('.column.left .options', popup_html).hide(); + $('.column.left .actions', popup_html).hide(); + + $('.options .option.delay', popup_html).bind('keyup', function() { + $(this).parents('li').data('delay', $(this).val()); + }); + + $('.options .option.timeout', popup_html).bind('keyup', function() { + $(this).parents('li').data('timeout', $(this).val()); + }); + + $('#save_ring_group', popup_html).click(function() { + var name = $('#name', popup_html).val(); + var audio = $('#audio', popup_html).val(); + + endpoints = []; + + $('.right .connect li', popup_html).each(function() { + var item_data = $(this).data(); + delete item_data.owner_id; + endpoints.push(item_data); + }); + + node.setMetadata('endpoints', endpoints); + node.setMetadata('name', name); + node.setMetadata('audio', audio); + + node.caption = name; + + popup.dialog('close'); + }); + + popup = monster.ui.dialog(popup_html, { + title: self.i18n.active().oldCallflows.page_group_title, + beforeClose: function() { + if(typeof callback == 'function') { + callback(); + } + } + }); + + // $('.scrollable', popup).jScrollPane({ + // horizontalDragMinWidth: 0, + // horizontalDragMaxWidth: 0 + // }); + + $('.connect', popup).sortable({ + connectWith: $('.connect.right', popup), + zIndex: 2000, + helper: 'clone', + appendTo: $('.wrapper', popup), + scroll: false, + tolerance: 'pointer', + receive: function(ev, ui) { + var data = ui.item[0].dataset, + list_li = [], + confirm_text; + + if(data.endpoint_type === 'device') { + confirm_text = self.i18n.active().oldCallflows.the_owner_of_this_device_is_already; + $('.connect.right li', popup_html).each(function() { + if($(this).data('id') === data.owner_id) { + list_li.push($(this)); + } + }); + } + else if(data.endpoint_type === 'user') { + confirm_text = self.i18n.active().oldCallflows.this_user_has_already_some_devices; + $('.connect.right li', popup_html).each(function() { + if($(this).data('owner_id') === data.id) { + list_li.push($(this)); + } + }); + } + + if(list_li.length > 0) { + monster.ui.confirm(confirm_text, + function() { + $.each(list_li, function() { + remove_element(this); + }); + }, + function() { + remove_element(ui.item); + } + ); + } + + if($(this).hasClass('right')) { + $('.options', ui.item).show(); + $('.actions', ui.item).show(); + //$('.item_name', ui.item).addClass('right'); + $('.column.right .connect', popup).removeClass('no_element'); + } + } + }); + + $(popup_html).delegate('.trash', 'click', function() { + var $parent_li = $(this).parents('li').first(); + remove_element($parent_li); + }); + + $('.pane_content', popup_html).hide(); + $('#users_pane', popup_html).show(); + + var remove_element = function(li) { + var $parent_li = li; + var data = $parent_li.data(); + data.name = jQuery.trim($('.item_name', $parent_li).html()); + $('#'+data.endpoint_type+'s_pane .connect.left', popup_html).append($(monster.template(self, 'groups-page_group_element', data))); + $parent_li.remove(); + + if($('.connect.right li', popup_html).size() == 0) { + $('.column.right .connect', popup).addClass('no_element'); + } + + if(data.name.toLowerCase().indexOf($('#'+data.endpoint_type+'s_pane .searchfield', popup_html).val().toLowerCase()) == -1) { + $('#'+data.id, popup_html).hide(); + } + }; + }); + }); + }); + }, + + groupsEditRingGroup: function(node, callback) { + var self = this, + default_timeout = '20', + default_delay = '0'; + + self.groupsDeviceList(function(data) { + var popup, popup_html, index, endpoints, + selected_endpoints = {}, + unselected_endpoints = [], + unselected_groups = [], + unselected_devices = [], + unselected_users = []; + + if(endpoints = node.getMetadata('endpoints')) { + // We need to translate the endpoints to prevent nasty O(N^2) time complexities, + // we also need to clone to prevent managing of objects + $.each($.extend(true, {}, endpoints), function(i, obj) { + obj.name = self.i18n.active().oldCallflows.undefined_device; + selected_endpoints[obj.id] = obj; + }); + } + + $.each(data, function(i, obj) { + obj.endpoint_type = 'device'; + if(obj.id in selected_endpoints) { + selected_endpoints[obj.id].endpoint_type = 'device'; + selected_endpoints[obj.id].owner_id = obj.owner_id; + selected_endpoints[obj.id].name = obj.name; + } + else { + obj.delay = default_delay; + obj.timeout = default_timeout; + unselected_devices.push(obj); + } + }); + + unselected_devices = _.sortBy(unselected_devices, 'name'); + + self.groupsGroupList(function(_data) { + $.each(_data, function(i, obj) { + obj.endpoint_type = 'group'; + if(obj.id in selected_endpoints) { + selected_endpoints[obj.id].endpoint_type = 'group', + selected_endpoints[obj.id].name = obj.name; + } + else { + obj.delay = default_delay; + obj.timeout = default_timeout; + unselected_groups.push(obj); + } + }); + + unselected_groups = _.sortBy(unselected_groups, 'name'); + + self.groupsUserList(function(_data, status) { + $.each(_data, function(i, obj) { + obj.name = obj.first_name + ' ' + obj.last_name; + obj.endpoint_type = 'user'; + if(obj.id in selected_endpoints) { + selected_endpoints[obj.id].endpoint_type = 'user', + selected_endpoints[obj.id].name = obj.name; + } + else { + obj.delay = default_delay; + obj.timeout = default_timeout; + unselected_users.push(obj); + } + }); + + unselected_users = _.sortBy(unselected_users, 'name'); + + self.groupsMediaList(function(_data) { + var media_array = _data.sort(function(a, b) { + return a.name.toLowerCase() > b.name.toLowerCase() ? 1 : -1; + }), + mediaId = node.getMetadata('ringback') || 'default', + isShoutcast = mediaId.indexOf('://') >= 0 && mediaId !== 'silence_stream://300000'; + + popup_html = $(monster.template(self, 'groups-ring_group_dialog', { + form: { + name: node.getMetadata('name') || '', + strategy: { + items: [ + { + id: 'simultaneous', + name: self.i18n.active().oldCallflows.at_the_same_time + }, + { + id: 'single', + name: self.i18n.active().oldCallflows.in_order + } + ], + selected: node.getMetadata('strategy') || 'simultaneous' + }, + timeout: node.getMetadata('timeout') || '30', + repeats: node.getMetadata('repeats') || 1, + ringback: { + items: $.merge([ + { + id: 'default', + name: self.i18n.active().oldCallflows.default, + class: 'uneditable' + }, + { + id: 'silence_stream://300000', + name: self.i18n.active().oldCallflows.silence, + class: 'uneditable' + }, + { + id: 'shoutcast_url', + name: self.i18n.active().callflows.media.shoutcastURL, + class: 'uneditable' + } + ], media_array), + selected: isShoutcast ? 'shoutcast_url' : mediaId, + shoutcastValue: mediaId + } + } + })); + $.each(unselected_groups, function() { + $('#groups_pane .connect.left', popup_html).append($(monster.template(self, 'groups-ring_group_element', this))); + }); + + $.each(unselected_devices, function() { + $('#devices_pane .connect.left', popup_html).append($(monster.template(self, 'groups-ring_group_element', this))); + }); + + $.each(unselected_users, function() { + $('#users_pane .connect.left', popup_html).append($(monster.template(self, 'groups-ring_group_element', this))); + }); + + $.each(selected_endpoints, function() { + //Check if user/device exists. + if(this.endpoint_type) { + $('.connect.right', popup_html).append($(monster.template(self, 'groups-ring_group_element', this))); + } + }); + + $('#name', popup_html).bind('keyup blur change', function() { + $('.column.right .title', popup_html).html(self.i18n.active().oldCallflows.ring_group_val + $(this).val()); + }); + + $('#ringback', popup_html).change(function(e) { + var val = $(this).val(), + isShoutcast = val === 'shoutcast_url'; + + popup_html.find('.shoutcast-div').toggleClass('hidden', !isShoutcast).find('input').val(''); + + if ($(this).find('option:selected').hasClass('uneditable')) { + + $('.media_action[data-action="edit"]', popup_html).hide(); + } else { + $('.media_action[data-action="edit"]', popup_html).show(); + } + }); + + $('.media_action', popup_html).click(function(e) { + var isCreation = $(this).data('action') === 'create', + mediaData = isCreation ? {} : { id: $('#ringback', popup_html).val() }; + + monster.pub('callflows.media.editPopup', { + data: mediaData, + callback: function(_mediaData) { + if (_mediaData) { + if (isCreation) { + $('#ringback', popup_html).append(''); + } else { + $('#ringback option[value="' + _mediaData.id + '"]', popup_html).text(_mediaData.name); + } + $('#ringback', popup_html).val(_mediaData.id); + } + } + }); + }); + + $('ul.settings1 > li > a', popup_html).click(function(item) { + $('.pane_content', popup_html).hide(); + + //Reset Search field + $('.searchfield', popup_html).val(''); + $('.column.left li', popup_html).show(); + + $('ul.settings1 > li', popup_html).removeClass('current'); + + var tab_id = $(this).attr('id'); + + if(tab_id === 'users_tab_link') { + $('#users_pane', popup_html).show(); + } + else if(tab_id === 'devices_tab_link') { + $('#devices_pane', popup_html).show(); + } + else if(tab_id === 'groups_tab_link') { + $('#groups_pane', popup_html).show(); + } + + $(this).parent().addClass('current'); + }); + + $('.searchsubmit2', popup_html).click(function() { + $('.searchfield', popup_html).val(''); + $('.column li', popup_html).show(); + }); + + $('#devices_pane .searchfield', popup_html).keyup(function() { + $('#devices_pane .column.left li').each(function() { + if($('.item_name', $(this)).html().toLowerCase().indexOf($('#devices_pane .searchfield', popup_html).val().toLowerCase()) == -1) { + $(this).hide(); + } + else { + $(this).show(); + } + }); + }); + + $('#users_pane .searchfield', popup_html).keyup(function() { + $('#users_pane .column.left li').each(function() { + if($('.item_name', $(this)).html().toLowerCase().indexOf($('#users_pane .searchfield', popup_html).val().toLowerCase()) == -1) { + $(this).hide(); + } + else { + $(this).show(); + } + }); + }); + + $('#groups_pane .searchfield', popup_html).keyup(function() { + $('#groups_pane .column.left li').each(function() { + if($('.item_name', $(this)).html().toLowerCase().indexOf($('#groups_pane .searchfield', popup_html).val().toLowerCase()) == -1) { + $(this).hide(); + } + else { + $(this).show(); + } + }); + }); + + if($.isEmptyObject(selected_endpoints)) { + $('.column.right .connect', popup_html).addClass('no_element'); + } + else { + $('.column.right .connect', popup_html).removeClass('no_element'); + } + + $('.column.left .options', popup_html).hide(); + $('.column.left .actions', popup_html).hide(); + + $('.options .option.delay', popup_html).bind('keyup', function() { + $(this).parents('li').data('delay', $(this).val()); + }); + + $('.options .option.timeout', popup_html).bind('keyup', function() { + $(this).parents('li').data('timeout', $(this).val()); + }); + + $('#save_ring_group', popup_html).click(function() { + var name = $('#name', popup_html).val(), + global_timeout = 0, + strategy = $('#strategy', popup_html).val(), + ringback = $('#ringback', popup_html).val(), + repeats = $('#repeats', popup_html).val(), + shoutcastValue = $('.shoutcast-url-input', popup_html).val(); + + if (ringback === 'shoutcast_url') { + ringback = shoutcastValue; + } + + endpoints = []; + + if(strategy === 'simultaneous') { + var computeTimeout = function(delay, local_timeout, global_timeout) { + var duration = delay + local_timeout; + + if(duration > global_timeout) { + global_timeout = duration; + } + + return global_timeout; + } + } + else { + var computeTimeout = function(delay, local_timeout, global_timeout) { + global_timeout += delay + local_timeout; + + return global_timeout; + } + } + + $('.right .connect li', popup_html).each(function() { + var item_data = $(this).data(); + delete item_data.owner_id; + endpoints.push(item_data); + global_timeout = computeTimeout(parseFloat(item_data.delay), parseFloat(item_data.timeout), global_timeout); + }); + + if (repeats < 1) { + repeats = 1; + } + + node.setMetadata('endpoints', endpoints); + node.setMetadata('name', name); + node.setMetadata('strategy', strategy); + node.setMetadata('timeout', global_timeout); + node.setMetadata('repeats', repeats); + if(ringback === 'default') { + node.deleteMetadata('ringback', ringback); + } else { + node.setMetadata('ringback', ringback); + } + + node.caption = name; + + popup.dialog('close'); + }); + + monster.ui.tooltips(popup_html); + + popup = monster.ui.dialog(popup_html, { + title: self.i18n.active().oldCallflows.ring_group, + beforeClose: function() { + if(typeof callback == 'function') { + callback(); + } + } + }); + + // $('.scrollable', popup).jScrollPane({ + // horizontalDragMinWidth: 0, + // horizontalDragMaxWidth: 0 + // }); + + $('.connect', popup).sortable({ + connectWith: $('.connect.right', popup), + zIndex: 2000, + helper: 'clone', + appendTo: $('.wrapper', popup), + scroll: false, + tolerance: 'pointer', + receive: function(ev, ui) { + var data = ui.item[0].dataset, + list_li = [], + confirm_text; + + if(data.endpoint_type === 'device') { + confirm_text = self.i18n.active().oldCallflows.the_owner_of_this_device_is_already; + $('.connect.right li', popup_html).each(function() { + if($(this).data('id') === data.owner_id) { + list_li.push($(this)); + } + }); + } + else if(data.endpoint_type === 'user') { + confirm_text = self.i18n.active().oldCallflows.this_user_has_already_some_devices; + $('.connect.right li', popup_html).each(function() { + if($(this).data('owner_id') === data.id) { + list_li.push($(this)); + } + }); + } + + if(list_li.length > 0) { + monster.ui.confirm(confirm_text, + function() { + $.each(list_li, function() { + remove_element(this); + }); + }, + function() { + remove_element(ui.item); + } + ); + } + + if($(this).hasClass('right')) { + $('.options', ui.item).show(); + $('.actions', ui.item).show(); + //$('.item_name', ui.item).addClass('right'); + $('.column.right .connect', popup).removeClass('no_element'); + } + } + }); + + $(popup_html).delegate('.trash', 'click', function() { + var $parent_li = $(this).parents('li').first(); + remove_element($parent_li); + }); + + $('.pane_content', popup_html).hide(); + $('#users_pane', popup_html).show(); + if($('#ringback option:selected').hasClass('uneditable')) { + $('.media_action[data-action="edit"]', popup_html).hide(); + } else { + $('.media_action[data-action="edit"]', popup_html).show(); + } + + var remove_element = function(li) { + var $parent_li = li; + var data = $parent_li.data(); + data.name = jQuery.trim($('.item_name', $parent_li).html()); + $('#'+data.endpoint_type+'s_pane .connect.left', popup_html).append($(monster.template(self, 'groups-ring_group_element', data))); + $parent_li.remove(); + + if($('.connect.right li', popup_html).size() == 0) { + $('.column.right .connect', popup).addClass('no_element'); + } + + if(data.name.toLowerCase().indexOf($('#'+data.endpoint_type+'s_pane .searchfield', popup_html).val().toLowerCase()) == -1) { + $('#'+data.id, popup_html).hide(); + } + }; + }); + }); + }); + }); + }, + + groupsDeviceList: function(callback) { + var self = this; + + self.callApi({ + resource: 'device.list', + data: { + accountId: self.accountId, + filters: { paginate:false } + }, + success: function(data, status) { + callback && callback(data.data); + } + }); + }, + + groupsGroupList: function(callback) { + var self = this; + + self.callApi({ + resource: 'group.list', + data: { + accountId: self.accountId, + filters: { paginate:false } + }, + success: function(data, status) { + callback && callback(data.data); + } + }); + }, + + groupsUserList: function(callback) { + var self = this; + + self.callApi({ + resource: 'user.list', + data: { + accountId: self.accountId, + filters: { paginate:false } + }, + success: function(data, status) { + callback && callback(data.data); + } + }); + }, + + groupsMediaList: function(callback) { + var self = this; + + self.callApi({ + resource: 'media.list', + data: { + accountId: self.accountId, + filters: { paginate:false } + }, + success: function(data, status) { + callback && callback(data.data); + } + }); + }, + + groupsNormalizeData: function(form_data) { + delete form_data.users; + return form_data; + }, + + groupsSave: function(form_data, data, success, error) { + var self = this, + normalized_data = self.groupsNormalizeData($.extend(true, {}, data.data, form_data)); + + if (typeof data.data === 'object' && data.data.id) { + self.callApi({ + resource: 'group.update', + data: { + accountId: self.accountId, + groupId: data.data.id, + data: normalized_data + }, + success: function(_data) { + success(_data.data, status, 'update'); + } + }); + } + else { + self.callApi({ + resource: 'group.create', + data: { + accountId: self.accountId, + data: normalized_data + }, + success: function(_data) { + success(_data.data, status, 'create'); + } + }); + } + }, + + groupsDelete: function(data, callback) { + var self = this; + + if(typeof data.data == 'object' && data.data.id) { + self.callApi({ + resource: 'group.delete', + data: { + accountId: self.accountId, + groupId: data.data.id + }, + success: function(_data) { + callback && callback(_data, status); + } + }); + } + } + }; + + return app; +}); diff --git a/src/apps/callflows/submodules/media/media.js b/src/apps/callflows/submodules/media/media.js new file mode 100644 index 0000000..2b9054f --- /dev/null +++ b/src/apps/callflows/submodules/media/media.js @@ -0,0 +1,548 @@ +define(function(require){ + var $ = require('jquery'), + _ = require('underscore'), + monster = require('monster'); + + var app = { + requests: {}, + + subscribe: { + 'callflows.fetchActions': 'mediaDefineActions', + 'callflows.media.editPopup': 'mediaPopupEdit', + 'callflows.media.edit': '_mediaEdit' + }, + + mediaRender: function(data, target, callbacks) { + var self = this, + media_html = $(monster.template(self, 'media-edit', data)), + mediaForm = media_html.find('#media-form'); + + monster.ui.validate(mediaForm, { + rules: { + 'name': { + required: true + } + } + }); + + $('*[rel=popover]:not([type="text"])', media_html).popover({ + trigger: 'hover' + }); + + $('*[rel=popover][type="text"]', media_html).popover({ + trigger: 'focus' + }); + + self.winkstartTabs(media_html); + + if(data.data.id) { + $('#upload_div', media_html).hide(); + } + + $('#change_link', media_html).click(function(ev) { + ev.preventDefault(); + $('#upload_div', media_html).show(); + $('.player_file', media_html).hide(); + }); + + $('#download_link', media_html).click(function(ev) { + ev.preventDefault(); + window.location.href = self.apiUrl + (self.apiUrl.substring(self.apiUrl.length-1) != '/' ? '/' : '') + 'accounts/' + + self.accountId + '/media/' + + data.data.id + '/raw?auth_token=' + self.getAuthToken(); + }); + + $('#file', media_html).bind('change', function(evt){ + var files = evt.target.files; + + if(files.length > 0) { + var reader = new FileReader(); + + file = 'updating'; + reader.onloadend = function(evt) { + var data = evt.target.result; + + file = data; + } + + reader.readAsDataURL(files[0]); + } + }); + + function changeType($select) { + var type = $select.val(); + + switch(type) { + case 'tts': + $('.tts', media_html).show(); + $('.file', media_html).hide(); + break; + case 'upload': + $('.tts', media_html).hide(); + $('.file', media_html).show(); + break; + } + } + + changeType($('#media_type', media_html)); + + $('#media_type', media_html).change(function() { + changeType($(this)); + }); + + $('.media-save', media_html).click(function(ev) { + ev.preventDefault(); + var $this = $(this); + + if(!$this.hasClass('disabled')) { + $this.addClass('disabled'); + + if(monster.ui.valid(mediaForm)) { + var form_data = monster.ui.getFormData('media-form'); + + form_data = self.mediaCleanFormData(form_data); + + self.mediaSave(form_data, data, function(_data, status) { + if(!form_data.tts) { + if($('#upload_div', media_html).is(':visible') && $('#file').val() != '') { + if(file === 'updating') { + monster.ui.alert(self.i18n.active().callflows.media.the_file_you_want_to_apply); + + $this.removeClass('disabled'); + } + else { + self.mediaUpload(file, _data.id, function() { + if(typeof callbacks.save_success == 'function') { + callbacks.save_success(_data, status); + } + }, function() { + if(data && data.data && data.data.id) { + self.mediaSave({}, data, function() { + if(typeof callbacks.save_success == 'function') { + callbacks.save_success(_data, status); + } + }); + } else { + self.mediaDelete(_data.id, callbacks.delete_success, callbacks.delete_error); + } + + $this.removeClass('disabled'); + + if(typeof callbacks.save_error == 'function') { + callbacks.save_error(_data, status); + } + }); + } + } + else { + if(typeof callbacks.save_success == 'function') { + callbacks.save_success(_data, status); + } + } + } else { + if(typeof callbacks.save_success == 'function') { + callbacks.save_success(_data, status); + } + } + }); + } else { + $this.removeClass('disabled'); + monster.ui.alert(self.i18n.active().callflows.media.there_were_errors_on_the_form); + } + } + }); + + $('.media-delete', media_html).click(function(ev) { + ev.preventDefault(); + + monster.ui.confirm(self.i18n.active().callflows.media.are_you_sure_you_want_to_delete, function() { + self.mediaDelete(data.data.id, callbacks.delete_success, callbacks.delete_error); + }); + }); + + (target) + .empty() + .append(media_html); + }, + + mediaCleanFormData: function(form_data) { + form_data.description = form_data.upload_media; + + if(form_data.description == '') { + delete form_data.description; + } + + if(form_data.media_source == 'tts') { + form_data.description = "tts file"; + } else { + delete form_data.tts; + } + + delete form_data.media_type; + + return form_data; + }, + + // Added for the subscribed event to avoid refactoring mediaEdit + _mediaEdit: function(args) { + var self = this; + self.mediaEdit(args.data, args.parent, args.target, args.callbacks, args.data_defaults); + }, + + mediaEdit: function(data, _parent, _target, _callbacks, data_defaults){ + var self = this, + parent = _parent || $('#media-content'), + target = _target || $('#media-view', parent), + _callbacks = _callbacks || {}, + callbacks = { + save_success: _callbacks.save_success, + save_error: _callbacks.save_error, + delete_success: _callbacks.delete_success, + delete_error: _callbacks.delete_error, + after_render: _callbacks.after_render + }, + defaults = { + data: $.extend(true, { + streamable: true + }, data_defaults || {}) + }; + + if(typeof data == 'object' && data.id) { + self.mediaGet(data.id, function(mediaData) { + self.mediaFormatData(mediaData); + + self.mediaRender($.extend(true, defaults, { data: mediaData }), target, callbacks); + + if(typeof callbacks.after_render == 'function') { + callbacks.after_render(); + } + }); + } + else { + self.mediaRender(defaults, target, callbacks); + + if(typeof callbacks.after_render == 'function') { + callbacks.after_render(); + } + } + }, + + mediaSave: function(form_data, data, success, error) { + var self = this, + normalized_data = self.mediaNormalizeData($.extend(true, {}, data.data, form_data)); + + if(typeof data.data == 'object' && data.data.id) { + self.mediaUpdate(normalized_data, function(_data, status) { + if(typeof success == 'function') { + success(_data, status, 'update'); + } + }); + } + else { + self.mediaCreate(normalized_data, function(_data, status) { + if(typeof success == 'function') { + success(_data, status, 'create'); + } + }); + } + }, + + mediaNormalizeData: function(form_data) { + delete form_data.upload_media; + + if('field_data' in form_data) { + delete form_data.field_data; + } + + if(form_data.media_source == 'upload') { + delete form_data.tts; + } + + return form_data; + }, + + mediaFormatData: function(data) { + /* On creation, crossbar store streamable as a string, and as a boolean on update + * And as we're using the same template for both behaviors, we need the same kind of data. + * TODO: delete once this bug is fixed! + */ + if(data.streamable == 'false') { + data.streamable = false; + } + else if(data.streamable == 'true') { + data.streamable = true; + } + + if(data.description != undefined && data.description.substr(0,12) == 'C:\\fakepath\\') { + data.description = data.description.substr(12); + } + + return data; + }, + + mediaPopupEdit: function(args) { + var self = this, + data = args.data, + callback = args.callback, + data_defaults = args.data_defaults || {}, + popup, + popup_html = $('
    '); + + self.mediaEdit(data, popup_html, $('.inline_content', popup_html), { + save_success: function(_data) { + popup.dialog('close'); + + if(typeof callback == 'function') { + callback(_data); + } + }, + delete_success: function() { + popup.dialog('close'); + + if(typeof callback == 'function') { + callback({ data: {} }); + } + }, + after_render: function() { + popup = monster.ui.dialog(popup_html, { + title: (data.id) ? self.i18n.active().callflows.media.edit_media : self.i18n.active().callflows.media.create_media + }); + } + }, data_defaults); + }, + + mediaDefineActions: function(args) { + var self = this, + callflow_nodes = args.actions; + + $.extend(callflow_nodes, { + 'play[id=*]': { + name: self.i18n.active().callflows.media.play_media, + icon: 'play', + category: self.i18n.active().oldCallflows.basic_cat, + module: 'play', + tip: self.i18n.active().callflows.media.play_media_tip, + data: { + id: 'null' + }, + rules: [ + { + type: 'quantity', + maxSize: '1' + } + ], + isUsable: 'true', + weight: 10, + caption: function(node, caption_map) { + var id = node.getMetadata('id'), + isSilence = id && id === 'silence_stream://300000', + isShoutcast = id && id.indexOf('://') >= 0 && !isSilence, + returned_value = ''; + + if(id in caption_map) { + returned_value = caption_map[id].name; + } else if (isShoutcast) { + returned_value = id; + } else if (isSilence) { + returned_value = self.i18n.active().callflows.media.silence; + } + + return returned_value; + }, + edit: function(node, callback) { + var _this = this; + + self.mediaList(function(medias) { + var popup, popup_html, + mediaId = node.getMetadata('id') || '', + isSilence = !mediaId || (mediaId && mediaId === 'silence_stream://300000'), // because silence is the default choice, we test for !mediaId + isShoutcast = mediaId.indexOf('://') >= 0 && mediaId !== 'silence_stream://300000'; + + popup_html = $(monster.template(self, 'media-callflowEdit', { + items: medias, + selected: isShoutcast ? 'shoutcast' : mediaId, + isShoutcast: isShoutcast, + shoutcastValue: mediaId, + isEditable: !isShoutcast && !isSilence + })); + + if($('#media_selector option:selected', popup_html).val() == undefined) { + $('#edit_link', popup_html).hide(); + } + + $('.inline_action', popup_html).click(function(ev) { + var _data = ($(this).data('action') == 'edit') ? + { id: $('#media_selector', popup_html).val() } : {}; + + ev.preventDefault(); + + self.mediaPopupEdit({ + data: _data, + callback: function(media) { + node.setMetadata('id', media.id || 'null'); + node.caption = media.name || ''; + + popup.dialog('close'); + } + }); + }); + + popup_html.find('#media_selector').on('change', function() { + var val = $(this).val(), + isSilence = val && val === 'silence_stream://300000', + isShoutcast = val === 'shoutcast', + isEditable = !isShoutcast && !isSilence; + + popup_html.find('#edit_link').toggleClass('active', isEditable); + popup_html.find('.shoutcast-div').toggleClass('active', isShoutcast).find('input').val(''); + }); + + $('#add', popup_html).click(function() { + var mediaValue = $('#media_selector', popup_html).val(), + shoutcastValue = $('.shoutcast-url-input', popup_html).val(); + + node.caption = mediaValue === 'shoutcast' ? shoutcastValue : $('#media_selector option:selected', popup_html).text(); + mediaValue = mediaValue === 'shoutcast' ? shoutcastValue : mediaValue; + node.setMetadata('id', mediaValue); + + popup.dialog('close'); + }); + + monster.ui.tooltips(popup_html); + + popup = monster.ui.dialog(popup_html, { + title: self.i18n.active().callflows.media.media, + minHeight: '0', + beforeClose: function() { + if(typeof callback == 'function') { + callback(); + } + } + }); + }); + }, + listEntities: function(callback) { + self.callApi({ + resource: 'media.list', + data: { + accountId: self.accountId, + filters: { paginate:false } + }, + success: function(data, status) { + callback && callback(data.data); + } + }); + }, + editEntity: 'callflows.media.edit' + } + }); + }, + + mediaList: function(callback) { + var self = this; + + self.callApi({ + resource: 'media.list', + data: { + accountId: self.accountId, + filters: { paginate:false } + }, + success: function(data) { + var mediaList = _.sortBy(data.data, function(item) { return item.name.toLowerCase(); }); + + mediaList.unshift( + { + id: 'silence_stream://300000', + name: self.i18n.active().callflows.media.silence + }, + { + id: 'shoutcast', + name: self.i18n.active().callflows.media.shoutcastURL + } + ); + + callback && callback(mediaList); + } + }); + }, + + mediaGet: function(mediaId, callback) { + var self = this; + + self.callApi({ + resource: 'media.get', + data: { + accountId: self.accountId, + mediaId: mediaId + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + mediaCreate: function(data, callback) { + var self = this; + + self.callApi({ + resource: 'media.create', + data: { + accountId: self.accountId, + data: data + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + mediaUpdate: function(data, callback) { + var self = this; + + self.callApi({ + resource: 'media.update', + data: { + accountId: self.accountId, + mediaId: data.id, + data: data + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + mediaDelete: function(mediaId, callback) { + var self = this; + + self.callApi({ + resource: 'media.delete', + data: { + accountId: self.accountId, + mediaId: mediaId + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + mediaUpload: function(data, mediaId, callback) { + var self = this; + + self.callApi({ + resource: 'media.upload', + data: { + accountId: self.accountId, + mediaId: mediaId, + data: data + }, + success: function(data, status) { + callback && callback(data, status); + } + }); + } + }; + + return app; +}); diff --git a/src/apps/callflows/submodules/menu/menu.js b/src/apps/callflows/submodules/menu/menu.js new file mode 100644 index 0000000..cc25857 --- /dev/null +++ b/src/apps/callflows/submodules/menu/menu.js @@ -0,0 +1,571 @@ +define(function(require){ + var $ = require('jquery'), + _ = require('underscore'), + monster = require('monster'); + + var app = { + requests: {}, + + subscribe: { + 'callflows.fetchActions': 'menuDefineActions', + 'callflows.menu.edit': '_menuEdit' + }, + + // Added for the subscribed event to avoid refactoring menuEdit + _menuEdit: function(args) { + var self = this; + self.menuEdit(args.data, args.parent, args.target, args.callbacks, args.data_defaults); + }, + + menuEdit: function(data, _parent, _target, _callbacks, data_defaults) { + var self = this, + parent = _parent || $('#menu-content'), + target = _target || $('#menu-view', parent), + _callbacks = _callbacks || {}, + callbacks = { + save_success: _callbacks.save_success, + save_error: _callbacks.save_error, + delete_success: _callbacks.delete_success, + delete_error: _callbacks.delete_error, + after_render: _callbacks.after_render + }, + defaults = { + data: $.extend(true, { + timeout: '10', + interdigit_timeout: '2', + max_extension_length: '4', + media: {}, + extra: { + retries: 2 + } + }, data_defaults || {}), + field_data: { + media: [] + } + }; + + monster.parallel({ + media_list: function(callback) { + self.callApi({ + resource: 'media.list', + data: { + accountId: self.accountId, + filters: { paginate:false } + }, + success: function(mediaList, status) { + _.each(mediaList.data, function(media) { + if(media.media_source) { + media.name = '['+media.media_source.substring(0,3).toUpperCase()+'] ' + media.name; + } + }); + + mediaList.data.unshift({ + id: '', + name: self.i18n.active().callflows.menu.not_set + }); + + defaults.field_data.media = mediaList.data; + + callback(null, mediaList); + } + }); + }, + menu_get: function(callback) { + if(typeof data == 'object' && data.id) { + self.menuGet(data.id, function(menuData, status) { + self.menuformatData(menuData); + + callback(null, { data: menuData }); + }); + } + else { + callback(null, {}); + } + } + }, + function(err, results) { + var render_data = defaults; + + if(typeof data === 'object' && data.id) { + render_data = $.extend(true, defaults, results.menu_get) + } + + self.menuRender(render_data, target, callbacks); + + if(typeof callbacks.after_render == 'function') { + callbacks.after_render(); + } + } + ); + }, + + menuPopupEdit: function(data, callback, data_defaults) { + var self = this, + popup, + popup_html = $('
    '); + + self.menuEdit(data, popup_html, $('.inline_content', popup_html), { + save_success: function(_data) { + popup.dialog('close'); + + if(typeof callback == 'function') { + callback(_data); + } + }, + delete_success: function() { + popup.dialog('close'); + + if(typeof callback == 'function') { + callback({ data: {} }); + } + }, + after_render: function() { + popup = monster.ui.dialog(popup_html, { + title: (data.id) ? self.i18n.active().callflows.menu.edit_menu : self.i18n.active().callflows.menu.create_menu + }); + } + }, data_defaults); + }, + + menuRender: function(data, target, callbacks){ + var self = this, + menu_html = $(monster.template(self, 'menu-edit', data)), + menuForm = menu_html.find('#menu-form'); + + monster.ui.validate(menuForm, { + rules: { + 'extra.retries': { + digits: true, + min: 0 + }, + 'record_pin': { + digits: true + }, + 'timeout': { + number: true, + max: 10 + }, + 'interdigit_timeout': { + number: true, + max: 10 + }, + 'max_extension_length': { + digits: true + } + } + }); + + $('*[rel=popover]:not([type="text"])', menu_html).popover({ + trigger: 'hover' + }); + + $('*[rel=popover][type="text"]', menu_html).popover({ + trigger: 'focus' + }); + + self.winkstartTabs(menu_html); + + if(!$('#media_greeting', menu_html).val()) { + $('#edit_link_media', menu_html).hide(); + } + + $('#media_greeting', menu_html).change(function() { + !$('#media_greeting option:selected', menu_html).val() ? $('#edit_link_media', menu_html).hide() : $('#edit_link_media', menu_html).show(); + }); + + $('.inline_action_media', menu_html).click(function(ev) { + var _data = ($(this).data('action') == 'edit') ? { id: $('#media_greeting', menu_html).val() } : {}, + _id = _data.id; + + ev.preventDefault(); + + monster.pub('callflows.media.editPopup', { + data: _data, + callback: function(dataMedia) { + /* Create */ + dataMedia.name = '[UPL] ' + dataMedia.name; + + if(!_id) { + $('#media_greeting', menu_html).append('') + $('#media_greeting', menu_html).val(dataMedia.id); + + $('#edit_link_media', menu_html).show(); + } + else { + /* Update */ + if(dataMedia.hasOwnProperty('id')) { + $('#media_greeting #'+dataMedia.id, menu_html).text(dataMedia.name); + } + /* Delete */ + else { + $('#media_greeting #'+_id, menu_html).remove(); + $('#edit_link_media', menu_html).hide(); + } + } + } + }); + }); + + $('.menu-save', menu_html).click(function(ev) { + ev.preventDefault(); + + var $this = $(this); + + if(!$this.hasClass('disabled')) { + $this.addClass('disabled'); + + if(monster.ui.valid(menuForm)) { + var form_data = monster.ui.getFormData('menu-form'); + + self.menuCleanFormData(form_data); + + if('field_data' in data) { + delete data.field_data; + } + + self.menuSave(form_data, data, callbacks.save_success, function() { + $this.removeClass('disabled'); + }); + } else { + $this.removeClass('disabled'); + monster.ui.alert('error', self.i18n.active().callflows.menu.there_were_errors_on_the_form); + } + } + }); + + $('.menu-delete', menu_html).click(function(ev) { + ev.preventDefault(); + + monster.ui.confirm(self.i18n.active().callflows.menu.are_you_sure_you_want_to_delete, function() { + self.menuDelete(data.data.id, callbacks.delete_success, callbacks.delete_error); + }); + }); + + (target) + .empty() + .append(menu_html); + }, + + menuSave: function(form_data, data, success, error) { + var self = this, + normalized_data = self.menuNormalizeData($.extend(true, {}, data.data, form_data)); + + if (typeof data.data == 'object' && data.data.id) { + self.menuUpdate(normalized_data, function(data, status) { + success && success(data, status, 'update'); + }, error); + } else { + self.menuCreate(normalized_data, function(data, status) { + success && success(data, status, 'create'); + }, error); + } + }, + + menuformatData: function(data) { + var self = this; + + data.extra = {}; + data.extra.retries = parseInt(data.retries) - 1; + + if (data.timeout) { + data.timeout /= 1000; // ms to seconds + } + + if(data.interdigit_timeout) { + data.interdigit_timeout /= 1000; // ms to seconds + } + + + if(data.media) { + if(data.media.invalid_media === false && data.media.transfer_media === false && data.media.exit_media === false) { + data.suppress_media = true; + } + else { + data.suppress_media = false; + } + } + }, + + menuCleanFormData: function(form_data) { + if(form_data.record_pin.length == 0) { + form_data.max_extension_length = 4; + } + else if(form_data.max_extension_length < form_data.record_pin.length) { + form_data.max_extension_length = form_data.record_pin.length; + } + + /* Hack to put timeouts in ms in database. */ + form_data.timeout = form_data.timeout * 1000; + form_data.interdigit_timeout = form_data.interdigit_timeout * 1000; + + form_data.retries = parseInt(form_data.extra.retries) + 1; + + if ('suppress_media' in form_data) { + form_data.media = form_data.media || {}; + if(form_data.suppress_media === true) { + form_data.media.invalid_media = false; + form_data.media.transfer_media = false; + form_data.media.exit_media = false; + } + else { + form_data.media.invalid_media = true; + form_data.media.transfer_media = true; + form_data.media.exit_media = true; + } + } + }, + + menuNormalizeData: function(form_data) { + if(!form_data.media.greeting) { + delete form_data.media.greeting; + } + + if(form_data.hunt_allow == '') { + delete form_data.hunt_allow; + } + + if(form_data.hunt_deny == '') { + delete form_data.hunt_deny; + } + + if(form_data.record_pin == '') { + delete form_data.record_pin; + } + + delete form_data.extra; + + return form_data; + }, + + menuDefineActions: function(args) { + var self = this, + callflow_nodes = args.actions; + + $.extend(callflow_nodes, { + 'menu[id=*]': { + name: self.i18n.active().callflows.menu.menu_title, + icon: 'menu1', + category: self.i18n.active().oldCallflows.basic_cat, + module: 'menu', + tip: self.i18n.active().callflows.menu.menu_tip, + data: { + id: 'null' + }, + rules: [ + { + type: 'quantity', + maxSize: '9999' + } + ], + isUsable: 'true', + weight: 60, + key_caption: function(child_node, caption_map) { + var key = child_node.key; + + return (key != '_') ? key : self.i18n.active().callflows.menu.default_action; + }, + key_edit: function(child_node, callback) { + var popup, popup_html; + + /* The '#' Key is not available anymore but we let it here so that it doesn't break existing callflows. + The '#' Key is only displayed if it exists in the callflow, otherwise it is hidden by the template (see /tmpl/menu_key_callflow.html) + */ + + popup_html = $(monster.template(self, 'menu-callflowKey', { + items: { + '_': self.i18n.active().callflows.menu.default_action, + '0': '0', + '1': '1', + '2': '2', + '3': '3', + '4': '4', + '5': '5', + '6': '6', + '7': '7', + '8': '8', + '9': '9', + '*': '*', + '#': '#' + }, + selected: child_node.key + })); + + popup_html.find('#add').on('click', function() { + child_node.key = $('#menu_key_selector', popup).val(); + + child_node.key_caption = $('#menu_key_selector option:selected', popup).text(); + + popup.dialog('close'); + }); + + popup = monster.ui.dialog(popup_html, { + title: self.i18n.active().callflows.menu.menu_option_title, + minHeight: '0', + beforeClose: function() { + callback && callback(); + } + }); + }, + caption: function(node, caption_map) { + var id = node.getMetadata('id'), + returned_value = ''; + + if(id in caption_map) { + returned_value = caption_map[id].name; + } + + return returned_value; + }, + edit: function(node, callback) { + var _this = this; + + self.menuList(function(menus) { + var popup, popup_html; + + popup_html = $(monster.template(self, 'menu-callflowEdit', { + items: _.sortBy(menus, 'name'), + selected: node.getMetadata('id') || '' + })); + + if($('#menu_selector option:selected', popup_html).val() == undefined) { + $('#edit_link', popup_html).hide(); + } + + $('.inline_action', popup_html).click(function(ev) { + var _data = ($(this).data('action') == 'edit') ? + { id: $('#menu_selector', popup_html).val() } : {}; + + ev.preventDefault(); + + self.menuPopupEdit(_data, function(menu) { + node.setMetadata('id', menu.id || 'null'); + node.caption = menu.name || ''; + + popup.dialog('close'); + }); + }); + + popup_html.find('#add').on('click', function() { + node.setMetadata('id', $('#menu_selector', popup).val()); + node.caption = $('#menu_selector option:selected', popup).text(); + + popup.dialog('close'); + }); + + popup = monster.ui.dialog(popup_html, { + title: self.i18n.active().callflows.menu.menu_title, + minHeight: '0', + beforeClose: function() { + if(typeof callback == 'function') { + callback(); + } + } + }); + }); + }, + listEntities: function(callback) { + self.callApi({ + resource: 'menu.list', + data: { + accountId: self.accountId, + filters: { paginate:false } + }, + success: function(data, status) { + callback && callback(data.data); + } + }); + }, + editEntity: 'callflows.menu.edit' + } + }); + }, + + menuList: function(callback) { + var self = this; + + self.callApi({ + resource: 'menu.list', + data: { + accountId: self.accountId, + filters: { paginate:false } + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + menuGet: function(menuId, callback) { + var self = this; + + self.callApi({ + resource: 'menu.get', + data: { + accountId: self.accountId, + menuId: menuId + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + menuCreate: function(data, callback, error) { + var self = this; + + self.callApi({ + resource: 'menu.create', + data: { + accountId: self.accountId, + data: data + }, + success: function(data) { + callback && callback(data.data); + }, + error: function(errorPayload, data, globalHandler) { + error && error(errorPayload); + + //globalHandler(data, { generateError: true }); + } + }); + }, + + menuUpdate: function(data, callback, error) { + var self = this; + + self.callApi({ + resource: 'menu.update', + data: { + accountId: self.accountId, + menuId: data.id, + data: data + }, + success: function(data) { + callback && callback(data.data); + }, + error: function(errorPayload, data, globalHandler) { + error && error(errorPayload); + + //globalHandler(data, { generateError: true }); + } + }); + }, + + menuDelete: function(menuId, callback) { + var self = this; + + self.callApi({ + resource: 'menu.delete', + data: { + accountId: self.accountId, + menuId: menuId + }, + success: function(data) { + callback && callback(data.data); + } + }); + } + }; + + return app; +}); diff --git a/src/apps/callflows/submodules/misc/misc.css b/src/apps/callflows/submodules/misc/misc.css new file mode 100644 index 0000000..f8db865 --- /dev/null +++ b/src/apps/callflows/submodules/misc/misc.css @@ -0,0 +1,196 @@ +/********** Two columns **********/ + +.callflows-port #two_columns { + padding-bottom: 20px; +} + +.callflows-port #two_columns .wrapper { + clear: left; + width: 520px; + padding: 10px; +} + +.callflows-port #two_columns .wrapper_form { + margin-top: 20px; + margin-left: 40px; +} + +.callflows-port #two_columns .wrapper .column { + width: 220px; + padding: 6px 0px 5px; + background: #444; + border-radius: 6px; +} + +.callflows-port #two_columns .wrapper .column.right { + float: right; + margin-left: 10px; +} + +.callflows-port #two_columns .wrapper .column.left { + float: left; + margin-right: 10px; +} + +.callflows-port #two_columns .wrapper .title_column { + background-color: #AFAFAF; + height: 28px; + line-height: 28px; + font-weight: bold; + font-size: 14px; + text-align: center; + margin-bottom: 3px; +} + +.callflows-port #two_columns .wrapper .left ul.connect { + background-color: #444444; + height: 289px; + width: 220px; + overflow: auto; + float: left; +} + +.callflows-port #two_columns .wrapper .connect { + min-height: 289px; +} + +.callflows-port #two_columns .wrapper .right ul.connect { + background-color: #444444; + height: 289px; + width: 220px; + overflow: auto; +} + +.callflows-port #two_columns .wrapper li { + list-style-type: none; + background-color: #AFAFAF; + color: #444; + display: block; + height: 28px; + line-height: 28px; + list-style-type: none; + overflow: hidden; + position: relative; + cursor: default; +} + +.callflows-port #two_columns .wrapper li:not(:first-child) { + border-top: 1px solid #444; +} + +.callflows-port #two_columns .item_name { + float:left; + overflow: hidden; + height: 28px; + line-height: 28px; + width: 155px; + font-size: 12px; + white-space: nowrap; +} +.callflows-port #two_columns .item_name.right { + width: 120px; +} + +.callflows-port #two_columns .wrapper li:hover { + background-color: #cccccc; +} + +.callflows-port #two_columns .wrapper li a.drag_btn { + float: left; + height: 28px; + width: 7px; + margin-right: 5px; + margin-left: 1px; +} + +/* Ring group specific css */ +.callflows-port #two_columns .options { + float: right; + margin-right: 2px; + padding-left: 4px; + border-left: 1px solid #444444; + height: 28px; +} + +.callflows-port #two_columns .options .option { + width: 30px; + font-size: 12px; + margin-top: 2px; + height: 20px; +} + +.callflows-port #two_columns .ring_group_form_wrapper { + display: block; + margin: auto; + width: 260px; +} + +.callflows-port #two_columns .form_field_div { + width: 260px; +} + +.callflows-port #two_columns .button_field_div { + margin: 20px 0px 5px; + text-align: center; +} + +/********** Listpanel's search box **********/ + +.callflows-port .search_box { + height: 28px; + background-color:#444444; + padding-top: 7px; + border-bottom: 1px solid #222; +} + +.callflows-port .search_box .searchsubmit1 { + float: left; + height: 20px; + width: 23px; +} +.callflows-port .search_box .searchsubmit2 { + float: left; + height: 20px; + width: 26px; +} + +.callflows-port .search_box .searchfield { + border: medium none; + float: left; + height: 14px; + width: 130px; + border-radius: 0px; + box-shadow: none; +} + +.callflows-port .search_box .searchfield:focus { + border: none; + border-color: transparent; + -webkit-box-shadow: none; + -moz-box-shadow: none; + box-shadow: none; +} + +/********** Receive Fax **********/ + +.callflows-port#fax_callflow_popup #t_38_checkbox { + margin-top: 8px; +} + +/* Missed call alert */ +#missed_call_alert_popup { + width: 540px; +} +#missed_call_alert_popup .buttons-center { + margin-top: 10px; +} + +#missed_call_alert_popup form { + margin-bottom: 0; + margin-top: 20px; +} + +/* Collect DTMF Popup */ +.dialog_popup.collect-dtmf-popup .form_content .popup_field { + padding-bottom: 0; +} \ No newline at end of file diff --git a/src/apps/callflows/submodules/misc/misc.js b/src/apps/callflows/submodules/misc/misc.js new file mode 100644 index 0000000..fedea14 --- /dev/null +++ b/src/apps/callflows/submodules/misc/misc.js @@ -0,0 +1,1270 @@ +define(function(require){ + var $ = require('jquery'), + _ = require('underscore'), + monster = require('monster'); + + var app = { + requests: {}, + + subscribe: { + 'callflows.fetchActions': 'miscDefineActions' + }, + + miscGetGroupPickupData: function(callback) { + var self = this; + + monster.parallel({ + groups: function(callback) { + self.miscGroupList(function(data) { + callback(null, data); + }); + }, + users: function(callback) { + self.miscUserList(function(data) { + _.each(data, function(user) { + user.name = user.first_name + ' ' + user.last_name; + }); + callback(null, data); + }); + }, + devices: function(callback) { + self.miscDeviceList(function(data) { + callback(null, data); + }); + } + }, + function(err, results) { + callback && callback(results); + } + ); + }, + + miscDefineActions: function(args) { + var self = this, + callflow_nodes = args.actions; + + $.extend(callflow_nodes, { + 'root': { + name: 'Root', + rules: [ + { + type: 'quantity', + maxSize: '1' + } + ], + isUsable : 'false' + }, + 'callflow[id=*]': { + name: self.i18n.active().oldCallflows.callflow, + icon: 'callflow', + category: self.i18n.active().oldCallflows.advanced_cat, + module: 'callflow', + tip: self.i18n.active().oldCallflows.callflow_tip, + data: { + id: 'null' + }, + rules: [ + { + type: 'quantity', + maxSize: '1' + } + ], + isUsable: 'true', + weight: 20, + caption: function(node, caption_map) { + var id = node.getMetadata('id'), + return_value = ''; + + if(id in caption_map) { + if(caption_map[id].hasOwnProperty('name')) { + return_value = caption_map[id].name; + } + else if(caption_map[id].hasOwnProperty('numbers')) { + return_value = caption_map[id].numbers.toString(); + } + } + + return return_value; + }, + edit: function(node, callback) { + self.callApi({ + resource: 'callflow.list', + data: { + accountId: self.accountId, + filters: { paginate:false } + }, + success:function(data, status) { + var popup, popup_html, _data = []; + + $.each(data.data, function() { + if(!this.featurecode && this.id !== self.flow.id) { + this.name = this.name ? this.name : ((this.numbers) ? this.numbers.toString() : self.i18n.active().oldCallflows.no_numbers); + + _data.push(this); + } + }); + + popup_html = $(monster.template(self, 'callflow-edit_dialog', { + objects: { + type: 'callflow', + items: _.sortBy(_data, 'name'), + selected: node.getMetadata('id') || '' + } + })); + + $('#add', popup_html).click(function() { + node.setMetadata('id', $('#object-selector', popup_html).val()); + + node.caption = $('#object-selector option:selected', popup_html).text(); + + popup.dialog('close'); + }); + + popup = monster.ui.dialog(popup_html, { + title: self.i18n.active().oldCallflows.callflow_title, + beforeClose: function() { + if(typeof callback == 'function') { + callback(); + } + } + }); + } + }); + } + }, + 'do_not_disturb[action=activate]': { + name: self.i18n.active().callflows.doNotDisturb.activate.label, + icon: 'x_circle', + category: self.i18n.active().callflows.doNotDisturb.categoryName, + module: 'do_not_disturb', + tip: self.i18n.active().callflows.doNotDisturb.activate.tip, + data: { + action: 'activate' + }, + rules: [ + { + type: 'quantity', + maxSize: '1' + } + ], + isUsable: 'true', + weight: 1, + caption: function(node) { + return ''; + }, + edit: function(node, callback) { + if (typeof callback === 'function') { + callback(); + } + } + }, + 'do_not_disturb[action=deactivate]': { + name: self.i18n.active().callflows.doNotDisturb.deactivate.label, + icon: 'x_circle', + category: self.i18n.active().callflows.doNotDisturb.categoryName, + module: 'do_not_disturb', + tip: self.i18n.active().callflows.doNotDisturb.deactivate.tip, + data: { + action: 'deactivate' + }, + rules: [ + { + type: 'quantity', + maxSize: '1' + } + ], + isUsable: 'true', + weight: 2, + caption: function(node) { + return ''; + }, + edit: function(node, callback) { + if (typeof callback === 'function') { + callback(); + } + } + }, + 'do_not_disturb[action=toggle]': { + name: self.i18n.active().callflows.doNotDisturb.toggle.label, + icon: 'x_circle', + category: self.i18n.active().callflows.doNotDisturb.categoryName, + module: 'do_not_disturb', + tip: self.i18n.active().callflows.doNotDisturb.toggle.tip, + data: { + action: 'toggle' + }, + rules: [ + { + type: 'quantity', + maxSize: '1' + } + ], + isUsable: 'true', + weight: 3, + caption: function(node) { + return ''; + }, + edit: function(node, callback) { + if (typeof callback === 'function') { + callback(); + } + } + }, + 'call_forward[action=activate]': { + name: self.i18n.active().oldCallflows.enable_call_forwarding, + icon: 'rightarrow', + category: self.i18n.active().oldCallflows.call_forwarding_cat, + module: 'call_forward', + tip: self.i18n.active().oldCallflows.enable_call_forwarding_tip, + data: { + action: 'activate' + }, + rules: [ + { + type: 'quantity', + maxSize: '1' + } + ], + isUsable: 'true', + weight: 10, + caption: function(node, caption_map) { + return ''; + }, + edit: function(node, callback) { + if(typeof callback == 'function') { + callback(); + } + } + }, + 'call_forward[action=deactivate]': { + name: self.i18n.active().oldCallflows.disable_call_forwarding, + icon: 'rightarrow', + category: self.i18n.active().oldCallflows.call_forwarding_cat, + module: 'call_forward', + tip: self.i18n.active().oldCallflows.disable_call_forwarding_tip, + data: { + action: 'deactivate' + }, + rules: [ + { + type: 'quantity', + maxSize: '1' + } + ], + isUsable: 'true', + weight: 20, + caption: function(node, caption_map) { + return ''; + }, + edit: function(node, callback) { + if(typeof callback == 'function') { + callback(); + } + } + }, + 'call_forward[action=update]': { + name: self.i18n.active().oldCallflows.update_call_forwarding, + icon: 'rightarrow', + category: self.i18n.active().oldCallflows.call_forwarding_cat, + module: 'call_forward', + tip: self.i18n.active().oldCallflows.update_call_forwarding_tip, + data: { + action: 'update' + }, + rules: [ + { + type: 'quantity', + maxSize: '1' + } + ], + isUsable: 'true', + weight: 30, + caption: function(node, caption_map) { + return ''; + }, + edit: function(node, callback) { + if(typeof callback == 'function') { + callback(); + } + } + }, + 'dynamic_cid[]': { + name: self.i18n.active().oldCallflows.dynamic_cid, + icon: 'rightarrow', + category: self.i18n.active().oldCallflows.caller_id_cat, + module: 'dynamic_cid', + tip: self.i18n.active().oldCallflows.dynamic_cid_tip, + isUsable: 'true', + weight: 10, + caption: function(node, caption_map) { + return ''; + }, + edit: function(node, callback) { + if(typeof callback == 'function') { + callback(); + } + } + }, + 'prepend_cid[action=prepend]': { + name: self.i18n.active().oldCallflows.prepend, + icon: 'plus_circle', + category: self.i18n.active().oldCallflows.caller_id_cat, + module: 'prepend_cid', + tip: self.i18n.active().oldCallflows.prepend_tip, + data: { + action: 'prepend', + caller_id_name_prefix: '', + caller_id_number_prefix: '', + apply_to: 'original' + }, + rules: [ + { + type: 'quantity', + maxSize: '1' + } + ], + isUsable: 'true', + weight: 20, + caption: function(node, caption_map) { + return (node.getMetadata('caller_id_name_prefix') || '') + ' ' + (node.getMetadata('caller_id_number_prefix') || ''); + }, + edit: function(node, callback) { + var popup, popup_html; + + popup_html = $(monster.template(self, 'misc-prepend_cid_callflow', { + data_cid: { + 'caller_id_name_prefix': node.getMetadata('caller_id_name_prefix') || '', + 'caller_id_number_prefix': node.getMetadata('caller_id_number_prefix') || '', + 'apply_to': node.getMetadata('apply_to') || '' + } + })); + + $('#add', popup_html).click(function() { + var cid_name_val = $('#cid_name_prefix', popup_html).val(), + cid_number_val = $('#cid_number_prefix', popup_html).val(), + apply_to_val = $('#apply_to', popup_html).val(); + + node.setMetadata('caller_id_name_prefix', cid_name_val); + node.setMetadata('caller_id_number_prefix', cid_number_val); + node.setMetadata('apply_to', apply_to_val); + + node.caption = cid_name_val + ' ' + cid_number_val; + + popup.dialog('close'); + }); + + popup = monster.ui.dialog(popup_html, { + title: self.i18n.active().oldCallflows.prepend_caller_id_title, + beforeClose: function() { + if(typeof callback == 'function') { + callback(); + } + } + }); + + monster.ui.tooltips(popup); + + if (typeof callback === 'function') { + callback(); + } + } + }, + 'prepend_cid[action=reset]': { + name: self.i18n.active().oldCallflows.reset_prepend, + icon: 'loop2', + category: self.i18n.active().oldCallflows.caller_id_cat, + module: 'prepend_cid', + tip: self.i18n.active().oldCallflows.reset_prepend_tip, + data: { + action: 'reset' + }, + rules: [ + { + type: 'quantity', + maxSize: '1' + } + ], + isUsable: 'true', + weight: 30, + caption: function(node, caption_map) { + return ''; + }, + edit: function(node, callback) { + if(typeof callback == 'function') { + callback(); + } + } + }, + 'manual_presence[]': { + name: self.i18n.active().oldCallflows.manual_presence, + icon: 'lightbulb_on', + category: self.i18n.active().oldCallflows.advanced_cat, + module: 'manual_presence', + tip: self.i18n.active().oldCallflows.manual_presence_tip, + data: { + }, + rules: [ + { + type: 'quantity', + maxSize: '1' + } + ], + isUsable: 'true', + weight: 40, + caption: function(node, caption_map) { + return node.getMetadata('presence_id') || ''; + }, + edit: function(node, callback) { + var popup_html = $(monster.template(self, 'presence-callflowEdit', { + data_presence: { + 'presence_id': node.getMetadata('presence_id') || '', + 'status': node.getMetadata('status') || 'busy' + } + })), + popup; + + $('#add', popup_html).click(function() { + var presence_id = $('#presence_id_input', popup_html).val(); + node.setMetadata('presence_id', presence_id); + node.setMetadata('status', $('#presence_status option:selected', popup_html).val()); + + node.caption = presence_id; + + popup.dialog('close'); + }); + + popup = monster.ui.dialog(popup_html, { + title: self.i18n.active().oldCallflows.manual_presence_title, + beforeClose: function() { + if(typeof callback == 'function') { + callback(); + } + } + }); + } + }, + 'language[]': { + name: self.i18n.active().oldCallflows.language, + icon: 'earth', + category: self.i18n.active().oldCallflows.advanced_cat, + module: 'language', + tip: self.i18n.active().oldCallflows.language_tip, + data: { + }, + rules: [ + { + type: 'quantity', + maxSize: '1' + } + ], + isUsable: 'true', + weight: 50, + caption: function(node, caption_map) { + return node.getMetadata('language') || ''; + }, + edit: function(node, callback) { + var popup, popup_html; + + popup_html = $(monster.template(self, 'misc-language', { + data_language: { + 'language': node.getMetadata('language') || '' + } + })); + + $('#add', popup_html).click(function() { + var language = $('#language_id_input', popup_html).val(); + node.setMetadata('language', language); + node.caption = language; + + popup.dialog('close'); + }); + + popup = monster.ui.dialog(popup_html, { + title: self.i18n.active().oldCallflows.language_title, + beforeClose: function() { + if(typeof callback == 'function') { + callback(); + } + } + }); + } + }, + 'group_pickup[]': { + name: self.i18n.active().oldCallflows.group_pickup, + icon: 'sip', + category: self.i18n.active().oldCallflows.advanced_cat, + module: 'group_pickup', + tip: self.i18n.active().oldCallflows.group_pickup_tip, + data: { + }, + rules: [ + { + type: 'quantity', + maxSize: '0' + } + ], + isUsable: 'true', + weight: 60, + caption: function(node, caption_map) { + return node.getMetadata('name') || ''; + }, + edit: function(node, callback) { + self.miscGetGroupPickupData(function(results) { + var popup, popup_html; + + popup_html = $(monster.template(self, 'misc-group_pickup', { + data: { + items: results, + selected: node.getMetadata('device_id') || node.getMetadata('group_id') || node.getMetadata('user_id') || '' + } + })); + + $('#add', popup_html).click(function() { + var selector = $('#endpoint_selector', popup_html), + id = selector.val(), + name = selector.find('#'+id).html(), + type = $('#'+ id, popup_html).parents('optgroup').data('type'), + type_id = type.substring(type, type.length - 1) + '_id'; + + /* Clear all the useless attributes */ + node.data.data = {}; + node.setMetadata(type_id, id); + node.setMetadata('name', name); + + node.caption = name; + + popup.dialog('close'); + }); + + popup = monster.ui.dialog(popup_html, { + title: self.i18n.active().oldCallflows.select_endpoint_title, + beforeClose: function() { + callback && callback(); + } + }); + }); + } + }, + 'receive_fax[]': { + name: self.i18n.active().oldCallflows.receive_fax, + icon: 'sip', + category: self.i18n.active().oldCallflows.advanced_cat, + module: 'receive_fax', + tip: self.i18n.active().oldCallflows.receive_fax_tip, + data: { + owner_id: null + }, + rules: [ + { + type: 'quantity', + maxSize: '0' + } + ], + isUsable: 'true', + weight: 70, + caption: function(node, caption_map) { + return ''; + }, + edit: function(node, callback) { + self.miscUserList(function(data, status) { + var popup, popup_html; + + $.each(data, function() { + this.name = this.first_name + ' ' + this.last_name; + }); + + popup_html = $(monster.template(self, 'fax-callflowEdit', { + objects: { + items: data, + selected: node.getMetadata('owner_id') || '', + t_38: node.getMetadata('media') && node.getMetadata('media').fax_option || false + } + })); + + if($('#user_selector option:selected', popup_html).val() == undefined) { + $('#edit_link', popup_html).hide(); + } + + $('.inline_action', popup_html).click(function(ev) { + var _data = ($(this).data('action') == 'edit') ? + { id: $('#user_selector', popup_html).val() } : {}; + + ev.preventDefault(); + + monster.pub('callflows.user.popupEdit', { + data: _data, + callback: function(_data) { + node.setMetadata('owner_id', _data.id || 'null'); + + popup.dialog('close'); + } + }); + }); + + $('#add', popup_html).click(function() { + node.setMetadata('owner_id', $('#user_selector', popup_html).val()); + node.setMetadata('media', { + fax_option: $('#t_38_checkbox', popup_html).is(':checked') + }); + popup.dialog('close'); + }); + + popup = monster.ui.dialog(popup_html, { + title: self.i18n.active().oldCallflows.select_user_title, + minHeight: '0', + beforeClose: function() { + if(typeof callback == 'function') { + callback(); + } + } + }); + }); + } + }, + 'record_call[action=start]': { + name: self.i18n.active().oldCallflows.start_call_recording, + icon: 'conference', + category: self.i18n.active().oldCallflows.call_recording_cat, + module: 'record_call', + tip: self.i18n.active().oldCallflows.start_call_recording_tip, + data: { + action: 'start' + }, + rules: [ + { + type: 'quantity', + maxSize: '1' + } + ], + isUsable: 'true', + weight: 10, + caption: function(node) { + return ''; + }, + edit: function(node, callback) { + var popup_html = $(monster.template(self, 'recordCall-callflowEdit', { + data_call_record: { + 'format': node.getMetadata('format') || 'mp3', + 'url': node.getMetadata('url') || '', + 'time_limit': node.getMetadata('time_limit') || '600' + } + })), + popup; + + $('#add', popup_html).click(function() { + node.setMetadata('url', $('#url', popup_html).val()); + node.setMetadata('format', $('#format', popup_html).val()); + node.setMetadata('time_limit', $('#time_limit', popup_html).val()); + + popup.dialog('close'); + }); + + popup = monster.ui.dialog(popup_html, { + title: self.i18n.active().oldCallflows.start_call_recording, + minHeight: '0', + beforeClose: function() { + if(typeof callback == 'function') { + callback(); + } + } + }); + } + }, + 'record_call[action=stop]': { + name: self.i18n.active().oldCallflows.stop_call_recording, + icon: 'conference', + category: self.i18n.active().oldCallflows.call_recording_cat, + module: 'record_call', + tip: self.i18n.active().oldCallflows.stop_call_recording_tip, + data: { + action: 'stop' + }, + rules: [ + { + type: 'quantity', + maxSize: '1' + } + ], + isUsable: 'true', + weight: 20, + caption: function(node) { + return ''; + }, + edit: function(node, callback) { + } + }, + 'pivot[]': { + name: self.i18n.active().oldCallflows.pivot, + icon: 'conference', + category: self.i18n.active().oldCallflows.advanced_cat, + module: 'pivot', + tip: self.i18n.active().oldCallflows.pivot_tip, + data: { + method: 'get', + req_timeout: '5', + req_format: 'twiml', + voice_url: '' + }, + rules: [ + { + type: 'quantity', + maxSize: '0' + } + ], + isUsable: 'true', + weight: 80, + caption: function(node) { + return ''; + }, + edit: function(node, callback) { + var popup, popup_html; + + popup_html = $(monster.template(self,'misc-pivot', { + data_pivot: { + 'method': node.getMetadata('method') || 'get', + 'voice_url': node.getMetadata('voice_url') || '', + 'req_timeout': node.getMetadata('req_timeout') || '5', + 'req_format': node.getMetadata('req_format') || 'twiml' + } + })); + + $('#add', popup_html).click(function() { + node.setMetadata('voice_url', $('#pivot_voiceurl_input', popup_html).val()); + node.setMetadata('method', $('#pivot_method_input', popup_html).val()); + node.setMetadata('req_format', $('#pivot_format_input', popup_html).val()); + + popup.dialog('close'); + }); + + popup = monster.ui.dialog(popup_html, { + title: self.i18n.active().oldCallflows.pivot_title, + minHeight: '0', + beforeClose: function() { + if(typeof callback == 'function') { + callback(); + } + } + }); + } + }, + 'disa[]': { + name: self.i18n.active().oldCallflows.disa, + icon: 'conference', + category: self.i18n.active().oldCallflows.advanced_cat, + module: 'disa', + tip: self.i18n.active().oldCallflows.disa_tip, + data: { + pin: '', + use_account_caller_id: true + }, + rules: [ + { + type: 'quantity', + maxSize: '0' + } + ], + isUsable: 'true', + weight: 90, + caption: function(node) { + return ''; + }, + edit: function(node, callback) { + var popup, popup_html; + + popup_html = $(monster.template(self,'misc-disa', { + data_disa: { + 'pin': node.getMetadata('pin'), + 'retries': node.getMetadata('retries'), + 'interdigit': node.getMetadata('interdigit'), + 'max_digits': node.getMetadata('max_digits'), + 'preconnect_audio': node.getMetadata('preconnect_audio'), + 'use_account_caller_id': node.getMetadata('use_account_caller_id') + } + })); + + monster.ui.tooltips(popup_html); + + $('#add', popup_html).click(function() { + var save_disa = function() { + var setData = function(field, value) { + if(value !== 'default') { + node.setMetadata(field, value); + } + else { + node.deleteMetadata(field); + } + }; + + setData('pin', $('#disa_pin_input', popup_html).val()); + setData('retries', $('#disa_retries_input', popup_html).val()); + setData('interdigit', $('#disa_interdigit_input', popup_html).val()); + setData('preconnect_audio', $('#preconnect_audio', popup_html).val()); + setData('use_account_caller_id', !$('#disa_keep_original_caller_id', popup_html).is(':checked')); + setData('max_digits', $('#disa_max_digits_input', popup_html).val()); + + popup.dialog('close'); + }; + if($('#disa_pin_input', popup_html).val() == '') { + monster.ui.confirm(self.i18n.active().oldCallflows.not_setting_a_pin, function() { + save_disa(); + }); + } + else { + save_disa(); + } + }); + + popup = monster.ui.dialog(popup_html, { + title: self.i18n.active().callflows.disa.title, + beforeClose: function() { + if(typeof callback == 'function') { + callback(); + } + } + }); + } + }, + 'collect_dtmf[]': { + name: self.i18n.active().callflows.collectDTMF.title, + icon: 'conference', + category: self.i18n.active().oldCallflows.advanced_cat, + module: 'collect_dtmf', + tip: self.i18n.active().callflows.collectDTMF.tip, + data: { + pin: '', + use_account_caller_id: true + }, + rules: [ + { + type: 'quantity', + maxSize: '1' + } + ], + isUsable: 'true', + weight: 90, + caption: function(node) { + return ''; + }, + edit: function(node, callback) { + var popup, popup_html; + + popup_html = $(monster.template(self, 'misc-collect-dtmf', { + data_dtmf: { + 'interdigit_timeout': node.getMetadata('interdigit_timeout') || '', + 'collection_name': node.getMetadata('collection_name') || '', + 'max_digits': node.getMetadata('max_digits') || '', + 'terminator': node.getMetadata('terminator') || '#', + 'timeout': node.getMetadata('timeout') || '5000' + } + })); + + monster.ui.tooltips(popup_html); + + $('#add', popup_html).click(function() { + var setData = function(field, value) { + if (value !== 'default' && value !== '') { + node.setMetadata(field, value); + } else { + node.deleteMetadata(field); + } + }; + + setData('interdigit_timeout', $('#collect_dtmf_interdigit_input', popup_html).val()); + setData('collection_name', $('#collect_dtmf_collection_input', popup_html).val()); + setData('max_digits', $('#collect_dtmf_max_digits_input', popup_html).val()); + setData('terminator', $('#collect_dtmf_terminator_input', popup_html).val()); + setData('timeout', $('#collect_dtmf_timeout_input', popup_html).val()); + + popup.dialog('close'); + }); + + popup = monster.ui.dialog(popup_html, { + title: self.i18n.active().callflows.collectDTMF.title, + beforeClose: function() { + if (typeof callback === 'function') { + callback(); + } + } + }); + } + }, + 'sleep[]': { + name: self.i18n.active().callflows.sleep.name, + icon: 'dot_chat', + category: self.i18n.active().oldCallflows.advanced_cat, + module: 'sleep', + tip: self.i18n.active().callflows.sleep.tip, + data: { + duration: '', + unit: 's' + }, + rules: [ + { + type: 'quantity', + maxSize: '1' + } + ], + isUsable: 'true', + weight: 47, + caption: function(node) { + return ''; + }, + edit: function(node, callback) { + var popup, popup_html; + + popup_html = $(monster.template(self, 'misc-sleep', { + data_sleep: { + 'duration': node.getMetadata('duration') + } + })); + + monster.ui.tooltips(popup_html); + + $('#add', popup_html).click(function() { + var setData = function(field, value) { + if (value !== 'default') { + node.setMetadata(field, value); + } else { + node.deleteMetadata(field); + } + }; + + setData('duration', $('#sleep_duration_input', popup_html).val()); + + popup.dialog('close'); + }); + + popup = monster.ui.dialog(popup_html, { + title: self.i18n.active().callflows.sleep.title, + beforeClose: function() { + if (typeof callback === 'function') { + callback(); + } + } + }); + } + }, + 'tts[]': { + name: self.i18n.active().callflows.tts.name, + icon: 'chat_circle', + category: self.i18n.active().oldCallflows.advanced_cat, + module: 'tts', + tip: self.i18n.active().callflows.tts.tip, + data: { + text: '' + }, + rules: [ + { + type: 'quantity', + maxSize: '1' + } + ], + isUsable: 'true', + weight: 45, + caption: function(node) { + return ''; + }, + edit: function(node, callback) { + var popup, popup_html; + + popup_html = $(monster.template(self, 'misc-tts', { + data_tts: { + 'text': node.getMetadata('text'), + 'language': node.getMetadata('language'), + 'voice': node.getMetadata('voice') + } + })); + + monster.ui.tooltips(popup_html); + + $('#add', popup_html).click(function() { + var setData = function(field, value) { + if (value !== 'default') { + node.setMetadata(field, value); + } else { + node.deleteMetadata(field); + } + }; + + setData('text', $('#tts_text_input', popup_html).val()); + setData('language', $('#tts_language_input', popup_html).val()); + setData('voice', $('#tts_voice_input', popup_html).val()); + + popup.dialog('close'); + }); + + popup = monster.ui.dialog(popup_html, { + title: self.i18n.active().callflows.tts.title, + beforeClose: function() { + if (typeof callback === 'function') { + callback(); + } + } + }); + } + }, + 'response[]': { + name: self.i18n.active().oldCallflows.response, + icon: 'rightarrow', + category: self.i18n.active().oldCallflows.advanced_cat, + module: 'response', + tip: self.i18n.active().oldCallflows.response_tip, + data: { + code: '', + message: '', + media: 'null' + }, + rules: [ + { + type: 'quantity', + maxSize: '0' + } + ], + isUsable: 'true', + weight: 100, + caption: function(node, caption_map) { + return self.i18n.active().oldCallflows.sip_code_caption + node.getMetadata('code'); + }, + edit: function(node, callback) { + self.miscMediaList(function(data) { + var popup, popup_html; + + popup_html = $(monster.template(self, 'misc-response', { + response_data: { + items: data, + media_enabled: node.getMetadata('media') ? true : false, + selected_media: node.getMetadata('media') || '', + code: node.getMetadata('code') || '', + message: node.getMetadata('message') || '' + } + })); + + if($('#media_selector option:selected', popup_html).val() == undefined + || $('#media_selector option:selected', popup_html).val() == 'null') { + $('#edit_link', popup_html).hide(); + } + + $('#media_selector', popup_html).change(function() { + if($('#media_selector option:selected', popup_html).val() == undefined + || $('#media_selector option:selected', popup_html).val() == 'null') { + $('#edit_link', popup_html).hide(); + } else { + $('#edit_link', popup_html).show(); + } + }) + + $('.inline_action', popup_html).click(function(ev) { + var _data = ($(this).data('action') == 'edit') ? + { id: $('#media_selector', popup_html).val() } : {}; + + ev.preventDefault(); + + monster.pub('callflows.media.editPopup', { + data: _data, + callback: function(_data) { + node.setMetadata('media', _data.data.id || 'null'); + + popup.dialog('close'); + } + }); + }); + + $('#add', popup_html).click(function() { + if($('#response_code_input', popup_html).val().match(/^[1-6][0-9]{2}$/)) { + node.setMetadata('code', $('#response_code_input', popup_html).val()); + node.setMetadata('message', $('#response_message_input', popup_html).val()); + if($('#media_selector', popup_html).val() && $('#media_selector', popup_html).val() != 'null') { + node.setMetadata('media', $('#media_selector', popup_html).val()); + } else { + node.deleteMetadata('media'); + } + + node.caption = self.i18n.active().oldCallflows.sip_code_caption + $('#response_code_input', popup_html).val(); + + popup.dialog('close'); + } else { + monster.ui.alert('error', self.i18n.active().oldCallflows.please_enter_a_valide_sip_code); + } + }); + + popup = monster.ui.dialog(popup_html, { + title: self.i18n.active().oldCallflows.response_title, + minHeight: '0', + beforeClose: function() { + if(typeof callback == 'function') { + callback(); + } + } + }); + }); + } + }, + 'missed_call_alert[]': { + name: self.i18n.active().callflows.missedCallAlert.title, + icon: 'bell1', + category: self.i18n.active().oldCallflows.advanced_cat, + module: 'missed_call_alert', + tip: self.i18n.active().callflows.missedCallAlert.tip, + data: { + name: '' + }, + rules: [ + { + type: 'quantity', + maxSize: '1' + } + ], + isUsable: 'true', + weight: 31, + caption: function() { + return ''; + }, + edit: function(node, callback) { + self.miscEditMissedCallAlerts(node, callback); + } + } + }); + }, + + miscEditMissedCallAlerts: function(node, callback) { + var self = this, + recipients = node.getMetadata('recipients'), + mapUsers = {}, + selectedEmails = [], + popup; + + _.each(recipients, function(recipient) { + if (recipient.type === 'user') { + mapUsers[recipient.id] = recipient; + } else if (recipient.type === 'email') { + selectedEmails.push(recipient.id); + } + }); + + self.miscUserList(function(users) { + var items = [], + selectedItems = []; + + _.each(users, function(user) { + var formattedUser = { + key: user.id, + value: user.first_name + ' ' + user.last_name + }; + + items.push(formattedUser); + + if (mapUsers.hasOwnProperty(user.id)) { + selectedItems.push(formattedUser); + } + }); + + var template = $(monster.template(self, 'misc-missedCallAlert-dialog', { emails: selectedEmails.toString() })), + widget = monster.ui.linkedColumns(template.find('.items-selector-wrapper'), items, selectedItems, { + i18n: { + columnsTitles: { + available: self.i18n.active().callflows.missedCallAlert.unselectedUsers, + selected: self.i18n.active().callflows.missedCallAlert.selectedUsers + } + }, + containerClasses: 'skinny' + }); + + template.find('#save_missed_call_alerts').on('click', function() { + var recipients = [], + emails = template.find('#emails').val(); + + emails = emails.replace(/\s/g, '').split(','); + + _.each(emails, function(email) { + recipients.push({ + type: 'email', + id: email + }); + }); + + _.each(widget.getSelectedItems(), function(id) { + recipients.push({ + type: 'user', + id: id + }); + }); + + node.setMetadata('recipients', recipients); + + popup.dialog('close'); + }); + + popup = monster.ui.dialog(template, { + title: self.i18n.active().callflows.missedCallAlert.popupTitle, + beforeClose: function() { + if (typeof callback === 'function') { + callback(); + } + } + }); + }); + }, + + miscDeviceList: function(callback) { + var self = this; + + self.callApi({ + resource: 'device.list', + data: { + accountId: self.accountId, + filters: { paginate:false } + }, + success: function(data, status) { + callback && callback(data.data); + } + }); + }, + + miscGroupList: function(callback) { + var self = this; + + self.callApi({ + resource: 'group.list', + data: { + accountId: self.accountId, + filters: { paginate:false } + }, + success: function(data, status) { + callback && callback(data.data); + } + }); + }, + + miscUserList: function(callback) { + var self = this; + + self.callApi({ + resource: 'user.list', + data: { + accountId: self.accountId, + filters: { paginate:false } + }, + success: function(data, status) { + callback && callback(data.data); + } + }); + }, + + miscMediaList: function(callback) { + var self = this; + + self.callApi({ + resource: 'media.list', + data: { + accountId: self.accountId, + filters: { paginate:false } + }, + success: function(data, status) { + callback && callback(data.data); + } + }); + } + }; + + return app; +}); diff --git a/src/apps/callflows/submodules/qubicle/qubicle.js b/src/apps/callflows/submodules/qubicle/qubicle.js new file mode 100644 index 0000000..f0f36ea --- /dev/null +++ b/src/apps/callflows/submodules/qubicle/qubicle.js @@ -0,0 +1,93 @@ +define(function(require) { + var $ = require('jquery'), + _ = require('underscore'), + monster = require('monster'); + + var app = { + requests: {}, + + subscribe: { + 'callflows.fetchActions': 'qubicleDefineActions' + }, + + qubicleDefineActions: function(args) { + var self = this, + callflow_nodes = args.actions; + + $.extend(callflow_nodes, { + 'qubicle[id=*]': { + name: self.i18n.active().callflows.qubicle.qubicle, + icon: 'support', + category: self.i18n.active().oldCallflows.advanced_cat, + module: 'qubicle', + tip: self.i18n.active().callflows.qubicle.qubicle_tip, + data: { + }, + rules: [ + { + type: 'quantity', + maxSize: '1' + } + ], + isUsable: 'true', + isListed: false, + weight: 30, + caption: function(node, caption_map) { + var id = node.getMetadata('id'), + returned_value = ''; + + if (id in caption_map) { + returned_value = caption_map[id].name; + } + + return returned_value; + }, + edit: function(node, callback) { + self.qubicleList(function(data) { + var popup_html = $(monster.template(self, 'qubicle-callflowEdit', { + items: _.sortBy(data, 'name'), + selected: node.getMetadata('id') || '' + })), + popup; + + $('#add', popup_html).click(function() { + node.setMetadata('id', $('#queue_selector', popup_html).val()); + + node.caption = $('#queue_selector option:selected', popup_html).text(); + + popup.dialog('close'); + }); + + popup = monster.ui.dialog(popup_html, { + title: self.i18n.active().callflows.qubicle.qubicle, + minHeight: '0', + beforeClose: function() { + if (typeof callback === 'function') { + callback(); + } + } + }); + }); + } + } + }); + }, + + qubicleList: function(callback) { + var self = this; + + self.callApi({ + resource: 'qubicleQueues.list', + data: { + accountId: self.accountId, + filters: { paginate: false } + }, + success: function(data) { + callback && callback(data.data); + } + }); + } + }; + + return app; +}); diff --git a/src/apps/callflows/submodules/resource/resource.js b/src/apps/callflows/submodules/resource/resource.js new file mode 100644 index 0000000..7286226 --- /dev/null +++ b/src/apps/callflows/submodules/resource/resource.js @@ -0,0 +1,94 @@ +define(function(require){ + var $ = require('jquery'), + _ = require('underscore'), + monster = require('monster'); + + var app = { + requests: {}, + + subscribe: { + 'callflows.fetchActions': 'resourceDefineActions' + }, + + resourceDefineActions: function(args) { + var self = this, + callflow_nodes = args.actions; + + $.extend(callflow_nodes, { + 'offnet[]': { + name: self.i18n.active().callflows.resource.global_carrier, + icon: 'offnet', + category: self.i18n.active().oldCallflows.advanced_cat, + module: 'offnet', + tip: self.i18n.active().callflows.resource.global_carrier_tip, + data: {}, + rules: [ + { + type: 'quantity', + maxSize: '0' + } + ], + isUsable: 'true', + weight: 140, + caption: function(node, caption_map) { + return ''; + }, + edit: function(node, callback) { + if(typeof callback == 'function') { + callback(); + } + } + }, + 'resources[]': { + name: self.i18n.active().callflows.resource.account_carrier, + icon: 'resource', + category: self.i18n.active().oldCallflows.advanced_cat, + module: 'resources', + tip: self.i18n.active().callflows.resource.account_carrier_tip, + data: {}, + rules: [ + { + type: 'quantity', + maxSize: '0' + } + ], + isUsable: 'true', + weight: 150, + caption: function(node, caption_map) { + return ''; + }, + edit: function(node, callback) { + var popup, popup_html; + + popup_html = $(monster.template(self, 'resource-account_carrier', { + data_resource: { + 'hunt_account_id': node.getMetadata('hunt_account_id') || '', + } + })); + + $('#add', popup_html).click(function() { + var hunt_id = $('#hunt_account_id', popup_html).val(); + + if(hunt_id) { + node.setMetadata('hunt_account_id', hunt_id); + } + + popup.dialog('close'); + }); + + popup = monster.ui.dialog(popup_html, { + title: self.i18n.active().callflows.resource.account_carrier_title, + beforeClose: function() { + if(typeof callback == 'function') { + callback(); + } + } + }); + } + } + }); + } + }; + + return app; +}); diff --git a/src/apps/callflows/submodules/temporalset/temporalset.css b/src/apps/callflows/submodules/temporalset/temporalset.css new file mode 100644 index 0000000..b3969a3 --- /dev/null +++ b/src/apps/callflows/submodules/temporalset/temporalset.css @@ -0,0 +1,10 @@ +.callflows-port #temporalset-form .items-selector-wrapper { + width: 535px; + margin-left: 99px; +} + +.callflows-port .warning-no-save { + display: inline-block; + color: red; + margin-right: 10px; +} \ No newline at end of file diff --git a/src/apps/callflows/submodules/temporalset/temporalset.js b/src/apps/callflows/submodules/temporalset/temporalset.js new file mode 100644 index 0000000..4b16f68 --- /dev/null +++ b/src/apps/callflows/submodules/temporalset/temporalset.js @@ -0,0 +1,369 @@ +define(function(require){ + var $ = require('jquery'), + _ = require('underscore'), + monster = require('monster'); + + var app = { + requests: {}, + + subscribe: { + 'callflows.fetchActions': 'temporalsetDefineActions', + 'callflows.temporalset.edit': '_temporalsetEdit' + }, + + temporalsetSave: function(form_data, data, success, error) { + var self = this, + normalized_data = self.temporalsetNormalizeData($.extend(true, {}, data.data, form_data), form_data); + + if (typeof data.data === 'object' && data.data.id) { + self.temporalSetUpdate(normalized_data, function(_data, status) { + success && success(_data, status, 'update'); + }); + } else { + self.temporalSetCreate(normalized_data, function(_data, status) { + success & success(_data, status, 'create'); + }); + } + }, + + temporalsetPopupEdit: function(args) { + var self = this, + popup, + popup_html, + data = args.data, + callback = args.callback, + data_defaults = args.data_defaults; + + popup_html = $('
    '); + + self.temporalsetEdit(data, popup_html, $('.inline_content', popup_html), { + save_success: function(_data) { + popup.dialog('close'); + + if (typeof callback === 'function') { + callback(_data); + } + }, + delete_success: function() { + popup.dialog('close'); + + if (typeof callback === 'function') { + callback({ data: {} }); + } + }, + after_render: function() { + popup = monster.ui.dialog(popup_html, { + title: (data.id) ? self.i18n.active().callflows.temporalset.editSet : self.i18n.active().callflows.temporalset.createSet + }); + } + }, data_defaults); + }, + + // Added for the subscribed event to avoid refactoring temporalsetEdit + _temporalsetEdit: function(args) { + var self = this; + self.temporalsetEdit(args.data, args.parent, args.target, args.callbacks, args.data_defaults); + }, + + temporalsetEdit: function(data, _parent, _target, _callbacks, data_defaults) { + var self = this, + parent = _parent || $('#temporalset-content'), + target = _target || $('#temporalset-view', parent), + _callbacks = _callbacks || {}, + callbacks = { + save_success: _callbacks.save_success, + save_error: _callbacks.save_error, + delete_success: _callbacks.delete_success, + delete_error: _callbacks.delete_error, + after_render: _callbacks.after_render + }, + defaults = { + data: $.extend(true, { + extra: { + showSave: true + } + }, data_defaults || {}), + field_data: {} + }; + + self.temporalSetGetData((data || {}).id, function(results) { + var formattedData = self.temporalsetFormatData(results.temporalSet), + templateData = $.extend(true, defaults, { data: formattedData, field_data: { rules: results.temporalRules } }); + + self.temporalsetRender(templateData, target, callbacks); + + if (typeof callbacks.after_render === 'function') { + callbacks.after_render(); + } + });/* + + if (typeof data === 'object' && data.id) { + self.temporalSetGet(data.id, function(_data, status) { + var oldFormatData = { data: _data }; + + self.temporalsetFormatData(oldFormatData); + + self.temporalsetRender($.extend(true, defaults, oldFormatData), target, callbacks); + + if (typeof callbacks.after_render === 'function') { + callbacks.after_render(); + } + }); + } else { + self.temporalsetRender(defaults, target, callbacks); + + if (typeof callbacks.after_render === 'function') { + callbacks.after_render(); + } + }*/ + }, + + temporalSetGetData: function(id, callback) { + var self = this; + + monster.parallel({ + 'temporalSet': function(callback) { + if (id) { + self.temporalSetGet(id, function(data) { + callback && callback(null, data); + }); + } else { + callback && callback(null, {}); + } + }, + 'temporalRules': function(callback) { + self.temporalSetGetAllRules(function(data) { + callback && callback(null, data); + }); + } + }, + function(err, results) { + callback && callback(results); + }); + }, + + temporalSetFormatRules: function(data) { + var self = this, + mapRules = _.indexBy(data.field_data.rules, 'id'), + formattedData = {}; + + formattedData.available = _.map(data.field_data.rules, function(rule) { + return { key: rule.id, value: rule.name }; + }); + + formattedData.selected = _.chain(data.data.temporal_rules) + .filter(function(id) { + if (mapRules.hasOwnProperty(id)) { + return id; + } + }).map(function(id) { + return { + key: id, + value: mapRules[id].name + }; + }).value(); + + return formattedData; + }, + + temporalsetRender: function(data, target, callbacks) { + var self = this, + temporalset_html = $(monster.template(self, 'temporalset-callflowEdit', data)), + temporalsetForm = temporalset_html.find('#temporalset-form'), + widgetRules = self.temporalSetFormatRules(data); + + var widget = monster.ui.linkedColumns(temporalset_html.find('.items-selector-wrapper'), widgetRules.available, widgetRules.selected, { + i18n: { + columnsTitles: { + available: self.i18n.active().callflows.temporalset.unselectedTOD, + selected: self.i18n.active().callflows.temporalset.selectedTOD + } + }, + containerClasses: 'skinny' + }); + + monster.ui.validate(temporalsetForm); + + $('*[rel=popover]', temporalset_html).popover({ + trigger: 'focus' + }); + + self.winkstartTabs(temporalset_html); + + $('.temporalset-save', temporalset_html).click(function(ev) { + ev.preventDefault(); + + var $this = $(this); + + if (!$this.hasClass('disabled')) { + $this.addClass('disabled'); + + if (monster.ui.valid(temporalsetForm)) { + var form_data = monster.ui.getFormData('temporalset-form'); + form_data.temporal_rules = widget.getSelectedItems(); + + form_data = self.temporalsetCleanFormData(form_data); + + self.temporalsetSave(form_data, data, callbacks.save_success); + } else { + $this.removeClass('disabled'); + monster.ui.alert('error', self.i18n.active().callflows.temporalset.there_were_errors_on_the_form); + } + } + }); + + $('.temporalset-delete', temporalset_html).click(function(ev) { + ev.preventDefault(); + + monster.ui.confirm(self.i18n.active().callflows.temporalset.are_you_sure_you_want_to_delete, function() { + self.temporalSetDelete(data.data.id, callbacks.delete_success); + }); + }); + + (target) + .empty() + .append(temporalset_html); + }, + + temporalsetCleanFormData: function(form_data) { + return form_data; + }, + + temporalsetNormalizeData: function(merged_data, form_data) { + // Because extend doesn't merge arrays properly + delete merged_data.temporal_rules; + merged_data.temporal_rules = form_data.temporal_rules; + + delete merged_data.extra; + + return merged_data; + }, + + temporalsetFormatData: function(data) { + data.extra = data.extra || {}; + data.extra.showSave = true; + data.extra.showDelete = data.id ? true : false; + + if (data.hasOwnProperty('ui_metadata') && data.ui_metadata.hasOwnProperty('origin') && data.ui_metadata.origin === 'voip') { + data.extra.showSave = false; + + if (!monster.util.isSuperDuper()) { + data.extra.showDelete = false; + } + } + + return data; + }, + + temporalsetDefineActions: function(args) { + var self = this, + callflow_nodes = args.actions; + + $.extend(callflow_nodes, { + 'temporal_set[]': { + name: self.i18n.active().callflows.temporalset.name, + module: 'temporal_set', + listEntities: function(callback) { + self.temporalSetList(function(data) { + callback && callback(data); + }); + }, + editEntity: 'callflows.temporalset.edit' + } + }); + }, + + temporalSetGetAllRules: function(callback) { + var self = this; + + self.callApi({ + resource: 'temporalRule.list', + data: { + accountId: self.accountId, + filters: { paginate:false } + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + temporalSetList: function(callback) { + var self = this; + + self.callApi({ + resource: 'temporalSet.list', + data: { + accountId: self.accountId, + filters: { paginate:false } + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + temporalSetGet: function(temporalSetId, callback) { + var self = this; + + self.callApi({ + resource: 'temporalSet.get', + data: { + accountId: self.accountId, + setId: temporalSetId + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + temporalSetCreate: function(data, callback) { + var self = this; + + self.callApi({ + resource: 'temporalSet.create', + data: { + accountId: self.accountId, + data: data + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + temporalSetUpdate: function(data, callback) { + var self = this; + + self.callApi({ + resource: 'temporalSet.update', + data: { + accountId: self.accountId, + setId: data.id, + data: data + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + temporalSetDelete: function(temporalSetId, callback) { + var self = this; + + self.callApi({ + resource: 'temporalSet.delete', + data: { + accountId: self.accountId, + setId: temporalSetId + }, + success: function(data) { + callback && callback(data.data); + } + }); + } + }; + + return app; +}); diff --git a/src/apps/callflows/submodules/timeofday/timeofday.css b/src/apps/callflows/submodules/timeofday/timeofday.css new file mode 100644 index 0000000..5d5ab25 --- /dev/null +++ b/src/apps/callflows/submodules/timeofday/timeofday.css @@ -0,0 +1,75 @@ +.callflows-port #timeofday-form { + color: #EBEBEB; +} + +.callflows-port #timeofday-form .time-wrapper-field { + height: 50px; + padding: 10px 20px 0 0; +} + +.callflows-port #timeofday-form #days_checkboxes .fake_checkbox { + float: left; + color: #eeeeee; + width: 15px; + height: 20px; + line-height: 20px; + text-align: center; + padding: 0px; + margin: 0px; + border-top: 1px solid #000000; + border-bottom: 1px solid #000000; + border-right: 1px solid #000000; + background-color: #989898; + cursor: pointer; +} + +.callflows-port #timeofday-form #days_checkboxes .fake_checkbox:first-child { + border-left: 1px solid #000000; + border-radius: 5px 0 0 5px; +} + +.callflows-port #timeofday-form #days_checkboxes .fake_checkbox:last-child { + border-radius: 0 5px 5px 0; +} + +.callflows-port #timeofday-form #days_checkboxes .fake_checkbox:hover { + background-color: #BEBEBE; +} + +.callflows-port #timeofday-form #days_checkboxes .fake_checkbox.checked { + background-color: #05ADDC; +} + +.callflows-port #timeofday-form .time-wrapper label.monster-invalid { + margin-top: 0; + position: absolute; +} + + +.callflows-port #timeofday-form .time-wrapper-field .time-wrapper { + width: 233px; + padding: 0; + margin: 0 0 0 20px; + float: left; +} + +.callflows-port #timeofday-form .time-wrapper-field .checkbox-container { + float: left; + margin-left: 20px; +} + + +.callflows-port #timeofday-form .time-wrapper-field .checkbox-container label.monster-checkbox { + text-align: left; + padding-top: 0; + margin-top: 5px; +} + +.callflows-port #timeofday-form .timepicker:first-child { + margin-left: 0; +} + +.callflows-port #timeofday-form .timepicker { + width: 80px; + margin: 0 10px; +} \ No newline at end of file diff --git a/src/apps/callflows/submodules/timeofday/timeofday.js b/src/apps/callflows/submodules/timeofday/timeofday.js new file mode 100644 index 0000000..4fd6a68 --- /dev/null +++ b/src/apps/callflows/submodules/timeofday/timeofday.js @@ -0,0 +1,1020 @@ +define(function(require){ + var $ = require('jquery'), + _ = require('underscore'), + monster = require('monster'), + timezone = require('monster-timezone'); + + var app = { + requests: {}, + + subscribe: { + 'callflows.fetchActions': 'timeofdayDefineActions', + 'callflows.timeofday.edit': '_timeofdayEdit' + }, + + timeofdaySave: function(form_data, data, success, error) { + var self = this, + normalized_data = self.timeofdayNormalizeData($.extend(true, {}, data.data, form_data)); + + if(typeof data.data == 'object' && data.data.id) { + self.temporalRuleUpdate(normalized_data, function(_data, status) { + success && success(_data, status, 'update'); + }); + } + else { + self.temporalRuleCreate(normalized_data, function(_data, status) { + success & success(_data, status, 'create'); + }); + } + }, + + timeofdayPopupEdit: function(args) { + var self = this, + popup, + popup_html, + data = args.data, + callback = args.callback, + data_defaults = args.data_defaults; + + popup_html = $('
    '); + + self.timeofdayEdit(data, popup_html, $('.inline_content', popup_html), { + save_success: function(_data) { + popup.dialog('close'); + + if(typeof callback == 'function') { + callback(_data); + } + }, + delete_success: function() { + popup.dialog('close'); + + if(typeof callback == 'function') { + callback({ data: {} }); + } + }, + after_render: function() { + popup = monster.ui.dialog(popup_html, { + title: (data.id) ? self.i18n.active().callflows.timeofday.edit_time_of_day : self.i18n.active().callflows.timeofday.create_time_of_day + }); + } + }, data_defaults); + }, + + // Added for the subscribed event to avoid refactoring timeofdayEdit + _timeofdayEdit: function(args) { + var self = this; + self.timeofdayEdit(args.data, args.parent, args.target, args.callbacks, args.data_defaults); + }, + + timeofdayEdit: function(data, _parent, _target, _callbacks, data_defaults) { + var self = this, + parent = _parent || $('#timeofday-content'), + target = _target || $('#timeofday-view', parent) + _callbacks = _callbacks || {}, + callbacks = { + save_success: _callbacks.save_success, + save_error: _callbacks.save_error, + delete_success: _callbacks.delete_success, + delete_error: _callbacks.delete_error, + after_render: _callbacks.after_render + }, + defaults = { + data: $.extend(true, { + time_window_start: 32400, + time_window_stop: 61200, + wdays: [], + days: [], + interval: 1, + showSave: true + }, data_defaults || {}), + field_data: { + wdays: { + sunday: { + friendlyName: self.i18n.active().callflows.timeofday.sunday.friendlyName, + shortName: self.i18n.active().callflows.timeofday.sunday.shortName + }, + monday: { + friendlyName: self.i18n.active().callflows.timeofday.monday.friendlyName, + shortName: self.i18n.active().callflows.timeofday.monday.shortName + }, + tuesday: { + friendlyName: self.i18n.active().callflows.timeofday.tuesday.friendlyName, + shortName: self.i18n.active().callflows.timeofday.tuesday.shortName + }, + wednesday: { + friendlyName: self.i18n.active().callflows.timeofday.wednesday.friendlyName, + shortName: self.i18n.active().callflows.timeofday.wednesday.shortName + }, + thursday: { + friendlyName: self.i18n.active().callflows.timeofday.thursday.friendlyName, + shortName: self.i18n.active().callflows.timeofday.thursday.shortName + }, + friday: { + friendlyName: self.i18n.active().callflows.timeofday.friday.friendlyName, + shortName: self.i18n.active().callflows.timeofday.friday.shortName + }, + saturday: { + friendlyName: self.i18n.active().callflows.timeofday.saturday.friendlyName, + shortName: self.i18n.active().callflows.timeofday.saturday.shortName + } + }, + + day: [ + '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', + '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31' + ], + + cycle: [ + { id: 'weekly', value: 'Weekly' }, + { id: 'monthly', value:'Monthly' }, + { id: 'yearly', value:'Yearly' } + ], + + ordinals: [ + { id: 'first', value: 'First' }, + { id: 'second', value: 'Second' }, + { id: 'third', value: 'Third' }, + { id: 'fourth', value: 'Fourth' }, + { id: 'fifth', value: 'Fifth' }, + { id: 'last', value: 'Last' }, + { id: 'every', value: 'Day' } + ], + + months: [ + { id: 1, value: 'January' }, + { id: 2, value: 'February' }, + { id: 3, value: 'March' }, + { id: 4, value: 'April' }, + { id: 5, value: 'May' }, + { id: 6, value: 'June' }, + { id: 7, value: 'July' }, + { id: 8, value: 'August' }, + { id: 9, value: 'September' }, + { id: 10, value: 'October' }, + { id: 11, value: 'November' }, + { id: 12, value: 'December' } + ], + + isAllDay: false + } + }; + + if(typeof data == 'object' && data.id) { + self.temporalRuleGet(data.id, function(_data, status) { + var oldFormatData = { data: _data }; + + self.timeofdayMigrateData(oldFormatData); + self.timeofdayFormatData(oldFormatData); + + var renderData = $.extend(true, defaults, oldFormatData); + + if (renderData.data.time_window_start === 0 && renderData.data.time_window_stop === 86400) { + renderData.field_data.isAllDay = true; + } + + self.timeofdayRender(renderData, target, callbacks); + + if (typeof callbacks.after_render === 'function') { + callbacks.after_render(); + } + }); + } + else { + self.timeofdayRender(defaults, target, callbacks); + + if(typeof callbacks.after_render == 'function') { + callbacks.after_render(); + } + } + }, + + timeofdayRender: function(data, target, callbacks){ + var self = this, + wday, + timeofday_html = $(monster.template(self, 'timeofday-callflowEdit', data)), + _after_render, + timeofdayForm = timeofday_html.find('#timeofday-form'); + + monster.ui.validate(timeofdayForm, { + rules: { + 'extra.timeofday.from': {}, + 'extra.timeofday.to': { + greaterDate: timeofday_html.find('input[name="extra.timeofday.from"]') + } + }, + groups: { + 'extra.timeofday': 'extra.timeofday.from extra.timeofday.to' + }, + errorPlacement: function(error, element) { + error.appendTo(element.parent()); + } + }); + + $('*[rel=popover]', timeofday_html).popover({ + trigger: 'focus' + }); + + self.winkstartTabs(timeofday_html); + + monster.ui.datepicker(timeofday_html.find('#start_date')); + monster.ui.timepicker(timeofday_html.find('.timepicker'), { + step: 5 + }); + + $('#yearly_every', timeofday_html).hide(); + $('#monthly_every', timeofday_html).hide(); + $('#weekly_every', timeofday_html).hide(); + $('#ordinal', timeofday_html).hide(); + $('#days_checkboxes', timeofday_html).hide(); + $('#weekdays', timeofday_html).hide(); + $('#specific_day', timeofday_html).hide(); + + if(data.data.id == undefined) { + $('#weekly_every', timeofday_html).show(); + $('#days_checkboxes', timeofday_html).show(); + } else { + if(data.data.cycle == 'monthly') { + $('#monthly_every', timeofday_html).show(); + $('#ordinal', timeofday_html).show(); + if(data.data.days != undefined && data.data.days[0] != undefined) { + $('#specific_day', timeofday_html).show(); + } else { + $('#weekdays', timeofday_html).show(); + } + } else if(data.data.cycle == 'yearly') { + $('#yearly_every', timeofday_html).show(); + $('#ordinal', timeofday_html).show(); + if(data.data.days != undefined && data.data.days[0] != undefined) { + $('#specific_day', timeofday_html).show(); + } else { + $('#weekdays', timeofday_html).show(); + } + } else if(data.data.cycle = 'weekly') { + $('#weekly_every', timeofday_html).show(); + $('#days_checkboxes', timeofday_html).show(); + } + } + + $('.fake_checkbox', timeofday_html).click(function() { + $(this).toggleClass('checked'); + }); + + $('#ordinal', timeofday_html).change(function() { + if($(this).val() == 'every') { + $('#weekdays', timeofday_html).hide(); + $('#specific_day', timeofday_html).show(); + } else { + $('#weekdays', timeofday_html).show(); + $('#specific_day', timeofday_html).hide(); + } + }); + + $('#cycle', timeofday_html).change(function() { + $('#yearly_every', timeofday_html).hide(); + $('#monthly_every', timeofday_html).hide(); + $('#weekly_every', timeofday_html).hide(); + $('#ordinal', timeofday_html).hide(); + $('#days_checkboxes', timeofday_html).hide(); + $('#weekdays', timeofday_html).hide(); + $('#specific_day', timeofday_html).hide(); + + switch($(this).val()) { + case 'yearly': + $('#yearly_every', timeofday_html).show(); + $('#ordinal', timeofday_html).show(); + if($('#ordinal', timeofday_html).val() == 'every') { + //$('#weekdays', timeofday_html).hide(); + $('#specific_day', timeofday_html).show(); + } else { + $('#weekdays', timeofday_html).show(); + //$('#specific_day', timeofday_html).hide(); + } + break; + + case 'monthly': + $('#monthly_every', timeofday_html).show(); + $('#ordinal', timeofday_html).show(); + if($('#ordinal', timeofday_html).val() == 'every') { + //$('#weekdays', timeofday_html).hide(); + $('#specific_day', timeofday_html).show(); + } else { + $('#weekdays', timeofday_html).show(); + //$('#specific_day', timeofday_html).hide(); + } + break; + + case 'weekly': + $('#weekly_every', timeofday_html).show(); + $('#days_checkboxes', timeofday_html).show(); + break; + } + }); + + $('.timeofday-save', timeofday_html).click(function(ev) { + ev.preventDefault(); + + var $this = $(this); + + if(!$this.hasClass('disabled')) { + $this.addClass('disabled'); + + if(monster.ui.valid(timeofdayForm)) { + var form_data = monster.ui.getFormData('timeofday-form'); + + form_data.wdays = []; + data.data.wdays = []; + + $('.fake_checkbox.checked', timeofday_html).each(function() { + form_data.wdays.push($(this).data('value')); + }); + + form_data.interval = $('#cycle', timeofday_html).val() == 'monthly' ? $('#interval_month', timeofday_html).val() : $('#interval_week', timeofday_html).val(); + form_data.start_date = timeofday_html.find('#start_date').datepicker('getDate'); + form_data = self.timeofdayCleanFormData(form_data); + + self.timeofdaySave(form_data, data, callbacks.save_success); + } + else { + $this.removeClass('disabled'); + monster.ui.alert('error', self.i18n.active().callflows.timeofday.there_were_errors_on_the_form); + } + } + }); + + $('.timeofday-delete', timeofday_html).click(function(ev) { + ev.preventDefault(); + + monster.ui.confirm(self.i18n.active().callflows.timeofday.are_you_sure_you_want_to_delete, function() { + self.temporalRuleDelete(data.data.id, callbacks.delete_success); + }); + }); + + $('#all_day_checkbox', timeofday_html).on('click', function() { + var $this = $(this); + + $('input.timepicker', timeofday_html).val(''); + $('.time-wrapper', timeofday_html).toggleClass('hidden', $this.is(':checked')); + }); + + _after_render = callbacks.after_render; + + callbacks.after_render = function() { + if(typeof _after_render == 'function') { + _after_render(); + } + }; + + (target) + .empty() + .append(timeofday_html); + }, + + timeofdayCleanFormData: function(form_data) { + var wdays = [], + timeStart = form_data.extra.allDay ? '0:00' : form_data.extra.timeofday.from, + timeEnd = form_data.extra.allDay ? '24:00' : form_data.extra.timeofday.to; + + if(form_data.cycle != 'weekly' && form_data.weekday != undefined) { + form_data.wdays = []; + form_data.wdays.push(form_data.weekday); + } + + $.each(form_data.wdays, function(i, val) { + if(val) { + if(val == 'wednesday') { + val = 'wensday'; + } + wdays.push(val); + } + }); + + if(wdays.length > 0 && wdays[0] == 'sunday') { + wdays.push(wdays.shift()); + } + + form_data.wdays = wdays; + + if(form_data.start_date === '') { + delete form_data.start_date; + } + else { + form_data.start_date = monster.util.dateToGregorian(form_data.start_date); + } + + form_data.time_window_start = parseInt(monster.util.timeToSeconds(timeStart)); + form_data.time_window_stop = parseInt(monster.util.timeToSeconds(timeEnd)); + + if(form_data.month) { + form_data.month = parseInt(form_data.month); + } + + delete form_data.extra; + + return form_data; + }, + + timeofdayNormalizeData: function(form_data) { + if(form_data.cycle == 'weekly') { + delete form_data.ordinal; + delete form_data.days; + delete form_data.month; + } + else { + form_data.cycle == 'yearly' ? delete form_data.interval : delete form_data.month; + form_data.ordinal != 'every' ? delete form_data.days : delete form_data.wdays; + } + + delete form_data.time; + delete form_data.weekday; + + if(form_data.enabled === "true") { + form_data.enabled = true; + } else if(form_data.enabled === "false") { + form_data.enabled = false; + } else { + delete form_data.enabled; + } + + delete form_data.extra; + delete form_data.showSave; + delete form_data.showDelete; + + return form_data; + }, + + timeofdayFormatData: function(data) { + var self = this, + is12hMode = monster.apps.auth.currentUser.ui_flags && monster.apps.auth.currentUser.ui_flags.twelve_hours_mode ? true : false, + secondsToTime = function(seconds) { + var hours = parseInt(seconds / 3600) % 24, + minutes = (parseInt(seconds / 60) % 60).toString(), + suffix = ''; + + if (is12hMode) { + suffix = hours >= 12 ? 'PM' : 'AM'; + hours = hours > 12 ? hours - 12 : (hours === 0 ? 12 : hours); + } + return hours.toString() + ':' + (minutes.length < 2 ? '0' + minutes : minutes) + suffix; + }; + + if (data.data.wdays !== undefined && data.data.cycle !== 'weekly') { + data.data.weekday = data.data.wdays[0]; + } + + data.extra = {}; + data.extra.timeStart = secondsToTime(data.data.time_window_start); + data.extra.timeStop = secondsToTime(data.data.time_window_stop); + + data.data.showSave = true; + data.data.showDelete = data.data.id ? true : false; + + if(data.data.hasOwnProperty('ui_metadata') && data.data.ui_metadata.hasOwnProperty('origin') && data.data.ui_metadata.origin === 'voip') { + data.data.showSave = false; + + if(!monster.util.isSuperDuper()) { + data.data.showDelete = false; + } + } + + return data; + }, + + timeofdayMigrateData: function(data) { + // Check for spelling ;) + if('wdays' in data.data && (wday = $.inArray('wensday', data.data.wdays)) > -1) { + data.data.wdays[wday] = 'wednesday'; + } + + return data; + }, + + timeofdayDefineActions: function(args) { + var self = this, + callflow_nodes = args.actions; + + $.extend(callflow_nodes, { + 'temporal_route[]': { + name: self.i18n.active().callflows.timeofday.time_of_day, + icon: 'temporal_route', + category: self.i18n.active().callflows.timeofday.time_of_day_cat, + module: 'temporal_route', + data: {}, + rules: [ + { + type: 'quantity', + maxSize: '9999' + } + ], + isUsable: 'true', + weight: 10, + key_caption: function(child_node, caption_map) { + var key = child_node.key, + caption; + + if (key === '_') { + caption = self.i18n.active().callflows.timeofday.all_other_times; + } else if (caption_map.hasOwnProperty(key)) { + caption = caption_map[key].name; + } else { + caption = ''; + } + + return caption; + }, + key_edit: function(child_node, callback) { + var _this = this; + + self.temporalRuleAndSetList(function(formattedData) { + formattedData.rules.push({ id: '_', name: self.i18n.active().callflows.timeofday.all_other_times }); + + var popup, popup_html; + + popup_html = $(monster.template(self, 'timeofday-callflowKey', { + items: formattedData, + selected: child_node.key + })); + + $('.inline_action', popup_html).click(function(ev) { + var _data = ($(this).data('action') === 'edit') ? { id: $('#timeofday_selector', popup_html).val() } : {}, + isRule = $('#timeofday_selector option:selected').parents('optgroup').data('type') === 'rules', + methodToCall = $(this).data('action') === 'edit' ? (isRule ? 'timeofdayPopupEdit' : 'temporalsetPopupEdit') : 'timeofdayPopupEdit'; + + ev.preventDefault(); + + self[methodToCall]({ + data: _data, + callback: function(timeofday) { + child_node.key = timeofday.id || 'null'; + + child_node.key_caption = timeofday.name || ''; + + popup.dialog('close'); + } + }); + }); + + if ($('#timeofday_selector option:selected', popup_html).val() === '_') { + $('#edit_link', popup_html).hide(); + } + + $('#timeofday_selector', popup_html).change(function() { + $('#timeofday_selector option:selected', popup_html).val() === '_' ? $('#edit_link', popup_html).hide() : $('#edit_link', popup_html).show(); + }); + + $('#add', popup_html).click(function() { + child_node.key = $('#timeofday_selector', popup_html).val(); + + child_node.key_caption = $('#timeofday_selector option:selected', popup_html).text(); + + popup.dialog('close'); + }); + + popup = monster.ui.dialog(popup_html, { + title: self.i18n.active().callflows.timeofday.time_of_day, + beforeClose: function() { + if (typeof callback === 'function') { + callback(); + } + } + }); + }); + }, + caption: function(node) { + return node.getMetadata('timezone') || self.i18n.active().defaultTimezone; + }, + edit: function(node, callback) { + var popup, popup_html; + + popup_html = $(monster.template(self, 'timeofday-callflowTimezone', { + items: {}, + selected: {} + })); + + timezone.populateDropdown($('#timezone_selector', popup_html), node.getMetadata('timezone') || 'inherit', {inherit: self.i18n.active().defaultTimezone}); + + $('#add', popup_html).click(function() { + var timezone = $('#timezone_selector', popup_html).val(); + if (timezone && timezone !== 'inherit') { + node.setMetadata('timezone', timezone); + } + + node.caption = $('#timezone_selector option:selected', popup_html).text(); + + popup.dialog('close'); + }); + + popup = monster.ui.dialog(popup_html, { + title: self.i18n.active().callflows.timeofday.select_a_timezone_title, + beforeClose: function() { + if (typeof callback === 'function') { + callback(); + } + } + }); + }, + listEntities: function(callback) { + self.temporalRuleList(function(data) { + callback && callback(data); + }); + }, + editEntity: 'callflows.timeofday.edit' + }, + 'temporal_route[action=disable]': { + name: self.i18n.active().callflows.timeofday.disable_time_of_day, + icon: 'temporal_route', + category: self.i18n.active().callflows.timeofday.time_of_day_cat, + module: 'temporal_route', + data: { + action: 'disable', + rules: [] + }, + rules: [ + { + type: 'quantity', + maxSize: '1' + } + ], + isUsable: 'true', + weight: 20, + caption: function(node, caption_map) { + return ''; + }, + edit: function(node, callback) { + self.temporalRuleList(function(listRules) { + var popup, + popup_html, + rules, + unselected_rules = [], + selected_rules = []; + + if(rules = node.getMetadata('rules')) { + $.each(listRules, function(i, obj) { + if($.inArray(obj.id, rules) != -1) { + selected_rules.push(obj); + } + else { + unselected_rules.push(obj); + } + }); + } + else { + unselected_rules = listRules; + } + + popup_html = $(monster.template(self, 'timeofday-two_column', { + left: { + title: self.i18n.active().callflows.timeofday.unselected_time_of_day_rules, + items: unselected_rules + }, + right: { + title: self.i18n.active().callflows.timeofday.selected_time_of_day_rules, + items: selected_rules + } + })); + + $('#add', popup_html).click(function() { + var _rules = []; + + $('.right .connect li', popup_html).each(function() { + _rules.push($(this).data('id')); + }); + + node.setMetadata('rules', _rules); + + popup.dialog('close'); + }); + + popup = monster.ui.dialog(popup_html, { + title: self.i18n.active().callflows.timeofday.disable_time_of_day_rules_title, + beforeClose: function() { + if(typeof callback == 'function') { + callback(); + } + } + }); + + /* Initialize the scrollpane AFTER it has rendered */ + + //$('.scrollable', popup).jScrollPane(); + + $('.connect', popup).sortable({ + connectWith: $('.connect', popup), + zIndex: 2000, + helper: 'clone', + appendTo: $('.wrapper', popup), + scroll: false, + tolerance: 'pointer', + receive: function() { + //$('.scrollable', popup).data('jsp').reinitialise(); + }, + remove: function() { + //$('.scrollable', popup).data('jsp').reinitialise(); + } + }); + }); + } + }, + 'temporal_route[action=enable]': { + name: self.i18n.active().callflows.timeofday.enable_time_of_day, + icon: 'temporal_route', + category: self.i18n.active().callflows.timeofday.time_of_day_cat, + module: 'temporal_route', + data: { + action: 'enable', + rules: [] + }, + rules: [ + { + type: 'quantity', + maxSize: '1' + } + ], + isUsable: 'true', + weight: 30, + caption: function(node, caption_map) { + return ''; + }, + edit: function(node, callback) { + self.temporalRuleList(function(listRules) { + var popup, popup_html, rules, + unselected_rules = [], + selected_rules = []; + + if(rules = node.getMetadata('rules')) { + $.each(listRules, function(i, obj) { + if($.inArray(obj.id, rules) != -1) { + selected_rules.push(obj); + } + else { + unselected_rules.push(obj); + } + }); + } + else { + unselected_rules = listRules; + } + + popup_html = $(monster.template(self, 'timeofday-two_column', { + left: { + title: self.i18n.active().callflows.timeofday.unselected_time_of_day_rules, + items: unselected_rules + }, + right: { + title: self.i18n.active().callflows.timeofday.selected_time_of_day_rules, + items: selected_rules + } + })); + + $('#add', popup_html).click(function() { + var _rules = []; + + $('.right .connect li', popup_html).each(function() { + _rules.push($(this).data('id')); + }); + + node.setMetadata('rules', _rules); + + popup.dialog('close'); + }); + + popup = monster.ui.dialog(popup_html, { + title: self.i18n.active().callflows.timeofday.enable_time_of_day_rules, + beforeClose: function() { + if(typeof callback == 'function') { + callback(); + } + } + }); + + /* Initialize the scrollpane AFTER it has rendered */ + + //$('.scrollable', popup).jScrollPane(); + + $('.connect', popup).sortable({ + connectWith: $('.connect', popup), + zIndex: 2000, + helper: 'clone', + appendTo: $('.wrapper', popup), + scroll: false, + tolerance: 'pointer', + receive: function() { + //$('.scrollable', popup).data('jsp').reinitialise(); + }, + remove: function() { + //$('.scrollable', popup).data('jsp').reinitialise(); + } + }); + }); + } + }, + 'temporal_route[action=reset]': { + name: self.i18n.active().callflows.timeofday.reset_time_of_day, + icon: 'temporal_route', + category: self.i18n.active().callflows.timeofday.time_of_day_cat, + module: 'temporal_route', + data: { + action: 'reset', + rules: [] + }, + rules: [ + { + type: 'quantity', + maxSize: '1' + } + ], + isUsable: 'true', + weight: 40, + caption: function(node, caption_map) { + return ''; + }, + edit: function(node, callback) { + self.temporalRuleList(function(listRules) { + var popup, popup_html, rules, + unselected_rules = [], + selected_rules = []; + + if(rules = node.getMetadata('rules')) { + $.each(listRules, function(i, obj) { + if($.inArray(obj.id, rules) != -1) { + selected_rules.push(obj); + } + else { + unselected_rules.push(obj); + } + }); + } + else { + unselected_rules = listRules; + } + + popup_html = $(monster.template(self, 'timeofday-two_column', { + left: { + title: self.i18n.active().callflows.timeofday.unselected_time_of_day_rules, + items: unselected_rules + }, + right: { + title: self.i18n.active().callflows.timeofday.selected_time_of_day_rules, + items: selected_rules + } + })); + + $('#add', popup_html).click(function() { + var _rules = []; + + $('.right .connect li', popup_html).each(function() { + _rules.push($(this).data('id')); + }); + + node.setMetadata('rules', _rules); + + popup.dialog('close'); + }); + + popup = monster.ui.dialog(popup_html, { + title: self.i18n.active().callflows.timeofday.reset_time_of_day_rules, + beforeClose: function() { + if(typeof callback == 'function') { + callback(); + } + } + }); + + /* Initialize the scrollpane AFTER it has rendered */ + + //$('.scrollable', popup).jScrollPane(); + + $('.connect', popup).sortable({ + connectWith: $('.connect', popup), + zIndex: 2000, + helper: 'clone', + appendTo: $('.wrapper', popup), + scroll: false, + tolerance: 'pointer', + receive: function() { + //$('.scrollable', popup).data('jsp').reinitialise(); + }, + remove: function() { + //$('.scrollable', popup).data('jsp').reinitialise(); + } + }); + } + ); + } + } + }); + }, + + temporalRuleAndSetList: function(callback) { + var self = this; + + monster.parallel({ + 'rules': function(callback) { + self.temporalRuleList(function(data) { + callback(null, _.sortBy(data, 'name')); + }); + }, + 'sets': function(callback) { + self.temporalSetList(function(data) { + callback(null, _.sortBy(data, 'name')); + }); + } + }, function(err, results) { + callback && callback(results); + }); + }, + + temporalRuleList: function(callback) { + var self = this; + + self.callApi({ + resource: 'temporalRule.list', + data: { + accountId: self.accountId, + filters: { paginate: false } + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + temporalSetList: function(callback) { + var self = this; + + self.callApi({ + resource: 'temporalSet.list', + data: { + accountId: self.accountId, + filters: { paginate: false } + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + temporalRuleGet: function(temporalRuleId, callback) { + var self = this; + + self.callApi({ + resource: 'temporalRule.get', + data: { + accountId: self.accountId, + ruleId: temporalRuleId + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + temporalRuleCreate: function(data, callback) { + var self = this; + + self.callApi({ + resource: 'temporalRule.create', + data: { + accountId: self.accountId, + data: data + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + temporalRuleUpdate: function(data, callback) { + var self = this; + + self.callApi({ + resource: 'temporalRule.update', + data: { + accountId: self.accountId, + ruleId: data.id, + data: data + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + temporalRuleDelete: function(temporalRuleId, callback) { + var self = this; + + self.callApi({ + resource: 'temporalRule.delete', + data: { + accountId: self.accountId, + ruleId: temporalRuleId + }, + success: function(data) { + callback && callback(data.data); + } + }); + } + }; + + return app; +}); diff --git a/src/apps/callflows/submodules/user/user.css b/src/apps/callflows/submodules/user/user.css new file mode 100644 index 0000000..d075bd1 --- /dev/null +++ b/src/apps/callflows/submodules/user/user.css @@ -0,0 +1,171 @@ +.callflows-port #user-form input[disabled=disabled] { + background: #ccc; +} + +.callflows-port #user-form #equipment { + text-align: center; + font-size: 12px; + font-family: 'Helvetica'; +} + +.callflows-port #user-form #equipment .help_box { + color: #333333; + line-height: 12px; +} + +.callflows-port #user-form #equipment .add_device { + margin-top: 15px; + display: inline-block; +} + +.callflows-port #user-form #equipment .add_device:hover a { + color: #333333; +} + +.callflows-port #user-form #equipment .add_device:hover .add_device_icon { + background-position: 0 -24px; + cursor: pointer; +} + +.callflows-port #user-form #equipment #tab_devices { + border: 2px solid #666666; + border-radius: 15px 15px 15px 15px; + color: #666666; + margin: 20px auto auto; + width: 560px; +} + +.callflows-port #user-form #equipment #tab_devices .action_device { + color: #666666; + cursor: pointer; + text-decoration: underline; + line-height: 30px; +} + +.callflows-port #user-form #equipment #tab_devices .action_device:not(:first-child) { + margin-left: 10px; +} +.callflows-port #user-form #equipment #tab_devices .action_device:hover { + color: #05addc; +} + +.callflows-port #user-form #equipment #tab_devices .column:not(.fifth) { + border-right: 1px solid #A6A6A6; +} + +.callflows-port #user-form #equipment #tab_devices .column { + float: left; + text-align: center; + height: 30px; + line-height: 30px; +} + +.callflows-port #user-form #equipment #tab_devices .column.first { + width: 190px; + overflow: hidden; + text-align:center; +} + +.callflows-port #user-form #equipment #tab_devices .column.second { + width: 99px; +} + +.callflows-port #user-form #equipment #tab_devices .column.third { + min-width: 49px; +} + +.callflows-port #user-form #equipment #tab_devices .rows .column.third { + background-image: url('../../style/static/images/red_phone.png'); + background-repeat: no-repeat; + background-position: 16px center; +} + +.callflows-port #user-form #equipment #tab_devices .rows .column.third.registered,.callflows-port #user-form #equipment #tab_devices .rows .column.third.cellphone { + background-image: url('../../style/static/images/green_phone.png'); +} + +.callflows-port #user-form #equipment #tab_devices .rows .column.third.disabled { + background-image: url('../../style/static/images/gray_phone.png') !important; +} + +.callflows-port #user-form #equipment #tab_devices .column.fourth { + width: 59px; +} + +.callflows-port #user-form #equipment #tab_devices .column.fourth .enabled_checkbox { + margin-top: 8px; +} + +.callflows-port #user-form #equipment #tab_devices .column.fifth { + width: 159px; +} + +.callflows-port #user-form #equipment #tab_devices .column.merged { + width: 560px; + border-right: none; +} + +.callflows-port #user-form #equipment #tab_devices .row { + height: 30px; + margin-left: 0px; +} + +.callflows-port #user-form #equipment #tab_devices .row.title { + background-color: #dddddd !important; + border-bottom: 2px solid #666666 !important; + border-radius: 15px 15px 0px 0px; + font-weight: bold; +} + +.callflows-port #user-form #equipment #tab_devices .row:not(:last-child) { + border-bottom: 1px solid #A6A6A6; +} + +.callflows-port #user-form #equipment #tab_devices .row:last-child { + border-radius: 0px 0px 15px 15px; +} + +.callflows-port #user-form #equipment #tab_devices .row:nth-child(odd) { + background-color: #eeeeee; +} + +.callflows-port #user-form #equipment #tab_devices .row:nth-child(even) { + background-color: #dddddd; +} + +.callflows-port #user-form #username_label { + color: #05addc; + text-align: left; + font-weight: bold; +} + +.callflows-port #user-form .shoutcast-div { + display: none; +} + +.callflows-port #user-form .shoutcast-div.active { + display: block; +} + +/* Hotdesk devices */ +.callflows-port #user-form #hotdesk_devices { + /*width: 400px;*/ + width: 320px; +} + +.callflows-port #user-form #hotdesk_devices .row .column:nth-child(1) { + width: 300px; +} + +.callflows-port #user-form #hotdesk_devices .row .column:nth-child(2) { + width: 80px; +} + +.callflows-port #user-form #hotdesk_devices .row .column.merged { + /* width: 400px; */ + width: 320px; +} + +.callflows-port #user-form #hotdesk_devices .row input[type="checkbox"] { + margin-top: 10px; +} diff --git a/src/apps/callflows/submodules/user/user.js b/src/apps/callflows/submodules/user/user.js new file mode 100644 index 0000000..91ffaeb --- /dev/null +++ b/src/apps/callflows/submodules/user/user.js @@ -0,0 +1,1197 @@ +define(function(require){ + var $ = require('jquery'), + _ = require('underscore'), + monster = require('monster'), + timezone = require('monster-timezone'); + + var app = { + requests: {}, + + subscribe: { + 'callflows.fetchActions': 'userDefineActions', + 'callflows.user.popupEdit': 'userPopupEdit', + 'callflows.user.edit': 'userEdit' + }, + + random_id: false, + + userDefineActions: function(args) { + var self = this, + callflow_nodes= args.actions; + + $.extend(callflow_nodes, { + 'user[id=*]': { + name: self.i18n.active().callflows.user.user, + icon: 'user', + category: self.i18n.active().oldCallflows.basic_cat, + module: 'user', + tip: self.i18n.active().callflows.user.user_tip, + data: { + id: 'null' + }, + rules: [ + { + type: 'quantity', + maxSize: '1' + } + ], + isUsable: 'true', + weight: 40, + caption: function(node, caption_map) { + var id = node.getMetadata('id'), + returned_value = ''; + + if(id in caption_map) { + returned_value = caption_map[id].name; + } + + return returned_value; + }, + edit: function(node, callback) { + self.userList(function(users) { + var popup, popup_html; + + $.each(users, function() { + this.name = this.first_name + ' ' + this.last_name; + }); + + popup_html = $(monster.template(self, 'user-callflowEdit' , { + can_call_self: node.getMetadata('can_call_self') || false, + parameter: { + name: 'timeout (s)', + value: node.getMetadata('timeout') || '20' + }, + objects: { + items: _.sortBy(users, 'name'), + selected: node.getMetadata('id') || '' + } + })); + + if($('#user_selector option:selected', popup_html).val() == undefined) { + $('#edit_link', popup_html).hide(); + } + + $('.inline_action', popup_html).click(function(ev) { + var _data = ($(this).data('action') == 'edit') ? + { id: $('#user_selector', popup_html).val() } : {}; + + ev.preventDefault(); + + self.userPopupEdit({ + data: _data, + callback: function(_data) { + node.setMetadata('id', _data.id || 'null'); + node.setMetadata('timeout', $('#parameter_input', popup_html).val()); + node.setMetadata('can_call_self', $('#user_can_call_self', popup_html).is(':checked')); + + node.caption = (_data.first_name || '') + ' ' + (_data.last_name || ''); + + popup.dialog('close'); + } + }); + }); + + $('#add', popup_html).click(function() { + node.setMetadata('id', $('#user_selector', popup_html).val()); + node.setMetadata('timeout', $('#parameter_input', popup_html).val()); + node.setMetadata('can_call_self', $('#user_can_call_self', popup_html).is(':checked')); + + node.caption = $('#user_selector option:selected', popup_html).text(); + + popup.dialog('close'); + }); + + popup = monster.ui.dialog(popup_html, { + title: self.i18n.active().callflows.user.select_user, + beforeClose: function() { + if(typeof callback == 'function') { + callback(); + } + } + }); + }); + }, + listEntities: function(callback) { + self.callApi({ + resource: 'user.list', + data: { + accountId: self.accountId, + filters: { paginate:false } + }, + success: function(data, status) { + callback && callback(data.data); + } + }); + }, + editEntity: 'callflows.user.edit' + }, + 'hotdesk[action=login]': { + name: self.i18n.active().callflows.user.hot_desk_login, + icon: 'hotdesk_login', + category: self.i18n.active().callflows.user.hotdesking_cat, + module: 'hotdesk', + tip: self.i18n.active().callflows.user.hot_desk_login_tip, + data: { + action: 'login' + }, + rules: [ + { + type: 'quantity', + maxSize: '1' + } + ], + isUsable: 'true', + weight: 10, + caption: function(node, caption_map) { + return ''; + }, + edit: function(node, callback) { + if(typeof callback == 'function') { + callback(); + } + } + }, + 'hotdesk[action=logout]': { + name: self.i18n.active().callflows.user.hot_desk_logout, + icon: 'hotdesk_logout', + category: self.i18n.active().callflows.user.hotdesking_cat, + module: 'hotdesk', + tip: self.i18n.active().callflows.user.hot_desk_logout_tip, + data: { + action: 'logout' + }, + rules: [ + { + type: 'quantity', + maxSize: '1' + } + ], + isUsable: 'true', + weight: 20, + caption: function(node, caption_map) { + return ''; + }, + edit: function(node, callback) { + if(typeof callback == 'function') { + callback(); + } + } + }, + 'hotdesk[action=toggle]': { + name: self.i18n.active().callflows.user.hot_desk_toggle, + icon: 'hotdesk_toggle', + category: self.i18n.active().callflows.user.hotdesking_cat, + module: 'hotdesk', + tip: self.i18n.active().callflows.user.hot_desk_toggle_tip, + data: { + action: 'toggle' + }, + rules: [ + { + type: 'quantity', + maxSize: '1' + } + ], + isUsable: 'true', + weight: 30, + caption: function(node, caption_map) { + return ''; + }, + edit: function(node, callback) { + if(typeof callback == 'function') { + callback(); + } + } + } + }); + }, + + userPopupEdit: function(args) { + var self = this, + popup_html = $('
    '), + popup, + data = args.data, + callback = args.callback, + data_defaults = args.data_defaults; + + popup_html.css({ + height: 500, + 'overflow-y': 'scroll' + }); + + self.userEdit({ + data: data, + parent: popup_html, + target: $('.inline_content', popup_html), + callbacks: { + save_success: function(_data) { + popup.dialog('close'); + + if(typeof callback == 'function') { + callback(_data); + } + }, + delete_success: function() { + popup.dialog('close'); + + if(typeof callback == 'function') { + callback({ data: {} }); + } + }, + after_render: function() { + popup = monster.ui.dialog(popup_html, { + title: (data.id) ? self.i18n.active().callflows.user.edit_user : self.i18n.active().callflows.user.create_user + }); + } + }, + data_defaults: data_defaults + }); + }, + + userEdit: function(args) { + var self = this, + data = args.data, + parent = args.parent || $('#user-content'), + target = args.target || $('#user-view', parent), + _callbacks = args.callbacks || {}, + callbacks = { + save_success: _callbacks.save_success || function(_data) { + self.userRenderList(parent); + + self.userEdit({ + data: { id: _data.data.id }, + parent: parent, + target: target, + callbacks: callbacks + }); + }, + + save_error: _callbacks.save_error, + + delete_success: _callbacks.delete_success || function() { + target.empty(); + + self.userRenderList(parent); + }, + + delete_error: _callbacks.delete_error, + + after_render: _callbacks.after_render + }, + defaults = { + data: $.extend(true, { + apps: {}, + call_forward: { + substitute: true + }, + call_restriction: { + closed_groups: { action: 'inherit' } + }, + caller_id: { + internal: {}, + external: {}, + emergency: {} + }, + hotdesk: {}, + contact_list: { + exclude: false, + }, + priv_level: 'user', + music_on_hold: {}, + timezone: 'inherit' + }, args.data_defaults || {}), + field_data: { + device_types: { + sip_device: self.i18n.active().callflows.user.sip_device_type, + cellphone: self.i18n.active().callflows.user.cell_phone_type, + fax: self.i18n.active().callflows.user.fax_type, + smartphone: self.i18n.active().callflows.user.smartphone_type, + landline: self.i18n.active().callflows.user.landline_type, + softphone: self.i18n.active().callflows.user.softphone_type, + sip_uri: self.i18n.active().callflows.user.sip_uri_type + }, + call_restriction: {} + } + }; + + self.random_id = false; + + monster.parallel({ + list_classifiers: function(callback) { + self.callApi({ + resource: 'numbers.listClassifiers', + data: { + accountId: self.accountId, + filters: { paginate:false } + }, + success: function(_data_classifiers, status) { + if('data' in _data_classifiers) { + $.each(_data_classifiers.data, function(k, v) { + defaults.field_data.call_restriction[k] = { + friendly_name: v.friendly_name + }; + + defaults.data.call_restriction[k] = { action: 'inherit' }; + }); + } + callback(null, _data_classifiers); + } + }); + }, + media_list: function(callback) { + self.callApi({ + resource: 'media.list', + data: { + accountId: self.accountId, + filters: { paginate:false } + }, + success: function(_data, status) { + if(_data.data) { + _data.data.unshift( + { + id: '', + name: self.i18n.active().callflows.user.default_music + }, + { + id: 'silence_stream://300000', + name: self.i18n.active().callflows.user.silence + }, + { + id: 'shoutcast', + name: self.i18n.active().callflows.accountSettings.musicOnHold.shoutcastURL + } + ); + } + + defaults.field_data.media = _data.data; + + callback(null, _data); + } + }); + }, + user_get: function(callback) { + if(typeof data == 'object' && data.id) { + self.userGet(data.id, function(_data, status) { + self.userMigrateData(_data); + + callback(null, _data); + }); + } + else { + self.random_id = $.md5(monster.util.randomString(10)+new Date().toString()); + defaults.field_data.new_user = self.random_id; + + callback(null, defaults); + } + }, + user_hotdesks: function(callback) { + if(typeof data == 'object' && data.id) { + self.callApi({ + resource: 'user.hotdesks', + data: { + accountId: self.accountId, + userId: data.id + }, + success: function(_data_devices) { + defaults.field_data.hotdesk_enabled = true; + defaults.field_data.device_list = {}; + + $.each(_data_devices.data, function(k, v) { + defaults.field_data.device_list[v.device_id] = { name: v.device_name }; + }); + + if($.isEmptyObject(defaults.field_data.device_list)) { + delete defaults.field_data.device_list; + } + + callback(null, _data_devices); + }, + error: function(_data, status) { + //callback({api_name: 'Hotdesk'}, _data); + callback(null, defaults); + } + }) + } + else { + callback(null, defaults); + } + } + }, + function(err, results) { + var render_data = defaults; + if(typeof data === 'object' && data.id) { + if(results.user_get.hasOwnProperty('call_restriction')) { + $.each(results.user_get.call_restriction, function(k, v) { + if (defaults.field_data.call_restriction.hasOwnProperty(k)) { + defaults.field_data.call_restriction[k].action = v.action; + } + }); + } + + render_data = $.extend(true, defaults, { data: results.user_get }); + + render_data.extra = render_data.extra || {}; + render_data.extra.isShoutcast = false; + + // if the value is set to a stream, we need to set the value of the media_id to shoutcast so it gets selected by the old select mechanism, + // but we also need to store the value so we can display it + if (render_data.data.hasOwnProperty('music_on_hold') && render_data.data.music_on_hold.hasOwnProperty('media_id')) { + if (render_data.data.music_on_hold.media_id.indexOf('://') >= 0) { + if (render_data.data.music_on_hold.media_id !== 'silence_stream://300000') { + render_data.extra.isShoutcast = true; + render_data.extra.shoutcastValue = render_data.data.music_on_hold.media_id; + render_data.data.music_on_hold.media_id = 'shoutcast'; + } + } + } + } + + self.userRender(render_data, target, callbacks); + + if(typeof callbacks.after_render == 'function') { + callbacks.after_render(); + } + }); + }, + + userRender: function(data, target, callbacks) { + var self = this, + user_html = $(monster.template(self, 'user-edit', data)), + user_form = user_html.find('#user-form'), + data_devices, + hotdesk_pin = $('.hotdesk_pin', user_html), + hotdesk_pin_require = $('#hotdesk_require_pin', user_html); + + self.userRenderDeviceList(data, user_html); + + monster.ui.validate(user_form, { + rules: { + "extra.shoutcastUrl": { + protocol: true + }, + username: { + required: true, + minlength: 3, + regex: /^[0-9a-zA-Z+@._-]*$/ + }, + first_name: { + required: true, + minlength: 1, + maxlength: 256, + regex: /^[0-9a-zA-Z\s\-\']+$/ + }, + last_name: { + required: true, + minlength: 1, + maxlength: 256, + regex: /^[0-9a-zA-Z\s\-\']+$/ + }, + + email: { + required: true, + email: true + }, + pwd_mngt_pwd1: { + required: true, + minlength: 3 + }, + pwd_mngt_pwd2: { + required: true, + minlength: 3, + equalTo: '#pwd_mngt_pwd1' + }, + 'hotdesk.pin': { regex: /^[0-9]*$/ }, + 'hotdesk.id': { regex: /^[0-9\+\#\*]*$/ }, + call_forward_number: { regex: /^[\+]?[0-9]*$/ }, + 'caller_id.internal.name': { regex: /^[0-9A-Za-z ,]{0,30}$/ }, + 'caller_id.external.name': { regex: /^[0-9A-Za-z ,]{0,30}$/ }, + 'caller_id.internal.number': { regex: /^[\+]?[0-9\s\-\.\(\)]*$/ }, + 'caller_id.external.number': { regex: /^[\+]?[0-9\s\-\.\(\)]*$/ }, + 'caller_id.emergency.name': { regex: /^[0-9A-Za-z ,]{0,30}$/ }, + 'caller_id.emergency.number': { regex: /^[\+]?[0-9\s\-\.\(\)]*$/ } + }, + messages: { + username: { regex: self.i18n.active().callflows.user.validation.username }, + first_name: { regex: self.i18n.active().callflows.user.validation.name }, + last_name: { regex: self.i18n.active().callflows.user.validation.name }, + 'hotdesk.pin': { regex: self.i18n.active().callflows.user.validation.hotdesk.pin }, + 'hotdesk.id': { regex: self.i18n.active().callflows.user.validation.hotdesk.id }, + 'caller_id.internal.name': { regex: self.i18n.active().callflows.user.validation.caller_id.name }, + 'caller_id.external.name': { regex: self.i18n.active().callflows.user.validation.caller_id.name }, + 'caller_id.emergency.name': { regex: self.i18n.active().callflows.user.validation.caller_id.name }, + 'caller_id.internal.number': { regex: self.i18n.active().callflows.user.validation.caller_id.number }, + 'caller_id.external.number': { regex: self.i18n.active().callflows.user.validation.caller_id.number }, + 'caller_id.emergency.number': { regex: self.i18n.active().callflows.user.validation.caller_id.number } + } + }); + + timezone.populateDropdown($('#timezone', user_html), data.data.timezone||'inherit', {inherit: self.i18n.active().defaultTimezone}); + + if (data.data.id === monster.apps.auth.userId){ + $('.user-delete', user_html).hide(); + } + + $('*[rel=popover]:not([type="text"])', user_html).popover({ + trigger: 'hover' + }); + + $('*[rel=popover][type="text"]', user_html).popover({ + trigger: 'focus' + }); + + self.winkstartTabs(user_html); + self.winkstartLinkForm(user_html); + + hotdesk_pin_require.is(':checked') ? hotdesk_pin.show() : hotdesk_pin.hide(); + + hotdesk_pin_require.change(function() { + $(this).is(':checked') ? hotdesk_pin.show('blind') : hotdesk_pin.hide('blind'); + }); + + $('.user-save', user_html).click(function(ev) { + ev.preventDefault(); + + var $this = $(this); + + if(!$this.hasClass('disabled')) { + $this.addClass('disabled'); + + if (monster.ui.valid(user_form)) { + var form_data = monster.ui.getFormData('user-form'); + + if(form_data.enable_pin === false) { + delete data.data.queue_pin; + delete data.data.record_call; + } + + if(form_data.music_on_hold.media_id === 'shoutcast') { + form_data.music_on_hold.media_id = user_html.find('.shoutcast-url-input').val(); + } + + self.userCleanFormData(form_data); + + if('field_data' in data) { + delete data.field_data; + } + + self.callApi({ + resource: 'account.get', + data: { + accountId: self.accountId + }, + success: function(_data, status) { + if(form_data.priv_level == 'admin') { + form_data.apps = form_data.apps || {}; + if(!('voip' in form_data.apps) && $.inArray('voip', (_data.data.available_apps || [])) > -1) { + form_data.apps['voip'] = { + label: self.i18n.active().callflows.user.voip_services_label, + icon: 'device', + api_url: monster.config.api.default + } + } + } + else if(form_data.priv_level == 'user' && $.inArray('userportal', (_data.data.available_apps || [])) > -1) { + form_data.apps = form_data.apps || {}; + if(!('userportal' in form_data.apps)) { + form_data.apps['userportal'] = { + label: self.i18n.active().callflows.user.user_portal_label, + icon: 'userportal', + api_url: monster.config.api.default + } + } + } + + self.userSave(form_data, data, function(data, status, action) { + if(action == 'create') { + self.userAcquireDevice(data, function() { + if(typeof callbacks.save_success == 'function') { + callbacks.save_success(data, status, action); + } + }, function() { + if(typeof callbacks.save_error == 'function') { + callbacks.save_error(data, status, action); + } + }); + } + else { + if(typeof callbacks.save_success == 'function') { + callbacks.save_success(data, status, action); + } + } + // }, winkstart.error_message.process_error(callbacks.save_error)); + }); + } + }); + } + else { + $this.removeClass('disabled'); + monster.ui.alert(self.i18n.active().callflows.user.there_were_errors_on_the_form); + } + } + }); + + $('.user-delete', user_html).click(function(ev) { + ev.preventDefault(); + + monster.ui.confirm(self.i18n.active().callflows.user.are_you_sure_you_want_to_delete, function() { + self.userDelete(data.data.id, callbacks.delete_success, callbacks.delete_error); + }); + }); + + if(!$('#music_on_hold_media_id', user_html).val()) { + $('#edit_link_media', user_html).hide(); + } + + $('#music_on_hold_media_id', user_html).change(function() { + !$('#music_on_hold_media_id option:selected', user_html).val() ? $('#edit_link_media', user_html).hide() : $('#edit_link_media', user_html).show(); + + user_html.find('.shoutcast-div').toggleClass('active', $(this).val() === 'shoutcast'); + }); + + $('.inline_action_media', user_html).click(function(ev) { + var _data = ($(this).data('action') == 'edit') ? { id: $('#music_on_hold_media_id', user_html).val() } : {}, + _id = _data.id; + + ev.preventDefault(); + monster.pub('callflows.media.editPopup', { + data: _data, + callback: function(media) { + /* Create */ + if(!_id) { + $('#music_on_hold_media_id', user_html).append('') + $('#music_on_hold_media_id', user_html).val(media.id); + + $('#edit_link_media', user_html).show(); + } + else { + /* Update */ + if(media.hasOwnProperty('id')) { + $('#music_on_hold_media_id #'+ media.id, user_html).text(media.name); + } + /* Delete */ + else { + $('#music_on_hold_media_id #'+_id, user_html).remove(); + $('#edit_link_media', user_html).hide(); + } + } + } + }); + }); + + $(user_html).delegate('.enabled_checkbox', 'click', function() { + self.userUpdateSingleDevice($(this), user_html); + }); + + $(user_html).delegate('.action_device.edit', 'click', function() { + var data_device = { + id: $(this).data('id'), + hide_owner: !data.data.id ? true : false + }; + + var defaults = {}; + + if(!data.data.id) { + defaults.new_user = self.random_id; + } + else { + defaults.owner_id = data.data.id; + } + + monster.pub('callflows.device.popupEdit', { + data: data_device, + callback: function(_data) { + data_devices = { + data: { }, + field_data: { + device_types: data.field_data.device_types + } + }; + data_devices.data = _data.data.new_user ? { new_user: true, id: self.random_id } : { id: data.data.id }; + + self.userRenderDeviceList(data_devices, user_html); + }, + data_defaults: defaults + }); + }); + + $(user_html).delegate('.action_device.delete', 'click', function() { + var device_id = $(this).data('id'); + monster.ui.confirm(self.i18n.active().callflows.user.do_you_really_want_to_delete, function() { + self.userDeleteDevice(device_id, function() { + data_devices = { + data: { }, + field_data: { + device_types: data.field_data.device_types + } + }; + data_devices.data = self.random_id ? { new_user: true, id: self.random_id } : { id: data.data.id }; + + self.userRenderDeviceList(data_devices, user_html); + }); + }); + }); + + $('.add_device', user_html).click(function(ev) { + var data_device = { + hide_owner: true + }, + defaults = {}; + + ev.preventDefault(); + + if(!data.data.id) { + defaults.new_user = self.random_id; + } + else { + defaults.owner_id = data.data.id; + } + + monster.pub('callflows.device.popupEdit', { + data: data_device, + callback: function(_data) { + var data_devices = { + data: { }, + field_data: { + device_types: data.field_data.device_types + } + }; + data_devices.data = self.random_id ? { new_user: true, id: self.random_id } : { id: data.data.id }; + + self.userRenderDeviceList(data_devices, user_html); + }, + data_defaults: defaults + }); + }); + + (target) + .empty() + .append(user_html); + }, + + userRenderList: function(parent, callback) { + var self = this; + + self.userList(function(data, status) { + var map_crossbar_data = function(data) { + var new_list = []; + + if(data.length > 0) { + $.each(data, function(key, val) { + new_list.push({ + id: val.id, + title: (val.first_name && val.last_name) ? + val.last_name + ', ' + val.first_name : + '(no name)' + }); + }); + } + + new_list.sort(function(a, b) { + return a.title.toLowerCase() < b.title.toLowerCase() ? -1 : 1; + }); + + return new_list; + }; + + // $('#user-listpanel', parent) + // .empty() + // .listpanel({ + // label: _t('user', 'users_label'), + // identifier: 'user-listview', + // new_entity_label: _t('user', 'add_user_label'), + // data: map_crossbar_data(data.data), + // publisher: monster.pub, + // notifyMethod: 'callflows.user.edit', + // notifyCreateMethod: 'callflows.user.edit', + // notifyParent: parent + // }); + + callback && callback(); + } + ); + }, + + userRenderDeviceList: function(data, parent) { + var self = this, + parent = $('#tab_devices', parent); + + if(data.data.id) { + var filter = data.data.new_user ? { filter_new_user: data.data.id } : { filter_owner_id: data.data.id }; + + self.userListDevice(filter, function(_data, status) { + $('.rows', parent).empty(); + if(_data.length > 0) { + $.each(_data, function(k, v) { + v.display_type = data.field_data.device_types[v.device_type]; + v.not_enabled = this.enabled === false ? true : false; + $('.rows', parent).append($(monster.template(self, 'user-deviceRow', v))); + }); + + self.callApi({ + resource: 'device.getStatus', + data: { + accountId: self.accountId + }, + success: function(_data, status) { + $.each(_data.data, function(key, val) { + $('#' + val.device_id + ' .column.third', parent).addClass('registered'); + }); + } + }); + } + else { + $('.rows', parent).append($(monster.template(self, 'user-deviceRow'))); + } + }); + } + else { + $('.rows', parent).empty() + .append($(monster.template(self, 'user-deviceRow'))); + } + }, + + userMigrateData: function(data) { + if(!('priv_level' in data)) { + if('apps' in data && 'voip' in data.apps) { + data.priv_level = 'admin'; + } else { + data.priv_level = 'user'; + } + } + + return data; + }, + + userUpdateSingleDevice: function($checkbox, parent) { + $checkbox.attr('disabled', 'disabled'); + + var self = this, + device_id = $checkbox.data('device_id'), + enabled = $checkbox.is(':checked'); + + self.userGetDevice(device_id, function(_data) { + if($.inArray(_data.device_type, ['cellphone', 'smartphone', 'landline']) > -1) { + _data.call_forward.enabled = enabled; + } + _data.enabled = enabled; + self.userUpdateDevice(device_id, _data, function(_data) { + $checkbox.removeAttr('disabled'); + if(_data.enabled === true) { + $('#'+ _data.id + ' .column.third', parent).removeClass('disabled'); + } + else { + $('#'+ _data.id + ' .column.third', parent).addClass('disabled'); + } + }, + function() { + $checkbox.removeAttr('disabled'); + enabled ? $checkbox.removeAttr('checked') : $checkbox.attr('checked', 'checked'); + } + ); + }, + function() { + $checkbox.removeAttr('disabled'); + enabled ? $checkbox.removeAttr('checked') : $checkbox.attr('checked', 'checked'); + } + ); + }, + + userAcquireDevice: function(user_data, success, error) { + var self = this, + user_id = user_data.id; + + if(self.random_id) { + self.userListDevice({ filter_new_user: self.random_id }, function(_data, status) { + var device_id; + var array_length = _data.length; + if(array_length != 0) { + $.each(_data, function(k, v) { + device_id = this.id; + self.userGetDevice(device_id, function(_data, status) { + _data.owner_id = user_id; + delete _data.new_user; + self.userUpdateDevice(device_id, _data, function(_data, status) { + if(k == array_length - 1) { + success({}, status, 'create'); + } + }); + }); + }); + } + else { + success({}, status, 'create'); + } + }); + } + else { + success({}, status, 'create'); + } + }, + + userCleanFormData: function(form_data){ + form_data.caller_id.internal.number = form_data.caller_id.internal.number.replace(/\s|\(|\)|\-|\./g,''); + form_data.caller_id.external.number = form_data.caller_id.external.number.replace(/\s|\(|\)|\-|\./g,''); + form_data.caller_id.emergency.number = form_data.caller_id.emergency.number.replace(/\s|\(|\)|\-|\./g,''); + + form_data.call_restriction.closed_groups = { action: form_data.extra.closed_groups ? 'deny' : 'inherit' }; + + if(!form_data.hotdesk.require_pin) { + delete form_data.hotdesk.pin; + } + + if(form_data.pwd_mngt_pwd1 != 'fakePassword') { + form_data.password = form_data.pwd_mngt_pwd1; + } + + delete form_data.pwd_mngt_pwd1; + delete form_data.pwd_mngt_pwd2; + delete form_data.extra; + + return form_data; + }, + + userSave: function(form_data, data, success, error) { + var self = this, + normalized_data = self.userNormalizeData($.extend(true, {}, data.data, form_data)); + + if(typeof data.data == 'object' && data.data.id) { + self.userUpdate(normalized_data, function(_data, status) { + if(typeof success == 'function') { + success(_data, status, 'update'); + } + }, + function(_data, status) { + if(typeof error == 'function') { + error(_data, status, 'update'); + } + } + ); + } + else { + self.userCreate(normalized_data, function(_data, status) { + if(typeof success == 'function') { + success(_data, status, 'create'); + } + }, + function(_data, status) { + if(typeof error == 'function') { + error(_data, status, 'create'); + } + } + ); + } + }, + + userNormalizeData: function(data) { + if($.isArray(data.directories)) { + data.directories = {}; + } + + $.each(data.caller_id, function(key, val) { + $.each(val, function(_key, _val) { + if(_val == '') { + delete val[_key]; + } + }); + + if($.isEmptyObject(val)) { + delete data.caller_id[key]; + } + }); + + if($.isEmptyObject(data.caller_id)) { + delete data.caller_id; + } + + if(!data.music_on_hold.media_id) { + delete data.music_on_hold.media_id; + } + + if(data.hotdesk.hasOwnProperty("enable")) { + delete data.hotdesk.enable; + } + + if(data.hotdesk.hasOwnProperty('log_out')) { + var new_endpoint_ids = []; + + $.each(data.hotdesk.endpoint_ids, function(k, v) { + if(data.hotdesk.log_out.indexOf(v) < 0) { + new_endpoint_ids.push(v); + } + }); + + data.hotdesk.endpoint_ids = new_endpoint_ids; + + delete data.hotdesk.log_out; + } + + if(data.hotdesk.hasOwnProperty('endpoint_ids') && data.hotdesk.endpoint_ids.length === 0) { + delete data.hotdesk.endpoint_ids; + } + + if(data.hasOwnProperty('call_forward') && data.call_forward.number === '') { + delete data.call_forward.number; + } + + if(data.hasOwnProperty('presence_id') && data.presence_id === '') { + delete data.presence_id; + } + + if(data.timezone && data.timezone === 'inherit') { + delete data.timezone; + } + + return data; + }, + + + userList: function(callback) { + var self = this; + + self.callApi({ + resource: 'user.list', + data: { + accountId: self.accountId, + filters: { paginate:false } + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + userGet: function(userId, callback) { + var self = this; + + self.callApi({ + resource: 'user.get', + data: { + accountId: self.accountId, + userId: userId + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + userCreate: function(data, callback) { + var self = this; + + self.callApi({ + resource: 'user.create', + data: { + accountId: self.accountId, + data: data + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + userUpdate: function(data, callback) { + var self = this; + + self.callApi({ + resource: 'user.update', + data: { + accountId: self.accountId, + userId: data.id, + data: data + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + userDelete: function(userId, callbackSuccess, callbackError) { + var self = this; + + self.callApi({ + resource: 'user.delete', + data: { + accountId: self.accountId, + userId: userId + }, + success: function(data) { + callbackSuccess && callbackSuccess(data.data); + }, + error: function(error) { + callbackError && callbackError(); + } + }); + }, + + userListDevice: function(pFilters, callback) { + var self = this, + filters = $.extend(true, pFilters, { paginate: false }); + + self.callApi({ + resource: 'device.list', + data: { + accountId: self.accountId, + filters: filters + }, + success: function(data) { + callback && callback(data.data); + } + }) + }, + + userGetDevice: function(deviceId, callbackSuccess, callbackError) { + var self = this; + + self.callApi({ + resource: 'device.get', + data: { + accountId: self.accountId, + deviceId: deviceId + }, + success: function(data) { + callbackSuccess && callbackSuccess(data.data); + }, + error: function(data) { + callbackError && callbackError(); + } + }) + }, + + userUpdateDevice: function(deviceId, data, callbackSuccess, callbackError) { + var self = this; + + self.callApi({ + resource: 'device.update', + data: { + accountId: self.accountId, + deviceId: deviceId, + data: data + }, + success: function(data) { + callbackSuccess && callbackSuccess(data.data); + }, + error: function() { + callbackError && callbackError(); + } + }); + }, + + userDeleteDevice: function(deviceId, callback) { + var self = this; + + self.callApi({ + resource: 'device.delete', + data: { + accountId: self.accountId, + deviceId: deviceId + }, + success: function() { + callback && callback(); + } + }); + } + }; + + return app; +}); diff --git a/src/apps/callflows/submodules/vmbox/vmbox.js b/src/apps/callflows/submodules/vmbox/vmbox.js new file mode 100644 index 0000000..0b716d9 --- /dev/null +++ b/src/apps/callflows/submodules/vmbox/vmbox.js @@ -0,0 +1,634 @@ +define(function(require){ + var $ = require('jquery'), + _ = require('underscore'), + monster = require('monster'), + timezone = require('monster-timezone'); + + var app = { + requests: {}, + + subscribe: { + 'callflows.fetchActions': 'vmboxDefineActions', + 'callflows.vmbox.edit': '_vmboxEdit' + }, + + vmboxPopupEdit: function(args) { + var self = this, + data = args.data, + callback = args.callback, + data_defaults = args.data_defaults || {}, + popup, + popup_html = $('
    '); + + self.vmboxEdit(data, popup_html, $('.inline_content', popup_html), { + save_success: function(_data) { + popup.dialog('close'); + + if(typeof callback == 'function') { + callback(_data); + } + }, + delete_success: function() { + popup.dialog('close'); + + if(typeof callback == 'function') { + callback({ data: {} }); + } + }, + after_render: function() { + popup = monster.ui.dialog(popup_html, { + title: (data.id) ? self.i18n.active().callflows.vmbox.edit_voicemail_box_title : self.i18n.active().callflows.vmbox.create_voicemail_box_title + }); + } + }, data_defaults); + }, + + // Added for the subscribed event to avoid refactoring vmboxEdit + _vmboxEdit: function(args) { + var self = this; + self.vmboxEdit(args.data, args.parent, args.target, args.callbacks, args.data_defaults); + }, + + vmboxEdit: function(data, _parent, _target, _callbacks, data_defaults) { + var self = this, + parent = _parent || $('#vmbox-content'), + target = _target || $('#vmbox-view', parent), + _callbacks = _callbacks || {}, + callbacks = { + save_success: _callbacks.save_success, + save_error: _callbacks.save_error, + delete_success: _callbacks.delete_success, + delete_error: _callbacks.delete_error, + after_render: _callbacks.after_render + }, + defaults = { + data: $.extend(true, { + require_pin: true, + check_if_owner: true, + pin: '', + media: {}, + timezone: 'inherit' + }, data_defaults || {}), + + field_data: { + users: [], + media: [] + } + }; + + monster.parallel({ + media_list: function(callback) { + self.vmboxMediaList(function(_data) { + _data.unshift({ + id: '', + name: self.i18n.active().callflows.vmbox.not_set + }); + + defaults.field_data.media = _data; + + callback(null, _data); + }); + }, + user_list: function(callback) { + self.vmboxUserList(function(_data) { + _data.unshift({ + id: '', + first_name: self.i18n.active().callflows.vmbox.no, + last_name: self.i18n.active().callflows.vmbox.owner + }); + + defaults.field_data.users = _data; + + callback(null, _data); + }); + }, + get_vmbox: function(callback) { + if(typeof data == 'object' && data.id) { + self.vmboxGet(data.id, function(_data) { + callback(null, _data); + }); + } + else { + callback(null, {}); + } + } + }, + function(err, results) { + var render_data = defaults; + + if(typeof data === 'object' && data.id) { + render_data = $.extend(true, defaults, { data: results.get_vmbox }); + } + + self.vmboxRender(render_data, target, callbacks); + + if(typeof callbacks.after_render == 'function') { + callbacks.after_render(); + } + }); + }, + + vmboxFormatData: function(data) { + var self = this; + + data.data.extra = data.data.extra || {}; + + data.data.extra.recipients = (data.data.notify_email_addresses || []).toString(); + + return data; + }, + + vmboxRender: function(data, target, callbacks) { + var self = this, + formattedData = self.vmboxFormatData(data), + vmbox_html = $(monster.template(self, 'vmbox-edit', formattedData)), + vmboxForm = vmbox_html.find('#vmbox-form'); + + timezone.populateDropdown($('#timezone', vmbox_html), data.data.timezone||'inherit', {inherit: self.i18n.active().defaultTimezone}); + + monster.ui.validate(vmboxForm, { + rules: { + 'mailbox': { + required: true, + digits: true + }, + 'pin': { + digits: true, + minlength: 4 + }, + 'name': { + required: true + } + } + }); + + $('*[rel=popover]:not([type="text"])', vmbox_html).popover({ + trigger: 'hover' + }); + + $('*[rel=popover][type="text"]', vmbox_html).popover({ + trigger: 'focus' + }); + + self.winkstartTabs(vmbox_html); + + + $('#owner_id', vmbox_html).change(function() { + if($(this).val()) { + self.callApi({ + resource: 'user.get', + data: { + accountId: self.accountId, + userId: $(this).val() + }, + success: function(data) { + if('timezone' in data.data) { + $('#timezone', vmbox_html).val(data.data.timezone); + } + } + }); + } + }); + + if(!$('#owner_id', vmbox_html).val()) { + $('#edit_link', vmbox_html).hide(); + } + + $('#owner_id', vmbox_html).change(function() { + if(!$('#owner_id option:selected', vmbox_html).val()) { + $('#edit_link', vmbox_html).hide(); + $('#timezone', vmbox_html).val(timezone.getLocaleTimezone()); + } + else { + $('#edit_link', vmbox_html).show(); + } + }); + + $('.inline_action', vmbox_html).click(function(ev) { + var _data = ($(this).data('action') == 'edit') ? { id: $('#owner_id', vmbox_html).val() } : {}, + _id = _data.id; + + ev.preventDefault(); + + monster.pub('callflows.user.popupEdit', { + data: _data, + callback: function(_data) { + /* Create */ + if(!_id) { + $('#owner_id', vmbox_html).append('') + $('#owner_id', vmbox_html).val(_data.id); + + $('#edit_link', vmbox_html).show(); + $('#timezone', vmbox_html).val(_data.timezone); + } + else { + /* Update */ + if('id' in _data) { + $('#owner_id #'+_data.data.id, vmbox_html).text(_data.first_name + ' ' + _data.last_name); + $('#timezone', vmbox_html).val(_data.timezone); + } + /* Delete */ + else { + $('#owner_id #'+_id, vmbox_html).remove(); + $('#edit_link', vmbox_html).hide(); + $('#timezone', vmbox_html).val('America/Los_Angeles'); + } + } + } + }); + }); + + if(!$('#media_unavailable', vmbox_html).val()) { + $('#edit_link_media', vmbox_html).hide(); + } + + $('#media_unavailable', vmbox_html).change(function() { + !$('#media_unavailable option:selected', vmbox_html).val() ? $('#edit_link_media', vmbox_html).hide() : $('#edit_link_media', vmbox_html).show(); + }); + + $('.inline_action_media', vmbox_html).click(function(ev) { + var _data = ($(this).data('action') == 'edit') ? { id: $('#media_unavailable', vmbox_html).val() } : {}, + _id = _data.id; + + ev.preventDefault(); + + monster.pub('callflows.media.editPopup', { + data: _data, + callback: function(_data) { + /* Create */ + if(!_id) { + $('#media_unavailable', vmbox_html).append('') + $('#media_unavailable', vmbox_html).val(_data.id); + + $('#edit_link_media', vmbox_html).show(); + } + else { + /* Update */ + if('id' in _data) { + $('#media_unavailable #'+_data.id, vmbox_html).text(_data.name); + } + /* Delete */ + else { + $('#media_unavailable #'+_id, vmbox_html).remove(); + $('#edit_link_media', vmbox_html).hide(); + } + } + } + }); + }); + + + var validateEmail = function (email) { + var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; + return re.test(email); + }, + getRecipients = function() { + var list = $('#recipients_list', vmbox_html).val().replace(/\s+/g, '').split(','); + + return list.filter(function(email) { return validateEmail(email) }); + }; + + $('.vmbox-save', vmbox_html).click(function(ev) { + ev.preventDefault(); + + var $this = $(this); + + if(!$this.hasClass('disabled')) { + $this.addClass('disabled'); + + if(monster.ui.valid(vmboxForm)) { + var form_data = monster.ui.getFormData('vmbox-form'); + + form_data.notify_email_addresses = getRecipients(); + + /* self.clean_form_data(form_data); */ + + if('field_data' in data) { + delete data.field_data; + } + + self.vmboxSave(form_data, data, callbacks.save_success); + } + else { + $this.removeClass('disabled'); + } + } + }); + + $('.vmbox-delete', vmbox_html).click(function(ev) { + ev.preventDefault(); + + monster.ui.confirm(self.i18n.active().callflows.vmbox.are_you_sure_you_want_to_delete, function() { + self.vmboxDelete(data.data.id, callbacks.delete_success); + }); + }); + + (target) + .empty() + .append(vmbox_html); + }, + + vmboxSave: function(form_data, data, success, error) { + var self = this, + normalized_data = self.vmboxNormalizeData($.extend(true, {}, data.data, form_data), form_data); + + if(typeof data.data == 'object' && data.data.id) { + self.vmboxUpdate(normalized_data, function(_data, status) { + if(typeof success == 'function') { + success(_data, status, 'update'); + } + }); + } + else { + self.vmboxCreate(normalized_data, function(_data, status) { + if(typeof success == 'function') { + success(_data, status, 'create'); + } + }); + } + }, + + vmboxNormalizeData: function(mergedData, formData) { + if(!mergedData.owner_id) { + delete mergedData.owner_id; + } + + if(!mergedData.media.unavailable) { + delete mergedData.media.unavailable; + } + + if(mergedData.pin === '') { + delete mergedData.pin; + } + + if(mergedData.timezone && mergedData.timezone === 'inherit') { + delete mergedData.timezone; + } + + if (mergedData.media_extension === 'default') { + delete mergedData.media_extension; + } + + mergedData.not_configurable = !mergedData.extra.allow_configuration; + + // extend doesn't override arrays... + mergedData.notify_email_addresses = formData.notify_email_addresses; + + delete mergedData.extra; + + return mergedData; + }, + + vmboxDefineActions: function(args) { + var self = this, + callflow_nodes = args.actions, + getVoicemailNode = function(hasCategory) { + var action = { + name: self.i18n.active().callflows.vmbox.voicemail, + icon: 'voicemail', + module: 'voicemail', + tip: self.i18n.active().callflows.vmbox.voicemail_tip, + data: { + id: 'null' + }, + rules: [ + { + type: 'quantity', + maxSize: '1' + } + ], + isUsable: 'true', + weight: 50, + caption: function(node, caption_map) { + var id = node.getMetadata('id'), + returned_value = ''; + + if(id in caption_map) { + returned_value = caption_map[id].name; + } + + return returned_value; + }, + edit: function(node, callback) { + var _this = this; + + self.vmboxList(function(data) { + var popup, popup_html; + + popup_html = $(monster.template(self, 'vmbox-callflowEdit', { + items: _.sortBy(data, 'name'), + selected: node.getMetadata('id') || '' + })); + + if($('#vmbox_selector option:selected', popup_html).val() == undefined) { + $('#edit_link', popup_html).hide(); + } + + $('.inline_action', popup_html).click(function(ev) { + var _data = ($(this).data('action') == 'edit') ? + { id: $('#vmbox_selector', popup_html).val() } : {}; + + ev.preventDefault(); + + self.vmboxPopupEdit({ + data: _data, + callback: function(vmbox) { + node.setMetadata('id', vmbox.id || 'null'); + + node.caption = vmbox.name || ''; + + popup.dialog('close'); + } + }); + }); + + $('#add', popup_html).click(function() { + node.setMetadata('id', $('#vmbox_selector', popup_html).val()); + + node.caption = $('#vmbox_selector option:selected', popup_html).text(); + + popup.dialog('close'); + }); + + popup = monster.ui.dialog(popup_html, { + title: self.i18n.active().callflows.vmbox.voicemail_title, + minHeight: '0', + beforeClose: function() { + if(typeof callback == 'function') { + callback(); + } + } + }); + } + ); + }, + listEntities: function(callback) { + self.callApi({ + resource: 'voicemail.list', + data: { + accountId: self.accountId, + filters: { paginate:false } + }, + success: function(data, status) { + callback && callback(data.data); + } + }); + }, + editEntity: 'callflows.vmbox.edit' + }; + + if(hasCategory) { + action.category = self.i18n.active().oldCallflows.basic_cat; + } + + return action; + }; + + $.extend(callflow_nodes, { + // some old nodes won't have an action set, so we need a node to support no "action" + // this is also the node we want to use when we drag it onto a callflow as we want the back-end to use the default action set in the schemas + 'voicemail[id=*]': getVoicemailNode(true), + + // the default action being "compose", the front-end needs a node handling the "compose" action. + // but we set the flag to false so we don't have 2 times the same node in the right list of actions + 'voicemail[id=*,action=compose]': getVoicemailNode(false), + + 'voicemail[action=check]': { + name: self.i18n.active().callflows.vmbox.check_voicemail, + icon: 'voicemail', + category: self.i18n.active().oldCallflows.advanced_cat, + module: 'voicemail', + tip: self.i18n.active().callflows.vmbox.check_voicemail_tip, + data: { + action: 'check' + }, + rules: [ + { + type: 'quantity', + maxSize: '1' + } + ], + isUsable: 'true', + weight: 120, + caption: function(node, caption_map) { + return ''; + }, + edit: function(node, callback) { + if(typeof callback == 'function') { + callback(); + } + } + } + }); + }, + + vmboxList: function(callback) { + var self = this; + + self.callApi({ + resource: 'voicemail.list', + data: { + accountId: self.accountId, + filters: { paginate:false } + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + vmboxGet: function(vmboxId, callback) { + var self = this; + + self.callApi({ + resource: 'voicemail.get', + data: { + accountId: self.accountId, + voicemailId: vmboxId + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + vmboxCreate: function(data, callback) { + var self = this; + + self.callApi({ + resource: 'voicemail.create', + data: { + accountId: self.accountId, + data: data + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + vmboxUpdate: function(data, callback) { + var self = this; + + self.callApi({ + resource: 'voicemail.update', + data: { + accountId: self.accountId, + voicemailId: data.id, + data: data + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + vmboxDelete: function(vmboxId, callback) { + var self = this; + + self.callApi({ + resource: 'voicemail.delete', + data: { + accountId: self.accountId, + voicemailId: vmboxId + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + vmboxMediaList: function(callback) { + var self = this; + + self.callApi({ + resource: 'media.list', + data: { + accountId: self.accountId, + filters: { paginate:false } + }, + success: function(data) { + callback && callback(data.data); + } + }); + }, + + vmboxUserList: function(callback) { + var self = this; + + self.callApi({ + resource: 'user.list', + data: { + accountId: self.accountId, + filters: { paginate:false } + }, + success: function(data) { + callback && callback(data.data); + } + }); + } + + }; + + return app; +}); diff --git a/src/apps/callflows/views/accountSettings.html b/src/apps/callflows/views/accountSettings.html new file mode 100644 index 0000000..a63bea2 --- /dev/null +++ b/src/apps/callflows/views/accountSettings.html @@ -0,0 +1,189 @@ + diff --git a/src/apps/callflows/views/addNumber.html b/src/apps/callflows/views/addNumber.html new file mode 100644 index 0000000..23a9506 --- /dev/null +++ b/src/apps/callflows/views/addNumber.html @@ -0,0 +1,45 @@ +
    +
    + + + + +
    + +
    +
    +
    diff --git a/src/apps/callflows/views/blacklist-addNumber.html b/src/apps/callflows/views/blacklist-addNumber.html new file mode 100644 index 0000000..9a9a6cc --- /dev/null +++ b/src/apps/callflows/views/blacklist-addNumber.html @@ -0,0 +1,7 @@ +
    + {{number}} + +
    + +
    +
    \ No newline at end of file diff --git a/src/apps/callflows/views/blacklist-edit.html b/src/apps/callflows/views/blacklist-edit.html new file mode 100644 index 0000000..b8ace7f --- /dev/null +++ b/src/apps/callflows/views/blacklist-edit.html @@ -0,0 +1,62 @@ +
    +
    +
    +

    {{#if data.id}}{{ i18n.callflows.blacklist.edit }}{{else}}{{ i18n.callflows.blacklist.create }}{{/if}}

    +
    + +
    +
    +
    +
    +
    + +
    + +
    +
    +
    + +
    + {{#monsterSwitch}} + + {{/monsterSwitch}} +
    +
    + +
    +

    {{ i18n.callflows.blacklist.listNumbers }}

    +
    +
    +
    + + {{ i18n.callflows.blacklist.addNumber }} +
    + +
    + + + {{ i18n.cancel }} +
    +
    +
    + +
    +
    +
    + +
    +

    {{ i18n.callflows.blacklist.help }}

    +
    +
    +
    +
    + +
    + {{#if data.id}} + + {{/if}} + +
    +
    +
    +
    diff --git a/src/apps/callflows/views/branch.html b/src/apps/callflows/views/branch.html new file mode 100644 index 0000000..08c9c18 --- /dev/null +++ b/src/apps/callflows/views/branch.html @@ -0,0 +1,31 @@ +
    + {{#compare node.actionName "!==" "root"}} + {{#if display_key}} +
    + {{else}} +
    + {{/if}} + +
    + +
    + +
    + + {{#if display_key}} + + {{/if}} + {{/compare}} + +
    + {{#compare node.actionName "!==" "root"}} +
    + {{else}} +
    + {{/compare}} + +
    +
    +
    diff --git a/src/apps/callflows/views/buttons.html b/src/apps/callflows/views/buttons.html new file mode 100644 index 0000000..86c2394 --- /dev/null +++ b/src/apps/callflows/views/buttons.html @@ -0,0 +1,4 @@ + +
    {{ i18n.oldCallflows.delete_callflow }}
    +
    {{ i18n.oldCallflows.save_changes }}
    +
    diff --git a/src/apps/callflows/views/callflow-edit_dialog.html b/src/apps/callflows/views/callflow-edit_dialog.html new file mode 100644 index 0000000..f7517d9 --- /dev/null +++ b/src/apps/callflows/views/callflow-edit_dialog.html @@ -0,0 +1,23 @@ +
    +

    {{ i18n.oldCallflows.connect_caller_to_another_callflow }}

    +
    +
    + + +
    + +
    +
    \ No newline at end of file diff --git a/src/apps/callflows/views/callflow-manager.html b/src/apps/callflows/views/callflow-manager.html new file mode 100644 index 0000000..fc72a7d --- /dev/null +++ b/src/apps/callflows/views/callflow-manager.html @@ -0,0 +1,62 @@ +
    +
    + +
    + + {{ i18n.callflows.addCallflow }} +
    +
    +
      +
      +
      + +
      +
      +
      {{ i18n.entityManager.callflowsTitle }}
      + + + {{#if canToggleCallflows}} +
      + + + {{ i18n.entityManager.showSystemCallflows.title }} + + {{#monsterSwitch}} + + {{/monsterSwitch}} +
      + {{/if}} +
      +
      +
      +
      + +
      +
      +
      +
      +
      +
      +
      + {{ i18n.oldCallflows.you_have_modified_this_callflow }} +
      +
      +
      {{ i18n.callflows.hiddenCallflowWarning }}
      +
      +
      + +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      + diff --git a/src/apps/callflows/views/callflowList-searchLink.html b/src/apps/callflows/views/callflowList-searchLink.html new file mode 100644 index 0000000..b3f4f86 --- /dev/null +++ b/src/apps/callflows/views/callflowList-searchLink.html @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/src/apps/callflows/views/callflowList.html b/src/apps/callflows/views/callflowList.html new file mode 100644 index 0000000..1a77cc3 --- /dev/null +++ b/src/apps/callflows/views/callflowList.html @@ -0,0 +1,8 @@ +{{#each callflows}} +
    • + +
    • +{{/each}} \ No newline at end of file diff --git a/src/apps/callflows/views/conference-callflowEdit.html b/src/apps/callflows/views/conference-callflowEdit.html new file mode 100644 index 0000000..54b0a4c --- /dev/null +++ b/src/apps/callflows/views/conference-callflowEdit.html @@ -0,0 +1,26 @@ +
      +

      {{ i18n.callflows.conference.connect_caller_to_conference }}

      +
      +
      + +
      +
      +
      + +
      +
      diff --git a/src/apps/callflows/views/conference-edit.html b/src/apps/callflows/views/conference-edit.html new file mode 100644 index 0000000..cc8ca3e --- /dev/null +++ b/src/apps/callflows/views/conference-edit.html @@ -0,0 +1,134 @@ +
      +
      +

      {{#if data.id}}{{ i18n.callflows.conference.edit_conference }}{{else}}{{ i18n.callflows.conference.create_conference }}{{/if}}

      +
      + + +
      +
      + +
      + + +
      +
      +
      +
      + +
      + +
      +
      + +
      + +
      + + + + +
      +
      + +
      + +
      + +
      +
      +
      + +
      +
      +
      +
        +
      • + +
      • +
      +
      +
      + +
      +
      +
        +
      • + +
      • +
      +
      +
      + +
      +
      +
        +
      • + +
      • +
      +
      +
      + +
      +
      +
        +
      • + +
      • +
      +
      +
      +
      + +
      +
      + +
      + +
      +
      +
      +
      +
      + +
      + {{#if data.id}} + + {{/if}} + +
      +
      +
      diff --git a/src/apps/callflows/views/device-ata.html b/src/apps/callflows/views/device-ata.html new file mode 100644 index 0000000..7820859 --- /dev/null +++ b/src/apps/callflows/views/device-ata.html @@ -0,0 +1,266 @@ +
      +
      +
      + {{#if data.id}} +

      {{ i18n.callflows.device.edit_ata }}

      + {{else}} +

      {{ i18n.callflows.device.add_a_ata }}

      + {{/if}} +
      + + +
      +
      +
      +
      + +
      +
      +
      +
      + +
      + +
      +
      + + {{#unless field_data.hide_owner}} +
      + +
      + + + + +
      +
      + {{/unless}} + +
      + +
      + + +
      +
      + +
      +
      +
        +
      • + +
      • +
      +
      +
      +
      + +
      +
      + +
      + +
      +
      + +

      {{ i18n.callflows.device.in_house_calls }}

      +
      + +
      + +
      +
      + +
      + +
      + +
      +
      +
      + +

      {{ i18n.callflows.device.outbound_calls }}

      +
      + +
      + +
      +
      + +
      + +
      + +
      +
      +
      + +

      {{ i18n.callflows.device.emergency }}

      +
      + +
      + +
      +
      + +
      + +
      + +
      +
      +
      + + +
      +
      + +
      + {{ field_data.sip.realm }} +
      +
      + +
      + +
      + +
      +
      + +
      +
      + +
      + +
      +
      +
      + +
      +
      + +
      + +
      +
      + +
      + +
      + +
      +
      +
      + +
      + +
      + +
      +
      + +
      + +
      + +
      +
      + +
      + +
      + +
      +
      +
      + +
      +
      +
      +
        +
      • + +
      • +
      +
      +
      +
      + +
      +
      +
      +
        +
      • + +
      • +
      +
      +
      + + {{#each field_data.call_restriction}} +
      + +
      + +
      +
      + {{/each}} +
      +
      +
      +
      + {{#if data.id}} + + {{/if}} + +
      +
      +
      diff --git a/src/apps/callflows/views/device-callflowEdit.html b/src/apps/callflows/views/device-callflowEdit.html new file mode 100644 index 0000000..93980a3 --- /dev/null +++ b/src/apps/callflows/views/device-callflowEdit.html @@ -0,0 +1,40 @@ +
      +

      {{ i18n.callflows.device.connect_caller_to_device }}

      +
      +
      + + +
      + +
      +
      +
      + diff --git a/src/apps/callflows/views/device-cellphone.html b/src/apps/callflows/views/device-cellphone.html new file mode 100644 index 0000000..ff345f8 --- /dev/null +++ b/src/apps/callflows/views/device-cellphone.html @@ -0,0 +1,131 @@ +
      +
      +
      + {{#if data.id}} +

      {{ i18n.callflows.device.edit_cell_phone }}

      + {{else}} +

      {{ i18n.callflows.device.add_a_cell_phone }}

      + {{/if}} +
      + + +
      +
      +
      +
      + +
      +
      +
      +
      + +
      + +
      +
      + + {{#unless field_data.hide_owner}} +
      + +
      + + + + +
      +
      + {{/unless}} + +
      + +
      + +
      +
      + +
      +
      +
        +
      • + +
      • +
      +
      +
      + + +
      + +
      +
      +
      +
        +
      • + +
      • +
      +
      +
      + +
      +
      +
        +
      • + +
      • +
      +
      +
      + +
      +
      +
        +
      • + +
      • +
      +
      +
      +
      +
      +
      +
      + {{#if data.id}} + + {{/if}} + +
      +
      +
      diff --git a/src/apps/callflows/views/device-entity-element.html b/src/apps/callflows/views/device-entity-element.html new file mode 100644 index 0000000..19308fa --- /dev/null +++ b/src/apps/callflows/views/device-entity-element.html @@ -0,0 +1,3 @@ +
      + {{name}}
      +
      \ No newline at end of file diff --git a/src/apps/callflows/views/device-fax.html b/src/apps/callflows/views/device-fax.html new file mode 100644 index 0000000..ac5ab3e --- /dev/null +++ b/src/apps/callflows/views/device-fax.html @@ -0,0 +1,289 @@ +
      +
      +
      + {{#if data.id}} +

      {{ i18n.callflows.device.edit_fax }}

      + {{else}} +

      {{ i18n.callflows.device.add_a_fax }}

      + {{/if}} +
      + + +
      +
      +
      +
      + +
      +
      +
      +
      + +
      + +
      +
      + + {{#unless field_data.hide_owner}} +
      + +
      + + + + +
      +
      + {{/unless}} + +
      + +
      + + +
      +
      + +
      +
      +
        +
      • + +
      • +
      +
      +
      + +
      +
      +
        +
      • + +
      • +
      +
      +
      +
      + +
      +
      + +
      + +
      +
      + +

      {{ i18n.callflows.device.in_house_calls }}

      +
      + +
      + +
      +
      + +
      + +
      + +
      +
      +
      + +

      {{ i18n.callflows.device.outbound_calls }}

      +
      + +
      + +
      +
      + +
      + +
      + +
      +
      +
      + +

      {{ i18n.callflows.device.emergency }}

      +
      + +
      + +
      +
      + +
      + +
      + +
      +
      +
      + + +
      +
      + +
      + {{ field_data.sip.realm }} +
      +
      + +
      + +
      + +
      +
      + +
      +
      + +
      + +
      +
      +
      + +
      +
      + +
      + +
      +
      + +
      + +
      + +
      +
      +
      + +
      + +
      + +
      +
      + +
      + +
      + +
      +
      +
      + +
      +
      +
      +
        +
      • + +
      • +
      +
      +
      + +
      +
      +
        +
      • + +
      • +
      +
      +
      +
      + +
      +
      +
      +
        +
      • + +
      • +
      +
      +
      + + {{#each field_data.call_restriction}} +
      + +
      + +
      +
      + {{/each}} +
      +
      +
      +
      + {{#if data.id}} + + {{/if}} + +
      +
      +
      diff --git a/src/apps/callflows/views/device-general_edit.html b/src/apps/callflows/views/device-general_edit.html new file mode 100644 index 0000000..5434cf7 --- /dev/null +++ b/src/apps/callflows/views/device-general_edit.html @@ -0,0 +1,49 @@ +
      +
      +
      + + + {{ i18n.callflows.device.voip_phone }} + + + + + {{ i18n.callflows.device.cell_phone }} + + + + + {{ i18n.callflows.device.smart_phone }} + + + + + {{ i18n.callflows.device.landline }} + + + + + {{ i18n.callflows.device.soft_phone }} + + + + + {{ i18n.callflows.device.fax }} + + + + + {{ i18n.callflows.device.ata }} + + + + + {{ i18n.callflows.device.sip_uri }} + +
      +
      + +
      + +
      +
      diff --git a/src/apps/callflows/views/device-landline.html b/src/apps/callflows/views/device-landline.html new file mode 100644 index 0000000..1bc26bc --- /dev/null +++ b/src/apps/callflows/views/device-landline.html @@ -0,0 +1,131 @@ +
      +
      +
      + {{#if data.id}} +

      {{ i18n.callflows.device.edit_landline }}

      + {{else}} +

      {{ i18n.callflows.device.add_a_landline }}

      + {{/if}} +
      + + +
      +
      +
      +
      + +
      +
      +
      +
      + +
      + +
      +
      + + {{#unless field_data.hide_owner}} +
      + +
      + + + + +
      +
      + {{/unless}} + +
      + +
      + +
      +
      + +
      +
      +
        +
      • + +
      • +
      +
      +
      + + +
      + +
      +
      +
      +
        +
      • + +
      • +
      +
      +
      + +
      +
      +
        +
      • + +
      • +
      +
      +
      + +
      +
      +
        +
      • + +
      • +
      +
      +
      +
      +
      +
      +
      + {{#if data.id}} + + {{/if}} + +
      +
      +
      diff --git a/src/apps/callflows/views/device-mobile.html b/src/apps/callflows/views/device-mobile.html new file mode 100644 index 0000000..fa6dace --- /dev/null +++ b/src/apps/callflows/views/device-mobile.html @@ -0,0 +1,343 @@ +
      +
      +
      +

      {{ i18n.callflows.device.view_mobile_phone }}

      +
      + + +
      +
      +
      +
      + +
      +
      +
      +
      + +
      +
      {{ data.name }}
      +
      +
      + + {{#unless field_data.hide_owner}} +
      + +
      +
      {{field_data.users.first_name}} {{field_data.users.last_name}}
      +
      +
      + {{/unless}} + +
      + +
      +
      {{ field_data.sip.realm }}
      +
      +
      + +
      + +
      +
      {{ data.sip.username }}
      +
      +
      + +
      + +
      +
      {{ data.sip.password }}
      +
      +
      + +
      + +
      +
      {{ data.mobile.mdn }}
      +
      +
      + + + + +
      + +
      +
      + +
      + +
      +
      + +

      {{ i18n.callflows.device.in_house_calls }}

      +
      + +
      + +
      +
      + +
      + +
      + +
      +
      +
      + +

      {{ i18n.callflows.device.outbound_calls }}

      +
      + +
      + +
      +
      + +
      + +
      + +
      +
      + + + + +
      + +
      +
      + +
      + +
      +
      + +
      + +
      + +
      +
      + +
      + +
      + +
      +
      +
      + +
      +
      + +
      + + + + +
      +
      + +
      + +
      + +
      +
      + +
      + +
      + +
      +
      + +
      + +
      + +
      +
      + + {{#each field_data.media.audio.codecs}} +
      +
      +
        +
      • + +
      • +
      +
      +
      + {{/each}} +
      + +
      + {{#each field_data.media.video.codecs}} +
      +
      +
        +
      • + +
      • +
      +
      +
      + {{/each}} +
      + +
      +
      +
      +
        +
      • + +
      • +
      +
      +
      + +
      +
      +
        +
      • + +
      • +
      +
      +
      + +
      +
      +
        +
      • + +
      • +
      +
      +
      + +
      + +
      +
      +
      +
        +
      • + +
      • +
      +
      +
      + + {{#each field_data.call_restriction}} +
      + +
      + +
      +
      + {{/each}} +
      +
      +
      +
      + +
      +
      +
      diff --git a/src/apps/callflows/views/device-sip_device.html b/src/apps/callflows/views/device-sip_device.html new file mode 100644 index 0000000..0909acf --- /dev/null +++ b/src/apps/callflows/views/device-sip_device.html @@ -0,0 +1,443 @@ +
      +
      + {{#if data.id}} +

      {{ i18n.callflows.device.edit_voip_phone }}

      + {{else}} +

      {{ i18n.callflows.device.add_a_voip_phone }}

      + {{/if}} +
      + + +
      +
      + +
      + +
      +
      +
      +
      + +
      + +
      +
      + + {{#unless field_data.hide_owner}} +
      + +
      + + + + +
      +
      + {{/unless}} + +
      + +
      + + + {{#if field_data.provisioner.isEnabled}} +
      + + Model   + + + {{#each field_data.provisioner.brands}} + + {{/each}} + +
      + {{/if}} +
      +
      +
      + +
      +
      +
        +
      • + +
      • +
      +
      +
      + +
      +
      +
        +
      • + +
      • +
      +
      +
      +
      + +
      +
      + +
      + +
      +
      + +

      {{ i18n.callflows.device.in_house_calls }}

      +
      + +
      + +
      +
      + +
      + +
      + +
      +
      +
      + +

      {{ i18n.callflows.device.outbound_calls }}

      +
      + +
      + +
      +
      + +
      + +
      + +
      +
      +
      + +

      {{ i18n.callflows.device.emergency }}

      +
      + +
      + +
      +
      + +
      + +
      + +
      +
      +
      + +
      +
      + +
      + {{ field_data.sip.realm }} +
      +
      + +
      + +
      + +
      +
      + +
      +
      + +
      + +
      +
      +
      + +
      +
      + +
      + +
      +
      + +
      + +
      + +
      +
      +
      + +
      + +
      + +
      +
      + +
      + +
      + +
      +
      + +
      + +
      + +
      +
      +
      + +
      +
      + +
      + + + + +
      +
      + +
      + +
      + +
      +
      + +
      + +
      + +
      +
      + +
      + +
      + +
      +
      + + {{#each field_data.media.audio.codecs}} +
      +
      +
        +
      • + +
      • +
      +
      +
      + {{/each}} +
      + +
      + {{#each field_data.media.video.codecs}} +
      +
      +
        +
      • + +
      • +
      +
      +
      + {{/each}} +
      + + + +
      +
      + +
      + +
      +
      + +
      + +
      + +
      +
      + +
      +
      +
        +
      • + +
      • +
      +
      +
      + +
      +
      +
        +
      • + +
      • +
      +
      +
      + +
      +
      +
        +
      • + +
      • +
      +
      +
      +
      + +
      +
      +
      +
        +
      • + +
      • +
      +
      +
      + + {{#each field_data.call_restriction}} +
      + +
      + +
      +
      + {{/each}} +
      +
      +
      + +
      + {{#if data.id}} + + {{/if}} + +
      +
      +
      diff --git a/src/apps/callflows/views/device-sip_uri.html b/src/apps/callflows/views/device-sip_uri.html new file mode 100644 index 0000000..9f23811 --- /dev/null +++ b/src/apps/callflows/views/device-sip_uri.html @@ -0,0 +1,102 @@ +
      +
      +
      + {{#if data.id}} +

      {{ i18n.callflows.device.edit_sip_uri }}

      + {{else}} +

      {{ i18n.callflows.device.add_a_sip_uri }}

      + {{/if}} +
      + + +
      +
      +
      +
      + +
      +
      +
      +
      + +
      + +
      +
      + + {{#unless field_data.hide_owner}} +
      + +
      + + + + +
      +
      + {{/unless}} + +
      + +
      + +
      +
      + +
      +
      +
        +
      • + +
      • +
      +
      +
      + + + +
      + +
      +
      +
      +
        +
      • + +
      • +
      +
      +
      +
      +
      +
      +
      + {{#if data.id}} + + {{/if}} + +
      +
      +
      diff --git a/src/apps/callflows/views/device-smartphone.html b/src/apps/callflows/views/device-smartphone.html new file mode 100644 index 0000000..c88303a --- /dev/null +++ b/src/apps/callflows/views/device-smartphone.html @@ -0,0 +1,231 @@ +
      +
      +
      + {{#if data.id}} +

      {{ i18n.callflows.device.edit_smart_phone }}

      + {{else}} +

      {{ i18n.callflows.device.add_a_smart_phone }}

      + {{/if}} +
      + + +
      +
      +
      +
      + +
      +
      +
      +
      + +
      + +
      +
      + + {{#unless field_data.hide_owner}} +
      + +
      + + + + +
      +
      + {{/unless}} + +
      + +
      + +
      +
      + +
      +
      +
        +
      • + +
      • +
      +
      +
      + + +
      + +
      +
      +
      +
        +
      • + +
      • +
      +
      +
      + +
      +
      +
        +
      • + +
      • +
      +
      +
      + +
      +
      +
        +
      • + +
      • +
      +
      +
      +
      + +
      +
      + +
      + {{ field_data.sip.realm }} +
      +
      + +
      + +
      + +
      +
      + +
      +
      + +
      + +
      +
      +
      + +
      +
      + +
      + +
      +
      + +
      + +
      + +
      +
      +
      + +
      + +
      + +
      +
      + +
      + +
      + +
      +
      +
      +
      +
      +
      +
        +
      • + +
      • +
      +
      +
      + + {{#each field_data.call_restriction}} +
      + +
      + +
      +
      + {{/each}} +
      +
      +
      +
      + {{#if data.id}} + + {{/if}} + +
      +
      +
      diff --git a/src/apps/callflows/views/device-softphone.html b/src/apps/callflows/views/device-softphone.html new file mode 100644 index 0000000..a0bbef4 --- /dev/null +++ b/src/apps/callflows/views/device-softphone.html @@ -0,0 +1,375 @@ +
      +
      +
      + {{#if data.id}} +

      {{ i18n.callflows.device.edit_soft_phone }}

      + {{else}} +

      {{ i18n.callflows.device.add_a_soft_phone }}

      + {{/if}} +
      + + +
      +
      +
      +
      + +
      +
      +
      +
      + +
      + +
      +
      + + {{#unless field_data.hide_owner}} +
      + +
      + + + + +
      +
      + {{/unless}} + +
      + +
      + {{ field_data.sip.realm }} +
      +
      + +
      + +
      + +
      +
      + +
      + +
      + +
      +
      + +
      +
      +
        +
      • + +
      • +
      +
      +
      + + +
      + +
      +
      + +
      + +
      +
      +

      {{ i18n.callflows.device.in_house_calls }}

      +
      + +
      + +
      +
      + +
      + +
      + +
      +
      +
      + +

      {{ i18n.callflows.device.outbound_calls }}

      +
      + +
      + +
      +
      + +
      + +
      + +
      +
      + +
      + +

      {{ i18n.callflows.device.emergency }}

      +
      + +
      + +
      +
      + +
      + +
      + +
      +
      +
      + +
      +
      + +
      + +
      +
      + +
      + +
      + +
      +
      + +
      + +
      + +
      +
      +
      + +
      +
      + +
      + + + + +
      +
      + +
      + +
      + +
      +
      + +
      + +
      + +
      +
      + +
      + +
      + +
      +
      + + {{#each field_data.media.audio.codecs}} +
      +
      +
        +
      • + +
      • +
      +
      +
      + {{/each}} +
      + +
      + {{#each field_data.media.video.codecs}} +
      +
      +
        +
      • + +
      • +
      +
      +
      + {{/each}} +
      + +
      +
      +
      +
        +
      • + +
      • +
      +
      +
      + +
      +
      +
        +
      • + +
      • +
      +
      +
      + +
      +
      +
        +
      • + +
      • +
      +
      +
      + +
      +
      +
        +
      • + +
      • +
      +
      +
      + +
      + +
      +
      +
      +
        +
      • + +
      • +
      +
      +
      + + {{#each field_data.call_restriction}} +
      + +
      + +
      +
      + {{/each}} +
      +
      +
      +
      + {{#if data.id}} + + {{/if}} + +
      +
      +
      diff --git a/src/apps/callflows/views/directory-callflowEdit.html b/src/apps/callflows/views/directory-callflowEdit.html new file mode 100644 index 0000000..e61c021 --- /dev/null +++ b/src/apps/callflows/views/directory-callflowEdit.html @@ -0,0 +1,26 @@ +
      +

      {{ i18n.callflows.directory.connect_caller_to_directory }}

      +
      +
      + +
      +
      +
      + +
      +
      diff --git a/src/apps/callflows/views/directory-edit.html b/src/apps/callflows/views/directory-edit.html new file mode 100644 index 0000000..3bc3e3b --- /dev/null +++ b/src/apps/callflows/views/directory-edit.html @@ -0,0 +1,140 @@ +
      +
      +
      + {{#if data.id}} +

      {{ i18n.callflows.directory.edit_directory }}

      + {{else}} +

      {{ i18n.callflows.directory.create_directory }}

      + {{/if}} +
      + + +
      +
      +
      +
      + +
      +
      +
      +
      + +
      + +
      +
      + +
      +
      +
      +
      {{ i18n.callflows.directory.user }}  
      +
      {{ i18n.callflows.directory.callflow }}  
      +
      {{ i18n.callflows.directory.remove }}
      +
      +
      +
      +
      + +
      +
      {{ i18n.callflows.directory.add_user }}
      +
      +
      +
        +
        +
      • + + +
      • +
        +
        +
      • + + + +
      • +
        +
      +
      + +
      +
      +
      + +
      +
      + +
      + +
      +
      + +
      + +
      + +
      +
      + +
      +
      +
        +
      • + +
      • +
      +
      +
      + +
      + +
      + +
      +
      +
      +
      + +
      + {{#if data.id}} + + {{/if}} + +
      +
      +
      diff --git a/src/apps/callflows/views/directory-userRow.html b/src/apps/callflows/views/directory-userRow.html new file mode 100644 index 0000000..65dd72b --- /dev/null +++ b/src/apps/callflows/views/directory-userRow.html @@ -0,0 +1,27 @@ + {{#if user_id}} +
      +
      {{ user_name }}
      +
      + +
      +
      + {{else}} +
      +
      {{ i18n.callflows.directory.there_is_currently_no_user }}
      + {{/if}} +
      +
      diff --git a/src/apps/callflows/views/editName.html b/src/apps/callflows/views/editName.html new file mode 100644 index 0000000..af32495 --- /dev/null +++ b/src/apps/callflows/views/editName.html @@ -0,0 +1,37 @@ +
      +
      +
      + + + + + + +
      {{ i18n.oldCallflows.giving_a_name_to_a_callflow }}
      +
      +
      +
      + +
      +
      diff --git a/src/apps/callflows/views/entity-list.html b/src/apps/callflows/views/entity-list.html new file mode 100644 index 0000000..a445a07 --- /dev/null +++ b/src/apps/callflows/views/entity-list.html @@ -0,0 +1,16 @@ +{{#each entities}} +
    • + +
    • +{{/each}} \ No newline at end of file diff --git a/src/apps/callflows/views/fax-callflowEdit.html b/src/apps/callflows/views/fax-callflowEdit.html new file mode 100644 index 0000000..74637fd --- /dev/null +++ b/src/apps/callflows/views/fax-callflowEdit.html @@ -0,0 +1,32 @@ +
      +

      {{ i18n.oldCallflows.sends_fax_to_user }}

      +
      +
      + diff --git a/src/apps/callflows/views/faxbox-callflowEdit.html b/src/apps/callflows/views/faxbox-callflowEdit.html new file mode 100644 index 0000000..6c2951f --- /dev/null +++ b/src/apps/callflows/views/faxbox-callflowEdit.html @@ -0,0 +1,29 @@ +
      +
      +

      {{ i18n.callflows.faxbox.connect_call_to_faxbox }}

      +
      +
      + + +
      + +
      +
      +
      diff --git a/src/apps/callflows/views/faxbox-edit.html b/src/apps/callflows/views/faxbox-edit.html new file mode 100644 index 0000000..6ea3e49 --- /dev/null +++ b/src/apps/callflows/views/faxbox-edit.html @@ -0,0 +1,170 @@ +
      +
      + {{#if faxbox.id}} +

      {{ i18n.callflows.faxbox.edit_faxbox }}

      + {{else}} +

      {{ i18n.callflows.faxbox.create_faxbox }}

      + {{/if}} +
      + + +
      +
      +
      +
      + +
      +
      +
      +
      + +
      + +
      +
      + +
      + +
      + + + + +
      +
      + +
      +

      {{ i18n.callflows.faxbox.notification_emails }}

      + +
      + +
      + +
      +
      + +
      + +
      + +
      +
      + +
      + +
      +
      + +
      + +
      +
      + +
      + +
      + +
      +
      + +
      + +
      + +
      +
      + +
      + +
      + +
      +
      +
      + +
      +
      + +
      + +
      +
      + +
      + +
      + +
      +
      + + {{#if faxbox.smtp_email_address}} +
      + +
      + {{faxbox.smtp_email_address}} + +
      +
      + {{/if}} +
      + + {{#compare faxbox.cloud_state '===' 'registered'}} +
      +
      + + +
      +
      + + +
      +
      + {{/compare}} + +
      +
      + +
      + +
      +
      + +
      + +
      + +
      +
      +
      +
      +
      + +
      + {{#if faxbox.id}} + + {{/if}} + +
      +
      diff --git a/src/apps/callflows/views/featurecodes-view.html b/src/apps/callflows/views/featurecodes-view.html new file mode 100644 index 0000000..be1507f --- /dev/null +++ b/src/apps/callflows/views/featurecodes-view.html @@ -0,0 +1,42 @@ + \ No newline at end of file diff --git a/src/apps/callflows/views/groups-edit.html b/src/apps/callflows/views/groups-edit.html new file mode 100644 index 0000000..3a25140 --- /dev/null +++ b/src/apps/callflows/views/groups-edit.html @@ -0,0 +1,77 @@ +
      +
      +
      + {{#if data.id}} +

      {{ @root.i18n.callflows.groups.edit_group }}

      + {{else}} +

      {{ @root.i18n.callflows.groups.create_group }}

      + {{/if}} +
      + + +
      +
      +
      +
      + +
      +
      +
      +
      + +
      + +
      +
      + +
      +
      +
      +
      +
      {{ @root.i18n.callflows.groups.endpoints }}
      +
      {{ @root.i18n.callflows.groups.remove }}
      +
      +
      +
      +
      + +
      +
      +
      {{ @root.i18n.callflows.groups.add_user }}
      +
      + +
      +
      + +
      +
      {{ @root.i18n.callflows.groups.add_device }}
      +
      + +
      +
      +
      +
      +
      +
      +
      +
      +
      + {{#if data.id}} + + {{/if}} + +
      +
      +
      diff --git a/src/apps/callflows/views/groups-endpoint_row.html b/src/apps/callflows/views/groups-endpoint_row.html new file mode 100644 index 0000000..6a62f9c --- /dev/null +++ b/src/apps/callflows/views/groups-endpoint_row.html @@ -0,0 +1,12 @@ +
      + {{#if endpoint_id}} +
      +
      {{#compare endpoint_type "===" "user"}}{{else}}{{/compare}}  {{endpoint_name}}
      +
      + {{else}} +
      +
      {{ @root.i18n.callflows.groups.there_are_currently_no_endpoint }}
      + {{/if}} +
      +
      +
      diff --git a/src/apps/callflows/views/groups-page_group_dialog.html b/src/apps/callflows/views/groups-page_group_dialog.html new file mode 100644 index 0000000..0d3e367 --- /dev/null +++ b/src/apps/callflows/views/groups-page_group_dialog.html @@ -0,0 +1,92 @@ +
      +
      +