GUI2 Extract Topology view in to its own library

Change-Id: I45597d0902c99b5b3d606966866cc518011c54a0
diff --git a/web/gui2-topo-lib/projects/gui2-topo-tester/src/app/app.component.css b/web/gui2-topo-lib/projects/gui2-topo-tester/src/app/app.component.css
new file mode 100644
index 0000000..e6f8352
--- /dev/null
+++ b/web/gui2-topo-lib/projects/gui2-topo-tester/src/app/app.component.css
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+
+
+#view h2 {
+    color: #3c3a3a;
+    /*margin: 32px 0 4px 16px;*/
+    padding: 0;
+    font-size: 18pt;
+    font-weight: lighter;
+}
+
+a {
+    color: #009fdb;
+    text-decoration: none;
+}
+a:hover {
+    text-decoration: underline;
+}
+a:visited {
+    color: #7fabdb;
+    text-decoration: none;
+}
diff --git a/web/gui2-topo-lib/projects/gui2-topo-tester/src/app/app.component.html b/web/gui2-topo-lib/projects/gui2-topo-tester/src/app/app.component.html
new file mode 100644
index 0000000..9293382
--- /dev/null
+++ b/web/gui2-topo-lib/projects/gui2-topo-tester/src/app/app.component.html
@@ -0,0 +1,7 @@
+<!--The content below is only a placeholder and can be replaced.-->
+<div style="text-align:center">
+  <p>ONOS Topology view test application</p>
+</div>
+<onos-topology [bannerHeight]="50"></onos-topology>
+
+
diff --git a/web/gui2-topo-lib/projects/gui2-topo-tester/src/app/app.component.spec.ts b/web/gui2-topo-lib/projects/gui2-topo-tester/src/app/app.component.spec.ts
new file mode 100644
index 0000000..964800f
--- /dev/null
+++ b/web/gui2-topo-lib/projects/gui2-topo-tester/src/app/app.component.spec.ts
@@ -0,0 +1,31 @@
+import { TestBed, async } from '@angular/core/testing';
+import { AppComponent } from './app.component';
+
+describe('AppComponent', () => {
+  beforeEach(async(() => {
+    TestBed.configureTestingModule({
+      declarations: [
+        AppComponent
+      ],
+    }).compileComponents();
+  }));
+
+  it('should create the app', () => {
+    const fixture = TestBed.createComponent(AppComponent);
+    const app = fixture.debugElement.componentInstance;
+    expect(app).toBeTruthy();
+  });
+
+  it(`should have as title 'gui2-topo-tester'`, () => {
+    const fixture = TestBed.createComponent(AppComponent);
+    const app = fixture.debugElement.componentInstance;
+    expect(app.title).toEqual('gui2-topo-tester');
+  });
+
+  it('should render title in a h1 tag', () => {
+    const fixture = TestBed.createComponent(AppComponent);
+    fixture.detectChanges();
+    const compiled = fixture.debugElement.nativeElement;
+    expect(compiled.querySelector('h1').textContent).toContain('Welcome to gui2-topo-tester!');
+  });
+});
diff --git a/web/gui2-topo-lib/projects/gui2-topo-tester/src/app/app.component.ts b/web/gui2-topo-lib/projects/gui2-topo-tester/src/app/app.component.ts
new file mode 100644
index 0000000..4261f48
--- /dev/null
+++ b/web/gui2-topo-lib/projects/gui2-topo-tester/src/app/app.component.ts
@@ -0,0 +1,69 @@
+/*
+ * 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 {AfterViewInit, Component, OnDestroy} from '@angular/core';
+import {
+    GlyphService,
+    KeysService,
+    LionService,
+    LogService,
+    ThemeService,
+    WebSocketService,
+    WsOptions
+} from 'gui2-fw-lib';
+import * as d3 from 'd3';
+
+@Component({
+  selector: 'app-root',
+  templateUrl: './app.component.html',
+  styleUrls: ['./app.component.css']
+})
+export class AppComponent implements AfterViewInit, OnDestroy {
+    title = 'gui2-topo-tester';
+
+    constructor (
+        private lion: LionService,
+        private ts: ThemeService,
+        private gs: GlyphService,
+        private ks: KeysService,
+        public wss: WebSocketService,
+        private log: LogService,
+    ) {
+        // Testing of debugging
+        log.debug('OnosComponent: testing logger.debug()');
+        log.info('OnosComponent: testing logger.info()');
+        log.warn('OnosComponent: testing logger.warn()');
+        log.error('OnosComponent: testing logger.error()');
+
+        this.wss.createWebSocket(<WsOptions>{ wsport: 8181});
+
+        log.debug('OnosComponent constructed');
+    }
+
+    ngAfterViewInit(): void {
+        this.ks.installOn(d3.select('body'));
+        this.log.debug('AppComponent after view initialized');
+    }
+
+
+    ngOnDestroy() {
+        if (this.wss.isConnected()) {
+            this.log.debug('Stopping Web Socket connection');
+            this.wss.closeWebSocket();
+        }
+
+        this.log.debug('AppComponent destroyed');
+    }
+}
diff --git a/web/gui2-topo-lib/projects/gui2-topo-tester/src/app/app.module.ts b/web/gui2-topo-lib/projects/gui2-topo-tester/src/app/app.module.ts
new file mode 100644
index 0000000..2fbba74
--- /dev/null
+++ b/web/gui2-topo-lib/projects/gui2-topo-tester/src/app/app.module.ts
@@ -0,0 +1,33 @@
+import { BrowserModule } from '@angular/platform-browser';
+import { NgModule } from '@angular/core';
+
+import { AppComponent } from './app.component';
+import {ConsoleLoggerService, Gui2FwLibModule, LogService} from 'gui2-fw-lib';
+import {Gui2TopoLibModule} from 'gui2-topo-lib';
+import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
+import {RouterModule, Routes} from '@angular/router';
+import {HttpClientModule} from '@angular/common/http';
+
+const appRoutes: Routes = [
+    { path: '**', component: AppComponent }
+]
+
+@NgModule({
+    declarations: [
+        AppComponent
+    ],
+    imports: [
+        RouterModule.forRoot(appRoutes),
+        BrowserModule,
+        BrowserAnimationsModule,
+        Gui2FwLibModule,
+        Gui2TopoLibModule,
+        HttpClientModule
+    ],
+    providers: [
+        { provide: LogService, useClass: ConsoleLoggerService },
+        { provide: 'Window', useValue: window }
+    ],
+    bootstrap: [AppComponent]
+})
+export class AppModule { }
diff --git a/web/gui2-topo-lib/projects/gui2-topo-tester/src/assets/.gitkeep b/web/gui2-topo-lib/projects/gui2-topo-tester/src/assets/.gitkeep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/web/gui2-topo-lib/projects/gui2-topo-tester/src/assets/.gitkeep
diff --git a/web/gui2-topo-lib/projects/gui2-topo-tester/src/assets/onos-logo.png b/web/gui2-topo-lib/projects/gui2-topo-tester/src/assets/onos-logo.png
new file mode 100644
index 0000000..8688cd6
--- /dev/null
+++ b/web/gui2-topo-lib/projects/gui2-topo-tester/src/assets/onos-logo.png
Binary files differ
diff --git a/web/gui2-topo-lib/projects/gui2-topo-tester/src/environments/environment.prod.ts b/web/gui2-topo-lib/projects/gui2-topo-tester/src/environments/environment.prod.ts
new file mode 100644
index 0000000..3612073
--- /dev/null
+++ b/web/gui2-topo-lib/projects/gui2-topo-tester/src/environments/environment.prod.ts
@@ -0,0 +1,3 @@
+export const environment = {
+  production: true
+};
diff --git a/web/gui2-topo-lib/projects/gui2-topo-tester/src/environments/environment.ts b/web/gui2-topo-lib/projects/gui2-topo-tester/src/environments/environment.ts
new file mode 100644
index 0000000..7b4f817
--- /dev/null
+++ b/web/gui2-topo-lib/projects/gui2-topo-tester/src/environments/environment.ts
@@ -0,0 +1,16 @@
+// This file can be replaced during build by using the `fileReplacements` array.
+// `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
+// The list of file replacements can be found in `angular.json`.
+
+export const environment = {
+  production: false
+};
+
+/*
+ * For easier debugging in development mode, you can import the following file
+ * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
+ *
+ * This import should be commented out in production mode because it will have a negative impact
+ * on performance if an error is thrown.
+ */
+// import 'zone.js/dist/zone-error';  // Included with Angular CLI.
diff --git a/web/gui2-topo-lib/projects/gui2-topo-tester/src/favicon.ico b/web/gui2-topo-lib/projects/gui2-topo-tester/src/favicon.ico
new file mode 100644
index 0000000..8081c7c
--- /dev/null
+++ b/web/gui2-topo-lib/projects/gui2-topo-tester/src/favicon.ico
Binary files differ
diff --git a/web/gui2-topo-lib/projects/gui2-topo-tester/src/index.html b/web/gui2-topo-lib/projects/gui2-topo-tester/src/index.html
new file mode 100644
index 0000000..800bff9
--- /dev/null
+++ b/web/gui2-topo-lib/projects/gui2-topo-tester/src/index.html
@@ -0,0 +1,38 @@
+<!doctype html>
+<!--
+~ Copyright 2014-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.
+-->
+<html lang="en">
+<head>
+    <meta charset="utf-8">
+    <link rel="shortcut icon" href="data/img/onos-logo.png">
+
+    <link rel="apple-touch-icon" href="data/img/apple-touch-icon.png">
+    <meta name="apple-mobile-web-app-capable" content="yes">
+    <meta name="apple-mobile-web-app-status-bar-style" content="black">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+
+    <link href="app/fw/layer/loading.service.css" rel='stylesheet' type='text/css'>
+
+    <title>Gui2TopoTester</title>
+    <base href="/">
+
+    <meta name="viewport" content="width=device-width, initial-scale=1">
+    <link rel="icon" type="image/x-icon" href="favicon.ico">
+</head>
+<body>
+    <app-root></app-root>
+</body>
+</html>
diff --git a/web/gui2-topo-lib/projects/gui2-topo-tester/src/main.ts b/web/gui2-topo-lib/projects/gui2-topo-tester/src/main.ts
new file mode 100644
index 0000000..c7b673c
--- /dev/null
+++ b/web/gui2-topo-lib/projects/gui2-topo-tester/src/main.ts
@@ -0,0 +1,12 @@
+import { enableProdMode } from '@angular/core';
+import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
+
+import { AppModule } from './app/app.module';
+import { environment } from './environments/environment';
+
+if (environment.production) {
+  enableProdMode();
+}
+
+platformBrowserDynamic().bootstrapModule(AppModule)
+  .catch(err => console.error(err));
diff --git a/web/gui2-topo-lib/projects/gui2-topo-tester/src/polyfills.ts b/web/gui2-topo-lib/projects/gui2-topo-tester/src/polyfills.ts
new file mode 100644
index 0000000..ee8b84d
--- /dev/null
+++ b/web/gui2-topo-lib/projects/gui2-topo-tester/src/polyfills.ts
@@ -0,0 +1,80 @@
+/**
+ * This file includes polyfills needed by Angular and is loaded before the app.
+ * You can add your own extra polyfills to this file.
+ *
+ * This file is divided into 2 sections:
+ *   1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
+ *   2. Application imports. Files imported after ZoneJS that should be loaded before your main
+ *      file.
+ *
+ * The current setup is for so-called "evergreen" browsers; the last versions of browsers that
+ * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
+ * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
+ *
+ * Learn more in https://angular.io/guide/browser-support
+ */
+
+/***************************************************************************************************
+ * BROWSER POLYFILLS
+ */
+
+/** IE9, IE10 and IE11 requires all of the following polyfills. **/
+// import 'core-js/es6/symbol';
+// import 'core-js/es6/object';
+// import 'core-js/es6/function';
+// import 'core-js/es6/parse-int';
+// import 'core-js/es6/parse-float';
+// import 'core-js/es6/number';
+// import 'core-js/es6/math';
+// import 'core-js/es6/string';
+// import 'core-js/es6/date';
+// import 'core-js/es6/array';
+// import 'core-js/es6/regexp';
+// import 'core-js/es6/map';
+// import 'core-js/es6/weak-map';
+// import 'core-js/es6/set';
+
+/**
+ * If the application will be indexed by Google Search, the following is required.
+ * Googlebot uses a renderer based on Chrome 41.
+ * https://developers.google.com/search/docs/guides/rendering
+ **/
+// import 'core-js/es6/array';
+
+/** IE10 and IE11 requires the following for NgClass support on SVG elements */
+// import 'classlist.js';  // Run `npm install --save classlist.js`.
+
+/** IE10 and IE11 requires the following for the Reflect API. */
+// import 'core-js/es6/reflect';
+
+/**
+ * Web Animations `@angular/platform-browser/animations`
+ * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
+ * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
+ **/
+// import 'web-animations-js';  // Run `npm install --save web-animations-js`.
+
+/**
+ * By default, zone.js will patch all possible macroTask and DomEvents
+ * user can disable parts of macroTask/DomEvents patch by setting following flags
+ */
+
+ // (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
+ // (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
+ // (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
+
+ /*
+ * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
+ * with the following flag, it will bypass `zone.js` patch for IE/Edge
+ */
+// (window as any).__Zone_enable_cross_context_check = true;
+
+/***************************************************************************************************
+ * Zone JS is required by default for Angular itself.
+ */
+import 'zone.js/dist/zone';  // Included with Angular CLI.
+
+
+/***************************************************************************************************
+ * APPLICATION IMPORTS
+ */
diff --git a/web/gui2-topo-lib/projects/gui2-topo-tester/src/styles.css b/web/gui2-topo-lib/projects/gui2-topo-tester/src/styles.css
new file mode 100644
index 0000000..24801ba
--- /dev/null
+++ b/web/gui2-topo-lib/projects/gui2-topo-tester/src/styles.css
@@ -0,0 +1,18 @@
+/* You can add global styles to this file, and also import other style files */
+html {
+    font-family: 'Open Sans', normal;
+    -webkit-text-size-adjust: 100%;
+    -ms-text-size-adjust: 100%;
+    height: 100%;
+}
+
+/*
+   overflow hidden is to ensure that the body does not expand to account
+   for any flyout panes, that are positioned "off screen".
+ */
+body {
+    background-color: white;
+    height: 100%;
+    margin: 0;
+    overflow: hidden;
+}
diff --git a/web/gui2-topo-lib/projects/gui2-topo-tester/src/test.ts b/web/gui2-topo-lib/projects/gui2-topo-tester/src/test.ts
new file mode 100644
index 0000000..1631789
--- /dev/null
+++ b/web/gui2-topo-lib/projects/gui2-topo-tester/src/test.ts
@@ -0,0 +1,20 @@
+// This file is required by karma.conf.js and loads recursively all the .spec and framework files
+
+import 'zone.js/dist/zone-testing';
+import { getTestBed } from '@angular/core/testing';
+import {
+  BrowserDynamicTestingModule,
+  platformBrowserDynamicTesting
+} from '@angular/platform-browser-dynamic/testing';
+
+declare const require: any;
+
+// First, initialize the Angular testing environment.
+getTestBed().initTestEnvironment(
+  BrowserDynamicTestingModule,
+  platformBrowserDynamicTesting()
+);
+// Then we find all the tests.
+const context = require.context('./', true, /\.spec\.ts$/);
+// And load the modules.
+context.keys().map(context);