Added the FlashComponent in to GUI 2

Change-Id: I80923759cc70dbd902e478a5ad995621543d29f1
diff --git a/web/gui2/src/main/tslint.json b/web/gui2/src/main/tslint.json
index 0e12d1d..c040afa 100644
--- a/web/gui2/src/main/tslint.json
+++ b/web/gui2/src/main/tslint.json
@@ -60,7 +60,7 @@
     "no-empty-interface": true,
     "no-eval": true,
     "no-inferrable-types": [
-      true,
+      false,
       "ignore-params"
     ],
     "no-misused-new": true,
diff --git a/web/gui2/src/main/webapp/app/fw/layer/flash.service.ts b/web/gui2/src/main/webapp/app/fw/layer/flash.service.ts
deleted file mode 100644
index bd71d28..0000000
--- a/web/gui2/src/main/webapp/app/fw/layer/flash.service.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2015-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 { Injectable } from '@angular/core';
-import { LogService } from '../../log.service';
-
-/**
- * ONOS GUI -- Layer -- Flash Service
- *
- * Provides a mechanism to flash short informational messages to the screen
- * to alert the user of something, e.g. "Hosts visible" or "Hosts hidden".
- */
-@Injectable()
-export class FlashService {
-
-  constructor(
-    private log: LogService
-  ) {
-    this.log.debug('FlashService constructed');
-  }
-
-}
diff --git a/web/gui2/src/main/webapp/app/fw/layer/flash/flash.component.css b/web/gui2/src/main/webapp/app/fw/layer/flash/flash.component.css
new file mode 100644
index 0000000..829d5e2
--- /dev/null
+++ b/web/gui2/src/main/webapp/app/fw/layer/flash/flash.component.css
@@ -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.
+ */
+
+/*
+ ONOS GUI -- Flash Service (layout) -- CSS file
+ */
+
+#flash {
+    z-index: 1400;
+}
+
+#flash svg {
+    /*position: absolute;*/
+    bottom: 0;
+    opacity: 0.8;
+}
+
+#flash svg g.flashItem text {
+    stroke: none;
+    text-anchor: middle;
+    alignment-baseline: middle;
+    font-size: 16pt;
+}
+
+/* Used for temp div */
+.centered {
+    position: fixed;
+    top: 50%;
+    left: 50%;
+    -webkit-transform: translate(-50%, -50%);
+    transform: translate(-50%, -50%);
+    margin: 0;
+    padding: 10px;
+}
diff --git a/web/gui2/src/main/webapp/app/fw/layer/flash/flash.component.html b/web/gui2/src/main/webapp/app/fw/layer/flash/flash.component.html
new file mode 100644
index 0000000..5566013
--- /dev/null
+++ b/web/gui2/src/main/webapp/app/fw/layer/flash/flash.component.html
@@ -0,0 +1,27 @@
+<!--
+~ 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 id="flash">
+    <svg *ngIf="enabled" [attr.width]="width" [attr.height]="height" [attr.viewBox]="vbox" >
+        <g class="flashItem" [@flashState]="enabled?'active':'inactive'">
+            <text #flashtext>{{ message }}</text>
+            <rect [attr.opacity]="0.5" [attr.rx]="rx"
+                      [attr.x]="-flashtext.getBBox().width/2-xpad"
+                      [attr.y]="flashtext.getBBox().y-ypad"
+                      [attr.height]="flashtext.getBBox().height+ypad*2"
+                      [attr.width]="flashtext.getBBox().width+xpad*2"></rect>
+        </g>
+    </svg>
+</div>
\ No newline at end of file
diff --git a/web/gui2/src/main/webapp/app/fw/layer/flash/flash.component.ts b/web/gui2/src/main/webapp/app/fw/layer/flash/flash.component.ts
new file mode 100644
index 0000000..3a70c35
--- /dev/null
+++ b/web/gui2/src/main/webapp/app/fw/layer/flash/flash.component.ts
@@ -0,0 +1,78 @@
+/*
+ * 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';
+import { LogService } from '../../../log.service';
+import { trigger, state, style, animate, transition } from '@angular/animations';
+
+/**
+ * ONOS GUI -- Layer -- Flash Component
+ *
+ * Replaces Flash Service in old GUI.
+ * Provides a mechanism to flash short informational messages to the screen
+ * to alert the user of something, e.g. "Hosts visible" or "Hosts hidden".
+ *
+ * To use add an element to the template like
+ *   <onos-flash #flashComponent (click)="flashComponent.flash('Hosts visible')"></onos-flash>
+ * 1) The (click) can be removed and the call to flash() can be called from anywhere else in the template.
+ * 2) This whole element can be disabled until needed with an ngIf
+ */
+@Component({
+    selector: 'onos-flash',
+    templateUrl: './flash.component.html',
+    styleUrls: ['./flash.component.css'],
+    animations: [
+        trigger('flashState', [
+            state('inactive', style({
+                opacity: '0.0',
+            })),
+            state('active', style({
+                opacity: '1.0',
+            })),
+            transition('inactive => active', animate('200ms ease-in')),
+            transition('active => inactive', animate('200ms ease-out'))
+        ])
+    ]
+})
+export class FlashComponent {
+    public message: string;
+
+    public width: string = '100%';
+    public height: number = 200;
+    public rx: number = 10;
+    public vbox: string = '-200 -' + (this.height / 2) + ' 400 ' + this.height;
+    public xpad: number = 20;
+    public ypad: number = 10;
+    public enabled: boolean = false;
+
+    constructor(
+        private log: LogService,
+    ) {
+        this.log.debug('FlashComponent constructed');
+    }
+
+    /**
+     * Flash a message up for 1200ms then disappear again.
+     * See animation parameter for the ease in and ease out params
+     */
+    flash(message: string): void {
+        this.message = message;
+        this.enabled = true;
+
+        setTimeout(() => {
+            this.enabled = false;
+        }, 1200);
+    }
+}
diff --git a/web/gui2/src/main/webapp/app/fw/layer/layer.module.ts b/web/gui2/src/main/webapp/app/fw/layer/layer.module.ts
index f5923fc..e01b004 100644
--- a/web/gui2/src/main/webapp/app/fw/layer/layer.module.ts
+++ b/web/gui2/src/main/webapp/app/fw/layer/layer.module.ts
@@ -17,10 +17,10 @@
 import { CommonModule } from '@angular/common';
 import { UtilModule } from '../util/util.module';
 
