rbrindley: branch rbrindley/astman_revamp r4549 - /team/rbrindley/astman_reva...

SVN commits to the Asterisk-GUI project asterisk-gui-commits at lists.digium.com
Mon Mar 2 19:31:58 CST 2009


Author: rbrindley
Date: Mon Mar  2 19:31:55 2009
New Revision: 4549

URL: http://svn.digium.com/svn-view/asterisk-gui?view=rev&rev=4549
Log:

- implemented astman.cliCommand, replacing ASTGUI.cliCommand
- implemented astman.parseCLI, replacing ASTGUI.parseCLIResponse


Modified:
    team/rbrindley/astman_revamp/config/js/astman2.js

Modified: team/rbrindley/astman_revamp/config/js/astman2.js
URL: http://svn.digium.com/svn-view/asterisk-gui/team/rbrindley/astman_revamp/config/js/astman2.js?view=diff&rev=4549&r1=4548&r2=4549
==============================================================================
--- team/rbrindley/astman_revamp/config/js/astman2.js (original)
+++ team/rbrindley/astman_revamp/config/js/astman2.js Mon Mar  2 19:31:55 2009
@@ -161,3 +161,37 @@
 		return true;
 	}
 };
+
+/**
+ * Executes a CLI Command.
+ * This function takes a string CLI command and sends it to Asterisk to be executed. This function was formerly named ASTGUI.cliCommand
+ * @param {String} cmd The CLI Command to be executed.
+ * @return the CLI output
+ */
+astman.cliCommand = function(cmd) {
+	if (typeof cmd !== 'string') {
+		log.warn('cliComannd: Expecting cmd as String');
+		return '';
+	}
+
+	log.debug('Executing manager command: "' + cmd + '"');
+	return this.makeSyncRequest( {action: 'command', command: cmd });
+};
+
+/**
+ * Parses CLI Responses.
+ * The function takes a raw CLI response and strips unnecessary info, returning only the useful info. This function use to be called ASTGUI.parseCLIResponse.
+ * @param resp The CLI Response to be parsed.
+ * @return {String} the parsed CLI responsed
+ */
+astman.parseCLIResponse = function(resp) {
+	if (typeof resp !== 'string') {
+		return resp;
+	}
+
+	resp = resp.replace(/Response: Follows/, '');
+	resp = resp.replace(/Privilege: Command/, '');
+	resp = resp.replace(/--END COMMAND--/, '');
+
+	return resp;
+};




More information about the asterisk-gui-commits mailing list