forked from extern/egroupware
add async include and et2 render times to page-generation-times shown
This commit is contained in:
parent
5179794f15
commit
90edb55ec5
@ -195,8 +195,14 @@ class etemplate_new extends etemplate_widget_template
|
||||
// check if we are in an ajax-exec call from jdots template (or future other tabbed templates)
|
||||
if (isset($GLOBALS['egw']->framework->response))
|
||||
{
|
||||
//error_log("Ajax " . __LINE__);
|
||||
$GLOBALS['egw']->framework->response->generic("data", array('<div id="'.$dom_id.'" class="et2_container"></div>'));
|
||||
$content = '<div id="'.$dom_id.'" class="et2_container"></div>';
|
||||
// add server-side page-generation times
|
||||
if($GLOBALS['egw_info']['user']['preferences']['common']['show_generation_time'])
|
||||
{
|
||||
$vars = $GLOBALS['egw']->framework->_get_footer();
|
||||
$content .= "\n".$vars['page_generation_time'];
|
||||
}
|
||||
$GLOBALS['egw']->framework->response->generic("data", array($content));
|
||||
$GLOBALS['egw']->framework->response->generic('et2_load',$load_array+egw_framework::get_extra());
|
||||
self::$request = null;
|
||||
return;
|
||||
|
@ -207,6 +207,8 @@ etemplate2.prototype.load = function(_name, _url, _data, _callback)
|
||||
if (!$j.isArray(_data.langRequire)) _data.langRequire = [];
|
||||
egw(currentapp, window).langRequire(window, _data.langRequire, function()
|
||||
{
|
||||
var start_time = (new Date).getTime();
|
||||
|
||||
// Appname should be first part of the template name
|
||||
var split = _name.split('.');
|
||||
var appname = split[0];
|
||||
@ -311,6 +313,12 @@ etemplate2.prototype.load = function(_name, _url, _data, _callback)
|
||||
}
|
||||
|
||||
$j(this.DOMContainer).trigger('load', this);
|
||||
|
||||
var end_time = (new Date).getTime();
|
||||
var gen_time_div = $j('#divGenTime_'+appname);
|
||||
if (!gen_time_div.length) gen_time_div = $j('.pageGenTime');
|
||||
gen_time_div.find('.et2RenderTime').remove();
|
||||
gen_time_div.append('<span class="et2RenderTime">'+egw.lang('eT2 rendering took %1s', (end_time-start_time)/1000)+'</span>');
|
||||
},this));
|
||||
};
|
||||
|
||||
@ -723,7 +731,7 @@ function etemplate2_handle_load(_type, _response)
|
||||
{
|
||||
window.framework.setSidebox.apply(window.framework, data.setSidebox);
|
||||
}
|
||||
|
||||
|
||||
// regular et2 re-load
|
||||
if (typeof data.url == "string" && typeof data.data === 'object')
|
||||
{
|
||||
|
@ -547,7 +547,7 @@ abstract class egw_framework
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function _get_footer()
|
||||
public function _get_footer()
|
||||
{
|
||||
$var = Array(
|
||||
'img_root' => $GLOBALS['egw_info']['server']['webserver_url'] . $this->template_dir.'/images',
|
||||
@ -558,7 +558,7 @@ abstract class egw_framework
|
||||
{
|
||||
$totaltime = sprintf('%4.2lf',microtime(true) - $GLOBALS['egw_info']['flags']['page_start_time']);
|
||||
|
||||
$var['page_generation_time'] = '<div id="divGenTime"><br/><span>'.lang('Page was generated in %1 seconds',$totaltime);
|
||||
$var['page_generation_time'] = '<div class="pageGenTime" id="divGenTime_'.$GLOBALS['egw_info']['flags']['currentapp'].'"><span>'.lang('Page was generated in %1 seconds',$totaltime);
|
||||
if ($GLOBALS['egw_info']['flags']['session_restore_time'])
|
||||
{
|
||||
$var['page_generation_time'] .= ' '.lang('(session restored in %1 seconds)',
|
||||
|
@ -39,6 +39,7 @@
|
||||
(function(){
|
||||
var debug = false;
|
||||
var egw_script = document.getElementById('egw_script_id');
|
||||
var start_time = (new Date).getTime();
|
||||
|
||||
// Flag for if this is opened in a popup
|
||||
var popup = (window.opener != null);
|
||||
@ -151,8 +152,14 @@
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
window.egw_LAB.script(include).wait(function()
|
||||
{
|
||||
var end_time = (new Date).getTime();
|
||||
var gen_time_div = $j('#divGenTime_'+window.egw_appName);
|
||||
if (!gen_time_div.length) gen_time_div = $j('.pageGenTime');
|
||||
gen_time_div.append('<span class="asyncIncludeTime">'+egw.lang('async includes took %1s', (end_time-start_time)/1000)+'</span>');
|
||||
|
||||
// Make sure opener knows when we close - start a heartbeat
|
||||
if((popup || window.opener) && window.name != '')
|
||||
{
|
||||
|
@ -76,7 +76,7 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_app, _wnd) {
|
||||
{
|
||||
this.async = async;
|
||||
}
|
||||
|
||||
|
||||
// Assemble the complete request
|
||||
var request_obj = {
|
||||
'json_data': this.egw.jsonEncode({
|
||||
@ -88,7 +88,7 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_app, _wnd) {
|
||||
|
||||
// Send the request via AJAX using the jquery ajax function
|
||||
// we need to use jQuery of window of egw object, as otherwise the one from main window is used!
|
||||
// (causing eg. apply from server with app.$app.method to run in main window instead of popup)
|
||||
// (causing eg. apply from server with app.$app.method to run in main window instead of popup)
|
||||
(this.egw.window?this.egw.window.$j:$j).ajax({
|
||||
url: this.url,
|
||||
async: this.async,
|
||||
@ -120,7 +120,14 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_app, _wnd) {
|
||||
}
|
||||
if(js_files.length > 0)
|
||||
{
|
||||
this.egw.includeJS(js_files, function() {this.handleResponse(data);}, this);
|
||||
var start_time = (new Date).getTime();
|
||||
this.egw.includeJS(js_files, function() {
|
||||
var end_time = (new Date).getTime();
|
||||
this.handleResponse(data);
|
||||
var gen_time_div = $j('#divGenTime_'+this.egw.appname);
|
||||
if (!gen_time_div.length) gen_time_div = $j('.pageGenTime');
|
||||
gen_time_div.append('<span class="asyncIncludeTime">'+egw.lang('async includes took %1s', (end_time-start_time)/1000)+'</span>');
|
||||
}, this);
|
||||
return;
|
||||
}
|
||||
for (var i = 0; i < data.response.length; i++)
|
||||
@ -165,13 +172,13 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_app, _wnd) {
|
||||
* not.
|
||||
* @param _callback specifies the callback function which should be
|
||||
* called, once the request has been sucessfully executed.
|
||||
* @param _context is the context which will be used for the callback function
|
||||
* @param _context is the context which will be used for the callback function
|
||||
* @param _sender is a parameter being passed to the _callback function
|
||||
*/
|
||||
json: function(_menuaction, _parameters, _callback, _context, _async,
|
||||
_sender)
|
||||
{
|
||||
return new json_request(_menuaction, _parameters, _callback,
|
||||
return new json_request(_menuaction, _parameters, _callback,
|
||||
_context, _async, _sender, this);
|
||||
},
|
||||
|
||||
@ -244,7 +251,7 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_app, _wnd) {
|
||||
// Regisert the "alert" plugin
|
||||
json.registerJSONPlugin(function(type, res, req) {
|
||||
//Check whether all needed parameters have been passed and call the alertHandler function
|
||||
if ((typeof res.data.message != 'undefined') &&
|
||||
if ((typeof res.data.message != 'undefined') &&
|
||||
(typeof res.data.details != 'undefined'))
|
||||
{
|
||||
req.alertHandler(
|
||||
@ -258,7 +265,7 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_app, _wnd) {
|
||||
// Register the "assign" plugin
|
||||
json.registerJSONPlugin(function(type, res, req) {
|
||||
//Check whether all needed parameters have been passed and call the alertHandler function
|
||||
if ((typeof res.data.id != 'undefined') &&
|
||||
if ((typeof res.data.id != 'undefined') &&
|
||||
(typeof res.data.key != 'undefined') &&
|
||||
(typeof res.data.value != 'undefined'))
|
||||
{
|
||||
|
@ -59,10 +59,23 @@ a:hover,a:active
|
||||
color:#666666;
|
||||
}
|
||||
|
||||
#divGenTime,#divPoweredBy
|
||||
.pageGenTime,#divPoweredBy
|
||||
{
|
||||
font-size: 80%;
|
||||
color: #ff0000;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.pageGenTime {
|
||||
margin-top: 1em;
|
||||
}
|
||||
|
||||
.pageGenTime > span:after {
|
||||
content: ", ";
|
||||
}
|
||||
|
||||
.pageGenTime > span:last-child:after {
|
||||
content: "";
|
||||
}
|
||||
|
||||
#divPoweredBy
|
||||
@ -84,7 +97,7 @@ a:hover,a:active
|
||||
#menu1close {
|
||||
position: absolute;
|
||||
right: 7px;
|
||||
top: 7px;
|
||||
top: 7px;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -774,7 +787,7 @@ tr.draggedOver td {
|
||||
font-weight: bold;
|
||||
}
|
||||
td.lettersearch {
|
||||
border-color: #E0E0E0;
|
||||
border-color: #E0E0E0;
|
||||
background-image: url(../images/gradient22.png);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user