Moved ZoomDirective to gui2-fw-lib (from gui2-topo-lib)

Change-Id: Idc8bfefea7c84d6611242a9562d84ca6cc53a7b3
diff --git a/web/gui2-fw-lib/package.json b/web/gui2-fw-lib/package.json
index d7da490..d26e07b 100644
--- a/web/gui2-fw-lib/package.json
+++ b/web/gui2-fw-lib/package.json
@@ -1,6 +1,6 @@
 {
     "name": "gui2-fw-lib-app",
-    "version": "2.3.0",
+    "version": "2.3.3",
     "license": "MIT",
     "scripts": {
         "ng": "ng",
diff --git a/web/gui2-fw-lib/projects/gui2-fw-lib/package.json b/web/gui2-fw-lib/projects/gui2-fw-lib/package.json
index fd1249a..402e4d9 100644
--- a/web/gui2-fw-lib/projects/gui2-fw-lib/package.json
+++ b/web/gui2-fw-lib/projects/gui2-fw-lib/package.json
@@ -1,6 +1,6 @@
 {
     "name": "gui2-fw-lib",
-    "version": "2.3.2",
+    "version": "2.3.3",
     "author": {
         "name": "Sean Condon",
         "email": "sean@opennetworking.org"
diff --git a/web/gui2-fw-lib/projects/gui2-fw-lib/src/lib/gui2-fw-lib.module.ts b/web/gui2-fw-lib/projects/gui2-fw-lib/src/lib/gui2-fw-lib.module.ts
index 2027b14..4a59988 100644
--- a/web/gui2-fw-lib/projects/gui2-fw-lib/src/lib/gui2-fw-lib.module.ts
+++ b/web/gui2-fw-lib/projects/gui2-fw-lib/src/lib/gui2-fw-lib.module.ts
@@ -13,46 +13,53 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-import { NgModule } from '@angular/core';
-import { CommonModule } from '@angular/common';
-import { DetectBrowserDirective } from './detectbrowser.directive';
-import { IconComponent } from './svg/icon/icon.component';
-import { VeilComponent } from './layer/veil/veil.component';
-import { FlashComponent } from './layer/flash/flash.component';
-import { ConfirmComponent } from './layer/confirm/confirm.component';
-import { MastComponent } from './mast/mast/mast.component';
-import { TableFilterPipe } from './widget/tablefilter.pipe';
-import { TableResizeDirective } from './widget/tableresize.directive';
-import { QuickhelpComponent } from './layer/quickhelp/quickhelp.component';
-import { LoadingComponent } from './layer/loading/loading.component';
+import {NgModule} from '@angular/core';
+import {CommonModule} from '@angular/common';
+import {DetectBrowserDirective} from './detectbrowser.directive';
+import {IconComponent} from './svg/icon/icon.component';
+import {VeilComponent} from './layer/veil/veil.component';
+import {FlashComponent} from './layer/flash/flash.component';
+import {ConfirmComponent} from './layer/confirm/confirm.component';
+import {MastComponent} from './mast/mast/mast.component';
+import {TableFilterPipe} from './widget/tablefilter.pipe';
+import {TableResizeDirective} from './widget/tableresize.directive';
+import {QuickhelpComponent} from './layer/quickhelp/quickhelp.component';
+import {LoadingComponent} from './layer/loading/loading.component';
+import {ZoomableDirective} from './svg/zoomable.directive';
+import {NameInputComponent} from './util/name-input/name-input.component';
 
 @NgModule({
-  imports: [
-    CommonModule
-  ],
-  declarations: [
-    DetectBrowserDirective,
-    TableResizeDirective,
-    IconComponent,
-    VeilComponent,
-    FlashComponent,
-    ConfirmComponent,
-    QuickhelpComponent,
-    MastComponent,
-    TableFilterPipe,
-    LoadingComponent
-  ],
-  exports: [
-    DetectBrowserDirective,
-    TableResizeDirective,
-    IconComponent,
-    VeilComponent,
-    FlashComponent,
-    ConfirmComponent,
-    QuickhelpComponent,
-    MastComponent,
-    TableFilterPipe,
-    LoadingComponent
-  ]
+    imports: [
+        CommonModule
+    ],
+    declarations: [
+        DetectBrowserDirective,
+        TableResizeDirective,
+        IconComponent,
+        VeilComponent,
+        FlashComponent,
+        ConfirmComponent,
+        QuickhelpComponent,
+        MastComponent,
+        TableFilterPipe,
+        LoadingComponent,
+        ZoomableDirective,
+        NameInputComponent
+    ],
+    exports: [
+        DetectBrowserDirective,
+        TableResizeDirective,
+        IconComponent,
+        VeilComponent,
+        FlashComponent,
+        ConfirmComponent,
+        QuickhelpComponent,
+        MastComponent,
+        TableFilterPipe,
+        LoadingComponent,
+        ZoomableDirective,
+        NameInputComponent
+    ]
 })
-export class Gui2FwLibModule { }
+export class Gui2FwLibModule {
+}
diff --git a/web/gui2-topo-lib/projects/gui2-topo-lib/src/lib/layer/zoomable.directive.spec.ts b/web/gui2-fw-lib/projects/gui2-fw-lib/src/lib/svg/zoomable.directive.spec.ts
similarity index 93%
rename from web/gui2-topo-lib/projects/gui2-topo-lib/src/lib/layer/zoomable.directive.spec.ts
rename to web/gui2-fw-lib/projects/gui2-fw-lib/src/lib/svg/zoomable.directive.spec.ts
index 23d75c5..36b6e37 100644
--- a/web/gui2-topo-lib/projects/gui2-topo-lib/src/lib/layer/zoomable.directive.spec.ts
+++ b/web/gui2-fw-lib/projects/gui2-fw-lib/src/lib/svg/zoomable.directive.spec.ts
@@ -15,10 +15,12 @@
  */
 import { ZoomableDirective } from './zoomable.directive';
 import {inject, TestBed} from '@angular/core/testing';
-import {LogService, ConsoleLoggerService, FnService} from 'gui2-fw-lib';
 import {ElementRef} from '@angular/core';
 import {ActivatedRoute, Params} from '@angular/router';
 import {of} from 'rxjs';
+import {FnService} from '../util/fn.service';
+import {LogService} from '../log.service';
+import {ConsoleLoggerService} from '../consolelogger.service';
 
 class MockActivatedRoute extends ActivatedRoute {
     constructor(params: Params) {
diff --git a/web/gui2-topo-lib/projects/gui2-topo-lib/src/lib/layer/zoomable.directive.ts b/web/gui2-fw-lib/projects/gui2-fw-lib/src/lib/svg/zoomable.directive.ts
similarity index 95%
rename from web/gui2-topo-lib/projects/gui2-topo-lib/src/lib/layer/zoomable.directive.ts
rename to web/gui2-fw-lib/projects/gui2-fw-lib/src/lib/svg/zoomable.directive.ts
index 9564444..96fbbfb 100644
--- a/web/gui2-topo-lib/projects/gui2-topo-lib/src/lib/layer/zoomable.directive.ts
+++ b/web/gui2-fw-lib/projects/gui2-fw-lib/src/lib/svg/zoomable.directive.ts
@@ -21,8 +21,10 @@
     OnInit,
     SimpleChanges
 } from '@angular/core';
-import {LogService, PrefsService, TopoZoomPrefs} from 'gui2-fw-lib';
 import * as d3 from 'd3';
+import {TopoZoomPrefs} from './zoomutils';
+import {LogService} from '../log.service';
+import {PrefsService} from '../util/prefs.service';
 
 const TOPO_ZOOM_PREFS = 'topo_zoom';
 
diff --git a/web/gui2-fw-lib/projects/gui2-fw-lib/src/lib/util/name-input/name-input.component.css b/web/gui2-fw-lib/projects/gui2-fw-lib/src/lib/util/name-input/name-input.component.css
new file mode 100644
index 0000000..c8acf1b
--- /dev/null
+++ b/web/gui2-fw-lib/projects/gui2-fw-lib/src/lib/util/name-input/name-input.component.css
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2019-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ ONOS GUI -- Name Input Component (layout) -- CSS file
+ */
+#name-input-dialog {
+    top: 140px;
+    padding: 12px;
+}
+
+#name-input-dialog h3 {
+    display: inline-block;
+    font-weight: bold;
+    font-size: 18pt;
+}
+
+#name-input-dialog p {
+    font-size: 12pt;
+}
+
+#name-input-dialog p.strong {
+    font-weight: bold;
+    padding: 8px;
+    text-align: center;
+}
diff --git a/web/gui2-fw-lib/projects/gui2-fw-lib/src/lib/util/name-input/name-input.component.html b/web/gui2-fw-lib/projects/gui2-fw-lib/src/lib/util/name-input/name-input.component.html
new file mode 100644
index 0000000..e505780
--- /dev/null
+++ b/web/gui2-fw-lib/projects/gui2-fw-lib/src/lib/util/name-input/name-input.component.html
@@ -0,0 +1,22 @@
+<!--
+~ Copyright 2019-present Open Networking Foundation
+~
+~ Licensed under the Apache License, Version 2.0 (the "License");
+~ you may not use this file except in compliance with the License.
+~ You may obtain a copy of the License at
+~
+~     http://www.apache.org/licenses/LICENSE-2.0
+~
+~ Unless required by applicable law or agreed to in writing, software
+~ distributed under the License is distributed on an "AS IS" BASIS,
+~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+~ See the License for the specific language governing permissions and
+~ limitations under the License.
+-->
+<div id="name-input-dialog" class="floatpanel dialog" [@niDlgState]="title!==''">
+    <h3>{{ title }}</h3><br>
+    <input #newName type="text" pattern="[a-zA-Z0-9\-:_]{3}" [placeholder]="placeholder" name="nameinput" [minLength]="minLen" [maxLength]="maxLen" width="40" required>
+    <p *ngIf="warning" class="warning strong">{{ warning }}</p>
+    <div tabindex="10" class="dialog-button" (click)="choice(true, newName.value)">OK</div>
+    <div tabindex="11" class="dialog-button" (click)="choice(false, '')">Cancel</div>
+</div>
diff --git a/web/gui2-fw-lib/projects/gui2-fw-lib/src/lib/util/name-input/name-input.component.spec.ts b/web/gui2-fw-lib/projects/gui2-fw-lib/src/lib/util/name-input/name-input.component.spec.ts
new file mode 100644
index 0000000..63ec2cb
--- /dev/null
+++ b/web/gui2-fw-lib/projects/gui2-fw-lib/src/lib/util/name-input/name-input.component.spec.ts
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2019-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import {async, ComponentFixture, TestBed} from '@angular/core/testing';
+
+import {NameInputComponent} from './name-input.component';
+import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
+
+describe('NameInputComponent', () => {
+    let component: NameInputComponent;
+    let fixture: ComponentFixture<NameInputComponent>;
+
+    beforeEach(async(() => {
+        TestBed.configureTestingModule({
+            imports: [BrowserAnimationsModule],
+            declarations: [NameInputComponent]
+        })
+            .compileComponents();
+    }));
+
+    beforeEach(() => {
+        fixture = TestBed.createComponent(NameInputComponent);
+        component = fixture.componentInstance;
+        fixture.detectChanges();
+    });
+
+    it('should create', () => {
+        expect(component).toBeTruthy();
+    });
+});
diff --git a/web/gui2-fw-lib/projects/gui2-fw-lib/src/lib/util/name-input/name-input.component.ts b/web/gui2-fw-lib/projects/gui2-fw-lib/src/lib/util/name-input/name-input.component.ts
new file mode 100644
index 0000000..9d7116e
--- /dev/null
+++ b/web/gui2-fw-lib/projects/gui2-fw-lib/src/lib/util/name-input/name-input.component.ts
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2019-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
+import {animate, state, style, transition, trigger} from '@angular/animations';
+
+export interface NameInputResult {
+    chosen: boolean;
+    name: string;
+}
+
+@Component({
+    selector: 'onos-name-input',
+    templateUrl: './name-input.component.html',
+    styleUrls: [
+        './name-input.component.css',
+        './name-input.theme.css',
+        '../../layer/dialog.css',
+        '../../layer/dialog.theme.css',
+        '../../widget/panel.css',
+        '../../widget/panel-theme.css'
+    ],
+    animations: [
+        trigger('niDlgState', [
+            state('true', style({
+                transform: 'translateX(-100%)',
+                opacity: '100'
+            })),
+            state('false', style({
+                transform: 'translateX(0%)',
+                opacity: '0'
+            })),
+            transition('0 => 1', animate('100ms ease-in')),
+            transition('1 => 0', animate('100ms ease-out'))
+        ])
+    ]
+})
+export class NameInputComponent implements OnInit {
+    @Input() warning: string;
+    @Input() title: string = '';
+    @Input() pattern;
+    @Input() minLen = 4;
+    @Input() maxLen = 40;
+    @Input() placeholder = 'name';
+    @Output() chosen: EventEmitter<NameInputResult> = new EventEmitter();
+
+    constructor() {
+    }
+
+    ngOnInit() {
+    }
+
+    /**
+     * When OK or Cancel is pressed, send an event to parent with choice
+     */
+    choice(chosen: boolean, newName: string): void {
+        if (chosen && (newName === undefined || newName === '')) {
+            return;
+        }
+        this.chosen.emit(<NameInputResult>{
+            chosen: chosen,
+            name: newName
+        });
+    }
+}
diff --git a/web/gui2-fw-lib/projects/gui2-fw-lib/src/lib/util/name-input/name-input.theme.css b/web/gui2-fw-lib/projects/gui2-fw-lib/src/lib/util/name-input/name-input.theme.css
new file mode 100644
index 0000000..bb88fb2
--- /dev/null
+++ b/web/gui2-fw-lib/projects/gui2-fw-lib/src/lib/util/name-input/name-input.theme.css
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2019-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ ONOS GUI -- name-input-dialog Component (theme) -- CSS file
+ */
+/* temporarily removed .light */
+#name-input-dialog p.strong {
+    color: white;
+    background-color: #ce5b58;
+}
+
+#name-input-dialog.floatpanel.dialog {
+    background-color: #ffffff;
+}
+
+#name-input-dialog p.strong {
+    color: white;
+    background-color: #ce5b58;
+}
diff --git a/web/gui2-fw-lib/projects/gui2-fw-lib/src/public_api.ts b/web/gui2-fw-lib/projects/gui2-fw-lib/src/public_api.ts
index 9c70db9..35cb29b 100644
--- a/web/gui2-fw-lib/projects/gui2-fw-lib/src/public_api.ts
+++ b/web/gui2-fw-lib/projects/gui2-fw-lib/src/public_api.ts
@@ -51,9 +51,11 @@
 export * from './lib/layer/quickhelp/quickhelp.component';
 export * from './lib/layer/loading/loading.component';
 export * from './lib/svg/icon/icon.component';
