pari: branch asterisknow r1770 - /branches/asterisknow/config/

SVN commits to the Asterisk-GUI project asterisk-gui-commits at lists.digium.com
Fri Nov 2 19:51:59 CDT 2007


Author: pari
Date: Fri Nov  2 19:51:58 2007
New Revision: 1770

URL: http://svn.digium.com/view/asterisk-gui?view=rev&rev=1770
Log:
Create/Edit/Delete trunks for misdn - in users.conf

Modified:
    branches/asterisknow/config/cfgbasic.html
    branches/asterisknow/config/misdn.html

Modified: branches/asterisknow/config/cfgbasic.html
URL: http://svn.digium.com/view/asterisk-gui/branches/asterisknow/config/cfgbasic.html?view=diff&rev=1770&r1=1769&r2=1770
==============================================================================
--- branches/asterisknow/config/cfgbasic.html (original)
+++ branches/asterisknow/config/cfgbasic.html Fri Nov  2 19:51:58 2007
@@ -177,7 +177,7 @@
 	newpanel( ["Call Queues", "queues.html", "Call queues allow calls to be sequenced to one or more agents."]);
 	newpanel( ["Service Providers", "trunks.html", "Service Providers are outbound lines used to allow the system to make calls to the real world.  Trunks can be VoIP lines or traditional telephony lines."]);
 	newpanel( ["Digital Config", "digital.html", "Digital Configuration and setup allow the user to detect all digital cards (t1/e1/j1) and configure them. The user can access each individual line property, and also set each line as a trunk."]);
-	//newpanel( ["mISDN Config", "misdn.html", "mISDN configuration from the asterisk GUI"]); // Uncomment when mISDN is completed.
+	newpanel( ["mISDN Config", "misdn.html", "mISDN configuration from the asterisk GUI"]); // Uncomment when mISDN is completed.
 	newpanel( ["Calling Rules", "numberplan.html", "The Calling Rules define dialing permissions and least cost routing rules."]);
 	newpanel( ["Incoming Calls", "incoming.html", "Define how your incoming calls should be handled & configure DID (Direct inward Dialing)"]);
 	newpanel( ["Voice Menus", "menus.html", "Menus allow for more efficient routing of calls from incoming callers. Also known as IVR (Interactive Voice Response) menus or Digital Receptionist"]);

Modified: branches/asterisknow/config/misdn.html
URL: http://svn.digium.com/view/asterisk-gui/branches/asterisknow/config/misdn.html?view=diff&rev=1770&r1=1769&r2=1770
==============================================================================
--- branches/asterisknow/config/misdn.html (original)
+++ branches/asterisknow/config/misdn.html Fri Nov  2 19:51:58 2007
@@ -76,6 +76,8 @@
 	'nt_ptp':'NT-Mode, PTP',
 	'nt_ptmp':'NT-Mode, PMTP'
 };
+var mISDNTRUNKS = {};
+var isnewTrunk ;
 
 function resetmainscreen(){ top._$('mainscreen').width= 540; }
 
@@ -176,14 +178,20 @@
 			// done parsing misdn-init.conf
 			// show table
 			parent.astmanEngine.run_tool("touch /etc/asterisk/applymisdn.conf", function(t){}) // just to make sure it is there later when we write to it
-			misdnConfig.showMisdnConfiginTable();
+			try{
+				misdnConfig.showMisdnConfiginTable();
+			}catch(err){
+
+			}finally{
+				load_mISDNtrunks();
+			}
 		};
 
 		var somefunction = function(){
 			var c = 0;
 			var uri = build_action('delcat', c, 'general', "", ""); c++;
 			uri += build_action('newcat', c, 'general', "", ""); c++;
-			uri += build_action('update', c, 'general', '#include "../misdn-init.conf" ; = ', ''); c++;
+			uri += build_action('update', c, 'general', '#include "../misdn-init.conf" ;', ''); c++;
 			makerequest('u', "misdninit_guiRead.conf", uri, function(t) { config2json("misdninit_guiRead.conf", 0, parseMisdnInit); });
 		}();
 	},
@@ -297,6 +305,184 @@
 	});
 }
 
