mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2024-12-23 23:02:22 +00:00
Implementation of style editor
This commit is contained in:
parent
669fcc0ddc
commit
e926a2039d
@ -85,6 +85,7 @@ import { InterfaceLabelDraggedComponent } from './components/drawings-listeners/
|
||||
import { ToolsService } from './services/tools.service';
|
||||
import { TextAddedComponent } from './components/drawings-listeners/text-added/text-added.component';
|
||||
import { DrawingAddedComponent } from './components/drawings-listeners/drawing-added/drawing-added.component';
|
||||
import { StyleEditorDialogComponent } from './components/project-map/drawings-editors/style-editor/style-editor.component';
|
||||
|
||||
|
||||
if (environment.production) {
|
||||
@ -137,7 +138,8 @@ if (environment.production) {
|
||||
NodeLabelDraggedComponent,
|
||||
DrawingDraggedComponent,
|
||||
LinkCreatedComponent,
|
||||
InterfaceLabelDraggedComponent
|
||||
InterfaceLabelDraggedComponent,
|
||||
StyleEditorDialogComponent
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
@ -192,7 +194,8 @@ if (environment.production) {
|
||||
TemplateListDialogComponent,
|
||||
AddBlankProjectDialogComponent,
|
||||
ImportProjectDialogComponent,
|
||||
ConfirmationDialogComponent
|
||||
ConfirmationDialogComponent,
|
||||
StyleEditorDialogComponent
|
||||
],
|
||||
bootstrap: [ AppComponent ]
|
||||
})
|
||||
|
@ -1,6 +1,5 @@
|
||||
<div #temporaryTextElement id="temporaryElement" class="temporaryElement" contenteditable="true"
|
||||
[style.top]=topPosition
|
||||
[style.left]=leftPosition
|
||||
[style.display]=display>
|
||||
[style.left]=leftPosition>
|
||||
{{innerText}}
|
||||
</div>
|
||||
|
@ -17,9 +17,9 @@ export class TextEditorComponent implements OnInit, OnDestroy {
|
||||
@ViewChild('temporaryTextElement') temporaryTextElement: ElementRef;
|
||||
@Input('svg') svg: SVGSVGElement;
|
||||
|
||||
private leftPosition: string = '0px';
|
||||
private topPosition: string = '0px';
|
||||
private innerText: string = '';
|
||||
leftPosition: string = '0px';
|
||||
topPosition: string = '0px';
|
||||
innerText: string = '';
|
||||
|
||||
private editingDrawingId: string;
|
||||
private editedElement: any;
|
||||
|
@ -19,6 +19,7 @@ export class MapDrawingToDrawingConverter implements Converter<MapDrawing, Drawi
|
||||
drawing.x = mapDrawing.x;
|
||||
drawing.y = mapDrawing.y;
|
||||
drawing.z = mapDrawing.z;
|
||||
drawing.element = mapDrawing.element;
|
||||
return drawing;
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,11 @@
|
||||
import { Component, OnInit, Input } from "@angular/core";
|
||||
import { Drawing } from '../../../../../cartography/models/drawing';
|
||||
import { Server } from '../../../../../models/server';
|
||||
import { DrawingsDataSource } from '../../../../../cartography/datasources/drawings-datasource';
|
||||
import { DrawingService } from '../../../../../services/drawing.service';
|
||||
import { MatDialog } from '@angular/material';
|
||||
import { Project } from '../../../../../models/project';
|
||||
import { TextElement } from '../../../../../cartography/models/drawings/text-element';
|
||||
import { StyleEditorDialogComponent } from '../../../drawings-editors/style-editor/style-editor.component';
|
||||
import { TextEditorDialogComponent } from '../../../drawings-editors/text-editor/text-editor.component';
|
||||
|
||||
|
||||
@Component({
|
||||
@ -11,14 +14,36 @@ import { DrawingService } from '../../../../../services/drawing.service';
|
||||
})
|
||||
export class EditStyleActionComponent implements OnInit {
|
||||
@Input() server: Server;
|
||||
@Input() project: Project;
|
||||
@Input() drawing: Drawing;
|
||||
|
||||
constructor(
|
||||
private drawingsDataSource: DrawingsDataSource,
|
||||
private drawingService: DrawingService
|
||||
private dialog: MatDialog
|
||||
) {}
|
||||
|
||||
ngOnInit() {}
|
||||
|
||||
editStyle(){}
|
||||
editStyle() {
|
||||
this.drawing.element instanceof TextElement ? this.openTextEditor() : this.openStyleEditor();
|
||||
}
|
||||
|
||||
openStyleEditor() {
|
||||
const dialogRef = this.dialog.open(StyleEditorDialogComponent, {
|
||||
width: '550px',
|
||||
});
|
||||
let instance = dialogRef.componentInstance;
|
||||
instance.server = this.server;
|
||||
instance.project = this.project;
|
||||
instance.drawing = this.drawing;
|
||||
}
|
||||
|
||||
openTextEditor() {
|
||||
const dialogRef = this.dialog.open(TextEditorDialogComponent, {
|
||||
width: '550px',
|
||||
});
|
||||
let instance = dialogRef.componentInstance;
|
||||
instance.server = this.server;
|
||||
instance.project = this.project;
|
||||
instance.drawing = this.drawing;
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
<mat-menu #contextMenu="matMenu" class="context-menu-items">
|
||||
<app-start-node-action *ngIf="hasNodeCapabilities" [server]="server" [node]="node"></app-start-node-action>
|
||||
<app-stop-node-action *ngIf="hasNodeCapabilities" [server]="server" [node]="node"></app-stop-node-action>
|
||||
<app-edit-style-action *ngIf="hasDrawingCapabilities" [server]="server" [drawing]="drawing"></app-edit-style-action>
|
||||
<app-edit-style-action *ngIf="hasDrawingCapabilities" [server]="server" [project]="project" [drawing]="drawing"></app-edit-style-action>
|
||||
<app-move-layer-up-action *ngIf="!projectService.isReadOnly(project)" [server]="server" [node]="node" [drawing]="drawing"></app-move-layer-up-action>
|
||||
<app-move-layer-down-action *ngIf="!projectService.isReadOnly(project)" [server]="server" [node]="node" [drawing]="drawing"></app-move-layer-down-action>
|
||||
</mat-menu>
|
||||
|
@ -0,0 +1,30 @@
|
||||
<h1 mat-dialog-title>Style editor</h1>
|
||||
<span *ngIf="drawing.element.fill" class="item">
|
||||
<div class="item-name">Fill color: </div>
|
||||
<input class="input-color" type='color' [(ngModel)]="drawing.element.fill"/>
|
||||
</span>
|
||||
<br/>
|
||||
<span class="item">
|
||||
<div class="item-name">Border color: </div>
|
||||
<input class="input-color" type='color' [(ngModel)]="drawing.element.stroke"/>
|
||||
</span>
|
||||
<br/>
|
||||
<span class="item">
|
||||
<div class="item-name">Border width: </div>
|
||||
<input class="item-value" matInput type="text" [(ngModel)]="drawing.element.stroke_width"/>
|
||||
</span>
|
||||
<br/>
|
||||
<span *ngIf="drawing.element.stroke_dasharray" class="item">
|
||||
<div class="item-name">Border style: </div>
|
||||
<input class="item-value" matInput type="text" [(ngModel)]="drawing.element.stroke_dasharray"/>
|
||||
</span>
|
||||
<br/>
|
||||
<span class="item">
|
||||
<div class="item-name">Rotation: </div>
|
||||
<input class="item-value" matInput type="text" [(ngModel)]="drawing.rotation"/>
|
||||
</span>
|
||||
<br/>
|
||||
<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,24 @@
|
||||
.item {
|
||||
display: flex;
|
||||
height: 25px;
|
||||
}
|
||||
|
||||
.item-name {
|
||||
width: 30%;
|
||||
}
|
||||
|
||||
.item-value {
|
||||
width: 70%;
|
||||
}
|
||||
|
||||
.input-color {
|
||||
padding: 0px;
|
||||
border-width: 0px;
|
||||
width: 70%;
|
||||
background-color: transparent;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
input:focus {
|
||||
outline: none;
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
import { Component, OnInit } from "@angular/core";
|
||||
import { Server } from '../../../../models/server';
|
||||
import { Project } from '../../../../models/project';
|
||||
import { Drawing } from '../../../../cartography/models/drawing';
|
||||
import { MatDialogRef, MatDialog } from '@angular/material';
|
||||
import { DrawingToMapDrawingConverter } from '../../../../cartography/converters/map/drawing-to-map-drawing-converter';
|
||||
import { MapDrawingToSvgConverter } from '../../../../cartography/converters/map/map-drawing-to-svg-converter';
|
||||
import { DrawingService } from '../../../../services/drawing.service';
|
||||
import { DrawingsDataSource } from '../../../../cartography/datasources/drawings-datasource';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-style-editor',
|
||||
templateUrl: './style-editor.component.html',
|
||||
styleUrls: ['./style-editor.component.scss']
|
||||
})
|
||||
export class StyleEditorDialogComponent implements OnInit {
|
||||
server: Server;
|
||||
project: Project;
|
||||
drawing: Drawing;
|
||||
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<StyleEditorDialogComponent>,
|
||||
private dialog: MatDialog,
|
||||
private drawingToMapDrawingConverter: DrawingToMapDrawingConverter,
|
||||
private mapDrawingToSvgConverter: MapDrawingToSvgConverter,
|
||||
private drawingService: DrawingService,
|
||||
private drawingsDataSource: DrawingsDataSource
|
||||
){}
|
||||
|
||||
ngOnInit() {
|
||||
console.log(this.drawing.element);
|
||||
}
|
||||
|
||||
onNoClick() {
|
||||
this.dialogRef.close();
|
||||
}
|
||||
|
||||
onYesClick() {
|
||||
let mapDrawing = this.drawingToMapDrawingConverter.convert(this.drawing);
|
||||
this.drawing.svg = this.mapDrawingToSvgConverter.convert(mapDrawing);
|
||||
this.drawingService
|
||||
.update(this.server, this.drawing).subscribe((serverDrawing: Drawing) => {
|
||||
this.drawingsDataSource.update(serverDrawing);
|
||||
this.dialogRef.close();
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
import { Component, OnInit } from "@angular/core";
|
||||
import { Project } from '../../../../models/project';
|
||||
import { Drawing } from '../../../../cartography/models/drawing';
|
||||
import { Server } from '../../../../models/server';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-text-editor',
|
||||
templateUrl: './text-editor.component.html',
|
||||
styleUrls: ['./text-editor.component.scss']
|
||||
})
|
||||
export class TextEditorDialogComponent implements OnInit {
|
||||
server: Server;
|
||||
project: Project;
|
||||
drawing: Drawing;
|
||||
|
||||
constructor(){}
|
||||
|
||||
ngOnInit(){}
|
||||
}
|
@ -313,10 +313,7 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
public showMenu() {
|
||||
setTimeout(() => {
|
||||
this.drawTools.visibility = true;
|
||||
},
|
||||
200);
|
||||
this.drawTools.visibility = true;
|
||||
}
|
||||
|
||||
public ngOnDestroy() {
|
||||
|
@ -52,6 +52,8 @@ export class DrawingService {
|
||||
update(server: Server, drawing: Drawing): Observable<Drawing> {
|
||||
return this.httpServer
|
||||
.put<Drawing>(server, `/projects/${drawing.project_id}/drawings/${drawing.drawing_id}`, {
|
||||
'svg': drawing.svg,
|
||||
'rotation': drawing.rotation,
|
||||
'x': Math.round(drawing.x),
|
||||
'y': Math.round(drawing.y),
|
||||
'z': drawing.z
|
||||
|
Loading…
Reference in New Issue
Block a user