Commit b8e77397 authored by Curtis Adam's avatar Curtis Adam Committed by Tom Käsler

Refactor the access denied template

parent b9633dcf
......@@ -20,7 +20,7 @@
@import '../imports/ui/learn/progress.scss';
@import '../imports/ui/pomodoroTimer/pomodoroTimer.scss';
@import '../imports/ui/admin/admin.scss';
@import '../imports/ui/access_denied/access_denied.scss';
@import '../imports/ui/accessDenied/accessDenied';
@import '../imports/ui/markdeep/content.scss';
@import '../imports/ui/main/sweetAlert2.scss';
@import '../imports/ui/loadingScreen/loadingScreen.scss';
......
......@@ -32,6 +32,11 @@ Router.route('/firstLogin', {
template: 'firstLoginContent'
});
Router.route('/accessDenied', {
name: 'accessDenied',
template: 'accessDenied'
});
Router.route('/home', {
name: 'home',
template: 'welcome',
......@@ -858,6 +863,9 @@ var isSignedIn = function () {
if (Roles.userIsInRole(Meteor.userId(), ['firstLogin'])) {
Router.go('firstLogin');
}
if (Roles.userIsInRole(Meteor.userId(), ['blocked'])) {
Router.go('accessDenied');
}
this.next();
}
};
......
<template name="accessDenied">
<div class="text-left col-md-12" id="access-denied-admin">
<h2>{{_ "access-denied.title"}}</h2>
<p>{{_ "access-denied.reason"}}{{currentUser.blockedtext}}</p>
<br/>
<hr/>
<button id="logout_access_denied_blocked" type="button" class="btn btn-danger btn-block btn-raised">{{_ "access-denied.button"}}</button>
</div>
</template>
\ No newline at end of file
//------------------------ IMPORTS
import {Meteor} from "meteor/meteor";
import {Template} from "meteor/templating";
import "./accessDenied.html";
Meteor.subscribe("notifications");
/*
* ############################################################################
* accessDenied
* ############################################################################
*/
Template.accessDenied.events({
'click #logout_access_denied_blocked': function (event) {
event.preventDefault();
Meteor.logout();
Router.go('home');
}
});
This diff is collapsed.
//------------------------ IMPORTS
import {Meteor} from "meteor/meteor";
import {Template} from "meteor/templating";
import {Session} from "meteor/session";
import {Notifications} from "../../api/notifications.js";
import "./access_denied.html";
Meteor.subscribe("notifications");
/*
* ############################################################################
* access_denied_nav_admin
* ############################################################################
*/
Template.access_denied.events({
'click #logout_access_denied': function (event) {
event.preventDefault();
Meteor.logout();
Router.go('home');
},
'click #logout_access_denied_blocked': function (event) {
event.preventDefault();
Meteor.logout();
Router.go('home');
}
});
/*
* ############################################################################
* access_denied_nav_admin
* ############################################################################
*/
Template.access_denied_nav_admin.onRendered(function () {
Session.set("searchValue", undefined);
});
Template.access_denied_nav_admin.helpers({
getUsername: function () {
if (Meteor.user()) {
return Meteor.user().profile.name;
}
},
searchCategories: function () {
return Session.get("searchValue") ? CardsetsIndex.search(Session.get("searchValue")).fetch() : undefined;
},
isActiveProfile: function () {
if (ActiveRoute.name(/^profile/)) {
return Router.current().params._id === Meteor.userId();
}
return false;
},
countNotifications: function () {
return Notifications.find({
read: false,
target_type: 'user',
target: Meteor.userId()
}).count();
},
getNotifications: function () {
return Notifications.find({
cleared: false,
target_type: 'user',
target: Meteor.userId()
}, {sort: {date: -1}});
},
getLink: function () {
return "/cardset/" + this.link_id;
}
});
Template.access_denied_nav_admin.events({
'keyup #input-search': function (event) {
event.preventDefault();
Session.set("searchValue", $(event.currentTarget).val());
if ($(event.currentTarget).val() && CardsetsIndex.search(Session.get("searchValue")).count()) {
$('#searchDropdown').addClass("open");
} else {
$('#searchDropdown').removeClass("open");
}
},
'click #searchResults': function () {
$('#searchDropdown').removeClass("open");
$('#input-search').val('');
},
'click #notificationsBtn': function () {
var notifications = Notifications.find({
read: false,
target_type: 'user',
target: Meteor.userId()
});
notifications.forEach(function (notification) {
Meteor.call("setNotificationAsRead", notification._id);
});
},
'click #clearBtn': function () {
var notifications = Notifications.find({
cleared: false,
target_type: 'user',
target: Meteor.userId()
});
notifications.forEach(function (notification) {
Meteor.call("setNotificationAsCleared", notification._id);
});
}
});
/*
* ############################################################################
* access_denied_content_only
* ############################################################################
*/
Template.access_denied_content_only.events({
'click #logout_access_denied_blocked': function (event) {
event.preventDefault();
Meteor.logout();
Router.go('home');
}
});
/*
* ############################################################################
* access_denied_content_only
* ############################################################################
*/
Template.access_denied_memo_blocked.events({
'click #back_to_pool': function () {
Router.go('home');
}
});
/*
* ############################################################################
* access_denied_profile_incomplete_content_only
* ############################################################################
*/
Template.access_denied_profile_incomplete_content_only.events({
'click #completeProfileGoToProfile': function () {
Router.go('profileSettings', {
_id: Meteor.userId()
});
},
'click #completeProfileCancel': function () {
Router.go('learn');
}
});
This diff is collapsed.
<template name="cardsetAccess">
{{#if isInRole 'firstLogin'}}
{{> firstLoginContent}}
{{else}}
{{#if isInRole 'blocked'}}
{{> access_denied_content_only}}
{{#if hasPermission}}
{{#if learningActive}}
{{> cardset}}
{{else}}
{{#if hasPermission}}
{{#if learningActive}}
{{> cardset}}
{{else}}
{{> cardset}}
{{/if}}
{{else}}
<div class="col-md-12">
<h4>{{_ "permission"}}</h4>
</div>
{{/if}}
{{> cardset}}
{{/if}}
{{else}}
{{> accessDenied}}
{{/if}}
</template>
......
This diff is collapsed.
<template name="cardsetManageEditors">
{{#if isInRole 'firstLogin'}}
{{> firstLoginContent}}
{{#unless isCardsetOwner _id}}
{{> accessDenied}}
{{else}}
{{#if isInRole 'blocked'}}
{{> access_denied_content_only}}
{{else}}
{{#unless isCardsetOwner _id}}
{{> access_denied_content_only}}
{{else}}
<div class="container">
<h3 class="modal-title">{{_ "modal-dialog.manageEditors" name = this.name}}</h3>
<div style="overflow-x:auto;">
<table class="table table-striped table-hover table-user-list">
<tbody>
<tr class="active">
<th>{{_ "panel-body.givenname"}}</th>
<th>{{_ "panel-body.birthname"}}</th>
<th>{{_ "panel-body.roles"}}</th>
<th></th>
</tr>
{{#each getEditors}}
<tr>
<td>{{this.givenname}}</td>
<td>{{this.birthname}}</td>
<td> {{getRoles this.roles}}</td>
<td>
{{#if isCardsetEditor this.id}}
<a class="btn btn-block btn-raised btn-danger removeEditor"
data-id="{{this.id}}">
<i class="fa fa-minus"></i> {{_ "admin.cardset.removeFromWordcloud"}}
</a>
{{else}}
<a class="btn btn-block btn-raised btn-success addEditor"
data-id="{{this.id}}">
<i class="fa fa-plus"></i> {{_ "admin.cardset.addToWordcloud"}}
</a>
{{/if}}
</td>
</tr>
{{/each}}
</tbody>
</table>
</div>
<button class="btn btn-block btn-raised btn-danger" id="backButton">
<span class="pull-left"><i class="fa fa-arrow-left"></i> {{_ "backbutton"}}</span>
</button>
</div>
{{/unless}}
{{/if}}
{{/if}}
<div class="container">
<h3 class="modal-title">{{_ "modal-dialog.manageEditors" name = this.name}}</h3>
<div style="overflow-x:auto;">
<table class="table table-striped table-hover table-user-list">
<tbody>
<tr class="active">
<th>{{_ "panel-body.givenname"}}</th>
<th>{{_ "panel-body.birthname"}}</th>
<th>{{_ "panel-body.roles"}}</th>
<th></th>
</tr>
{{#each getEditors}}
<tr>
<td>{{this.givenname}}</td>
<td>{{this.birthname}}</td>
<td> {{getRoles this.roles}}</td>
<td>
{{#if isCardsetEditor this.id}}
<a class="btn btn-block btn-raised btn-danger removeEditor"
data-id="{{this.id}}">
<i class="fa fa-minus"></i> {{_ "admin.cardset.removeFromWordcloud"}}
</a>
{{else}}
<a class="btn btn-block btn-raised btn-success addEditor"
data-id="{{this.id}}">
<i class="fa fa-plus"></i> {{_ "admin.cardset.addToWordcloud"}}
</a>
{{/if}}
</td>
</tr>
{{/each}}
</tbody>
</table>
</div>
<button class="btn btn-block btn-raised btn-danger" id="backButton">
<span class="pull-left"><i class="fa fa-arrow-left"></i> {{_ "backbutton"}}</span>
</button>
</div>
{{/unless}}
</template>
......@@ -30,7 +30,8 @@
{{#if isMobilePreviewActive}}
<div class="mobilePreviewContainer">
<div class="mobilePreviewFrame {{#if isMobilePreviewRotated}}portrait{{else}}landscape{{/if}}">
<div class="mobilePreviewContent {{#if isMobilePreviewRotated}}portrait{{else}}landscape{{/if}}">
<div class="mobilePreviewContent {{#if
isMobilePreviewRotated}}portrait{{else}}landscape{{/if}}">
{{> flashcardSidebar}}
{{> presentationView}}
</div>
......@@ -44,33 +45,17 @@
</template>
<template name="newCard">
{{#if isInRole 'firstLogin'}}
{{> firstLoginContent}}
{{#if isCardsetOwner this._id}}
{{> editor}}
{{else}}
{{#if isInRole 'blocked'}}
{{> access_denied_content_only}}
{{else}}
{{#if isCardsetOwner this._id}}
{{> editor}}
{{else}}
<h4>{{_ "permission"}}</h4>
{{/if}}
{{/if}}
<h4>{{_ "permission"}}</h4>
{{/if}}
</template>
<template name="editCard">
{{#if isInRole 'firstLogin'}}
{{> firstLoginContent}}
{{#if isEditor}}
{{> editor}}
{{else}}
{{#if isInRole 'blocked'}}
{{> access_denied_content_only}}
{{else}}
{{#if isEditor}}
{{> editor}}
{{else}}
<h4>{{_ "permission"}}</h4>
{{/if}}
{{/if}}
{{> accessDenied}}
{{/if}}
</template>
\ No newline at end of file
<template name="filterIndex">
{{#if isInRole 'firstLogin'}}
{{> firstLoginContent}}
{{else}}
{{#if isInRole 'blocked'}}
{{> access_denied_content_only}}
{{else}}
{{> showLicense}}
{{#if isActiveRoute regex='alldecks|repetitorium'}}
{{> cardsetFormAdmin}}
{{/if}}
{{#if isActiveRoute regex='alldecks|create'}}
{{> cardsetDeleteForm}}
{{> cardsetForm}}
{{> filterIndexCreate}}
{{/if}}
{{> showLicense}}
{{#if isActiveRoute regex='alldecks|repetitorium'}}
{{> cardsetFormAdmin}}
{{/if}}
{{#if isActiveRoute regex='alldecks|create'}}
{{> cardsetDeleteForm}}
{{> cardsetForm}}
{{> filterIndexCreate}}
{{/if}}
{{#if isActiveRoute regex='repetitorium'}}
{{> cardsetDeleteForm}}
{{> cardsetForm}}
{{> filterIndexRepetitorium}}
{{/if}}
{{#if isActiveRoute regex='repetitorium'}}
{{> cardsetDeleteForm}}
{{> cardsetForm}}
{{> filterIndexRepetitorium}}
{{/if}}
{{#if isActiveRoute 'learn'}}
{{> filterIndexWorkload}}
{{/if}}
{{#if isActiveRoute 'learn'}}
{{> filterIndexWorkload}}
{{/if}}
{{#if isActiveRoute 'shuffle'}}
{{> cardsetForm}}
{{> filterIndexShuffle}}
{{/if}}
{{#if isActiveRoute 'shuffle'}}
{{> cardsetForm}}
{{> filterIndexShuffle}}
{{/if}}
{{#if isActiveRoute 'pool'}}
{{> filterIndexPool}}
{{/if}}
{{/if}}
{{#if isActiveRoute 'pool'}}
{{> filterIndexPool}}
{{/if}}
</template>
......
<template name="learnAlgorithmAccess">
{{#if isInRole 'firstLogin'}}
{{> firstLoginContent}}
{{else}}
{{#if isInRole 'blocked'}}
{{> access_denied_content_only}}
{{#if hasPermission}}
{{#if isInBonusAndProfileIncomplete}}
{{> accessDenied}}
{{else}}
{{#if hasPermission}}
{{#if isInBonusAndProfileIncomplete}}
{{> access_denied_profile_incomplete_content_only}}
{{else}}
{{> learnAlgorithms}}
{{/if}}
{{else}}
<h4>{{_ "permission"}}</h4>
{{/if}}
{{> learnAlgorithms}}
{{/if}}
{{else}}
<h4>{{_ "permission"}}</h4>
{{/if}}
</template>
......@@ -53,16 +45,19 @@
{{#if isQuestionSide}}
<div id="answerButtons" class="btn-group btn-group-justified">
<div class="btn-group" role="group">
<button id="learnShowAnswer" class="btn btn-success btn-block btn-raised answer show-answer"
title="{{_ "wozniak.show"}}" {{isPomodoroBreakActive}}>{{_ "wozniak.show"}} {{#if fullscreenActive}}
<span class="hidden-xs">( {{_ "key" key='y'}} )</span>{{/if}}</button>
<button id="learnShowAnswer" class="btn btn-success btn-block btn-raised answer show-answer"
title="{{_ "wozniak.show"}}" {{isPomodoroBreakActive}}>{{_ "wozniak.show"}} {{#if
fullscreenActive}}
<span class="hidden-xs">( {{_ "key" key='y'}} )</span>{{/if}}</button>
</div>
{{#unless gotOneCardLeft}}
<div class="btn-group" role="group">
<button href="#" id="skipAnswer" class="btn btn-danger btn-block btn-raised answer show-answer"
title="{{_ "wozniak.skip"}}" {{isPomodoroBreakActive}}>{{_ "wozniak.skip"}} {{#if fullscreenActive}}
<span class="hidden-xs">( {{_ "arrowKeys"}} )</span>{{/if}}</button>
</div>
<div class="btn-group" role="group">
<button href="#" id="skipAnswer"
class="btn btn-danger btn-block btn-raised answer show-answer"
title="{{_ "wozniak.skip"}}" {{isPomodoroBreakActive}}>{{_ "wozniak.skip"}} {{#if
fullscreenActive}}
<span class="hidden-xs">( {{_ "arrowKeys"}} )</span>{{/if}}</button>
</div>
{{/unless}}
</div>
{{else}}
......
<template name="progress">
{{#if isInRole 'firstLogin'}}
{{> firstLoginContent}}
{{else}}
{{#if isInRole 'blocked'}}
{{> access_denied_content_only}}
{{else}}
<div class="container">
<div class="well">
{{> graph}}
</div>
<button class="btn btn-block btn-raised btn-danger" id="backButton">
<div class="container">
<div class="well">
{{> graph}}
</div>
<button class="btn btn-block btn-raised btn-danger" id="backButton">
<span class="pull-left">{{#if isStatsOwner}}{{_ "backbutton"}}{{else}}{{_
"backbuttonStatistics"}}{{/if}}</span>
</button>
</div>
{{/if}}
{{/if}}
</button>
</div>
</template>
<template name="graph">
......
......@@ -18,7 +18,7 @@ import "../learn/progress.js";
import "../profile/profile.js";
import "../admin/admin.js";
import "../filter/filter.js";
import "../access_denied/access_denied.js";
import "../accessDenied/accessDenied.js";
import "../firstLogin/firstLogin.js";
import "../editor/editor.js";
import "../editor/cardEditor.js";
......
<template name="presentation">
{{#if isInRole 'firstLogin'}}
{{> firstLoginContent}}
{{#if hasPermission}}
{{> presentationView}}
{{else}}
{{#if isInRole 'blocked'}}
{{> access_denied_content_only}}
{{else}}
{{#if hasPermission}}
{{> presentationView}}
{{else}}
<h4>{{_ "permission"}}</h4>
{{/if}}
{{/if}}
{{> accessDenied}}
{{/if}}
</template>
......
<template name="profile">
{{#if isInRole 'firstLogin'}}
{{> firstLoginContent}}
{{else}}
{{#if isInRole 'blocked'}}
{{> access_denied_content_only}}
{{else}}
{{#if isVisible}}
<div class="col-xs-12">
{{#if isActiveRoute 'profileOverview'}}
<div id="profileOverview">{{> profileOverview}}</div>
{{/if}}
{{#if isActiveRoute 'profileBilling'}}
<div id="profileBilling">
{{#if isUser}}
{{> profileBilling}}
{{else}}
<h3>{{_ "permission"}}</h3>
{{/if}}
</div>
{{#if isVisible}}
<div class="col-xs-12">
{{#if isActiveRoute 'profileOverview'}}
<div id="profileOverview">{{> profileOverview}}</div>
{{/if}}
{{#if isActiveRoute 'profileBilling'}}
<div id="profileBilling">
{{#if isUser}}
{{> profileBilling}}
{{else}}
<h3>{{_ "permission"}}</h3>
{{/if}}
</div>
{{/if}}
{{#if isActiveRoute 'profileMembership'}}
<div id="profileMembership">
{{#if isUser}}
{{> profileMembership}}
{{else}}
<h3>{{_ "permission"}}</h3>
{{/if}}
</div>
{{#if isActiveRoute 'profileMembership'}}
<div id="profileMembership">
{{#if isUser}}
{{> profileMembership}}
{{else}}
<h3>{{_ "permission"}}</h3>
{{/if}}
</div>
{{/if}}
{{#if isActiveRoute 'profileNotifications'}}
<div id="profileNotifications">
{{#if isUser}}
{{> profileNotifications}}
{{else}}
<h3>{{_ "permission"}}</h3>
{{/if}}
</div>
{{#if isActiveRoute 'profileNotifications'}}
<div id="profileNotifications">
{{#if isUser}}
{{> profileNotifications}}
{{else}}
<h3>{{_ "permission"}}</h3>
{{/if}}
</div>
{{/if}}
{{#if isActiveRoute 'profileSettings'}}
<div id="profileSettings">
{{#if isUser}}
{{> profileSettings}}
{{else}}
{{> profilePublic}}
{{/if}}
</div>
{{#if isActiveRoute 'profileSettings'}}
<div id="profileSettings">
{{#if isUser}}
{{> profileSettings}}
{{else}}
{{> profilePublic}}
{{/if}}
</div>
{{/if}}
{{#if isActiveRoute 'profileRequests'}}
<div id="profileRequests">
{{#if isUser}}
{{#if isInRole 'lecturer'}}
{{> profileRequests}}
{{else}}
<h3>{{_ "permission"}}</h3>
{{/if}}
{{else}}
<h3>{{_ "permission"}}</h3>
{{/if}}
</div>
{{#if isActiveRoute 'profileRequests'}}
<div id="profileRequests">
{{#if isUser}}
{{#if isInRole 'lecturer'}}
{{> profileRequests}}
{{else}}
<h3>{{_ "permission"}}</h3>
{{/if}}
{{else}}
<h3>{{_ "permission"}}</h3>
{{/if}}
</div>
{{else}}
<div class="col-xs-12">
<div class="row">
<div id="profileprivate">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">{{_ "panel-body.profileprivate"}}</h3>
</div>
<div class="panel-body">{{_ "panel-body.profileprivatetext"}}</div>
</div>
{{/if}}
</div>
{{else}}
<div class="col-xs-12">
<div class="row">
<div id="profileprivate">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">{{_ "panel-body.profileprivate"}}</h3>
</div>
<div class="panel-body">{{_ "panel-body.profileprivatetext"}}</div>
</div>
</div>
{{/if}}
{{/if}}
</div>
</div>
{{/if}}
</template>
......
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 to comment