Initial implementaion - global variables

This commit is contained in:
Piotr Pekala
2019-10-25 00:43:13 -07:00
parent 6d81bd4a0b
commit 98f93901ec
4 changed files with 70 additions and 39 deletions

View File

@ -545,7 +545,7 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
editProject() { editProject() {
const dialogRef = this.dialog.open(EditProjectDialogComponent, { const dialogRef = this.dialog.open(EditProjectDialogComponent, {
width: '500px', width: '600px',
autoFocus: false autoFocus: false
}); });
let instance = dialogRef.componentInstance; let instance = dialogRef.componentInstance;

View File

@ -1,42 +1,60 @@
<h1 mat-dialog-title>Edit project</h1> <h1 mat-dialog-title>Edit project</h1>
<form [formGroup]="formGroup"> <div class="modal-form-container">
<mat-form-field class="form-field"> <mat-tab-group>
<input matInput formControlName="projectName" placeholder="Project name" type="text"> <mat-tab label="General">
</mat-form-field> <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"> <mat-form-field class="form-field">
<input matInput formControlName="width" placeholder="Scene width (px)" type="number"> <input matInput formControlName="width" placeholder="Scene width (px)" type="number">
</mat-form-field> </mat-form-field>
<mat-form-field class="form-field"> <mat-form-field class="form-field">
<input matInput formControlName="height" placeholder="Scene height (px)" type="number"> <input matInput formControlName="height" placeholder="Scene height (px)" type="number">
</mat-form-field> </mat-form-field>
<mat-form-field class="form-field"> <mat-form-field class="form-field">
<input matInput formControlName="nodeGridSize" placeholder="Node grid size" type="number"> <input matInput formControlName="nodeGridSize" placeholder="Node grid size" type="number">
</mat-form-field> </mat-form-field>
<mat-form-field class="form-field"> <mat-form-field class="form-field">
<input matInput formControlName="drawingGridSize" placeholder="Drawing grid size" type="number"> <input matInput formControlName="drawingGridSize" placeholder="Drawing grid size" type="number">
</mat-form-field> </mat-form-field>
</form> </form>
<mat-checkbox [ngModelOptions]="{standalone: true}" [(ngModel)]="project.auto_open"> <mat-checkbox [ngModelOptions]="{standalone: true}" [(ngModel)]="project.auto_open">
Open this project in the background when GNS3 server starts Open this project in the background when GNS3 server starts
</mat-checkbox> </mat-checkbox>
<mat-checkbox [ngModelOptions]="{standalone: true}" [(ngModel)]="project.auto_start"> <mat-checkbox [ngModelOptions]="{standalone: true}" [(ngModel)]="project.auto_start">
Start all nodes when this project is opened Start all nodes when this project is opened
</mat-checkbox> </mat-checkbox>
<mat-checkbox [ngModelOptions]="{standalone: true}" [(ngModel)]="!project.auto_close"> <mat-checkbox [ngModelOptions]="{standalone: true}" [(ngModel)]="!project.auto_close">
Leave this project running in the background after closing Leave this project running in the background after closing
</mat-checkbox> </mat-checkbox>
<mat-checkbox [ngModelOptions]="{standalone: true}" [(ngModel)]="project.show_interface_labels"> <mat-checkbox [ngModelOptions]="{standalone: true}" [(ngModel)]="project.show_interface_labels">
Show interface labels at start Show interface labels at start
</mat-checkbox> </mat-checkbox>
</mat-tab>
<mat-tab label="Global variables">
<form [formGroup]="variableformGroup">
<mat-form-field class="form-field">
<input matInput formControlName="name" placeholder="Name" type="text">
</mat-form-field>
<mat-form-field class="form-field">
<input matInput formControlName="value" placeholder="Value" type="number">
</mat-form-field>
</form>
</mat-tab>
</mat-tab-group>
</div>
<div mat-dialog-actions> <div mat-dialog-actions>
<button mat-button (click)="onNoClick()" color="accent">Cancel</button> <button mat-button (click)="onNoClick()" color="accent">Cancel</button>

View File

@ -2,7 +2,7 @@ import { Component, OnInit, Injectable } from '@angular/core';
import { MatDialogRef } from '@angular/material'; import { MatDialogRef } from '@angular/material';
import { FormGroup, FormBuilder, FormControl, Validators } from '@angular/forms'; import { FormGroup, FormBuilder, FormControl, Validators } from '@angular/forms';
import { Server } from '../../../models/server'; import { Server } from '../../../models/server';
import { Project } from '../../../models/project'; import { Project, ProjectVariable } from '../../../models/project';
import { ToasterService } from '../../../services/toaster.service'; import { ToasterService } from '../../../services/toaster.service';
import { NonNegativeValidator } from '../../../validators/non-negative-validator'; import { NonNegativeValidator } from '../../../validators/non-negative-validator';
import { ProjectService } from '../../../services/project.service'; import { ProjectService } from '../../../services/project.service';
@ -16,6 +16,8 @@ export class EditProjectDialogComponent implements OnInit {
server: Server; server: Server;
project: Project; project: Project;
formGroup: FormGroup; formGroup: FormGroup;
variableFormGroup: FormGroup;
projectVariables: ProjectVariable[];
constructor( constructor(
public dialogRef: MatDialogRef<EditProjectDialogComponent>, public dialogRef: MatDialogRef<EditProjectDialogComponent>,
@ -31,6 +33,11 @@ export class EditProjectDialogComponent implements OnInit {
nodeGridSize: new FormControl('', [Validators.required, nonNegativeValidator.get]), nodeGridSize: new FormControl('', [Validators.required, nonNegativeValidator.get]),
drawingGridSize: new FormControl('', [Validators.required, nonNegativeValidator.get]) drawingGridSize: new FormControl('', [Validators.required, nonNegativeValidator.get])
}); });
this.variableFormGroup = this.formBuilder.group({
name: new FormControl('', [Validators.required]),
value: new FormControl('', [Validators.required])
});
} }
ngOnInit() { ngOnInit() {

View File

@ -16,4 +16,10 @@ export class Project {
show_layers: boolean; show_layers: boolean;
show_grid: boolean; show_grid: boolean;
snap_to_grid: boolean; snap_to_grid: boolean;
variables: ProjectVariable[];
}
export class ProjectVariable {
name: string;
value: string;
} }