Skip to content

Commit

Permalink
omd top: use strftime for readable date format
Browse files Browse the repository at this point in the history
  • Loading branch information
sni committed Jan 25, 2025
1 parent 44df857 commit 626f678
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion plugins/plugins-available/omd/root/omd_top.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function updateDetailsTable(index, fetch) {
jQuery.each(plots, function(name, plot) { keys.push(name); });
var timestamp = plots[keys[0]].getData()[0].data[index][0];
var date = new Date(timestamp);
jQuery('#time').html(date.toLocaleString());
jQuery('#time').html(_dateString(timestamp));

if(plots['load']) {
jQuery('#load1').html(plots['load'].getData()[0].data[index][1]);
Expand Down Expand Up @@ -179,4 +179,8 @@ function _backgroundColor() {
backgroundColor = "#333";
}
return(backgroundColor);
}

function _dateString(ts) {
return((new Date(ts)).strftime("%Y-%m-%d %H:%M:%S"));
}
2 changes: 1 addition & 1 deletion plugins/plugins-available/omd/templates/omd_top.tt
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ jQuery().ready(function() {
/* add zooming and hover */
jQuery('#load_graph').bind("plothover", function (event, pos, item) {
if (item) {
var date = new Date(item.datapoint[0]).toLocaleString();
var date = _dateString(item.datapoint[0]);
var tooltip = _getTooltipFromSeries(date, load_series, item.dataIndex);
var main = jQuery("MAIN").first();
var x = Number(pos.pageX) + Number(main.scrollLeft()) + 10;
Expand Down
2 changes: 1 addition & 1 deletion plugins/plugins-available/omd/templates/omd_top_details.tt
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ jQuery().ready(function() {
/* graph hover */
jQuery(e).bind("plothover", function (event, pos, item) {
if (item) {
var d = new Date(item.datapoint[0]).toLocaleString();
var d = _dateString(item.datapoint[0]);
var tooltip;
if(e == '#load_graph') { tooltip = _getTooltipFromSeries(d, load_series, item.dataIndex )};
if(e == '#cpu_graph') { tooltip = _getTooltipFromSeries(d, cpu_series, item.dataIndex, "%" )};
Expand Down

0 comments on commit 626f678

Please sign in to comment.