Commit 93c224ff authored by Ziirish's avatar Ziirish

consistent client order on live monitor + display client labels to ease readability

parent f054e1e2
......@@ -10,6 +10,7 @@
from . import api, cache_key, force_refresh
from ..engines.server import BUIServer # noqa
from .custom import fields, Resource
from .client import ClientLabels
from ..filter import mask
from ..exceptions import BUIserverException
from ..decorators import browser_cache
......@@ -96,6 +97,7 @@ class Counters(Resource):
'client': fields.String(required=True, description='Client name'),
'agent': fields.String(description='Server (agent) name'),
'counters': fields.Nested(counters_fields, description='Various statistics about the running backup'),
'labels': fields.List(fields.String, description='List of labels'),
})
@ns.marshal_with(monitor_fields, code=200, description='Success')
......@@ -151,6 +153,10 @@ class Counters(Resource):
res['client'] = client
res['agent'] = server
res['counters'] = counters
try:
res['labels'] = ClientLabels._get_labels(client, server)
except BUIserverException as exp:
self.abort(500, str(exp))
return res
......@@ -177,6 +183,7 @@ class Live(Resource):
'client': fields.String(required=True, description='Client name'),
'agent': fields.String(description='Server (agent) name'),
'counters': fields.Nested(counters_fields, description='Various statistics about the running backup'),
'labels': fields.List(fields.String, description='List of labels'),
})
@ns.marshal_list_with(live_fields, code=200, description='Success')
......@@ -197,7 +204,10 @@ class Live(Resource):
'phase': 2,
'path': '/etc/some/configuration',
'...': '...'
}
},
'labels': [
'...'
]
},
{
'client': 'client12',
......@@ -206,7 +216,10 @@ class Live(Resource):
'phase': 3,
'path': '/etc/some/other/configuration',
'...': '...'
}
},
'labels': [
'...'
]
}
]
......@@ -255,6 +268,10 @@ class Live(Resource):
data['counters'] = bui.client.get_counters(client, agent=serv)
except BUIserverException:
data['counters'] = {}
try:
data['labels'] = ClientLabels._get_labels(client, serv)
except BUIserverException as exp:
data['labels'] = []
res.append(data)
else:
for client in running:
......@@ -268,6 +285,10 @@ class Live(Resource):
data['counters'] = bui.client.get_counters(client, agent=server)
except BUIserverException:
data['counters'] = {}
try:
data['labels'] = ClientLabels._get_labels(client)
except BUIserverException as exp:
data['labels'] = []
res.append(data)
return res
......
......@@ -7,9 +7,9 @@
<li class="active">{{ _('Live monitor') }}</li>
</ul>
<div class="row" id="live-container" ng-cloak>
<div class="col-lg-12" ng-repeat="client in clients">
<div class="col-lg-12" ng-repeat="client in clients | orderBy:'client'">
<br />
<h1 class="page-header">{{ _('{{ ::client.client }}<span ng-if="client.agent"> on {{ ::client.agent }}</span>') }}</h1>
<h1 class="page-header">{{ _('{{ ::client.client }}<span ng-if="client.agent"> on {{ ::client.agent }}</span><span class="pull-right"><span ng-repeat="label in client.labels" class="label label-info">{{ label }}</span></span> ') }}</h1>
{# From here, the jinja syntax is escaped because we use the angularjs syntax #}
{% raw %}
<h4>{{ client.counters.percent | number:0 }}%</h4>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment