Module: check_mk
Branch: master
Commit: 5c99e3a3d7fc85e105d3cc06f97f8eb6a56a3dcd
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5c99e3a3d7fc85…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Jul 27 11:40:49 2015 +0200
WATO: rework replication table to use table module
---
web/htdocs/wato.py | 102 ++++++++++++++++++++++------------------------------
1 file changed, 42 insertions(+), 60 deletions(-)
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 8720a4b..1eb2e49 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -4764,11 +4764,11 @@ def mode_changelog(phase):
transaction_already_checked = False
changes = foreign_changes()
if changes:
- table = "<table class=foreignchanges>"
+ table_html = "<table class=foreignchanges>"
for user_id, count in changes.items():
- table += '<tr><td>%s: </td><td>%d
%s</td></tr>' % \
+ table_html += '<tr><td>%s: </td><td>%d
%s</td></tr>' % \
(config.alias_of_user(user_id), count, _("changes"))
- table += '</table>'
+ table_html += '</table>'
if action in [ "activate", "sync_restart",
"restart" ]:
title = _("Confirm activating foreign changes")
@@ -4784,7 +4784,7 @@ def mode_changelog(phase):
"discard if you proceed:")
c = wato_confirm(title,
- HTML('<img class=foreignchanges
src="images/icon_foreign_changes.png">' + text + table +
+ HTML('<img class=foreignchanges
src="images/icon_foreign_changes.png">' + text + table_html +
_("Do you really want to proceed?")))
if c == False:
return ""
@@ -4866,28 +4866,28 @@ def mode_changelog(phase):
if is_distributed():
# Distributed WATO: Show replication state of each site
- html.write("<h3>%s</h3>" % _("Site Status"))
repstatus = load_replication_status()
sites = [(name, config.site(name)) for name in config.sitenames() ]
sort_sites(sites)
- html.write("<table class=data>")
- html.write("<tr>")
- html.write("<th>%s</th>" % _("Actions") +
- "<th>%s</th>" % _("ID") +
- "<th>%s</th>" % _("Alias"))
- html.write("<th>%s</th>" % _("Status") +
- "<th>%s</th>" % _("Version") +
- "<th>%s</th>" % _("Core") +
- "<th>%s</th>" % _("Hosts") +
- "<th>%s</th>" % _("Services"))
- if sitestatus_do_async_replication:
- html.write("<th>%s</th>" % _("Replication
result"))
- else:
- html.write("<th colspan=2>%s</th>" %
_("Pending changes") +
- "<th>%s</th>" % _("Last
result"))
- html.write("</tr>")
- odd = "odd"
+ table.begin(_("Site Status"), searchable=False)
+ # html.write("<table class=data>")
+ # html.write("<tr>")
+ # html.write("<th>%s</th>" % _("Actions") +
+ # "<th>%s</th>" % _("ID") +
+ # "<th>%s</th>" % _("Alias"))
+ # html.write("<th>%s</th>" % _("Status") +
+ # "<th>%s</th>" % _("Version") +
+ # "<th>%s</th>" % _("Core") +
+ # "<th>%s</th>" % _("Hosts") +
+ # "<th>%s</th>" % _("Services"))
+ # if sitestatus_do_async_replication:
+ # html.write("<th>%s</th>" % _("Replication
result"))
+ # else:
+ # html.write("<th colspan=2>%s</th>" %
_("Pending changes") +
+ # "<th>%s</th>" % _("Last
result"))
+ # html.write("</tr>")
+
num_replsites = 0 # for detecting end of bulk replication
for site_id, site in sites:
is_local = site_is_local(site_id)
@@ -4895,6 +4895,8 @@ def mode_changelog(phase):
if not is_local and not site.get("replication"):
continue
+ table.row()
+
if site.get("disabled"):
ss = {}
status = "disabled"
@@ -4904,60 +4906,43 @@ def mode_changelog(phase):
srs = repstatus.get(site_id, {})
- # Make row red, if site status is not online
- html.write('<tr class="data %s0">' % odd)
- odd = odd == "odd" and "even" or "odd"
-
- # Multisite-URL
- html.write("<td class=icons>")
+ # Iconbuttons
+ table.cell(_("Actions"), css="buttons")
edit_url = make_link([("mode", "edit_site"),
("edit", site_id)])
html.icon_button(edit_url, _("Edit the properties of this
site"), "edit")
site_url = site.get("multisiteurl")
if site_url:
html.icon_button(site_url, _("Open this site's local web
user inteface"), "url", target="_blank")
- html.write("</td>")
# ID & Alias
- html.write("<td>%s</td>" % site_id)
- html.write("<td>%s</td>" %
site.get("alias", ""))
+ table.cell(_("ID"), site_id)
+ table.cell(_("Alias"), site.get("alias",
""))
# Livestatus
- html.write('<td><img
src="images/button_sitestatus_%s_lo.png"></td>' % (status))
+ table.cell(_("Status"))
+ html.write('<img
src="images/button_sitestatus_%s_lo.png">' % (status))
# Livestatus-Version
- html.write('<td>%s</td>' %
ss.get("livestatus_version", ""))
+ table.cell(_("Version"), ss.get("livestatus_version",
""))
# Core-Version
- html.write('<td>%s</td>' %
ss.get("program_version", ""))
+ table.cell(_("Core"), ss.get("program_version",
""))
# Hosts/services
- html.write('<td class=number><a
href="view.py?view_name=sitehosts&site=%s">%s</a></td>'
%
+ table.cell(_("Hosts"), css="number")
+ html.write('<a
href="view.py?view_name=sitehosts&site=%s">%s</a>' %
(site_id, ss.get("num_hosts", "")))
- html.write('<td class=number><a
href="view.py?view_name=sitesvcs&site=%s">%s</a></td>' %
+ table.cell(_("Services"), css="number")
+ html.write('<a
href="view.py?view_name=sitesvcs&site=%s">%s</a>' %
(site_id, ss.get("num_services", "")))
- ## # Uptime / Last restart
- ## if "program_start" in ss:
- ## age_text = html.age_text(time.time() -
ss["program_start"])
- ## else:
- ## age_text = ""
- ## html.write('<td class=number>%s</td>' % age_text)
-
- # Type
- ## sitetype = ''
- ## if is_local:
- ## sitetype = _("local")
- ## elif site["replication"] == "slave":
- ## sitetype = _("Slave")
- ## html.write("<td>%s</td>" % sitetype)
-
need_restart = srs.get("need_restart")
need_sync = srs.get("need_sync") and not
site_is_local(site_id)
uptodate = not (need_restart or need_sync)
# Start asynchronous replication
if sitestatus_do_async_replication:
- html.write("<td class=repprogress>")
+ table.cell(_("Activation"), css="repprogress")
# Do only include sites that are known to be up
if not site_is_local(site_id) and not "secret" in site:
html.write("<b>%s</b>" % _("Not logged
in."))
@@ -4975,10 +4960,9 @@ def mode_changelog(phase):
html.javascript("wato_do_replication('%s',
%d);" %
(site_id, int(estimated_duration * 1000.0)))
num_replsites += 1
- html.write("</td>")
else:
# State
- html.write("<td class=buttons>")
+ table.cell("", css="buttons")
if srs.get("need_sync") and not site_is_local(site_id):
html.write('<img class=icon title="%s"
src="images/icon_need_replicate.png">' %
_("This site is not update and needs a
replication."))
@@ -4988,10 +4972,9 @@ def mode_changelog(phase):
if uptodate:
html.write('<img class=icon title="%s"
src="images/icon_siteuptodate.png">' %
_("This site is up-to-date."))
- html.write("</td>")
# Actions
- html.write("<td class=buttons>")
+ table.cell(_("Activate"), css="buttons")
sync_url = make_action_link([("mode",
"changelog"),
("_site", site_id), ("_siteaction",
"sync")])
restart_url = make_action_link([("mode",
"changelog"),
@@ -5010,7 +4993,6 @@ def mode_changelog(phase):
html.buttonlink(restart_url, _("Restart"))
else:
html.buttonlink(restart_url, _("Restart"))
- html.write("</td>")
# Last result
result = srs.get("result", "")
@@ -5018,10 +5000,10 @@ def mode_changelog(phase):
result = html.strip_tags(result)
result = '<span
title="%s">%s...</span>' % \
(html.attrencode(result), result[:20])
- html.write("<td>%s</td>" % result)
+ table.cell(_("Last Result"), result)
+
+ table.end()
- html.write("</tr>")
- html.write("</table>")
# The Javascript world needs to know, how many asynchronous
# replication jobs it should wait to be finished.
if sitestatus_do_async_replication and num_replsites > 0: