Commit 0363b74d authored by Nico Müller's avatar Nico Müller

added "Appearence"-Settings.

selected color theme is now saved in the mongodb
parent 624c39a2
......@@ -216,7 +216,9 @@
"settings": {
"name": "Profil",
"delete": "Benutzerprofil löschen",
"deleteText": "Falls Sie glauben, dass Sie THMcards nicht noch einmal verwenden möchten, können Sie hier Ihr Benutzerprofil löschen."
"deleteText": "Falls Sie glauben, dass Sie THMcards nicht noch einmal verwenden möchten, können Sie hier Ihr Benutzerprofil löschen.",
"appearance": "Erscheinungsbild",
"theme": "Farbauswahl"
}
},
"profil-header": {
......
......@@ -220,7 +220,9 @@
"settings": {
"name": "Profile",
"delete": "Delete user profile",
"deleteText": "If you do not think you will use THMcards again, you can delete here your user profile."
"deleteText": "If you do not think you will use THMcards again, you can delete here your user profile.",
"appearance": "Appearance",
"theme": "Color theme"
}
},
"profil-header": {
......
import {Meteor} from "meteor/meteor";
import {Mongo} from "meteor/mongo";
import {SimpleSchema} from "meteor/aldeed:simple-schema";
export const ColorThemes = new Mongo.Collection("colorThemes");
if (Meteor.isServer) {
Meteor.publish("colorThemes", function () {
return ColorThemes.find();
});
}
......@@ -22,7 +22,8 @@ if (Meteor.isServer) {
'daysInRow': 1,
'earnedBadges': 1,
'customerId': 1,
'blockedtext': 1
'blockedtext': 1,
"selectedColorTheme": 1
}
});
} else if (Roles.userIsInRole(this.userId, 'blocked')) {
......@@ -171,7 +172,8 @@ Meteor.methods({
lvl: 1,
lastOnAt: new Date(),
daysInRow: 0,
earnedBadges: []
earnedBadges: [],
selectedColorTheme: "1",
}
});
},
......@@ -294,9 +296,19 @@ Meteor.methods({
Roles.removeUsersFromRoles(Meteor.user()._id, 'firstLogin');
},
updateEarnedBadges: function (index, rank) {
check(index, Number);
check(rank, Number);
Meteor.users.update(Meteor.user()._id,
{$addToSet: {"earnedBadges": {"index": index.toString(), "rank": rank.toString()}}});
}
check(index, Number);
check(rank, Number);
Meteor.users.update(Meteor.user()._id,
{$addToSet: {"earnedBadges": {"index": index.toString(), "rank": rank.toString()}}});
},
updateColorTheme: function (selectedColorTheme, id) {
check(selectedColorTheme, String);
check(id, String);
Meteor.users.update(id, {
$set: {
"selectedColorTheme": selectedColorTheme
}
});
}
});
import {Meteor} from "meteor/meteor";
import {Badges} from "../../api/badges.js";
import {ColorThemes} from "../../api/theme.js";
import {AdminSettings} from "../../api/adminSettings";
import {CronScheduler} from "../../../server/cronjob.js";
var initColorThemes = function() {
return [{
"_id": "1",
"name": "template1"
},{
"_id": "2",
"name": "template2"
}];
}
var initBadges = function () {
return [{
"_id": "1",
......@@ -106,6 +117,8 @@ var initBadges = function () {
Meteor.startup(function () {
const cronScheduler = new CronScheduler();
var badges = initBadges();
var themes = initColorThemes();
process.env.MAIL_URL = Meteor.settings.MAIL_URL;
SSR.compileTemplate("newsletter", Assets.getText("newsletter/newsletter.html"));
Template.newsletter.helpers({
......@@ -130,5 +143,12 @@ Meteor.startup(function () {
}
}
}
if (ColorThemes.find().count() === 0) {
for (var theme in themes) {
ColorThemes.insert(themes[theme]);
}
}
cronScheduler.startCron();
});
......@@ -250,6 +250,25 @@
</form>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">{{_ "profile.settings.appearance"}}</h4>
</div>
<div class="panel-body">
<div class="form-group">
<label for="sel1">{{_ "profile.settings.theme"}}:</label>
<select class="form-control" id="colorThemeSelect">
{{#each getColorThemes}}
<option {{getSelectedColorThemes}} value="{{_id}}">{{name}}</option>
{{/each}}
</select>
</div>
<div class="btn-group pull-right" role="group">
<button disabled id="colorThemeSave" type="button" class="btn btn-success">{{_
"profile.save"}}</button>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">{{_ "profile.settings.delete"}}</h4>
......
......@@ -10,6 +10,7 @@ import {Cardsets} from "../../api/cardsets.js";
import {Cards} from "../../api/cards.js";
import {Learned} from "../../api/learned.js";
import {Ratings} from "../../api/ratings.js";
import {ColorThemes} from "../../api/theme.js";
import {Paid} from "../../api/paid.js";
import {Notifications} from "../../api/notifications.js";
import {AdminSettings} from "../../api/adminSettings";
......@@ -21,6 +22,7 @@ Meteor.subscribe("badges");
Meteor.subscribe("notifications");
Meteor.subscribe("userData");
Meteor.subscribe("cardsets");
Meteor.subscribe("colorThemes");
Meteor.subscribe('default_db_data', function () {
Session.set('data_loaded', true);
});
......@@ -299,6 +301,17 @@ Template.profileSidebar.helpers({
* ############################################################################
*/
Template.profileSettings.helpers({
getColorThemes() {
return ColorThemes.find();
},
getSelectedColorThemes: function()
{
if(this._id === Meteor.users.findOne(Meteor.userId()).selectedColorTheme)
return "selected";
}
});
Template.profileSettings.events({
"click #profilepublicoption1": function () {
Meteor.call("updateUsersVisibility", true);
......@@ -388,6 +401,23 @@ Template.profileSettings.events({
$('#profileCancel')[0].disabled = true;
}
},
"click #colorThemeSave": function () {
var selected = $('#colorThemeSelect').val();
var user_id = Meteor.userId();
//$('#colorThemeCancel')[0].disabled = true;
$('#colorThemeSave')[0].disabled = true;
Meteor.call("updateColorTheme", selected, user_id);
Bert.alert(TAPi18n.__('profile.saved'), 'success', 'growl-bottom-right');
},
"change #colorThemeSelect": function() {
var selected = $('#colorThemeSelect').val();
//$('#colorThemeCancel')[0].disabled = false;
$('#colorThemeSave')[0].disabled = false;
Session.set("theme", selected);
},
"click #profileSave": function () {
// Email validation
var re = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
......
......@@ -5,8 +5,8 @@
"start": "meteor run"
},
"dependencies": {
"babel-runtime": "^6.18.0",
"chart.js": "^2.3.0",
"babel-runtime": "^6.20.0",
"chart.js": "^2.4.0",
"meteor-node-stubs": "~0.2.0",
"react": "^15.0.2"
},
......
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