def show(self) -> None: html.open_table(cellspacing="0", class_="sitestate") sites.update_site_states_from_dead_sites() for sitename, _sitealias in sites.sorted_sites(): site = sites.get_site_config(sitename) state = sites.states().get(sitename, sites.SiteStatus({})).get("state") if state is None: state = "missing" switch = "missing" text = escape_html_permissive(sitename) else: if state == "disabled": switch = "on" text = escape_html_permissive(site["alias"]) else: switch = "off" text = render_link( site["alias"], "view.py?view_name=sitehosts&site=%s" % sitename) html.open_tr() html.td(text, class_="left") html.open_td(class_="state") if switch == "missing": html.status_label(content=state, status=state, title=_("Site is missing")) else: url = makeactionuri_contextless( request, transactions, [ ("_site_switch", "%s:%s" % (sitename, switch)), ], filename="switch_site.py", ) html.status_label_button( content=state, status=state, title=_("enable this site") if state == "disabled" else _("disable this site"), onclick="cmk.sidebar.switch_site(%s)" % (json.dumps(url)), ) html.close_tr() html.close_table()
def show(self): html.open_table(cellspacing=0, class_="sitestate") sites.update_site_states_from_dead_sites() for sitename, _sitealias in config.sorted_sites(): site = config.site(sitename) state = sites.states().get(sitename, {}).get("state") if state is None: state = "missing" switch = "missing" text = sitename else: if state == "disabled": switch = "on" text = site["alias"] else: switch = "off" text = render_link( site["alias"], "view.py?view_name=sitehosts&site=%s" % sitename) html.open_tr() html.open_td(class_="left") html.write(text) html.close_td() html.open_td(class_="state") if switch == "missing": html.status_label(content=state, status=state, title=_("Site is missing")) else: url = html.makeactionuri_contextless([ ("_site_switch", "%s:%s" % (sitename, switch)), ], filename="switch_site.py") html.status_label_button( content=state, status=state, title=_("enable this site") if state == "disabled" else _("disable this site"), onclick="cmk.sidebar.switch_site(%s)" % (json.dumps(url))) html.close_tr() html.close_table()