bkruse: trunk r1629 - in /trunk: ./ config/ config/scripts/

SVN commits to the Asterisk-GUI project asterisk-gui-commits at lists.digium.com
Fri Sep 21 15:48:12 CDT 2007


Author: bkruse
Date: Fri Sep 21 15:48:11 2007
New Revision: 1629

URL: http://svn.digium.com/view/asterisk-gui?view=rev&rev=1629
Log:
Merged revisions 1628 via svnmerge from 
https://origsvn.digium.com/svn/asterisk-gui/branches/1.4

........
r1628 | bkruse | 2007-09-21 15:46:27 -0500 (Fri, 21 Sep 2007) | 1 line

This commit kind of breaks it, but it updates to a lot of the code for pari to look at
........

Modified:
    trunk/   (props changed)
    trunk/config/digital.html
    trunk/config/scripts/tooltip.js

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/config/digital.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/digital.html?view=diff&rev=1629&r1=1628&r2=1629
==============================================================================
--- trunk/config/digital.html (original)
+++ trunk/config/digital.html Fri Sep 21 15:48:11 2007
@@ -124,6 +124,8 @@
 var sysinfocallbacks = new Object;
 var zt_cb = new Object;
 var SPANS = new Object;
+var callbacks = new Object;
+var allchans_var = new Array;
 var tabs = new Array('tab1', 'tab2', 'tab3');
 var divs_tohide = new Array('osversion_div', 'uptime_div', 'asterisk_div', 'today_div','hostname_div','ifconfig_div','df_div','memory_div');
 var has_spans = 0; /* Count of our spans we have, incrementing each time. */
@@ -131,16 +133,19 @@
 var old_zap = 0;
 var isrefresh = 0;
 var widgets = {};
-var fieldnames_clickable = [ 'fac', 'lbo', 'syncsrc' ]; 
+var zap_settings = [ 'switchtype', 'signalling', 'echocancel', 'echocancelwhenbridged', 'rxgain', 'txgain', 'group' ]; 
+var fieldnames_clickable = [ 'fac', 'lbo', 'syncsrc', 'totchans' ]; 
 var fieldnames = [ 'alarms', 'syncsrc', 'description', 'totchans', 'fac', 'lbo' ]; 
-var fieldnames_proper = [ 'Alarms:', 'Sync Source:', 'Card Description:', 'Total Channels:', 'Framing/Coding:', 'Line Build Out:' ]; 
+var fieldnames_proper = [ 'Alarms:', 'Sync Source:', 'Card Description:', 'Total Channels:', 'Framing/Coding:', 'Options:' ]; 
 var fieldnames_zap_opts = [ 'loadzone', 'defaultzone'];
 
 /* Our select boxes for framing/coding and line build out */
-var framing_and_coding = [ "esf,b8zs", "d4,ami", "cas,ami", "ccs,hdb3", "ccs,crc4,hdb3", "fxoks", "fxols", "fxsks", "fxsls"];
-var framing_and_coding_nice = [ "ESF/B8ZS", "D4/AMI", "CAS/AMI", "CCS/HDB3", "CCS/CRC4/HDB3", "FXOKS", "FXOLS", "FXSKS", "FXSLS"];
-
+var framing_and_coding = [ "esf,b8zs", "d4,ami", "cas,ami", "ccs,hdb3", "ccs,crc4,hdb3"];
+var framing_and_coding_nice = [ "ESF/B8ZS", "D4/AMI", "CAS/AMI", "CCS/HDB3", "CCS/CRC4/HDB3"];
 /* _______________________________________________________ */
+
+var pri_and_cb = ["pri", "fxoks", "fxsks", "fxols", "fxols"]
+var pri_and_cb_nice = ["PRI", "FXOKS", "FXSKS", "FXOLS", "FXOLS"];
 
 var line_build_out = [ 0, 1, 2, 3, 4, 5, 6, 7];
 var line_build_out_nice = [ "0 db (CSU)/0-133 feet (DSX-1)", "133-266 feet (DSX-1)", "266-399 feet (DSX-1)", "399-533 feet (DSX-1)", "533-655 feet (DSX-1)", "-7.5db (CSU)", "-15db (CSU)", "-22.5db (CSU)" ];
@@ -184,6 +189,117 @@
 	return true;
 };
 
