pari: trunk r904 - in /trunk/config: cfgbasic.html timerules.html

asterisk-gui-commits at lists.digium.com asterisk-gui-commits at lists.digium.com
Wed May 9 17:25:04 MST 2007


Author: pari
Date: Wed May  9 19:25:04 2007
New Revision: 904

URL: http://svn.digium.com/view/asterisk-gui?view=rev&rev=904
Log:
** NOT COMPLETE *** Initial attempt at Time Based Routing ** NOT COMPLETE ** 

Added:
    trunk/config/timerules.html
Modified:
    trunk/config/cfgbasic.html

Modified: trunk/config/cfgbasic.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/cfgbasic.html?view=diff&rev=904&r1=903&r2=904
==============================================================================
--- trunk/config/cfgbasic.html (original)
+++ trunk/config/cfgbasic.html Wed May  9 19:25:04 2007
@@ -125,6 +125,7 @@
 // show additional panels for advanced mode
 if(window.location.href.match("advanced=yes") ){
 panels.splice(10,0,
+//	new PanelDef("timerules", "Time Based Rules", "accordion-icon.gif", " Define Call handling Rules based on Time, Day, Date and/or Month"),
 
 	new PanelDef("feditor", "File Editor", "accordion-icon.gif", " Manually edit Config Files"),
 

Added: trunk/config/timerules.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/timerules.html?view=auto&rev=904
==============================================================================
--- trunk/config/timerules.html (added)
+++ trunk/config/timerules.html Wed May  9 19:25:04 2007
@@ -1,0 +1,434 @@
+<!--
+ * Asterisk-GUI	-	an Asterisk configuration interface
+ *
+ * Time Based Rules - *********** NOT COMPLETE *************** 
+ *
+ * Copyright (C) 2006-2007, Digium, Inc.
+ *
+ * Pari Nannapaneni <pari at digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ *
+ * ******** PENDING ****** PENDING ***
+-->
+<script src="scripts/prototype.js"></script>
+<script src="scripts/astman.js"></script>
+<link href="stylesheets/rico.css" media="all" rel="Stylesheet" type="text/css" />
+<link href="stylesheets/schwing.css" media="all" rel="Stylesheet" type="text/css" />
+<script>
+var timebasedrules = {};
+var voicemenus = [];
+var user_extens = [];
+var isNewRule;
+
+function showlist_of_rules(){
+	var t;
+	for( t in timebasedrules ){
+		if(timebasedrules.hasOwnProperty(t)){ addrow_totable( timebasedrules[t],t ); }
+	}
+}
+
+function addrow_totable(k,l){
+	// sno, rulename, desc, options
+	var newRow = _$('tbrulesTable').insertRow(-1);
+	newRow.style.backgroundColor='#FFFFFF';
+	newRow.onmouseover= function(){ this.style.backgroundColor='#F9F0D1'; };
+	newRow.onmouseout=function(){ this.style.backgroundColor='#FFFFFF'; };
+	
+	var newCell0 = newRow.insertCell(0);
+	newCell0 .innerHTML =_$('tbrulesTable').rows.length  ;
+	newCell0 .width = 35;
+	newCell0.align = "center";
+	
+	var newCell1 = newRow.insertCell(1);
+	newCell1 .innerHTML = k.rulename ;
+	newCell1.align = "left";
+	
+	var newCell2 = newRow.insertCell(2);
+	newCell2 .innerHTML = "<input type=\"button\" onclick='edit_form(\""+ l+ "\")'  value=\"Edit\" class=\"splbutton\">&nbsp;"  +
+	"<input type=\"button\" onclick='delete_rule(\""+ l+ "\")'  value=\"Delete\"  class=\"splbutton\">" ;
+	newCell2.align = "center";
+	newCell2.width = 115;
+}
+
+
+function localajaxinit(){
+	setWindowTitle("File Editor");
+	parent.loadscreen(this);
+	config2json('users.conf', 1, get_users) ;
+}
+
+
+function get_users(m){
+	var n = eval('(' + m + ')');
+	var l;
+
+	for( l in n ){
+		if(n.hasOwnProperty(l)){
+			if( l =='general'){ continue;}
+			if ( n[l]['context'] && unescape(n[l]['context']) == asterisk_guiTDPrefix + l ) {
+				continue;
+			}
+
+			if( n[l]['context'] ){
+				var p = {};
+				p.username = (n[l]['fullname'])? unescape(n[l]['fullname'])+" ("+l+")" : "Local Extension ("+l+")";
+				p.usercontextstring = "default,"+l+",1" ;
+				user_extens.push(p);
+			}
+		}
+	}
+	config2json('extensions.conf', 0, get_timerules) ;
+}
+
+
+function get_timerules(b){
+	var c,d,e,t,p,q;
+	c = eval('(' + b + ')');
+
+	for( d in c ){
+		if(c.hasOwnProperty(d)){
+			if( d == 'timebasedrules'){ e = c[d];}
+			if( d.substr(0,17) == 'voicemenu-custom-'){
+				p = {};
+				q = get_menuname(c[d]);
+				p.menuname = (q)?q:d;
+				p.menucontextstring = d+",s,1";
+				voicemenus.push(p);
+			}
+		}
+	}
+
+	for( t=0; t < e.length; t++) {
+		if( unescape(e[t]).match("NoOp") ){ parsetimeconditions(e,t); }
+	}
+
+	showlist_of_rules();
+	set_selectboxes();
+}
+
+
+function get_menuname(c){
+	var r,s;
+	for( r =0; r < c.length; r++){
+		s = unescape(c[r]);
+		if( s.match('comment=') ){return "VoiceMenu " + s.split('comment=')[1];}
+	}
+	return null;
+}
+
+
+function parsetimeconditions(a,b){ // a is the [timebasedrules] array, b is the index
+/*	timebasedrules[1] = {};
+	timebasedrules[1].rulename =  ; //'NoOp(Christmas)'
+	timebasedrules[1].ruleconditons = {} ;
+	timebasedrules[1].ruleconditons.fromhour = '' ;
+	timebasedrules[1].ruleconditons.fromminutes = '' ;
+	timebasedrules[1].ruleconditons.tohour = '' ;
+	timebasedrules[1].ruleconditons.tominutes = '' ;
+	timebasedrules[1].ruleconditons.from_wday = '' ;
+	timebasedrules[1].ruleconditons.to_wday = '' ;
+	timebasedrules[1].ruleconditons.from_mday = '' ;
+	timebasedrules[1].ruleconditons.to_mday = '' ;
+	timebasedrules[1].ruleconditons.from_month = '' ;
+	timebasedrules[1].ruleconditons.to_month = '' ;
+	timebasedrules[1].ifmatch_goto =  ;
+	timebasedrules[1].ifnomatch_goto =  ;
+	console.log( unescape( a[b] ) ); // exten=3,1,NoOp(SomeTimeRule)
+	console.log( unescape( a[b+1] ) ); // exten=3,n,GotoIfTime(04:00-11:59|mon-sun|1-31|jan-dec?voicemenu-custom-1,s,1)
+	console.log( unescape( a[b+2] ) ); // exten=3,n,Goto(default,6001,1)
+*/
+	var m,n,o;
+	m = unescape(a[b]);
+	n = unescape(a[b+1]);
+	o = unescape(a[b+2]);
+
+	var s,t,u,v,w,x,y ;
+
+	s = m.split('exten=')[1].split(',')[0]; // s is the extension in the context - 3 in the above case 
+	timebasedrules[s] = {};
+
+	t = m.split('NoOp')[1].substr(1);
+	t = t.substr(0, t.length-1); // t is the name of the timebased rule - SomeTimeRule in the above case
+	timebasedrules[s].rulename = t ; 
+	timebasedrules[s].ruleconditons = {} ;
+
+	u = n.split('GotoIfTime')[1].substr(1);
+	u = u.substr(0, u.length-1); // u is the timeconditon string '04:00-11:59|mon-sun|1-31|jan-dec?voicemenu-custom-1,s,1' in the above case
+	v = u.split('|'); // v[0] is timeconditions '04:00-11:59', v[1] is dayofweek 'mon-sun', v[2] is dayofmonth '1-31', v[3] is 'jan-dec?voicemenu-custom-1,s,1'
+
+	if(v[0]=='*'){
+		timebasedrules[s].ruleconditons.fromhour = '00' ;
+		timebasedrules[s].ruleconditons.fromminutes = '00' ;
+		timebasedrules[s].ruleconditons.tohour = '23' ;
+		timebasedrules[s].ruleconditons.tominutes = '59' ;
+	}else{
+		timebasedrules[s].ruleconditons.fromhour = v[0].split('-')[0].split(':')[0] ;
+		timebasedrules[s].ruleconditons.fromminutes = v[0].split('-')[0].split(':')[1] ;
+		timebasedrules[s].ruleconditons.tohour = v[0].split('-')[1].split(':')[0] ;
+		timebasedrules[s].ruleconditons.tominutes = v[0].split('-')[1].split(':')[1] ;
+	}
+
+	if(v[1]=='*'){
+		timebasedrules[s].ruleconditons.from_wday = 'sun' ;
+		timebasedrules[s].ruleconditons.to_wday = 'sat' ;
+	}else{
+		timebasedrules[s].ruleconditons.from_wday = v[1].split('-')[0] ;
+		timebasedrules[s].ruleconditons.to_wday = v[1].split('-')[1] ;
+	}
+
+	if(v[2]=='*'){
+		timebasedrules[s].ruleconditons.from_mday = '01' ;
+		timebasedrules[s].ruleconditons.to_mday = '31' ;
+	}else{
+		timebasedrules[s].ruleconditons.from_mday = v[2].split('-')[0] ;
+		timebasedrules[s].ruleconditons.to_mday = v[2].split('-')[1] ;
+	}
+
+	w = v[3].split("?")[0]; //jan-dec
+	x = v[3].split("?")[1]; //voicemenu-custom-1,s,1
+
+	if(w=='*'){
+		timebasedrules[s].ruleconditons.from_month = 'jan' ;
+		timebasedrules[s].ruleconditons.to_month = 'dec' ;
+	}else{
+		timebasedrules[s].ruleconditons.from_month = w.split('-')[0] ;
+		timebasedrules[s].ruleconditons.to_month = w.split('-')[1] ;
+	}
+
+	y = o.split('Goto')[1].substr(1);
+	y = y.substr(0, y.length-1) ; //default,6001,1
+
+	timebasedrules[s].ifmatch_goto = x ;
+	timebasedrules[s].ifnomatch_goto = y ;
+}
+
+
+
+
+function set_selectboxes(){
+	var ie;
+	var opt_temp = document.createElement('option');
+	if(document.attachEvent){ ie=1;}else{ie=0;}
+
+	var tostring = function (s){
+		return (s<10)?"0"+String(s):s;
+	}
+
+	var updateselect = function( el,start,end ){
+		var s,u;
+		for(s =start; s< end; s++){
+			u = opt_temp.cloneNode(true);
+			s = tostring(s);
+			u.text = s ;	u.value = s;
+			if(ie){el.add(u);} else{el.add(u,null);}
+		}
+		el.selectedIndex = -1;
+	}
+
+	var update_select_menus = function(el){
+		var g,h;
+		for ( g=0; g <voicemenus.length; g++){
+			h = opt_temp.cloneNode(true);
+			h.text = voicemenus[g].menuname ;
+			h.value = voicemenus[g].menucontextstring;
+			if(ie){el.add(h);} else{ el.add(h,null);}
+		}
+		for ( g=0 ; g <user_extens.length; g++){
+			h = opt_temp.cloneNode(true);
+			h.text = user_extens[g].username;
+			h.value = user_extens[g].usercontextstring;
+			if(ie){ el.add(h);} else{ el.add(h,null);}
+		}
+	}
+
+	updateselect(_$('startime_hour'), 0,24); 
+	updateselect(_$('endtime_hour'), 0,24);
+	updateselect(_$('startime_minute'), 0,60);
+	updateselect(_$('endtime_minute'), 0,60);
+	updateselect(_$('startdom'),1,32);
+	updateselect(_$('enddom'),1,32);
+
+	update_select_menus(_$('dest_match') );
+	update_select_menus(_$('dest_nomatch') );
+
+}
+
+
+function add_trule(){
+	isNewRule = 1;
+	reset_fields();
+	_$('create_rule').disabled = 1;
+	_$('timerule_editdiv').style.display = "";
+	_$('id_rulename').focus();
+}
+
+function cancel_rule(){
+	_$('create_rule').disabled = 0;
+	_$('timerule_editdiv').style.display = "none";
+}
+
+function reset_fields(){
+//	id_rulename, startime_hour, startime_minute, endtime_hour, endtime_minute, wday_start
+//	wday_end, startdom, enddom, month_start, month_end, dest_match, dest_nomatch
+	_$('id_rulename').value = "";
+	var slectboxes = ['startime_hour', 'startime_minute','endtime_hour','endtime_minute','wday_start','wday_end','startdom','enddom','month_start','month_end','dest_match','dest_nomatch'];
+	for (var r=0; r < slectboxes.length; r++){
+		_$(slectboxes[r]).selectedIndex = -1;
+	}
+}
+
+function save_rule(){
+	if(isNewRule){
+		add_newrule();
+	}else{
+		update_rule();
+	}
+}
+
+
+function edit_form(f){
+	isNewRule = 0;
+	reset_fields();
+	form_updatevalues(f);
+	_$('create_rule').disabled = 1;
+	_$('timerule_editdiv').style.display = "";
+	_$('id_rulename').focus();
+}
+
+function delete_rule(f){
+
+}
+
+function form_updatevalues(f){
+//	_$('id_rulename').value = "";
+//	var slectboxes = ['','','','','','','','',];
+	_$('id_rulename').value = timebasedrules[f].rulename;
+
+	_$('startime_hour').selectedIndex = parseInt(timebasedrules[f].ruleconditons.fromhour);
+	_$('startime_minute').selectedIndex = parseInt(timebasedrules[f].ruleconditons.fromminutes);
+
+	_$('endtime_hour').selectedIndex = parseInt(timebasedrules[f].ruleconditons.tohour);
+	_$('endtime_minute').selectedIndex = parseInt(timebasedrules[f].ruleconditons.tominutes);
+
+	var find_index = function(el,val){
+		for(var t=0; t< el.options.length; t++){
+			if( el.options[t].value == val){ el.selectedIndex = t; return; }
+		}
+	}
+
+	find_index(_$('wday_start'), timebasedrules[f].ruleconditons.from_wday);
+	find_index(_$('wday_end'), timebasedrules[f].ruleconditons.to_wday);
+
+	_$('startdom').selectedIndex = parseInt(timebasedrules[f].ruleconditons.from_mday -1);
+	_$('enddom').selectedIndex = parseInt(timebasedrules[f].ruleconditons.to_mday -1);
+
+	find_index(_$('month_start'), timebasedrules[f].ruleconditons.from_month);
+	find_index(_$('month_end'), timebasedrules[f].ruleconditons.to_month);
+
+	find_index(_$('dest_match'), timebasedrules[f].ifmatch_goto);
+	find_index(_$('dest_nomatch'), timebasedrules[f].ifnomatch_goto);
+
+}
+
+
+// * ******** PENDING ****** PENDING ***
+</script>
+<body onload="localajaxinit()"  bgcolor="FFFFFF">
+<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;">
+	<span style="margin-left: 4px;font-weight:bold;">Time Based Rules</span>
+	<span style="cursor: pointer; cursor: hand;" onclick="window.location.href=window.location.href;" >&nbsp;<img src="images/refresh.png" title=" Refresh " border=0 >&nbsp;</span>	&nbsp;&nbsp;
+	<input id="create_rule" type=button value="New Time Rule" class="input8" onclick="add_trule();">
+</div>
+<div id="maintable1">
+	<table class="table_blacksm" cellpadding=2 cellspacing=2 border=0 align=center width=500 id="table_one">
+		<tr>	<td width=35>S.No</td>
+			<td align=left>RuleName</td>
+			<td align="center" width=115>Options</td>
+		</tr>
+	</table>
+	<div id="tbrulesTable_div" style="height:260px;width=100%; overflow :auto; padding : 0px 0px 0px 0px;">
+		<table id="tbrulesTable" cellpadding=2 cellspacing=1 border=0 align=center width=500 bgcolor="#DEDEDE"></table>
+	</div>
+	<BR>
+</div>
+* ******** PENDING ****** PENDING ***
+<div id="timerule_editdiv" STYLE="display:none; position: absolute; left: 20; top: 20; width:480; height:320; background-color:#F4EFE5; border-width: 1px; border-color: #7E5538; border-style: solid; z-index:5">
+	<table width="100%" cellpadding=0 cellspacing=0  onmousedown="startDrag(event , 'timerule_editdiv');">
+	<TR bgcolor="#7E5538"  style="background-image:url('images/title_gradient.gif');">
+		<TD><font color="#FFFFFF">&nbsp;&nbsp;<span><B>Edit/Add Time Rule</B></span></FONT></TD>
+		<TD Height="20" align="right" style="cursor: move">
+			<A href="#" onclick="$('cancel').click();" style="color:#FFFFFF; font-size: 12px; font-weight:bold;">X</A>
+		</TD>
+		<TD width=4></TD>
+	</TR>
+	</table>
+	<table cellpadding=2 cellspacing=2 border=0 width="100%" align="center">
+		<tr><td align=center colspan=2>	Rule Name : <input id="id_rulename" size=20 class="input9">	</td>	</tr>
+		<tr><td align=center colspan=2 height=30 valign=bottom><B>Time & Date Conditions</B></td>	</tr>
+
+		<tr>	<td align=right>Start Time: <select id="startime_hour" class="input9"></select> : <select id="startime_minute" class="input9"></select></td>
+			<td align=left>End Time: <select id="endtime_hour" class="input9"></select> : <select id="endtime_minute" class="input9"></select></td>
+		</tr>
+		
+
+		<tr>	<td align=right>Start Day: 
+				<select id="wday_start" class="input9">
+					<option value="sun">Sun</option><option value="mon">Mon</option><option value="tue">Tue</option><option value="wed">Wed</option>
+					<option value="thu">Thu</option><option value="fri">Fri</option><option value="sat">Sat</option>
+				</select>
+			</td>
+			<td align=left>End Day: 
+				<select id="wday_end" class="input9">
+					<option value="sun">Sun</option><option value="mon">Mon</option><option value="tue">Tue</option><option value="wed">Wed</option>
+					<option value="thu">Thu</option><option value="fri">Fri</option><option value="sat">Sat</option>
+				</select>
+			</td>
+		</tr>
+		
+		<tr>	<td align=right>Start Date: <select id="startdom" class="input9"></select></td>
+			<td align=left>End Date: <select id="enddom" class="input9"></select></td>
+		</tr>
+
+		<tr>	<td align=right>Start Month: 
+				<select id="month_start" class="input9">
+					<option value="jan">January</option><option value="feb">February</option><option value="mar">March</option><option value="apr">April</option>
+					<option value="may">May</option><option value="jun">June</option><option value="jul">July</option><option value="aug">August</option>
+					<option value="sep">September</option><option value="oct">October</option><option value="nov">November</option><option value="dec">December</option>
+				</select>
+			</td>
+			<td align=left>End Month:
+				<select id="month_end" class="input9">
+					<option value="jan">January</option><option value="feb">February</option><option value="mar">March</option><option value="apr">April</option>
+					<option value="may">May</option><option value="jun">June</option><option value="jul">July</option><option value="aug">August</option>
+					<option value="sep">September</option><option value="oct">October</option><option value="nov">November</option><option value="dec">December</option>
+				</select>
+			</td>
+		</tr>
+
+		<tr><td align=center colspan=2 height=40 valign=bottom><B>Destination</B></td>	</tr>
+
+		<tr>	<td align=right>if time matches:</td>
+			<td align=left><select id="dest_match" class="input9"></select></td>
+		</tr>
+
+		<tr>	<td align=right>if time did not match:</td>
+			<td align=left><select id="dest_nomatch" class="input9"></select></td>
+		</tr>
+
+		<tr>	<td align=center colspan=2 height=30 valign=bottom>
+				<input id="save" type=button value="Save" class="input9" onclick="save_rule();">&nbsp;&nbsp;
+				<input id="cancel" type=button value="Cancel" class="input9" onclick="cancel_rule();">
+			</td>
+		</tr>
+	</table>
+</div>
+</body>



More information about the asterisk-gui-commits mailing list