2014-01-27 15:29:24 +01:00
|
|
|
/**
|
|
|
|
* EGroupware clientside egw tail
|
|
|
|
*
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
|
|
|
* @package api
|
|
|
|
* @subpackage jsapi
|
2021-06-10 11:38:54 +02:00
|
|
|
* @link https://www.egroupware.org
|
2014-01-27 15:29:24 +01:00
|
|
|
* @author Hadi Nategh (as AT stylite.de)
|
|
|
|
* @author Ralf Becker <RalfBecker@outdoor-training.de>
|
|
|
|
*/
|
|
|
|
|
2021-06-05 20:39:39 +02:00
|
|
|
import './egw_json.js';
|
2014-01-27 15:29:24 +01:00
|
|
|
|
2016-02-29 16:50:24 +01:00
|
|
|
jQuery(function()
|
|
|
|
{
|
|
|
|
"use strict";
|
|
|
|
|
2014-01-27 15:29:24 +01:00
|
|
|
var log_tail_start=0;
|
2016-06-02 16:51:15 +02:00
|
|
|
var filename = jQuery('pre[id^="log"]');
|
2014-01-27 15:29:24 +01:00
|
|
|
if (typeof filename !='undefined' && filename.length > 0)
|
|
|
|
{
|
|
|
|
filename = filename.attr('data-filename');
|
|
|
|
}
|
|
|
|
function button_log(buttonId)
|
|
|
|
{
|
|
|
|
if (buttonId != "clear_log")
|
|
|
|
{
|
2016-04-02 12:44:17 +02:00
|
|
|
egw.json("api.EGroupware\\Api\\Json\\Tail.ajax_delete",[filename,buttonId=="empty_log"])
|
|
|
|
.sendRequest(true);
|
2014-01-27 15:29:24 +01:00
|
|
|
}
|
2016-06-02 16:51:15 +02:00
|
|
|
jQuery("#log").text("");
|
2014-01-27 15:29:24 +01:00
|
|
|
}
|
|
|
|
function refresh_log()
|
|
|
|
{
|
2016-04-02 12:44:17 +02:00
|
|
|
egw.json("api.EGroupware\\Api\\Json\\Tail.ajax_chunk",[filename,log_tail_start], function(_data)
|
|
|
|
{
|
2014-01-27 15:29:24 +01:00
|
|
|
if (_data.length) {
|
|
|
|
log_tail_start = _data.next;
|
2016-06-02 16:51:15 +02:00
|
|
|
var log = jQuery("#log").append(_data.content.replace(/</g,"<"));
|
2014-01-27 15:29:24 +01:00
|
|
|
log.animate({ scrollTop: log.prop("scrollHeight") - log.height() + 20 }, 500);
|
|
|
|
}
|
|
|
|
if (_data.size === false)
|
|
|
|
{
|
2016-06-02 16:51:15 +02:00
|
|
|
jQuery("#download_log").hide();
|
2014-01-27 15:29:24 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-06-18 10:15:04 +02:00
|
|
|
jQuery("#download_log").show().attr("title", egw(window).lang('Size')+_data.size);
|
2014-01-27 15:29:24 +01:00
|
|
|
}
|
|
|
|
if (_data.writable === false)
|
|
|
|
{
|
2016-06-02 16:51:15 +02:00
|
|
|
jQuery("#purge_log").hide();
|
|
|
|
jQuery("#empty_log").hide();
|
2014-01-27 15:29:24 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-06-02 16:51:15 +02:00
|
|
|
jQuery("#purge_log").show();
|
|
|
|
jQuery("#empty_log").show();
|
2014-01-27 15:29:24 +01:00
|
|
|
}
|
|
|
|
window.setTimeout(refresh_log,_data.length?200:2000);
|
2016-04-02 12:44:17 +02:00
|
|
|
}).sendRequest(true);
|
2014-01-27 15:29:24 +01:00
|
|
|
}
|
|
|
|
function resize_log()
|
|
|
|
{
|
2016-06-02 16:51:15 +02:00
|
|
|
jQuery("#log").width(egw_getWindowInnerWidth()-20).height(egw_getWindowInnerHeight()-33);
|
2014-01-27 15:29:24 +01:00
|
|
|
}
|
|
|
|
jQuery('input[id^="clear_log"]').on('click',function(){
|
|
|
|
button_log(this.getAttribute('id'));
|
|
|
|
});
|
2014-01-28 09:33:28 +01:00
|
|
|
jQuery('input[id^="purge_log"]').on('click',function(){
|
2014-01-27 15:29:24 +01:00
|
|
|
button_log(this.getAttribute('id'));
|
|
|
|
});
|
|
|
|
jQuery('input[id^="empty_log"]').on('click',function(){
|
|
|
|
button_log(this.getAttribute('id'));
|
|
|
|
});
|
2021-06-05 20:39:39 +02:00
|
|
|
//egw_LAB.wait(function() {
|
2016-06-02 16:51:15 +02:00
|
|
|
jQuery(document).ready(function()
|
2014-01-27 15:29:24 +01:00
|
|
|
{
|
|
|
|
if (typeof filename !='undefined' && filename.length > 0)
|
|
|
|
{
|
|
|
|
resize_log();
|
|
|
|
refresh_log();
|
|
|
|
}
|
|
|
|
});
|
2016-06-02 16:51:15 +02:00
|
|
|
jQuery(window).resize(resize_log);
|
2021-06-05 20:39:39 +02:00
|
|
|
//});
|
2014-01-27 15:29:24 +01:00
|
|
|
});
|