rbrindley: branch rbrindley/astman_revamp r4594 - /team/rbrindley/astman_reva...
SVN commits to the Asterisk-GUI project
asterisk-gui-commits at lists.digium.com
Mon Mar 9 22:17:46 CDT 2009
Author: rbrindley
Date: Mon Mar 9 22:17:43 2009
New Revision: 4594
URL: http://svn.digium.com/svn-view/asterisk-gui?view=rev&rev=4594
Log:
- copied astgui_managetrunks.deletetrunk to pbx.trunks.remove
- consolidated astgui_managetrunks.list*Trunks to pbx.trunks.list. You can now call all by just calling lost(), or separate them by passing an object with just the needed params, such as pbx.trunks.list({pri: true, analog: true, bri: true});
Modified:
team/rbrindley/astman_revamp/config/js/pbx2.js
Modified: team/rbrindley/astman_revamp/config/js/pbx2.js
URL: http://svn.digium.com/svn-view/asterisk-gui/team/rbrindley/astman_revamp/config/js/pbx2.js?view=diff&rev=4594&r1=4593&r2=4594
==============================================================================
--- team/rbrindley/astman_revamp/config/js/pbx2.js (original)
+++ team/rbrindley/astman_revamp/config/js/pbx2.js Mon Mar 9 22:17:43 2009
@@ -173,10 +173,103 @@
*/
pbx.time_intervals = {};
+/*---------------------------------------------------------------------------*/
/**
* Trunks object.
*/
pbx.trunks = {};
+
+/**
+ * List trunks.
+ * This function takes an object as an argument and cycles through
+ * @param types This is the object holding all the types to be listed.
+ */
+pbx.trunks.list = function(types) {
+ var trunks = [];
+ if (typeof types === 'undefined') {
+ top.log.warn('pbx.trunks.list: types is undefined');
+ return null;
+ }
+
+ if (types.all) {
+ delete types;
+ types = {};
+ types.analog = true;
+ types.bri = true;
+ types.iax = true;
+ types.pri = true;
+ types.provider = true;
+ types.sip = true;
+ }
+
+ for (var type in types) {
+ if (!types.hasOwnProperty(type) || type === 'all' || types[type] === false) {
+ continue;
+ }
+
+ if (!sessionData.pbxinfo.trunks.hasOwnProperty(type)) {
+ top.log.debug('pbx.trunks.list: ' + type + 'is not a type of trunk.');
+ continue;
+ }
+
+ try {
+ for (var item in sessionData.pbxinfo.trunks[type]) {
+ if (!sessionData.pbxinfo.trunks[type].hasOwnProperty(item)) {
+ continue;
+ }
+
+ trunks.push(item);
+ }
+ } catch(err) {
+ top.log.error('pbx.trunks.list: ' + err);
+ }
+ }
+};
+
+/**
+ * Delete a trunk
+ * @param trunk The trunk name
+ */
+pbx.trunks.remove = function(trunk) {
+ var actions = new listOfSynActions('users.conf');
+ actions.new_action('delcat', trunk, '', '');
+ actions.callActions();
+ delete actions;
+
+ var exts = config2json({filename: 'extensions.conf', usf:0});
+ var actions = new listOfSynActions('extensions.conf');
+ actions.new_action('delete', 'globals', trunk, '');
+
+ for (var trunk in exts) {
+ if (!exts.hasOwnProperty(trunk)) {
+ continue;
+ }
+
+ actions.new_action('delcat', trunk, '', '');
+ }
+ actions.callActions();
+
+ try {
+ if (sessionData.pbxinfo['trunks']['analog'][trunk]) {
+ delete sessionData.pbxinfo['trunks']['analog'][trunk];
+ } else if (sessionData.pbxinfo['trunks']['sip'][trunk]) {
+ delete sessionData.pbxinfo['trunks']['sip'][trunk];
+ } else if (sessionData.pbxinfo['trunks']['iax'][trunk]) {
+ delete sessionData.pbxinfo['trunks']['iax'][trunk];
+ } else if (sessionData.pbxinfo['trunks']['pri'][trunk]) {
+ delete sessionData.pbxinfo['trunks']['pri'][trunk];
+ } else if (sessionData.pbxinfo['trunks']['providers'][trunk]) {
+ delete sessionData.pbxinfo['trunks']['providers'][trunk];
+ }
+
+ } catch(err) {
+ top.log.error(err);
+ return false;
+ }
+
+ return true;
+};
+/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/**
More information about the asterisk-gui-commits
mailing list