diff --git a/src/frontend/app/installer/customization/customization.component.html b/src/frontend/app/installer/customization/customization.component.html index e9e6b8fde339bbbcd1a3a5550c19e138a456cfef..6edc4fef9a6e4f5709a80eb5d0f7a1e0673e42b0 100644 --- a/src/frontend/app/installer/customization/customization.component.html +++ b/src/frontend/app/installer/customization/customization.component.html @@ -47,11 +47,11 @@ </mat-card> <mat-card *ngFor="let background of backgroundList" (click)="stepFormGroup.controls['bodyLoginBackground'].setValue(background.url)" style="opacity: 0.3;" class="backgroundItem" - [class.selected]="background.filename === stepFormGroup.controls['bodyLoginBackground'].value" + [class.selected]="background.url === stepFormGroup.controls['bodyLoginBackground'].value" [style.background]="'url('+background.url+')'"> </mat-card> <mat-card style="opacity: 0.3;display: flex;align-items: center;justify-content: center;" class="backgroundItem" [class.readonly]="readonlyState" (click)="uploadFile.click()"> - <input type="file" name="files[]" #uploadFile (change)="uploadTrigger($event, 'bg')" accept="image/jpg" style="display: none;"> + <input type="file" name="files[]" #uploadFile (change)="uploadTrigger($event, 'bg')" accept="image/jpeg" style="display: none;"> <i class="fa fa-plus" style="font-size: 30px;color: #666;"></i> </mat-card> </div> diff --git a/src/frontend/app/installer/customization/customization.component.ts b/src/frontend/app/installer/customization/customization.component.ts index 4acf2ab292098a3968119316c6f547fe055295f3..d022e2d9b203fab47a093af88568ed274315c405 100644 --- a/src/frontend/app/installer/customization/customization.component.ts +++ b/src/frontend/app/installer/customization/customization.component.ts @@ -6,9 +6,10 @@ import { DomSanitizer } from '@angular/platform-browser'; import { NotificationService } from '../../../service/notification/notification.service'; import { environment } from '../../../environments/environment'; import { ScanPipe } from 'ngx-pipes'; -import { debounceTime, filter, tap } from 'rxjs/operators'; +import { debounceTime, filter, tap, catchError } from 'rxjs/operators'; import { HttpClient } from '@angular/common/http'; import { InstallerService } from '../installer.service'; +import { of } from 'rxjs/internal/observable/of'; declare var tinymce: any; @@ -53,18 +54,15 @@ export class CustomizationComponent implements OnInit { } ngOnInit(): void { + this.checkCustomExist(); this.stepFormGroup.controls['customId'].valueChanges.pipe( tap(() => { - if (this.stepFormGroup.controls['customId'].errors !== null) { - const errors = Object.keys(this.stepFormGroup.controls['customId']?.errors).length > 0 ? { ...this.stepFormGroup.controls['customId'].errors} : null; - this.stepFormGroup.controls['customId'].setErrors(errors); - } + this.stepFormGroup.controls['firstCtrl'].setValue(''); }), debounceTime(500), filter((value: any) => value.length > 2), tap(() => { - this.notify.error('TO DO WAIT BACK ../rest/installer/customExist'); - // this.checkCustomExist(); + this.checkCustomExist(); }), ).subscribe(); } @@ -86,17 +84,23 @@ export class CustomizationComponent implements OnInit { } checkCustomExist() { - this.http.get('../rest/installer/customExist', { params: { 'search': this.stepFormGroup.controls['customId'].value } }).pipe( + this.http.get('../rest/installer/custom', { observe: 'response', params: { 'customId': this.stepFormGroup.controls['customId'].value } }).pipe( tap((response: any) => { - if (!response) { - // this.stepFormGroup.controls['customId'].setErrors({ ...this.stepFormGroup.controls['customId'].errors, customExist: true }); - // this.stepFormGroup.controls['customId'].markAsTouched(); - } else { + if (this.stepFormGroup.controls['customId'].errors !== null) { const error = this.stepFormGroup.controls['customId'].errors; delete error.customExist; - // this.stepFormGroup.controls['customId'].setErrors(error); - // this.stepFormGroup.controls['customId'].markAsTouched(); + } else { + this.stepFormGroup.controls['firstCtrl'].setValue('success'); + } + }), + catchError((err: any) => { + if (err.error.errors === 'Custom already exists') { + this.stepFormGroup.controls['customId'].setErrors({ ...this.stepFormGroup.controls['customId'].errors, customExist: true }); + this.stepFormGroup.controls['customId'].markAsTouched(); + } else { + this.notify.handleSoftErrors(err); } + return of(false); }) ).subscribe(); } @@ -152,7 +156,7 @@ export class CustomizationComponent implements OnInit { body: { loginMessage: this.stepFormGroup.controls['loginMessage'].value, homeMessage: this.stepFormGroup.controls['homeMessage'].value, - bodyLogin: this.stepFormGroup.controls['bodyLoginBackground'].value, + bodyLoginBackground: this.stepFormGroup.controls['bodyLoginBackground'].value, logo: this.stepFormGroup.controls['uploadedLogo'].value, }, description: this.lang.stepCustomizationActionDesc, diff --git a/src/frontend/app/installer/install-action/install-action.component.html b/src/frontend/app/installer/install-action/install-action.component.html index 747448a795f87932f4d06fb81328922716348bbf..48d2ce44ad1160adaf61f8efd9e4f5e42ed2cce5 100644 --- a/src/frontend/app/installer/install-action/install-action.component.html +++ b/src/frontend/app/installer/install-action/install-action.component.html @@ -1,17 +1,20 @@ <div class="mat-dialog-content-container"> - <div mat-dialog-content> + <div mat-dialog-content [@.disabled]="disableAnimation"> <mat-accordion> <mat-expansion-panel hideToggle expanded> - <h2 class="text-center">Vous y êtes presque !</h2> - <button mat-raised-button type="button" color="primary" (click)="installStepAction.open();launchInstall()" style="font-size: 25px;padding: 20px;"> - <i class=" far fa-hdd"></i> {{lang.launchInstall}} - </button> + <div class="launch-action"> + <h2 class="text-center" color="primary">Vous y êtes presque !</h2> + <button mat-raised-button type="button" color="primary" + (click)="installStepAction.open();launchInstall()" style="font-size: 25px;padding: 20px;"> + <i class=" far fa-hdd"></i> {{lang.launchInstall}} + </button> + </div> </mat-expansion-panel> <mat-expansion-panel #installStepAction [expanded]="false"> <mat-list-item *ngFor="let step of steps"> <div mat-line class="step" [class.endStep]="step.state==='OK' || step.state==='KO'" - [class.currentStep]="step.state==='inProgress'"><span class="stepLabel">{{step.label}}</span> <ng-container - *ngIf="step.state==='inProgress'">...</ng-container> + [class.currentStep]="step.state==='inProgress'"><span class="stepLabel">{{step.label}}</span> + <ng-container *ngIf="step.state==='inProgress'">...</ng-container> <i *ngIf="step.state==='OK'" class="fa fa-check" style="color: green"></i> <i *ngIf="step.state==='KO'" class="fa fa-times" style="color: red"></i> <div *ngIf="step.msgErr!==''" class="alert-message alert-message-danger" role="alert" @@ -26,7 +29,8 @@ <ng-container *ngIf="isInstallComplete()"> <span class="divider-modal"></span> <div mat-dialog-actions class="actions"> - <button *ngIf="!isInstallError()" mat-raised-button mat-button color="primary" [mat-dialog-close]="">Accéder + <button *ngIf="!isInstallError()" mat-raised-button mat-button color="primary" + (click)="goToInstance()">Accéder à la nouvelle instance</button> <button *ngIf="isInstallError()" mat-raised-button mat-button [mat-dialog-close]="">{{lang.cancel}}</button> </div> diff --git a/src/frontend/app/installer/install-action/install-action.component.scss b/src/frontend/app/installer/install-action/install-action.component.scss index aebd4c82dba79ba06df90bba2f0eb141cd73aab6..2196381f78ba19e94f3150992ab2a95b146cf872 100644 --- a/src/frontend/app/installer/install-action/install-action.component.scss +++ b/src/frontend/app/installer/install-action/install-action.component.scss @@ -1,18 +1,20 @@ .step { opacity: 0.5; transition: all 0.2s; - .stepLabel{ + + .stepLabel { transition: all 0.2s; } } .currentStep { opacity: 1; - .stepLabel{ + + .stepLabel { font-size: 150%; transition: all 0.2s; } - + transition: all 0.2s; } @@ -24,7 +26,7 @@ box-shadow: none; } -.mat-expansion-panel-body { +.launch-action { display: flex; flex-direction: column; } \ No newline at end of file diff --git a/src/frontend/app/installer/install-action/install-action.component.ts b/src/frontend/app/installer/install-action/install-action.component.ts index 108e6b36a383a5c7711e62b99dc6209aea3cfda0..990ddbc2e6735fedd6a016813050c5bca6261bd8 100644 --- a/src/frontend/app/installer/install-action/install-action.component.ts +++ b/src/frontend/app/installer/install-action/install-action.component.ts @@ -6,6 +6,8 @@ import { tap } from 'rxjs/internal/operators/tap'; import { catchError } from 'rxjs/internal/operators/catchError'; import { of } from 'rxjs/internal/observable/of'; import { InstallerService } from '../installer.service'; +import { Router } from '@angular/router'; +import { NotificationService } from '../../../service/notification/notification.service'; @Component({ selector: 'app-install-action', @@ -20,12 +22,12 @@ export class InstallActionComponent implements OnInit, AfterViewInit { // Workaround for angular component issue #13870 disableAnimation = true; - constructor( @Inject(MAT_DIALOG_DATA) public data: any, public dialogRef: MatDialogRef<InstallActionComponent>, public http: HttpClient, - private installerService: InstallerService + private installerService: InstallerService, + private notify: NotificationService ) { } async ngOnInit(): Promise<void> { @@ -38,9 +40,13 @@ export class InstallActionComponent implements OnInit, AfterViewInit { } async launchInstall() { + let res: any; for (let index = 0; index < this.data.length; index++) { this.steps[index].state = 'inProgress'; - await this.doStep(index); + res = await this.doStep(index); + if (!res) { + break; + } } } @@ -77,7 +83,7 @@ export class InstallActionComponent implements OnInit, AfterViewInit { }), catchError((err: any) => { this.steps[index].state = 'KO'; - resolve(true); + resolve(false); this.steps[index].msgErr = err.error.errors; return of(false); }) @@ -91,6 +97,20 @@ export class InstallActionComponent implements OnInit, AfterViewInit { } isInstallError() { + console.log(this.steps); return this.steps.filter(step => step.state === 'KO').length > 0; } + + goToInstance() { + this.http.request('DELETE', '../rest/installer/lock', { body: { customId: this.customId } }).pipe( + tap((res: any) => { + window.location.href = res.url; + this.dialogRef.close('ok'); + }), + catchError((err: any) => { + this.notify.handleSoftErrors(err); + return of(false); + }) + ).subscribe(); + } } diff --git a/src/frontend/app/installer/welcome/welcome.component.ts b/src/frontend/app/installer/welcome/welcome.component.ts index 862b9ae90dec452a60781292e46676d146d3c543..1a26210ec5f737d066409815ce9f2493e81d62a8 100644 --- a/src/frontend/app/installer/welcome/welcome.component.ts +++ b/src/frontend/app/installer/welcome/welcome.component.ts @@ -16,6 +16,10 @@ export class WelcomeComponent implements OnInit { ngOnInit(): void { } + initStep() { + return false; + } + getInfoToInstall(): any[] { return []; /*return {