+export * from './lib/util/name-input/name-input.component';
 
 export * from './lib/widget/tableresize.directive';
 export * from './lib/detectbrowser.directive';
+export * from './lib/svg/zoomable.directive';
 
 export * from './lib/widget/tablefilter.pipe';
 
diff --git a/web/gui2-fw-lib/src/app/app.component.html b/web/gui2-fw-lib/src/app/app.component.html
index 80c9050..e3c6531 100644
--- a/web/gui2-fw-lib/src/app/app.component.html
+++ b/web/gui2-fw-lib/src/app/app.component.html
@@ -46,3 +46,4 @@
 </p>
 <onos-quickhelp #qh></onos-quickhelp>
 <button (click)="qh.ks.quickHelpShown = true">Toggle quick help shown</button>
+<onos-name-input [title]="'test-input'" [minLen]="10" [maxLen]="20"></onos-name-input>
diff --git a/web/gui2-topo-lib/projects/gui2-topo-lib/package.json b/web/gui2-topo-lib/projects/gui2-topo-lib/package.json
index 644d88a..90a3ca7 100644
--- a/web/gui2-topo-lib/projects/gui2-topo-lib/package.json
+++ b/web/gui2-topo-lib/projects/gui2-topo-lib/package.json
@@ -1,6 +1,6 @@
 {
   "name": "gui2-topo-lib",
-  "version": "2.1.1",
+  "version": "2.3.3",
   "author": {
     "name": "Sean Condon",
     "email": "sean@opennetworking.org"
@@ -17,6 +17,6 @@
   "peerDependencies": {
     "@angular/common": "^7.0.0",
     "@angular/core": "^7.0.0",
-    "gui2-fw-lib": "^2.1.1"
+    "gui2-fw-lib": "^2.3.3"
   }
 }
diff --git a/web/gui2-topo-lib/projects/gui2-topo-lib/src/lib/gui2-topo-lib.module.ts b/web/gui2-topo-lib/projects/gui2-topo-lib/src/lib/gui2-topo-lib.module.ts
index a19b73d..e857b64 100644
--- a/web/gui2-topo-lib/projects/gui2-topo-lib/src/lib/gui2-topo-lib.module.ts
+++ b/web/gui2-topo-lib/projects/gui2-topo-lib/src/lib/gui2-topo-lib.module.ts
@@ -28,7 +28,6 @@
 import { MapSvgComponent } from './layer/mapsvg/mapsvg.component';
 import { TopologyService } from './topology.service';
 import { DraggableDirective } from './layer/forcesvg/draggable/draggable.directive';
-import { ZoomableDirective } from './layer/zoomable.directive';
 import { MapSelectorComponent } from './panel/mapselector/mapselector.component';
 import { DeviceNodeSvgComponent} from './layer/forcesvg/visuals/devicenodesvg/devicenodesvg.component';
 import { HostNodeSvgComponent } from './layer/forcesvg/visuals/hostnodesvg/hostnodesvg.component';
@@ -72,7 +71,6 @@
         SummaryComponent,
         ToolbarComponent,
         TopologyComponent,
-        ZoomableDirective,
         DraggableDirective,
         BadgeSvgComponent,
     ],
