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

FIX: Removing unused code and fixing bug of generating csv in multiple periods graphs #11742

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.');
TamazC marked this conversation as resolved.
Show resolved Hide resolved
}

$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">
kduret marked this conversation as resolved.
Show resolved Hide resolved
<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