pari: branch asterisknow r1683 - in /branches/asterisknow/config: ./ scripts/
SVN commits to the Asterisk-GUI project
asterisk-gui-commits at lists.digium.com
Fri Oct 12 11:53:41 CDT 2007
Author: pari
Date: Fri Oct 12 11:53:40 2007
New Revision: 1683
URL: http://svn.digium.com/view/asterisk-gui?view=rev&rev=1683
Log:
merge digital stuff from trunk
Modified:
branches/asterisknow/config/digital.html
branches/asterisknow/config/scripts/astman.js
branches/asterisknow/config/trunks.html
Modified: branches/asterisknow/config/digital.html
URL: http://svn.digium.com/view/asterisk-gui/branches/asterisknow/config/digital.html?view=diff&rev=1683&r1=1682&r2=1683
==============================================================================
--- branches/asterisknow/config/digital.html (original)
+++ branches/asterisknow/config/digital.html Fri Oct 12 11:53:40 2007
@@ -23,887 +23,577 @@
<script src="scripts/tooltip.js"></script>
<link href="stylesheets/schwing.css" media="all" rel="Stylesheet" type="text/css" />
<style>
- .tr0 {
- background-color: #efaa50;
- color: white;
- font-weight: bold;
- }
-
- .tr1 {
- background-color: #6b79a5;
- color: white;
- font-weight: bold
- }
-
- .tr2 {
- background-color: white;
- color: black;
- text-decoration: underline;
- }
-
- .tr3 {
- background-color: red;
- color: black;
- text-decoration: underline;
- }
-
-
- .tr0 td, .tr1 td, .tr2 td, .tr3 td {
- font-size: xx-small;
- }
.taglist {
border: 1px solid #666666;
- margin-top:40px; margin-bottom:30px;
- }
+ margin-top:10px;
+ margin-bottom:10px;
+ max-width: 745;
+ }
+
+ .taglist tr.frow {
+ background-color: #6b79a5;
+ color: #CED7EF;
+ }
+
+ .taglist tr.even {
+ background-color: #DFDFDF;
+ }
+
+ .taglist tr.odd{
+ background-color: #FFFFFF;
+ }
+
+ .taglist tr.even:hover, .taglist tr.odd:hover {
+ background-color: #a8b6e5;
+ }
+
+ #errmsg{
+ border: 1px solid #666666;
+ margin-left:50px;
+ margin-right:50px;
+ padding : 20px 10px 20px 10px;
+ font-size: 125%;
+ text-align: center;
+ background-color:#FFFFFF;
+ }
+
+ .pageheading{
+ padding : 10px 10px 10px 10px;
+ font-size: 135%;
+ text-align: center;
+ font-weight: bold;
+ }
+</style>
+<script>
+var SPANS = {};
+var oldSpanCount = 0; // we get this from previuos applyzap.conf
+var oldLoadZone;
+var menu ; // document.getElementById('mymenu');
+
+function hide_mymenu(){ menu.style.display="none"; }
+
+function canelSpanInfo(){
+ _$('edit_span').style.display = "none";
+ _$('bg_transparent').style.display = "none";
+}
+
+function preparemenus(){
+ menu.style.width="80";
+ menu.style.borderColor = "#eee #bbb #bbb #ddd";
+ ASTGUI.events.add( document.body , "click", function(){ menu.style.display="none"; } );
+
+ 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'];
+
+ ASTGUI.selectbox.clear( _$('editspan_fac') );
+
+ if ( Number(SPANS[l]['totchans']) <= 24 ){
+ ASTGUI.selectbox.append(_$('editspan_fac'),'ESF/B8ZS', 'ESF/B8ZS');
+ ASTGUI.selectbox.append(_$('editspan_fac'),'D4/AMI', 'D4/AMI');
+ }else{
+ ASTGUI.selectbox.append(_$('editspan_fac'),'CAS/AMI', 'CAS/AMI');
+ ASTGUI.selectbox.append(_$('editspan_fac'),'CCS/HDB3', 'CCS/HDB3');
+ ASTGUI.selectbox.append(_$('editspan_fac'),'CCS/CRC4/HDB3', 'CCS/CRC4/HDB3');
+ }
+
+ ASTGUI.selectbox.selectOption( _$('editspan_fac') , SPANS[l]['fac'] );
+
+ _$('editspan_channels').innerHTML = String(SPANS[l]['usedchans']) + "/" + String(SPANS[l]['totchans']) + " ("+SPANS[l]['spantype']+")";
- .taglist tbody tr td {
- font-family: "lucida grande", verdana, sans-serif;
- font-size: 8pt;
- padding: 3px 8px;
- border-left: 1px solid #D9D9D9;
- }
-
- .taglist tbody tr.selected td {
- background-color: #3d80df;
- color: #ffffff;
- font-weight: bold;
- border-left: 1px solid #346DBE;
- border-bottom: 1px solid #7DAAEA;
- }
-
- .navcontainer{
- margin: 5px 10px 5px 10px;
- }
-
- .navlist
- {
- margin: 0;
- padding: 0 0 20px 10px;
- border-bottom: 1px solid #000;
- }
-
- .navlist ul, .navlist li
- {
- margin: 0;
- padding: 0;
- display: inline;
- list-style-type: none;
- }
-
- .navlist a:link, .navlist a:visited
- {
- float: left;
- line-height: 14px;
- font-weight: bold;
- margin: 0 10px 4px 10px;
- text-decoration: none;
- color: #999;
- font-size: 120%;
- font-family : Verdana, Arial, Helvetica, sans-serif;
- }
-
- .navlist a.current:link , .navlist a.current:visited , .navlist a.current:hover
- {
- border-bottom: 4px solid #000;
- padding-bottom: 2px;
- background: transparent;
- color: #000;
- }
-
- .navlist a:hover {
- color: #CC0000;
- cursor: pointer;
- }
-
-
-</style>
-
-<script>
-
-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. */
-var total_spans = 0; /* Count of our spans that ztscan.conf says we have */
-var old_zap = 0;
-var isrefresh = 0;
-var widgets = {};
-var zap_settings = [ 'switchtype', 'signalling', 'echocancel', 'echocancelwhenbridged', 'rxgain', 'txgain', 'group' ];
-var fieldnames_clickable = [ 'fac', 'lbo', 'syncsrc', 'totchans' ];
-var fieldnames_clickable_zap = [ 'fac', 'syncsrc', 'totchans' ];
-var fieldnames = [ 'alarms', 'syncsrc', 'description', 'totchans', 'fac', 'lbo' ];
-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"];
-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)" ];
-
-/* This page is based off of sample.html, the gui tutorial on writing a page */
-
-/* Function used in the GUI to show and hide the different tabs we defined, pretty basic. */
-function show_window(x){
- for(i=0; i < tabs.length ; i++){
- _$(tabs[i]).className = "tab";
- }
- _$(tabs[x]).className = "tabselected";
- _$(tabs[x]).blur();
-
- /* Traverse through the tabs to see which one we want to display. */
- if(divs_tohide[x]) {
- var divs_toshow = new Array(divs_tohide[x]);
- /* Here we will declare divs to show as whatever element in the array is the tab we want to show! */
- } else {
- return false;
- /* We did not find the tab that we were called to show. */
- }
-
- /* Here we will hide all of our divs that we do not want to show, and then show our last div. */
- for(var i=0; i < divs_tohide.length; i++ ) {
- _$(divs_tohide[i]).style.display = "none";
- }
- for(var i=0; i < divs_toshow.length; i++ ) {
- _$(divs_toshow[i]).style.display = "";
- }
-
- return true;
-}
-
-zt_cb.format = function(t) {
- return t.fieldbyname['alarms'];
-};
-
-zt_cb.loaded = function() {
- loadCardsintoTable();
- 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'] ;
+ if( SPANS[l]['signalling'] ){
+ ASTGUI.selectbox.selectOption( _$('editspan_signalling') , SPANS[l]['signalling'] );
}else{
- allow_aliasextns = 'no' ;
+ _$('editspan_signalling').selectedIndex = -1 ;
}
- 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;
+ disablEnable_sc();
+ if(SPANS[l]['switchtype']){
+ ASTGUI.selectbox.selectOption( _$('editspan_switchtype') , SPANS[l]['switchtype'] );
+ }else{
+ _$('editspan_switchtype').selectedIndex = -1 ;
}
- }
-
- 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);
+ ASTGUI.selectbox.selectOption( _$('editspan_syncsrc') , SPANS[l]['syncsrc'] );
+ ASTGUI.selectbox.selectOption( _$('editspan_lbo') , SPANS[l]['lbo'] );
+ _$('edit_span').style.display = "";
+ _$('bg_transparent').style.display = "";
+ };
+
+ var menuitem1 = document.createElement('div');
+ menuitem1.innerHTML = "Edit" ;
+ menuitem1.onclick = function(){ hide_mymenu(); editSPAN( this.parentNode.span_value); };
+ menu.appendChild(menuitem1);
+}
+
+function show_downmenu(s){
+ var a = _$("span_"+s);
+ menu.span_value = s ;
+ ASTGUI.alignBbelowA(a,menu);
+ setTimeout( function(){ menu.style.display=""; } , 100 );
+}
+
+function showtable(){ // navigates through the SPANS object and presents as a table to the user
+ var tbl = _$('digitalcardstable') ;
+
+ var add_fRow = function(){
+ var newRow = tbl.insertRow(-1);
+ newRow.className = "frow";
+
+ var newCell0 = newRow.insertCell(0);
+ newCell0.innerHTML = "SPAN";
+
+ var newCell1 = newRow.insertCell(1);
+ newCell1.innerHTML = "ALARMS";
+
+ var newCell2 = newRow.insertCell(2);
+ newCell2.innerHTML = "Framing/Coding";
+
+ var newCell3 = newRow.insertCell(3);
+ newCell3.innerHTML = "channels<BR>Used/Total" ;
+ newCell3.align = "center";
+
+ var newCell4 = newRow.insertCell(4);
+ newCell4.innerHTML = "Signalling" ;
+ newCell4.align = "center";
+
+ var newCell5 = newRow.insertCell(5);
+ newCell5.innerHTML = "" ;
+
+ };
+
+ var addrow_totable = function(span){
+ var sno = tbl.rows.length + 1;
+ var newRow = tbl.insertRow(-1);
+ newRow.className = ((tbl.rows.length)%2==1)?"odd":"even";
+
+ newRow.id ="row" + span ;
+ newRow["span_value"] = span;
+
+ var newCell0 = newRow.insertCell(0);
+ newCell0.innerHTML = SPANS[span]['description'] + " ";
+ newCell0.align = "center";
+
+ var newCell1 = newRow.insertCell(1);
+ newCell1.innerHTML = SPANS[span]['alarms'];
+ newCell1.align = "center";
+
+ var newCell2 = newRow.insertCell(2);
+ newCell2.innerHTML = SPANS[span]['fac'];
+
+ var newCell3 = newRow.insertCell(3);
+ newCell3.innerHTML = String(SPANS[span]['usedchans'])+"/"+String(SPANS[span]['totchans'])+" ("+SPANS[k]['spantype']+")";
+ newCell3.align = "center";
+
+ var newCell4 = newRow.insertCell(4);
+ newCell4.innerHTML = (SPANS[span]['signalling'])?SPANS[span]['signalling'] : "<font color=red>NOT DEFINED</font>" ;
+ newCell4.align = "center";
+
+
+ var newCell5 = newRow.insertCell(5);
+ newCell5.innerHTML = "<span class=\"downmenubutton\" id='" + "span_" + span + "' onclick=\"show_downmenu( '"+ span + "');\">Options <img src=images/1.gif></span>" ;
+ newCell5.style.width = 90;
+ newCell5.align = "center";
+ };
+
+ ASTGUI.domActions.clear_table(tbl);
+ add_fRow();
+ for( var k in SPANS ){ if( SPANS.hasOwnProperty(k) ){ addrow_totable(k); }}
+
+}
+
+function localajaxinit(){
+ menu = document.getElementById('mymenu');
+ setWindowTitle("Digital Setup Wizard");
+ top._$('mainscreen').width= 798;
+ _$('save_b').disabled = true;
+ _$('cancel_b').disabled = true;
+
+ ASTGUI.events.add( _$('loadZone') , "change" , function(){_$('save_b').disabled = false; _$('cancel_b').disabled = false;}) ;
+
+ showdiv_statusmessage(); // create status message dialog
+ _$('message_text').innerHTML = "Detecting Digital Cards ... (Beta)";
+ _$('status_message').style.display="block";
+ setTimeout(function(){ _$('status_message').style.display='none';}, 1000);
+ preparemenus();
+ parent.loadscreen(this);
+ loadConfigFiles.readApplyzap();
+}
+
+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
+ // 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
+
+ readApplyzap: function(){
+
+ var applyZapParse = function(n){ // read applyzap.conf
+ if( ASTGUI.checkType.isString(n) && n=="ERROR: CONFIG FILE NOT FOUND" ){
+ // applyzap.conf not found - probably running this page for the first time
+ // touch applyzap.conf - we need to have a file to be a able to write to it
+ oldSpanCount = 0;
+ oldLoadZone ='us';
+ setTimeout( function(){ parent.astmanEngine.run_tool("/bin/touch /etc/asterisk/applyzap.conf", function(){} ); } , 100);
+
+ }else{
+ try{
+ for (var i=0; i < n['general'].length; i++){
+ if( n['general'][i].beginsWith('span=') ){ oldSpanCount++; continue; }
+ if( n['general'][i].contains('loadzone=') ){
+ oldLoadZone = n['general'][i].split('loadzone=')[1];
+ ASTGUI.selectbox.selectOption( _$('loadZone') , oldLoadZone );
+ continue;
+ }
+
+ }
+ }catch(err){
+
+ }
}
- }
- 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");
- e.innerHTML = "";
- var d = document.createElement("TABLE");
- d.style.overflow = "scroll" ;
- var tr = document.createElement("tr");
- tr.className = "tr2";
- for(var i=0;i<=records[offset].length;i++) {
- var td = document.createElement("td");
- td.appendChild(document.createTextNode(fields[i]));
- tr.appendChild(td);
- }
- d.appendChild(tr);
- for(var i=0;c--&&isset(records[i+offset]);i++) {
- var tr = document.createElement("tr");
- tr.className = "tr"+(i%2);
- var r = records[i+offset];
-
- for(var j=-1;j<r.length;j++) {
-
- if(r[(j + 4)])
- var dest_context = (r[j + 4].toString().replace(/^[\"]{1}/, "").replace(/[\"]{1}$/, "")) ? r[j + 4].toString().replace(/^[\"]{1}/, "").replace(/[\"]{1}$/, "") : 'none';
- if(dest_context == "asterisk_guitools") {
- j += fields.length-3;
- /* go to next cdr record, which is exact 21 csvs away, so count the csv field names, and subtract 3, since we only added 4, and started with -1 */
- continue;
- }
- var td = document.createElement("td");
- if (j < 0) {
- var l = offset+i+1;
- } else {
- var l = r[j].toString().replace(/^[\"]{1}/, "").replace(/[\"]{1}$/, "");
- }
- td.appendChild(document.createTextNode(l));
- tr.appendChild(td);
- }
- d.appendChild(tr);
- }
- e.appendChild(d);
-}
-
-function refresh_alarms() {
- _$('status_message').style.display="block";
- setTimeout("_$('status_message').style.display='none'", 5000);
- _$('message_text').innerHTML = "Re-Detecting Digital Cards and Alarms... ";
- /* Give ztscan 4 seconds to detect and write to ztscan.conf */
- isrefresh = 1;
- parent.astmanEngine.run_tool(asterisk_guiZtscan, function(t) {
- setTimeout('load_config_tool()', 4000);
- });
-
-}
-
-function create_table_names() {
- var box = _$('digitalcardstable');
- var tr = document.createElement("tr");
- tr.className="tr1";
- for(var i=0; i < fieldnames_proper.length; i++) {
- var td = document.createElement("td");
- td.appendChild(document.createTextNode(fieldnames_proper[i]));
- td.setAttribute("tip", 'en,digital,'+fieldnames_proper[i]);
- tr.appendChild(td);
- }
- box.appendChild(tr);
- return true;
-
-}
-
-function create_table_options() {
- return true;
- /* I am not sure what I want to do here yet, whether give the user the option to configure all zaptel.conf related stuff...or not */
- var box = _$('digitalcardstable');
- var tr = document.createElement("tr");
- tr.className="tr3";
- for(var i=0; i < fieldnames_zap_opts.length; i++) {
- var td = document.createElement("td");
- td.appendChild(document.createTextNode(fieldnames_zap_opts[i]));
- td.setAttribute("id", fieldnames_zap_opts[i]);
- tr.appendChild(td);
- }
- box.appendChild(tr);
- return true;
-
-}
-
-function isInt(x) {
- var y=parseInt(x);
- if (isNaN(y)) return false;
- return x==y && x.toString()==y.toString();
-}
-
-function run_zt_and_restart() {
- /* this function will run ztcfg and reload the page. */
- parent.needs_reloadzap = 1;
- gui_feedback("Save Completed.", 'blue');
-
-}
-
-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 ZAPTEL = new Object;
- 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_zap.length; x++) {
- var tmp_id = i+'-'+fieldnames_clickable_zap[x]+'-sel';
- var tmp_b = _$(tmp_id);
- ZAPTEL[i].en[fieldnames_clickable_zap[x]] = tmp_b.options[tmp_b.selectedIndex].value;
- // 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":
- 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;
- }
- }
-
- 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);
- return true;
-}
-
-function digitalparse(n) {
-
- var l, h;
- var box = _$('digitalcardstable');
- if(isrefresh == 1) {
- /* We want to reset our table, so that we do not append to it. */
- box.innerHTML = "";
- }
- var _class = 0;
- for( l in n ){ if(n.hasOwnProperty(l)){
- if( l =='general') {
- if(n[l]['continue'] && n[l]['continue'] == "no") {
- _$('error_txt').style.display="";
- _$('error_txt').innerHTML="<br><br>Problem Detecting/No Cards(or spans) Found!<br><br> Error: " + n[l]['error'];
- has_spans=0;
- _$('tablecontainer').style.display="none";
- _$('tablecontainer').style.visibility="none";
-
+ loadConfigFiles.runZtscan(); // to next step - run ztscan and read ztscan.conf
+ };
+ config2json("applyzap.conf", 0, applyZapParse);
+ },
+
+ runZtscan: function(){
+ parent.astmanEngine.run_tool(asterisk_guiZtscan, function(t) { // run ztscan and then try loading ztscan.conf
+ setTimeout( function(){ loadConfigFiles.readZtscanConf(); } , 700); // leave some time for ztscan to generate ztscan.conf
+ });
+ },
+
+ readZtscanConf:function(){
+ var digitalparse = function(n){
+ if( n == "ERROR: CONFIG FILE NOT FOUND"){
+ _$('errmsg').innerHTML = "Please check if <B>ztscan</B> is installed ? <BR> /etc/asterisk/ztscan.conf not found";
+ _$('errmsg').style.display = '';
+ _$('div_digitalcardstable').style.display = 'none';
+ gui_feedback("No Cards/Spans found, No Config File found !!");
+ //_$('tablecontainer').style.display="none";
return false;
}
- if(n[l]['continue'] && n[l]['continue'] == "yes") {
- total_spans = (n[l]['totalspans']) ? n[l]['totalspans'] : 'Unknown';
- for(var z=0; z < total_spans; z++) {
- SPANS[(1 + z)] = new Object;
- }
- has_spans=1;
- if(n[l]['isnew'] && n[l]['isnew'] == "yes") {
- var uri = build_action('update', 0, 'general', 'isnew', 'no', '');
- makerequest('u','ztscan.conf', uri, function(t){ return true;} );
- }
- create_table_names();
- }
- }
- if(isInt(l)) {
- var tr = document.createElement("tr");
- if(_class == 0) {
- tr.className = "tr0";
- _class = 1;
- } else {
- tr.className = "tr1";
- _class = 0;
- }
- /* if alarms is red, make cell red, else make cell green/yellow etc. */
- SPANS[l].en = new Array;
- for(var i=0; i < fieldnames.length; i++) {
- var td = document.createElement("td");
- /* save our information for global use... */
- SPANS[l].en[fieldnames[i]] = n[l][fieldnames[i]];
- /* dumb hack because we cannot use multidimentional arrays */
- if(fieldnames[i] == 'lbo' && n[l][fieldnames[i]] == "NODEF") {
- old_zap = 1;
- td.appendChild(document.createTextNode("N/A"));
- tr.appendChild(td);
+
+ for( var l in n ){ if(n.hasOwnProperty(l)){
+ if( l =='general') {
+ if(n[l]['continue'] && n[l]['continue'] == "no") {
+ _$('errmsg').innerHTML = "No digital Cards detected (found 0 spans)! <BR> Error: " + n[l]['error'];
+ _$('errmsg').style.display = '';
+ _$('div_digitalcardstable').style.display = 'none';
+ gui_feedback("No Cards/Spans found !!");
+ //_$('tablecontainer').style.display="none";
+ return false;
+ }
+ if(n[l]['continue'] && n[l]['continue'] == "yes") {
+ //var t = (n[l]['totalspans']) ? n[l]['totalspans'] : 'Unknown';
+ if(n[l]['isnew'] && n[l]['isnew'] == "yes") {
+ var uri = build_action('update', 0, 'general', 'isnew', 'no', '');
+ makerequest('u','ztscan.conf', uri, function(t){ return true;} );
+ }
+ }
continue;
}
- if(fieldnames[i] == 'fac') {
- if(n[l][fieldnames[i]] == "NODEF") {
- old_zap = 1;
- td.appendChild(document.createTextNode("N/A"));
- tr.appendChild(td);
- continue;
+ SPANS[l] = {};
+ for( var k in n[l] ){ if(n[l].hasOwnProperty(k)){
+ SPANS[l][k] = n[l][k];
+ if( k == 'totchans' ){
+ SPANS[l]['spantype'] = ( Number(n[l][k]) <= 24) ? "T1" : "E1";
}
- var framing = n[l][fieldnames[i]].split("/");
- if(framing[0] == "ESF" || framing[0] == "D4") {
- td.appendChild(document.createTextNode(n[l][fieldnames[i]] + " (T1)"));
- td.setAttribute("id", l + '-' + fieldnames[i]);
- tr.appendChild(td);
- continue;
- } else {
- td.appendChild(document.createTextNode(n[l][fieldnames[i]] + " (E1)"));
- td.setAttribute("id", l + '-' + fieldnames[i]);
- tr.appendChild(td);
- continue;
+ }}
+ }}
+ loadConfigFiles.checkHardwareChanges();
+ };
+ config2json("ztscan.conf", 1, digitalparse);
+ },
+
+ checkHardwareChanges: function(){
+ var usersparse = function(n){ // read users.conf and load switchtype, signalling, zapchan into the SPANS object
+ if( n == "ERROR: CONFIG FILE NOT FOUND"){
+ _$('errmsg').innerHTML = "/etc/asterisk/users.conf not found";
+ _$('errmsg').style.display = '';
+ _$('div_digitalcardstable').style.display = 'none';
+ gui_feedback("No Users File found !!");
+ //_$('tablecontainer').style.display="none";
+ return false;
+ }
+ 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]; }}
+ }
+ }}
+ }();
+ showtable();
+ };
+ config2json("users.conf", 1, usersparse);
+ }
+};
+
+
+
+function resetmainscreen(){ top._$('mainscreen').width= 540; }
+
+function reloadpage(){ window.location.href="digital.html"; }
+
+function disablEnable_sc() {
+ if( _$('editspan_signalling').value.beginsWith('fx') ){
+ _$('editspan_switchtype').disabled = true;
+ _$('editspan_switchtype').selectedIndex = -1;
+ }else{
+ _$('editspan_switchtype').disabled = false;
+ }
+ return true;
+}
+
+function updateSpanInfo(){
+ var b = String( menu.span_value );
+ SPANS[b]['fac'] = _$('editspan_fac').value;
+ SPANS[b]['signalling'] = _$('editspan_signalling').value;
+ SPANS[b]['switchtype'] = _$('editspan_switchtype').value;
+ SPANS[b]['syncsrc'] = _$('editspan_syncsrc').value;
+ SPANS[b]['lbo'] = _$('editspan_lbo').value;
+ canelSpanInfo();
+ _$('save_b').disabled = false;
+ _$('cancel_b').disabled = false;
+}
+
+var applySettings = {
+ generate_zaptel: function(){
+ parent.astmanEngine.run_tool(asterisk_guiEditZap + " applysettings", function(t) {
+ /* anything we need to do here? */
+ // inform the user to restart
+ alert("You need to restart your machine for these settings to take effect");
+ window.location.href= "digital.html";
+ return true;
+ });
+ /* to run ztcfg and apply settings, you can do this call, but replace applysettings with ztcfg.
+ You can then read /var/lib/asterisk/static-http/config/ztcfg_output.html to look at ztcfg errors */
+ },
+
+ updateUsersConf: function(){
+ /* update the users.conf to make sure there are corresponding [SPAN_x] contexts are updated */
+
+ var uri1 = [];
+ var uri2 = '';
+ var add_lines = function(){
+ // for each span update span with new values of 'switchtype', 'singalling'
+ var c = 0, d ='', e ='', f=0, uri = '';
+ for( var k in SPANS ){ if( SPANS.hasOwnProperty(k) ){ if(SPANS[k]['signalling']){
+ uri = '', c=0;
+ d = 'span_'+ String(k);
+ e = asterisk_guiTDPrefix + d ;
+ uri += build_action('delcat', c, d , "", ""); c++;
+ 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++;
+
+ uri2 += build_action('delete', f, 'globals', d, "", ""); f++;
+ uri2 += build_action('update', f, 'globals', d,'Zap/g'+String(k)); f++;
+ uri2 += build_action('delcat', f, e , "", ""); f++;
+ uri2 += build_action('newcat', f, e , "", ""); f++;
+ uri2 += build_action('update', f, e , 'include', 'default'); f++;
+
+ uri1.push(uri);
+ }}}
+ }();
+
+ var something = function(){
+ if(uri1.length){
+ makerequest('u', "users.conf", uri1.shift() , function(t) { something(); } );
+ }else{
+ makerequest('u', "extensions.conf", uri2 , function(t) { applySettings.generate_zaptel(); });
+ }
+ };
+ something();
+ },
+
+ updateZaptel: function(){
+ // navigate through the SPANS object and save it to the applyzap.conf,
+ // 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' ;
+ 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? */
+ /* LBO is being set to 0 */
+ secondpart = k + "," + SPANS[k]['syncsrc'] + "," + SPANS[k]['lbo'] + "," + SPANS[k]['fac'].toLowerCase().replace("/", ",");
+ uri += build_action('append', c, context, firstpart, secondpart ); c++;
+ tmp2 = (bchanstring)? ",":"";
+
+ if ( SPANS[k]['signalling'].beginsWith('fx') ){
+ bchanstring += '';
+ dchanstring += '';
+ tmp = totalchans + Number(SPANS[k]['totchans']);
+ tmp3 = String(totalchans+1) + "-" + String(tmp);
+ totalchans = tmp;
+ }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);
}
}
- if(fieldnames[i] == 'alarms') {
- if(n[l][fieldnames[i]] == "UNCONFIGURED") {
- gui_alert("Span " + (i+1) + " is unconfigured, running ztscan.");
- run_zt_and_restart();
- }
- switch(n[l][fieldnames[i]]) {
- case "OK":
- td.setAttribute("style", 'color:green');
- td.style.color == "green";
- break;
- case "YEL/REC":
- td.setAttribute("style", 'color:yellow');
- break;
- default:
- td.className = "tr3";
- break;
- }
- }
- if(fieldnames[i] == 'totchans') {
- 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";
- }
- }
- td.appendChild(document.createTextNode(n[l][fieldnames[i]]));
- td.setAttribute("id", l + '-' + fieldnames[i]);
- tr.appendChild(td);
- }
- box.appendChild(tr);
- }
- }}
- if(old_zap == 1) {
- gui_alert("To have the ability to see your cards current configuration/framing/coding/line build out, please install rev: 2986 or higher of the 1.4 branch of zaptel!");
- parent._$('tooltip').innerHTML = "<B>Framing/Coding/Line Build Out:</B><br>To see this requires rev: 2986 of the 1.4 branch of zaptel.";
- }
-
- create_table_options(); /* create zaptel.conf general options */
- _$('tablecontainer').style.display="";
- _$('tablecontainer').style.visibility="";
- _$('status_message').style.display='none';
- _$('save_changes_id').style.display="";
- 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 <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() {
- for(var i=1; i < (total_spans + 1); i++ ){
- for(var x=0; x < fieldnames_clickable.length; x++) {
- if(fieldnames_clickable[x] == "fac") {
- var tmp_sel = "";
- for(var y=0; y < framing_and_coding.length; y++) {
- tmp_sel += '<option value='+framing_and_coding[y]+'>'
- tmp_sel += framing_and_coding_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;
- }
- }
- if(fieldnames_clickable[x] == "lbo") {
- var tmp_sel = "";
- for(var y=0; y < line_build_out.length; y++) {
- tmp_sel += '<option value='+line_build_out[y]+'>'
- tmp_sel += line_build_out_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;
- }
-
- }
- if(fieldnames_clickable[x] == "syncsrc") {
- var tmp_sel = "<option value='0'>0</option>";
- var ll = (parseInt(total_spans) + 1);
- for(var y=1; y < ll; y++) {
- tmp_sel += '<option value='+y+'>'
- tmp_sel += 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;
- }
-
- }
- 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;
-}
-
-/* function to select the proper framing/coding || lbo and sync source as specified */
-function select_correct_index() {
- var find_index = function(el,val,sec) {
- for(var t=0; t < el.options.length; t++) {
- if(sec == 'fac') {
- var l = val.toLowerCase();
- l = l.replace('/', ',');
- if(el.options[t].value == l) { el.selectedIndex = t; break; }
- } else {
- if(el.options[t].value == val) { el.selectedIndex = t; break; }
- }
- }
- }
-
- 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';
- 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 */
- _$('status_message').style.display="block";
- _$('status_message').innerHTML = '<TABLE border=0 cellpadding=0 cellspacing=4 align=center><TR><TD><img src="/asterisk/static/config/images/loading.gif"></TD><TD><div id=message_text></div></TD></TR></TABLE>';
- _$('message_text').innerHTML = "Time: <div id='counter'>10</div>Are you sure you want to apply settings to zaptel.conf and restart zaptel? (run ztcfg)<BR>1. <A href=\"#\" class=\"splbutton\" onclick=\"_$('status_message').style.display='none'; get_params_and_ztcfg();\">Yes</A><br>2. <A href=\"#\" class=\"splbutton\" onclick=\"_$('status_message').style.display='none'; gui_feedback('You Chose not to save your settings.', 'red');>No<br></a>";
- setTimeout("_$('status_message').style.display='none';", 10000);
- int_handle = setInterval("_$('counter').innerHTML = (_$('counter').innerHTML - 1);", 1000);
[... 424 lines stripped ...]
More information about the asterisk-gui-commits
mailing list