Added the FlashComponent in to GUI 2
Change-Id: I80923759cc70dbd902e478a5ad995621543d29f1
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,