[DEV] continue right integration

This commit is contained in:
Edouard DUPIN 2023-04-27 11:32:01 +02:00
parent 10cd17e594
commit 7917d239dc
12 changed files with 621 additions and 13 deletions

View File

@ -2,6 +2,7 @@
package org.kar.karso; package org.kar.karso;
import org.kar.archidata.util.ConfigBaseVariable; import org.kar.archidata.util.ConfigBaseVariable;
import org.kar.karso.util.ConfigVariable;
public class WebLauncherLocal { public class WebLauncherLocal {
private WebLauncherLocal() {} private WebLauncherLocal() {}
@ -11,6 +12,8 @@ public class WebLauncherLocal {
// for local test: // for local test:
ConfigBaseVariable.apiAdress = "http://0.0.0.0:15080/karso/api/"; ConfigBaseVariable.apiAdress = "http://0.0.0.0:15080/karso/api/";
ConfigBaseVariable.dbPort = "3306"; ConfigBaseVariable.dbPort = "3306";
// create a unique key for test ==> not retrieve the token every load...
ConfigVariable.uuid_for_key_generation = "lkjlkjlkjlmkjqmwlsdkjqfsdlkf,nmQLSDK,NFMQLKSdjmlKQJSDMLQK,S;ndmLQKZNERMA,ÉL";
//ConfigBaseVariable.dbType = "sqlite"; //ConfigBaseVariable.dbType = "sqlite";
//ConfigBaseVariable.dbHost = "./bdd_base.sqlite"; //ConfigBaseVariable.dbHost = "./bdd_base.sqlite";

View File

@ -47,6 +47,39 @@ public class ApplicationResource {
} }
return out; return out;
} }
public List<Long> getListOfUsers(Long applicationId) {
List<Long> out = new ArrayList<>();
List<UserLinkApplication> links = null;
try {
links = SqlWrapper.getsWhere(UserLinkApplication.class,
List.of(
new WhereCondition("application_id", "=", applicationId),
new WhereCondition("deleted", "=", 0)
), false);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
String result = "SERVER Internal error";
System.out.println(" result: " + result);
return out;
}
System.out.println("Find list of user for an application :" + links);
for (UserLinkApplication app : links) {
out.add(app.user_id);
}
return out;
}
@GET
@Path("{id}/users")
@RolesAllowed(value= {"ADMIN"})
public List<Long> getApplicationUsers(@PathParam("id") Long applicationId) throws Exception {
// special case for SSO: (all user have access on the SSO...).
System.out.println("Request list of user for an applciation:" + applicationId);
return getListOfUsers(applicationId);
}
@GET @GET
@RolesAllowed(value= {"USER", "ADMIN"}) @RolesAllowed(value= {"USER", "ADMIN"})
public List<Application> getApplications(@Context SecurityContext sc) throws Exception { public List<Application> getApplications(@Context SecurityContext sc) throws Exception {
@ -54,6 +87,9 @@ public class ApplicationResource {
System.out.println("getApplications"); System.out.println("getApplications");
// TODO filter with the list of element available in his authorizations ... // TODO filter with the list of element available in his authorizations ...
List<Application> tmp = SqlWrapper.gets(Application.class, false); List<Application> tmp = SqlWrapper.gets(Application.class, false);
if (gc.userByToken.hasRight("ADMIN", true)) {
return tmp;
}
List<Long> regular = this.getUserListOfApplication(gc.userByToken.id); List<Long> regular = this.getUserListOfApplication(gc.userByToken.id);
List<Application> out = new ArrayList<>(); List<Application> out = new ArrayList<>();
for (Application app : tmp) { for (Application app : tmp) {

View File

@ -19,6 +19,7 @@ import {
ManageAccountsScene, ManageAccountsScene,
ApplicationsScene, ApplicationsScene,
ApplicationEditScene, ApplicationEditScene,
ApplicationUserEditScene,
} from '../base/scene'; } from '../base/scene';
import { OnlyAdminGuard, OnlyUnregisteredGuardHome, OnlyUsersGuard, OnlyUsersGuardHome } from 'common/service/session'; import { OnlyAdminGuard, OnlyUnregisteredGuardHome, OnlyUsersGuard, OnlyUsersGuardHome } from 'common/service/session';
import { ForbiddenScene, NotFound404Scene } from 'common/scene'; import { ForbiddenScene, NotFound404Scene } from 'common/scene';
@ -79,6 +80,11 @@ const routes: Routes = [
component: ApplicationsScene, component: ApplicationsScene,
canActivate: [OnlyAdminGuard], canActivate: [OnlyAdminGuard],
}, },
{
path: 'application-user-edit/:applicationId',
component: ApplicationUserEditScene,
canActivate: [OnlyAdminGuard],
},
{ {
path: 'application-edit/:applicationId', path: 'application-edit/:applicationId',
component: ApplicationEditScene, component: ApplicationEditScene,

View File

@ -25,6 +25,7 @@ import {
ManageAccountsScene, ManageAccountsScene,
ApplicationsScene, ApplicationsScene,
ApplicationEditScene, ApplicationEditScene,
ApplicationUserEditScene,
} from 'base/scene'; } from 'base/scene';
import { import {
BddService, BddService,
@ -42,7 +43,23 @@ import {
UserService, UserService,
} from 'common/service'; } from 'common/service';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { ErrorComponent, PopInComponent, SpinerComponent, TopMenuComponent, UploadFileComponent, PasswordEntryComponent, EntryComponent, AsyncActionStatusComponent, ErrorMessageStateComponent, CheckboxComponent, BurgerPropertyComponent, EntryValidatorComponent, RenderSettingsComponent, RenderFormComponent, EntryNumberComponent } from 'common/component'; import {
ErrorComponent,
PopInComponent,
SpinerComponent,
TopMenuComponent,
UploadFileComponent,
PasswordEntryComponent,
EntryComponent,
AsyncActionStatusComponent,
ErrorMessageStateComponent,
CheckboxComponent,
BurgerPropertyComponent,
EntryValidatorComponent,
RenderSettingsComponent,
RenderFormComponent,
EntryNumberComponent,
} from 'common/component';
import { ForbiddenScene } from 'common/scene'; import { ForbiddenScene } from 'common/scene';
import { AdminUserService, ApplicationService, ApplicationTokenService, SettingsService } from 'base/service'; import { AdminUserService, ApplicationService, ApplicationTokenService, SettingsService } from 'base/service';
import { PopInUploadProgress, PopInDeleteConfirm } from 'common/popin'; import { PopInUploadProgress, PopInDeleteConfirm } from 'common/popin';
@ -84,7 +101,8 @@ import { environment } from 'environments/environment';
HomeUnregisteredScene, HomeUnregisteredScene,
ManageAccountsScene, ManageAccountsScene,
ApplicationsScene, ApplicationsScene,
ApplicationEditScene ApplicationEditScene,
ApplicationUserEditScene,
], ],
imports: [ imports: [
BrowserModule, BrowserModule,
@ -134,4 +152,5 @@ import { environment } from 'environments/environment';
bootstrap: [AppComponent], bootstrap: [AppComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA], schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA],
}) })
export class AppModule { }
export class AppModule { }

