Commit ab94cf0d authored by Curtis Adam's avatar Curtis Adam

Redirect to the original requested page after login (Excludes new accounts)

parent f238847d
......@@ -1863,6 +1863,14 @@
"confirm": "Ja, Präsentation fortsetzen!"
}
}
},
"fullscreen": {
"title": "Vollbildmodus ist nicht aktiv",
"text": "Für diese Ansicht wird der Vollbildmodus benötigt",
"button": {
"cancel": "Zurück",
"confirm": "Vollbildmodus aktivieren"
}
}
}
}
......@@ -266,6 +266,8 @@ export let CardNavigation = class CardNavigation {
if (screenfull.element === null && Session.get('fullscreen')) {
if (Route.isPresentation()) {
SweetAlertMessages.continuePresentation();
} else if (Route.isBox() || Route.isMemo()) {
SweetAlertMessages.activateFullscreen();
} else {
$(".toggleFullscreen").click();
}
......
......@@ -24,6 +24,14 @@ export let CardVisuals = class CardVisuals {
return Session.get('fullscreen');
}
static isScreenfullActive () {
if (NavigatorCheck.isIOS()) {
return true;
} else {
return screenfull.isFullscreen;
}
}
static checkFullscreen () {
let currentRoute = Router.current().route.getName();
if (currentRoute === (Route.isPresentation())) {
......
......@@ -6,6 +6,7 @@ let firstTimePresentation = 'isFirstTimePresentation';
let firstTimeLeitner = 'isFirstTimeLeitner';
let firstTimeWozniak = 'isFirstTimeWozniak';
let firstTimeDemo = 'isFirstTimeDemo';
let loginTarget;
export let MainNavigation = class MainNavigation {
......@@ -29,6 +30,14 @@ export let MainNavigation = class MainNavigation {
return firstTimeDemo;
}
static setLoginTarget (target) {
loginTarget = target;
}
static getLoginTarget () {
return loginTarget;
}
static toggleHelp () {
if ($('#helpModal').is(':visible')) {
$('#helpModal').modal('hide');
......
......@@ -21,6 +21,10 @@ export let Route = class Route {
return Router.current().route.getName() === "newCard";
}
static requiresUserInputForFullscreen () {
return (this.isPresentation() || this.isBox() || this.isMemo());
}
static isEditCard () {
return Router.current().route.getName() === "editCard";
}
......
import {Meteor} from "meteor/meteor";
import swal from "sweetalert2";
import * as screenfull from 'screenfull';
import {CardVisuals} from "./cardVisuals";
export let SweetAlertMessages = class SweetAlertMessages {
static completeProfile () {
......@@ -42,6 +43,27 @@ export let SweetAlertMessages = class SweetAlertMessages {
});
}
static activateFullscreen () {
swal({
title: TAPi18n.__('sweetAlert.fullscreen.title'),
html: TAPi18n.__('sweetAlert.fullscreen.text'),
type: "warning",
showCancelButton: true,
confirmButtonText: TAPi18n.__('sweetAlert.fullscreen.button.confirm'),
cancelButtonText: TAPi18n.__('sweetAlert.fullscreen.button.cancel'),
allowOutsideClick: false
}).then((result) => {
if (result.value) {
CardVisuals.toggleFullscreen();
} else {
screenfull.exit();
Router.go('cardsetdetailsid', {
_id: Router.current().params._id
});
}
});
}
static exitPresentation () {
swal({
title: TAPi18n.__('sweetAlert.presentation.end.title'),
......
......@@ -7,9 +7,26 @@ import {Route} from "../../api/route.js";
import {Filter} from "../../api/filter";
import {MarkdeepEditor} from "../../api/markdeepEditor";
import {WebPushNotifications} from "../../api/webPushSubscriptions";
import {UserPermissions} from "../../api/permissions";
import {MainNavigation} from "../../api/mainNavigation";
let loadingScreenTemplate = 'loadingScreen';
let linksWithNoLoginRequirement = [
'home',
'about',
'learning',
'faq',
'help',
'impressum',
'demo',
'demolist',
'agb',
'datenschutz',
'making',
'makinglist'
];
Router.route('/', function () {
this.redirect('home');
});
......@@ -48,6 +65,7 @@ Router.route('/home', {
},
action: function () {
if (this.ready()) {
CardVisuals.toggleFullscreen(true);
this.render();
} else {
this.render(loadingScreenTemplate);
......@@ -201,7 +219,7 @@ Router.route('/alldecks', {
name: 'alldecks',
template: 'filterIndex',
subscriptions: function () {
return [Meteor.subscribe('allCardsets'), Meteor.subscribe('paidCardsets')];
return [Meteor.subscribe('allCardsets'), Meteor.subscribe('paidCardsets'), Meteor.subscribe('userData')];
},
data: function () {
Session.set('helpFilter', "pool");
......@@ -210,7 +228,12 @@ Router.route('/alldecks', {
},
action: function () {
if (this.ready()) {
this.render();
if (UserPermissions.isAdmin()) {
this.render();
} else {
MainNavigation.setLoginTarget(false);
this.redirect('home');
}
} else {
this.render(loadingScreenTemplate);
}
......@@ -710,15 +733,20 @@ Router.route('/admin/dashboard', {
template: 'admin_dashboard',
layoutTemplate: 'admin_main',
loadingTemplate: 'admin_dashboard',
waitOn: function () {
return [Meteor.subscribe("serverInventory")];
subscriptions: function () {
return [Meteor.subscribe("serverInventory"), Meteor.subscribe('userData')];
},
data: function () {
Session.set('helpFilter', undefined);
},
action: function () {
if (this.ready()) {
this.render();
if (UserPermissions.isAdmin()) {
this.render();
} else {
MainNavigation.setLoginTarget(false);
this.redirect('home');
}
} else {
this.render(loadingScreenTemplate);
}
......@@ -729,12 +757,20 @@ Router.route('/admin/users', {
name: 'admin_users',
template: 'admin_users',
layoutTemplate: 'admin_main',
subscriptions: function () {
return [Meteor.subscribe('userData')];
},
data: function () {
Session.set('helpFilter', undefined);
},
action: function () {
if (this.ready()) {
this.render();
if (UserPermissions.isAdmin()) {
this.render();
} else {
MainNavigation.setLoginTarget(false);
this.redirect('home');
}
} else {
this.render(loadingScreenTemplate);
}
......@@ -745,13 +781,21 @@ Router.route('/admin/user/:_id', {
name: 'admin_user',
template: 'admin_user',
layoutTemplate: 'admin_main',
subscriptions: function () {
return [Meteor.subscribe('userData')];
},
data: function () {
Session.set('helpFilter', undefined);
return Meteor.users.findOne({_id: this.params._id});
},
action: function () {
if (this.ready()) {
this.render();
if (UserPermissions.isAdmin()) {
this.render();
} else {
MainNavigation.setLoginTarget(false);
this.redirect('home');
}
} else {
this.render(loadingScreenTemplate);
}
......@@ -763,14 +807,19 @@ Router.route('/admin/learningStatistics', {
template: 'admin_learningStatistics',
layoutTemplate: 'admin_main',
subscriptions: function () {
return [Meteor.subscribe('allCardsets'), Meteor.subscribe('allLeitner')];
return [Meteor.subscribe('allCardsets'), Meteor.subscribe('allLeitner'), Meteor.subscribe('userData')];
},
data: function () {
Session.set('helpFilter', undefined);
},
action: function () {
if (this.ready()) {
this.render();
if (UserPermissions.isAdmin()) {
this.render();
} else {
MainNavigation.setLoginTarget(false);
this.redirect('home');
}
} else {
this.render(loadingScreenTemplate);
}
......@@ -782,11 +831,16 @@ Router.route('/admin/apiAccess', {
template: 'admin_apiAccess',
layoutTemplate: 'admin_main',
subscriptions: function () {
return [Meteor.subscribe('allCardsets')];
return [Meteor.subscribe('allCardsets'), Meteor.subscribe('userData')];
},
action: function () {
if (this.ready()) {
this.render();
if (UserPermissions.isAdmin()) {
this.render();
} else {
MainNavigation.setLoginTarget(false);
this.redirect('home');
}
} else {
this.render(loadingScreenTemplate);
}
......@@ -797,12 +851,20 @@ Router.route('/admin/notifications', {
name: 'admin_notifications',
template: 'admin_notifications',
layoutTemplate: 'admin_main',
subscriptions: function () {
return [Meteor.subscribe('userData')];
},
data: function () {
Session.set('helpFilter', undefined);
},
action: function () {
if (this.ready()) {
this.render();
if (UserPermissions.isAdmin()) {
this.render();
} else {
MainNavigation.setLoginTarget(false);
this.redirect('home');
}
} else {
this.render(loadingScreenTemplate);
}
......@@ -813,12 +875,20 @@ Router.route('/admin/university', {
name: 'admin_university',
template: 'admin_university',
layoutTemplate: 'admin_main',
subscriptions: function () {
return [Meteor.subscribe('userData')];
},
data: function () {
Session.set('helpFilter', undefined);
},
action: function () {
if (this.ready()) {
this.render();
if (UserPermissions.isAdmin()) {
this.render();
} else {
MainNavigation.setLoginTarget(false);
this.redirect('home');
}
} else {
this.render(loadingScreenTemplate);
}
......@@ -829,20 +899,27 @@ Router.route('/admin/settings', {
name: 'admin_settings',
template: 'admin_settings',
layoutTemplate: 'admin_main',
subscriptions: function () {
return [Meteor.subscribe('userData')];
},
data: function () {
Session.set('helpFilter', undefined);
WebPushNotifications.subscribeForPushNotification();
},
action: function () {
if (this.ready()) {
this.render();
if (UserPermissions.isAdmin()) {
this.render();
} else {
MainNavigation.setLoginTarget(false);
this.redirect('home');
}
} else {
this.render(loadingScreenTemplate);
}
}
});
var isSignedIn = function () {
CardVisuals.checkFullscreen();
if (!(Meteor.user() || Meteor.loggingIn())) {
......@@ -852,6 +929,13 @@ var isSignedIn = function () {
TAPi18n.setLanguage(language);
}
Session.set('theme', "default");
if (MainNavigation.getLoginTarget() === undefined) {
if (linksWithNoLoginRequirement.includes(Router.current().route.getName())) {
MainNavigation.setLoginTarget(false);
} else {
MainNavigation.setLoginTarget(Router.current().url);
}
}
Router.go('home');
} else {
Route.setFirstTimeVisit();
......@@ -898,35 +982,40 @@ export function firstLoginBertAlert() {
var goToCreated = function () {
if (Meteor.user()) {
if (!Roles.userIsInRole(Meteor.userId(), ['firstLogin'])) {
if (!Roles.userIsInRole(Meteor.userId(), ['firstLogin', 'blocked'])) {
firstLoginBertAlert();
}
if (Roles.userIsInRole(Meteor.userId(), ['admin', 'editor'])) {
Router.go('alldecks');
} else {
Meteor.subscribe("userLeitner", {
onReady: function () {
Meteor.subscribe("userWozniak", {
onReady: function () {
let actualDate = new Date(new Date().getTime() + 24 * 60 * 60 * 1000);
actualDate.setHours(0, 0, 0, 0);
let count = Leitner.find({
user_id: Meteor.userId(),
active: true
}).count() + Wozniak.find({
user_id: Meteor.userId(), nextDate: {
$lte: actualDate
if (!Roles.userIsInRole(Meteor.userId(), ['firstLogin', 'blocked']) && MainNavigation.getLoginTarget() !== undefined && MainNavigation.getLoginTarget() !== false) {
Router.go(MainNavigation.getLoginTarget());
MainNavigation.setLoginTarget(false);
} else {
if (Roles.userIsInRole(Meteor.userId(), ['admin', 'editor'])) {
Router.go('alldecks');
} else {
Meteor.subscribe("userLeitner", {
onReady: function () {
Meteor.subscribe("userWozniak", {
onReady: function () {
let actualDate = new Date(new Date().getTime() + 24 * 60 * 60 * 1000);
actualDate.setHours(0, 0, 0, 0);
let count = Leitner.find({
user_id: Meteor.userId(),
active: true
}).count() + Wozniak.find({
user_id: Meteor.userId(), nextDate: {
$lte: actualDate
}
}).count();
if (count) {
Router.go('learn');
} else {
Router.go('pool');
}
}).count();
if (count) {
Router.go('learn');
} else {
Router.go('pool');
}
}
});
}
});
});
}
});
}
}
} else {
this.next();
......@@ -934,20 +1023,7 @@ var goToCreated = function () {
};
Router.onBeforeAction(isSignedIn, {
except: [
'home',
'about',
'learning',
'faq',
'help',
'impressum',
'demo',
'demolist',
'agb',
'datenschutz',
'making',
'makinglist'
]
except: linksWithNoLoginRequirement
});
Router.onBeforeAction(goToCreated, {
......
......@@ -3,6 +3,7 @@
import {Meteor} from "meteor/meteor";
import {Template} from "meteor/templating";
import {Notifications} from "../../api/notifications.js";
import {MainNavigation} from "../../api/mainNavigation";
import "./admin.html";
import "./dashboard/dashboard.js";
import "./users/index.js";
......@@ -25,6 +26,7 @@ Meteor.subscribe("notifications");
Template.admin_main.events({
'click #logout_admin': function (event) {
event.preventDefault();
MainNavigation.setLoginTarget(false);
Meteor.logout();
},
'click #notificationsBtn_admin': function () {
......
import "./backToCardset.html";
import {Route} from "../../../../api/route";
import {PomodoroTimer} from "../../../../api/pomodoroTimer";
import {Template} from "meteor/templating";
/*
* ############################################################################
......
......@@ -123,6 +123,7 @@ Template.main.events({
'click .logout': function (event) {
event.preventDefault();
Session.set('helpFilter', undefined);
MainNavigation.setLoginTarget(false);
Meteor.logout();
},
'keyup #input-search': function (event) {
......
......@@ -46,7 +46,7 @@
<template name="pomodoroTimerModal">
<!--this is the modal, hidden by default, that pops up when the user clicks the clock. Not too complicated.-->
<div id="pomodoroTimerModal" class="modal fade" role="dialog">
<div id="pomodoroTimerModal" class="modal fade" data-backdrop="{{#if requiresUserInputForFullscreen}}static{{/if}}" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
......
......@@ -2,7 +2,6 @@
import "./pomodoroTimer.html";
import {Template} from "meteor/templating";
import {PomodoroTimer} from "../../api/pomodoroTimer";
import {NavigatorCheck} from "../../api/navigatorCheck";
import {Bonus} from "../../api/bonus";
import {Route} from "../../api/route";
import {CardVisuals} from "../../api/cardVisuals";
......@@ -55,8 +54,11 @@ Template.pomodoroTimerModal.onCreated(function () {
Template.pomodoroTimerModal.onRendered(function () {
$('#pomodoroTimerModal').on('show.bs.modal', function () {
PomodoroTimer.initializeModalContent();
if (Route.requiresUserInputForFullscreen() && !CardVisuals.isFullscreen()) {
CardVisuals.toggleFullscreen();
}
});
if (Route.isBox() || Route.isMemo() || Route.isPresentation()) {
if (Route.requiresUserInputForFullscreen()) {
if (Bonus.isInBonus(Router.current().params._id)) {
PomodoroTimer.start();
} else {
......@@ -72,9 +74,9 @@ Template.pomodoroTimerModal.onRendered(function () {
});
});
Template.pomodoroTimerModalContent.helpers({
isiOS: function () {
return NavigatorCheck.isIOS();
Template.pomodoroTimerModal.helpers({
requiresUserInputForFullscreen: function () {
return Route.requiresUserInputForFullscreen();
}
});
......@@ -83,12 +85,15 @@ Template.pomodoroTimerModal.events({
PomodoroTimer.updateSettingsBtn();
},
'click #startPom': function () {
if (Route.isPresentation()) {
if (Route.requiresUserInputForFullscreen) {
CardVisuals.toggleFullscreen();
}
PomodoroTimer.start();
},
'click #cancelPomodoroBtn': function () {
if (Route.requiresUserInputForFullscreen) {
CardVisuals.toggleFullscreen();
}
$('#pomodoroTimerModal').modal('hide');
Session.set('presentationPomodoroActive', false);
}
......
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