Ongoing rewrite work

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

View File

@ -51,5 +51,9 @@ module.exports = Mn.View.extend({
return 'Sign out';
}
},
initialize: function () {
this.listenTo(Cache.User, 'change', this.render);
}
});

View File

@ -8,15 +8,28 @@
<li class="nav-item dropdown">
<a href="#" class="nav-link" data-toggle="dropdown"><i class="fe fe-monitor"></i> Hosts</a>
<div class="dropdown-menu dropdown-menu-arrow">
<% if (canShow('proxy_hosts')) { %>
<a href="/nginx/proxy" class="dropdown-item ">Proxy Hosts</a>
<% } %>
<% if (canShow('redirection_hosts')) { %>
<a href="/nginx/redirection" class="dropdown-item ">Redirections</a>
<% } %>
<% if (canShow('streams')) { %>
<a href="/nginx/stream" class="dropdown-item ">Streams</a>
<% } %>
<% if (canShow('dead_hosts')) { %>
<a href="/nginx/404" class="dropdown-item ">404 Hosts</a>
<% } %>
</div>
</li>
<% if (canShow('access_lists')) { %>
<li class="nav-item">
<a href="/nginx/access" class="nav-link"><i class="fe fe-lock"></i> Access Lists</a>
</li>
<% } %>
<% if (showUsers()) { %>
<li class="nav-item">
<a href="/users" class="nav-link"><i class="fe fe-users"></i> Users</a>

View File

@ -17,14 +17,25 @@ module.exports = Mn.View.extend({
events: {
'click @ui.links': function (e) {
e.preventDefault();
Controller.navigate($(e.currentTarget).attr('href'), true);
let href = $(e.currentTarget).attr('href');
if (href !== '#') {
e.preventDefault();
Controller.navigate(href, true);
}
}
},
templateContext: {
showUsers: function () {
return Cache.User.isAdmin();
},
canShow: function (perm) {
return Cache.User.isAdmin() || Cache.User.canView(perm);
}
},
initialize: function () {
this.listenTo(Cache.User, 'change', this.render);
}
});