View File

@ -0,0 +1,132 @@
<div class="generic-page">
<div class="title">Configure Application (Users rights)</div>
<div class="fill-all">
<burger-property>
<name>Users</name>
<description>Users that have access on this application</description>
<body>
<table class="table-model">
<tr>
<th>id</th>
<th>login</th>
<th>actions</th>
</tr>
<tr *ngFor="let user of users">
<td>{{user.id}}</td>
<td>{{user.login}}</td>
<td>
<button class="square-button login color-shadow-black"
(click)="onEditUserRight($event, user)" type="submit">
<i class="material-icons">edit</i>
</button>&nbsp;
<button class="square-button login color-button-cancel color-shadow-black"
(click)="onRemoveApplicationUser($event, user)" type="submit">
<i class="material-icons">delete</i>
</button>
</td>
</tr>
</table>
</body>
</burger-property>
</div>
<div class="clear"><br /></div>
<div class="fill-all">
<burger-property>
<name>Add users</name>
<description>Add a new user at this application</description>
<body>
<table class="table-model">
<tr>
<th>id</th>
<th>login</th>
<th>add</th>
</tr>
<tr *ngFor="let user of notUsers">
<td>{{user.id}}</td>
<td>{{user.login}}</td>
<td>
<button class="circular-button color-button-validate color-shadow-black"
(click)="onAddApplicationUser($event, user)" type="submit">
+
</button>
</td>
</tr>
</table>
</body>
</burger-property>
</div>
<div class="clear"><br /></div>
<!--
<div class="fill-all">
<burger-property>
<name>Application properties</name>
<description>Update property of the application:</description>
<body>
<spiner *ngIf="editApplicationMenu===undefined"></spiner>
<app-render-form *ngIf="editApplicationMenu!==undefined" [values]="editApplicationMenu"
(deltaValues)="onEditValues($event)" (changeState)="onEditState($event)"></app-render-form>
</body>
<footer>
<button class="button login color-button-validate color-shadow-black" id="create-button"
[disabled]="updateButtonDisabled !== 0" (click)="onUpdateApplication()" type="submit">
Update
</button>
</footer>
</burger-property>
</div>
<div class="clear"><br /></div>
<div style="padding-top:15px;">
<burger-property>
<name>Associated Tokens</name>
<description>All current token available for this application</description>
<body>
<table class="table-model">
<tr>
<th>id</th>
<th>Name</th>
<th>Expiration Time</th>
<th>Token</th>
<th>Actions</th>
</tr>
<tr *ngFor="let token of tokens">
<td>{{token.id}}</td>
<td>{{token.name}}</td>
<td>{{formatTimestamp(token.endValidityTime)}}</td>
<td>{{token.token}}</td>
<td>
<button class="square-button login color-button-cancel color-shadow-black"
(click)="onRemoveApplicationToken($event, token)" type="submit">
<i class="material-icons">delete_forever</i>
</button>
</td>
</tr>
</table>
</body>
</burger-property>
</div>
<div class="clear"><br /></div>
<div style="padding-top:15px;">
<burger-property>
<name>Add Token</name>
<body>
<app-render-form [values]="createTokenMenu" (deltaValues)="onCreateValueDeltaValues($event)"
(changeState)="onCreateValueState($event)"></app-render-form>
</body>
<footer>
<button class="button login color-button-validate color-shadow-black" id="create-button"
(click)="createToken()" [disabled]="createTokenDisabled !== 0" type="submit">
+ Create new Token
</button>
</footer>
</burger-property>
</div>
<div class="clear"></div>
-->
</div>
<delete-confirm [comment]="confirmDeleteComment" (callback)="deleteConfirmed()"></delete-confirm>

