From b9c59911942a5c2ba3a215c4e0ec9f3731179d70 Mon Sep 17 00:00:00 2001 From: saravanan30erd Date: Sun, 8 Mar 2020 16:47:59 +0400 Subject: [PATCH] organize the code using function --- static/monit-dashboard.css | 5 +++ templates/index.html | 80 ++++++++++++++++++++++++-------------- 2 files changed, 55 insertions(+), 30 deletions(-) diff --git a/static/monit-dashboard.css b/static/monit-dashboard.css index 7459367..348d641 100644 --- a/static/monit-dashboard.css +++ b/static/monit-dashboard.css @@ -10,6 +10,11 @@ th { padding: 10px; } +.th-custom { + padding: 10px; + font-weight: 300; +} + td { border-bottom: 1px solid #ccc; padding: 15px; diff --git a/templates/index.html b/templates/index.html index 437c40b..f210aec 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,5 +1,19 @@ $def with (output, now) +$def row_error(check): + + $check + + + +$def row_ok(check): + + $check + + + $ errors = 0 $ color = "green" @@ -34,27 +48,41 @@ $def with (output, now) $for env, services in output[server]['result'].items(): - - - $env - - - + $ errors = 0 $for check in services.keys(): - $ isError = services.get(check) - $if isError != 0: - - $check - - - $else: - - $check - - - + $ isError = services.get(check) + $if isError != 0: + $ errors=errors+1 + $if errors > 0: + $ color = "red" + + + $env + + + + $for check in services.keys(): + $ isError = services.get(check) + $if isError != 0: + $:row_error(check) + $else: + $:row_ok(check) + + $else: + $ color = "green" + + + $env + + + + $for check in services.keys(): + $ isError = services.get(check) + $if isError != 0: + $:row_error(check) + $else: + $:row_ok(check) + $else: @@ -79,17 +107,9 @@ $def with (output, now) $for check in services.keys(): $ isError = services.get(check) $if isError != 0: - - $check - - + $:row_error(check) $else: - - $check - - + $:row_ok(check)