Ongoing rewrite work

This commit is contained in:
Jamie Curnow committed 2018-07-09 11:22:10 +10:00
1 parent 30924a6922
commit 54d220a191
72 files changed
+3656 -113

No files matched your search

+16 -6
View File
@@ -2,8 +2,10 @@
<h1 class="page-title">Hi <%- getUserName() %></h1>
</div>
<% if (columns) { %>
<div class="row">
<div class="col-sm-6 col-lg-3">
<% if (canShow('proxy_hosts')) { %>
<div class="col-sm-<%- 24 / columns %> col-lg-<%- 12 / columns %>">
<div class="card p-3">
<div class="d-flex align-items-center">
<span class="stamp stamp-md bg-green mr-3">
@@ -15,8 +17,10 @@
</div>
</div>
</div>
<% } %>
<div class="col-sm-6 col-lg-3">
<% if (canShow('redirection_hosts')) { %>
<div class="col-sm-<%- 24 / columns %> col-lg-<%- 12 / columns %>">
<div class="card p-3">
<div class="d-flex align-items-center">
<span class="stamp stamp-md bg-yellow mr-3">
@@ -28,8 +32,10 @@
</div>
</div>
</div>
<% } %>
<div class="col-sm-6 col-lg-3">
<% if (canShow('streams')) { %>
<div class="col-sm-<%- 24 / columns %> col-lg-<%- 12 / columns %>">
<div class="card p-3">
<div class="d-flex align-items-center">
<span class="stamp stamp-md bg-blue mr-3">
@@ -41,17 +47,21 @@
</div>
</div>
</div>
<% } %>
<div class="col-sm-6 col-lg-3">
<% if (canShow('dead_hosts')) { %>
<div class="col-sm-<%- 24 / columns %> col-lg-<%- 12 / columns %>">
<div class="card p-3">
<div class="d-flex align-items-center">
<span class="stamp stamp-md bg-red mr-3">
<i class="fe fe-zap-off"></i>
</span>
<div>
<h4 class="m-0"><a href="/nginx/404"><%- getHostStat('404') %> <small>404 Hosts</small></a></h4>
<h4 class="m-0"><a href="/nginx/404"><%- getHostStat('dead') %> <small>404 Hosts</small></a></h4>
</div>
</div>
</div>
</div>
</div>
<% } %>
</div>
<% } %>
+34 -1
View File
@@ -10,6 +10,7 @@ const template = require('./main.ejs');
module.exports = Mn.View.extend({
template: template,
id: 'dashboard',
columns: 0,
stats: {},
@@ -38,7 +39,13 @@ module.exports = Mn.View.extend({
}
return '-';
}
},
canShow: function (perm) {
return Cache.User.isAdmin() || Cache.User.canView(perm);
},
columns: view.columns
}
},
@@ -57,5 +64,31 @@ module.exports = Mn.View.extend({
console.log(err);
});
}
},
/**
* @param {Object} [model]
*/
preRender: function (model) {
this.columns = 0;
// calculate the available columns based on permissions for the objects
// and store as a variable
//let view = this;
let perms = ['proxy_hosts', 'redirection_hosts', 'streams', 'dead_hosts'];
perms.map(perm => {
this.columns += Cache.User.isAdmin() || Cache.User.canView(perm) ? 1 : 0;
});
// Prevent double rendering on initial calls
if (typeof model !== 'undefined') {
this.render();
}
},
initialize: function () {
this.preRender();
this.listenTo(Cache.User, 'change', this.preRender);
}
});