1/*!
2 * Automation Status Javascript.
3 *
4 * @copyright Copyright (c) WHMCS Limited 2005-2019
5 * @license http://www.whmcs.com/license/ WHMCS Eula
6 */
7$(document).ready(function(){
8 $('#statsContainer').on('click', '.btn-viewing', function (e){
9 e.preventDefault();
10 });
11 $('#graphContainer').on('click', '.graph-filter-metric a', function (e){
12 e.preventDefault();
13 $('.graph-filter-metric a').removeClass('active');
14 $(this).addClass('active');
15 refreshGraph();
16 });
17 $('#graphContainer').on('click', '.graph-filter-period a', function (e){
18 e.preventDefault();
19 $('.graph-filter-period a').removeClass('active');
20 $(this).addClass('active');
21 refreshGraph();
22 });
23});
24
25function loadAutomationStatsForDate(date) {
26 $('#statsContainer').css('opacity', '0.5');
27 WHMCS.http.jqClient.post(
28 "automationstatus.php",
29 'action=stats&date=' + date,
30 function(data) {
31 $('.widgets-container').html(data.body);
32 $('.day-selector').find('.btn-viewing').html(data.newDate);
33 }
34 ).fail(function() {
35 jQuery.growl({ title: "", message: "Your session has expired. Please refresh to continue." });
36 }).always(function() {
37 $('#statsContainer').css('opacity', '1');
38 });
39}
40
41function refreshGraph() {
42 $('#graphContainer').css('opacity', '0.5');
43 var jqxhr = WHMCS.http.jqClient.post( "automationstatus.php",'action=graph&metric=' + $('.graph-filter-metric a.active').attr('href') + '&period=' + $('.graph-filter-period a.active').attr('href'),
44 function(data) {
45 $('#graphContainer').html(data.body);
46 }).fail(function() {
47 jQuery.growl({ title: "", message: "Your session has expired. Please refresh to continue." });
48 }).always(function() {
49 $('#graphContainer').css('opacity', '1');
50 });
51}
52