/* The MIT License (MIT) Copyright (C) 2012-2013 Anton Simonov Copyright (C) 2014-2017 Vsevolod Stakhov Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ (function () { $(document).ready(function () { // begin var pie; var rrd_pie; var history; var errors; var graph; var symbols; var read_only = false; var neighbours = []; //list of clusters var checked_server = "All SERVERS"; var timer_id = []; var selData; // Graph's dataset selector state // Bind event handlers to selectors $("#selData").change(function () { selData = this.value; tabClick("#throughput_nav"); }); $("#selConvert").change(function () { graph.convert(this.value); }); $("#selType").change(function () { graph.type(this.value); }); $("#selInterpolate").change(function () { graph.interpolate(this.value); }); function stopTimers() { for (var key in timer_id) { Visibility.stop(timer_id[key]); } } function disconnect() { if (pie) { pie.destroy(); } if (rrd_pie) { rrd_pie.destroy(); } if (graph) { graph.destroy(); graph = undefined; } if (history) { history.destroy(); } if (errors) { errors.destroy(); } if (symbols) { symbols.destroy(); symbols = null; } stopTimers(); cleanCredentials(); connectRSPAMD(); // window.location.reload(); return false; } function tabClick(tab_id) { if ($(tab_id).attr('disabled')) return; $(tab_id).attr('disabled', true); stopTimers(); if (tab_id === "#refresh") { tab_id = "#" + $('.navbar-nav .active > a' ).attr('id'); } switch (tab_id) { case "#status_nav": statWidgets(); timer_id.status = Visibility.every(10000, function () { statWidgets(); }); break; case "#throughput_nav": getGraphData(selData); const autoRefresh = { hourly: 60000, daily: 300000 }; timer_id.throughput = Visibility.every(autoRefresh[selData] || 3600000, function () { getGraphData(selData); }); break; case "#configuration_nav": getActions(); $('#modalBody').empty(); getMaps(); break; case "#symbols_nav": getSymbols(); break; case "#history_nav": getHistory(); getErrors(); break; case "#disconnect": disconnect(); break; } setTimeout(function () { $(tab_id).removeAttr('disabled'); $('#refresh').removeAttr('disabled'); }, 1000); } // @supports session storage function supportsSessionStorage() { return typeof (Storage) !== "undefined"; } // @return password function getPassword() { return sessionStorage.getItem('Password'); } // @detect session storate supportsSessionStorage(); // @save credentials function saveCredentials(password) { sessionStorage.setItem('Password', password); } // @update credentials function saveActions(data) { sessionStorage.setItem('Actions', JSON.stringify(data)); } // @update credentials function saveMaps(data) { sessionStorage.setItem('Maps', JSON.stringify(data)); } // @clean credentials function cleanCredentials() { sessionStorage.clear(); $('#statWidgets').empty(); $('#listMaps').empty(); $('#modalBody').empty(); $('#historyLog tbody').remove(); $('#errorsLog tbody').remove(); $('#symbolsTable tbody').remove(); password = ''; } function isLogged() { if (sessionStorage.getItem('Credentials') !== null) { return true; } return false; } // @alert popover function alertMessage(alertState, alertText) { if ($('.alert').is(':visible')) { $(alert).hide().remove(); } var alert = $('