+import { FlashComponent } from './flash/flash.component';
 import { DetailsPanelService } from './detailspanel.service';
 import { DialogService } from './dialog.service';
 import { EditableTextService } from './editabletext.service';
-import { FlashService } from './flash.service';
 import { LoadingService } from './loading.service';
 import { PanelService } from './panel.service';
 import { QuickHelpService } from './quickhelp.service';
@@ -30,15 +30,20 @@
  * ONOS GUI -- Layers Module
  */
 @NgModule({
+  exports: [
+    FlashComponent
+  ],
   imports: [
     CommonModule,
     UtilModule
   ],
+  declarations: [
+    FlashComponent
+  ],
   providers: [
     DetailsPanelService,
     DialogService,
     EditableTextService,
-    FlashService,
     LoadingService,
     PanelService,
     QuickHelpService,
diff --git a/web/gui2/src/main/webapp/app/onos.component.ts b/web/gui2/src/main/webapp/app/onos.component.ts
index a1a84de..02b3a44 100644
--- a/web/gui2/src/main/webapp/app/onos.component.ts
+++ b/web/gui2/src/main/webapp/app/onos.component.ts
@@ -21,7 +21,6 @@
 import { GlyphService } from './fw/svg/glyph.service';
 import { VeilService } from './fw/layer/veil.service';
 import { PanelService } from './fw/layer/panel.service';
-import { FlashService } from './fw/layer/flash.service';
 import { QuickHelpService } from './fw/layer/quickhelp.service';
 import { EeService } from './fw/util/ee.service';
 import { WebSocketService } from './fw/remote/websocket.service';
@@ -84,7 +83,6 @@
         private gs: GlyphService,
         private vs: VeilService,
         private ps: PanelService,
-        private flash: FlashService,
         private qhs: QuickHelpService,
         private ee: EeService,
         private wss: WebSocketService,
diff --git a/web/gui2/src/main/webapp/tests/app/fw/layer/flash.service.spec.ts b/web/gui2/src/main/webapp/tests/app/fw/layer/flash.service.spec.ts
deleted file mode 100644
index 3b0eb3e..0000000
--- a/web/gui2/src/main/webapp/tests/app/fw/layer/flash.service.spec.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2015-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, inject } from '@angular/core/testing';
-
-import { LogService } from '../../../../app/log.service';
-import { ConsoleLoggerService } from '../../../../app/consolelogger.service';
-import { FlashService } from '../../../../app/fw/layer/flash.service';
-
-/**
- * ONOS GUI -- Layer -- Flash Service - Unit Tests
- */
-describe('FlashService', () => {
-    let log: LogService;
-
-    beforeEach(() => {
-        log = new ConsoleLoggerService();
-
-        TestBed.configureTestingModule({
-            providers: [FlashService,
-                { provide: LogService, useValue: log },
-            ]
-        });
-    });
-
-    it('should be created', inject([FlashService], (service: FlashService) => {
-        expect(service).toBeTruthy();
-    }));
-});
diff --git a/web/gui2/src/main/webapp/tests/app/fw/layer/flash/flash.component.spec.ts b/web/gui2/src/main/webapp/tests/app/fw/layer/flash/flash.component.spec.ts
new file mode 100644
index 0000000..53a7ecc
--- /dev/null
+++ b/web/gui2/src/main/webapp/tests/app/fw/layer/flash/flash.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 { async, ComponentFixture, TestBed } from '@angular/core/testing';
+import { ConsoleLoggerService } from '../../../../../app/consolelogger.service';
+import { LogService } from '../../../../../app/log.service';
+import { FlashComponent } from '../../../../../app/fw/layer/flash/flash.component';
+
+/**
+ * ONOS GUI -- Layer -- Flash Component - Unit Tests
+ */
+describe('FlashComponent', () => {
+    let log: LogService;
+
+    beforeEach(() => {
+        log = new ConsoleLoggerService();
+        TestBed.configureTestingModule({
+            declarations: [ FlashComponent ],
+            providers: [
+                { provide: LogService, useValue: log },
+            ]
+        });
+    });
+
+
+    it('should create', () => {
+        const fixture = TestBed.createComponent(FlashComponent);
+        const component = fixture.componentInstance;
+        expect(component).toBeTruthy();
+    });
+});
diff --git a/web/gui2/src/main/webapp/tests/app/onos.component.spec.ts b/web/gui2/src/main/webapp/tests/app/onos.component.spec.ts
index d82bdc2..2831d97 100644
--- a/web/gui2/src/main/webapp/tests/app/onos.component.spec.ts
+++ b/web/gui2/src/main/webapp/tests/app/onos.component.spec.ts
@@ -23,7 +23,6 @@
 import { OnosComponent } from '../../app/onos.component';
 import { DialogService } from '../../app/fw/layer/dialog.service';
 import { EeService } from '../../app/fw/util/ee.service';
-import { FlashService } from '../../app/fw/layer/flash.service';
 import { GlyphService } from '../../app/fw/svg/glyph.service';
 import { IconService } from '../../app/fw/svg/icon.service';
 import { KeyService } from '../../app/fw/util/key.service';
@@ -41,8 +40,6 @@
 
 class MockEeService {}
 
-class MockFlashService {}
-
 class MockGlyphService {}
 
 class MockIconService {}
@@ -88,7 +85,6 @@
                 { provide: ChildrenOutletContexts, useClass: ChildrenOutletContexts },
                 { provide: DialogService, useClass: MockDialogService },
                 { provide: EeService, useClass: MockEeService },
-                { provide: FlashService, useClass: MockFlashService },
                 { provide: GlyphService, useClass: MockGlyphService },
                 { provide: IconService, useClass: MockIconService },
                 { provide: KeyService, useClass: MockKeyService },