[DEV] continue integration of right management
This commit is contained in:
parent
8a700864d6
commit
2d134fbb95
@ -198,7 +198,7 @@ public class ApplicationResource {
|
||||
SqlWrapper.addLink(UserAuth.class, data.userId, "application", applicationId);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// TODO : review the function to correct admin only access...
|
||||
@DELETE
|
||||
@Path("{id}/users")
|
||||
@ -209,6 +209,17 @@ public class ApplicationResource {
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO : review the function to correct admin only access...
|
||||
@GET
|
||||
@Path("{id}/rights")
|
||||
@RolesAllowed(value= {"ADMIN"})
|
||||
public List<RightDescription> getRightsDescription(@PathParam("id") Long applicationId) throws Exception {
|
||||
logger.debug("getApplications rights");
|
||||
return SqlWrapper.getsWhere(RightDescription.class, List.of(
|
||||
new WhereCondition("applicationId", "=", applicationId)),
|
||||
false);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("get_token")
|
||||
@RolesAllowed(value= {"USER", "ADMIN"})
|
||||
|
@ -66,11 +66,11 @@ public class UserResource {
|
||||
//GenericContext gc = (GenericContext) sc.getUserPrincipal();
|
||||
return SqlWrapper.get(UserAuthGet.class, userId);
|
||||
}
|
||||
|
||||
|
||||
@POST
|
||||
@Path("{userId}/application/{applicationId}/link")
|
||||
@RolesAllowed("ADMIN")
|
||||
public Response linkApplication(@Context SecurityContext sc,
|
||||
public UserAuth linkApplication(@Context SecurityContext sc,
|
||||
@PathParam("userId") long userId,
|
||||
@PathParam("applicationId") long applicationId,
|
||||
boolean data) throws Exception {
|
||||
@ -80,7 +80,8 @@ public class UserResource {
|
||||
} else {
|
||||
SqlWrapper.removeLink(UserAuth.class, userId, "application", applicationId);
|
||||
}
|
||||
return Response.ok(SqlWrapper.get(UserAuth.class, userId)).build();
|
||||
return SqlWrapper.get(UserAuth.class, userId);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: check this it might be deprecated ...
|
||||
|
@ -35,6 +35,10 @@ public class Initialization extends MigrationSqlStep {
|
||||
(1, 'karadmin', '0ddcac5ede3f1300a1ce5948ab15112f2810130531d578ab8bc4dc131652d7cf7a3ff6e827eb957bff43bc2c65a6a1d46722e5b3a2343ac3176a33ea7250080b',
|
||||
'admin@admin.ZZZ', 1);
|
||||
""");
|
||||
addAction("""
|
||||
INSERT INTO `user_link_application` (`user_id`, `application_id`)
|
||||
VALUES ('1', '1');
|
||||
""");
|
||||
addAction("""
|
||||
INSERT INTO `settings` (`key`, `right`, `type`, `value`) VALUES
|
||||
('SIGN_UP_ENABLE', 'rwr-r-', 'BOOLEAN', 'false'),
|
||||
@ -52,19 +56,19 @@ public class Initialization extends MigrationSqlStep {
|
||||
""");
|
||||
// we generate an offset to permit to manage some generic upgrade in the future...
|
||||
addAction("""
|
||||
ALTER TABLE application AUTO_INCREMENT = 1000;
|
||||
ALTER TABLE `application` AUTO_INCREMENT = 1000;
|
||||
""");
|
||||
addAction("""
|
||||
ALTER TABLE user AUTO_INCREMENT = 1000;
|
||||
ALTER TABLE `user` AUTO_INCREMENT = 1000;
|
||||
""");
|
||||
addAction("""
|
||||
ALTER TABLE settings AUTO_INCREMENT = 1000;
|
||||
ALTER TABLE `settings` AUTO_INCREMENT = 1000;
|
||||
""");
|
||||
addAction("""
|
||||
ALTER TABLE right AUTO_INCREMENT = 1000;
|
||||
ALTER TABLE `right` AUTO_INCREMENT = 1000;
|
||||
""");
|
||||
addAction("""
|
||||
ALTER TABLE rightDescription AUTO_INCREMENT = 1000;
|
||||
ALTER TABLE `rightDescription` AUTO_INCREMENT = 1000;
|
||||
""");
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@ import {
|
||||
ApplicationsScene,
|
||||
ApplicationEditScene,
|
||||
ApplicationUserEditScene,
|
||||
applicationUserRightEditScene,
|
||||
} from '../base/scene';
|
||||
import { OnlyAdminGuard, OnlyUnregisteredGuardHome, OnlyUsersGuard, OnlyUsersGuardHome } from 'common/service/session';
|
||||
import { ForbiddenScene, NotFound404Scene } from 'common/scene';
|
||||
@ -80,6 +81,11 @@ const routes: Routes = [
|
||||
component: ApplicationsScene,
|
||||
canActivate: [OnlyAdminGuard],
|
||||
},
|
||||
{
|
||||
path: 'application-user-right-edit/:applicationId/:userId',
|
||||
component: applicationUserRightEditScene,
|
||||
canActivate: [OnlyAdminGuard],
|
||||
},
|
||||
{
|
||||
path: 'application-user-edit/:applicationId',
|
||||
component: ApplicationUserEditScene,
|
||||
|
@ -26,6 +26,7 @@ import {
|
||||
ApplicationsScene,
|
||||
ApplicationEditScene,
|
||||
ApplicationUserEditScene,
|
||||
applicationUserRightEditScene,
|
||||
} from 'base/scene';
|
||||
import {
|
||||
BddService,
|
||||
@ -103,6 +104,7 @@ import { environment } from 'environments/environment';
|
||||
ApplicationsScene,
|
||||
ApplicationEditScene,
|
||||
ApplicationUserEditScene,
|
||||
applicationUserRightEditScene,
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
|
@ -247,7 +247,7 @@ export class ApplicationEditScene implements OnInit {
|
||||
{
|
||||
type: SettingType.STRING,
|
||||
title: 'Token name:',
|
||||
placeholder: 'Enter the token name / decription',
|
||||
placeholder: 'Enter the token name / description',
|
||||
key: 'name',
|
||||
value: '',
|
||||
checker: (value: CheckerParameterType) => { return this.checkName(value) },
|
||||
|
@ -1,5 +1,5 @@
|
||||
<div class="generic-page">
|
||||
<div class="title">Configure Application (Users rights)</div>
|
||||
<div class="title">Configure Application: '{{applicationName}}' (Users rights)</div>
|
||||
<div class="fill-all">
|
||||
<burger-property>
|
||||
<name>Users</name>
|
||||
@ -58,75 +58,6 @@
|
||||
</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>
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { ApplicationService, ApplicationModel, ApplicationTokenService, AdminUserService } from 'base/service';
|
||||
import { ApplicationTokenModel } from 'base/service/application-token';
|
||||
import { AsyncActionState } from 'common/component';
|
||||
@ -23,7 +23,7 @@ export class ApplicationUserEditScene implements OnInit {
|
||||
id: number = undefined;
|
||||
users: any[] = undefined;
|
||||
notUsers: any[] = undefined;
|
||||
application: ApplicationModel = undefined;
|
||||
applicationName: string = undefined;
|
||||
applicationRef: ApplicationModel = undefined;
|
||||
tokens: ApplicationTokenModel[] = [];
|
||||
|
||||
@ -35,11 +35,24 @@ export class ApplicationUserEditScene implements OnInit {
|
||||
private cdr: ChangeDetectorRef,
|
||||
private popInService: PopInService,
|
||||
private notificationService: NotificationService,
|
||||
private router: Router,
|
||||
) {
|
||||
}
|
||||
ngOnInit() {
|
||||
this.id = Number(this.activatedRoute.snapshot.paramMap.get('applicationId'));
|
||||
const self = this;
|
||||
// get local information of the application
|
||||
this.applicationService
|
||||
.get(this.id)
|
||||
.then((response: ApplicationModel) => {
|
||||
console.log(`??? get full response: ${JSON.stringify(response, null, 4)}`);
|
||||
self.applicationName = response.name;
|
||||
self.applicationRef = response;
|
||||
})
|
||||
.catch((error: any) => {
|
||||
console.log(`??? get ERROR response: ${JSON.stringify(error, null, 4)}`);
|
||||
});
|
||||
// get all the user connected on it
|
||||
this.applicationService
|
||||
.getUsers(this.id)
|
||||
.then((userListToFilter: number[]) => {
|
||||
@ -64,36 +77,10 @@ export class ApplicationUserEditScene implements OnInit {
|
||||
.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();
|
||||
*/
|
||||
}
|
||||
|
||||
onRemoveApplicationUser(value: boolean, user: any) {
|
||||
@ -114,7 +101,6 @@ export class ApplicationUserEditScene implements OnInit {
|
||||
.catch((error: any) => {
|
||||
console.log(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
||||
});
|
||||
//this.cdr.detectChanges();
|
||||
}
|
||||
onAddApplicationUser(value: boolean, user: any) {
|
||||
console.log(`changeState : ${JSON.stringify(value, null, 2)}`);
|
||||
@ -134,160 +120,17 @@ export class ApplicationUserEditScene implements OnInit {
|
||||
.catch((error: any) => {
|
||||
console.log(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
||||
});
|
||||
//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(
|
||||
() => {
|
||||
@ -302,6 +145,7 @@ export class ApplicationUserEditScene implements OnInit {
|
||||
self.notificationService.errorRaw(`Fail to delete application token: [${self.application.id}/${token.id}] : ${token.name} ==> ${error}`)
|
||||
}
|
||||
);
|
||||
*/
|
||||
}
|
||||
confirmDeleteComment: string = undefined;
|
||||
confirmDeleteApplicationToken: ApplicationTokenModel = undefined;
|
||||
@ -383,6 +227,9 @@ export class ApplicationUserEditScene implements OnInit {
|
||||
// we do not change the main ref ==> notify angular that something have change and need to be re-render???
|
||||
this.cdr.detectChanges();
|
||||
}
|
||||
onEditUserRight(_event: any, user: any) {
|
||||
this.router.navigate(['application-user-right-edit', this.applicationRef.id, user.id]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,30 @@
|
||||
<div class="generic-page">
|
||||
<div class="title">Edit user right</div>
|
||||
<div class="fill-all">
|
||||
<burger-property>
|
||||
<name>User right: {{applicationName}} / {{userName}}</name>
|
||||
<description>Update the user rights:</description>
|
||||
|
||||
<body>
|
||||
<!--
|
||||
<spiner *ngIf="editApplicationMenu===undefined"></spiner>
|
||||
<app-render-form
|
||||
*ngIf="editApplicationMenu!==undefined"
|
||||
[values]="editApplicationMenu"
|
||||
(deltaValues)="onEditValues($event)"
|
||||
(changeState)="onEditState($event)"
|
||||
></app-render-form>
|
||||
-->
|
||||
<app-render-settings [values]="editMenu" (deltaValues)="onEditValues($event)"
|
||||
(changeState)="onEditState($event)"></app-render-settings>
|
||||
</body>
|
||||
<footer>
|
||||
<button class="button login color-button-validate color-shadow-black" id="create-button"
|
||||
[disabled]="updateButtonDisabled !== 0" (click)="onUpdate()" type="submit">
|
||||
Update
|
||||
</button>
|
||||
</footer>
|
||||
</burger-property>
|
||||
</div>
|
||||
<div class="clear"><br /></div>
|
||||
</div>
|
@ -0,0 +1,13 @@
|
||||
.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;
|
||||
}
|
@ -0,0 +1,173 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2018, Edouard DUPIN, all right reserved
|
||||
* @license PROPRIETARY (see license file)
|
||||
*/
|
||||
|
||||
import { ChangeDetectorRef, Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { ApplicationModel, ApplicationService, SettingsService } from 'base/service';
|
||||
import { ApplicationRightModel } from 'base/service/application';
|
||||
import { SettingType, SettingsItem } from '../manage-accounts/manage-accounts';
|
||||
import { UserService } from 'common/service';
|
||||
|
||||
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'application-user-right-edit',
|
||||
templateUrl: './application-user-right-edit.html',
|
||||
styleUrls: ['./application-user-right-edit.less'],
|
||||
})
|
||||
export class applicationUserRightEditScene implements OnInit {
|
||||
page = '';
|
||||
applicationId: number = undefined;
|
||||
userId: number = undefined;
|
||||
application: ApplicationModel;
|
||||
rowRight: ApplicationRightModel[];
|
||||
applicationName: string;
|
||||
userName: string;
|
||||
|
||||
constructor(
|
||||
private settingService: SettingsService,
|
||||
private applicationService: ApplicationService,
|
||||
private userService: UserService,
|
||||
private activatedRoute: ActivatedRoute,
|
||||
private cdr: ChangeDetectorRef,
|
||||
) { }
|
||||
|
||||
|
||||
ngOnInit() {
|
||||
this.applicationId = Number(this.activatedRoute.snapshot.paramMap.get('applicationId'));
|
||||
this.userId = Number(this.activatedRoute.snapshot.paramMap.get('userId'));
|
||||
let self = this;
|
||||
this.applicationService
|
||||
.get(this.applicationId)
|
||||
.then((response: ApplicationModel) => {
|
||||
console.log(`??? get full response: ${JSON.stringify(response, null, 4)}`);
|
||||
self.applicationName = response.name;
|
||||
self.application = response;
|
||||
//this.configureEditInput();
|
||||
})
|
||||
.catch((error: any) => {
|
||||
console.log(`??? get ERROR response: ${JSON.stringify(error, null, 4)}`);
|
||||
});
|
||||
/* TODO:
|
||||
this.userService
|
||||
.get(this.userId)
|
||||
.then((response: UserModel) => {
|
||||
console.log(`??? get full response: ${JSON.stringify(response, null, 4)}`);
|
||||
self.userName = response.name;
|
||||
//this.configureEditInput();
|
||||
})
|
||||
.catch((error: any) => {
|
||||
console.log(`??? get ERROR response: ${JSON.stringify(error, null, 4)}`);
|
||||
});
|
||||
*/
|
||||
this.applicationService
|
||||
.getApplicationRights(this.applicationId)
|
||||
.then((response: ApplicationRightModel[]) => {
|
||||
console.log(`??? get full response: ${JSON.stringify(response, null, 4)}`);
|
||||
self.rowRight = response;
|
||||
this.configureEditInput();
|
||||
})
|
||||
.catch((error: any) => {
|
||||
console.log(`??? get ERROR response: ${JSON.stringify(error, null, 4)}`);
|
||||
});
|
||||
// get all the user connected on it
|
||||
/*
|
||||
this.applicationService
|
||||
.getUserRight(this.applicationId, this.userId)
|
||||
.then((userListToFilter: object[]) => {
|
||||
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)}`);
|
||||
});
|
||||
})
|
||||
.catch((error: any) => {
|
||||
console.log(`??? get ERROR response: ${JSON.stringify(error, null, 4)}`);
|
||||
});
|
||||
*/
|
||||
}
|
||||
editMenu: SettingsItem[] = undefined;
|
||||
|
||||
// this permit to clear the input menu...
|
||||
configureEditInput() {
|
||||
console.log(`generate inputs: ${JSON.stringify(this.rowRight, null, 4)}`);
|
||||
const tmp = [];
|
||||
for (let iii = 0; iii < this.rowRight.length; iii++) {
|
||||
const elem = this.rowRight[iii];
|
||||
tmp.push({
|
||||
type: SettingType.BOOLEAN,
|
||||
title: elem.title,
|
||||
description: elem.description,
|
||||
key: elem.key,
|
||||
value: false,
|
||||
});
|
||||
}
|
||||
this.editMenu = tmp;
|
||||
this.cdr.detectChanges();
|
||||
}
|
||||
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.
|
||||
*/
|
||||
onUpdate(): 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);
|
||||
}
|
||||
);
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
@ -13,6 +13,7 @@ import { SignUpScene } from './sign-up/sign-up';
|
||||
import { ValidateEmailScene } from './validate-email/validate-email';
|
||||
import { ApplicationEditScene } from './application-edit/application-edit';
|
||||
import { ApplicationUserEditScene } from './application-user-edit/application-user-edit';
|
||||
import { applicationUserRightEditScene } from './application-user-right-edit/application-user-right-edit';
|
||||
|
||||
export {
|
||||
ErrorViewerScene,
|
||||
@ -30,4 +31,5 @@ export {
|
||||
ApplicationsScene,
|
||||
ApplicationEditScene,
|
||||
ApplicationUserEditScene,
|
||||
applicationUserRightEditScene,
|
||||
};
|
||||
|
@ -22,6 +22,7 @@ import {
|
||||
isOptionalOf,
|
||||
isString,
|
||||
} from 'common/utils';
|
||||
|
||||
export enum SettingType {
|
||||
TITLE = 'TITLE',
|
||||
GROUP = 'GROUP',
|
||||
|
@ -44,6 +44,14 @@ export interface ApplicationModel {
|
||||
notification: string;
|
||||
ttl: number;
|
||||
}
|
||||
export interface ApplicationRightModel {
|
||||
id: number;
|
||||
applicationId: number;
|
||||
title: string;
|
||||
description: string;
|
||||
key: string;
|
||||
type: string;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class ApplicationService {
|
||||
@ -51,6 +59,30 @@ export class ApplicationService {
|
||||
console.log('Start ApplicationService');
|
||||
}
|
||||
|
||||
getApplicationRights(applicationId: number): Promise<ApplicationRightModel[]> {
|
||||
const self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
this.http
|
||||
.requestJson({
|
||||
server: 'karso',
|
||||
endPoint: `application/${applicationId}/rights`,
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
})
|
||||
.then((response: ModelResponseHttp) => {
|
||||
// TODO: check type ...
|
||||
console.log(
|
||||
`retrieve Token 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)}`);
|
||||
});
|
||||
});
|
||||
}
|
||||
getApplicationSpecificToken(applicationId: string): Promise<SpecificTokenResponse> {
|
||||
const self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
|
Loading…
Reference in New Issue
Block a user