mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-01-22 20:38:09 +00:00
Merge pull request #479 from GNS3/User-has-ability-to-delete-project-in-the-opened-project
User has ability to delete project in the opened project
This commit is contained in:
commit
3cc062f457
@ -46,6 +46,10 @@
|
||||
<mat-icon>developer_board</mat-icon>
|
||||
<span>Servers</span>
|
||||
</button>
|
||||
<button mat-menu-item (click)="deleteProject()">
|
||||
<mat-icon>delete</mat-icon>
|
||||
<span>Delete project</span>
|
||||
</button>
|
||||
</mat-menu>
|
||||
|
||||
<mat-toolbar-row>
|
||||
|
@ -2,7 +2,6 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ProjectMapComponent } from './project-map.component';
|
||||
import { MatIconModule, MatToolbarModule, MatMenuModule, MatCheckboxModule } from '@angular/material';
|
||||
import { Router } from '@angular/router';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { ServerService } from '../../services/server.service';
|
||||
import { ProjectService } from '../../services/project.service';
|
||||
@ -21,7 +20,7 @@ import { DrawingsDataSource } from '../../cartography/datasources/drawings-datas
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { ANGULAR_MAP_DECLARATIONS } from '../../cartography/angular-map.imports';
|
||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { MockedSettingsService } from '../../services/settings.service.spec';
|
||||
import { MockedServerService } from '../../services/server.service.spec';
|
||||
import { MockedProjectService } from '../../services/project.service.spec';
|
||||
@ -53,8 +52,8 @@ import { MapSettingService } from '../../services/mapsettings.service';
|
||||
import { ProjectMapMenuComponent } from './project-map-menu/project-map-menu.component';
|
||||
import { MockedToasterService } from '../../services/toaster.service.spec';
|
||||
import { ToasterService } from '../../services/toaster.service';
|
||||
import { MockedActivatedRoute } from '../snapshots/list-of-snapshots/list-of-snaphshots.component.spec';
|
||||
import { MapNodesDataSource, MapLinksDataSource, MapDrawingsDataSource, MapSymbolsDataSource } from '../../cartography/datasources/map-datasource';
|
||||
import { MockedRouter } from '../../common/progress/progress.component.spec';
|
||||
|
||||
export class MockedProgressService {
|
||||
public activate() {}
|
||||
@ -208,8 +207,8 @@ describe('ProjectMapComponent', () => {
|
||||
let nodesDataSource = new MockedNodesDataSource();
|
||||
let linksDataSource = new MockedLinksDataSource();
|
||||
let mockedToasterService = new MockedToasterService();
|
||||
let router = new MockedRouter();
|
||||
let nodeCreatedLabelStylesFixer;
|
||||
let mockedRouter = new MockedActivatedRoute;
|
||||
|
||||
beforeEach(async(() => {
|
||||
nodeCreatedLabelStylesFixer = {
|
||||
@ -254,11 +253,11 @@ describe('ProjectMapComponent', () => {
|
||||
{ provide: MapScaleService },
|
||||
{ provide: NodeCreatedLabelStylesFixer, useValue: nodeCreatedLabelStylesFixer},
|
||||
{ provide: ToasterService, useValue: mockedToasterService },
|
||||
{ provide: Router, useValue: mockedRouter },
|
||||
{ provide: MapNodesDataSource, useClass: MapNodesDataSource },
|
||||
{ provide: MapLinksDataSource, useClass: LinksDataSource },
|
||||
{ provide: MapDrawingsDataSource, useClass: MapDrawingsDataSource },
|
||||
{ provide: MapSymbolsDataSource, useClass: MapSymbolsDataSource },
|
||||
{ provide: Router, useValue: router}
|
||||
{ provide: MapSymbolsDataSource, useClass: MapSymbolsDataSource }
|
||||
],
|
||||
declarations: [ProjectMapComponent, ProjectMapMenuComponent, D3MapComponent, ...ANGULAR_MAP_DECLARATIONS],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
|
@ -117,11 +117,11 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
|
||||
private mapScaleService: MapScaleService,
|
||||
private nodeCreatedLabelStylesFixer: NodeCreatedLabelStylesFixer,
|
||||
private toasterService: ToasterService,
|
||||
private router: Router,
|
||||
private mapNodesDataSource: MapNodesDataSource,
|
||||
private mapLinksDataSource: MapLinksDataSource,
|
||||
private mapDrawingsDataSource: MapDrawingsDataSource,
|
||||
private mapSymbolsDataSource: MapSymbolsDataSource,
|
||||
private router: Router
|
||||
private mapSymbolsDataSource: MapSymbolsDataSource
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
@ -440,6 +440,12 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
|
||||
imageToUpload.src = window.URL.createObjectURL(file);
|
||||
}
|
||||
|
||||
public deleteProject() {
|
||||
this.projectService.delete(this.server, this.project.project_id).subscribe(() => {
|
||||
this.router.navigate(['/server', this.server.id, 'projects']);
|
||||
});
|
||||
}
|
||||
|
||||
public ngOnDestroy() {
|
||||
this.drawingsDataSource.clear();
|
||||
this.nodesDataSource.clear();
|
||||
|
Loading…
Reference in New Issue
Block a user