@@ -97,7 +95,6 @@
         SummaryComponent,
         ToolbarComponent,
         TopologyComponent,
-        ZoomableDirective,
         DraggableDirective,
         BadgeSvgComponent
     ]
diff --git a/web/gui2-topo-lib/projects/gui2-topo-lib/src/lib/topology/topology.component.spec.ts b/web/gui2-topo-lib/projects/gui2-topo-lib/src/lib/topology/topology.component.spec.ts
index 15c2bd1..bbab25a 100644
--- a/web/gui2-topo-lib/projects/gui2-topo-lib/src/lib/topology/topology.component.spec.ts
+++ b/web/gui2-topo-lib/projects/gui2-topo-lib/src/lib/topology/topology.component.spec.ts
@@ -36,7 +36,7 @@
     LogService,
     IconService, IconComponent, PrefsService, KeysService, LionService
 } from 'gui2-fw-lib';
-import {ZoomableDirective} from '../layer/zoomable.directive';
+import {ZoomableDirective} from 'gui2-fw-lib';
 import {RouterTestingModule} from '@angular/router/testing';
 import {TrafficService} from '../traffic.service';
 import {ForceSvgComponent} from '../layer/forcesvg/forcesvg.component';
@@ -203,7 +203,6 @@
                 ToolbarComponent,
                 DetailsComponent,
                 FlashComponent,
