pari: branch 2.0 r3696 - in /branches/2.0/config: ./ js/
SVN commits to the Asterisk-GUI project
asterisk-gui-commits at lists.digium.com
Thu Aug 21 15:37:55 CDT 2008
Author: pari
Date: Thu Aug 21 15:37:54 2008
New Revision: 3696
URL: http://svn.digium.com/view/asterisk-gui?view=rev&rev=3696
Log:
Adding basic caching mechanism for storing config files
=> config2json and context2json now Cache Config Files output
=> next time config2json is called on the same file, use the file
output from cache instead of making a new AJAX request - if the file is not modified.
=> modify jquery such that the file cache status flag is updated
during any action=updateconfig requests
Modified:
branches/2.0/config/index.html
branches/2.0/config/js/astman.js
branches/2.0/config/js/jquery.js
Modified: branches/2.0/config/index.html
URL: http://svn.digium.com/view/asterisk-gui/branches/2.0/config/index.html?view=diff&rev=3696&r1=3695&r2=3696
==============================================================================
--- branches/2.0/config/index.html (original)
+++ branches/2.0/config/index.html Thu Aug 21 15:37:54 2008
@@ -62,6 +62,7 @@
'lpc10': 'LPC10' ,
'g729' : 'G.729'
},
+ FileCache:{}, // Object to Cache config files .. sessionData.FileCache['users.conf'].content , sessionData.FileCache['users.conf'].modified
FXO_PORTS_DETECTED : [], // so that we donot have to parse ztscan output each time where we want this list
// sessionData.FXO_PORTS_DETECTED
FXS_PORTS_DETECTED : [], // so that we donot have to parse ztscan output each time where we want this list
Modified: branches/2.0/config/js/astman.js
URL: http://svn.digium.com/view/asterisk-gui/branches/2.0/config/js/astman.js?view=diff&rev=3696&r1=3695&r2=3696
==============================================================================
--- branches/2.0/config/js/astman.js (original)
+++ branches/2.0/config/js/astman.js Thu Aug 21 15:37:54 2008
@@ -2651,12 +2651,21 @@
}
return (catfound)?cat : null ;
};
+
ASTGUI.debugLog("AJAX Request : reading '" + params.filename + "'" , 'get');
- if( parent.sessionData.PLATFORM.isAST_1_6 ){
- var s = $.ajax({ url: ASTGUI.paths.rawman+'?action=getconfig&filename='+params.filename+'&category='+params.context, async: false }).responseText;
+ if( top.sessionData.FileCache.hasOwnProperty(params.filename) && top.sessionData.FileCache[params.filename].modified == false){ // if file is in cache and is not modified since
+ var s = top.sessionData.FileCache[params.filename].content ;
}else{
- var s = $.ajax({ url: ASTGUI.paths.rawman+'?action=getconfig&filename='+params.filename, async: false}).responseText;
+ if( parent.sessionData.PLATFORM.isAST_1_6 ){
+ var s = $.ajax({ url: ASTGUI.paths.rawman+'?action=getconfig&filename='+params.filename+'&category='+params.context, async: false }).responseText;
+ }else{
+ var s = $.ajax({ url: ASTGUI.paths.rawman+'?action=getconfig&filename='+params.filename, async: false}).responseText;
+ }
+
+ top.sessionData.FileCache[params.filename] = {};
+ top.sessionData.FileCache[params.filename].content = s;
+ top.sessionData.FileCache[params.filename].modified = false;
}
if(s.contains('Response: Error') && ( s.contains('Message: Config file not found') || s.contains('Message: Permission denied') ) ){
@@ -2734,8 +2743,19 @@
if( params.configFile_output ){
return toJSO( params.configFile_output );
};
+
ASTGUI.debugLog("AJAX Request : reading '" + params.filename + "'" , 'get');
- var s = $.ajax({ url: ASTGUI.paths.rawman+'?action=getconfig&filename='+params.filename, async: false }).responseText;
+
+ if( top.sessionData.FileCache.hasOwnProperty(params.filename) && top.sessionData.FileCache[params.filename].modified == false){ // if file is in cache and is not modified since
+ var s = top.sessionData.FileCache[params.filename].content ;
+ }else{
+ var s = $.ajax({ url: ASTGUI.paths.rawman+'?action=getconfig&filename='+params.filename, async: false }).responseText;
+
+ top.sessionData.FileCache[params.filename] = {};
+ top.sessionData.FileCache[params.filename].content = s;
+ top.sessionData.FileCache[params.filename].modified = false;
+ }
+
if( s.contains('Response: Error') && s.contains('Message: Config file not found') ){
// return ASTGUI.globals.fnf; // return 'file not found'
ASTGUI.ErrorLog( ' config file(' + params.filename +') not found ' );
Modified: branches/2.0/config/js/jquery.js
URL: http://svn.digium.com/view/asterisk-gui/branches/2.0/config/js/jquery.js?view=diff&rev=3696&r1=3695&r2=3696
==============================================================================
--- branches/2.0/config/js/jquery.js (original)
+++ branches/2.0/config/js/jquery.js Thu Aug 21 15:37:54 2008
@@ -2638,6 +2638,11 @@
///// ADDED FOR ASTERISK GUI //////
try{
if( ASTGUI && s.url.contains('action=updateconfig&') ){
+ // update cache status flag for the modified file
+ var tmp_filename = ASTGUI.parseGETparam( s.url , 'srcfilename');
+ if( !top.sessionData.FileCache.hasOwnProperty(tmp_filename) ){ top.sessionData.FileCache[tmp_filename] = {}; }
+ top.sessionData.FileCache[tmp_filename].modified = true;
+
if( s.url.contains('&srcfilename=http.conf&') || s.url.contains( '&srcfilename=' + ASTGUI.globals.zaptelIncludeFile + '&') ){
}else{
More information about the asterisk-gui-commits
mailing list