1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-25 08:09:43 +02:00

moved emberjs to gui folder

This commit is contained in:
Harvey Kandola 2017-07-19 14:48:33 +01:00
parent 6a18d18f91
commit dc49dbbeff
999 changed files with 677 additions and 651 deletions

View file

@ -0,0 +1,156 @@
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
//
// This software (Documize Community Edition) is licensed under
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
//
// You can operate outside the AGPL restrictions by purchasing
// Documize Enterprise Edition and obtaining a commercial license
// by contacting <sales@documize.com>.
//
// https://documize.com
import Ember from 'ember';
import constants from '../../utils/constants';
import encoding from '../../utils/encoding';
import NotifierMixin from "../../mixins/notifier";
const {
computed
} = Ember;
export default Ember.Component.extend(NotifierMixin, {
appMeta: Ember.inject.service(),
isDocumizeProvider: computed.equal('authProvider', constants.AuthProvider.Documize),
isKeycloakProvider: computed.equal('authProvider', constants.AuthProvider.Keycloak),
KeycloakUrlError: computed.empty('keycloakConfig.url'),
KeycloakRealmError: computed.empty('keycloakConfig.realm'),
KeycloakClientIdError: computed.empty('keycloakConfig.clientId'),
KeycloakPublicKeyError: computed.empty('keycloakConfig.publicKey'),
KeycloakAdminUserError: computed.empty('keycloakConfig.adminUser'),
KeycloakAdminPasswordError: computed.empty('keycloakConfig.adminPassword'),
keycloakConfig: {
url: '',
realm: '',
clientId: '',
publicKey: '',
adminUser: '',
adminPassword: '',
group: '',
disableLogout: false,
defaultPermissionAddSpace: false
},
didReceiveAttrs() {
this._super(...arguments);
let provider = this.get('authProvider');
switch (provider) {
case constants.AuthProvider.Documize:
// nothing to do
break;
case constants.AuthProvider.Keycloak: // eslint-disable-line no-case-declarations
let config = this.get('authConfig');
if (is.undefined(config) || is.null(config) || is.empty(config) ) {
config = {};
} else {
config = JSON.parse(config);
config.publicKey = encoding.Base64.decode(config.publicKey);
config.defaultPermissionAddSpace = config.hasOwnProperty('defaultPermissionAddSpace') ? config.defaultPermissionAddSpace : false;
config.disableLogout = config.hasOwnProperty('disableLogout') ? config.disableLogout : true;
}
this.set('keycloakConfig', config);
break;
}
},
actions: {
onDocumize() {
this.set('authProvider', constants.AuthProvider.Documize);
},
onKeycloak() {
this.set('authProvider', constants.AuthProvider.Keycloak);
},
onSave() {
let provider = this.get('authProvider');
let config = this.get('authConfig');
switch (provider) {
case constants.AuthProvider.Documize:
config = {};
break;
case constants.AuthProvider.Keycloak:
if (this.get('KeycloakUrlError')) {
this.$("#keycloak-url").focus();
return;
}
if (this.get('KeycloakRealmError')) {
this.$("#keycloak-realm").focus();
return;
}
if (this.get('KeycloakClientIdError')) {
this.$("#keycloak-clientId").focus();
return;
}
if (this.get('KeycloakPublicKeyError')) {
this.$("#keycloak-publicKey").focus();
return;
}
if (this.get('KeycloakAdminUserError')) {
this.$("#keycloak-admin-user").focus();
return;
}
if (this.get('KeycloakAdminPasswordError')) {
this.$("#keycloak-admin-password").focus();
return;
}
config = Ember.copy(this.get('keycloakConfig'));
config.url = config.url.trim();
config.realm = config.realm.trim();
config.clientId = config.clientId.trim();
config.publicKey = config.publicKey.trim();
config.group = is.undefined(config.group) ? '' : config.group.trim();
config.adminUser = config.adminUser.trim();
config.adminPassword = config.adminPassword.trim();
config.defaultPermissionAddSpace = config.hasOwnProperty('defaultPermissionAddSpace') ? config.defaultPermissionAddSpace : true;
config.disableLogout = config.hasOwnProperty('disableLogout') ? config.disableLogout : true;
if (is.endWith(config.url, '/')) {
config.url = config.url.substring(0, config.url.length-1);
}
Ember.set(config, 'publicKey', encoding.Base64.encode(this.get('keycloakConfig.publicKey')));
break;
}
let data = { authProvider: provider, authConfig: JSON.stringify(config) };
this.get('onSave')(data).then(() => {
if (data.authProvider === constants.AuthProvider.Keycloak) {
this.get('onSync')().then((response) => {
if (response.isError) {
this.showNotification(response.message);
data.authProvider = constants.AuthProvider.Documize;
this.get('onSave')(data).then(() => {
this.showNotification('Reverted back to Documize');
});
} else {
if (data.authProvider === this.get('appMeta.authProvider')) {
this.showNotification(response.message);
} else {
this.get('onChange')(data);
}
}
});
} else {
this.showNotification('Saved');
}
});
}
}
});

