pari: trunk r978 - /trunk/config/ringgroups.html

asterisk-gui-commits at lists.digium.com asterisk-gui-commits at lists.digium.com
Thu May 24 10:54:53 MST 2007


Author: pari
Date: Thu May 24 12:54:52 2007
New Revision: 978

URL: http://svn.digium.com/view/asterisk-gui?view=rev&rev=978
Log:
RingGroups - Not complete yet - but commiting what I got so far, will put a link in advanced menus when the rest of it is done

Added:
    trunk/config/ringgroups.html

Added: trunk/config/ringgroups.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/ringgroups.html?view=auto&rev=978
==============================================================================
--- trunk/config/ringgroups.html (added)
+++ trunk/config/ringgroups.html Thu May 24 12:54:52 2007
@@ -1,0 +1,429 @@
+<!--
+ * Asterisk-GUI	-	an Asterisk configuration interface
+ *
+ * Ring Groups
+ *
+ * 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.
+ *
+-->
+<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 isNewRG, ie;
+var UserExtensions = [];
+var LISTOFCHANNELS = {};
+var ringgroups = {};
+var opt_temp = document.createElement('option');
+if(document.attachEvent){ ie=1;}else{ie=0;}
+var RG_COMMENT = 'gui_ring_groupname';
+var RG_FORMAT = 'ringroups-custom-';
+
+
+
+function clear_table(){
+	var t = _$('rgsTable') ;
+	for( var i=0; i < t.rows.length; ){ t.deleteRow(i); }
+}
+
+
+function showlist_of_rules(){
+	var t;
+	for( t in ringgroups ){
+		if(ringgroups.hasOwnProperty(t)){ addrow_totable( ringgroups[t],t ); }
+	}
+
+	var u = _$('rgsTable');
+	if( u.rows.length == 0 ){
+		_$('table_one').style.display="none";
+		var newRow = u.insertRow(-1);
+		var newCell0 = newRow.insertCell(0);
+		newCell0.align = "center";
+		newCell0.innerHTML = "<BR><I> No Previous Ring Groups found !!</I> <BR><BR>" +
+			"Please click on the 'New Ring Group' button<BR> to define a New RingGroup<BR><BR>" ;
+	}
+}
+
+function addrow_totable(k,l){
+	// sno, ringgroup, options
+	var newRow = _$('rgsTable').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 =_$('rgsTable').rows.length  ;
+	newCell0 .width = 35;
+	newCell0.align = "center";
+	
+	var newCell1 = newRow.insertCell(1);
+	newCell1 .innerHTML = k.rgname ;
+	newCell1.align = "left";
+	
+	var newCell2 = newRow.insertCell(2);
+	newCell2 .innerHTML = "<input type=\"button\" onclick='delete_rg(\""+ l+ "\")'  value=\"Delete\"  class=\"splbutton\">" ;
+	newCell2.align = "center";
+	newCell2.width = 115;
+}
+
+
+function save_rg(){
+	if(isNewRG){ 
+		var getnewringgroupcontext = function(){
+			var t=1;
+			while(ringgroups[t]){ t++; }
+			return t;
+		}
+		var s = getnewringgroupcontext();
+		create_newRG(s);
+ 	}
+}
+
+function create_newRG(v){
+	var uri="", p=0, context = 'ringroups-custom-' + v ;
+	var rcs = _$('select_ringthesechannels') ;
+	var s,t,u;
+
+	ringgroups[v] = {};
+	var this_ringgroup = ringgroups[v];
+	this_ringgroup.rgname = _$('text_rgname').value;
+	this_ringgroup.ringstyle = _$('select_strategy').value;
+	this_ringgroup.rgchannels = [];
+	this_ringgroup.laststep = '';
+
+	uri += build_action('newcat', p, context ,"", ""); p = p+1;
+
+	uri += build_action('append', p, context ,RG_COMMENT, _$('text_rgname').value); p = p+1;
+
+	uri += build_action('append', p, context ,"exten", "s,1,Answer"); p = p+1;
+
+	if( _$('select_strategy').value =='ringinorder'){
+		for( s=0; s< rcs.options.length; s++  ){
+			t = 's,n,Dial(' + rcs.options[s].value + ',10)' ;
+			this_ringgroup.rgchannels.push(rcs.options[s].value);
+			uri += build_action('append', p, context ,"exten", t); p = p+1;
+		}
+	}
+	
+	if( _$('select_strategy').value =='ringall'){
+		for( s=0; s< rcs.options.length; s++  ){ 
+			this_ringgroup.rgchannels.push(rcs.options[s].value);
+		}
+		t = 's,n,Dial(' + this_ringgroup.rgchannels.join("&") + ',10)' ;
+		uri += build_action('append', p, context ,"exten", t); p = p+1;
+	}
+	
+	
+	if( _$('radio_fbvm').checked ){ // FailBack to voicemail group
+		t = 's,n,' + _$('select_voicemails').value ;
+		uri += build_action('append', p, context ,"exten", t); p = p+1;
+		this_ringgroup.laststep = _$('select_voicemails').value;
+	}
+
+	if( _$('radio_fbivr').checked ){  // FailBack to IVR
+		t = 's,n,' + _$('select_vmenus').value ;
+		uri += build_action('append', p, context ,"exten", t); p = p+1;
+		this_ringgroup.laststep = _$('select_vmenus').value ;
+	}
+
+	if( _$('radio_fbhgp').checked){  // Failback to Hangup
+		uri += build_action('append', p, context ,"exten", 's,n,Hangup'); p = p+1;
+		this_ringgroup.laststep = 'Hangup' ;
+	}
+
+	makerequest('u','extensions.conf', uri, function(t){
+		_$('ringgroup_editdiv').style.display = 'none';
+		clear_table();
+		showlist_of_rules();
+	});
+}
+
+
+function switch_fb_selects(){
+
+	if( _$('radio_fbvm').checked ){
+		_$('select_voicemails').style.display = "";
+		_$('select_vmenus').style.display = "none";
+	}
+	if( _$('radio_fbivr').checked ){
+		_$('select_voicemails').style.display = "none";
+		_$('select_vmenus').style.display = "";
+	}	
+}
+
+
+function a2b(a,b){
+	var h; 
+	h = opt_temp.cloneNode(true);
+	if(a.selectedIndex < 0){return false;}
+	h.text = a.options[a.selectedIndex].text ;
+	h.value = a.options[a.selectedIndex].value;
+	if(ie){b.add(h);} else{ b.add(h,null);}
+	a.remove(a.selectedIndex);
+}
+
+function localajaxinit(){
+
+	add_event( _$('radio_fbvm') , 'click', switch_fb_selects );
+	add_event( _$('radio_fbivr') , 'click', switch_fb_selects );
+	add_event( _$('button_add_toringlist') , 'click', function(){
+		a2b(_$('select_listofchannels'),_$('select_ringthesechannels'));
+	});
+	add_event( _$('button_remove_fromringlist') , 'click', function(){
+		a2b(_$('select_ringthesechannels'),_$('select_listofchannels'));
+	});
+	add_event( _$('button_removeall_fromringlist') , 'click', function(){
+		var y = _$('select_ringthesechannels');
+		var z = _$('select_listofchannels');
+		while (y.options.length){
+			y.selectedIndex = 0;
+			a2b(y,z);
+		}
+	});	
+
+
+
+
+	// Load all user extensions
+	// Load Fall back extensions - Voicemail (same user extensions) and IVR menus
+	// Load Zap Channels
+	//
+	// Load all existing Ringgroups into the ringgroups object 
+	// Display ringgroup object as table.
+	//
+	// so we need to load users.conf and extensions.conf
+	//
+
+	config2json('users.conf', 1, get_users) ;
+
+	parent.loadscreen(this);
+}
+
+
+function get_users(n){
+	var l, h;
+	var el = _$('select_voicemails');
+	for( l in n ){	if(n.hasOwnProperty(l)){
+		if( l =='general'){ continue;} // ignore 'general' context
+		if ( n[l]['context'] && unescape(n[l]['context']) == asterisk_guiTDPrefix + l ) { // ignore trunks in users.conf
+			continue;
+		}
+
+		if( !n[l]['trunkstyle'] ){ // all entries from users.conf other than trunks
+			UserExtensions.push(l);
+			if( n[l]['hassip']=='yes'){LISTOFCHANNELS['SIP/' + l] = true;}
+			if( n[l]['hasiax']=='yes'){LISTOFCHANNELS['IAX2/' + l] = true;}
+
+			h = opt_temp.cloneNode(true);
+			h.text = l + " -- " + n[l]['fullname'] ;
+			h.value = 'Voicemail(' + l + ',b)';
+			if(ie){el.add(h);} else{ el.add(h,null);}
+		}
+	}}
+	config2json('extensions.conf', 0, read_extensions) ;
+}
+
+
+function read_extensions(n){
+	// read ringgroups, voicemenus
+	var l, t, h;
+	var el = _$('select_vmenus');
+	var get_menuname = function(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;
+	}
+
+	for( l in n ){	if(n.hasOwnProperty(l)){
+		t = l.substr(0,RG_FORMAT.length);
+		if(  t == RG_FORMAT ){ // if is a ring group
+			parse_addtoringgroups(l, n[l]);
+			continue;
+		}
+
+		t = l.substr(0,17);
+		if( t =='voicemenu-custom-' ){ // if is a Voice Menu
+			h = opt_temp.cloneNode(true);
+			h.text = get_menuname(n[l]);
+			h.value = 'Goto('+ n[l] + '|s|1)';
+			if(ie){el.add(h);} else{ el.add(h,null);}
+		}
+	}}
+
+	clear_table();
+	showlist_of_rules();
+}
+
+function parse_addtoringgroups(u, v){
+	//ringgroups
+	var f = u.substr(RG_FORMAT.length);
+	ringgroups[f] = {};
+	var this_ringgroup = ringgroups[f];
+	this_ringgroup.rgname = u;
+	this_ringgroup.rgchannels = [];
+	this_ringgroup.laststep = '';
+	this_ringgroup.ringstyle = '';
+
+	if(  v[0].match(RG_COMMENT+'=')  ){
+		f = v[0].split(RG_COMMENT+'=');
+		this_ringgroup.rgname = f[1] ;
+	}
+
+	var nd=0, indexes=[];
+	for( var a=1; a < v.length-1; a++ ){
+		if( v[a].match('s,n,Dial') ) {
+			nd++;
+			indexes.push(a);
+		}
+	}
+
+	var rc;
+	if(nd==1){ 
+		this_ringgroup.ringstyle = 'ringall';
+		rc = v[indexes[0]].split('Dial(')[1].split(',')[0].split('&') ;
+		for(a=0; a < rc.length; a++){ this_ringgroup.rgchannels.push(rc[a]); }
+	}
+
+	if(nd>1){
+		this_ringgroup.ringstyle = 'ringinorder';
+		for(a=0; a < indexes.length; a++){
+			rc = v[indexes[a]].split('Dial(')[1].split(',')[0];
+			this_ringgroup.rgchannels.push(rc);
+		}
+	}
+
+	// finally take a look at last step - if no one answers
+	this_ringgroup.laststep = v[v.length-1].split('s,n,')[1];
+}
+
+
+
+
+
+
+
+function add_rg(){
+	var u;
+	isNewRG = 1;
+	_$('form_caption').innerHTML = "<B>Add Ring Group</B>";
+	_$('select_voicemails').style.display = "none";
+	_$('select_vmenus').style.display = "none";
+	_$('ringgroup_editdiv').style.display = '';
+
+	var y = _$('select_listofchannels');
+	while (y.options.length)
+		y.remove(0);
+
+	for( var u in LISTOFCHANNELS ){ if(LISTOFCHANNELS.hasOwnProperty(u)) {
+		h = opt_temp.cloneNode(true);
+		h.text = u ;
+		h.value = u ;
+		if(ie){y.add(h);} else{ y.add(h,null);}
+	}}
+
+}
+
+function cancel_rg(){ _$('ringgroup_editdiv').style.display = 'none'; }
+
+
+</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;">Ring Groups</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 Ring Group" class="input8" onclick="add_rg();">
+</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>Ring Group</td>
+			<td align="center" width=115>Options</td>
+		</tr>
+	</table>
+	<div id="rgsTable_div" style="height:430px;width=100%; overflow :auto; padding : 0px 0px 0px 0px;">
+		<table id="rgsTable" cellpadding=2 cellspacing=1 border=0 align=center width=500 bgcolor="#DEDEDE"></table>
+	</div>
+	<BR>
+</div>
+<div id="ringgroup_editdiv" STYLE="display:none; position: absolute; left: 20; top: 40; width:480; height:400; 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 , 'ringgroup_editdiv');">
+	<TR bgcolor="#7E5538"  style="background-image:url('images/title_gradient.gif');">
+		<TD><font color="#FFFFFF">&nbsp;&nbsp;<span id="form_caption"></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>Name: <input type="text" id="text_rgname" size=18 class="input9"></td>
+			<td colspan=2 align="center">
+				Strategy: <select id="select_strategy"><option value="ringall">Ring all</option><option  value="ringinorder">Ring in Order</option></select>
+			</td>
+		</tr>
+		<tr>	<td width=200 align=center valign=top height=200>
+				<select id="select_ringthesechannels" style="width:175px; height: 200px" class="input10" size=10></select>
+			</td>
+			<td width=80 align=center>
+				<input type="button" id="button_add_toringlist" value="&#8592;"><BR><BR>
+				<input type="button" id="button_remove_fromringlist" value="&#8594;">
+				<BR><BR>
+				<input type="button" id="button_removeall_fromringlist" value="&#187;&#187;">
+			</td>
+			<td width=200 align=center valign=top>
+				<select id="select_listofchannels" style="width:175px; height: 200px" class="input10" size=10></select>
+			</td>
+		</tr>
+		<tr>	<td align=center valign=top>
+				<B>Ring Group Members</B>
+			</td>
+			<td width=80 align=center>
+
+			</td>
+			<td width=200 align=center valign=top>
+				<B>Available Channels</B>
+			</td>
+		</tr>
+		<tr>	<td colspan=2 align="left" class="field_text">
+				If not answered <BR>
+
+				<LABEL FOR="radio_fbvm">
+				<input name='failbacktype' type='radio' id='radio_fbvm' value='radio_fbvm'>Goto Voicemail of this user</LABEL><BR>
+
+				<LABEL FOR="radio_fbivr">
+				<input name='failbacktype' type='radio' id='radio_fbivr' value='radio_fbivr'>Goto an IVR menu</LABEL><BR>
+
+
+				<LABEL FOR="radio_fbhgp">
+				<input name='failbacktype' type='radio' id='radio_fbhgp' value='radio_fbhgp'>HangUp</LABEL>
+			</td>
+			<td>
+				<select id="select_voicemails" class="input10"></select>
+				<select id="select_vmenus" class="input10"></select>
+			</td>
+		</tr>
+		<tr>	<td align=center colspan=3 valign=bottom height=40>
+				<input id="save" type=button value="Save" class="input9" onclick="save_rg();">&nbsp;&nbsp;
+				<input id="cancel" type=button value="Cancel" class="input9" onclick="cancel_rg();">
+			</td>
+		</tr>
+	</table>
+</div>
+</body>



More information about the asterisk-gui-commits mailing list