+callbacks.format = function(t) {
+	if ((t.name == 'general')){
+		if (t.fieldbyname['allow_aliasextns'] && t.fieldbyname['allow_aliasextns'].length){
+			allow_aliasextns =  t.fieldbyname['allow_aliasextns'] ;
+		}else{
+			allow_aliasextns = 'no' ;
+		}
+		return null;
+	}
+	if ( t.fieldbyname['context'] == asterisk_guiTDPrefix + t.name )
+		return null;
+	if (t.fieldbyname['fullname'] && t.fieldbyname['fullname'].length) {
+		return t.name + " -- " + t.fieldbyname['fullname'];
+	} else
+		return t.name;
+}
+
+callbacks.savechanges = function(){
+	saveuserdetails();
+}
+
+callbacks.cancelnewcategory = function(){
+	hideuserdetails();
+}
+
+callbacks.cancelchanges = function(){
+	hideuserdetails();
+}
+
+
+callbacks.loaded = function() {
+	_$('devices').contentEditable = 'true';
+	_$('devices').disabled = 0;
+	//_$('new').addEventListener("click", showuserdetails, false);
+	ASTGUI.events.add( _$('new') , "click", showuserdetails );
+	//parent.astmanEngine.pollEvents();
+	loadusersintotable();
+}
+
+callbacks.sortfunc = function(a,b) {
+	return (a.name < b.name) ? -1 : 1;
+}
+
+callbacks.checkparams = function(box) {
+	_$('mailbox').value = _$('name').value;
+	_$('group').value = '';
+	return false;
+}
+
+callbacks.newcategory = function() {
+	var nar = [];
+	var _devices = _$('devices') ;
+	var _exten = _$('extensions') ;
+ 
+	for( var f=0; f < _devices.options.length ; f++ ){ nar.push( _devices.options[f].innerHTML.split(' -- ')[0]) ; }
+	for( f=0; f < _exten.options.length ; f++ ){ nar.push( _exten.options[f].innerHTML.split(' -- ')[0]) ; }
+	nar.sort();
+
+	var tmp = null;
+	var x = 6000;
+	if (_$('devices').stored_config.catbyname['general'])
+		tmp = objcopy(_$('devices').stored_config.catbyname['general']);
+	if (tmp) { x = parseInt( tmp.fieldbyname['userbase'],10); }
+	for( f=0; f < nar.length ; f++ ){
+		if( x < parseInt(nar[f]) ){ break; } x++;
+	}
+
+	tmp.name = x;
+	return tmp;
+}
+callbacks.identifier = "extension";
+callbacks.beforeSaving = function(){
+	if(!_$('fullname').value.length){
+		alert("Sorry, a User Name must be specified !");
+		_$('fullname').focus();
+		return false;
+	}
+	// check whether the extension entered matches with any of the - voicemail, queue, voicemenu, conference extensions
+	for(var k=0; k< _$('extensions').length; k++ ){
+		var tmp = _$('extensions').options[k].innerHTML.split(' -- '); 
+		if( tmp[0] ==  $('name').value   ){
+			alert("Sorry, an entry named " + _$('name').value + " already exists!");
+			return false;
+		}
+	}
+
+	if(allow_aliasextns == "no"){	// check whether the selected analog line is assigned to another user extension
+		var tmp_usedanaloglines = [] ;
+		for ( var i=1; i < _$('devices').stored_config.categories.length ; i++){
+			if ( _$('devices').stored_config.categories[i] != null ){
+			if ( _$('devices').stored_config.categories[i].fieldbyname['zapchan'] && _$('devices').stored_config.categories[i].fieldbyname.zapchan.length && _$('devices').stored_config.categories[i].name != _$('devices').value )
+				tmp_usedanaloglines.push(_$('devices').stored_config.categories[i].fieldbyname.zapchan);
+			}
+		}
+		if ( InArray(tmp_usedanaloglines,_$('zapchan').value)){
+			alert("This Analog Phone has already been assigned to another user extension.\n Please select a different Phone");
+			return false;
+		}
+	}
+
+	return true;
+}
+
+callbacks.postselect = function(box, val) {
+	if (adstatus == "hidden") {
+		adstatus = "shown";
+		 togglefeatures() ;
+	}
+	if( box.selectedIndex == -1)
+		return true;
+}
 function update_table() {
 	
 	var e = _$("cdr_content_container");
@@ -276,10 +392,6 @@
 		return x==y && x.toString()==y.toString();
 }
 
