mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-05-14 06:23:21 +00:00
Progress dialog
This commit is contained in:
parent
73db340afa
commit
070b84243e
@ -33,11 +33,13 @@ import {
|
|||||||
MatFormFieldModule,
|
MatFormFieldModule,
|
||||||
MatInputModule,
|
MatInputModule,
|
||||||
MatTableModule,
|
MatTableModule,
|
||||||
MatDialogModule
|
MatDialogModule, MatProgressBarModule
|
||||||
} from '@angular/material';
|
} from '@angular/material';
|
||||||
|
|
||||||
import {CdkTableModule} from "@angular/cdk/table";
|
import {CdkTableModule} from "@angular/cdk/table";
|
||||||
import {SnapshotService} from "./shared/services/snapshot.service";
|
import {SnapshotService} from "./shared/services/snapshot.service";
|
||||||
|
import { ProgressDialogComponent } from './shared/progress-dialog/progress-dialog.component';
|
||||||
|
import {ProgressDialogService} from "./shared/progress-dialog/progress-dialog.service";
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
@ -49,6 +51,7 @@ import {SnapshotService} from "./shared/services/snapshot.service";
|
|||||||
CreateSnapshotDialogComponent,
|
CreateSnapshotDialogComponent,
|
||||||
ProjectsComponent,
|
ProjectsComponent,
|
||||||
DefaultLayoutComponent,
|
DefaultLayoutComponent,
|
||||||
|
ProgressDialogComponent,
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
NgbModule.forRoot(),
|
NgbModule.forRoot(),
|
||||||
@ -66,6 +69,7 @@ import {SnapshotService} from "./shared/services/snapshot.service";
|
|||||||
MatInputModule,
|
MatInputModule,
|
||||||
MatTableModule,
|
MatTableModule,
|
||||||
MatDialogModule,
|
MatDialogModule,
|
||||||
|
MatProgressBarModule,
|
||||||
CdkTableModule
|
CdkTableModule
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
@ -76,11 +80,13 @@ import {SnapshotService} from "./shared/services/snapshot.service";
|
|||||||
ServerService,
|
ServerService,
|
||||||
IndexedDbService,
|
IndexedDbService,
|
||||||
HttpServer,
|
HttpServer,
|
||||||
SnapshotService
|
SnapshotService,
|
||||||
|
ProgressDialogService
|
||||||
],
|
],
|
||||||
entryComponents: [
|
entryComponents: [
|
||||||
AddServerDialogComponent,
|
AddServerDialogComponent,
|
||||||
CreateSnapshotDialogComponent
|
CreateSnapshotDialogComponent,
|
||||||
|
ProgressDialogComponent
|
||||||
],
|
],
|
||||||
bootstrap: [ AppComponent ]
|
bootstrap: [ AppComponent ]
|
||||||
})
|
})
|
||||||
|
@ -22,6 +22,8 @@ import { Server } from "../shared/models/server";
|
|||||||
import {MAT_DIALOG_DATA, MatDialog, MatDialogRef} from "@angular/material";
|
import {MAT_DIALOG_DATA, MatDialog, MatDialogRef} from "@angular/material";
|
||||||
import {SnapshotService} from "../shared/services/snapshot.service";
|
import {SnapshotService} from "../shared/services/snapshot.service";
|
||||||
import {Snapshot} from "../shared/models/snapshot";
|
import {Snapshot} from "../shared/models/snapshot";
|
||||||
|
import {ProgressDialogService} from "../shared/progress-dialog/progress-dialog.service";
|
||||||
|
import {ProgressDialogComponent} from "../shared/progress-dialog/progress-dialog.component";
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -47,7 +49,8 @@ export class ProjectMapComponent implements OnInit {
|
|||||||
private projectService: ProjectService,
|
private projectService: ProjectService,
|
||||||
private symbolService: SymbolService,
|
private symbolService: SymbolService,
|
||||||
private snapshotService: SnapshotService,
|
private snapshotService: SnapshotService,
|
||||||
private dialog: MatDialog) {
|
private dialog: MatDialog,
|
||||||
|
private progressDialogService: ProgressDialogService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@ -163,14 +166,21 @@ export class ProjectMapComponent implements OnInit {
|
|||||||
dialogRef.afterClosed().subscribe(snapshot => {
|
dialogRef.afterClosed().subscribe(snapshot => {
|
||||||
if (snapshot) {
|
if (snapshot) {
|
||||||
const creation = this.snapshotService.create(this.server, this.project.project_id, snapshot);
|
const creation = this.snapshotService.create(this.server, this.project.project_id, snapshot);
|
||||||
|
|
||||||
|
const progress = this.progressDialogService.open();
|
||||||
|
|
||||||
const subscription = creation.subscribe((created_snapshot: Snapshot) => {
|
const subscription = creation.subscribe((created_snapshot: Snapshot) => {
|
||||||
console.log(created_snapshot);
|
console.log(created_snapshot);
|
||||||
|
progress.close();
|
||||||
|
}, () => {
|
||||||
|
progress.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
// setTimeout(() => {
|
progress.afterClosed().subscribe((result) => {
|
||||||
// subscription.unsubscribe();
|
if (result === ProgressDialogComponent.CANCELLED) {
|
||||||
// console.log("Unsubscribed");
|
subscription.unsubscribe();
|
||||||
// }, 15000);
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
<h1 mat-dialog-title>Operation in progress</h1>
|
||||||
|
<div mat-dialog-content>
|
||||||
|
<mat-progress-bar
|
||||||
|
color="primary"
|
||||||
|
mode="determinate"
|
||||||
|
[value]="value">
|
||||||
|
</mat-progress-bar>
|
||||||
|
</div>
|
||||||
|
<div mat-dialog-actions>
|
||||||
|
<button mat-button (click)="onCancelClick()" tabindex="-1" color="accent">Cancel</button>
|
||||||
|
</div>
|
@ -0,0 +1,25 @@
|
|||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { ProgressDialogComponent } from './progress-dialog.component';
|
||||||
|
|
||||||
|
describe('ProgressDialogComponent', () => {
|
||||||
|
let component: ProgressDialogComponent;
|
||||||
|
let fixture: ComponentFixture<ProgressDialogComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ ProgressDialogComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(ProgressDialogComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
// it('should create', () => {
|
||||||
|
// expect(component).toBeTruthy();
|
||||||
|
// });
|
||||||
|
});
|
28
src/app/shared/progress-dialog/progress-dialog.component.ts
Normal file
28
src/app/shared/progress-dialog/progress-dialog.component.ts
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import {Component, Inject, OnInit} from '@angular/core';
|
||||||
|
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material";
|
||||||
|
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-progress-dialog',
|
||||||
|
templateUrl: './progress-dialog.component.html',
|
||||||
|
styleUrls: ['./progress-dialog.component.scss']
|
||||||
|
})
|
||||||
|
export class ProgressDialogComponent implements OnInit {
|
||||||
|
public static CANCELLED: 'canceled';
|
||||||
|
|
||||||
|
public value: 50;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
public dialogRef: MatDialogRef<ProgressDialogComponent>,
|
||||||
|
@Inject(MAT_DIALOG_DATA) public data: any) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
onCancelClick(): void {
|
||||||
|
this.dialogRef.close(ProgressDialogComponent.CANCELLED);
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
import { TestBed, inject } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { ProgressDialogService } from './progress-dialog.service';
|
||||||
|
|
||||||
|
describe('ProgressDialogService', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
providers: [ProgressDialogService]
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be created', inject([ProgressDialogService], (service: ProgressDialogService) => {
|
||||||
|
expect(service).toBeTruthy();
|
||||||
|
}));
|
||||||
|
});
|
16
src/app/shared/progress-dialog/progress-dialog.service.ts
Normal file
16
src/app/shared/progress-dialog/progress-dialog.service.ts
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import {MatDialog} from "@angular/material";
|
||||||
|
import {ProgressDialogComponent} from "./progress-dialog.component";
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class ProgressDialogService {
|
||||||
|
|
||||||
|
constructor(private dialog: MatDialog) { }
|
||||||
|
|
||||||
|
public open() {
|
||||||
|
const ref = this.dialog.open(ProgressDialogComponent, {
|
||||||
|
width: '250px',
|
||||||
|
});
|
||||||
|
return ref;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user