summaryrefslogtreecommitdiffstats
path: root/client/components/settings/settingBody.js
diff options
context:
space:
mode:
Diffstat (limited to 'client/components/settings/settingBody.js')
-rw-r--r--client/components/settings/settingBody.js122
1 files changed, 98 insertions, 24 deletions
diff --git a/client/components/settings/settingBody.js b/client/components/settings/settingBody.js
index a2993426..7230d893 100644
--- a/client/components/settings/settingBody.js
+++ b/client/components/settings/settingBody.js
@@ -1,7 +1,3 @@
-Meteor.subscribe('setting');
-Meteor.subscribe('mailServer');
-Meteor.subscribe('accountSettings');
-
BlazeComponent.extendComponent({
onCreated() {
this.error = new ReactiveVar('');
@@ -9,6 +5,12 @@ BlazeComponent.extendComponent({
this.generalSetting = new ReactiveVar(true);
this.emailSetting = new ReactiveVar(false);
this.accountSetting = new ReactiveVar(false);
+ this.announcementSetting = new ReactiveVar(false);
+
+ Meteor.subscribe('setting');
+ Meteor.subscribe('mailServer');
+ Meteor.subscribe('accountSettings');
+ Meteor.subscribe('announcements');
},
setError(error) {
@@ -21,7 +23,7 @@ BlazeComponent.extendComponent({
checkField(selector) {
const value = $(selector).val();
- if(!value || value.trim() === ''){
+ if (!value || value.trim() === '') {
$(selector).parents('li.smtp-form').addClass('has-error');
throw Error('blank field');
} else {
@@ -29,7 +31,7 @@ BlazeComponent.extendComponent({
}
},
- currentSetting(){
+ currentSetting() {
return Settings.findOne();
},
@@ -42,35 +44,36 @@ BlazeComponent.extendComponent({
sort: ['title'],
});
},
- toggleRegistration(){
+ toggleRegistration() {
this.setLoading(true);
const registrationClosed = this.currentSetting().disableRegistration;
- Settings.update(Settings.findOne()._id, {$set:{disableRegistration: !registrationClosed}});
+ Settings.update(Settings.findOne()._id, {$set: {disableRegistration: !registrationClosed}});
this.setLoading(false);
- if(registrationClosed){
+ if (registrationClosed) {
$('.invite-people').slideUp();
- }else{
+ } else {
$('.invite-people').slideDown();
}
},
- toggleTLS(){
+ toggleTLS() {
$('#mail-server-tls').toggleClass('is-checked');
},
- switchMenu(event){
+ switchMenu(event) {
const target = $(event.target);
- if(!target.hasClass('active')){
+ if (!target.hasClass('active')) {
$('.side-menu li.active').removeClass('active');
target.parent().addClass('active');
const targetID = target.data('id');
this.generalSetting.set('registration-setting' === targetID);
this.emailSetting.set('email-setting' === targetID);
this.accountSetting.set('account-setting' === targetID);
+ this.announcementSetting.set('announcement-setting' === targetID);
}
},
- checkBoard(event){
+ checkBoard(event) {
let target = $(event.target);
- if(!target.hasClass('js-toggle-board-choose')){
+ if (!target.hasClass('js-toggle-board-choose')) {
target = target.parent();
}
const checkboxId = target.attr('id');
@@ -78,7 +81,7 @@ BlazeComponent.extendComponent({
$(`#${checkboxId}`).toggleClass('is-checked');
},
- inviteThroughEmail(){
+ inviteThroughEmail() {
const emails = $('#email-to-invite').val().trim().split('\n').join(',').split(',');
const boardsToInvite = [];
$('.js-toggle-board-choose .materialCheckBox.is-checked').each(function () {
@@ -101,19 +104,23 @@ BlazeComponent.extendComponent({
}
},
- saveMailServerInfo(){
+ saveMailServerInfo() {
this.setLoading(true);
$('li').removeClass('has-error');
- try{
+ try {
const host = this.checkField('#mail-server-host');
const port = this.checkField('#mail-server-port');
const username = $('#mail-server-username').val().trim();
const password = $('#mail-server-password').val().trim();
const from = this.checkField('#mail-server-from');
const tls = $('#mail-server-tls.is-checked').length > 0;
- Settings.update(Settings.findOne()._id, {$set:{'mailServer.host':host, 'mailServer.port': port, 'mailServer.username': username,
- 'mailServer.password': password, 'mailServer.enableTLS': tls, 'mailServer.from': from}});
+ Settings.update(Settings.findOne()._id, {
+ $set: {
+ 'mailServer.host': host, 'mailServer.port': port, 'mailServer.username': username,
+ 'mailServer.password': password, 'mailServer.enableTLS': tls, 'mailServer.from': from,
+ },
+ });
} catch (e) {
return;
} finally {
@@ -122,7 +129,23 @@ BlazeComponent.extendComponent({
},
- events(){
+ sendSMTPTestEmail() {
+ Meteor.call('sendSMTPTestEmail', (err, ret) => {
+ if (!err && ret) { /* eslint-disable no-console */
+ const message = `${TAPi18n.__(ret.message)}: ${ret.email}`;
+ console.log(message);
+ alert(message);
+ } else {
+ const reason = err.reason || '';
+ const message = `${TAPi18n.__(err.error)}\n${reason}`;
+ console.log(message, err);
+ alert(message);
+ }
+ /* eslint-enable no-console */
+ });
+ },
+
+ events() {
return [{
'click a.js-toggle-registration': this.toggleRegistration,
'click a.js-toggle-tls': this.toggleTLS,
@@ -130,25 +153,76 @@ BlazeComponent.extendComponent({
'click a.js-toggle-board-choose': this.checkBoard,
'click button.js-email-invite': this.inviteThroughEmail,
'click button.js-save': this.saveMailServerInfo,
+ 'click button.js-send-smtp-test-email': this.sendSMTPTestEmail,
}];
},
}).register('setting');
BlazeComponent.extendComponent({
- saveAllowEmailChange() {
+
+ saveAccountsChange() {
const allowEmailChange = ($('input[name=allowEmailChange]:checked').val() === 'true');
+ const allowUserNameChange = ($('input[name=allowUserNameChange]:checked').val() === 'true');
AccountSettings.update('accounts-allowEmailChange', {
- $set: { 'booleanValue': allowEmailChange },
+ $set: {'booleanValue': allowEmailChange},
+ });
+ AccountSettings.update('accounts-allowUserNameChange', {
+ $set: {'booleanValue': allowUserNameChange},
});
},
allowEmailChange() {
return AccountSettings.findOne('accounts-allowEmailChange').booleanValue;
},
+ allowUserNameChange() {
+ return AccountSettings.findOne('accounts-allowUserNameChange').booleanValue;
+ },
events() {
return [{
- 'click button.js-accounts-save': this.saveAllowEmailChange,
+ 'click button.js-accounts-save': this.saveAccountsChange,
}];
},
}).register('accountSettings');
+
+BlazeComponent.extendComponent({
+ onCreated() {
+ this.loading = new ReactiveVar(false);
+ },
+
+ setLoading(w) {
+ this.loading.set(w);
+ },
+
+ currentSetting() {
+ return Announcements.findOne();
+ },
+
+ saveMessage() {
+ const message = $('#admin-announcement').val().trim();
+ Announcements.update(Announcements.findOne()._id, {
+ $set: {'body': message},
+ });
+ },
+
+ toggleActive() {
+ this.setLoading(true);
+ const isActive = this.currentSetting().enabled;
+ Announcements.update(Announcements.findOne()._id, {
+ $set: {'enabled': !isActive},
+ });
+ this.setLoading(false);
+ if (isActive) {
+ $('.admin-announcement').slideUp();
+ } else {
+ $('.admin-announcement').slideDown();
+ }
+ },
+
+ events() {
+ return [{
+ 'click a.js-toggle-activemessage': this.toggleActive,
+ 'click button.js-announcement-save': this.saveMessage,
+ }];
+ },
+}).register('announcementSettings');