Module: check_mk
Branch: master
Commit: 0f84114df3b3f0f96b43c24a2bbe9e8cf9166fd2
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=0f84114df3b3f0…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Dec 21 10:08:35 2018 +0100
Moved SLA logic to dedicated module
Change-Id: I3cdb2d4026b03053f07b9a46fdfd8ee4b93ba4fd
---
web/htdocs/js/checkmk.js | 68 -------------------------------------
web/htdocs/js/index.js | 2 ++
web/htdocs/js/modules/sla.js | 80 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 82 insertions(+), 68 deletions(-)
diff --git a/web/htdocs/js/checkmk.js b/web/htdocs/js/checkmk.js
index f3edf52..0e0fd61 100644
--- a/web/htdocs/js/checkmk.js
+++ b/web/htdocs/js/checkmk.js
@@ -2024,74 +2024,6 @@ function host_tag_update_value(prefix, grp) {
}
//#.
-//# .--SLA-----------------------------------------------------------------.
-//# | ____ _ _ |
-//# | / ___|| | / \ |
-//# | \___ \| | / _ \ |
-//# | ___) | |___ / ___ \ |
-//# | |____/|_____/_/ \_\ |
-//# | |
-//# +----------------------------------------------------------------------+
-//# | |
-//# '----------------------------------------------------------------------'
-
-
-function sla_details_period_hover(td, sla_period, onoff)
-{
- if (has_class(td, "lock_hilite")) {
- return;
- }
-
- var sla_period_elements = document.getElementsByClassName(sla_period)
- for(var i = 0; i < sla_period_elements.length; i++)
- {
- if (onoff) {
- add_class(sla_period_elements[i], 'sla_hilite');
- }
- else {
- remove_class(sla_period_elements[i], 'sla_hilite');
- }
- }
-}
-
-
-function sla_details_period_click(td, sla_period)
-{
- var sla_period_elements = document.getElementsByClassName(sla_period);
- var onoff = has_class(td, "lock_hilite")
- for(var i = 0; i < sla_period_elements.length; i++)
- {
- if (onoff) {
- remove_class(sla_period_elements[i], 'sla_hilite');
- remove_class(sla_period_elements[i], 'lock_hilite');
- }
- else {
- add_class(sla_period_elements[i], 'sla_hilite');
- add_class(sla_period_elements[i], 'lock_hilite');
- }
- }
-}
-
-
-function sla_details_table_hover(tr, row_id, onoff) {
- var sla_period_elements =
tr.closest("table").closest("tbody").getElementsByClassName(row_id);
- for(var i = 0; i < sla_period_elements.length; i++)
- {
-
- if (onoff) {
- add_class(sla_period_elements[i], 'sla_hilite');
- add_class(sla_period_elements[i], 'sla_error_hilite');
- }
- else {
- remove_class(sla_period_elements[i], 'sla_error_hilite');
- if (!has_class(sla_period_elements[i], "lock_hilite")) {
- remove_class(sla_period_elements[i], 'sla_hilite');
- }
- }
- }
-}
-
-//#.
//# .-Popup Menu---------------------------------------------------------.
//# | ____ __ __ |
//# | | _ \ ___ _ __ _ _ _ __ | \/ | ___ _ __ _ _ |
diff --git a/web/htdocs/js/index.js b/web/htdocs/js/index.js
index cbf47be..d74246f 100644
--- a/web/htdocs/js/index.js
+++ b/web/htdocs/js/index.js
@@ -35,6 +35,7 @@ import * as selection from "selection";
import * as element_dragging from "element_dragging";
import * as help from "help";
import * as availability from "availability";
+import * as sla from "sla";
import * as dashboard from "dashboard";
require("script-loader!./checkmk.js");
@@ -66,6 +67,7 @@ export default {
element_dragging: element_dragging,
help: help,
availability: availability,
+ sla: sla,
dashboard: dashboard
},
// TODO: Compatibility for not yet modularized JS code
diff --git a/web/htdocs/js/modules/sla.js b/web/htdocs/js/modules/sla.js
new file mode 100644
index 0000000..49928f8
--- /dev/null
+++ b/web/htdocs/js/modules/sla.js
@@ -0,0 +1,80 @@
+// +------------------------------------------------------------------+
+// | ____ _ _ __ __ _ __ |
+// | / ___| |__ ___ ___| | __ | \/ | |/ / |
+// | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+// | | |___| | | | __/ (__| < | | | | . \ |
+// | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+// | |
+// | Copyright Mathias Kettner 2014 mk(a)mathias-kettner.de |
+// +------------------------------------------------------------------+
+//
+// This file is part of Check_MK.
+// The official homepage is at
http://mathias-kettner.de/check_mk.
+//
+// check_mk is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by
+// the Free Software Foundation in version 2. check_mk is distributed
+// in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+// out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+// PARTICULAR PURPOSE. See the GNU General Public License for more de-
+// ails. You should have received a copy of the GNU General Public
+// License along with GNU Make; see the file COPYING. If not, write
+// to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+// Boston, MA 02110-1301 USA.
+
+import * as utils from "utils";
+
+export function details_period_hover(td, sla_period, onoff)
+{
+ if (utils.has_class(td, "lock_hilite")) {
+ return;
+ }
+
+ var sla_period_elements = document.getElementsByClassName(sla_period);
+ for(var i = 0; i < sla_period_elements.length; i++)
+ {
+ if (onoff) {
+ utils.add_class(sla_period_elements[i], "sla_hilite");
+ }
+ else {
+ utils.remove_class(sla_period_elements[i], "sla_hilite");
+ }
+ }
+}
+
+
+export function details_period_click(td, sla_period)
+{
+ var sla_period_elements = document.getElementsByClassName(sla_period);
+ var onoff = utils.has_class(td, "lock_hilite");
+ for(var i = 0; i < sla_period_elements.length; i++)
+ {
+ if (onoff) {
+ utils.remove_class(sla_period_elements[i], "sla_hilite");
+ utils.remove_class(sla_period_elements[i], "lock_hilite");
+ }
+ else {
+ utils.add_class(sla_period_elements[i], "sla_hilite");
+ utils.add_class(sla_period_elements[i], "lock_hilite");
+ }
+ }
+}
+
+
+export function details_table_hover(tr, row_id, onoff) {
+ var sla_period_elements =
tr.closest("table").closest("tbody").getElementsByClassName(row_id);
+ for(var i = 0; i < sla_period_elements.length; i++)
+ {
+
+ if (onoff) {
+ utils.add_class(sla_period_elements[i], "sla_hilite");
+ utils.add_class(sla_period_elements[i], "sla_error_hilite");
+ }
+ else {
+ utils.remove_class(sla_period_elements[i], "sla_error_hilite");
+ if (!utils.has_class(sla_period_elements[i], "lock_hilite")) {
+ utils.remove_class(sla_period_elements[i], "sla_hilite");
+ }
+ }
+ }
+}