mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-02-20 17:52:46 +00:00
Confirmation dialog for existing project added, error message handling added
This commit is contained in:
parent
668235936d
commit
cc401a584d
@ -50,6 +50,7 @@ import { LinkService } from "./services/link.service";
|
||||
|
||||
import { ProjectsComponent } from './components/projects/projects.component';
|
||||
import { ImportProjectDialogComponent } from './components/projects/import-project-dialog/import-project-dialog.component';
|
||||
import { ImportProjectConfirmationDialogComponent} from './components/projects/import-project-dialog/import-project-confirmation-dialog/import-project-confirmation-dialog.component';
|
||||
import { DefaultLayoutComponent } from './layouts/default-layout/default-layout.component';
|
||||
import { ProgressDialogComponent } from './common/progress-dialog/progress-dialog.component';
|
||||
import { AppComponent } from './app.component';
|
||||
@ -109,6 +110,7 @@ if (environment.production) {
|
||||
CreateSnapshotDialogComponent,
|
||||
ProjectsComponent,
|
||||
ImportProjectDialogComponent,
|
||||
ImportProjectConfirmationDialogComponent,
|
||||
DefaultLayoutComponent,
|
||||
ProgressDialogComponent,
|
||||
NodeContextMenuComponent,
|
||||
@ -191,7 +193,8 @@ if (environment.production) {
|
||||
CreateSnapshotDialogComponent,
|
||||
ProgressDialogComponent,
|
||||
ApplianceListDialogComponent,
|
||||
ImportProjectDialogComponent
|
||||
ImportProjectDialogComponent,
|
||||
ImportProjectConfirmationDialogComponent
|
||||
],
|
||||
bootstrap: [ AppComponent ]
|
||||
})
|
||||
|
@ -34,4 +34,3 @@ export class ApplianceComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,10 @@
|
||||
<span>
|
||||
{{confirmationMessage}}
|
||||
</span>
|
||||
<div class="buttons-bar" *ngIf="!isOpen">
|
||||
<button mat-button (click)="onNoClick()" color="accent">No</button>
|
||||
<button mat-button (click)="onYesClick()" tabindex="2" mat-raised-button color="primary">Yes</button>
|
||||
</div>
|
||||
<div class="buttons-bar" *ngIf="isOpen">
|
||||
<button mat-button (click)="onNoClick()" color="accent">Ok</button>
|
||||
</div>
|
@ -0,0 +1,40 @@
|
||||
import { Component, OnInit, Inject, ViewChild } from '@angular/core';
|
||||
import { MatStepper, MatDialogRef, MAT_DIALOG_DATA } from "@angular/material";
|
||||
import { FileUploader, ParsedResponseHeaders, FileItem } from 'ng2-file-upload';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms';
|
||||
import { Project } from '../../../../models/project';
|
||||
|
||||
@Component({
|
||||
selector: 'app-import-project-dialog',
|
||||
templateUrl: 'import-project-confirmation-dialog.component.html',
|
||||
styleUrls: ['import-project-confirmation-dialog.component.css']
|
||||
})
|
||||
export class ImportProjectConfirmationDialogComponent implements OnInit {
|
||||
private existingProject : Project;
|
||||
private confirmationMessage : string;
|
||||
private isOpen : boolean;
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<ImportProjectConfirmationDialogComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: any
|
||||
){
|
||||
this.existingProject = data['existingProject']
|
||||
}
|
||||
|
||||
ngOnInit(){
|
||||
if(this.existingProject.status === "opened"){
|
||||
this.confirmationMessage = `Project ${this.existingProject.name} is open. You can not overwrite it.`
|
||||
this.isOpen = true;
|
||||
} else {
|
||||
this.confirmationMessage = `Project ${this.existingProject.name} already exist, overwrite it?`
|
||||
}
|
||||
}
|
||||
|
||||
onNoClick() : void {
|
||||
this.dialogRef.close(false);
|
||||
}
|
||||
|
||||
onYesClick() : void {
|
||||
this.dialogRef.close(true);
|
||||
}
|
||||
}
|
4
src/app/models/serverResponse.ts
Normal file
4
src/app/models/serverResponse.ts
Normal file
@ -0,0 +1,4 @@
|
||||
export class ServerResponse {
|
||||
message: string;
|
||||
status: number;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user