mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-06-22 08:30:09 +00:00
Dialog for editing project properties added
This commit is contained in:
@ -206,6 +206,7 @@ import { ImportConfigActionComponent } from './components/project-map/context-me
|
|||||||
import { ConsoleDeviceActionBrowserComponent } from './components/project-map/context-menu/actions/console-device-action-browser/console-device-action-browser.component';
|
import { ConsoleDeviceActionBrowserComponent } from './components/project-map/context-menu/actions/console-device-action-browser/console-device-action-browser.component';
|
||||||
import { ChangeSymbolDialogComponent } from './components/project-map/change-symbol-dialog/change-symbol-dialog.component';
|
import { ChangeSymbolDialogComponent } from './components/project-map/change-symbol-dialog/change-symbol-dialog.component';
|
||||||
import { ChangeSymbolActionComponent } from './components/project-map/context-menu/actions/change-symbol/change-symbol-action.component';
|
import { ChangeSymbolActionComponent } from './components/project-map/context-menu/actions/change-symbol/change-symbol-action.component';
|
||||||
|
import { EditProjectDialogComponent } from './components/projects/edit-project-dialog/edit-project-dialog.component';
|
||||||
|
|
||||||
if (environment.production) {
|
if (environment.production) {
|
||||||
Raven.config('https://b2b1cfd9b043491eb6b566fd8acee358@sentry.io/842726', {
|
Raven.config('https://b2b1cfd9b043491eb6b566fd8acee358@sentry.io/842726', {
|
||||||
@ -340,7 +341,8 @@ if (environment.production) {
|
|||||||
ImportConfigActionComponent,
|
ImportConfigActionComponent,
|
||||||
ConsoleDeviceActionBrowserComponent,
|
ConsoleDeviceActionBrowserComponent,
|
||||||
ChangeSymbolDialogComponent,
|
ChangeSymbolDialogComponent,
|
||||||
ChangeSymbolActionComponent
|
ChangeSymbolActionComponent,
|
||||||
|
EditProjectDialogComponent
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
@ -438,7 +440,8 @@ if (environment.production) {
|
|||||||
ConfigEditorDialogComponent,
|
ConfigEditorDialogComponent,
|
||||||
SaveProjectDialogComponent,
|
SaveProjectDialogComponent,
|
||||||
InfoDialogComponent,
|
InfoDialogComponent,
|
||||||
ChangeSymbolDialogComponent
|
ChangeSymbolDialogComponent,
|
||||||
|
EditProjectDialogComponent
|
||||||
],
|
],
|
||||||
bootstrap: [AppComponent]
|
bootstrap: [AppComponent]
|
||||||
})
|
})
|
||||||
|
@ -20,7 +20,7 @@ export class EditStyleActionComponent implements OnInit {
|
|||||||
|
|
||||||
editStyle() {
|
editStyle() {
|
||||||
const dialogRef = this.dialog.open(StyleEditorDialogComponent, {
|
const dialogRef = this.dialog.open(StyleEditorDialogComponent, {
|
||||||
width: '300px',
|
width: '800px',
|
||||||
autoFocus: false
|
autoFocus: false
|
||||||
});
|
});
|
||||||
let instance = dialogRef.componentInstance;
|
let instance = dialogRef.componentInstance;
|
||||||
|
@ -54,6 +54,10 @@
|
|||||||
<mat-icon>save</mat-icon>
|
<mat-icon>save</mat-icon>
|
||||||
<span>Save project as</span>
|
<span>Save project as</span>
|
||||||
</button>
|
</button>
|
||||||
|
<button mat-menu-item (click)="editProject()">
|
||||||
|
<mat-icon>edit</mat-icon>
|
||||||
|
<span>Edit project</span>
|
||||||
|
</button>
|
||||||
<button mat-menu-item (click)="exportProject()">
|
<button mat-menu-item (click)="exportProject()">
|
||||||
<mat-icon>call_made</mat-icon>
|
<mat-icon>call_made</mat-icon>
|
||||||
<span>Export portable project</span>
|
<span>Export portable project</span>
|
||||||
|
@ -58,6 +58,7 @@ import { AddBlankProjectDialogComponent } from '../projects/add-blank-project-di
|
|||||||
import { SaveProjectDialogComponent } from '../projects/save-project-dialog/save-project-dialog.component';
|
import { SaveProjectDialogComponent } from '../projects/save-project-dialog/save-project-dialog.component';
|
||||||
import { MapNodesDataSource, MapLinksDataSource, MapDrawingsDataSource, MapSymbolsDataSource, Indexed } from '../../cartography/datasources/map-datasource';
|
import { MapNodesDataSource, MapLinksDataSource, MapDrawingsDataSource, MapSymbolsDataSource, Indexed } from '../../cartography/datasources/map-datasource';
|
||||||
import { MapSettingsService } from '../../services/mapsettings.service';
|
import { MapSettingsService } from '../../services/mapsettings.service';
|
||||||
|
import { EditProjectDialogComponent } from '../projects/edit-project-dialog/edit-project-dialog.component';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -460,6 +461,16 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
|
|||||||
instance.project = this.project;
|
instance.project = this.project;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
editProject() {
|
||||||
|
const dialogRef = this.dialog.open(EditProjectDialogComponent, {
|
||||||
|
width: '500px',
|
||||||
|
autoFocus: false
|
||||||
|
});
|
||||||
|
let instance = dialogRef.componentInstance;
|
||||||
|
instance.server = this.server;
|
||||||
|
instance.project = this.project;
|
||||||
|
}
|
||||||
|
|
||||||
importProject() {
|
importProject() {
|
||||||
let uuid: string = '';
|
let uuid: string = '';
|
||||||
const dialogRef = this.dialog.open(ImportProjectDialogComponent, {
|
const dialogRef = this.dialog.open(ImportProjectDialogComponent, {
|
||||||
|
@ -23,6 +23,8 @@ export class MockedProjectService {
|
|||||||
auto_close: false,
|
auto_close: false,
|
||||||
auto_open: false,
|
auto_open: false,
|
||||||
auto_start: false,
|
auto_start: false,
|
||||||
|
drawing_grid_size: 10,
|
||||||
|
grid_size: 10,
|
||||||
filename: 'blank',
|
filename: 'blank',
|
||||||
name: 'blank',
|
name: 'blank',
|
||||||
path: '',
|
path: '',
|
||||||
|
@ -15,6 +15,8 @@ describe('ConfirmationDialogComponent', () => {
|
|||||||
auto_close: false,
|
auto_close: false,
|
||||||
auto_open: false,
|
auto_open: false,
|
||||||
auto_start: false,
|
auto_start: false,
|
||||||
|
drawing_grid_size: 10,
|
||||||
|
grid_size: 10,
|
||||||
filename: 'blank',
|
filename: 'blank',
|
||||||
name: 'blank',
|
name: 'blank',
|
||||||
path: '',
|
path: '',
|
||||||
|
@ -0,0 +1,40 @@
|
|||||||
|
<h1 mat-dialog-title>Edit project</h1>
|
||||||
|
|
||||||
|
<form [formGroup]="formGroup">
|
||||||
|
<mat-form-field class="form-field">
|
||||||
|
<input matInput formControlName="projectName" placeholder="Project name" type="text">
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field class="form-field">
|
||||||
|
<input matInput formControlName="width" placeholder="Scene width (px)" type="number">
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field class="form-field">
|
||||||
|
<input matInput formControlName="height" placeholder="Scene height (px)" type="number">
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field class="form-field">
|
||||||
|
<input matInput formControlName="nodeGridSize" placeholder="Node grid size" type="number">
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field class="form-field">
|
||||||
|
<input matInput formControlName="drawingGridSize" placeholder="Drawing grid size" type="number">
|
||||||
|
</mat-form-field>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<mat-checkbox [ngModelOptions]="{standalone: true}" [(ngModel)]="project.auto_open">
|
||||||
|
Open this project in the background when GNS3 server starts
|
||||||
|
</mat-checkbox>
|
||||||
|
|
||||||
|
<mat-checkbox [ngModelOptions]="{standalone: true}" [(ngModel)]="project.auto_start">
|
||||||
|
Start all nodes when this project is opened
|
||||||
|
</mat-checkbox>
|
||||||
|
|
||||||
|
<mat-checkbox [ngModelOptions]="{standalone: true}" [(ngModel)]="!project.auto_close">
|
||||||
|
Leave this project running in the background after closing
|
||||||
|
</mat-checkbox>
|
||||||
|
|
||||||
|
<div mat-dialog-actions>
|
||||||
|
<button mat-button (click)="onNoClick()" color="accent">Cancel</button>
|
||||||
|
<button mat-button (click)="onYesClick()" tabindex="2" mat-raised-button color="primary">Apply</button>
|
||||||
|
</div>
|
@ -0,0 +1,3 @@
|
|||||||
|
.form-field {
|
||||||
|
width: 100%;
|
||||||
|
}
|
@ -0,0 +1,64 @@
|
|||||||
|
import { Component, OnInit, Injectable } from '@angular/core';
|
||||||
|
import { MatDialogRef } from '@angular/material';
|
||||||
|
import { FormGroup, FormBuilder, FormControl, Validators } from '@angular/forms';
|
||||||
|
import { Server } from '../../../models/server';
|
||||||
|
import { Project } from '../../../models/project';
|
||||||
|
import { ToasterService } from '../../../services/toaster.service';
|
||||||
|
import { NonNegativeValidator } from '../../../validators/non-negative-validator';
|
||||||
|
import { ProjectService } from '../../../services/project.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-edit-project-dialog',
|
||||||
|
templateUrl: './edit-project-dialog.component.html',
|
||||||
|
styleUrls: ['./edit-project-dialog.component.scss']
|
||||||
|
})
|
||||||
|
export class EditProjectDialogComponent implements OnInit {
|
||||||
|
server: Server;
|
||||||
|
project: Project;
|
||||||
|
formGroup: FormGroup;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
public dialogRef: MatDialogRef<EditProjectDialogComponent>,
|
||||||
|
private formBuilder: FormBuilder,
|
||||||
|
private projectService: ProjectService,
|
||||||
|
private toasterService: ToasterService,
|
||||||
|
private nonNegativeValidator: NonNegativeValidator
|
||||||
|
) {
|
||||||
|
this.formGroup = this.formBuilder.group({
|
||||||
|
projectName: new FormControl('', [Validators.required]),
|
||||||
|
width: new FormControl('', [Validators.required, nonNegativeValidator.get]),
|
||||||
|
height: new FormControl('', [Validators.required, nonNegativeValidator.get]),
|
||||||
|
nodeGridSize: new FormControl('', [Validators.required, nonNegativeValidator.get]),
|
||||||
|
drawingGridSize: new FormControl('', [Validators.required, nonNegativeValidator.get])
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.formGroup.controls['projectName'].setValue(this.project.name);
|
||||||
|
this.formGroup.controls['width'].setValue(this.project.scene_width);
|
||||||
|
this.formGroup.controls['height'].setValue(this.project.scene_height);
|
||||||
|
this.formGroup.controls['nodeGridSize'].setValue(this.project.grid_size);
|
||||||
|
this.formGroup.controls['drawingGridSize'].setValue(this.project.drawing_grid_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
onNoClick() {
|
||||||
|
this.dialogRef.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
onYesClick() {
|
||||||
|
if (this.formGroup.valid) {
|
||||||
|
this.project.name = this.formGroup.get('projectName').value;
|
||||||
|
this.project.scene_width = this.formGroup.get('width').value;
|
||||||
|
this.project.scene_height = this.formGroup.get('height').value;
|
||||||
|
this.project.drawing_grid_size = this.formGroup.get('drawingGridSize').value;
|
||||||
|
this.project.grid_size = this.formGroup.get('nodeGridSize').value;
|
||||||
|
|
||||||
|
this.projectService.update(this.server, this.project).subscribe((project: Project) => {
|
||||||
|
this.toasterService.success(`Project ${project.name} updated.`);
|
||||||
|
this.onNoClick();
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
this.toasterService.error(`Fill all required fields with correct values.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -28,6 +28,8 @@ export class MockedProjectService {
|
|||||||
auto_close: false,
|
auto_close: false,
|
||||||
auto_open: false,
|
auto_open: false,
|
||||||
auto_start: false,
|
auto_start: false,
|
||||||
|
drawing_grid_size: 10,
|
||||||
|
grid_size: 10,
|
||||||
filename: 'blank',
|
filename: 'blank',
|
||||||
name: 'blank',
|
name: 'blank',
|
||||||
path: '',
|
path: '',
|
||||||
|
@ -2,7 +2,9 @@ export class Project {
|
|||||||
auto_close: boolean;
|
auto_close: boolean;
|
||||||
auto_open: boolean;
|
auto_open: boolean;
|
||||||
auto_start: boolean;
|
auto_start: boolean;
|
||||||
|
drawing_grid_size: number;
|
||||||
filename: string;
|
filename: string;
|
||||||
|
grid_size: number;
|
||||||
name: string;
|
name: string;
|
||||||
path: string;
|
path: string;
|
||||||
project_id: string;
|
project_id: string;
|
||||||
|
@ -45,6 +45,19 @@ export class ProjectService {
|
|||||||
return this.httpServer.post<Project>(server, `/projects`, { name: project_name, project_id: project_id });
|
return this.httpServer.post<Project>(server, `/projects`, { name: project_name, project_id: project_id });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
update(server: Server, project: Project) : Observable<Project> {
|
||||||
|
return this.httpServer.put<Project>(server, `/projects/${project.project_id}`, {
|
||||||
|
auto_close: project.auto_close,
|
||||||
|
auto_open: project.auto_open,
|
||||||
|
auto_start: project.auto_start,
|
||||||
|
drawing_grid_size: project.drawing_grid_size,
|
||||||
|
grid_size: project.grid_size,
|
||||||
|
name: project.name,
|
||||||
|
scene_width: project.scene_width,
|
||||||
|
scene_height: project.scene_height
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
delete(server: Server, project_id: string): Observable<any> {
|
delete(server: Server, project_id: string): Observable<any> {
|
||||||
return this.httpServer.delete(server, `/projects/${project_id}`);
|
return this.httpServer.delete(server, `/projects/${project_id}`);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user