View File

@ -0,0 +1,32 @@
.title {
//background-color: green;
font-size: 45px;
font-weight: bold;
line-height: 60px;
width: 100%;
text-align: center;
vertical-align: middle;
margin: 10px 0 10px 0;
text-shadow: 1px 1px 2px white, 0 0 1em white, 0 0 0.2em white;
text-transform: uppercase;
font-family: 'Roboto', 'Helvetica', 'Arial', sans-serif;
}
.table-model {
tr:nth-child(odd) {
background-color: rgb(180, 180, 180);
//color: #fff;
}
th {
background-color: darkgray;
text-align: center;
}
td {
text-align: center;
}
}
table {
width: 100%;
}

View File

@ -0,0 +1,356 @@
/** @file
* @author Edouard DUPIN
* @copyright 2018, Edouard DUPIN, all right reserved
* @license PROPRIETARY (see license file)
*/
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { ApplicationService, ApplicationModel, ApplicationTokenService, AdminUserService } from 'base/service';
import { ApplicationTokenModel } from 'base/service/application-token';
import { AsyncActionState } from 'common/component';
import { CheckerParameterType, SettingsItem, SettingType } from 'common/component/render-settings/render-settings';
import { ModelResponseHttp, NotificationService, PopInService } from 'common/service';
import { isNumber, isNumeric, isString } from 'common/utils';
@Component({
selector: 'application-setting-user-edit',
templateUrl: './application-user-edit.html',
styleUrls: ['./application-user-edit.less'],
changeDetection: ChangeDetectionStrategy.Default,
})
export class ApplicationUserEditScene implements OnInit {
id: number = undefined;
users: any[] = undefined;
notUsers: any[] = undefined;
application: ApplicationModel = undefined;
applicationRef: ApplicationModel = undefined;
tokens: ApplicationTokenModel[] = [];
constructor(
private adminUserService: AdminUserService,
private applicationService: ApplicationService,
private applicationTokenService: ApplicationTokenService,
private activatedRoute: ActivatedRoute,
private cdr: ChangeDetectorRef,
private popInService: PopInService,
private notificationService: NotificationService,
) {
}
ngOnInit() {
this.id = Number(this.activatedRoute.snapshot.paramMap.get('applicationId'));
const self = this;
this.applicationService
.getUsers(this.id)
.then((userListToFilter: number[]) => {
console.log(`??? get full response: ${JSON.stringify(userListToFilter, null, 4)}`);
self.adminUserService
.getUsers()
.then((response: any[]) => {
console.log(`All user available for this application: ${JSON.stringify(response, null, 4)}`);
self.users = [];
self.notUsers = [];
for (let iii = 0; iii < response.length; iii++) {
if (response[iii].blocked === true) {
continue;
}
if (userListToFilter.indexOf(response[iii].id) >= 0) {
self.users.push(response[iii]);
} else {
self.notUsers.push(response[iii]);
}
}
})
.catch((error: any) => {
console.log(`??? get ERROR response: ${JSON.stringify(error, null, 4)}`);
});
self.checkName(self.application.name);
this.configureEditInput();
})
.catch((error: any) => {
console.log(`??? get ERROR response: ${JSON.stringify(error, null, 4)}`);
});
/*
this.applicationService
.get(this.id)
.then((response: ApplicationModel) => {
console.log(`??? get full response: ${JSON.stringify(response, null, 4)}`);
self.application = response;
self.checkName(self.application.name);
this.configureEditInput();
})
.catch((error: any) => {
console.log(`??? get ERROR response: ${JSON.stringify(error, null, 4)}`);
});
this.applicationTokenService
.gets(this.id)
.then((response: ApplicationTokenModel[]) => {
console.log(`??? get full response: ${JSON.stringify(response, null, 4)}`);
self.tokens = response;
})
.catch((error: any) => {
console.log(`??? get ERROR response: ${JSON.stringify(error, null, 4)}`);
});
this.configureInput();
*/
}
onAddApplicationUser(value: boolean, user: any) {
console.log(`changeState : ${JSON.stringify(value, null, 2)}`);
j'en suis la ... add user une application
//this.createTokenDisabled = value;
// we do not change the main ref ==> notify angular that something have change and need to be re-render???
this.cdr.detectChanges();
}
formatTimestamp(unix_timestamp: number) {
return new Date(unix_timestamp).toISOString().replace('T', ' ').replace('Z', ' GMT').replace('.000', '');
}
editApplicationMenu: SettingsItem[] = undefined;
// this permit to clear the input menu...
configureEditInput() {
this.editApplicationMenu = [
{
type: SettingType.VALUE,
title: 'ID:',
value: this.application?.id,
},
{
type: SettingType.STRING,
title: 'Name:',
placeholder: 'Enter application name',
key: 'name',
value: this.application?.name,
checker: (value) => this.checkName(value),
require: true,
},
{
type: SettingType.STRING,
title: 'Description:',
key: 'description',
value: this.application?.description,
},
{
type: SettingType.STRING,
title: 'Redirect:',
description: 'Redirect when login (http://):',
placeholder: 'Enter http redirect addresses',
key: 'redirect',
value: this.application?.redirect,
checker: (value: CheckerParameterType) => this.checkRedirect(value),
require: true,
},
{
type: SettingType.STRING,
title: 'Redirect (dev):',
description: 'Redirect development (http://):',
placeholder: 'Enter http redirect addresses',
key: 'redirectDev',
value: this.application?.redirectDev,
},
{
type: SettingType.STRING,
title: 'Notification:',
description: 'Redirect development (http://):',
placeholder: 'http://xxx/sso-event',
key: 'notification',
value: this.application?.notification,
},
{
type: SettingType.NUMBER,
title: 'TTL:',
description: 'Time in seconds of the validity of the token',
placeholder: '888',
key: 'ttl',
value: this.application?.ttl,
checker: (value: CheckerParameterType) => this.checkTTL(value),
require: true,
},
];
this.updateButtonDisabled = undefined;
this.dataUpdate = {};
}
/**
* Check the redirection have a good form
*/
checkRedirect(value: CheckerParameterType): string | undefined {
if (!isString(value)) {
return 'must be a string';
}
if (value.length <= 5) {
return 'This redirect is too small.';
}
return undefined;
}
updateButtonDisabled: number | undefined = undefined;
dataUpdate: object = {}
onEditState(value: number) {
console.log(`changeState : ${JSON.stringify(value, null, 2)}`);
this.updateButtonDisabled = value;
// we do not change the main ref ==> notify angular that something have change and need to be re-render???
this.cdr.detectChanges();
}
onEditValues(value: any) {
console.log(`onDeltaValues : ${JSON.stringify(value, null, 2)}`);
this.dataUpdate = value;
// we do not change the main ref ==> notify angular that something have change and need to be re-render???
this.cdr.detectChanges();
}
updateState: string | boolean = undefined;
/**
* Request the creation of a new application.
*/
onUpdateApplication(): void {
this.updateState = AsyncActionState.LOADING;
let self = this;
this.applicationService.update(this.id, this.dataUpdate)
.then(
(data: ApplicationModel) => {
self.updateState = AsyncActionState.DONE;
console.log(`Get new application data: ${JSON.stringify(data, null, 2)}`);
self.application = data;
self.configureEditInput()
setTimeout(() => {
this.updateState = undefined;
}, 3000);
}
).catch(
(error: any) => {
self.updateState = AsyncActionState.FAIL;
setTimeout(() => {
self.updateState = undefined;
}, 3000);
}
);
}
createToken(): void {
let self = this;
this.applicationTokenService
.create(this.id, this.dataCreateApplication['name'], this.dataCreateApplication['ttl'])
.then((response: ApplicationTokenModel) => {
//console.log(`??? get fullllllll response: ${JSON.stringify(response, null, 4)}`);
self.tokens.push(response);
response.token = `"${response.id}:${response.token}"`
self.cdr.detectChanges();
})
.catch((error: any) => {
console.log(`??? get ERROR response: ${JSON.stringify(error, null, 4)}`);
});
}
onRemoveApplicationToken(_event: any, token: ApplicationTokenModel) {
this.confirmDeleteComment = `Delete the application token ID: [${this.application.id}/${token.id}] ${token.name}`;
this.confirmDeleteApplicationToken = token;
this.popInService.open('popin-delete-confirm');
}
removeApplicationConfirm(token: ApplicationTokenModel) {
let self = this;
this.applicationTokenService.remove(self.application.id, token.id)
.then(
() => {
const index = self.tokens.indexOf(token, 0);
if (index > -1) {
self.tokens.splice(index, 1);
self.cdr.detectChanges();
}
}
).catch(
(error: any) => {
self.notificationService.errorRaw(`Fail to delete application token: [${self.application.id}/${token.id}] : ${token.name} ==> ${error}`)
}
);
}
confirmDeleteComment: string = undefined;
confirmDeleteApplicationToken: ApplicationTokenModel = undefined;
deleteConfirmed() {
if (this.confirmDeleteApplicationToken !== undefined) {
this.removeApplicationConfirm(this.confirmDeleteApplicationToken);
this.confirmDeleteComment = undefined;
this.confirmDeleteApplicationToken = undefined;
}
}
createTokenMenu: SettingsItem[] = []
// this permit to clear the input menu...
configureInput() {
this.createTokenMenu = [
{
type: SettingType.STRING,
title: 'Token name:',
placeholder: 'Enter the token name / decription',
key: 'name',
value: '',
checker: (value: CheckerParameterType) => this.checkName(value),
require: true,
},
{
type: SettingType.NUMBER,
title: 'Token TTL:',
placeholder: 'Enter the Time To Lead (in day)',
key: 'ttl',
value: '',
checker: (value: CheckerParameterType) => this.checkTTL(value),
require: true,
},
];
}
public createTokenDisabled: number = undefined;
public dataCreateApplication: object = {};
/**
* Check the application name is available
*/
checkName(value: CheckerParameterType): string | undefined {
if (!isString(value)) {
return 'Must be a String';
}
if (value.length < 3) {
return 'This name is too small >=3.';
}
return undefined;
}
/**
* Check the redirection have a good form
*/
checkTTL(value: CheckerParameterType): string | undefined {
if (!isNumber(value)) {
return 'Must be a number';
}
const tokenTTL = Number(value);
if (tokenTTL < 1) {
return 'Minimum one day';
}
return undefined;
}
onCreateValueState(value: number) {
console.log(`changeState : ${JSON.stringify(value, null, 2)}`);
this.createTokenDisabled = value;
// we do not change the main ref ==> notify angular that something have change and need to be re-render???
this.cdr.detectChanges();
}
onCreateValueDeltaValues(value: any) {
console.log(`onDeltaValues : ${JSON.stringify(value, null, 2)}`);
this.dataCreateApplication = value;
// we do not change the main ref ==> notify angular that something have change and need to be re-render???
this.cdr.detectChanges();
}
}

