Commit 6329df0b by Oláh István Gergely

dashboard: add label coloring to searching in node tags

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