-function build_span_config(span) {
-	return "yay";
-} 
-
 function run_zt_and_restart() {
 	/* this function will run ztcfg and reload the page. */
 	parent.needs_reloadzap = 1;
@@ -290,41 +402,99 @@
 function get_params_and_ztcfg() {
 	/* this function will get all the values out of all the fields, build a zaptel.conf file, then write it and run ztcfg */
 	parent.needs_reloadzap = 1;
-	var dchans = 0;
-	var bchans = 1;
 	var ZAPTEL = new Object;
-	for(var i=1; i < (total_spans + 1); i++ ){
-		var arr = (i - 1);
+	var CONFIG = new String;
+	var highest = 1;
+	/* our variable for building our zaptel config. */
+	for(var i=1; i <= total_spans; i++ ){
 		ZAPTEL[i] = new Object;
 		ZAPTEL[i].en = new Array;
 		for(var x=0; x < fieldnames_clickable.length; x++) {
 			var tmp_id = i+'-'+fieldnames_clickable[x]+'-sel';
 			var tmp_b = _$(tmp_id);
 			ZAPTEL[i].en[fieldnames_clickable[x]] = tmp_b.options[tmp_b.selectedIndex].value;
-		}
-		/*	switch(val) {
+		//	alert("showing val for span " + i + " for val: " + fieldnames_clickable[x] + " is : " + ZAPTEL[i].en[fieldnames_clickable[x]]);
+		}
+		ZAPTEL[i].en['config'] = "span="+i+","+ZAPTEL[i].en['syncsrc']+","+ZAPTEL[i].en['lbo']+","+ZAPTEL[i].en['fac'];
+	}
+	for(var i=1; i <= total_spans; i++ ){
+		switch(ZAPTEL[i].en['fac']) {
 				case "fxoks":
 				case "fxols":
 				case "fxsks":
 				case "fxsls":
+					//ZAPTEL[i].en['config'] += "\n
+					/* we are currently not dealing with fxo/fxs, just pri */
 					break;
 				case "esf,b8zs":
 				case "d4,ami":
-					alert("esf/b8zs or something");
+					ZAPTEL[i].en['type'] = "t1";
+					ZAPTEL[i].en['bchan'] = "bchan="+highest+"-"+(highest + 22);
+					highest = (highest + 22);
+					ZAPTEL[i].en['dchan'] = "dchan="+(highest+1);
+					highest += 2;
 					break;
 				case "cas,ami":
 				case "ccs,hdb3":
 				case "css,crc4,hdb3":
+					ZAPTEL[i].en['type'] = "e1";
+					var tmp_b = highest+'-'+(highest + 14);
+					highest += 14;
+					var tmp_d = (highest + 1);
+					highest += 3;
+					tmp_b += ","+(highest - 1)+'-'+(highest + 13);
+					highest += 14;
+					ZAPTEL[i].en['bchan'] = "bchan="+tmp_b;
+					ZAPTEL[i].en['dchan'] = "dchan="+tmp_d;
 					break;
 			}
-		*/
-
-	}
-	alert(ZAPTEL);
-
-	gui_alert("This is a place holder, if you see this its probably because you need to run ztcfg, and running it is not in this page yet.");
-}
-
+	}
+
+	ZAPTEL['general'] = new Object;
+	ZAPTEL['general'].en = new Array;
+	ZAPTEL['general'].en['loadzone'] += "\nloadzone=us";
+	ZAPTEL['general'].en['defaultzone'] += "\ndefaultzone=us";
+	/* XXX Need to make this dynamic */
+	build_and_ztcfg(ZAPTEL);
+}
+
+function StringBuffer() { 
+	this.buffer = []; 
+} 
+
+StringBuffer.prototype.append = function append(string) { 
+	this.buffer.push(string); 
+	return this; 
+}; 
+
+StringBuffer.prototype.toString = function toString() { 
+	return this.buffer.join(""); 
+}; 
+
+var buf = new StringBuffer();
+
+function build_and_ztcfg(ZAPTEL) {
+
+	var zaptel_string = new StringBuffer;
+	/* this could get crazy building this config.... */
+	zaptel_string.append(ZAPTEL['general'].en['loadzone'] + "\n\n|||" + ZAPTEL['general'].en['defaultzone']);
+
+	parent.astmanEngine.run_tool(asterisk_guiEditZap + " " + '\'' + zaptel_string.toString() + '\'', callback = function() { return true; }); 
+	
+}
+
+function read_errors() {
+	var opt = { method: 'get', asynchronous: true,
+		onComplete: function(originalRequest){
+			alert("ztcfg output: " + originalRequest);
+		},
+		onFailure: function(t) { alert("Config Error: " + t.status + ": " + t.statusText); }
+	};
+	var tmp = new Ajax.Request(asterisk_guiZtcfg_output, opt);
+	opt.parameters="";
+	return true;
+
+}
 function option_clicked(a) {
 	/* place holder for the option clicked callback for the event. */
 	alert(a);
@@ -425,8 +595,8 @@
 					}
 				}
 				if(fieldnames[i] == 'totchans') {
-					var type = parseInt(n[l][fieldnames[i]]);
-					if(type > 1 && type < 30) {
+					allchans_var[i] = parseInt(n[l][fieldnames[i]]);
+					if(allchans_var[i] > 1 && allchans_var[i] < 30) {
 						n[l][fieldnames[i]] = "24 / T1";
 					} else {
 						n[l][fieldnames[i]] = "31 / E1";
@@ -452,6 +622,40 @@
 	append_selectboxes();
 
 	return true;
+}
+
+function addoptions_totable(){
+	for(var i=0; i < total_spans; i++) {
+		var span = (i + 1);
+		var thediv = _$(span + '-lbo');
+		thediv.className = "downmenubutton";
+		thediv.innerHTML = "<span id='" + "span_" + span  + "' onclick=\"editspan( '"+ span + "');\">Options&nbsp;&nbsp;<img src=images/1.gif></span>";
+		thediv.style.width = 120;
+		thediv.align = "center";
+		thediv["sp_value"] = span;
+	}
+}
+
+function hide_mymenu( ) {
+	document.getElementById('mymenu').style.display="none"; 
+}
+
+function editspan(a) {
+	_$('spansettings').style.display = "";
+	_$('bg_transparent').style.display = "";
+} 
+
+function save_this(a) {
+	alert("saving changes?");
+}
+
+function savespandetails() {
+	hideuserdetails();
+	save_this();
+}
+function hidespandetails() {
+	_$('spansettings').style.display = "none";
+	_$('bg_transparent').style.display = "none";
 }
 
 function append_selectboxes() {
@@ -502,8 +706,25 @@
 				}
 
 			}
+			if(fieldnames_clickable[x] == "totchans") {
+				var tmp_sel = "";
+				for(var y=0; y < pri_and_cb.length; y++) {
+					tmp_sel += '<option value='+pri_and_cb[y]+'>'
+					tmp_sel += pri_and_cb_nice[y];
+					tmp_sel += '</option>'
+				}
+				tmp_sel += '</select>';
+				var tmp_id = i+'-'+fieldnames_clickable[x];
+				var ofid = _$(tmp_id);
+				if(ofid) {
+					ofid.innerHTML = '<select style="font-family: Verdana, Arial, Helvetica, Sans-Serif;" id="'+i+'-'+fieldnames_clickable[x]+'-sel">'+tmp_sel;
+				}
+
+			}
+
 		}
 	}	
