fixed router bug

This commit is contained in:
Senad Uka
2016-10-29 17:01:09 +02:00
parent a8e37f2f48
commit 971ca889fc
5 changed files with 37 additions and 26 deletions

View File

@@ -39,3 +39,7 @@
cursor: pointer;
}
}
.clickable {
cursor:pointer;
}

View File

@@ -0,0 +1,3 @@
<template name="no_access">
No access!
</template>

View File

@@ -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'));

View File

@@ -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>

View File

@@ -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() {