Commit 806f7149 authored by Yannick Lehnhausen's avatar Yannick Lehnhausen Committed by Dominik Maximilian Krion

Added functionality to change intervalls as admin in the admin-backend

parent 9cbe78af
......@@ -216,16 +216,24 @@
"nameAlreadyExists": "Benutzername ist bereits vergeben!"
},
"panel-heading-experience": {
"experience": "Erfahrungspunkte (XP)"
"experience": "Erfahrungspunkte (XP)",
"intervall": "Einstellungen der Intervalle für den Lernzeitraum (XP)",
"preview": "Vorschau"
},
"panel-body-experience": {
"intervall1" : "Intervall 1",
"intervall2" : "Intervall 2",
"intervall3" : "Intervall 3",
"total": "Total",
"twoDaysAgo": "Vorgestern",
"today": "Heute",
"days": "Tage",
"yesterday": "Gestern",
"days":"Tage",
"twoDaysAgo":"Vorgestern",
"month": "4 Wochen",
"threemonth": "3 Monate",
"month": "Wochen",
"threemonth": "Monate",
"lastredeem": "Zuletzt für: "
},
"panel-body-last": {
......@@ -442,6 +450,7 @@
"cardsets": "Kartensätze",
"cards": "Karten",
"users": "Benutzer",
"intervall": "Lernintervalle einstellen",
"notifications": "Benachrichtigungen",
"see_all": "Alle ansehen",
"name": "Name",
......
......@@ -217,14 +217,18 @@
"nameAlreadyExists": "Username is already taken!"
},
"panel-heading-experience": {
"experience": "Experience Points (XP)"
"experience": "Experience Points (XP)",
"intervall": "Set the learning period",
"preview": "Preview"
},
"panel-body-experience": {
"total": "Total",
"today": "Today",
"yesterday": "Yesterday",
"twoDaysAgo": "before yesterday",
"days": "days",
"twoDaysAgo": "Day before yesterday",
"days": "7 days",
"lastredeem": "At last for: "
},
"panel-body-last": {
......@@ -441,6 +445,7 @@
"cardsets": "Cardsets",
"cards": "Cards",
"users": "Users",
"intervall": "Define learning period",
"notifications": "Notifications",
"see_all": "See all",
"name": "Name",
......
import { Meteor } from 'meteor/meteor';
import { Mongo } from 'meteor/mongo';
export const AdminSettings = new Mongo.Collection("adminSettings");
if (Meteor.isServer) {
Meteor.publish("adminSettings", function() {
return AdminSettings.find();
});
}
Meteor.methods({
updateIntervall: function (inv1, inv2, inv3) {
if (!Roles.userIsInRole(this.userId, ["admin", "editor"])) {
throw new Meteor.Error("not-authorized");
}
AdminSettings.update(
{
name: "seqSettings"
},
{
$set: {
seqOne: inv1,
seqTwo: inv2,
seqThree: inv3
}
});
}
});
\ No newline at end of file
......@@ -193,12 +193,19 @@ Router.route('/admin/notifications', {
layoutTemplate: 'admin_main'
});
var isSignedIn = function () {
if (!(Meteor.user() || Meteor.loggingIn())) {
Router.go('home');
} else {
this.next();
}
Router.route('/admin/intervalls', {
name: 'admin_intervall',
template: 'admin_settings',
layoutTemplate: 'admin_main'
});
var isSignedIn = function() {
if (!(Meteor.user() || Meteor.loggingIn())) {
Router.go('home');
} else {
this.next();
}
};
var goToCreated = function () {
......
......@@ -82,45 +82,46 @@
<!-- Sidebar -->
<div id="admin-sidebar-wrapper">
<ul class="sidebar-nav">
<li>
<a class="{{#if isActiveRoute regex='admin_dashboard'}}active{{/if}}"
href="{{pathFor route='admin_dashboard'}}">
<i class="fa fa-dashboard"></i>
<span>{{_ "admin.dashboard"}}</span>
</a>
</li>
<li>
<a class="{{#if isActiveRoute regex='admin_cardsets|admin_cardset'}}active{{/if}}"
href="{{pathFor route='admin_cardsets'}}">
<i class="fa fa-folder-open"></i>
<span>{{_ "admin.cardsets"}}</span>
</a>
</li>
<li>
<a class="{{#if isActiveRoute regex='adminCards|adminCard'}}active{{/if}}"
href="{{pathFor route='adminCards'}}">
<i class="fa fa-file"></i>
<span>{{_ "admin.cards"}}</span>
</a>
</li>
<li>
<a class="{{#if isActiveRoute regex='admin_users|admin_user'}}active{{/if}}"
href="{{pathFor route='admin_users'}}">
<i class="fa fa-users"></i>
<span>{{_ "admin.users"}}</span>
</a>
</li>
<li>
<a class="{{#if isActiveRoute regex='admin_notifications'}}active{{/if}}"
href="{{pathFor route='admin_notifications'}}">
<i class="fa fa-bell"></i>
<span>{{_ "admin.notifications"}}</span>
</a>
</li>
</ul>
</div>
<!-- /#sidebar-wrapper -->
<ul class="sidebar-nav">
<li>
<a class="{{#if isActiveRoute regex='admin_dashboard'}}active{{/if}}" href="{{pathFor route='admin_dashboard'}}">
<i class="fa fa-dashboard"></i>
<span>{{_ "admin.dashboard"}}</span>
</a>
</li>
<li>
<a class="{{#if isActiveRoute regex='admin_cardsets|admin_cardset'}}active{{/if}}" href="{{pathFor route='admin_cardsets'}}">
<i class="fa fa-folder-open"></i>
<span>{{_ "admin.cardsets"}}</span>
</a>
</li>
<li>
<a class="{{#if isActiveRoute regex='adminCards|adminCard'}}active{{/if}}" href="{{pathFor route='adminCards'}}">
<i class="fa fa-file"></i>
<span>{{_ "admin.cards"}}</span>
</a>
</li>
<li>
<a class="{{#if isActiveRoute regex='admin_users|admin_user'}}active{{/if}}" href="{{pathFor route='admin_users'}}">
<i class="fa fa-users"></i>
<span>{{_ "admin.users"}}</span>
</a>
</li>
<li>
<a class="{{#if isActiveRoute regex='admin_notifications'}}active{{/if}}" href="{{pathFor route='admin_notifications'}}">
<i class="fa fa-bell"></i>
<span>{{_ "admin.notifications"}}</span>
</a>
</li>
<li>
<a class="{{#if isActiveRoute regex='admin_intervall'}}active{{/if}}" href="{{pathFor route='admin_intervall'}}">
<i class="fa fa-cog"></i>
<span>{{_ "admin.intervall"}}</span>
</a>
</li>
</ul>
</div>
<!-- /#sidebar-wrapper -->
<div id='admin-content-wrapper'>
{{> yield}}
......
......@@ -258,3 +258,104 @@
</div>
<!-- /.modal -->
</template>
<template name="admin_settings">
<div class="col-md-12" id="profile-xp">
<div class="panel panel-default">
<div class="panel-heading panel-heading-experience">
<h3 class="panel-title">{{_ "panel-heading-experience.intervall"}}</h3>
</div>
<div class="panel-body panel-body-experience">
<div class="row" style="margin-bottom:10px; margin-left: 5px">
<form class="form-inline">
<div class="form-group" style="margin-right: 20px; margin-bottom: 5px">
<label for="intervall1">Intervall 1 </label>
<input type="number" class="form-control" id="inv1" placeholder="Standard 1 Tag">
<label for="intervall1">Tag(e) </label>
</div>
<div class="form-group" style="margin-right: 20px; margin-bottom: 5px">
<label for="intervall2">Intervall 2 </label>
<input type="number" class="form-control" id="inv2" placeholder="Standard 30 Tage">
<label for="intervall2">Tage </label>
</div>
<div class="form-group" style="margin-right: 20px; margin-bottom: 5px">
<label for="intervall3">Intervall 3 </label>
<input type="number" class="form-control" id="inv3" placeholder="Standard 90 Tage">
<label for="intervall3">Tage </label>
</div>
<button type="button" class="btn btn-success" id="saveIntervall">Speichern</button>
</form>
</div>
</div>
</div>
</div>
{{> preview}}
</template>
<template name="preview">
<div class="col-md-12" id="profile-xp">
<div class="panel panel-default">
<div class="panel-heading panel-heading-experience">
<h3 class="panel-title">{{_ "panel-heading-experience.preview"}}</h3>
</div>
<div class="panel-body panel-body-experience">
<div class="row" style="margin-bottom:15px">
<!-- Secquencer 1 -->
<div class="col-md-4">
<div class="well well-sm" style="margin:0; text-align:center">
<div class="row" style="height:50px;">
<span style="display:inline-block; font-size:20px; margin-top:22px; height:20px">
</span>
</div>
<div class="row">
<span class="text-muted" style="font-size:12px">
{{_ "panel-body-experience.days"}}
</span>
</div>
</div>
</div>
<!-- Secquencer 2 -->
<div class="col-md-4">
<div class="well well-sm" style="margin:0; text-align:center">
<div class="row" style="height:50px;">
<span style="display:inline-block; font-size:20px; margin-top:22px; height:20px">
</span>
</div>
<div class="row">
<span class="text-muted" style="font-size:12px">
{{_ "panel-body-experience.days"}}
</span>
</div>
</div>
</div>
<!-- Secquencer 3 -->
<div class="col-md-4">
<div class="well well-sm" style="margin:0; text-align:center">
<div class="row" style="height:50px;">
<span style="display:inline-block; font-size:20px; margin-top:22px; height:20px">
</span>
</div>
<div class="row">
<span class="text-muted" style="font-size:12px">
{{_ "panel-body-experience.days"}}
</span>
</div>
</div>
</div>
</div> <!-- div row experience -->
</div>
</div>
</div>
</template>
......@@ -4,10 +4,12 @@ import {Meteor} from 'meteor/meteor';
import {Template} from 'meteor/templating';
import {Session} from 'meteor/session';
import {Cardsets} from '../../../api/cardsets.js';
import { allUsers } from '../../../api/allusers.js';
import { Cardsets } from '../../../api/cardsets.js';
import { AdminSettings} from '../../../api/adminSettings.js';
import './admin_user.html';
Meteor.subscribe("adminSettings");
/**
* ############################################################################
* admin_user
......@@ -160,6 +162,30 @@ Template.admin_user.helpers({
}
});
Template.admin_settings.events({
'click #saveIntervall': function() {
var inv1 = document.getElementById('inv1').value;
var inv2 = document.getElementById('inv2').value;
var inv3 = document.getElementById('inv3').value;
if(inv1 == 0){
inv1 = 1;
}
if(inv2 == 0){
inv2 = 30;
}
if(inv3 == 0){
inv3 = 90;
}
Meteor.call('updateIntervall', inv1,inv2,inv3);
console.log(inv1);
console.log(inv2);
console.log(inv3);
}
});
Template.admin_user.events({
'click #userSaveAdmin': function (event, tmpl) {
var name = $('#editUserNameAdmin').val();
......@@ -248,28 +274,30 @@ Template.admin_user.events({
}
}
Meteor.call('updateUser', user_id, visible, email, blockedtext);
Meteor.call("updateUsersName", result, user_id);
window.history.go(-1);
}
}
});
},
'click #userCancelAdmin': function () {
window.history.go(-1);
},
'click #userDeleteAdmin': function () {
$("#userDeleteAdmin").css('display', "none");
$("#userConfirmAdmin").css('display', "");
},
'click #userConfirmAdmin': function () {
var id = this._id;
Meteor.call("deleteUser", id);
window.history.go(-1);
},
'click .reactive-table tbody tr': function (event) {
event.preventDefault();
var cardset = this;
Meteor.call('updateUser', user_id, visible, email, blockedtext);
Meteor.call("updateUsersName", result, user_id);
window.history.go(-1);
}
}
});
},
'click #userCancelAdmin': function() {
window.history.go(-1);
},
'click #userDeleteAdmin': function() {
$("#userDeleteAdmin").css('display', "none");
$("#userConfirmAdmin").css('display', "");
},
'click #userConfirmAdmin': function() {
var id = this._id;
Meteor.call("deleteUser", id);
window.history.go(-1);
},
'click .reactive-table tbody tr': function(event) {
event.preventDefault();
var cardset = this;
if (event.target.className == "deleteCardsetAdmin btn btn-xs btn-default" || event.target.className == "glyphicon glyphicon-ban-circle") {
Session.set('cardsetId', cardset._id);
......
......@@ -100,3 +100,4 @@
</div>
</div>
</template>
......@@ -551,12 +551,23 @@ Template.profileRequests.helpers({
* profileXp
* ############################################################################
*/
var seq = AdminSettings.findOne({name: "seqSettings"});
var seqOne = seq.seqOne; //7 tag
var seqTwo = seq.seqTwo; //30 tag
var seqThree = seq.seqTwo; //90 tag
var seqOne = 7; //7 tag
var seqTwo = 29; //30 tag
var seqThree = 90; //90 tag
Template.profileXp.helpers({
startXp: function() {
var seq = AdminSettings.findOne({name: "seqSettings"});
if(seq){
seqOne = seq.seqOne; //7 tag
seqTwo = seq.seqTwo; //30 tag
seqThree = seq.seqThree; //90 tag
} else {
//console.log("error could not find adminSettings");
}
},
getDays1: function(){
return seqOne;
},
......
......@@ -21,7 +21,7 @@
"BT_PRIVATE_KEY": "b508f71a0e0b01940b0fbe75940debb9"
},
"admin": {
"name": "hg13345"
"name": "ylhn15"
},
"facebook": {
"api": "162760697401847",
......
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