diff options
author | Thiago Fernando <thiagofernando@outlook.com> | 2019-05-10 14:54:25 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-10 14:54:25 -0300 |
commit | ce0473480bab3fc621d4baecfff0f413e21b5e2c (patch) | |
tree | 06d724b4f80885bdd13137f7977d7a914cca0138 /client/components/settings | |
parent | c43508cacbd64357409a3de114db9dab2ae59a9d (diff) | |
parent | 7ff4067e88ed59686c86d81447fa2ce550032034 (diff) | |
download | wekan-ce0473480bab3fc621d4baecfff0f413e21b5e2c.tar.gz wekan-ce0473480bab3fc621d4baecfff0f413e21b5e2c.tar.bz2 wekan-ce0473480bab3fc621d4baecfff0f413e21b5e2c.zip |
Merge pull request #1 from wekan/devel
ldap changes
Diffstat (limited to 'client/components/settings')
-rw-r--r-- | client/components/settings/connectionMethod.jade | 9 | ||||
-rw-r--r-- | client/components/settings/connectionMethod.js | 37 | ||||
-rw-r--r-- | client/components/settings/informationBody.jade | 2 | ||||
-rw-r--r-- | client/components/settings/invitationCode.js | 17 | ||||
-rw-r--r-- | client/components/settings/peopleBody.jade | 34 | ||||
-rw-r--r-- | client/components/settings/peopleBody.js | 76 | ||||
-rw-r--r-- | client/components/settings/peopleBody.styl | 33 | ||||
-rw-r--r-- | client/components/settings/settingBody.jade | 47 | ||||
-rw-r--r-- | client/components/settings/settingBody.js | 76 | ||||
-rw-r--r-- | client/components/settings/settingBody.styl | 7 | ||||
-rw-r--r-- | client/components/settings/settingHeader.jade | 31 |
11 files changed, 334 insertions, 35 deletions
diff --git a/client/components/settings/connectionMethod.jade b/client/components/settings/connectionMethod.jade new file mode 100644 index 00000000..d191929f --- /dev/null +++ b/client/components/settings/connectionMethod.jade @@ -0,0 +1,9 @@ +template(name='connectionMethod') + div.at-form-authentication + label {{_ 'authentication-method'}} + select.select-authentication + each authentications + if isSelected value + option(value="{{value}}" selected) {{_ value}} + else + option(value="{{value}}") {{_ value}}
\ No newline at end of file diff --git a/client/components/settings/connectionMethod.js b/client/components/settings/connectionMethod.js new file mode 100644 index 00000000..db9da25f --- /dev/null +++ b/client/components/settings/connectionMethod.js @@ -0,0 +1,37 @@ +Template.connectionMethod.onCreated(function() { + this.authenticationMethods = new ReactiveVar([]); + + Meteor.call('getAuthenticationsEnabled', (_, result) => { + if (result) { + // TODO : add a management of different languages + // (ex {value: ldap, text: TAPi18n.__('ldap', {}, T9n.getLanguage() || 'en')}) + this.authenticationMethods.set([ + {value: 'password'}, + // Gets only the authentication methods availables + ...Object.entries(result).filter((e) => e[1]).map((e) => ({value: e[0]})), + ]); + } + + // If only the default authentication available, hides the select boxe + const content = $('.at-form-authentication'); + if (!(this.authenticationMethods.get().length > 1)) { + content.hide(); + } else { + content.show(); + } + }); +}); + +Template.connectionMethod.onRendered(() => { + // Moves the select boxe in the first place of the at-pwd-form div + $('.at-form-authentication').detach().prependTo('.at-pwd-form'); +}); + +Template.connectionMethod.helpers({ + authentications() { + return Template.instance().authenticationMethods.get(); + }, + isSelected(match) { + return Template.instance().data.authenticationMethod === match; + }, +}); diff --git a/client/components/settings/informationBody.jade b/client/components/settings/informationBody.jade index 53907513..feb7c0dc 100644 --- a/client/components/settings/informationBody.jade +++ b/client/components/settings/informationBody.jade @@ -17,7 +17,7 @@ template(name='statistics') table tbody tr - th {{_ 'Wekan_version'}} + th Wekan {{_ 'info'}} td {{statistics.version}} tr th {{_ 'Node_version'}} diff --git a/client/components/settings/invitationCode.js b/client/components/settings/invitationCode.js index c02f860f..fa355179 100644 --- a/client/components/settings/invitationCode.js +++ b/client/components/settings/invitationCode.js @@ -1,6 +1,13 @@ -Template.invitationCode.onRendered(() => { - const setting = Settings.findOne(); - if (setting || setting.disableRegistration) { - $('#invitationcode').hide(); - } +Template.invitationCode.onRendered(function() { + Meteor.subscribe('setting', { + onReady() { + const setting = Settings.findOne(); + + if (!setting || !setting.disableRegistration) { + $('#invitationcode').hide(); + } + + return this.stop(); + }, + }); }); diff --git a/client/components/settings/peopleBody.jade b/client/components/settings/peopleBody.jade index a3506a24..15deb005 100644 --- a/client/components/settings/peopleBody.jade +++ b/client/components/settings/peopleBody.jade @@ -3,8 +3,13 @@ template(name="people") unless currentUser.isAdmin | {{_ 'error-notAuthorized'}} else - .content-title - span {{_ 'people'}} + .content-title.ext-box + .ext-box-left + span {{_ 'people'}} + input#searchInput(placeholder="{{_ 'search'}}") + button#searchButton {{_ 'search'}} + .ext-box-right + span {{_ 'people-number'}} #{peopleNumber} .content-body .side-menu ul @@ -27,6 +32,7 @@ template(name="peopleGeneral") th {{_ 'verified'}} th {{_ 'createdAt'}} th {{_ 'active'}} + th {{_ 'authentication-method'}} th each user in peopleList +peopleRow(userId=user._id) @@ -52,6 +58,7 @@ template(name="peopleRow") | {{_ 'no'}} else | {{_ 'yes'}} + td {{_ userData.authenticationMethod }} td a.edit-user | {{_ 'edit'}} @@ -66,12 +73,18 @@ template(name="editUserPopup") | {{_ 'username'}} span.error.hide.username-taken | {{_ 'error-username-taken'}} - input.js-profile-username(type="text" value=user.username) + if isLdap + input.js-profile-username(type="text" value=user.username readonly) + else + input.js-profile-username(type="text" value=user.username) label | {{_ 'email'}} span.error.hide.email-taken | {{_ 'error-email-taken'}} - input.js-profile-email(type="email" value="{{user.emails.[0].address}}") + if isLdap + input.js-profile-email(type="email" value="{{user.emails.[0].address}}" readonly) + else + input.js-profile-email(type="email" value="{{user.emails.[0].address}}") label | {{_ 'admin'}} select.select-role.js-profile-isadmin @@ -82,9 +95,20 @@ template(name="editUserPopup") select.select-active.js-profile-isactive option(value="false") {{_ 'yes'}} option(value="true" selected="{{user.loginDisabled}}") {{_ 'no'}} + label + | {{_ 'authentication-type'}} + select.select-authenticationMethod.js-authenticationMethod + each authentications + if isSelected value + option(value="{{value}}" selected) {{_ value}} + else + option(value="{{value}}") {{_ value}} hr label | {{_ 'password'}} input.js-profile-password(type="password") + div.buttonsContainer + input.primary.wide(type="submit" value="{{_ 'save'}}") + div + input#deleteButton.primary.wide(type="button" value="{{_ 'delete'}}") - input.primary.wide(type="submit" value="{{_ 'save'}}") diff --git a/client/components/settings/peopleBody.js b/client/components/settings/peopleBody.js index 7cc992f2..83cf14fa 100644 --- a/client/components/settings/peopleBody.js +++ b/client/components/settings/peopleBody.js @@ -8,6 +8,8 @@ BlazeComponent.extendComponent({ this.error = new ReactiveVar(''); this.loading = new ReactiveVar(false); this.people = new ReactiveVar(true); + this.findUsersOptions = new ReactiveVar({}); + this.number = new ReactiveVar(0); this.page = new ReactiveVar(1); this.loadNextPageLocked = false; @@ -26,6 +28,33 @@ BlazeComponent.extendComponent({ }); }); }, + events() { + return [{ + 'click #searchButton'() { + this.filterPeople(); + }, + 'keydown #searchInput'(event) { + if (event.keyCode === 13 && !event.shiftKey) { + this.filterPeople(); + } + }, + }]; + }, + filterPeople() { + const value = $('#searchInput').first().val(); + if (value === '') { + this.findUsersOptions.set({}); + } else { + const regex = new RegExp(value, 'i'); + this.findUsersOptions.set({ + $or: [ + { username: regex }, + { 'profile.fullname': regex }, + { 'emails.address': regex }, + ], + }); + } + }, loadNextPage() { if (this.loadNextPageLocked === false) { this.page.set(this.page.get() + 1); @@ -49,9 +78,14 @@ BlazeComponent.extendComponent({ this.loading.set(w); }, peopleList() { - return Users.find({}, { + const users = Users.find(this.findUsersOptions.get(), { fields: {_id: true}, }); + this.number.set(users.count()); + return users; + }, + peopleNumber() { + return this.number.get(); }, }).register('people'); @@ -62,10 +96,43 @@ Template.peopleRow.helpers({ }, }); +Template.editUserPopup.onCreated(function() { + this.authenticationMethods = new ReactiveVar([]); + this.errorMessage = new ReactiveVar(''); + + Meteor.call('getAuthenticationsEnabled', (_, result) => { + if (result) { + // TODO : add a management of different languages + // (ex {value: ldap, text: TAPi18n.__('ldap', {}, T9n.getLanguage() || 'en')}) + this.authenticationMethods.set([ + {value: 'password'}, + // Gets only the authentication methods availables + ...Object.entries(result).filter((e) => e[1]).map((e) => ({value: e[0]})), + ]); + } + }); +}); + Template.editUserPopup.helpers({ user() { return Users.findOne(this.userId); }, + authentications() { + return Template.instance().authenticationMethods.get(); + }, + isSelected(match) { + const userId = Template.instance().data.userId; + const selected = Users.findOne(userId).authenticationMethod; + return selected === match; + }, + isLdap() { + const userId = Template.instance().data.userId; + const selected = Users.findOne(userId).authenticationMethod; + return selected === 'ldap'; + }, + errorMessage() { + return Template.instance().errorMessage.get(); + }, }); BlazeComponent.extendComponent({ @@ -91,6 +158,7 @@ Template.editUserPopup.events({ const isAdmin = tpl.find('.js-profile-isadmin').value.trim(); const isActive = tpl.find('.js-profile-isactive').value.trim(); const email = tpl.find('.js-profile-email').value.trim(); + const authentication = tpl.find('.js-authenticationMethod').value.trim(); const isChangePassword = password.length > 0; const isChangeUserName = username !== user.username; @@ -101,6 +169,7 @@ Template.editUserPopup.events({ 'profile.fullname': fullname, 'isAdmin': isAdmin === 'true', 'loginDisabled': isActive === 'true', + 'authenticationMethod': authentication, }, }); @@ -155,4 +224,9 @@ Template.editUserPopup.events({ }); } else Popup.close(); }, + + 'click #deleteButton'() { + Users.remove(this.userId); + Popup.close(); + }, }); diff --git a/client/components/settings/peopleBody.styl b/client/components/settings/peopleBody.styl index 84db44a7..80387611 100644 --- a/client/components/settings/peopleBody.styl +++ b/client/components/settings/peopleBody.styl @@ -13,3 +13,36 @@ table tr:nth-child(even) background-color: #dddddd; + +.ext-box + display: flex; + flex-direction: row; + height: 34px; + + .ext-box-left + display: flex; + width: 40% + + span + vertical-align: center; + line-height: 34px; + margin-right: 10px; + + input, button + margin: 0 10px 0 0; + padding: 0; + + button + min-width: 60px; + +.content-wrapper + margin-top: 10px + +.buttonsContainer + display: flex + + input + margin: 0 + + div + margin: auto diff --git a/client/components/settings/settingBody.jade b/client/components/settings/settingBody.jade index 5bc7972d..89911e09 100644 --- a/client/components/settings/settingBody.jade +++ b/client/components/settings/settingBody.jade @@ -16,6 +16,8 @@ template(name="setting") a.js-setting-menu(data-id="account-setting") {{_ 'accounts'}} li a.js-setting-menu(data-id="announcement-setting") {{_ 'admin-announcement'}} + li + a.js-setting-menu(data-id="layout-setting") {{_ 'layout'}} .main-body if loading.get +spinner @@ -27,6 +29,8 @@ template(name="setting") +accountSettings else if announcementSetting.get +announcementSettings + else if layoutSetting.get + +layoutSettings template(name="general") ul#registration-setting.setting-detail @@ -72,7 +76,7 @@ template(name='email') li.smtp-form .title {{_ 'smtp-password'}} .form-group - input.form-control#mail-server-password(type="text", placeholder="{{_ 'password'}}" value="{{currentSetting.mailServer.password}}") + input.form-control#mail-server-password(type="password", placeholder="{{_ 'password'}}" value="{{currentSetting.mailServer.password}}") li.smtp-form .title {{_ 'smtp-tls'}} .form-group @@ -127,3 +131,44 @@ template(name='announcementSettings') textarea#admin-announcement.form-control= currentSetting.body li button.js-announcement-save.primary {{_ 'save'}} + +template(name='layoutSettings') + ul#layout-setting.setting-detail + //li.layout-form + .title {{_ 'hide-logo'}} + .form-group.flex + input.form-control#hide-logo(type="radio" name="hideLogo" value="true" checked="{{#if currentSetting.hideLogo}}checked{{/if}}") + span {{_ 'yes'}} + input.form-control#hide-logo(type="radio" name="hideLogo" value="false" checked="{{#unless currentSetting.hideLogo}}checked{{/unless}}") + span {{_ 'no'}} + li.layout-form + .title {{_ 'display-authentication-method'}} + .form-group.flex + input.form-control#display-authentication-method(type="radio" name="displayAuthenticationMethod" value="true" checked="{{#if currentSetting.displayAuthenticationMethod}}checked{{/if}}") + span {{_ 'yes'}} + input.form-control#display-authentication-method(type="radio" name="displayAuthenticationMethod" value="false" checked="{{#unless currentSetting.displayAuthenticationMethod}}checked{{/unless}}") + span {{_ 'no'}} + li.layout-form + .title {{_ 'default-authentication-method'}} + +selectAuthenticationMethod(authenticationMethod=currentSetting.defaultAuthenticationMethod) + li.layout-form + .title {{_ 'custom-product-name'}} + .form-group + input.form-control#product-name(type="text", placeholder="" value="{{currentSetting.productName}}") + li.layout-form + .title {{_ 'add-custom-html-after-body-start'}} + textarea#customHTMLafterBodyStart.form-control= currentSetting.customHTMLafterBodyStart + li.layout-form + .title {{_ 'add-custom-html-before-body-end'}} + textarea#customHTMLbeforeBodyEnd.form-control= currentSetting.customHTMLbeforeBodyEnd + li + button.js-save-layout.primary {{_ 'save'}} + + +template(name='selectAuthenticationMethod') + select#defaultAuthenticationMethod + each authentications + if isSelected value + option(value="{{value}}" selected) {{_ value}} + else + option(value="{{value}}") {{_ value}} diff --git a/client/components/settings/settingBody.js b/client/components/settings/settingBody.js index 7230d893..8279a092 100644 --- a/client/components/settings/settingBody.js +++ b/client/components/settings/settingBody.js @@ -6,6 +6,7 @@ BlazeComponent.extendComponent({ this.emailSetting = new ReactiveVar(false); this.accountSetting = new ReactiveVar(false); this.announcementSetting = new ReactiveVar(false); + this.layoutSetting = new ReactiveVar(false); Meteor.subscribe('setting'); Meteor.subscribe('mailServer'); @@ -58,6 +59,12 @@ BlazeComponent.extendComponent({ toggleTLS() { $('#mail-server-tls').toggleClass('is-checked'); }, + toggleHideLogo() { + $('#hide-logo').toggleClass('is-checked'); + }, + toggleDisplayAuthenticationMethod() { + $('#display-authentication-method').toggleClass('is-checked'); + }, switchMenu(event) { const target = $(event.target); if (!target.hasClass('active')) { @@ -68,6 +75,7 @@ BlazeComponent.extendComponent({ this.emailSetting.set('email-setting' === targetID); this.accountSetting.set('account-setting' === targetID); this.announcementSetting.set('announcement-setting' === targetID); + this.layoutSetting.set('layout-setting' === targetID); } }, @@ -82,7 +90,7 @@ BlazeComponent.extendComponent({ }, inviteThroughEmail() { - const emails = $('#email-to-invite').val().trim().split('\n').join(',').split(','); + const emails = $('#email-to-invite').val().toLowerCase().trim().split('\n').join(',').split(','); const boardsToInvite = []; $('.js-toggle-board-choose .materialCheckBox.is-checked').each(function () { boardsToInvite.push($(this).data('id')); @@ -129,19 +137,48 @@ BlazeComponent.extendComponent({ }, + saveLayout() { + this.setLoading(true); + $('li').removeClass('has-error'); + + const productName = $('#product-name').val().trim(); + const hideLogoChange = ($('input[name=hideLogo]:checked').val() === 'true'); + const displayAuthenticationMethod = ($('input[name=displayAuthenticationMethod]:checked').val() === 'true'); + const defaultAuthenticationMethod = $('#defaultAuthenticationMethod').val(); + const customHTMLafterBodyStart = $('#customHTMLafterBodyStart').val().trim(); + const customHTMLbeforeBodyEnd = $('#customHTMLbeforeBodyEnd').val().trim(); + + try { + Settings.update(Settings.findOne()._id, { + $set: { + productName, + hideLogo: hideLogoChange, + customHTMLafterBodyStart, + customHTMLbeforeBodyEnd, + displayAuthenticationMethod, + defaultAuthenticationMethod, + }, + }); + } catch (e) { + return; + } finally { + this.setLoading(false); + } + + DocHead.setTitle(productName); + + }, + sendSMTPTestEmail() { Meteor.call('sendSMTPTestEmail', (err, ret) => { - if (!err && ret) { /* eslint-disable no-console */ + if (!err && ret) { 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 */ }); }, @@ -154,6 +191,9 @@ BlazeComponent.extendComponent({ 'click button.js-email-invite': this.inviteThroughEmail, 'click button.js-save': this.saveMailServerInfo, 'click button.js-send-smtp-test-email': this.sendSMTPTestEmail, + 'click a.js-toggle-hide-logo': this.toggleHideLogo, + 'click button.js-save-layout': this.saveLayout, + 'click a.js-toggle-display-authentication-method': this.toggleDisplayAuthenticationMethod, }]; }, }).register('setting'); @@ -226,3 +266,29 @@ BlazeComponent.extendComponent({ }]; }, }).register('announcementSettings'); + + +Template.selectAuthenticationMethod.onCreated(function() { + this.authenticationMethods = new ReactiveVar([]); + + Meteor.call('getAuthenticationsEnabled', (_, result) => { + if (result) { + // TODO : add a management of different languages + // (ex {value: ldap, text: TAPi18n.__('ldap', {}, T9n.getLanguage() || 'en')}) + this.authenticationMethods.set([ + {value: 'password'}, + // Gets only the authentication methods availables + ...Object.entries(result).filter((e) => e[1]).map((e) => ({value: e[0]})), + ]); + } + }); +}); + +Template.selectAuthenticationMethod.helpers({ + authentications() { + return Template.instance().authenticationMethods.get(); + }, + isSelected(match) { + return Template.instance().data.authenticationMethod === match; + }, +}); diff --git a/client/components/settings/settingBody.styl b/client/components/settings/settingBody.styl index fec64cee..dbf91a6c 100644 --- a/client/components/settings/settingBody.styl +++ b/client/components/settings/settingBody.styl @@ -52,6 +52,10 @@ .main-body padding: 0.1em 1em + -webkit-user-select: auto // Safari 3.1+ + -moz-user-select: auto // Firefox 2+ + -ms-user-select: auto // IE 10+ + user-select: auto // Standard syntax ul li @@ -66,7 +70,8 @@ padding: 0 0.5rem .admin-announcement, - .invite-people + .invite-people, + .layout padding-left 20px; li min-width: 500px; diff --git a/client/components/settings/settingHeader.jade b/client/components/settings/settingHeader.jade index c2d4db3a..221c1b79 100644 --- a/client/components/settings/settingHeader.jade +++ b/client/components/settings/settingHeader.jade @@ -4,22 +4,21 @@ template(name="settingHeaderBar") .setting-header-btns.left unless isMiniScreen - unless isSandstorm - if currentUser - a.setting-header-btn.settings(href="{{pathFor 'setting'}}") - i.fa(class="fa-cog") - span {{_ 'settings'}} + if currentUser + a.setting-header-btn.settings(href="{{pathFor 'setting'}}") + i.fa(class="fa-cog") + span {{_ 'settings'}} - a.setting-header-btn.people(href="{{pathFor 'people'}}") - i.fa(class="fa-users") - span {{_ 'people'}} + a.setting-header-btn.people(href="{{pathFor 'people'}}") + i.fa(class="fa-users") + span {{_ 'people'}} - a.setting-header-btn.informations(href="{{pathFor 'information'}}") - i.fa(class="fa-info-circle") - span {{_ 'info'}} + a.setting-header-btn.informations(href="{{pathFor 'information'}}") + i.fa(class="fa-info-circle") + span {{_ 'info'}} - else - a.setting-header-btn.js-log-in( - title="{{_ 'log-in'}}") - i.fa.fa-sign-in - span {{_ 'log-in'}} + else + a.setting-header-btn.js-log-in( + title="{{_ 'log-in'}}") + i.fa.fa-sign-in + span {{_ 'log-in'}} |