From 2b5b73ba3814dd44b29fa7a16a55608caea929d0 Mon Sep 17 00:00:00 2001 From: ziajka Date: Mon, 11 Jun 2018 14:08:35 +0200 Subject: [PATCH] Show/hide interfaces labels support, Fixes: #133 --- .../shared/widgets/interface-label.spec.ts | 9 +++++++++ .../cartography/shared/widgets/interface-label.ts | 10 +++++++++- src/app/project-map/project-map.component.css | 6 ++++++ src/app/project-map/project-map.component.html | 12 ++++++++++++ src/app/project-map/project-map.component.ts | 8 ++++++++ src/app/shared/models/project.ts | 6 +++++- 6 files changed, 49 insertions(+), 2 deletions(-) diff --git a/src/app/cartography/shared/widgets/interface-label.spec.ts b/src/app/cartography/shared/widgets/interface-label.spec.ts index 90d499d7..84c151bb 100644 --- a/src/app/cartography/shared/widgets/interface-label.spec.ts +++ b/src/app/cartography/shared/widgets/interface-label.spec.ts @@ -100,6 +100,15 @@ describe('InterfaceLabelsWidget', () => { }); + it('should not draw interface labels when disabled', () => { + widget.setEnabled(false); + widget.draw(linksEnter); + + const drew = svg.canvas.selectAll('g.interface_label_container'); + + expect(drew.nodes().length).toEqual(0); + }); + it('should draw interface label with class `selected` when selected', () => { links[0].nodes[0].label.is_selected = true; diff --git a/src/app/cartography/shared/widgets/interface-label.ts b/src/app/cartography/shared/widgets/interface-label.ts index 4eafb9f1..a69e421f 100644 --- a/src/app/cartography/shared/widgets/interface-label.ts +++ b/src/app/cartography/shared/widgets/interface-label.ts @@ -9,11 +9,16 @@ export class InterfaceLabelWidget { static SURROUNDING_TEXT_BORDER = 5; private cssFixer: CssFixer; + private enabled = true; constructor() { this.cssFixer = new CssFixer(); } + public setEnabled(enabled: boolean) { + this.enabled = enabled; + } + draw(selection: SVGSelection) { const labels = selection @@ -41,7 +46,10 @@ export class InterfaceLabelWidget { l.nodes[1].label.is_selected ); - return [sourceInterface, targetInterface]; + if (this.enabled) { + return [sourceInterface, targetInterface]; + } + return []; }); const enter = labels diff --git a/src/app/project-map/project-map.component.css b/src/app/project-map/project-map.component.css index 472dceb9..ee61573f 100644 --- a/src/app/project-map/project-map.component.css +++ b/src/app/project-map/project-map.component.css @@ -75,3 +75,9 @@ g.node text, border: none; -moz-outline-style: none } + +.options-item { + padding-left: 15px; + padding-right: 15px; + +} diff --git a/src/app/project-map/project-map.component.html b/src/app/project-map/project-map.component.html index 8a437510..067bff29 100644 --- a/src/app/project-map/project-map.component.html +++ b/src/app/project-map/project-map.component.html @@ -21,6 +21,18 @@ + + + + + +
+ Show interface labels +
+
+