-                ZoomableDirective,
                 IconComponent,
                 QuickhelpComponent,
                 ForceSvgComponent,
diff --git a/web/gui2-topo-lib/projects/gui2-topo-lib/src/lib/topology/topology.component.ts b/web/gui2-topo-lib/projects/gui2-topo-lib/src/lib/topology/topology.component.ts
index f48f33a..dfadb9e 100644
--- a/web/gui2-topo-lib/projects/gui2-topo-lib/src/lib/topology/topology.component.ts
+++ b/web/gui2-topo-lib/projects/gui2-topo-lib/src/lib/topology/topology.component.ts
@@ -67,7 +67,7 @@
     ALARMS_TOGGLE
 } from '../panel/toolbar/toolbar.component';
 import {TrafficService, TrafficType} from '../traffic.service';
-import {ZoomableDirective} from '../layer/zoomable.directive';
+import {ZoomableDirective} from 'gui2-fw-lib';
 import {MapObject} from '../layer/maputils';
 import {LayoutService, LayoutType} from '../layout.service';
 import {SelectedEvent} from '../layer/forcesvg/visuals/nodevisual';
diff --git a/web/gui2-topo-lib/projects/gui2-topo-lib/src/public_api.ts b/web/gui2-topo-lib/projects/gui2-topo-lib/src/public_api.ts
index 24d46a2..becde57 100644
--- a/web/gui2-topo-lib/projects/gui2-topo-lib/src/public_api.ts
+++ b/web/gui2-topo-lib/projects/gui2-topo-lib/src/public_api.ts
@@ -23,7 +23,6 @@
 export * from './lib/traffic.service';
 export * from './lib/topology-routing.module';
 
-export * from './lib/layer/zoomable.directive';
 export * from './lib/layer/viewcontroller';
 export * from './lib/layer/maputils';