View file

@ -0,0 +1,59 @@
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
//
// This software (Documize Community Edition) is licensed under
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
//
// You can operate outside the AGPL restrictions by purchasing
// Documize Enterprise Edition and obtaining a commercial license
// by contacting <sales@documize.com>.
//
// https://documize.com
import Ember from 'ember';
const {
isEmpty,
computed,
set
} = Ember;
export default Ember.Component.extend({
titleEmpty: computed.empty('model.general.title'),
messageEmpty: computed.empty('model.general.message'),
conversionEndpointEmpty: computed.empty('model.general.conversionEndpoint'),
hasTitleInputError: computed.and('titleEmpty', 'titleError'),
hasMessageInputError: computed.and('messageEmpty', 'messageError'),
hasConversionEndpointInputError: computed.and('conversionEndpointEmpty', 'conversionEndpointError'),
actions: {
save() {
if (isEmpty(this.get('model.general.title'))) {
set(this, 'titleError', true);
return $("#siteTitle").focus();
}
if (isEmpty(this.get('model.general.message'))) {
set(this, 'messageError', true);
return $("#siteMessage").focus();
}
if (isEmpty(this.get('model.general.conversionEndpoint'))) {
set(this, 'conversionEndpointError', true);
return $("#conversionEndpoint").focus();
}
let e = this.get('model.general.conversionEndpoint');
if (is.endWith(e, '/')) {
this.set('model.general.conversionEndpoint', e.substring(0, e.length-1));
}
this.model.general.set('allowAnonymousAccess', Ember.$("#allowAnonymousAccess").prop('checked'));
this.get('save')().then(() => {
set(this, 'titleError', false);
set(this, 'messageError', false);
set(this, 'conversionEndpointError', false);
});
}
}
});

View file

@ -0,0 +1,58 @@
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
//
// This software (Documize Community Edition) is licensed under
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
//
// You can operate outside the AGPL restrictions by purchasing
// Documize Enterprise Edition and obtaining a commercial license
// by contacting <sales@documize.com>.
//
// https://documize.com
import Ember from 'ember';
const {
computed
} = Ember;
export default Ember.Component.extend({
SMTPHostEmptyError: computed.empty('model.smtp.host'),
SMTPPortEmptyError: computed.empty('model.smtp.port'),
SMTPSenderEmptyError: computed.empty('model.smtp.sender'),
SMTPUserIdEmptyError: computed.empty('model.smtp.userid'),
SMTPPasswordEmptyError: computed.empty('model.smtp.password'),
actions: {
saveSMTP() {
if (this.get('SMTPHostEmptyError')) {
$("#smtp-host").focus();
return;
}
if (this.get('SMTPPortEmptyError')) {
$("#smtp-port").focus();
return;
}
if (this.get('SMTPSenderEmptyError')) {
$("#smtp-sender").focus();
return;
}
if (this.get('SMTPUserIdEmptyError')) {
$("#smtp-userid").focus();
return;
}
if (this.get('SMTPPasswordEmptyError')) {
$("#smtp-password").focus();
return;
}
this.get('saveSMTP')().then(() => {
});
},
saveLicense() {
this.get('saveLicense')().then(() => {
window.location.reload();
});
}
}
});

View file

