bkruse: branch asterisknow r1721 - /branches/asterisknow/config/
SVN commits to the Asterisk-GUI project
asterisk-gui-commits at lists.digium.com
Wed Oct 24 11:14:24 CDT 2007
Author: bkruse
Date: Wed Oct 24 11:14:23 2007
New Revision: 1721
URL: http://svn.digium.com/view/asterisk-gui?view=rev&rev=1721
Log:
Merging all the changes from trunk into asteriskNOW
(The manual way, since it was not developed in
branches/1.4, but thats ok)
Modified:
branches/asterisknow/config/digital.html
branches/asterisknow/config/incoming.html
Modified: branches/asterisknow/config/digital.html
URL: http://svn.digium.com/view/asterisk-gui/branches/asterisknow/config/digital.html?view=diff&rev=1721&r1=1720&r2=1721
==============================================================================
--- branches/asterisknow/config/digital.html (original)
+++ branches/asterisknow/config/digital.html Wed Oct 24 11:14:23 2007
@@ -73,6 +73,38 @@
function hide_mymenu(){ menu.style.display="none"; }
+function verify_priChLimit(){
+ var l = String( menu.span_value );
+ if(_$('editspan_signalling').value.beginsWith('fx')){ return true;}
+ var y = Number(_$('edit_DefinedChans').value);
+ if( Number(SPANS[l]['totchans'] ) <= 24 && y ==24){return false;}//alert("You should leave atleast 1 channel for PRI signalling");
+ if( Number(SPANS[l]['totchans'] ) > 24 && y ==31){return false;}//alert("You should leave atleast 1 channel for PRI signalling");
+ return true;
+};
+
+function calc_bchan_fxx(l){ // calculates the bchan,and fxx strings for a given span
+ var y = Number(SPANS[l]['min_ch']);
+ var z = Number(SPANS[l]['definedchans']);
+ if(z==1){return String(y);}
+
+ if( SPANS[l]['signalling'] && SPANS[l]['signalling'].beginsWith('fx') ){
+
+ return y + "-" + String(y+z-1);
+ }else{
+ if(SPANS[l]['totchans'] <= 24){ // if T1
+ return y + "-" + String(y+z-1);
+ }else{ // if E1 - take first 15 as b-channels, then a d channel and then take the next 15 as bchannels
+ if(z==16){ return y+"-"+String(y+14)+","+String(y+16); }
+ if(z<= 15){
+ return y+"-"+String(y+z-1);
+ }else{
+ return y+"-"+String(y+14)+","+String(y+16) +"-"+ String(y+z);
+ }
+ }
+ }
+}
+
+
function canelSpanInfo(){
_$('edit_span').style.display = "none";
_$('bg_transparent').style.display = "none";
@@ -82,12 +114,40 @@
menu.style.width="80";
menu.style.borderColor = "#eee #bbb #bbb #ddd";
ASTGUI.events.add( document.body , "click", function(){ menu.style.display="none"; } );
+ var edit_DefinedChans_changed = function(){
+ var b = String( menu.span_value );
+ var y = Number(_$('edit_DefinedChans').value);
+ if( !verify_priChLimit() ){
+ alert("You should leave atleast one channel for signalling");
+ return true;
+ }
+
+ SPANS[b]['definedchans'] = y;
+ //_$('edit_labelReserved').innerHTML = SPANS[b]['reserved_ch'];
+ _$('edit_labelZapchan').innerHTML = calc_bchan_fxx(b);
+ };
+
+ ASTGUI.events.add( _$('edit_DefinedChans'), "change", edit_DefinedChans_changed );
var editSPAN = function(l){ // show values for SPAN l in the edit_span dialog box
_$('editspan_SPAN').innerHTML = SPANS[l]['description'];
_$('editspan_ALARMS').innerHTML = SPANS[l]['alarms'];
+ // console.log( SPANS[l]['min_ch'] );
+ // console.log( SPANS[l]['max_ch'] );
+ // console.log( SPANS[l]['definedchans'] );
+
ASTGUI.selectbox.clear( _$('editspan_fac') );
+ var w = _$('edit_DefinedChans') ;
+
+ var ijkl = function(){
+ ASTGUI.selectbox.clear(w);
+ var f = Number( SPANS[l]['totchans'] ), g=0;
+ for(g=1; g <=f; g++){ ASTGUI.selectbox.append(w,g,g); }
+ ASTGUI.selectbox.selectOption(w,SPANS[l]['definedchans']);
+ _$('edit_labelReserved').innerHTML = SPANS[l]['reserved_ch'];
+ _$('edit_labelZapchan').innerHTML = calc_bchan_fxx(l);
+ }();
if ( Number(SPANS[l]['totchans']) <= 24 ){
ASTGUI.selectbox.append(_$('editspan_fac'),'ESF/B8ZS', 'ESF/B8ZS');
@@ -222,10 +282,12 @@
var loadConfigFiles = {
// read applyzap.conf (if exists) - so that the GUI knows the last configured hardware
// run ztscan - to detect digital cards
- // read ztscan.conf - read spans information
+ // read ztscan.conf - read spans information - also set the max , min values for each span
// see if the number of spans in ztscan.conf matches with that from applyzap.conf
// (this way we know if any changes in digital hardware since the gui was last used)
- // read users.conf - and read spans information
+ // read users.conf - and read spans information
+ // check if the channels in zapchan are within max and min
+ // if yes then set the current range values
readApplyzap: function(){
@@ -273,7 +335,7 @@
//_$('tablecontainer').style.display="none";
return false;
}
-
+ var q = 0;
for( var l in n ){ if(n.hasOwnProperty(l)){
if( l =='general') {
if(n[l]['continue'] && n[l]['continue'] == "no") {
@@ -298,6 +360,11 @@
SPANS[l][k] = n[l][k];
if( k == 'totchans' ){
SPANS[l]['spantype'] = ( Number(n[l][k]) <= 24) ? "T1" : "E1";
+ SPANS[l]['min_ch'] = q + 1;
+ SPANS[l]['max_ch'] = q + Number(n[l][k]) ;
+ SPANS[l]['reserved_ch'] = q + ( (Number(n[l][k])<=24)? 24 : 16 );
+ SPANS[l]['definedchans'] = 1; // default value
+ q += Number(n[l][k]);
}
}}
}}
@@ -316,13 +383,41 @@
//_$('tablecontainer').style.display="none";
return false;
}
+
+ var efgh = function(zc){
+ // calculate the number of channels defined for use in zapchan string
+ // zc can be in the format 'u', 'u-v', 'u-v,w-x' or 'u-v,w'
+ // the function returns 1 if u, (v-u +1) for the second case
+ // and x-u for the third and // v-u+2 for the fourth case
+ try{
+ if( zc.contains('-') ){
+ if(zc.contains(',')){ // case 3 or case 4
+ if( zc.split('-').length > 2 ) { // case 3
+ return (Number(zc.split('-')[2]) - Number(zc.split('-')[0]));
+ }else{ // case 4
+ return (Number((zc.split('-')[1]).split(',')[0])-Number(zc.split('-')[0]) + 2);
+ }
+ } else { // case 'u-v'
+ return (Number(zc.split('-')[1])-Number(zc.split('-')[0])+1);
+ }
+ }else{ // case 1
+ return 1;
+ }
+ }catch(err){
+ return null;
+ }
+ };
+
var abcd = function(){
var tmp;
for( var l in n ){ if(n.hasOwnProperty(l)){
if( l.beginsWith('span_')) {
tmp = l.split('span_')[1];
if (!SPANS[tmp]){SPANS[tmp] = {};}
- for( var k in n[l] ){ if(n[l].hasOwnProperty(k)){ SPANS[tmp][k] = n[l][k]; }}
+ for( var k in n[l] ){ if(n[l].hasOwnProperty(k)){
+ SPANS[tmp][k] = n[l][k];
+ if( k=='zapchan' || k=='fxochannels'){ SPANS[tmp]['definedchans'] = efgh(n[l][k]); }
+ }}
}
}}
}();
@@ -349,6 +444,23 @@
}
function updateSpanInfo(){
+ if( !verify_priChLimit() ){
+ alert("You should leave atleast one channel for signalling.");
+ return true;
+ }
+ if(!_$('editspan_fac').value){
+ alert("Please select a Framing/Coding !");
+ return true;
+ }
+ if(!_$('editspan_signalling').value){
+ alert("Please select a signalling !");
+ return true;
+ }
+ if(_$('editspan_signalling').value.beginsWith('pri') && !_$('editspan_switchtype').value ){
+ alert("Please select a Switch Type !");
+ return true;
+ }
+
var b = String( menu.span_value );
SPANS[b]['fac'] = _$('editspan_fac').value;
SPANS[b]['signalling'] = _$('editspan_signalling').value;
@@ -389,11 +501,18 @@
uri += build_action('newcat', c, d , "", ""); c++;
uri += build_action('update', c, d , "switchtype", SPANS[k]['switchtype']); c++;
uri += build_action('update', c, d , "signalling", SPANS[k]['signalling']); c++;
- uri += build_action('update', c, d , "context", e); c++;
- uri += build_action('update', c, d , "group", String(k)); c++;
uri += build_action('update', c, d , "trunkname", 'Span '+String(k)); c++;
uri += build_action('update', c, d , "trunkstyle", 'digital'); c++;
- uri += build_action('update', c, d , "zapchan", SPANS[k]['zapchanstring'] ); c++;
+ uri += build_action('update', c, d , "context", e); c++;
+
+ if ( !SPANS[k]['signalling'].beginsWith('fxo') ){
+ uri += build_action('update', c, d , "group", String(k)); c++;
+ uri += build_action('update', c, d , "zapchan", SPANS[k]['zapchanstring'] ); c++;
+ }else{
+ // if fxs signalling , donot add zapchan under span_x,
+ // we would want to define zapchan under the user extension to which we want the station to be assigned to
+ uri += build_action('update', c, d , "fxochannels", SPANS[k]['zapchanstring'] ); c++;
+ }
uri2 += build_action('delete', f, 'globals', d, "", ""); f++;
uri2 += build_action('update', f, 'globals', d,'Zap/g'+String(k)); f++;
@@ -420,10 +539,14 @@
// then call a script which will generate zaptel.conf from it and asks the user to restart his machine
var uri = '';
var add_lines = function(){
- var c = 0, bchanstring = '', dchanstring = '', context = 'general' ;
+ var fxx={};
+ var c = 0, bchanstring = '', dchanstring = '', context = 'general';
+ var totalchans = 0, firstpart , secondpart, tmp2 , tmp3;
+
uri = build_action('delcat', c, context,"", ""); c++;
uri += build_action('newcat', c , context, "", ""); c++;
- var totalchans = 0, firstpart , secondpart, tmp, tmp2 , tmp3;
+
+
for( var k in SPANS ){ if( SPANS.hasOwnProperty(k) ){ if(SPANS[k]['signalling']){
firstpart = "span";
/* XXX Timing source for card is being set to zero? */
@@ -431,32 +554,21 @@
secondpart = k + "," + SPANS[k]['syncsrc'] + "," + SPANS[k]['lbo'] + "," + SPANS[k]['fac'].toLowerCase().replace("/", ",");
uri += build_action('append', c, context, firstpart, secondpart ); c++;
tmp2 = (bchanstring)? ",":"";
-
+ tmp3 = (dchanstring)? ",":"";
+
+ var ppp = calc_bchan_fxx(k);
if ( SPANS[k]['signalling'].beginsWith('fx') ){
- bchanstring += '';
- dchanstring += '';
- tmp = totalchans + Number(SPANS[k]['totchans']);
- tmp3 = String(totalchans+1) + "-" + String(tmp);
- totalchans = tmp;
+ fxx[SPANS[k]['signalling']] = ((fxx[SPANS[k]['signalling']])? fxx[SPANS[k]['signalling']] + ",":"") + ppp;
}else{
- if(SPANS[k]['totchans'] <= 24){
- tmp = totalchans + Number(SPANS[k]['totchans']);
- dchanstring += tmp2 + String(tmp) ;
- tmp3 = String(totalchans+1) + "-" + String(tmp-1);
- bchanstring += tmp2 + tmp3;
- totalchans = tmp;
- }else{ // take first 15 as b-channels, then a d channel and then take the next 15 as bchannels
- tmp = totalchans + Number(15);
- tmp3 = String(totalchans+1) + "-" + String(tmp);
- dchanstring += tmp2 + String(totalchans+16) ;
- tmp3 += "," + String(tmp+2) + "-" + String(tmp+16);
- bchanstring += tmp2 + tmp3;
- totalchans = tmp + Number(16);
- }
+ bchanstring += tmp2 + ppp;
+ dchanstring += tmp3 + SPANS[k]['reserved_ch'];
}
- SPANS[k]['zapchanstring'] = tmp3;
+ SPANS[k]['zapchanstring'] = ppp;
}}}
+ for( var e in fxx ){ if(fxx.hasOwnProperty(e)){
+ uri += build_action('append', c, context, e, fxx[e]); c++;
+ }}
uri += build_action('append', c, context, 'bchan', bchanstring); c++;
uri += build_action('append', c, context, 'dchan', dchanstring); c++;
uri += build_action('append', c, context, 'loadzone', _$('loadZone').value); c++;
@@ -523,16 +635,18 @@
<div id="edit_span" STYLE="display:none; position: absolute; left: 30; top: 40; width:500; height:310; 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_span');">
<TR bgcolor="#7E5538" style="background-image:url('images/title_gradient.gif');">
- <TD Height="20" align="right" style="cursor: move">
+ <TD Height="20" align="left" style="cursor: move">
+ <font style="color:#FFFFFF; font-size: 12px; font-weight:bold;">
+ SPAN : <span id="editspan_SPAN"></span>
+ </font>
+ </TD>
+ <TD Height="20" align="right" style="cursor: move" width=20>
<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">SPAN:</TD>
- <TD><span id="editspan_SPAN"></span></TD>
- </TR>
<TR> <TD align="right">ALARMS:</TD>
<TD><span id="editspan_ALARMS"></span></TD>
</TR>
@@ -547,9 +661,9 @@
<option value="pri_net">PRI - Net</option>
<option value="pri_cpe">PRI - CPE</option>
<option value="fxoks">FXOKS</option>
- <option value="fxsks">FXSKS</option>
<option value="fxols">FXOLS</option>
- <option value="fxsls">FXSLS</option>
+ <!--<option value="fxsks">FXSKS</option>
+ <option value="fxsls">FXSLS</option>-->
</select>
</TD>
</TR>
@@ -585,7 +699,16 @@
</select>
</TD>
</TR>
-
+
+ <TR> <TD align="right" valign=top>Channels:</TD>
+ <TD> <table border=0 cellpadding=2 cellspacing=1>
+ <tr> <td> Use : <select id="edit_DefinedChans"></select> </td> </tr>
+ <tr> <td> From : <span id="edit_labelZapchan"></span> </td> </tr>
+ <tr> <td> Reserved : <span id="edit_labelReserved"></span> </td> </tr>
+ </table>
+ </TD>
+ </TR>
+
<TR> <TD colspan=2 align=center height=50 valign=middle>
<input type="button" id="save_a" value="Update" onclick="updateSpanInfo();">
<input type="button" id="cancel_a" value="Cancel" onclick="canelSpanInfo();">
Modified: branches/asterisknow/config/incoming.html
URL: http://svn.digium.com/view/asterisk-gui/branches/asterisknow/config/incoming.html?view=diff&rev=1721&r1=1720&r2=1721
==============================================================================
--- branches/asterisknow/config/incoming.html (original)
+++ branches/asterisknow/config/incoming.html Wed Oct 24 11:14:23 2007
@@ -35,7 +35,8 @@
}
user_callbacks.format = function(t, x) {
- var tmp = asterisk_guiTDPrefix + t.name ;
+ var tmp = asterisk_guiTDPrefix + t.name ;
+ if (t.fieldbyname['fxochannels']){ return false; }
if ( ( t.fieldbyname['context'] == tmp ) && x == undefined ) {
didtrunks[tmp] = new Object();
didtrunks[tmp].trunkname = t.fieldbyname['trunkname'] ;
@@ -56,6 +57,8 @@
// parse all contexts in extensions.conf that look like [DID_trunk_x]
// and show each entry in the table
numplan_callbacks.format = function(t, x) {
+ if((typeof didtrunks[t.name] == "undefined") && t.name.contains('_span_')){ return false; }
+
if ((t.name == specialcontext && x != undefined )){
var p = format_extension( _$('extensions'), t, x) ;
if ( p != null ){
More information about the asterisk-gui-commits
mailing list