FM GUI as an NPM library for GUI 2

* added dynamic loading of external modules
* new commands on Alarm to allow create/updating/delete
* new fields in alarm gui

Change-Id: I9a7f4d665618a7949bb02039374974dabf6e5363
diff --git a/apps/faultmanagement/fm-gui2-lib/src/app/app.component.css b/apps/faultmanagement/fm-gui2-lib/src/app/app.component.css
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/apps/faultmanagement/fm-gui2-lib/src/app/app.component.css
diff --git a/apps/faultmanagement/fm-gui2-lib/src/app/app.component.html b/apps/faultmanagement/fm-gui2-lib/src/app/app.component.html
new file mode 100644
index 0000000..caa02a6
--- /dev/null
+++ b/apps/faultmanagement/fm-gui2-lib/src/app/app.component.html
@@ -0,0 +1,47 @@
+<!--
+~ Copyright 2018-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 style="text-align:center">
+  <onos-icon iconId="nav_apps" iconSize="200" toolTip="Test app"></onos-icon>
+  <h1>
+    Welcome to {{ title }}!
+  </h1>
+</div>
+<h2>Test App - Do not use or extend</h2>
+<p>This app is just a wrapper around the FM GUI2 Library and is
+  necessary only to provide a base for that library.
+  It has a use in validating that the library can be loaded.
+
+  The library is linked in here by the addition of the paths statement in
+  tsconfig.json. This is fine for accessing a local library, but for another
+  project it should be added in through package.json, using the 'file' locator.
+  Then run "npm install" in that target project and the tar will be expanded in
+  to it's node_modules folder.
+
+  A good article on the creation and use of libraries in Angular 6 is given in<br />
+  <a href="https://blog.angularindepth.com/creating-a-library-in-angular-6-87799552e7e5">The Angular Library Series - Creating a Library with the Angular CLI</a><br />
+  and <br />
+  <a href="https://blog.angularindepth.com/creating-a-library-in-angular-6-part-2-6e2bc1e14121">The Angular Library Series - Building and Packaging</a><br />
+
+  This "app" component is not built by Bazel - it's only the library that is built
+  by bazel which in turn calls "ng build --prod fm-gui2-lib" and then "npm pack"
+  resulting in a tar file that can be used as an NPM package anywhere.
+  <br />
+  Note: Please remember that in Angular 6 rebuilding of libraries is not automatic.
+  If you change anything in the library, you will have to build it again before
+  it is picked up in this app.
+</p>
+<onos-alarmtable></onos-alarmtable>
+
diff --git a/apps/faultmanagement/fm-gui2-lib/src/app/app.component.spec.ts b/apps/faultmanagement/fm-gui2-lib/src/app/app.component.spec.ts
new file mode 100644
index 0000000..5c37eed
--- /dev/null
+++ b/apps/faultmanagement/fm-gui2-lib/src/app/app.component.spec.ts
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2018-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 { 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', async(() => {
+    const fixture = TestBed.createComponent(AppComponent);
+    const app = fixture.debugElement.componentInstance;
+    expect(app).toBeTruthy();
+  }));
+  it(`should have as title 'app'`, async(() => {
+    const fixture = TestBed.createComponent(AppComponent);
+    const app = fixture.debugElement.componentInstance;
+    expect(app.title).toEqual('app');
+  }));
+  it('should render title in a h1 tag', async(() => {
+    const fixture = TestBed.createComponent(AppComponent);
+    fixture.detectChanges();
+    const compiled = fixture.debugElement.nativeElement;
+    expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!');
+  }));
+});
diff --git a/apps/faultmanagement/fm-gui2-lib/src/app/app.component.ts b/apps/faultmanagement/fm-gui2-lib/src/app/app.component.ts
new file mode 100644
index 0000000..e2d5560
--- /dev/null
+++ b/apps/faultmanagement/fm-gui2-lib/src/app/app.component.ts
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2018-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 } from '@angular/core';
+
+@Component({
+  selector: 'app-root',
+  templateUrl: './app.component.html',
+  styleUrls: ['./app.component.css']
+})
+export class AppComponent {
+  title = 'app';
+}
diff --git a/apps/faultmanagement/fm-gui2-lib/src/app/app.module.ts b/apps/faultmanagement/fm-gui2-lib/src/app/app.module.ts
new file mode 100644
index 0000000..1bdaaee
--- /dev/null
+++ b/apps/faultmanagement/fm-gui2-lib/src/app/app.module.ts
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2018-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 { BrowserModule } from '@angular/platform-browser';
+import { NgModule } from '@angular/core';
+import { RouterModule, Routes }  from '@angular/router';
+import { FmGui2LibModule } from 'fm-gui2-lib';
+import { AppComponent } from './app.component';
+import { Gui2FwLibModule, ConsoleLoggerService, LogService } from 'gui2-fw-lib';
+
+const appRoutes: Routes = [
+  { path: '**', component: AppComponent }
+]
+
+@NgModule({
+  declarations: [
+    AppComponent
+  ],
+  imports: [
+    RouterModule.forRoot(appRoutes),
+    BrowserModule,
+    FmGui2LibModule,
+    Gui2FwLibModule
+  ],
+  providers: [
+    { provide: 'Window', useValue: window },
+    { provide: LogService, useClass: ConsoleLoggerService },
+  ],
+  bootstrap: [AppComponent]
+})
+export class AppModule { }
diff --git a/apps/faultmanagement/fm-gui2-lib/src/assets/.gitkeep b/apps/faultmanagement/fm-gui2-lib/src/assets/.gitkeep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/apps/faultmanagement/fm-gui2-lib/src/assets/.gitkeep
diff --git a/apps/faultmanagement/fm-gui2-lib/src/browserslist b/apps/faultmanagement/fm-gui2-lib/src/browserslist
new file mode 100644
index 0000000..8e09ab4
--- /dev/null
+++ b/apps/faultmanagement/fm-gui2-lib/src/browserslist
@@ -0,0 +1,9 @@
+# This file is currently used by autoprefixer to adjust CSS to support the below specified browsers
+# For additional information regarding the format and rule options, please see:
+# https://github.com/browserslist/browserslist#queries
+# For IE 9-11 support, please uncomment the last line of the file and adjust as needed
+> 0.5%
+last 2 versions
+Firefox ESR
+not dead
+# IE 9-11
\ No newline at end of file
diff --git a/apps/faultmanagement/fm-gui2-lib/src/environments/environment.prod.ts b/apps/faultmanagement/fm-gui2-lib/src/environments/environment.prod.ts
new file mode 100644
index 0000000..3612073
--- /dev/null
+++ b/apps/faultmanagement/fm-gui2-lib/src/environments/environment.prod.ts
@@ -0,0 +1,3 @@
+export const environment = {
+  production: true
+};
diff --git a/apps/faultmanagement/fm-gui2-lib/src/environments/environment.ts b/apps/faultmanagement/fm-gui2-lib/src/environments/environment.ts
new file mode 100644
index 0000000..012182e
--- /dev/null
+++ b/apps/faultmanagement/fm-gui2-lib/src/environments/environment.ts
@@ -0,0 +1,15 @@
+// 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
+};
+
+/*
+ * In development mode, to ignore zone related error stack frames such as
+ * `zone.run`, `zoneDelegate.invokeTask` for easier debugging, you can
+ * import the following file, but please comment it out in production mode
+ * because it will have performance impact when throw error
+ */
+// import 'zone.js/dist/zone-error';  // Included with Angular CLI.
diff --git a/apps/faultmanagement/fm-gui2-lib/src/favicon.ico b/apps/faultmanagement/fm-gui2-lib/src/favicon.ico
new file mode 100644
index 0000000..8081c7c
--- /dev/null
+++ b/apps/faultmanagement/fm-gui2-lib/src/favicon.ico
Binary files differ
diff --git a/apps/faultmanagement/fm-gui2-lib/src/index.html b/apps/faultmanagement/fm-gui2-lib/src/index.html
new file mode 100644
index 0000000..8567582
--- /dev/null
+++ b/apps/faultmanagement/fm-gui2-lib/src/index.html
@@ -0,0 +1,14 @@
+<!doctype html>
+<html lang="en">
+<head>
+  <meta charset="utf-8">
+  <title>FmGui2LibApp</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/apps/faultmanagement/fm-gui2-lib/src/karma.conf.js b/apps/faultmanagement/fm-gui2-lib/src/karma.conf.js
new file mode 100644
index 0000000..b6e0042
--- /dev/null
+++ b/apps/faultmanagement/fm-gui2-lib/src/karma.conf.js
@@ -0,0 +1,31 @@
+// Karma configuration file, see link for more information
+// https://karma-runner.github.io/1.0/config/configuration-file.html
+
+module.exports = function (config) {
+  config.set({
+    basePath: '',
+    frameworks: ['jasmine', '@angular-devkit/build-angular'],
+    plugins: [
+      require('karma-jasmine'),
+      require('karma-chrome-launcher'),
+      require('karma-jasmine-html-reporter'),
+      require('karma-coverage-istanbul-reporter'),
+      require('@angular-devkit/build-angular/plugins/karma')
+    ],
+    client: {
+      clearContext: false // leave Jasmine Spec Runner output visible in browser
+    },
+    coverageIstanbulReporter: {
+      dir: require('path').join(__dirname, '../coverage'),
+      reports: ['html', 'lcovonly'],
+      fixWebpackSourcePaths: true
+    },
+    reporters: ['progress', 'kjhtml'],
+    port: 9876,
+    colors: true,
+    logLevel: config.LOG_INFO,
+    autoWatch: true,
+    browsers: ['Chrome'],
+    singleRun: false
+  });
+};
\ No newline at end of file
diff --git a/apps/faultmanagement/fm-gui2-lib/src/main.ts b/apps/faultmanagement/fm-gui2-lib/src/main.ts
new file mode 100644
index 0000000..91ec6da
--- /dev/null
+++ b/apps/faultmanagement/fm-gui2-lib/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.log(err));
diff --git a/apps/faultmanagement/fm-gui2-lib/src/polyfills.ts b/apps/faultmanagement/fm-gui2-lib/src/polyfills.ts
new file mode 100644
index 0000000..d310405
--- /dev/null
+++ b/apps/faultmanagement/fm-gui2-lib/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/docs/ts/latest/guide/browser-support.html
+ */
+
+/***************************************************************************************************
+ * 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';
+
+/** 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';
+
+
+/** Evergreen browsers require these. **/
+// Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove.
+import 'core-js/es7/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/apps/faultmanagement/fm-gui2-lib/src/styles.css b/apps/faultmanagement/fm-gui2-lib/src/styles.css
new file mode 100644
index 0000000..90d4ee0
--- /dev/null
+++ b/apps/faultmanagement/fm-gui2-lib/src/styles.css
@@ -0,0 +1 @@
+/* You can add global styles to this file, and also import other style files */
diff --git a/apps/faultmanagement/fm-gui2-lib/src/test.ts b/apps/faultmanagement/fm-gui2-lib/src/test.ts
new file mode 100644
index 0000000..1631789
--- /dev/null
+++ b/apps/faultmanagement/fm-gui2-lib/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);
diff --git a/apps/faultmanagement/fm-gui2-lib/src/tsconfig.app.json b/apps/faultmanagement/fm-gui2-lib/src/tsconfig.app.json
new file mode 100644
index 0000000..722c370
--- /dev/null
+++ b/apps/faultmanagement/fm-gui2-lib/src/tsconfig.app.json
@@ -0,0 +1,12 @@
+{
+  "extends": "../tsconfig.json",
+  "compilerOptions": {
+    "outDir": "../out-tsc/app",
+    "module": "es2015",
+    "types": []
+  },
+  "exclude": [
+    "src/test.ts",
+    "**/*.spec.ts"
+  ]
+}
diff --git a/apps/faultmanagement/fm-gui2-lib/src/tsconfig.spec.json b/apps/faultmanagement/fm-gui2-lib/src/tsconfig.spec.json
new file mode 100644
index 0000000..8f7cede
--- /dev/null
+++ b/apps/faultmanagement/fm-gui2-lib/src/tsconfig.spec.json
@@ -0,0 +1,19 @@
+{
+  "extends": "../tsconfig.json",
+  "compilerOptions": {
+    "outDir": "../out-tsc/spec",
+    "module": "commonjs",
+    "types": [
+      "jasmine",
+      "node"
+    ]
+  },
+  "files": [
+    "test.ts",
+    "polyfills.ts"
+  ],
+  "include": [
+    "**/*.spec.ts",
+    "**/*.d.ts"
+  ]
+}
diff --git a/apps/faultmanagement/fm-gui2-lib/src/tslint.json b/apps/faultmanagement/fm-gui2-lib/src/tslint.json
new file mode 100644
index 0000000..52e2c1a
--- /dev/null
+++ b/apps/faultmanagement/fm-gui2-lib/src/tslint.json
@@ -0,0 +1,17 @@
+{
+    "extends": "../tslint.json",
+    "rules": {
+        "directive-selector": [
+            true,
+            "attribute",
+            "app",
+            "camelCase"
+        ],
+        "component-selector": [
+            true,
+            "element",
+            "app",
+            "kebab-case"
+        ]
+    }
+}