Service state colours, activity badge colours, readable named colours
This commit is contained in:
@@ -44,6 +44,17 @@ def _service_running(entry):
|
||||
return raw in _RUNNING_STATES
|
||||
|
||||
|
||||
# Paused, plus the four transitional states Windows reports while a service is
|
||||
# on its way somewhere.
|
||||
_TRANSITIONAL_STATES = ('paused', 'start pending', 'stop pending',
|
||||
'continue pending', 'pause pending', 'starting',
|
||||
'stopping', 'pausing')
|
||||
|
||||
|
||||
def _service_transitional(raw):
|
||||
return (raw or '').strip().lower() in _TRANSITIONAL_STATES
|
||||
|
||||
|
||||
def _service_name(entry):
|
||||
return entry.get('name') or entry.get('service') or 'Unknown'
|
||||
|
||||
@@ -465,7 +476,14 @@ def panel_services(asset_id: int):
|
||||
'name': name,
|
||||
'kind': (kind or '').lower() or None,
|
||||
'statelabel': 'Running' if running else (raw.title() or 'Unknown'),
|
||||
'statecolor': 'green' if running else ('red' if raw else 'gray'),
|
||||
# Amber for paused and the four Windows transitional states. A
|
||||
# service stuck in Start Pending is failing to start on a retry
|
||||
# cycle - which is what raises event 7011 - and a paused one was
|
||||
# paused deliberately. Painting either the same red as Stopped
|
||||
# loses the distinction that tells you which to chase.
|
||||
'statecolor': ('green' if running
|
||||
else 'yellow' if _service_transitional(raw)
|
||||
else 'red' if raw else 'gray'),
|
||||
}
|
||||
# Only offer Start/Stop to a caller who could actually run it. The
|
||||
# emission never consulted the caller, so a read-only viewer was shown
|
||||
@@ -601,9 +619,15 @@ def panel_activity(asset_id: int):
|
||||
key=lambda r: (r['eventtime'] is not None, r['eventtime']),
|
||||
reverse=True)
|
||||
|
||||
# The list renderer reads a badge colour from a ROW FIELD, so without this
|
||||
# every badge falls back to grey and the feed loses the one signal it is
|
||||
# there to carry.
|
||||
colours = {'critical': 'red', 'warning': 'yellow', 'info': 'gray'}
|
||||
|
||||
return success_response([{
|
||||
'title': r['title'],
|
||||
'severity': r['severity'],
|
||||
'severitycolor': colours.get(r['severity'], 'gray'),
|
||||
'detail': r['detail'],
|
||||
'eventtime': r['eventtime'].isoformat() + 'Z' if r['eventtime'] else None,
|
||||
} for r in rows[:15]])
|
||||
|
||||
@@ -244,6 +244,18 @@ class EndpointsPlugin(BasePlugin):
|
||||
'render': 'list',
|
||||
'collapsible': True,
|
||||
'filter': {'key': 'kind', 'equals': 'service'},
|
||||
# Facet on the STATE, not the status colour. statecolor is only
|
||||
# ever green, red or grey here, so chips derived from it would
|
||||
# read "OK" and "Critical" - not how anybody talks about a
|
||||
# service. statelabel carries the real vocabulary: Running,
|
||||
# Stopped, Paused, and the Windows transitional states. Any
|
||||
# value not listed still gets a chip, appended after these.
|
||||
'facets': {
|
||||
'key': 'statelabel',
|
||||
'order': ['Running', 'Stopped', 'Paused', 'Start Pending',
|
||||
'Stop Pending', 'Continue Pending', 'Pause Pending',
|
||||
'Unknown'],
|
||||
},
|
||||
'status': {
|
||||
'key': 'statecolor',
|
||||
'levels': {
|
||||
@@ -270,6 +282,18 @@ class EndpointsPlugin(BasePlugin):
|
||||
'render': 'list',
|
||||
'collapsible': True,
|
||||
'filter': {'key': 'kind', 'equals': 'process'},
|
||||
# Facet on the STATE, not the status colour. statecolor is only
|
||||
# ever green, red or grey here, so chips derived from it would
|
||||
# read "OK" and "Critical" - not how anybody talks about a
|
||||
# service. statelabel carries the real vocabulary: Running,
|
||||
# Stopped, Paused, and the Windows transitional states. Any
|
||||
# value not listed still gets a chip, appended after these.
|
||||
'facets': {
|
||||
'key': 'statelabel',
|
||||
'order': ['Running', 'Stopped', 'Paused', 'Start Pending',
|
||||
'Stop Pending', 'Continue Pending', 'Pause Pending',
|
||||
'Unknown'],
|
||||
},
|
||||
'status': {
|
||||
'key': 'statecolor',
|
||||
'levels': {
|
||||
@@ -313,6 +337,10 @@ class EndpointsPlugin(BasePlugin):
|
||||
'title': 'title',
|
||||
'badge': {
|
||||
'label': 'severity',
|
||||
# The renderer reads the colour from a row field; with
|
||||
# no colour declared every badge renders grey, which is
|
||||
# what the feed spent its first version doing.
|
||||
'color': 'severitycolor',
|
||||
'labelmap': {
|
||||
'critical': 'Critical',
|
||||
'warning': 'Warning',
|
||||
|
||||
Reference in New Issue
Block a user