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

Set user admin max results and Keycloak sync option

This commit is contained in:
McMatts 2018-08-20 17:17:25 +01:00
parent 2c8b757ff6
commit 351b8dcc12
13 changed files with 100 additions and 31 deletions

View file

@ -1,11 +1,11 @@
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
//
// This software (Documize Community Edition) is licensed under
// 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>.
// by contacting <sales@documize.com>.
//
// https://documize.com
@ -34,8 +34,11 @@ export default Base.extend({
authenticate(data) {
data.domain = netUtil.getSubdomain();
if (!isPresent(data.token) || !isPresent(data.email)) {
return reject("invalid");
if (!isPresent(data.token)) {
return reject("data.token is empty");
}
if (!isPresent(data.email)) {
return reject("data.email is empty");
}
return this.get('ajax').post('public/authenticate/keycloak', {
@ -45,7 +48,7 @@ export default Base.extend({
},
invalidate() {
this.get('localStorage').clearAll();
this.get('localStorage').clearAll();
return this.get('kcAuth').logout();
}
});
});

View file

@ -12,9 +12,9 @@
import $ from 'jquery';
import { inject as service } from '@ember/service';
import { schedule, debounce } from '@ember/runloop';
import Component from '@ember/component';
import AuthProvider from '../../mixins/auth';
import ModalMixin from '../../mixins/modal';
import Component from '@ember/component';
export default Component.extend(AuthProvider, ModalMixin, {
groupSvc: service('group'),
@ -230,6 +230,15 @@ export default Component.extend(AuthProvider, ModalMixin, {
this.get('groupSvc').join(groupId, userId).then(() => {
this.filterUsers();
});
},
onSync() {
this.get('onSync')();
},
onLimit(limit) {
this.set('userLimit', limit);
this.filterUsers();
}
}
});

View file

@ -41,7 +41,11 @@ export default Route.extend({
this.get("session").authenticate('authenticator:keycloak', data).then(() => {
this.transitionTo('folders');
}, (reject) => {
this.set('message', reject.Error);
if (is.not.undefined(reject.Error)) {
this.set('message', reject.Error);
} else {
this.set('message', reject);
}
this.set('mode', 'reject');
resolve();
});

View file

@ -14,9 +14,12 @@ import Controller from '@ember/controller';
export default Controller.extend({
userService: service('user'),
globalSvc: service('global'),
syncInProgress: false,
userLimit: 100,
loadUsers(filter) {
this.get('userService').getComplete(filter).then((users) => {
this.get('userService').getComplete(filter, this.get('userLimit')).then((users) => {
this.set('model', users);
});
},
@ -27,7 +30,7 @@ export default Controller.extend({
this.get('model').pushObject(user);
});
},
onAddUsers(list) {
return this.get('userService').addBulk(list).then(() => {
this.loadUsers('');
@ -52,6 +55,14 @@ export default Controller.extend({
onFilter(filter) {
this.loadUsers(filter);
},
onSync() {
this.set('syncInProgress', true);
this.get('globalSvc').syncExternalUsers().then(() => {
this.set('syncInProgress', false);
this.loadUsers('');
});
}
}
});

View file

@ -16,7 +16,6 @@ import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-rout
export default Route.extend(AuthenticatedRouteMixin, {
userService: service('user'),
global: service('global'),
appMeta: service(),
beforeModel () {
@ -27,19 +26,9 @@ export default Route.extend(AuthenticatedRouteMixin, {
model() {
return new EmberPromise((resolve) => {
let constants = this.get('constants');
if (this.get('appMeta.authProvider') == constants.AuthProvider.Keycloak) {
this.get('global').syncExternalUsers().then(() => {
this.get('userService').getComplete('').then((users) =>{
resolve(users);
});
});
} else {
this.get('userService').getComplete('').then((users) => {
resolve(users);
});
}
this.get('userService').getComplete('', 100).then((users) => {
resolve(users);
});
});
},

View file

@ -3,6 +3,9 @@
onAddUsers=(action 'onAddUsers')}}
{{customize/user-list users=model
syncInProgress=syncInProgress
userLimit=userLimit
onSync=(action "onSync")
onFilter=(action "onFilter")
onDelete=(action "onDelete")
onSave=(action "onSave")

View file

@ -68,11 +68,12 @@ export default Service.extend({
// Returns all active and inactive users for organization.
// Only available for admins and limits results to max. 100 users.
// Takes filter for user search criteria.
getComplete(filter) {
getComplete(filter, limit) {
filter = filter.trim();
if (filter.length > 0) filter = encodeURIComponent(filter);
if (is.null(limit) || is.undefined(limit)) limit = 100;
return this.get('ajax').request(`users?active=0&filter=${filter}`).then((response) => {
return this.get('ajax').request(`users?active=0&filter=${filter}&limit=${limit}`).then((response) => {
if (is.not.array(response)) response = [];
return response.map((obj) => {

View file

@ -157,4 +157,8 @@
}
}
}
> .max-results {
float: right;
}
}

View file

@ -1,4 +1,11 @@
<div class="view-customize my-5">
{{#if isAuthProviderKeycloak}}
{{#if syncInProgress}}
<div class="btn btn-secondary mt-3 mb-3">Keycloak user sync running...</div>
{{else}}
<div class="btn btn-success mt-3 mb-3" {{action 'onSync'}}>Sync with Keycloak</div>
{{/if}}
{{/if}}
<div class="my-2">
<span class="font-weight-bold">Spaces</span>
@ -26,6 +33,39 @@
<small class="form-text text-muted">search firstname, lastname, email</small>
</div>
<div class="max-results py-3">
<div class="btn-group btn-group-toggle">
<label class="btn btn-outline-secondary {{if (eq userLimit 1) 'active'}}">
<input type="radio" name="options" autocomplete="off" {{action 'onLimit' 1}}>1
</label>
<label class="btn btn-outline-secondary {{if (eq userLimit 10) 'active'}}">
<input type="radio" name="options" autocomplete="off" {{action 'onLimit' 10}}>10
</label>
<label class="btn btn-outline-secondary {{if (eq userLimit 25) 'active'}}">
<input type="radio" name="options" autocomplete="off" {{action 'onLimit' 25}}>25
</label>
<label class="btn btn-outline-secondary {{if (eq userLimit 50) 'active'}}">
<input type="radio" name="options" autocomplete="off" {{action 'onLimit' 50}}>50
</label>
<label class="btn btn-outline-secondary {{if (eq userLimit 100) 'active'}}">
<input type="radio" name="options" autocomplete="off" {{action 'onLimit' 100}}>100
</label>
<label class="btn btn-outline-secondary {{if (eq userLimit 250) 'active'}}">
<input type="radio" name="options" autocomplete="off" {{action 'onLimit' 250}}>250
</label>
<label class="btn btn-outline-secondary {{if (eq userLimit 500) 'active'}}">
<input type="radio" name="options" autocomplete="off" {{action 'onLimit' 500}}>500
</label>
<label class="btn btn-outline-secondary {{if (eq userLimit 1000) 'active'}}">
<input type="radio" name="options" autocomplete="off" {{action 'onLimit' 1000}}>1,000
</label>
<label class="btn btn-outline-secondary {{if (eq userLimit 99999) 'active'}}">
<input type="radio" name="options" autocomplete="off" {{action 'onLimit' 99999}}>all
</label>
</div>
</div>
<table class="table table-responsive table-borderless user-table">
<thead>
<tr>