diff --git a/src/app/versionUpdate/controllers/VersionUpdateController.php b/src/app/versionUpdate/controllers/VersionUpdateController.php index 7c6354d4451dacd73871a6fc4e1f1870d4b2e7bf..e97ef348530fe8aa2b156207153b0d1acf41aa01 100755 --- a/src/app/versionUpdate/controllers/VersionUpdateController.php +++ b/src/app/versionUpdate/controllers/VersionUpdateController.php @@ -102,7 +102,7 @@ class VersionUpdateController public function update(Request $request, Response $response) { - if (!ServiceModel::hasService(['id' => 'admin_update_control', 'userId' => $GLOBALS['userId'], 'location' => 'apps', 'type' => 'admin'])) { + return $response->withStatus(400)->withJson(['errors' => 'Some files are modified. Can not update application', 'lang' => 'canNotUpdateApplication']); if (!ServiceModel::hasService(['id' => 'admin_update_control', 'userId' => $GLOBALS['userId'], 'location' => 'apps', 'type' => 'admin'])) { return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']); } diff --git a/src/frontend/app/administration/versionUpdate/versions-update-administration.component.ts b/src/frontend/app/administration/versionUpdate/versions-update-administration.component.ts index a918b16a668243d6824fb704d1691bc76b7b049f..5355e317fed30475f7561c80e7db131fe807ae42 100755 --- a/src/frontend/app/administration/versionUpdate/versions-update-administration.component.ts +++ b/src/frontend/app/administration/versionUpdate/versions-update-administration.component.ts @@ -4,10 +4,11 @@ import { HttpClient } from '@angular/common/http'; import { LANG } from '../../translate.component'; import { MatSidenav, MatDialog, MatDialogRef } from '@angular/material'; import { HeaderService } from '../../../service/header.service'; -import { tap, catchError, exhaustMap } from 'rxjs/operators'; +import { tap, catchError, exhaustMap, filter } from 'rxjs/operators'; import { NotificationService } from '../../notification.service'; import { of } from 'rxjs'; import { AlertComponent } from '../../../plugins/modal/alert.component'; +import { ConfirmComponent } from '../../../plugins/modal/confirm.component'; declare function $j(selector: any): any; @@ -66,16 +67,28 @@ export class VersionsUpdateAdministrationComponent implements OnInit { } updateVersionAccess() { - this.updateInprogress = true; - this.http.put('../../rest/versionsUpdate', {}).pipe( + this.dialogRef = this.dialog.open(ConfirmComponent, { data: { title: this.lang.confirm + ' ?', msg: this.lang.updateInfo } }); + this.dialogRef.afterClosed().pipe( + filter((data) => { + this.dialogRef = null; + + if (data === 'ok') { + this.updateInprogress = true; + return true; + } else { + this.updateInprogress = false; + return false; + } + }), + exhaustMap(() => this.http.put('../../rest/versionsUpdate', {})), tap(() => { - this.dialogRef = this.dialog.open(AlertComponent, { autoFocus: false, disableClose: true, data: { mode: '', title: this.lang.updateOk, msg: '' } }); + this.dialogRef = this.dialog.open(AlertComponent, { autoFocus: false, disableClose: true, data: { title: this.lang.updateOk, msg: '' } }); }), exhaustMap(() => this.dialogRef.afterClosed()), tap(() => { - window.location.reload(true); this.dialogRef = null; + window.location.reload(true); }), catchError(err => { this.notify.handleErrors(err); @@ -83,7 +96,9 @@ export class VersionsUpdateAdministrationComponent implements OnInit { }), tap(() => { this.updateInprogress = false; - }) + }), + ).subscribe(); + } } diff --git a/src/frontend/app/app-common.module.ts b/src/frontend/app/app-common.module.ts index abbd7aac0ff0651cfbe58f63237f94b5cee489d2..c4022c7843850c92a9382de6f1a858e6a9f30f36 100755 --- a/src/frontend/app/app-common.module.ts +++ b/src/frontend/app/app-common.module.ts @@ -45,6 +45,7 @@ import { BasketHomeComponent } from './basket/basket-home /*MODAL*/ import { AlertComponent } from '../plugins/modal/alert.component'; +import { ConfirmComponent } from '../plugins/modal/confirm.component'; export class MyHammerConfig extends HammerGestureConfig { @@ -84,7 +85,8 @@ export class MyHammerConfig extends HammerGestureConfig { SmdFabSpeedDialComponent, SmdFabSpeedDialTrigger, SmdFabSpeedDialActions, - AlertComponent + AlertComponent, + ConfirmComponent ], exports: [ CommonModule, @@ -125,7 +127,8 @@ export class MyHammerConfig extends HammerGestureConfig { ], entryComponents: [ IndexingGroupModalComponent, - AlertComponent + AlertComponent, + ConfirmComponent ], }) export class SharedModule { } diff --git a/src/frontend/lang/lang-en.ts b/src/frontend/lang/lang-en.ts index b919bf4393e4eb1bd11bda921980946d6fbbd34f..fa5a65858e49ac7a396fb686ff0c5a0090b5bc30 100755 --- a/src/frontend/lang/lang-en.ts +++ b/src/frontend/lang/lang-en.ts @@ -1028,4 +1028,5 @@ export const LANG_EN = { "ok" : "Ok", "updateOk" : "Update successfull !", "updateInProgress" : "Update in progress ...", + "updateInfo" : "This action cannot be undone! Do not make any actions during process.", }; diff --git a/src/frontend/lang/lang-fr.ts b/src/frontend/lang/lang-fr.ts index 92f2983c7ec2fd20c0ae2da6ac54ac6ebce548ef..61b121fe8b00217073c055424dacf02cfcd99a52 100755 --- a/src/frontend/lang/lang-fr.ts +++ b/src/frontend/lang/lang-fr.ts @@ -1061,4 +1061,5 @@ export const LANG_FR = { "ok" : "Ok", "updateOk" : "Mise à jour effectuée avec succès !", "updateInProgress" : "Mise à jour en cours ...", + "updateInfo" : "Cette action est irréversible! Il est préférable de ne pas faire d\'actions durant le processus.", }; \ No newline at end of file diff --git a/src/frontend/lang/lang-nl.ts b/src/frontend/lang/lang-nl.ts index f5e0973f0b4918ad5e129fc793f8cd29da136310..e7bafe6da858e6325313b923357e3846af34b623 100755 --- a/src/frontend/lang/lang-nl.ts +++ b/src/frontend/lang/lang-nl.ts @@ -1054,4 +1054,5 @@ export const LANG_NL = { "ok" : "Ok", //_TO_TRANSLATE "updateOk" : "Update successfull !", //_TO_TRANSLATE "updateInProgress" : "Update in progress ...", //_TO_TRANSLATE + "updateInfo" : "This action cannot be undone! Do not make any actions during process.", //_TO_TRANSLATE }; diff --git a/src/frontend/plugins/modal/alert.component.html b/src/frontend/plugins/modal/alert.component.html index 3811499db143700ff3124d074bc003e515232479..68eb0a473bd60eb3c08bb2ec34ec51b7e1111473 100644 --- a/src/frontend/plugins/modal/alert.component.html +++ b/src/frontend/plugins/modal/alert.component.html @@ -1,7 +1,7 @@ -<div class="modalContent {{data.mode}}"> +<div class="modalContent"> <h1 mat-dialog-title>{{data.title}}</h1> - <div mat-dialog-content [innerHTML]="data.msg"> - + <div mat-dialog-content> + <div class="alert-message alert-message-info" [innerHTML]="data.msg"></div> </div> <div mat-dialog-actions> <button class="actions" color="primary" mat-raised-button (click)="this.dialogRef.close();">{{lang.ok}}</button> diff --git a/src/frontend/plugins/modal/alert.component.scss b/src/frontend/plugins/modal/alert.component.scss index 40fc92c036994bd44b5264c2fc47d8e8f82427cd..109b81b69d1f34ff6b967b7dba7733e0a5404a7a 100644 --- a/src/frontend/plugins/modal/alert.component.scss +++ b/src/frontend/plugins/modal/alert.component.scss @@ -3,19 +3,24 @@ .modalContent { position: relative; } -.mat-dialog-content, .mat-dialog-title { - text-align:center !important; + +.mat-dialog-content, +.mat-dialog-title { color: #666; } + .mat-dialog-title { + text-align: center !important; padding-left: 10px; padding-right: 10px; color: white; } + .actions { width: 100%; margin: 10px; } + .close { position: absolute; top: -15px; @@ -24,10 +29,4 @@ height: 40px; font-size: 20px; color: #666; -} - -.warning { - .mat-dialog-title, .actions { - color : $warn; - } } \ No newline at end of file diff --git a/src/frontend/plugins/modal/alert.component.ts b/src/frontend/plugins/modal/alert.component.ts index b62e0f4f564c197d185414bbd32fd1654b5a796c..08f97c8cf9e4246066743c462d5af867f760729a 100644 --- a/src/frontend/plugins/modal/alert.component.ts +++ b/src/frontend/plugins/modal/alert.component.ts @@ -11,9 +11,6 @@ export class AlertComponent { lang: any = LANG; constructor(@Inject(MAT_DIALOG_DATA) public data: any, public dialogRef: MatDialogRef<AlertComponent>) { - if (this.data.mode === null) { - this.data.mode = ''; - } if (this.data.msg === null) { this.data.msg = ''; } diff --git a/src/frontend/plugins/modal/confirm.component.html b/src/frontend/plugins/modal/confirm.component.html new file mode 100644 index 0000000000000000000000000000000000000000..1365ec39a28b587a11f6294b1fb309d4fe2ab618 --- /dev/null +++ b/src/frontend/plugins/modal/confirm.component.html @@ -0,0 +1,10 @@ +<div class="modalContent"> + <h1 mat-dialog-title>{{data.title}}</h1> + <div mat-dialog-content> + <div class="alert-message alert-message-info" [innerHTML]="data.msg"></div> + </div> + <div mat-dialog-actions> + <button class="actions" color="primary" mat-raised-button (click)="this.dialogRef.close('ok');">{{lang.ok}}</button> + <button class="actions" color="" mat-raised-button (click)="this.dialogRef.close('');" cdkFocusInitial>{{lang.cancel}}</button> + </div> +</div> \ No newline at end of file diff --git a/src/frontend/plugins/modal/confirm.component.scss b/src/frontend/plugins/modal/confirm.component.scss new file mode 100644 index 0000000000000000000000000000000000000000..e73e3726d5a78b9db3b371390b5a3116735f6b92 --- /dev/null +++ b/src/frontend/plugins/modal/confirm.component.scss @@ -0,0 +1,32 @@ +@import '../../css/vars.scss'; + +.modalContent { + position: relative; + max-width: 350px; +} + +.mat-dialog-content, +.mat-dialog-title { + color: #666; +} + +.mat-dialog-title { + text-align: center !important; + padding-left: 10px; + padding-right: 10px; + color: white; +} + +.actions { + margin: 10px; +} + +.close { + position: absolute; + top: -15px; + right: -15px; + width: 40px; + height: 40px; + font-size: 20px; + color: #666; +} \ No newline at end of file diff --git a/src/frontend/plugins/modal/confirm.component.ts b/src/frontend/plugins/modal/confirm.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..f6d719c73f2c52e0bb046929cb8ae53c23037902 --- /dev/null +++ b/src/frontend/plugins/modal/confirm.component.ts @@ -0,0 +1,18 @@ +import { Component, Inject } from '@angular/core'; +import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material'; +import { LANG } from '../../app/translate.component'; + +@Component({ + templateUrl: 'confirm.component.html', + styleUrls: ['confirm.component.scss'] +}) +export class ConfirmComponent { + + lang: any = LANG; + + constructor(@Inject(MAT_DIALOG_DATA) public data: any, public dialogRef: MatDialogRef<ConfirmComponent>) { + if (this.data.msg === null) { + this.data.msg = ''; + } + } +}