+	addoptions_totable();
 	select_correct_index();
 	return true;
 }
@@ -515,9 +736,9 @@
 			if(sec == 'fac') {
 				var l = val.toLowerCase();
 				l = l.replace('/', ',');
-				if(el.options[t].value == l) { el.selectedIndex = t; return; }
+				if(el.options[t].value == l) { el.selectedIndex = t; break; }
 			} else {
-				if(el.options[t].value == val) { el.selectedIndex = t; return; }
+				if(el.options[t].value == val) { el.selectedIndex = t; break; }
 			}
 		}
 	}
@@ -525,10 +746,11 @@
 	for(var i=1; i < (total_spans + 1); i++ ){
 		for(var x=0; x < fieldnames_clickable.length; x++) {
 			var tmp_id = i+'-'+fieldnames_clickable[x]+'-sel';
-			find_index(_$(tmp_id), SPANS[i].en[fieldnames_clickable[x]], fieldnames_clickable[x]);
-			}
-		}
-	return true;
+			if(tmp_id) {
+				find_index(_$(tmp_id), SPANS[i].en[fieldnames_clickable[x]], fieldnames_clickable[x]);
+			}
+		}
+	}
 }
 function save_changes() {
 	/* function to grab the values of fields, and call the bash script to apply the changes and run ztcfg */
@@ -617,8 +839,8 @@
 <center>
 <font size="+1">Digital Card Setup</font><br>
 <span style="cursor: pointer; cursor: hand;" onclick="refresh_alarms();" >&nbsp;Click to refresh alarms.&nbsp;<img src="images/refresh.png" title=" Refresh " border=0 ></span>
-<div style="width:525;height:250;overflow:auto;">
-        <table class="taglist" id="digitalcardstable" cellpadding=2 cellspacing=1 border=0 align=center width=525></table>
+<div style="width:535;height:250;overflow:auto;">
+        <table class="taglist" id="digitalcardstable" cellpadding=2 cellspacing=1 border=0 align=center width=535></table>
 </div>
 <div id="save_changes_id">
 <span type='button' onclick="save_changes();" class="downmenubutton" value='Save Changes'>Save Changes</span>
@@ -635,7 +857,18 @@
 </div>
 </center>
 <div id="mymenu" class="mymenu" style="display:none"></div>
-<div style="display:none;visibility:hidden">
+<td valign=top align=center>
+<div ID="spansettings"  STYLE="display:none; position: absolute; left: 240; top: 40; width:530; height:250;  background-color:#F4EFE5;   border-width: 1px; border-color: #7E5538; border-style: solid; z-index:5">
+	<table width="100%" cellpadding=0 cellspacing=0  onmousedown="ASTGUI.startDrag(event , 'spansettings');">
+			<TR bgcolor="#7E5538" >
+				<TD Height="20" align="right" style="cursor: move">
+					<A href="#" onclick="$('cancel').click();"><font style="color:#FFFFFF; font-size: 12px; font-weight:bold;">X</font></A>
+				</TD>
+				<TD width=4></TD>
+			</TR>
+		</table>
+
+	<TABLE cellpadding=0 cellspacing=2 border=0 class="spandetails">
 	<tr>	<td class="field_text">Alarms:</td>
 		<td><input id="alarms" size=14  class="input8"></td>
 	</tr>
@@ -660,7 +893,16 @@
 	<tr>	<td class="field_text">Sync Source:</td>
 		<td><input type="text" id="syncsrc" size=14 class="input8"></td>
 	</tr>
-
-
+	<tr>	<td colspan=4 align=center>
+		<input type='button' id='save' value='Save'  onclick="save_this(this);" class="buttonbold">&nbsp;&nbsp;
+		<input type='button' id='cancel' value='Cancel' onclick="hidespandetails();" class="buttonbold">
+	</td>
+	</tr>
+	</table>
+	</div>
+</td>
 </div>
 </body>
+<div id="bg_transparent" STYLE="display:none; position: absolute; left: 0; top: 0; width:100%; height:100%;  background-color:#FFFFFF; filter:alpha(opacity=50); -moz-opacity:.50;opacity:.50; border-width: 0px; z-index:4">
+</div>
+</html>

Modified: trunk/config/scripts/tooltip.js
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/scripts/tooltip.js?view=diff&rev=1629&r1=1628&r2=1629
==============================================================================
--- trunk/config/scripts/tooltip.js (original)
+++ trunk/config/scripts/tooltip.js Fri Sep 21 15:48:11 2007
@@ -346,3 +346,4 @@
 	tooltips['digital'].en['Framing/Coding:'] = "<B>Framing/Coding:</B> Drop down box for enabling the changing of Framing/Coding. The first option is your current Framing/Coding";
 	tooltips['digital'].en['Line Build Out:'] = "<B>Line Build Out:</B> The current LBO (Line Build Out) of the span.";
 	tooltips['digital'].en['Sync Source:'] = "<B>Sync Source:</B> Your Zaptel Sync Source. Can be one of any spans, or 0 for non master";
+	tooltips['digital'].en['Options:'] = "<B>Options:</B> Span Related Options, including Signalling, Switchtype, Channels, etc";




More information about the asterisk-gui-commits mailing list