From e926a2039dc921a8f6f696274ecb32ca21797ba4 Mon Sep 17 00:00:00 2001 From: Piotr Pekala Date: Fri, 11 Jan 2019 06:00:53 -0800 Subject: [PATCH] Implementation of style editor --- src/app/app.module.ts | 7 ++- .../text-editor/text-editor.component.html | 3 +- .../text-editor/text-editor.component.ts | 6 +-- .../map/map-drawing-to-drawing-converter.ts | 1 + .../edit-style-action.component.ts | 35 ++++++++++++-- .../context-menu/context-menu.component.html | 2 +- .../style-editor/style-editor.component.html | 30 ++++++++++++ .../style-editor/style-editor.component.scss | 24 ++++++++++ .../style-editor.component.spec.ts | 0 .../style-editor/style-editor.component.ts | 48 +++++++++++++++++++ .../text-editor/text-editor.component.html | 0 .../text-editor/text-editor.component.scss | 0 .../text-editor/text-editor.component.spec.ts | 0 .../text-editor/text-editor.component.ts | 20 ++++++++ .../project-map/project-map.component.ts | 5 +- src/app/services/drawing.service.ts | 2 + 16 files changed, 166 insertions(+), 17 deletions(-) create mode 100644 src/app/components/project-map/drawings-editors/style-editor/style-editor.component.html create mode 100644 src/app/components/project-map/drawings-editors/style-editor/style-editor.component.scss create mode 100644 src/app/components/project-map/drawings-editors/style-editor/style-editor.component.spec.ts create mode 100644 src/app/components/project-map/drawings-editors/style-editor/style-editor.component.ts create mode 100644 src/app/components/project-map/drawings-editors/text-editor/text-editor.component.html create mode 100644 src/app/components/project-map/drawings-editors/text-editor/text-editor.component.scss create mode 100644 src/app/components/project-map/drawings-editors/text-editor/text-editor.component.spec.ts create mode 100644 src/app/components/project-map/drawings-editors/text-editor/text-editor.component.ts diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 8566a4ba..377b416d 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -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 ] }) diff --git a/src/app/cartography/components/text-editor/text-editor.component.html b/src/app/cartography/components/text-editor/text-editor.component.html index f5d81eb2..eda815eb 100644 --- a/src/app/cartography/components/text-editor/text-editor.component.html +++ b/src/app/cartography/components/text-editor/text-editor.component.html @@ -1,6 +1,5 @@
+ [style.left]=leftPosition> {{innerText}}
diff --git a/src/app/cartography/components/text-editor/text-editor.component.ts b/src/app/cartography/components/text-editor/text-editor.component.ts index ea674e9f..4517666b 100644 --- a/src/app/cartography/components/text-editor/text-editor.component.ts +++ b/src/app/cartography/components/text-editor/text-editor.component.ts @@ -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; diff --git a/src/app/cartography/converters/map/map-drawing-to-drawing-converter.ts b/src/app/cartography/converters/map/map-drawing-to-drawing-converter.ts index 04347c0e..1ed35d30 100644 --- a/src/app/cartography/converters/map/map-drawing-to-drawing-converter.ts +++ b/src/app/cartography/converters/map/map-drawing-to-drawing-converter.ts @@ -19,6 +19,7 @@ export class MapDrawingToDrawingConverter implements Converter - + diff --git a/src/app/components/project-map/drawings-editors/style-editor/style-editor.component.html b/src/app/components/project-map/drawings-editors/style-editor/style-editor.component.html new file mode 100644 index 00000000..e357b8c4 --- /dev/null +++ b/src/app/components/project-map/drawings-editors/style-editor/style-editor.component.html @@ -0,0 +1,30 @@ +

Style editor

+ +
Fill color:
+ +
+
+ +
Border color:
+ +
+
+ +
Border width:
+ +
+
+ +
Border style:
+ +
+
+ +
Rotation:
+ +
+
+
+ + +
diff --git a/src/app/components/project-map/drawings-editors/style-editor/style-editor.component.scss b/src/app/components/project-map/drawings-editors/style-editor/style-editor.component.scss new file mode 100644 index 00000000..2d804158 --- /dev/null +++ b/src/app/components/project-map/drawings-editors/style-editor/style-editor.component.scss @@ -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; +} diff --git a/src/app/components/project-map/drawings-editors/style-editor/style-editor.component.spec.ts b/src/app/components/project-map/drawings-editors/style-editor/style-editor.component.spec.ts new file mode 100644 index 00000000..e69de29b diff --git a/src/app/components/project-map/drawings-editors/style-editor/style-editor.component.ts b/src/app/components/project-map/drawings-editors/style-editor/style-editor.component.ts new file mode 100644 index 00000000..95dbf65b --- /dev/null +++ b/src/app/components/project-map/drawings-editors/style-editor/style-editor.component.ts @@ -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, + 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(); + }); + } +} diff --git a/src/app/components/project-map/drawings-editors/text-editor/text-editor.component.html b/src/app/components/project-map/drawings-editors/text-editor/text-editor.component.html new file mode 100644 index 00000000..e69de29b diff --git a/src/app/components/project-map/drawings-editors/text-editor/text-editor.component.scss b/src/app/components/project-map/drawings-editors/text-editor/text-editor.component.scss new file mode 100644 index 00000000..e69de29b diff --git a/src/app/components/project-map/drawings-editors/text-editor/text-editor.component.spec.ts b/src/app/components/project-map/drawings-editors/text-editor/text-editor.component.spec.ts new file mode 100644 index 00000000..e69de29b diff --git a/src/app/components/project-map/drawings-editors/text-editor/text-editor.component.ts b/src/app/components/project-map/drawings-editors/text-editor/text-editor.component.ts new file mode 100644 index 00000000..f86bfc24 --- /dev/null +++ b/src/app/components/project-map/drawings-editors/text-editor/text-editor.component.ts @@ -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(){} +} diff --git a/src/app/components/project-map/project-map.component.ts b/src/app/components/project-map/project-map.component.ts index 9e0a3f80..d5787c6d 100644 --- a/src/app/components/project-map/project-map.component.ts +++ b/src/app/components/project-map/project-map.component.ts @@ -313,10 +313,7 @@ export class ProjectMapComponent implements OnInit, OnDestroy { } public showMenu() { - setTimeout(() => { - this.drawTools.visibility = true; - }, - 200); + this.drawTools.visibility = true; } public ngOnDestroy() { diff --git a/src/app/services/drawing.service.ts b/src/app/services/drawing.service.ts index e0cf9d8b..d93a97ac 100644 --- a/src/app/services/drawing.service.ts +++ b/src/app/services/drawing.service.ts @@ -52,6 +52,8 @@ export class DrawingService { update(server: Server, drawing: Drawing): Observable { return this.httpServer .put(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