diff --git a/angular.json b/angular.json index ba76327052d4f7b1a1ada53b110a527f85ab0316..0c2c2f9da91db7289a1b55178cad403f1eb28b72 100755 --- a/angular.json +++ b/angular.json @@ -49,7 +49,6 @@ }, "./src/frontend/core/styles.scss", "./node_modules/@fortawesome/fontawesome-free/css/all.min.css", - "./node_modules/ng2-dnd/bundles/style.css", "./node_modules/angular2-draggable/css/resizable.min.css" ], "scripts": [ diff --git a/package.json b/package.json index 50eca9cf59e9073f580732a6cb62d2b97f19d9f6..44c7653087a7bcdf17b552f58f81186f4b6685e2 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,6 @@ "license": "GPL-3.0", "dependencies": { "core-js": "3.6.4", - "ng2-dnd": "^5.0.2", "tslib": "^2.0.0", "zone.js": "~0.10.2" }, @@ -45,8 +44,6 @@ "@biesbjerg/ngx-translate-extract": "^6.0.3", "@fortawesome/fontawesome-free": "^5.13.0", "@ionic/angular": "^5.0.0", - "ngx-drag-scroll": "^9.0.0-beta.4", - "ngx-extended-pdf-viewer": "^5.0.1", "@ngrx/store": "^9.0.0", "@ngrx/store-devtools": "^9.0.0", "@ngx-translate/core": "^12.1.2", @@ -63,8 +60,9 @@ "hammerjs": "^2.0.8", "jquery": "^3.4.1", "ngx-cookie-service": "^3.0.3", + "ngx-drag-scroll": "^9.0.0-beta.4", + "ngx-extended-pdf-viewer": "^5.0.1", "ngx-pipes": "^2.7.3", - "ngx-scroll-event": "^1.0.8", "node-sass": "^4.13.1", "npm-check-updates": "^4.1.0", "rxjs": "^6.5.4", diff --git a/src/app/user/controllers/SignatureController.php b/src/app/user/controllers/SignatureController.php index cc5e730d5b2088a312c7c6fba1fcfaaf96338631..e106a4dc7e78e90949ccfbcc8bb9cf0b29ee21c4 100755 --- a/src/app/user/controllers/SignatureController.php +++ b/src/app/user/controllers/SignatureController.php @@ -233,6 +233,13 @@ class SignatureController return $response->withStatus(204); } + public function getSignatureModes(Request $request, Response $response) + { + $modes = CoreConfigModel::getSignatureModes(); + + return $response->withJson($modes); + } + public static function isValidSignatureMode(array $args) { ValidatorModel::stringType($args, ['mode']); diff --git a/src/core/controllers/AuthenticationController.php b/src/core/controllers/AuthenticationController.php index e91f67f26bc5a2f79ebf9568de876ba29813324b..84c4b7c835c84f2eae31703987e850331d003089 100755 --- a/src/core/controllers/AuthenticationController.php +++ b/src/core/controllers/AuthenticationController.php @@ -42,13 +42,11 @@ class AuthenticationController $encryptKey = CoreConfigModel::getEncryptKey(); $path = CoreConfigModel::getConfigPath(); $hashedPath = md5($path); - $signatureModes = CoreConfigModel::getSignatureModes(); return $response->withJson([ 'connection' => $connection, 'changeKey' => $encryptKey == 'Security Key Maarch Parapheur #2008', - 'instanceId' => $hashedPath, - 'signatureModes' => $signatureModes + 'instanceId' => $hashedPath ]); } diff --git a/src/frontend/app/administration/group/group.component.html b/src/frontend/app/administration/group/group.component.html index 8c117353524ec57de49ce27712ab950475dda6ab..e41ead76e14e9f69022af8bbf2c2cf46e2ae2e13 100644 --- a/src/frontend/app/administration/group/group.component.html +++ b/src/frontend/app/administration/group/group.component.html @@ -30,7 +30,7 @@ <ion-item lines="none" *ngIf="!creationMode"> <ion-label color="secondary">{{'lang.linkedUsers' | translate}} :</ion-label> </ion-item> - <ion-card style="height: 400px;"> + <ion-card *ngIf="!creationMode" style="height: 400px;"> <ion-list> <ion-item style="display: flex;"> <!--<ion-checkbox slot="start"></ion-checkbox>--> diff --git a/src/frontend/app/administration/user/user.component.html b/src/frontend/app/administration/user/user.component.html index 811d74994b89bc08dbb4d6b21fc4d181843e5714..01eb0d3387d44fea0c4be856c7774e318d90abee 100644 --- a/src/frontend/app/administration/user/user.component.html +++ b/src/frontend/app/administration/user/user.component.html @@ -38,10 +38,12 @@ <ion-list-header> <ion-label color="secondary">{{'lang.signatureModes' | translate}}</ion-label> </ion-list-header> - <ion-item *ngFor="let signMode of signatureModes"> - <ion-label [style.color]="signMode.color">{{'lang.' + signMode.id | translate}}</ion-label> - <ion-checkbox slot="start" [checked]="user.signatureModes.indexOf(signMode.id) > -1" (ionChange)="toggleSignMode(signMode, $event.detail.checked)" [disabled]="signMode.id === 'stamp'"></ion-checkbox> - </ion-item> + <ng-container *ngFor="let signMode of authService.signatureRoles"> + <ion-item *ngIf="signMode.id !=='visa'"> + <ion-label [style.color]="signMode.color">{{'lang.' + signMode.id | translate}}</ion-label> + <ion-checkbox slot="start" [checked]="user.signatureModes.indexOf(signMode.id) > -1" (ionChange)="toggleSignMode(signMode, $event.detail.checked)" [disabled]="signMode.id === 'stamp'"></ion-checkbox> + </ion-item> + </ng-container> </ion-list> <ion-item style="align-items: center;" *ngIf="user.isRest"> <ion-button slot="end" fill="clear" color="primary" (click)="hideNewPassword = !hideNewPassword"> diff --git a/src/frontend/app/administration/user/user.component.ts b/src/frontend/app/administration/user/user.component.ts index 7663d91afe57d593711585e373bedfdea4c42d58..2f288d5d04a36e1f236020a4ac2909e7682e69b9 100644 --- a/src/frontend/app/administration/user/user.component.ts +++ b/src/frontend/app/administration/user/user.component.ts @@ -3,12 +3,11 @@ import { SignaturesContentService } from '../../service/signatures.service'; import { NotificationService } from '../../service/notification.service'; import { HttpClient, HttpHeaders } from '@angular/common/http'; import { MatDialog } from '@angular/material/dialog'; -import { map, finalize, catchError, tap } from 'rxjs/operators'; +import { map, finalize } from 'rxjs/operators'; import { ActivatedRoute, Router } from '@angular/router'; import { ConfirmComponent } from '../../plugins/confirm.component'; import { TranslateService } from '@ngx-translate/core'; import { AuthService } from '../../service/auth.service'; -import { of } from 'rxjs'; export interface User { @@ -42,7 +41,6 @@ export class UserComponent implements OnInit { isRest: false, signatureModes: ['stamp'] }; - signatureModes: any[] = []; userClone: User; title: string = ''; hideCurrentPassword: Boolean = true; @@ -85,7 +83,6 @@ export class UserComponent implements OnInit { } ngOnInit(): void { - this.getSignatureModes(); this.route.params.subscribe((params: any) => { if (params['id'] === undefined) { this.creationMode = true; @@ -122,18 +119,6 @@ export class UserComponent implements OnInit { }); } - getSignatureModes() { - this.http.get('../rest/signatureModes').pipe( - tap((data: any) => { - this.signatureModes = data; - }), - catchError((err: any) => { - this.notificationService.handleErrors(err); - return of(false); - }) - ).subscribe(); - } - canValidate() { if (this.user.isRest && this.passwordRest.newPassword !== '' && (this.handlePassword.error || this.passwordRest.passwordConfirmation !== this.passwordRest.newPassword)) { return false; diff --git a/src/frontend/app/app.module.ts b/src/frontend/app/app.module.ts index 76e8b22c63a415ded7ab31821b08e57fd3254370..be8877d2b4376909740e4a62ece41c862d7f48f7 100755 --- a/src/frontend/app/app.module.ts +++ b/src/frontend/app/app.module.ts @@ -15,9 +15,7 @@ import { TranslateHttpLoader } from '@ngx-translate/http-loader'; import { NgxExtendedPdfViewerModule } from 'ngx-extended-pdf-viewer'; import { DragScrollModule } from 'ngx-drag-scroll'; -import { ScrollEventModule } from 'ngx-scroll-event'; import { AngularDraggableModule } from 'angular2-draggable'; -import { DndModule } from 'ng2-dnd'; import { CookieService } from 'ngx-cookie-service'; import { NgPipesModule } from 'ngx-pipes'; import { LatinisePipe } from 'ngx-pipes'; @@ -148,9 +146,7 @@ import { SortPipe } from './plugins/sorting.pipe'; }), SignaturePadModule, NgxExtendedPdfViewerModule, - ScrollEventModule, DragScrollModule, - DndModule.forRoot(), NgPipesModule, AngularDraggableModule, AppMaterialModule, diff --git a/src/frontend/app/document/visa-workflow/models/visa-workflow-models.component.ts b/src/frontend/app/document/visa-workflow/models/visa-workflow-models.component.ts index 7c23daed0d693c7206395f9053eecb1b75eeb526..919071e483e3b5b0bea45837364733461a5dff3d 100644 --- a/src/frontend/app/document/visa-workflow/models/visa-workflow-models.component.ts +++ b/src/frontend/app/document/visa-workflow/models/visa-workflow-models.component.ts @@ -140,11 +140,7 @@ export class VisaWorkflowModelsComponent implements OnInit { 'role': item.mode === 'visa' ? 'visa' : item.signatureMode, 'processDate': null, 'current': false, - 'modes': [ - 'visa', - 'sign', - 'stamp', - ] + 'modes': ['visa'].concat(item.userSignatureModes) }; return obj; }); diff --git a/src/frontend/app/document/visa-workflow/visa-workflow.component.html b/src/frontend/app/document/visa-workflow/visa-workflow.component.html index 806201f191aea93c3eaa2fe224123b0783b89c59..6a259b7ada2f64abd6053a79835b785c22fc00a8 100644 --- a/src/frontend/app/document/visa-workflow/visa-workflow.component.html +++ b/src/frontend/app/document/visa-workflow/visa-workflow.component.html @@ -59,8 +59,11 @@ {{'lang.'+diffusion.mode+'ProcessInfo' | translate}} {{diffusion.processDate}} </p> - <h2 [title]="diffusion.userDisplay">{{diffusion.userDisplay}}</h2> + <p class="secondary" *ngIf="diffusion.current && diffusion.userId !== authService.user.id">{{'lang.substituteMsg' | translate}}</p> + <h2 [title]="diffusion.userDisplay" *ngIf="diffusion.userDisplay !== ''">{{diffusion.userDisplay}}</h2> + <h2 [title]="diffusion.userDisplay" class="danger" *ngIf="diffusion.userDisplay === ''">{{'lang.userDeleted' | translate}}</h2> </ion-label> + <ion-icon *ngIf="!editMode && diffusion.current" color="success" slot="end" name="caret-back-outline"></ion-icon> <ion-button *ngIf="editMode" fill="clear" slot="end" shape="round" color="danger" (click)="removeUser(i)"> <ion-icon slot="icon-only" name="trash-outline"></ion-icon> </ion-button> diff --git a/src/frontend/app/document/visa-workflow/visa-workflow.component.scss b/src/frontend/app/document/visa-workflow/visa-workflow.component.scss index d0ffa7ea274588cc4d4a2dcb801a735f649b32a6..df70b86fbf7a8ce630d533ba016043ad99cde3e1 100644 --- a/src/frontend/app/document/visa-workflow/visa-workflow.component.scss +++ b/src/frontend/app/document/visa-workflow/visa-workflow.component.scss @@ -44,7 +44,7 @@ ion-select { .processDate { display: flex; - justify-content: start; + justify-content: flex-start; font-size: 12px; text-align: right; color : var(--ion-color-success); diff --git a/src/frontend/app/document/visa-workflow/visa-workflow.component.ts b/src/frontend/app/document/visa-workflow/visa-workflow.component.ts index 279d35af167fdf8aab7834d68e1a6e8f8b829a3b..3755f009c6b5cb6b24598e547b64e9a2e2c09243 100644 --- a/src/frontend/app/document/visa-workflow/visa-workflow.component.ts +++ b/src/frontend/app/document/visa-workflow/visa-workflow.component.ts @@ -47,17 +47,7 @@ export class VisaWorkflowComponent implements OnInit { } doReorder(ev: CustomEvent<ItemReorderEventDetail>) { - // Before complete is called with the items they will remain in the - // order before the drag - console.log('Before complete', this.visaWorkflow); - - // Finish the reorder and position the item in the DOM based on - // where the gesture ended. Update the items variable to the - // new order of items this.visaWorkflow = ev.detail.complete(this.visaWorkflow); - - // After complete is called the items will be in the new order - console.log('After complete', this.visaWorkflow); } drop(event: CdkDragDrop<string[]>) { @@ -133,7 +123,6 @@ export class VisaWorkflowComponent implements OnInit { popover.onDidDismiss() .then((result: any) => { if (result.role !== 'backdrop') { - console.log(result.data); this.visaWorkflow = this.visaWorkflow.concat(result.data); this.visaWorkflow.forEach((element: any, index: number) => { this.getAvatarUser(index); diff --git a/src/frontend/app/service/auth.guard.ts b/src/frontend/app/service/auth.guard.ts index 744b8e64091636ab3f0cb2d2aba27a8eb3bb7253..8079339d39e558b19f2167773883dfc519aae579 100644 --- a/src/frontend/app/service/auth.guard.ts +++ b/src/frontend/app/service/auth.guard.ts @@ -47,6 +47,23 @@ export class AuthGuard implements CanActivate { this.translate.use(this.authService.user.preferences.lang); this.cookieService.set('maarchParapheurLang', this.authService.user.preferences.lang); + if (this.authService.signatureRoles.length === 0) { + this.http.get('../rest/signatureModes') + .subscribe((dataModes: any) => { + this.authService.signatureRoles = [{ + 'id': 'visa', + 'type': 'visa', + 'color': '#135F7F' + }]; + this.authService.signatureRoles = this.authService.signatureRoles.concat(dataModes.map((item: any) => { + return { + ...item, + type: 'sign' + }; + })); + }); + } + if (this.signaturesService.signaturesList.length === 0) { this.http.get('../rest/users/' + this.authService.user.id + '/signatures') .subscribe((dataSign: any) => { @@ -60,34 +77,6 @@ export class AuthGuard implements CanActivate { this.authService.user.picture = dataPic.picture; }); } - - this.authService.signatureRoles = [ - { - 'id': 'rgs_2stars', - 'type': 'sign', - 'color': '#FF0000' - }, - { - 'id': 'inca_card', - 'type': 'sign', - 'color': '#FFA500' - }, - { - 'id': 'eidas', - 'type': 'sign', - 'color': '#00FF00' - }, - { - 'id': 'stamp', - 'type': 'sign', - 'color': '#808080' - }, - { - 'id': 'visa', - 'type': 'visa', - 'color': '#135F7F' - } - ]; } return true; @@ -95,34 +84,6 @@ export class AuthGuard implements CanActivate { return this.http.get('../rest/authenticationInformations') .pipe( map((data: any) => { - // FOR TEST - this.authService.signatureRoles = [ - { - 'id': 'rgs_2stars', - 'type': 'sign', - 'color': '#FF0000' - }, - { - 'id': 'inca_card', - 'type': 'sign', - 'color': '#FFA500' - }, - { - 'id': 'eidas', - 'type': 'sign', - 'color': '#00FF00' - }, - { - 'id': 'stamp', - 'type': 'sign', - 'color': '#808080' - }, - { - 'id': 'visa', - 'type': 'visa', - 'color': '#135F7F' - } - ]; this.authService.authMode = data.connection; this.authService.changeKey = data.changeKey; this.localStorage.setAppSession(data.instanceId); @@ -134,6 +95,23 @@ export class AuthGuard implements CanActivate { this.translate.use(this.authService.user.preferences.lang); this.cookieService.set('maarchParapheurLang', this.authService.user.preferences.lang); + if (this.authService.signatureRoles.length === 0) { + this.http.get('../rest/signatureModes') + .subscribe((dataModes: any) => { + this.authService.signatureRoles = [{ + 'id': 'visa', + 'type': 'visa', + 'color': '#135F7F' + }]; + this.authService.signatureRoles = this.authService.signatureRoles.concat(dataModes.map((item: any) => { + return { + ...item, + type: 'sign' + }; + })); + }); + } + if (this.signaturesService.signaturesList.length === 0) { this.http.get('../rest/users/' + this.authService.user.id + '/signatures') .subscribe((dataSign: any) => { diff --git a/src/frontend/app/sidebar/sidebar.component.html b/src/frontend/app/sidebar/sidebar.component.html index d921121ec816e4741a7c01377928c881a75b686b..718b8a48266f4121bfc22774031cc6709a74839b 100755 --- a/src/frontend/app/sidebar/sidebar.component.html +++ b/src/frontend/app/sidebar/sidebar.component.html @@ -13,7 +13,7 @@ <ion-button (click)="authService.logout()"> <ion-icon slot="icon-only" name="power"></ion-icon> </ion-button> - <ion-button *ngIf="!isAdminRoute()" (click)="openAdmin()"> + <ion-button *ngIf="!isAdminRoute() && authService.user.administrativePrivileges.length > 0" (click)="openAdmin()"> <ion-icon slot="icon-only" name="build-outline"></ion-icon> </ion-button> <ion-button *ngIf="isAdminRoute()" (click)="openHome()">