Skip to content

Commit

Permalink
rework the navigation menu of the Web UI
Browse files Browse the repository at this point in the history
  • Loading branch information
julien6387 committed Apr 4, 2024
1 parent e3e217d commit 1dfadf8
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 13 deletions.
10 changes: 7 additions & 3 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@
* Move the host statistics collector to the statistics collector process.
The option `stats_collecting_period` is now applicable to host statistics collector.

* Re-apply the eventual process `extra_args` when restarting the application.
* Re-apply the eventual process `extra_args` when restarting the application.

* In the Supervisors navigation menu of the Web UI, add a red light to Supervisor instances having raised a failure.

* Rework the navigation menu of the Web UI.

* Rework **Supvisors** `RPCInterface` exceptions.

Expand Down Expand Up @@ -534,7 +538,7 @@
* In the Process page of the Web UI, expand / shrink actions are not applicable to programs that are not owned
by a Supervisor group.

* In the application navigation menu of the Web UI, add a red light near the Applications title if any application
* In the Applications navigation menu of the Web UI, add a red light near the Applications title if any application
has raised a failure.

* In the Application page of the Web UI, default starting strategy is the starting strategy defined
Expand Down Expand Up @@ -566,7 +570,7 @@

* Enable stop sequence on *Unmanaged* applications.

* In the application navigation menu of the Web UI, add a red light to applications having raised a failure.
* In the Applications navigation menu of the Web UI, add a red light to applications having raised a failure.

* New application rules `distributed` and `addresses` added to the **Supvisors** rules file.
Non-distributed applications have all their processes started on the same node chosen in accordance with the
Expand Down
2 changes: 1 addition & 1 deletion supvisors/ui/application.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h1><a href="index.html" meld:id="supvisors_mid"><img src="img/supvisors.png"/><
</header>

<nav id="instance_list">
<h2>Supervisors</h2>
<h2 meld:id="instance_h_mid">Supervisors</h2>
<div>
<ul>
<li meld:id="instance_li_mid"><a href="#" meld:id="instance_a_mid">Supervisor</a></li>
Expand Down
3 changes: 2 additions & 1 deletion supvisors/ui/css/menu.css
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,6 @@ nav li.failure::after {
content: url(../img/red_light_30.png);
float: right;
position: relative;
top: -30px;
top: -29px;
right: -5px;
}
2 changes: 1 addition & 1 deletion supvisors/ui/host_instance.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h1><a href="index.html" meld:id="supvisors_mid"><img src="img/supvisors.png"/><
</header>

<nav id="instance_list">
<h2>Supervisors</h2>
<h2 meld:id="instance_h_mid">Supervisors</h2>
<div>
<ul>
<li meld:id="instance_li_mid"><a href="#" meld:id="instance_a_mid">Supervisor</a></li>
Expand Down
2 changes: 1 addition & 1 deletion supvisors/ui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ <h1>
</header>

<nav id="instance_list">
<h2>Supervisors</h2>
<h2 meld:id="instance_h_mid">Supervisors</h2>
<div>
<ul>
<li meld:id="instance_li_mid"><a href="#" meld:id="instance_a_mid">Supervisor</a></li>
Expand Down
2 changes: 1 addition & 1 deletion supvisors/ui/proc_instance.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h1><a href="index.html" meld:id="supvisors_mid"><img src="img/supvisors.png"/><
</header>

<nav id="instance_list">
<h2>Supervisors</h2>
<h2 meld:id="instance_h_mid">Supervisors</h2>
<div>
<ul>
<li meld:id="instance_li_mid"><a href="#" meld:id="instance_a_mid">Supervisor</a></li>
Expand Down
20 changes: 15 additions & 5 deletions supvisors/web/viewhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,11 @@ def write_nav(self, root, identifier=None, appli=None):
self.write_nav_instances(root, identifier)
self.write_nav_applications(root, appli)

def write_nav_instances(self, root, identifier):
def write_nav_instances(self, root, identifier: str) -> None:
""" Write the node part of the navigation menu. """
mid_elt = root.findmeld('instance_li_mid')
identifiers = list(self.supvisors.mapper.instances.keys())
any_failure = False
# in discovery mode, other Supvisors instances arrive randomly in every Supvisors instance
# so let's sort them by name
if self.supvisors.options.discovery_mode:
Expand All @@ -145,10 +146,14 @@ def write_nav_instances(self, root, identifier):
except KeyError:
self.logger.debug(f'ViewHandler.write_nav_instances: failed to get instance status from {item}')
else:
failure = status.has_error()
any_failure |= failure
# set element class
update_attrib(li_elt, 'class', status.state.name)
if item == identifier:
update_attrib(li_elt, 'class', 'active')
if failure:
update_attrib(li_elt, 'class', 'failure')
# set hyperlink attributes
elt = li_elt.findmeld('instance_a_mid')
if status.state_modes.starting_jobs or status.state_modes.stopping_jobs:
Expand All @@ -161,10 +166,14 @@ def write_nav_instances(self, root, identifier):
else:
update_attrib(elt, 'class', 'off')
# set content
identifier = item
displayed_item = item
if item == self.sup_ctx.master_identifier:
identifier = f'{MASTER_SYMBOL} {item}'
elt.content(identifier)
displayed_item = f'{MASTER_SYMBOL} {item}'
elt.content(displayed_item)
# warn at title level if any application has a failure
if any_failure:
elt = root.findmeld('instance_h_mid')
update_attrib(elt, 'class', 'failure')

def write_nav_applications(self, root, appli):
""" Write the application part of the navigation menu. """
Expand Down Expand Up @@ -199,7 +208,8 @@ def write_nav_applications(self, root, appli):
elt.content(item.application_name)
# warn at title level if any application has a failure
if any_failure:
update_attrib(root.findmeld('appli_h_mid'), 'class', 'failure')
elt = root.findmeld('appli_h_mid')
update_attrib(elt, 'class', 'failure')

def write_header(self, root):
""" Write the header part of the page.
Expand Down

0 comments on commit 1dfadf8

Please sign in to comment.