fixed router bug
This commit is contained in:
@@ -39,3 +39,7 @@
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.clickable {
|
||||
cursor:pointer;
|
||||
}
|
||||
|
||||
3
app/client/no_access.html
Normal file
3
app/client/no_access.html
Normal file
@@ -0,0 +1,3 @@
|
||||
<template name="no_access">
|
||||
No access!
|
||||
</template>
|
||||
@@ -7,18 +7,20 @@ Tracker.autorun(function() {
|
||||
}
|
||||
});
|
||||
|
||||
Router.route('/', function() {
|
||||
if (Meteor.zoblak.client.accessible('start')) {
|
||||
Session.set('templateName', 'start');
|
||||
} else {
|
||||
Session.set('templateName', 'no_access')
|
||||
function safeRoute(route) {
|
||||
return function () {
|
||||
console.log('go ', route);
|
||||
if (Meteor.zoblak.client.accessible(route)) {
|
||||
Session.set('templateName', route);
|
||||
} else {
|
||||
Session.set('templateName', 'no_access')
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Router.route('/farmalarm', function() {
|
||||
if (Meteor.zoblak.client.accessible('alarm')) {
|
||||
Session.set('templateName', 'alarm');
|
||||
} else {
|
||||
Session.set('templateName', 'no_access')
|
||||
}
|
||||
});
|
||||
|
||||
Router.route('/', safeRoute('start'));
|
||||
Router.route('/alarm', safeRoute('alarm'));
|
||||
Router.route('/log', safeRoute('log'));
|
||||
Router.route('/surveillance', safeRoute('surveillance'));
|
||||
Router.route('/weather', safeRoute('weather'));
|
||||
|
||||
@@ -2,23 +2,23 @@
|
||||
<div></div>
|
||||
<ul class="nav nav-tabs">
|
||||
{{#if accessible 'start'}}
|
||||
<li role="presentation" class="{{ class_for 'start' }}"><a href="#">Stanje</a></li>
|
||||
<li role="presentation" class="{{ class_for 'start' }}"><a class="clickable">Stanje</a></li>
|
||||
{{/if}}
|
||||
|
||||
{{#if accessible 'weather'}}
|
||||
<li role="presentation" class="{{ class_for 'weather' }}"><a href="#">Vrijeme</a></li>
|
||||
<li role="presentation" class="{{ class_for 'weather' }}"><a class="clickable">Vrijeme</a></li>
|
||||
{{/if}}
|
||||
|
||||
{{#if accessible 'log'}}
|
||||
<li role="presentation" class="{{ class_for 'log' }}"><a href="#">Novosti</a></li>
|
||||
<li role="presentation" class="{{ class_for 'log' }}"><a class="clickable">Novosti</a></li>
|
||||
{{/if}}
|
||||
|
||||
{{#if accessible 'surveillance'}}
|
||||
<li role="presentation" class="{{ class_for 'surveillance' }}"><a href="#">Videonadzor</a></li>
|
||||
<li role="presentation" class="{{ class_for 'surveillance' }}"><a class="clickable">Videonadzor</a></li>
|
||||
{{/if}}
|
||||
|
||||
{{#if accessible 'alarm'}}
|
||||
<li role="presentation" class="{{ class_for 'alarm' }}"><a href="#">Alarm</a></li>
|
||||
<li role="presentation" class="{{ class_for 'alarm' }}"><a class="clickable">Alarm</a></li>
|
||||
{{/if}}
|
||||
|
||||
<li role="presentation" class="controller_selection"> <input type="number" id="controller" name="controller" value="{{ selected_controller }}" min="1" max="99999"> <button id="switch" name="switch">Prebaci</button>
|
||||
|
||||
@@ -18,25 +18,27 @@ Template.tabs.helpers({
|
||||
accessible: Meteor.zoblak.client.accessible
|
||||
});
|
||||
|
||||
|
||||
|
||||
Template.tabs.events({
|
||||
'click .start': function() {
|
||||
Session.set('templateName', 'start');
|
||||
Router.go('/');
|
||||
},
|
||||
'click .weather': function() {
|
||||
Session.set('templateName', 'weather');
|
||||
Router.go('/weather');
|
||||
},
|
||||
'click .log': function() {
|
||||
Session.set('templateName', 'log');
|
||||
Router.go('/log');
|
||||
},
|
||||
'click .surveillance': function() {
|
||||
Session.set('templateName', 'surveillance');
|
||||
},
|
||||
'click .settings': function() {
|
||||
Session.set('templateName', 'settings');
|
||||
Router.go('/surveillance');
|
||||
},
|
||||
|
||||
'click .alarm': function() {
|
||||
Session.set('templateName', 'alarm');
|
||||
Router.go('/alarm');
|
||||
},
|
||||
'click .settings': function() {
|
||||
Session.set('templateName', 'settings');
|
||||
},
|
||||
|
||||
'click #switch': function() {
|
||||
|
||||
Reference in New Issue
Block a user