@ -0,0 +1,202 @@
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
//
// This software (Documize Community Edition) is licensed under
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
//
// You can operate outside the AGPL restrictions by purchasing
// Documize Enterprise Edition and obtaining a commercial license
// by contacting <sales@documize.com>.
//
// https://documize.com
import Ember from 'ember';
import AuthProvider from '../../mixins/auth';
export default Ember.Component.extend(AuthProvider, {
editUser: null,
deleteUser: null,
drop: null,
password: {},
filter: '',
filteredUsers: [],
selectedUsers: [],
hasSelectedUsers: false,
didReceiveAttrs() {
this.users.forEach(user => {
user.set('me', user.get('id') === this.get('session.session.authenticated.user.id'));
user.set('selected', false);
});
this.set('filteredUsers', this.users);
},
willDestroyElement() {
let drop = this.get('drop');
if (is.not.null(drop)) {
drop.destroy();
}
},
onKeywordChange: function () {
Ember.run.debounce(this, this.filterUsers, 350);
}.observes('filter'),
filterUsers() {
let users = this.get('users');
let filteredUsers = [];
let filter = this.get('filter').toLowerCase();
users.forEach(user => {
if (user.get('fullname').toLowerCase().includes(filter) || user.get('email').toLowerCase().includes(filter)) {
filteredUsers.pushObject(user);
}
});
this.set('filteredUsers', filteredUsers);
},
actions: {
toggleSelect(user) {
user.set('selected', !user.get('selected'));
let su = this.get('selectedUsers');
if (user.get('selected')) {
su.push(user.get('id'));
} else {
su = _.reject(su, function(id){ return id === user.get('id') });
}
this.set('selectedUsers', su);
this.set('hasSelectedUsers', su.length > 0);
},
toggleActive(id) {
let user = this.users.findBy("id", id);
user.set('active', !user.get('active'));
this.attrs.onSave(user);
},
toggleEditor(id) {
let user = this.users.findBy("id", id);
user.set('editor', !user.get('editor'));
this.attrs.onSave(user);
},
toggleAdmin(id) {
let user = this.users.findBy("id", id);
user.set('admin', !user.get('admin'));
this.attrs.onSave(user);
},
edit(id) {
let self = this;
let user = this.users.findBy("id", id);
let userCopy = user.getProperties('id', 'created', 'revised', 'firstname', 'lastname', 'email', 'initials', 'active', 'editor', 'admin', 'accounts');
this.set('editUser', userCopy);
this.set('password', {
password: "",
confirmation: ""
});
$(".edit-user-dialog").css("display", "block");
$("input").removeClass("error");
let drop = new Drop({
target: $(".edit-button-" + id)[0],
content: $(".edit-user-dialog")[0],
classes: 'drop-theme-basic',
position: "bottom right",
openOn: "always",
tetherOptions: {
offset: "5px 0",
targetOffset: "10px 0"
},
remove: false
});
self.set('drop', drop);
drop.on('open', function () {
self.$("#edit-firstname").focus();
});
},
confirmDelete(id) {
let user = this.users.findBy("id", id);
this.set('deleteUser', user);
$(".delete-user-dialog").css("display", "block");
let drop = new Drop({
target: $(".delete-button-" + id)[0],
content: $(".delete-user-dialog")[0],
classes: 'drop-theme-basic',
position: "bottom right",
openOn: "always",
tetherOptions: {
offset: "5px 0",
targetOffset: "10px 0"
},
remove: false
});
this.set('drop', drop);
},
cancel() {
let drop = this.get('drop');
drop.close();
},
save() {
let user = this.get('editUser');
let password = this.get('password');
if (is.empty(user.firstname)) {
$("#edit-firstname").addClass("error").focus();
return;
}
if (is.empty(user.lastname)) {
$("#edit-lastname").addClass("error").focus();
return;
}
if (is.empty(user.email)) {
$("#edit-email").addClass("error").focus();
return;
}
let drop = this.get('drop');
drop.close();
this.attrs.onSave(user);
if (is.not.empty(password.password) && is.not.empty(password.confirmation) &&
password.password === password.confirmation) {
this.attrs.onPassword(user, password.password);
}
},
delete() {
let drop = this.get('drop');
drop.close();
this.set('selectedUsers', []);
this.set('hasSelectedUsers', false);
this.attrs.onDelete(this.get('deleteUser.id'));
},
onBulkDelete() {
let su = this.get('selectedUsers');
su.forEach(userId => {
this.attrs.onDelete(userId);
});
this.set('selectedUsers', []);
this.set('hasSelectedUsers', false);
return true;
}
}
});

View file

@ -0,0 +1,57 @@
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
//
// This software (Documize Community Edition) is licensed under
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
//
// You can operate outside the AGPL restrictions by purchasing
// Documize Enterprise Edition and obtaining a commercial license
// by contacting <sales@documize.com>.
//
// https://documize.com
import Ember from 'ember';
import AuthProvider from '../../mixins/auth';
const {
isEmpty,
computed,
set,
get
} = Ember;
export default Ember.Component.extend(AuthProvider, {
newUser: { firstname: "", lastname: "", email: "", active: true },
firstnameEmpty: computed.empty('newUser.firstname'),
lastnameEmpty: computed.empty('newUser.lastname'),
emailEmpty: computed.empty('newUser.email'),
hasFirstnameEmptyError: computed.and('firstnameEmpty', 'firstnameError'),
hasLastnameEmptyError: computed.and('lastnameEmpty', 'lastnameError'),
hasEmailEmptyError: computed.and('emailEmpty', 'emailError'),
actions: {
add() {
if (isEmpty(this.get('newUser.firstname'))) {
set(this, 'firstnameError', true);
return $("#newUserFirstname").focus();
}
if (isEmpty(this.get('newUser.lastname'))) {
set(this, 'lastnameError', true);
return $("#newUserLastname").focus();
}
if (isEmpty(this.get('newUser.email')) || is.not.email(this.get('newUser.email'))) {
set(this, 'emailError', true);
return $("#newUserEmail").focus();
}
let user = get(this, 'newUser');
get(this, 'add')(user).then(() => {
this.set('newUser', { firstname: "", lastname: "", email: "", active: true });
set(this, 'firstnameError', false);
set(this, 'lastnameError', false);
set(this, 'emailError', false);
$("#newUserFirstname").focus();
});
}
}
});