Commit 6329df0b by Oláh István Gergely

dashboard: add label coloring to searching in node tags

parent bc6d45ee
......@@ -238,6 +238,7 @@ $(function () {
'name': result[i].name.toLowerCase(),
'icon': result[i].icon,
'status': result[i].status,
'label': result[i].label,
'url': result[i].url,
});
}
......@@ -254,7 +255,7 @@ $(function () {
}
}
for(var i=0; i<5 && i<search_result.length; i++)
html += generateNodeHTML(search_result[i].pk, search_result[i].name,
html += generateNodeHTML(search_result[i].name,
search_result[i].icon, search_result[i].status,
search_result[i].url);
if(search_result.length == 0)
......@@ -264,9 +265,9 @@ $(function () {
html = '';
for(var i=0; i<5 && i<search_result.length; i++)
html += generateNodeTagHTML(search_result[i].pk, search_result[i].name,
html += generateNodeTagHTML(search_result[i].name,
search_result[i].icon, search_result[i].status,
search_result[i].url);
search_result[i].label, search_result[i].url);
if(search_result.length == 0)
html += '<div class="list-group-item">No result</div>';
$("#dashboard-node-taglist").html(html);
......@@ -305,7 +306,7 @@ function generateVmHTML(pk, name, host, icon, _status, fav) {
'</a>';
}
function generateNodeHTML(pk, name, icon, _status, url) {
function generateNodeHTML(name, icon, _status, url) {
return '<a href="' + url + '" class="list-group-item" >' +
'<span class="index-node-list-name">' +
'<i class="' + icon + '" title="' + _status + '"></i> ' + name +
......@@ -314,8 +315,8 @@ function generateNodeHTML(pk, name, icon, _status, url) {
'</a>';
}
function generateNodeTagHTML(pk, name, icon, _status, url) {
return '<a href="' + url + '" class="label label-danger" >' +
function generateNodeTagHTML(name, icon, _status, label , url) {
return '<a href="' + url + '" class="label ' + label + '" >' +
'<i class="' + icon + '" title="' + _status + '"></i> ' + name +
'</a> ';
}
......
......@@ -933,6 +933,7 @@ class NodeList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView):
'name': i.name,
'icon': i.get_status_icon(),
'url': i.get_absolute_url(),
'label': i.get_status_label(),
'status': i.state.lower()} for i in nodes]
return HttpResponse(
......
......@@ -278,9 +278,9 @@ class Node(OperatedMixin, TimeStampedModel):
def get_status_label(self):
return {
'OFFLINE': 'label-warning',
'DISABLED': 'label-warning',
'MISSING': 'label-danger',
'OFFLINE': 'label-danger',
'DISABLED': 'label-danger',
'MISSING': 'label-warning',
'ONLINE': 'label-success'}.get(self.get_state(),
'label-danger')
......
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 sign in to comment