mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-01-19 11:16:41 +00:00
Dialog for editing text created
This commit is contained in:
parent
e926a2039d
commit
e30e3893c6
@ -86,6 +86,8 @@ import { ToolsService } from './services/tools.service';
|
|||||||
import { TextAddedComponent } from './components/drawings-listeners/text-added/text-added.component';
|
import { TextAddedComponent } from './components/drawings-listeners/text-added/text-added.component';
|
||||||
import { DrawingAddedComponent } from './components/drawings-listeners/drawing-added/drawing-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';
|
import { StyleEditorDialogComponent } from './components/project-map/drawings-editors/style-editor/style-editor.component';
|
||||||
|
import { EditTextActionComponent } from './components/project-map/context-menu/actions/edit-text-action/edit-text-action.component';
|
||||||
|
import { TextEditorDialogComponent } from './components/project-map/drawings-editors/text-editor/text-editor.component';
|
||||||
|
|
||||||
|
|
||||||
if (environment.production) {
|
if (environment.production) {
|
||||||
@ -123,6 +125,7 @@ if (environment.production) {
|
|||||||
MoveLayerDownActionComponent,
|
MoveLayerDownActionComponent,
|
||||||
MoveLayerUpActionComponent,
|
MoveLayerUpActionComponent,
|
||||||
EditStyleActionComponent,
|
EditStyleActionComponent,
|
||||||
|
EditTextActionComponent,
|
||||||
ProjectMapShortcutsComponent,
|
ProjectMapShortcutsComponent,
|
||||||
SettingsComponent,
|
SettingsComponent,
|
||||||
LocalServerComponent,
|
LocalServerComponent,
|
||||||
@ -139,7 +142,8 @@ if (environment.production) {
|
|||||||
DrawingDraggedComponent,
|
DrawingDraggedComponent,
|
||||||
LinkCreatedComponent,
|
LinkCreatedComponent,
|
||||||
InterfaceLabelDraggedComponent,
|
InterfaceLabelDraggedComponent,
|
||||||
StyleEditorDialogComponent
|
StyleEditorDialogComponent,
|
||||||
|
TextEditorDialogComponent
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
@ -195,7 +199,8 @@ if (environment.production) {
|
|||||||
AddBlankProjectDialogComponent,
|
AddBlankProjectDialogComponent,
|
||||||
ImportProjectDialogComponent,
|
ImportProjectDialogComponent,
|
||||||
ConfirmationDialogComponent,
|
ConfirmationDialogComponent,
|
||||||
StyleEditorDialogComponent
|
StyleEditorDialogComponent,
|
||||||
|
TextEditorDialogComponent
|
||||||
],
|
],
|
||||||
bootstrap: [ AppComponent ]
|
bootstrap: [ AppComponent ]
|
||||||
})
|
})
|
||||||
|
@ -15,6 +15,7 @@ export class MapDrawingToSvgConverter implements Converter<MapDrawing, string> {
|
|||||||
|
|
||||||
convert(mapDrawing: MapDrawing) {
|
convert(mapDrawing: MapDrawing) {
|
||||||
let elem = ``;
|
let elem = ``;
|
||||||
|
console.log("!!! ", mapDrawing.element);
|
||||||
|
|
||||||
if (mapDrawing.element instanceof RectElement) {
|
if (mapDrawing.element instanceof RectElement) {
|
||||||
elem = `<rect fill=\"${mapDrawing.element.fill}\" fill-opacity=\"${mapDrawing.element.fill_opacity}\" height=\"${mapDrawing.element.height}\" width=\"${mapDrawing.element.width}\" stroke=\"${mapDrawing.element.stroke}\" stroke-width=\"${mapDrawing.element.stroke_width}\" />`;
|
elem = `<rect fill=\"${mapDrawing.element.fill}\" fill-opacity=\"${mapDrawing.element.fill_opacity}\" height=\"${mapDrawing.element.height}\" width=\"${mapDrawing.element.width}\" stroke=\"${mapDrawing.element.stroke}\" stroke-width=\"${mapDrawing.element.stroke_width}\" />`;
|
||||||
|
@ -3,9 +3,7 @@ import { Drawing } from '../../../../../cartography/models/drawing';
|
|||||||
import { Server } from '../../../../../models/server';
|
import { Server } from '../../../../../models/server';
|
||||||
import { MatDialog } from '@angular/material';
|
import { MatDialog } from '@angular/material';
|
||||||
import { Project } from '../../../../../models/project';
|
import { Project } from '../../../../../models/project';
|
||||||
import { TextElement } from '../../../../../cartography/models/drawings/text-element';
|
|
||||||
import { StyleEditorDialogComponent } from '../../../drawings-editors/style-editor/style-editor.component';
|
import { StyleEditorDialogComponent } from '../../../drawings-editors/style-editor/style-editor.component';
|
||||||
import { TextEditorDialogComponent } from '../../../drawings-editors/text-editor/text-editor.component';
|
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -24,10 +22,6 @@ export class EditStyleActionComponent implements OnInit {
|
|||||||
ngOnInit() {}
|
ngOnInit() {}
|
||||||
|
|
||||||
editStyle() {
|
editStyle() {
|
||||||
this.drawing.element instanceof TextElement ? this.openTextEditor() : this.openStyleEditor();
|
|
||||||
}
|
|
||||||
|
|
||||||
openStyleEditor() {
|
|
||||||
const dialogRef = this.dialog.open(StyleEditorDialogComponent, {
|
const dialogRef = this.dialog.open(StyleEditorDialogComponent, {
|
||||||
width: '550px',
|
width: '550px',
|
||||||
});
|
});
|
||||||
@ -36,14 +30,4 @@ export class EditStyleActionComponent implements OnInit {
|
|||||||
instance.project = this.project;
|
instance.project = this.project;
|
||||||
instance.drawing = this.drawing;
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
<button mat-menu-item (click)="editText()">
|
||||||
|
<mat-icon>text_format</mat-icon>
|
||||||
|
<span>Edit text</span>
|
||||||
|
</button>
|
@ -0,0 +1,33 @@
|
|||||||
|
import { Component, OnInit, Input } from '@angular/core';
|
||||||
|
import { Server } from '../../../../../models/server';
|
||||||
|
import { Project } from '../../../../../models/project';
|
||||||
|
import { Drawing } from '../../../../../cartography/models/drawing';
|
||||||
|
import { MatDialog } from '@angular/material';
|
||||||
|
import { TextEditorDialogComponent } from '../../../drawings-editors/text-editor/text-editor.component';
|
||||||
|
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-edit-text-action',
|
||||||
|
templateUrl: './edit-text-action.component.html'
|
||||||
|
})
|
||||||
|
export class EditTextActionComponent implements OnInit {
|
||||||
|
@Input() server: Server;
|
||||||
|
@Input() project: Project;
|
||||||
|
@Input() drawing: Drawing;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private dialog: MatDialog
|
||||||
|
) {}
|
||||||
|
|
||||||
|
ngOnInit() {}
|
||||||
|
|
||||||
|
editText() {
|
||||||
|
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,8 @@
|
|||||||
<mat-menu #contextMenu="matMenu" class="context-menu-items">
|
<mat-menu #contextMenu="matMenu" class="context-menu-items">
|
||||||
<app-start-node-action *ngIf="hasNodeCapabilities" [server]="server" [node]="node"></app-start-node-action>
|
<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-stop-node-action *ngIf="hasNodeCapabilities" [server]="server" [node]="node"></app-stop-node-action>
|
||||||
<app-edit-style-action *ngIf="hasDrawingCapabilities" [server]="server" [project]="project" [drawing]="drawing"></app-edit-style-action>
|
<app-edit-style-action *ngIf="hasDrawingCapabilities && !isTextElement" [server]="server" [project]="project" [drawing]="drawing"></app-edit-style-action>
|
||||||
|
<app-edit-text-action *ngIf="hasDrawingCapabilities && isTextElement" [server]="server" [project]="project" [drawing]="drawing"></app-edit-text-action>
|
||||||
<app-move-layer-up-action *ngIf="!projectService.isReadOnly(project)" [server]="server" [node]="node" [drawing]="drawing"></app-move-layer-up-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>
|
<app-move-layer-down-action *ngIf="!projectService.isReadOnly(project)" [server]="server" [node]="node" [drawing]="drawing"></app-move-layer-down-action>
|
||||||
</mat-menu>
|
</mat-menu>
|
||||||
|
@ -6,6 +6,7 @@ import { Server } from "../../../models/server";
|
|||||||
import { Project } from "../../../models/project";
|
import { Project } from "../../../models/project";
|
||||||
import { ProjectService } from "../../../services/project.service";
|
import { ProjectService } from "../../../services/project.service";
|
||||||
import { Drawing } from '../../../cartography/models/drawing';
|
import { Drawing } from '../../../cartography/models/drawing';
|
||||||
|
import { TextElement } from '../../../cartography/models/drawings/text-element';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -25,6 +26,7 @@ export class ContextMenuComponent implements OnInit {
|
|||||||
drawing: Drawing;
|
drawing: Drawing;
|
||||||
private hasNodeCapabilities: boolean = false;
|
private hasNodeCapabilities: boolean = false;
|
||||||
private hasDrawingCapabilities: boolean = false;
|
private hasDrawingCapabilities: boolean = false;
|
||||||
|
private isTextElement: boolean = false;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private sanitizer: DomSanitizer,
|
private sanitizer: DomSanitizer,
|
||||||
@ -54,6 +56,7 @@ export class ContextMenuComponent implements OnInit {
|
|||||||
public openMenuForDrawing(drawing: Drawing, top: number, left: number) {
|
public openMenuForDrawing(drawing: Drawing, top: number, left: number) {
|
||||||
this.resetCapabilities();
|
this.resetCapabilities();
|
||||||
this.hasDrawingCapabilities = true;
|
this.hasDrawingCapabilities = true;
|
||||||
|
this.isTextElement = drawing.element instanceof TextElement;
|
||||||
|
|
||||||
this.drawing = drawing;
|
this.drawing = drawing;
|
||||||
this.setPosition(top, left);
|
this.setPosition(top, left);
|
||||||
@ -66,5 +69,6 @@ export class ContextMenuComponent implements OnInit {
|
|||||||
this.drawing = null;
|
this.drawing = null;
|
||||||
this.hasDrawingCapabilities = false;
|
this.hasDrawingCapabilities = false;
|
||||||
this.hasNodeCapabilities = false;
|
this.hasNodeCapabilities = false;
|
||||||
|
this.isTextElement = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
<br/>
|
<br/>
|
||||||
<span class="item">
|
<span class="item">
|
||||||
<div class="item-name">Rotation: </div>
|
<div class="item-name">Rotation: </div>
|
||||||
<input class="item-value" matInput type="text" [(ngModel)]="drawing.rotation"/>
|
<input class="item-value" matInput type="text" [(ngModel)]="rotation"/>
|
||||||
</span>
|
</span>
|
||||||
<br/>
|
<br/>
|
||||||
<div mat-dialog-actions>
|
<div mat-dialog-actions>
|
||||||
|
@ -2,7 +2,7 @@ import { Component, OnInit } from "@angular/core";
|
|||||||
import { Server } from '../../../../models/server';
|
import { Server } from '../../../../models/server';
|
||||||
import { Project } from '../../../../models/project';
|
import { Project } from '../../../../models/project';
|
||||||
import { Drawing } from '../../../../cartography/models/drawing';
|
import { Drawing } from '../../../../cartography/models/drawing';
|
||||||
import { MatDialogRef, MatDialog } from '@angular/material';
|
import { MatDialogRef } from '@angular/material';
|
||||||
import { DrawingToMapDrawingConverter } from '../../../../cartography/converters/map/drawing-to-map-drawing-converter';
|
import { DrawingToMapDrawingConverter } from '../../../../cartography/converters/map/drawing-to-map-drawing-converter';
|
||||||
import { MapDrawingToSvgConverter } from '../../../../cartography/converters/map/map-drawing-to-svg-converter';
|
import { MapDrawingToSvgConverter } from '../../../../cartography/converters/map/map-drawing-to-svg-converter';
|
||||||
import { DrawingService } from '../../../../services/drawing.service';
|
import { DrawingService } from '../../../../services/drawing.service';
|
||||||
@ -18,10 +18,10 @@ export class StyleEditorDialogComponent implements OnInit {
|
|||||||
server: Server;
|
server: Server;
|
||||||
project: Project;
|
project: Project;
|
||||||
drawing: Drawing;
|
drawing: Drawing;
|
||||||
|
rotation: string;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public dialogRef: MatDialogRef<StyleEditorDialogComponent>,
|
public dialogRef: MatDialogRef<StyleEditorDialogComponent>,
|
||||||
private dialog: MatDialog,
|
|
||||||
private drawingToMapDrawingConverter: DrawingToMapDrawingConverter,
|
private drawingToMapDrawingConverter: DrawingToMapDrawingConverter,
|
||||||
private mapDrawingToSvgConverter: MapDrawingToSvgConverter,
|
private mapDrawingToSvgConverter: MapDrawingToSvgConverter,
|
||||||
private drawingService: DrawingService,
|
private drawingService: DrawingService,
|
||||||
@ -29,7 +29,7 @@ export class StyleEditorDialogComponent implements OnInit {
|
|||||||
){}
|
){}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
console.log(this.drawing.element);
|
this.rotation = this.drawing.rotation.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
onNoClick() {
|
onNoClick() {
|
||||||
@ -37,8 +37,12 @@ export class StyleEditorDialogComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onYesClick() {
|
onYesClick() {
|
||||||
|
this.drawing.rotation = +this.rotation;
|
||||||
let mapDrawing = this.drawingToMapDrawingConverter.convert(this.drawing);
|
let mapDrawing = this.drawingToMapDrawingConverter.convert(this.drawing);
|
||||||
|
mapDrawing.element = this.drawing.element;
|
||||||
|
|
||||||
this.drawing.svg = this.mapDrawingToSvgConverter.convert(mapDrawing);
|
this.drawing.svg = this.mapDrawingToSvgConverter.convert(mapDrawing);
|
||||||
|
|
||||||
this.drawingService
|
this.drawingService
|
||||||
.update(this.server, this.drawing).subscribe((serverDrawing: Drawing) => {
|
.update(this.server, this.drawing).subscribe((serverDrawing: Drawing) => {
|
||||||
this.drawingsDataSource.update(serverDrawing);
|
this.drawingsDataSource.update(serverDrawing);
|
||||||
|
@ -0,0 +1,19 @@
|
|||||||
|
<h1 mat-dialog-title>Text editor</h1>
|
||||||
|
<span *ngIf="drawing.element.fill" class="item">
|
||||||
|
<div class="item-name">Fill color:</div>
|
||||||
|
<input class="input-color" type="color" (ngModelChange)="changeTextColor($event)" [(ngModel)]="drawing.element.fill"/>
|
||||||
|
</span>
|
||||||
|
<br/>
|
||||||
|
<span class="item">
|
||||||
|
<div class="item-name">Rotation:</div>
|
||||||
|
<input class="item-value" matInput type="text" [(ngModel)]="rotation"/>
|
||||||
|
</span>
|
||||||
|
<br/>
|
||||||
|
<span>
|
||||||
|
<textarea #textArea id="textArea" class="text" [(ngModel)]="drawing.element.text">
|
||||||
|
</textarea>
|
||||||
|
</span>
|
||||||
|
<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,29 @@
|
|||||||
|
.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;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text {
|
||||||
|
width: 100%;
|
||||||
|
height: 150px;
|
||||||
|
}
|
@ -1,7 +1,13 @@
|
|||||||
import { Component, OnInit } from "@angular/core";
|
import { Component, OnInit, ViewChild, ElementRef, Renderer2 } from "@angular/core";
|
||||||
import { Project } from '../../../../models/project';
|
import { Project } from '../../../../models/project';
|
||||||
import { Drawing } from '../../../../cartography/models/drawing';
|
import { Drawing } from '../../../../cartography/models/drawing';
|
||||||
import { Server } from '../../../../models/server';
|
import { Server } from '../../../../models/server';
|
||||||
|
import { MatDialogRef } 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';
|
||||||
|
import { TextElement } from '../../../../cartography/models/drawings/text-element';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -10,11 +16,51 @@ import { Server } from '../../../../models/server';
|
|||||||
styleUrls: ['./text-editor.component.scss']
|
styleUrls: ['./text-editor.component.scss']
|
||||||
})
|
})
|
||||||
export class TextEditorDialogComponent implements OnInit {
|
export class TextEditorDialogComponent implements OnInit {
|
||||||
|
@ViewChild('textArea') textArea : ElementRef;
|
||||||
|
|
||||||
server: Server;
|
server: Server;
|
||||||
project: Project;
|
project: Project;
|
||||||
drawing: Drawing;
|
drawing: Drawing;
|
||||||
|
rotation: string;
|
||||||
|
|
||||||
constructor(){}
|
constructor(
|
||||||
|
private dialogRef: MatDialogRef<TextEditorDialogComponent>,
|
||||||
|
private drawingToMapDrawingConverter: DrawingToMapDrawingConverter,
|
||||||
|
private mapDrawingToSvgConverter: MapDrawingToSvgConverter,
|
||||||
|
private drawingService: DrawingService,
|
||||||
|
private drawingsDataSource: DrawingsDataSource,
|
||||||
|
private renderer: Renderer2
|
||||||
|
){}
|
||||||
|
|
||||||
ngOnInit(){}
|
ngOnInit() {
|
||||||
|
this.rotation = this.drawing.rotation.toString();
|
||||||
|
|
||||||
|
let textElement = this.drawing.element as TextElement;
|
||||||
|
this.renderer.setStyle(this.textArea.nativeElement, 'color', textElement.fill);
|
||||||
|
this.renderer.setStyle(this.textArea.nativeElement, 'font-family', textElement.font_family);
|
||||||
|
this.renderer.setStyle(this.textArea.nativeElement, 'font-size', `${textElement.font_size}pt`);
|
||||||
|
this.renderer.setStyle(this.textArea.nativeElement, 'font-weight', textElement.font_weight);
|
||||||
|
}
|
||||||
|
|
||||||
|
onNoClick() {
|
||||||
|
this.dialogRef.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
onYesClick() {
|
||||||
|
this.drawing.rotation = +this.rotation;
|
||||||
|
let mapDrawing = this.drawingToMapDrawingConverter.convert(this.drawing);
|
||||||
|
mapDrawing.element = this.drawing.element;
|
||||||
|
|
||||||
|
this.drawing.svg = this.mapDrawingToSvgConverter.convert(mapDrawing);
|
||||||
|
|
||||||
|
this.drawingService
|
||||||
|
.update(this.server, this.drawing).subscribe((serverDrawing: Drawing) => {
|
||||||
|
this.drawingsDataSource.update(serverDrawing);
|
||||||
|
this.dialogRef.close();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
changeTextColor(changedColor) {
|
||||||
|
this.renderer.setStyle(this.textArea.nativeElement, 'color', changedColor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user