pari: branch 2.0 r4021 - /branches/2.0/config/paging.html
SVN commits to the Asterisk-GUI project
asterisk-gui-commits at lists.digium.com
Tue Oct 28 17:48:02 CDT 2008
Author: pari
Date: Tue Oct 28 17:48:02 2008
New Revision: 4021
URL: http://svn.digium.com/view/asterisk-gui?view=rev&rev=4021
Log:
more progress on 'Paging & Intercom'
Modified:
branches/2.0/config/paging.html
Modified: branches/2.0/config/paging.html
URL: http://svn.digium.com/view/asterisk-gui/branches/2.0/config/paging.html?view=diff&rev=4021&r1=4020&r2=4021
==============================================================================
--- branches/2.0/config/paging.html (original)
+++ branches/2.0/config/paging.html Tue Oct 28 17:48:02 2008
@@ -59,6 +59,373 @@
*/
+var isNewPgGrp;
+var PgGrp_EDITING; // page group being edited
+var listOfDialDevices = [];
+var loadDOMelements = function(){
+ DOM_pagegroup_editdiv = _$('pagegroup_editdiv');
+ DOM_table_pageGroups_list = _$('table_pageGroups_list');
+
+
+
+ DOM_text_pageGroup_Exten = _$('text_pgExten');
+ DOM_select_pageGroup_Type = _$('select_pg_type');
+ DOM_chk_pageGroup_beep = _$('chk_pgrp_beep');
+
+ DOM_select_ringthesechannels = _$('select_ringthesechannels');
+ DOM_select_fromlistofchannels = _$('select_fromlistofchannels');
+ DOM_button_addall_toringlist = _$('button_addall_toringlist');
+ DOM_button_add_toringlist = _$('button_add_toringlist');
+ DOM_button_remove_fromringlist = _$('button_remove_fromringlist');
+ DOM_button_removeall_fromringlist = _$('button_removeall_fromringlist');
+
+
+};
+
+var save_pageGroup = function(){
+ if ( !ASTGUI.checkRequiredFields([DOM_text_pageGroup_Exten, DOM_select_pageGroup_Type]) ){
+ return ;
+ }
+ if ( !ASTGUI.validateFields([DOM_text_pageGroup_Exten]) ){
+ return ;
+ }
+
+ var TEMP_members = ASTGUI.selectbox.readAllValues(DOM_select_ringthesechannels) ;
+ if( !TEMP_members.length ){
+ ASTGUI.highlightField(DOM_select_ringthesechannels, 'You need to have at least one member in the Page/Intercom group !!');
+ parent.ASTGUI.dialog.hide();
+ return;
+ }
+
+ var PAGE_EXTEN = ASTGUI.getFieldValue( DOM_text_pageGroup_Exten );
+ if( !isNewPgGrp ){ // if editing existing ring group
+ parent.astgui_manageRingGroups.deleteRg(PgGrp_EDITING) ;
+ }else{ // if is a new ring group
+ if( parent.miscFunctions.ifExtensionAlreadyExists(PAGE_EXTEN) ){
+ ASTGUI.highlightField(DOM_text_pageGroup_Exten , 'Extension already exists');
+ parent.ASTGUI.dialog.hide();
+ return;
+ }
+
+ // if( !ASTGUI.miscFunctions.isExtensionInRange( PAGE_EXTEN , 'rge_start' , 'rge_end' ) ){
+ // ASTGUI.highlightField(DOM_text_pageGroup_Exten, 'Extension is not in preferred range');
+ // parent.ASTGUI.dialog.hide();
+ // return;
+ // }
+ }
+
+ var tmp_options = [];
+ if ( ASTGUI.getFieldValue(DOM_select_pageGroup_Type) == '2way' ){ tmp_options.push('d'); }
+ if ( !DOM_chk_pageGroup_beep.checked ){ tmp_options.push('q'); }
+
+ var tmp_new_line = PAGE_EXTEN + ',1,Macro(pagingintercom|' + TEMP_members.join('&') + '|'+ tmp_options.join('') + ')' ;
+
+ var later = function(){
+ var msg = ( isNewPgGrp ) ? 'New Page/Intercom Group Created' : 'Page/Intercom Group Updated';
+ ASTGUI.feedback({msg: msg, showfor:2});
+ parent.ASTGUI.dialog.hide();
+ window.location.reload();
+ };
+
+ parent.ASTGUI.dialog.waitWhile(' Saving... ');
+ parent.astgui_managePageGroups.addPageGroup( tmp_new_line, later );
+};
+
+
+var resetFields = function(){
+
+ if(isNewPgGrp){
+ _$('rgedit_form_caption').innerHTML = 'New RingGroup';
+ DOM_text_rgname.value = '';
+ //DOM_select_strategy.selectedIndex = -1 ;
+ ASTGUI.selectbox.clear( DOM_select_ringthesechannels );
+ ASTGUI.selectbox.clear( DOM_select_fromlistofchannels );
+ listOfDialDevices.each(function(device){
+ var tmp_ext = device.afterChar('/');
+ var tmp_techn = device.beforeChar('/');
+
+ if( tmp_techn.toLowerCase() == 'zap' ){
+
+ var this_analogStation_user = '';
+ for ( var q in parent.sessionData.pbxinfo.users ){ if( parent.sessionData.pbxinfo.users.hasOwnProperty(q) ){
+ if( parent.sessionData.pbxinfo.users[q].getProperty('zapchan') == tmp_ext ){
+ this_analogStation_user = q + '(AnalogPort ' + tmp_ext + ') ' + parent.sessionData.pbxinfo.users[q].getProperty('fullname') ;
+ ASTGUI.selectbox.append( DOM_select_fromlistofchannels, this_analogStation_user , device);
+ return;
+ }
+ }}
+
+ }else{
+
+ if( parent.sessionData.pbxinfo.users[tmp_ext] && parent.sessionData.pbxinfo.users[tmp_ext].fullname ){
+ var tmp_name = parent.sessionData.pbxinfo.users[tmp_ext].fullname || '?' ;
+ }else{
+ return;
+ }
+ ASTGUI.selectbox.append( DOM_select_fromlistofchannels, tmp_ext + '('+ tmp_techn +')' + ' ' + tmp_name , device);
+ }
+ });
+ DOM_text_rgExten.value = '' ;
+
+ ASTGUI.selectbox.populateArray( DOM_rg_fb_select , parent.miscFunctions.getAllDestinations() );
+ ASTGUI.resetTheseFields([ DOM_rg_fb_select , DOM_select_strategy , DOM_text_ringTime ]);
+
+ (function(){
+ var tmp_aliasextens = [];
+ var rgs_list = parent.sessionData.pbxinfo.ringgroups.getOwnProperties();
+ rgs_list.each( function(rg){
+ var c = parent.sessionData.pbxinfo['ringgroups'][rg];
+ if ( c['extension'] ){
+ tmp_aliasextens.push( c['extension'] );
+ }
+ });
+ DOM_text_rgExten.value = tmp_aliasextens.firstAvailable( parent.sessionData.GUI_PREFERENCES.getProperty('rge_start') );
+ })();
+
+ return ;
+ }
+
+ var c = parent.sessionData.pbxinfo['ringgroups'][PgGrp_EDITING];
+ DOM_text_rgname.value = c.NAME ;
+ _$('rgedit_form_caption').innerHTML = 'Edit RingGroup - ' + c.NAME ;
+ ASTGUI.selectbox.selectOption( DOM_select_strategy , c['strategy'] );
+ ASTGUI.selectbox.clear( DOM_select_ringthesechannels );
+ var mbrs = ASTGUI.cloneObject(c['members']);
+ mbrs.each(function(device){
+ var tmp_ext = device.afterChar('/');
+ var tmp_techn = device.beforeChar('/');
+
+ if( tmp_techn.toLowerCase() == 'zap' ){
+ var this_analogStation_user = '';
+ for( var q in parent.sessionData.pbxinfo.users ){ if( parent.sessionData.pbxinfo.users.hasOwnProperty(q) ){
+ if( parent.sessionData.pbxinfo.users[q].getProperty('zapchan') == tmp_ext ){
+ this_analogStation_user = q + '(AnalogPort ' + tmp_ext + ') ' + parent.sessionData.pbxinfo.users[q].getProperty('fullname') ;
+ ASTGUI.selectbox.append( DOM_select_ringthesechannels, this_analogStation_user , device );
+ return;
+ }
+ }}
+ }else{
+ var tmp_name = (parent.sessionData.pbxinfo.users[tmp_ext] && parent.sessionData.pbxinfo.users[tmp_ext].fullname) || '?';
+ ASTGUI.selectbox.append( DOM_select_ringthesechannels, tmp_ext + '('+ tmp_techn +')' + ' ' + tmp_name , device);
+ }
+ });
+
+
+ ASTGUI.selectbox.clear( DOM_select_fromlistofchannels );
+ listOfDialDevices.each(function(device){ if( ! mbrs.contains(device) ){
+ var tmp_ext = device.afterChar('/');
+ var tmp_techn = device.beforeChar('/');
+
+ if( tmp_techn.toLowerCase() == 'zap' ){
+ var this_analogStation_user = '';
+ for( var q in parent.sessionData.pbxinfo.users ){ if( parent.sessionData.pbxinfo.users.hasOwnProperty(q) ){
+ if( parent.sessionData.pbxinfo.users[q].getProperty('zapchan') == tmp_ext ){
+ this_analogStation_user = q + '(AnalogPort ' + tmp_ext + ') ' + parent.sessionData.pbxinfo.users[q].getProperty('fullname') ;
+ ASTGUI.selectbox.append( DOM_select_fromlistofchannels, this_analogStation_user , device );
+ return;
+ }
+ }}
+ }else{
+ var tmp_name = (parent.sessionData.pbxinfo.users[tmp_ext] && parent.sessionData.pbxinfo.users[tmp_ext].fullname) || '?' ;
+ ASTGUI.selectbox.append( DOM_select_fromlistofchannels, tmp_ext + '('+ tmp_techn +')' + ' ' + tmp_name , device);
+ }
+ }});
+ DOM_text_rgExten.value = (c['extension'])?c['extension']:'' ;
+ DOM_text_ringTime.value = (c['ringtime'])?c['ringtime']:'' ;
+ // select value from select box DOM_rg_fb_select
+ var destinations = parent.miscFunctions.getAllDestinations() ;
+
+ var destinations_WithOut_ThisRingGroup = [];
+ destinations.each( function( this_object ){
+ if( this_object.optionValue != 'Goto('+ PgGrp_EDITING +'|s|1)' && this_object.optionValue != 'Goto('+ PgGrp_EDITING +',s,1)' ){
+ destinations_WithOut_ThisRingGroup.push( this_object );
+ }
+ });
+ ASTGUI.selectbox.populateArray( DOM_rg_fb_select , destinations_WithOut_ThisRingGroup );
+ ASTGUI.selectbox.selectDestinationOption( DOM_rg_fb_select , ( c['fallback'] ) ? c['fallback'] : '' );
+};
+
+var delete_rg_confirm = function(d){
+ if (!confirm('Delete RingGroup ?')) { return; }
+ parent.astgui_manageRingGroups.deleteRg(d) ;
+ ASTGUI.feedback( { msg:'Ring Group deleted', showfor:2 });
+ window.location.reload();
+};
+
+var show_NewRingGroup_form = function(){
+ PgGrp_EDITING = '';
+ isNewPgGrp = true;
+ resetFields();
+ ASTGUI.feedback( { msg: 'Create New RingGroup !', showfor: 2 , color: 'green', bgcolor: '#FFFFFF' } );
+ $(DOM_pagegroup_editdiv).showWithBg();
+};
+
+var edit_rg_form = function(d){
+ PgGrp_EDITING = d;
+ isNewPgGrp = false;
+ resetFields();
+ ASTGUI.feedback( { msg: 'Edit RingGroup !', showfor: 2 , color: 'green', bgcolor: '#FFFFFF' } );
+ $(DOM_pagegroup_editdiv).showWithBg();
+};
+
+var update_RingGroupsTable = function(){
+ var addCell = ASTGUI.domActions.tr_addCell; // temporarily store the function
+ (function(){ // add first row
+ var newRow = DOM_table_pageGroups_list.insertRow(-1);
+ newRow.className = "frow";
+ addCell( newRow , { html:'', width:'10px'} );
+ addCell( newRow , { html: 'Extension' } );
+ addCell( newRow , { html:'Ring Group'} );
+ addCell( newRow , { html:'Members'} );
+ addCell( newRow , { html:''} );
+ })();
+
+ var c = parent.sessionData.pbxinfo.ringgroups ;
+ for(var d in c){if(c.hasOwnProperty(d)){
+ var newRow = DOM_table_pageGroups_list.insertRow(-1);
+ var rn = DOM_table_pageGroups_list.rows.length;
+ newRow.className = ((rn)%2==1)?'odd':'even';
+ addCell( newRow , { html: '' } );
+ addCell( newRow , { html: c[d]['extension'] } );
+ addCell( newRow , { html: c[d]['NAME'] } );
+
+ var TMP_MEMBERS = [];
+ var CDM = ASTGUI.cloneObject(c[d]['members']);
+ CDM.each(function(device){
+ var tmp_ext = device.afterChar('/');
+ var tmp_techn = device.beforeChar('/');
+
+ if( tmp_techn.toLowerCase() == 'zap' ){
+ var this_analogStation_user = '';
+ for( var q in parent.sessionData.pbxinfo.users ){ if( parent.sessionData.pbxinfo.users.hasOwnProperty(q) ){
+ if( parent.sessionData.pbxinfo.users[q].getProperty('zapchan') == tmp_ext ){
+ this_analogStation_user = q + '(AnalogPort ' + tmp_ext + ') ' + parent.sessionData.pbxinfo.users[q].getProperty('fullname') ;
+ TMP_MEMBERS.push( this_analogStation_user );
+ break;
+ }
+ }}
+ if(! this_analogStation_user ){
+ TMP_MEMBERS.push( 'AnalogPort ' + tmp_ext + ' ?' );
+ }
+ }else{
+ var tmp_name = (parent.sessionData.pbxinfo.users[tmp_ext] && parent.sessionData.pbxinfo.users[tmp_ext].fullname) || '?';
+ TMP_MEMBERS.push( tmp_ext + '('+ tmp_techn +')' + ' ' + tmp_name );
+ }
+
+
+ });
+
+ addCell( newRow , { html: TMP_MEMBERS.join(', ') } );
+ var tmp = "<span class='guiButton' onclick=\"edit_rg_form('" + d +"')\">Edit</span>" +
+ "<span class='guiButtonDelete' onclick=\"delete_rg_confirm('" + d +"')\">Delete</span>" ;
+ addCell( newRow , { html: tmp } );
+ }}
+ if(DOM_table_pageGroups_list.rows.length == 1){
+ ASTGUI.domActions.clear_table(DOM_table_pageGroups_list);
+ var newRow = DOM_table_pageGroups_list.insertRow(-1);
+ newRow.className = 'even';
+ addCell( newRow , { html:'No RingGroups defined !!'} );
+ return ;
+ }
+};
+
+
+var localajaxinit = function(){
+ top.document.title = 'Manage RingGroups' ;
+ if( !ASTGUI.miscFunctions.alertIfRangeisNotdefined('rge_start','rge_end', 'RingGroups') ){
+ $('.top_buttons').hide();
+ return;
+ }
+ loadDOMelements();
+
+ (function (){
+ var t = parent.astgui_manageusers.listOfUsers();
+ t.each(function(usr){
+ if( parent.sessionData.pbxinfo['users'][usr]['hassip'] && parent.sessionData.pbxinfo['users'][usr]['hassip'] == 'yes' ){
+ listOfDialDevices.push( 'SIP/' + usr );
+ }
+ if( parent.sessionData.pbxinfo['users'][usr]['hasiax'] && parent.sessionData.pbxinfo['users'][usr]['hasiax'] == 'yes' ){
+ listOfDialDevices.push( 'IAX2/' + usr );
+ }
+ });
+ t = parent.sessionData.FXS_PORTS_DETECTED ;
+ t.each(function(fxs){
+ listOfDialDevices.push('Zap/' + fxs );
+ });
+
+ ASTGUI.events.add( DOM_button_add_toringlist , 'click' , function(){
+ var t = DOM_select_fromlistofchannels.value ; if(!t){return;}
+ var s = DOM_select_fromlistofchannels.options[DOM_select_fromlistofchannels.selectedIndex].text ; if(!s){ s = t; }
+ DOM_select_fromlistofchannels.remove( DOM_select_fromlistofchannels.selectedIndex );
+ ASTGUI.selectbox.append( DOM_select_ringthesechannels, s , t );
+ });
+ ASTGUI.events.add( DOM_button_remove_fromringlist , 'click' , function(){
+ var t = DOM_select_ringthesechannels.value ; if(!t){return;}
+ var s = DOM_select_ringthesechannels.options[DOM_select_ringthesechannels.selectedIndex].text ; if(!s){ s = t; }
+ DOM_select_ringthesechannels.remove( DOM_select_ringthesechannels.selectedIndex );
+ if( listOfDialDevices.contains(t) ){ ASTGUI.selectbox.append( DOM_select_fromlistofchannels, s, t ); }
+ });
+ ASTGUI.events.add( DOM_button_removeall_fromringlist , 'click' , function(){
+ ASTGUI.selectbox.clear( DOM_select_ringthesechannels );
+ ASTGUI.selectbox.clear( DOM_select_fromlistofchannels );
+ listOfDialDevices.each(function(device){
+ var tmp_ext = device.afterChar('/');
+ var tmp_techn = device.beforeChar('/');
+
+ if( tmp_techn.toLowerCase() == 'zap' ){
+ var this_analogStation_user = '';
+ for ( var q in parent.sessionData.pbxinfo.users ){ if( parent.sessionData.pbxinfo.users.hasOwnProperty(q) ){
+ if( parent.sessionData.pbxinfo.users[q].getProperty('zapchan') == tmp_ext ){
+ this_analogStation_user = q + '(AnalogPort ' + tmp_ext + ') ' + parent.sessionData.pbxinfo.users[q].getProperty('fullname') ;
+ ASTGUI.selectbox.append( DOM_select_fromlistofchannels, this_analogStation_user , device);
+ return;
+ }
+ }}
+ }else{
+ if( parent.sessionData.pbxinfo.users[tmp_ext] && parent.sessionData.pbxinfo.users[tmp_ext].fullname ){
+ var tmp_name = parent.sessionData.pbxinfo.users[tmp_ext].fullname || '?' ;
+ }else{
+ return;
+ }
+ ASTGUI.selectbox.append( DOM_select_fromlistofchannels, tmp_ext + '('+ tmp_techn +')' + ' ' + tmp_name , device);
+ }
+ });
+ });
+
+ ASTGUI.events.add( 'button_addall_toringlist' , 'click' , function(){
+ ASTGUI.selectbox.clear( DOM_select_ringthesechannels );
+ ASTGUI.selectbox.clear( DOM_select_fromlistofchannels );
+
+ listOfDialDevices.each(function(device){
+ var tmp_ext = device.afterChar('/');
+ var tmp_techn = device.beforeChar('/');
+
+ if( tmp_techn.toLowerCase() == 'zap' ){
+ var this_analogStation_user = '';
+ for ( var q in parent.sessionData.pbxinfo.users ){ if( parent.sessionData.pbxinfo.users.hasOwnProperty(q) ){
+ if( parent.sessionData.pbxinfo.users[q].getProperty('zapchan') == tmp_ext ){
+ this_analogStation_user = q + '(AnalogPort ' + tmp_ext + ') ' + parent.sessionData.pbxinfo.users[q].getProperty('fullname') ;
+ ASTGUI.selectbox.append( DOM_select_ringthesechannels, this_analogStation_user , device);
+ return;
+ }
+ }}
+ }else{
+ if( parent.sessionData.pbxinfo.users[tmp_ext] && parent.sessionData.pbxinfo.users[tmp_ext].fullname ){
+ var tmp_name = parent.sessionData.pbxinfo.users[tmp_ext].fullname || '?' ;
+ }else{
+ return;
+ }
+ ASTGUI.selectbox.append( DOM_select_ringthesechannels, tmp_ext + '('+ tmp_techn +')' + ' ' + tmp_name , device);
+ }
+ });
+ });
+
+ })();
+
+ update_RingGroupsTable();
+
+};
+
</script>
<body bgcolor="EFEFEF">
<div class="iframeTitleBar">
@@ -74,7 +441,7 @@
<table id='table_pageGroups_list' cellpadding=0 cellspacing=0 border=0 align=center></table>
-<div id="pagegroup_editdiv" STYLE="width:600;" class='dialog'>
+<div id="pagegroup_editdiv" STYLE="width:600;display:none;" class='dialog'>
<TABLE width="100%" cellpadding=0 cellspacing=0>
<TR class="dialog_title_tr">
<TD class="dialog_title" onmousedown="ASTGUI.startDrag(event);">
@@ -98,7 +465,7 @@
</TR>
<tr> <td align=right>Play a beep : </td>
- <td><input type=checkbox id="chk_pgrp_beep"></td>
+ <td colspan=2><input type=checkbox id="chk_pgrp_beep"></td>
</tr>
<tr> <td align=center valign=top>
@@ -122,9 +489,10 @@
<select id="select_fromlistofchannels" style="width: 240px" size=8></select>
</td>
</tr>
+ <tr> <td align="right" colspan=3 height=10></td></tr>
<tr> <td align=center colspan=3>
<span class='guiButtonCancel' onclick='ASTGUI.hideDrag(event);'>Cancel</span>
- <span class='guiButtonEdit' onclick='save_rg();'>Save</span>
+ <span class='guiButtonEdit' onclick='save_pageGroup();'>Save</span>
</td>
</tr>
</table>
More information about the asterisk-gui-commits
mailing list