+
+var showMisdnTrunksinTable = function(){
+	var tbl = _$('misdntrunkstable') ;
+	var add_fRow = function(){
+		var newRow = tbl.insertRow(-1);
+		newRow.className = "frow";
+
+		var newCell0 = newRow.insertCell(0);
+		newCell0.innerHTML = "Trunk Name";
+
+		var newCell1 = newRow.insertCell(1);
+		newCell1.innerHTML = "Ports";
+
+		var newCell2 = newRow.insertCell(2);
+		newCell2.innerHTML =  "";
+	};
+
+	var addrow_totable = function(trunk){
+		var sno = tbl.rows.length + 1;
+		var newRow = tbl.insertRow(-1);
+		//newRow.id = 'misdntable_r'+port_no;
+		//newRow["port_no"] = port_no;
+		//if( PORTS[port_no]['edited'] ){ newRow.style.background = "#C9AAAA"; }
+
+		var newCell0 = newRow.insertCell(0);
+		newCell0.innerHTML = mISDNTRUNKS[trunk]['trunkname'] ;
+		newCell0.align = "center";
+
+		var newCell1 = newRow.insertCell(1);
+		newCell1.innerHTML = mISDNTRUNKS[trunk]['ports']  ;
+		newCell1.align = "center";
+
+		var newCell2 = newRow.insertCell(2);
+		newCell2.innerHTML = '<input type=button value="Edit" onclick="edit_trunk("' + trunk  + '")">' + "&nbsp;&nbsp;" +
+					"<input type=button value='Delete' onclick=\"delete_trunk('" + trunk  + "')\">" ;
+		newCell2.align = "center";
+	};
+
+	ASTGUI.domActions.clear_table(tbl);
+	add_fRow();
+	for( var k in mISDNTRUNKS ){ if( mISDNTRUNKS.hasOwnProperty(k) ){ addrow_totable(k); }}
+
+}
+
+function load_mISDNtrunks(){
+	var parseUsersConf = function(n){
+		if( n == "ERROR: CONFIG FILE NOT FOUND"){// users.conf not found
+			return false;
+		}
+
+		for( var l in n ){ 
+			if( n.hasOwnProperty(l) && l.beginsWith('trunk_m') && n[l]['hasmisdn'] =='yes' ){
+				if(!mISDNTRUNKS[l]) { mISDNTRUNKS[l] = {};}
+				mISDNTRUNKS[l]['trunkname'] = n[l]['trunkname'];
+				mISDNTRUNKS[l]['context'] = n[l]['context'];
+				mISDNTRUNKS[l]['ports'] = n[l]['ports'];
+			}
+		};
+
+		showMisdnTrunksinTable();
+	};
+	config2json("users.conf", 1, parseUsersConf);
+}
+
+
+var new_misdntrunk = function(){
+	isnewTrunk = true;
+	_$('edit_MTrunk_ports').value = '';
+	_$('edit_MTrunk_trunkName').value = '';
+	_$('edit_trunk').style.display = "";
+};
+
+var canelTrunkInfo = function(){
+	_$('edit_trunk').style.display = "none";
+}
+
+var edit_trunk = function(k){
+	isnewTrunk = false;
+	_$('edit_trunk').style.display = "";
+	_$('edit_trunk')['trunk_being_Edited'] = k;
+};
+
+
+var delete_trunk = function(k){
+	//delete in users.conf
+	// delete in globals in extensions.conf
+	// delete the DID context in extensions.conf
+	var c = 0;
+	var uri = build_action('delcat', c, k, "", ""); c++;
+	makerequest('u', "users.conf", uri, function(t) { 
+		var c1 = 0;
+		var uri1 = build_action('delcat', c1, "DID_" + k , "", ""); c1++;
+		uri1 += build_action('delete', c1, "globals", k, '', "mISDN/g:" + k ); c1++;
+		makerequest('u', "extensions.conf", uri1, function(t) { 
+			delete mISDNTRUNKS[k];
+			showMisdnTrunksinTable();
+		});
+	});
+};
+
+var updateTrunkInfo = function(){
+
+	if(isnewTrunk){
+		// create new trunk
+		// get the available trunk number
+		var getnextavailabletrunk_number = function(){
+			var ts = [];
+			for(var t in mISDNTRUNKS){ if( mISDNTRUNKS.hasOwnProperty(t) ){
+					var i = t.split('trunk_m');
+					ts.push( Number(t.split('trunk_m')[1] ) );
+			}}
+
+			if(!ts.length){ return "1"; }
+
+			var c = 1 ;
+			var sortNumbers =function(a,b){return a - b};
+			ts.sort(sortNumbers);
+			for(var u =0 ; u < ts.length ; u++ ){
+				if( c < ts[u] ){ return c;}
+				c++ ;
+			}
+			return c;
+		};
+		var y = getnextavailabletrunk_number();
+		var newtrunkname =  "trunk_m" + y;
+		
+	/////////////////uri += build_action('append' , c , d , "poll" , "128") ; c++ ;
+	/////////////////	uri += build_action('newcat', c, d , "", ""); c++;
+	////////////////uri += build_action('update', c, 'general', '#include "../misdn-init.conf" ; = ', ''); c++;	
+		var c = 0, uri ='';
+		uri += build_action('newcat', c, newtrunkname , "", ""); c++;
+		uri += build_action('append' , c , newtrunkname , "trunkname", _$('edit_MTrunk_trunkName').value  ) ; c++ ;
+		uri += build_action('append' , c , newtrunkname , "context", "DID_" + newtrunkname) ; c++ ;
+		uri += build_action('append' , c , newtrunkname , "ports", _$('edit_MTrunk_ports').value ) ; c++ ;
+		uri += build_action('append' , c , newtrunkname , "hasmisdn", 'yes') ; c++ ;
+		uri += build_action('append' , c , newtrunkname , "msns", '*') ; c++ ;
+		makerequest('u', "users.conf", uri, function(t) {
+			var c1 = 0, uri2 ='';
+			uri2 += build_action('newcat', c1, "DID_"+newtrunkname, "", ""); c1++;
+			uri2 += build_action('append' , c1, "DID_"+newtrunkname, 'include', 'default') ; c1++ ;
+			uri2 += build_action('update', c1, 'globals', newtrunkname, 'mISDN/g:' + newtrunkname ); c++;	
+			makerequest('u', "extensions.conf", uri2, function(t) {
+				try{
+				if(mISDNTRUNKS[newtrunkname]) { delete mISDNTRUNKS[newtrunkname];}
+				mISDNTRUNKS[newtrunkname] = {};
+				mISDNTRUNKS[newtrunkname]['trunkname'] = _$('edit_MTrunk_trunkName').value ;
+				mISDNTRUNKS[newtrunkname]['context'] = "DID_" + newtrunkname;
+				mISDNTRUNKS[newtrunkname]['ports'] = _$('edit_MTrunk_ports').value;
+				showMisdnTrunksinTable();
+				}catch(err){
+
+				}finally{
+					_$('edit_trunk').style.display = "none";
+				}
+			});
+		});
+	}else{
+		// update existing trunk
+		var k = _$('edit_trunk')['trunk_being_Edited'];
+		var c = 0;
+		var uri = build_action('update', c, k, 'ports', _$('edit_MTrunk_ports').value ); c++;
+		uri += build_action('update', c, k, 'trunkname', _$('edit_MTrunk_trunkName').value ); c++;
+		makerequest('u', "users.conf", uri, function(t) {
+			try{
+				mISDNTRUNKS[k]['trunkname'] = _$('edit_MTrunk_trunkName').value ;
+				mISDNTRUNKS[k]['ports'] = _$('edit_MTrunk_ports').value ;
+				showMisdnTrunksinTable();
+			}catch(err){
+
+			}finally{
+				_$('edit_trunk').style.display = "none";
+			}
+		});
+	}
+
+}
+
+
 </script>
 <body onload="localajaxinit()" onunload="resetmainscreen()"  bgcolor="#EFEFEF">
 <div style="font-size : 12px; padding : 4px 6px 4px 6px; border-style : solid none solid none; border-top-color : #BDC7E7; border-bottom-color : #182052; border-width : 1px 0px 1px 0px; background-color : #ef8700; color : #ffffff;">
