Skip to content
Snippets Groups Projects
cronlog-renderer.class.php 29.02 KiB
<?php
require_once 'cronlog.class.php';
/**
 * ______________________________________________________________________
 * 
 *  _____                 _       _             _                        
 * /  __ \               (_)     | |           (_)                       
 * | /  \/_ __ ___  _ __  _  ___ | |__   __   ___  _____      _____ _ __ 
 * | |   | '__/ _ \| '_ \| |/ _ \| '_ \  \ \ / / |/ _ \ \ /\ / / _ \ '__|
 * | \__/\ | | (_) | | | | | (_) | |_) |  \ V /| |  __/\ V  V /  __/ |   
 *  \____/_|  \___/|_| |_| |\___/|_.__/    \_/ |_|\___| \_/\_/ \___|_|   
 *                      _/ |                                             
 *                     |__/                                              
 * ______________________________________________________________________
 * 
 * The cronjob viewer for centralized monitoring of cronjobs using
 * Axels cronrwapper (see <https://github.com/axelhahn/cronwrapper>).
 * 
 * You can browse all servers to see 
 * - the last status of all cronjobs
 * - results an execution times of running jonbs
 * - a timeline for all jobs running > 60s
 * 
 * 
 * Free software. Open Source. GNU GPL 3.
 * SOURCE: <https://git-repo.iml.unibe.ch/iml-open-source/cronlog-viewer>
 * 
 * ______________________________________________________________________
 * 
 * The class cronlog-renderer contains visual methods to render html
 * @see cronlog.class.php
 *
 * @license GNU GPL 3.0
 * @author Axel Hahn <axel.hahn@iml.unibe.ch>
 */
class cronlogrenderer extends cronlog{

    /**
     * minimal length for execution time of a job to be rendered in the timeline; value is in seconds
     * @var integer
     */
    protected $_iMinTime4Timeline = 60;
    
    /**
     * show date of last data and last access; used in rendering methods to display it on top
     * @param integer $iLast  unix timestamp of last log entry
     * @return string
     */
    protected function _renderAccessAndAge($iLast){
        if(!$iLast){
            return '';
        }
        $iAge=round((date('U')-$iLast)/60);
        return '<div class="accessandage">'
            . sprintf($this->t("request-time"), date("Y-m-d H:i:s")).'<br>'
            . sprintf($this->t("last-entry"), $iAge)
            .'</div>'
            ;
    }
    
    /**
     * get onclick value to filter a datatable
     * @param  string  $sDatatable   id of table
     * @param  string  $sFiltertext  text to filter
     * @return string
     * 
     */
    protected function _filterDatatable($sDatatable, $sFiltertext){
        return '$(\'#'.$sDatatable.'\').dataTable().fnFilter(\''.$sFiltertext.'\'); return false;';
    }