View File

@ -12,7 +12,7 @@
<th>name</th> <th>name</th>
<th>Description</th> <th>Description</th>
<th>redirect</th> <th>redirect</th>
<th>TTL (min)</th> <th>TTL (minutes)</th>
<th>Notification</th> <th>Notification</th>
<th>Actions</th> <th>Actions</th>
</tr> </tr>

View File

@ -12,6 +12,7 @@ import { SignOutScene } from './sign-out/sign-out';
import { SignUpScene } from './sign-up/sign-up'; import { SignUpScene } from './sign-up/sign-up';
import { ValidateEmailScene } from './validate-email/validate-email'; import { ValidateEmailScene } from './validate-email/validate-email';
import { ApplicationEditScene } from './application-edit/application-edit'; import { ApplicationEditScene } from './application-edit/application-edit';
import { ApplicationUserEditScene } from './application-user-edit/application-user-edit';
export { export {
ErrorViewerScene, ErrorViewerScene,
@ -28,4 +29,5 @@ export {
ManageAccountsScene, ManageAccountsScene,
ApplicationsScene, ApplicationsScene,
ApplicationEditScene, ApplicationEditScene,
ApplicationUserEditScene,
}; };

View File

@ -104,7 +104,7 @@ export function isSettingsItem(data: any): data is SettingsItem {
}) })
export class ManageAccountsScene implements OnInit { export class ManageAccountsScene implements OnInit {
users: any = []; users: any = [];
adminLogin: string = ""; adminLogin: string = '';
constructor( constructor(
private adminUserService: AdminUserService, private adminUserService: AdminUserService,
@ -114,7 +114,7 @@ export class ManageAccountsScene implements OnInit {
} }
ngOnInit() { ngOnInit() {
this.adminLogin = this.sessionService.getLogin(); this.adminLogin = this.sessionService.getLogin();
let self = this; const self = this;
this.adminUserService this.adminUserService
.getUsers() .getUsers()
.then((response: any) => { .then((response: any) => {
@ -131,7 +131,7 @@ export class ManageAccountsScene implements OnInit {
console.log(`onSetAdmin: ${value} on ${user.login}`); console.log(`onSetAdmin: ${value} on ${user.login}`);
user.adminState = AsyncActionState.LOADING; user.adminState = AsyncActionState.LOADING;
this.cdr.detectChanges(); this.cdr.detectChanges();
let self = this; const self = this;
this.adminUserService.setAdmin(user.id, value) this.adminUserService.setAdmin(user.id, value)
.then( .then(
() => { () => {
@ -160,7 +160,7 @@ export class ManageAccountsScene implements OnInit {
console.log(`onSetBlocked: ${value} on ${user.login}`); console.log(`onSetBlocked: ${value} on ${user.login}`);
user.blockedState = AsyncActionState.LOADING; user.blockedState = AsyncActionState.LOADING;
this.cdr.detectChanges(); this.cdr.detectChanges();
let self = this; const self = this;
this.adminUserService.setBlocked(user.id, value) this.adminUserService.setBlocked(user.id, value)
.then( .then(
() => { () => {
@ -224,7 +224,7 @@ export class ManageAccountsScene implements OnInit {
onCreateUser(): void { onCreateUser(): void {
console.log(`create user:`); console.log(`create user:`);
this.createState = AsyncActionState.LOADING; this.createState = AsyncActionState.LOADING;
let self = this; const self = this;
this.adminUserService.createUsers(this.email, this.login, this.password) this.adminUserService.createUsers(this.email, this.login, this.password)
.then( .then(
(user_data: any) => { (user_data: any) => {
@ -259,7 +259,7 @@ export class ManageAccountsScene implements OnInit {
this.loginState = createLoginState(this.login); this.loginState = createLoginState(this.login);
if (this.loginState === true) { if (this.loginState === true) {
this.loginState = "Checking login ..."; this.loginState = "Checking login ...";
let self = this; const self = this;
this.adminUserService this.adminUserService
.checkLogin(this.login) .checkLogin(this.login)
.then((isNotUsed: boolean) => { .then((isNotUsed: boolean) => {
@ -293,7 +293,7 @@ export class ManageAccountsScene implements OnInit {
return; return;
} }
this.emailState = "Checking email ..."; this.emailState = "Checking email ...";
let self = this; const self = this;
this.adminUserService.checkEMail(this.email).then( this.adminUserService.checkEMail(this.email).then(
(isNotUsed: boolean) => { (isNotUsed: boolean) => {
// check if the answer is correct with the question // check if the answer is correct with the question

View File

@ -138,7 +138,6 @@ export class AdminUserService {
}); });
} }
setAdmin(userId: number, state: boolean): Promise<void> { setAdmin(userId: number, state: boolean): Promise<void> {
const body = state; const body = state;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {

View File

@ -131,6 +131,29 @@ export class ApplicationService {
}); });
} }
getUsers(id: number): Promise<number[]> {
return new Promise((resolve, reject) => {
this.http
.requestJson({
server: 'karso',
endPoint: `application/${id}/users`,
requestType: HTTPRequestModel.GET,
accept: HTTPMimeType.JSON,
contentType: HTTPMimeType.JSON,
})
.then((response: ModelResponseHttp) => {
// TODO: check type ...
console.log(
`retrieve return for application : get some data to check: ${JSON.stringify(response.data)}`
);
// TODO: check the format...
resolve(response.data);
})
.catch((error: any) => {
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
});
});
}
gets(): Promise<ApplicationModel[]> { gets(): Promise<ApplicationModel[]> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.http this.http
@ -182,7 +205,7 @@ export class ApplicationService {
requestType: HTTPRequestModel.PUT, requestType: HTTPRequestModel.PUT,
accept: HTTPMimeType.JSON, accept: HTTPMimeType.JSON,
contentType: HTTPMimeType.JSON, contentType: HTTPMimeType.JSON,
body:updateState, body: updateState,
}) })
.then((response: ModelResponseHttp) => { .then((response: ModelResponseHttp) => {
// TODO: check type ... // TODO: check type ...