@@ -311,6 +497,39 @@
 		<input type="button" id="save_a" value="Update" onclick="generate_applyMisdn();">&nbsp;&nbsp;
 		<input type="button" id="cancel_a" value="Cancel" onclick="reloadpage();">
 	</center>
+</div>
+
+<div style="overflow:auto;left:40" id="div_misdnTrunkstable">
+	<h2 align="center"><div> List of mISDN Service providers (trunks)</div></h2>
+	<table class="taglist" id="misdntrunkstable" cellpadding=5 cellspacing=1 border=0 align=center></table>
+	<center>
+		<input type="button" value="Add" onclick="new_misdntrunk();">
+	</center>
+</div>
+
+<div id="edit_trunk" STYLE="display:none; position: absolute; left: 30; top: 40; width:500; height:180;  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 , 'edit_trunk');">
+	<TR bgcolor="#7E5538"  style="background-image:url('images/title_gradient.gif');">
+		<TD Height="20" align="right" style="cursor: move">
+			<A href="#" onclick="$('cancel_a').click();"><font style="color:#FFFFFF; font-size: 12px; font-weight:bold;">X</font></A>
+		</TD>
+		<TD width=4></TD>
+	</TR>
+	</TABLE>
+	<TABLE	align=center cellpadding=2 cellspacing=2 border=0>
+	<TR>	<TD align="right">TrunkName :</TD>
+		<TD> <input type=text size=15 id="edit_MTrunk_trunkName"></TD>
+	</TR>
+	<TR>	<TD align="right">Ports:</TD>
+		<TD> <input type=text size=15 id="edit_MTrunk_ports"> </TD>
+	</TR>
+
+	<TR>	<TD colspan=2 align=center height=50 valign=middle>  
+			<input type="button" id="save_a" value="Update" onclick="updateTrunkInfo();">&nbsp;&nbsp;
+			<input type="button" id="cancel_a" value="Cancel" onclick="canelTrunkInfo();">
+		</TD>
+	</TR>
+	</TABLE>
 </div>
 
 <div id="errmsg" style="display:none"></div>




More information about the asterisk-gui-commits mailing list