From 896a25f11ce581fdf677af4480ae790931b0854f Mon Sep 17 00:00:00 2001 From: hahn <axel.hahn@iml.unibe.ch> Date: Tue, 28 May 2019 07:59:19 +0200 Subject: [PATCH] - update appmonitor client class - simplify filter on top in the project overview --- public_html/deployment/js/functions.js | 41 ++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/public_html/deployment/js/functions.js b/public_html/deployment/js/functions.js index 187993c9..c8c2af19 100644 --- a/public_html/deployment/js/functions.js +++ b/public_html/deployment/js/functions.js @@ -107,6 +107,7 @@ function updateActionlog(){ sHtml+='</tr>'; } } + drawTimeline(aData); if (!sHtml){ sHtml=sMsgNolog; // variable is set in actionlog.class.php @@ -123,6 +124,46 @@ function updateActionlog(){ }); } + +/** + * render timeline with Visjs + * + * @param {array} aData + * @returns {undefined} + */ +function drawTimeline(aData){ + var sDataset=''; + + var container = document.getElementById('divTimeline'); + if(!container){ + return false; + } + container.innerHTML=''; // empty the div + + if (aData.length && aData[0]["id"]){ + for (i=0; i<aData.length; i++){ + // keys are + // var aTableitems=["id", "time", "loglevel", "ip", "user", "project", "action", "message"]; + sLabel=aData[i]["project"]+'<br>'+aData[i]["action"]; + sTitle=aData[i]["time"] + '<br>'+aData[i]["loglevel"]+'<br><br>Projekt: ' + aData[i]["project"] +'<br>User: ' + aData[i]["user"] + ' (' + aData[i]["ip"] +')<br>'+ aData[i]["message"] ; + sDataset+= (sDataset ? ', ': '' ) + + '{"id": '+i+', "content": "'+sLabel+'", "start": "'+aData[i]["time"].replace(/\ /, "T") +'", "title": "'+sTitle+'", "group": "'+aData[i]["project"]+'", "className": "loglevel-'+aData[i]["loglevel"]+'" }'; + } + aDataset=JSON.parse('['+sDataset+']'); + + var items = new vis.DataSet(aDataset); + + // Configuration for the Timeline + var options = { + // verticalScroll: false, + clickToUse: true + }; + + // Create a Timeline + var timeline = new vis.Timeline(container, items, options); + } +} + /** * filter table with action logs by filtertext (input field) */ -- GitLab