Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
FIX: Removing unused code and fixing bug of generating csv in multipl…
Browse files Browse the repository at this point in the history
…e periods graphs 21.10.x (#11857)
  • Loading branch information
hyahiaoui-ext committed Sep 22, 2022
1 parent a4db0ea commit ab0818e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 109 deletions.
79 changes: 0 additions & 79 deletions www/include/views/graphs/exportData/ExportCSVMetricData.php

This file was deleted.

2 changes: 0 additions & 2 deletions www/include/views/graphs/generateGraphs/generateImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@
} else {
die('Invalid token');
}
} else {
throw new \Exception('Username and token query strings must be set.');
}

$index = filter_var(
Expand Down
41 changes: 13 additions & 28 deletions www/include/views/graphs/graph-periods.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<div id="graphs" class="graph_content">
<div class="graphZone">
{foreach from=$periods item=period}
<div id="graph_wrapper_{$period.short}" data-graph-id="{$srv_id}" class="graph">
<div id="graph_wrapper_{$period.short}" data-graph-id="{$svc_id}" data-graph-period="{$period.short}" class="graph">
<div class="title">
<img class="remove ico-14 margin_right" src="./img/icons/circle-cross.png">
<span>{$srv_name} during {$period.long}</span>
Expand Down Expand Up @@ -54,36 +54,21 @@

/* Add events on click on action download image/CSV */
jQuery('.graphZone').delegate('a.actions', 'click', function (e) {
var $a = jQuery(this);
var baseUrl = $a.data('href');
var chartId = $a.parents('.graph').data('graphId');
var start;
var end;
var timezone = localStorage.getItem('realTimezone')
let $a = jQuery(this);
let baseUrl = $a.data('href');
let chartId = $a.parents('.graph').data('graphId');
let start;
let end;
let timezone = localStorage.getItem('realTimezone')
? localStorage.getItem('realTimezone')
: moment.tz.guess();

/* Get the period */
if (jQuery('select[name="period"]').val() === '') {
start = moment.tz(
jQuery('#StartDate').val() + ' ' + jQuery('#StartTime').val(),
timezone
);
end = moment.tz(
jQuery('#EndDate').val() + ' ' + jQuery('#EndTime').val(),
timezone
);
duration = moment.duration(end.diff(start));
} else {
parseInterval = jQuery('select[name="period"]').val().match(/(\d+)([a-z]+)/i);
duration = moment.duration(
parseInt(parseInterval[1], 10),
parseInterval[2]
);
start = moment().tz(timezone);
end = moment().tz(timezone);
start.subtract(parseInterval[1], parseInterval[2]);
}
//Defining the period
let graphPeriod = $a.parents('.graph').data('graphPeriod');
let parseInterval = graphPeriod.match(/(\d+)([a-z]+)/i);
start = moment().tz(timezone);
end = moment().tz(timezone);
start.subtract(parseInterval[1], parseInterval[2]);

e.preventDefault();
baseUrl += '?chartId=' + chartId + '&start=' + start.unix() + '&end=' + end.unix();
Expand Down

0 comments on commit ab0818e

Please sign in to comment.