Added native Bazel build to GUI2. Reduced a lot of the unused Angular CLI structures
Reviewers should look at the changes in WORKSPACE, BUILD, BUILD.bazel, README.md files
This is only possible now as rules_nodejs went to 1.0.0 on December 20
gui2 has now been made the entry point (rather than gui2-fw-lib)
No tests or linting are functional yet for Typescript
Each NgModule now has its own BUILD.bazel file with ng_module
gui2-fw-lib is all one module and has been refactored to simplify the directory structure
gui2-topo-lib is also all one module - its directory structure has had 3 layers removed
The big bash script in web/gui2/BUILD has been removed - all is done through ng_module rules
in web/gui2/src/main/webapp/BUILD.bazel and web/gui2/src/main/webapp/app/BUILD.bazel
Change-Id: Ifcfcc23a87be39fe6d6c8324046cc8ebadb90551
diff --git a/apps/faultmanagement/fm-gui2-lib/lib/alarmdetails/alarmdetails.component.css b/apps/faultmanagement/fm-gui2-lib/lib/alarmdetails/alarmdetails.component.css
new file mode 100644
index 0000000..97cfc46
--- /dev/null
+++ b/apps/faultmanagement/fm-gui2-lib/lib/alarmdetails/alarmdetails.component.css
@@ -0,0 +1,96 @@
+/*
+ * 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.
+ */
+
+/* css for alarm details table view */
+
+/* Panel Styling */
+#ov-alarm-table-item-details-panel.floatpanel {
+ z-index: 0;
+ font-size: 10pt;
+ top: 185px;
+}
+
+#ov-alarm-table-item-details-panel .container {
+ padding: 0 30px;
+}
+
+#ov-alarm-table-item-details-panel .close-btn {
+ position: absolute;
+ right:5px;
+ top: 5px;
+ cursor: pointer;
+}
+
+.light #ov-alarm-table-item-details-panel.floatpanel {
+ background-color: rgb(229, 234, 237);
+}
+.dark #ov-alarm-table-item-details-panel.floatpanel {
+ background-color: #3A4042;
+}
+
+#ov-alarm-table-item-details-panel h2 {
+ display: inline-block;
+ margin: 8px 0;
+ font-weight: bold;
+ font-size: 16pt;
+}
+
+#ov-alarm-table-item-details-panel h3 {
+ margin: 0;
+ font-size: large;
+}
+
+#ov-alarm-table-item-details-panel h4 {
+ margin: 0;
+}
+
+#ov-alarm-table-item-details-panel td {
+ padding: 5px;
+}
+#ov-alarm-table-item-details-panel td.label {
+ font-weight: bold;
+ text-align: right;
+ padding-right: 6px;
+}
+
+
+@keyframes blinker {
+ 50% {
+ opacity: 0;
+ }
+}
+
+td.severity.CRITICAL {
+ background-color: #c72930;
+ color: white;
+ font-weight: bold;
+ animation: blinker 1s linear infinite;
+}
+
+td.severity.MAJOR {
+ background-color: #db7773;
+ color: white;
+ font-weight: bold;
+}
+
+td.severity.MINOR {
+ background-color: #007dc4;
+ color: white;
+}
+
+td.severity.WARNING {
+ background-color: #87d6f9;
+}
diff --git a/apps/faultmanagement/fm-gui2-lib/lib/alarmdetails/alarmdetails.component.html b/apps/faultmanagement/fm-gui2-lib/lib/alarmdetails/alarmdetails.component.html
new file mode 100644
index 0000000..15e7ea4
--- /dev/null
+++ b/apps/faultmanagement/fm-gui2-lib/lib/alarmdetails/alarmdetails.component.html
@@ -0,0 +1,82 @@
+<!--
+~ 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="ov-alarm-table-item-details-panel" class="floatpanel" [@alarmDetailsState]="id!=='' && !closed">
+ <div class="container">
+ <div class="top">
+ <div class="close-btn">
+ <onos-icon class="close-btn" classes="active-close" iconId="close" iconSize="20" (click)="close()"></onos-icon>
+ </div>
+ <h2 class="editable clickable">{{detailsData.id}}</h2>
+ <div class="top-content">
+ <div class="top-tables">
+ <div class="left">
+ <table>
+ <tbody>
+ <tr>
+ <td class="label" width="110">Description:</td>
+ <td class="value" width="80">{{detailsData.alarmDesc}}</td>
+ </tr>
+ <tr>
+ <td class="label" width="110">Device ID :</td>
+ <td class="value" width="80">{{detailsData.alarmDeviceId}}</td>
+ </tr>
+ <tr>
+ <td class="label" width="110">Alarm source :</td>
+ <td class="value" width="80">{{detailsData.alarmSource}}</td>
+ </tr>
+ <tr>
+ <td class="label" width="110">Time raised :</td>
+ <td class="value" width="80">{{detailsData.alarmTimeRaised}}</td>
+ </tr>
+ <tr>
+ <td class="label" width="110">Time updated :</td>
+ <td class="value" width="80">{{detailsData.alarmTimeUpdated}}</td>
+ </tr>
+ <tr>
+ <td class="label" width="110">Cleared :</td>
+ <td class="value" width="80">{{detailsData.alarmCleared}}</td>
+ </tr>
+ <tr>
+ <td class="label" width="110">Time cleared :</td>
+ <td class="value" width="80">{{detailsData.alarmTimeCleared}}</td>
+ </tr>
+ <tr>
+ <td class="label" width="110">Severity :</td>
+ <td width="80" [ngClass]="[detailsData.alarmSeverity ? detailsData.alarmSeverity:'', 'severity', 'value']">{{detailsData.alarmSeverity}}</td>
+ </tr>
+ <hr>
+ <tr>
+ <td class="label" width="110">Service affecting :</td>
+ <td class="value" width="80">{{detailsData.alarmServiceAffecting}}</td>
+ </tr>
+ <tr>
+ <td class="label" width="110">Acknowledged :</td>
+ <td class="value" width="80">{{detailsData.alarmAcknowledged}}</td>
+ </tr>
+ <tr>
+ <td class="label" width="110">Assigned User :</td>
+ <td class="value" width="80">{{detailsData.alarmAssignedUser}}</td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+ </div>
+ </div>
+ <hr>
+ </div>
+ </div>
+</div>
diff --git a/apps/faultmanagement/fm-gui2-lib/lib/alarmdetails/alarmdetails.component.spec.ts b/apps/faultmanagement/fm-gui2-lib/lib/alarmdetails/alarmdetails.component.spec.ts
new file mode 100644
index 0000000..004617e
--- /dev/null
+++ b/apps/faultmanagement/fm-gui2-lib/lib/alarmdetails/alarmdetails.component.spec.ts
@@ -0,0 +1,100 @@
+/*
+ * 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 { AlarmDetailsComponent } from './alarmdetails.component';
+import { ActivatedRoute, Params } from '@angular/router';
+import { of } from 'rxjs/index';
+import {
+ FnService,
+ IconService,
+ LogService,
+ WebSocketService,
+ IconComponent
+} from '../../../../../web/gui2-fw-lib/public_api';
+
+import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
+import { DebugElement } from '@angular/core';
+import { By } from '@angular/platform-browser';
+import { } from 'jasmine';
+
+class MockActivatedRoute extends ActivatedRoute {
+ constructor(params: Params) {
+ super();
+ this.queryParams = of(params);
+ }
+}
+
+class MockIconService {
+ classes = 'active-close';
+ loadIconDef() { }
+}
+
+class MockWebSocketService {
+ createWebSocket() { }
+ isConnected() { return false; }
+ unbindHandlers() { }
+ bindHandlers() { }
+}
+
+describe('AlarmDetailsComponent', () => {
+ let fs: FnService;
+ let ar: MockActivatedRoute;
+ let windowMock: Window;
+ let logServiceSpy: jasmine.SpyObj<LogService>;
+ let component: AlarmDetailsComponent;
+ let fixture: ComponentFixture<AlarmDetailsComponent>;
+
+ beforeEach(async(() => {
+ const logSpy = jasmine.createSpyObj('LogService', ['info', 'debug', 'warn', 'error']);
+ ar = new MockActivatedRoute({ 'debug': 'panel' });
+ windowMock = <any>{
+ location: <any>{
+ hostname: 'foo',
+ host: 'foo',
+ port: '80',
+ protocol: 'http',
+ search: { debug: 'true' },
+ href: 'ws://foo:123/onos/ui/websock/path',
+ absUrl: 'ws://foo:123/onos/ui/websock/path'
+ }
+ };
+ fs = new FnService(ar, logSpy, windowMock);
+
+ TestBed.configureTestingModule({
+ imports: [BrowserAnimationsModule],
+ declarations: [ AlarmDetailsComponent, IconComponent ],
+ providers: [
+ { provide: FnService, useValue: fs },
+ { provide: IconService, useClass: MockIconService },
+ { provide: LogService, useValue: logSpy },
+ { provide: WebSocketService, useClass: MockWebSocketService },
+ { provide: 'Window', useValue: windowMock },
+ ]
+ })
+ .compileComponents();
+ logServiceSpy = TestBed.get(LogService);
+ }));
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(AlarmDetailsComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/apps/faultmanagement/fm-gui2-lib/lib/alarmdetails/alarmdetails.component.ts b/apps/faultmanagement/fm-gui2-lib/lib/alarmdetails/alarmdetails.component.ts
new file mode 100644
index 0000000..bcbb704
--- /dev/null
+++ b/apps/faultmanagement/fm-gui2-lib/lib/alarmdetails/alarmdetails.component.ts
@@ -0,0 +1,101 @@
+/*
+ * 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, Input, OnInit, OnDestroy, OnChanges } from '@angular/core';
+import { trigger, state, style, animate, transition } from '@angular/animations';
+import {
+ FnService,
+ IconService,
+ LogService,
+ DetailsPanelBaseImpl,
+ WebSocketService,
+} from '../../../../../web/gui2-fw-lib/public_api';
+
+/**
+ * ONOS GUI -- Alarm Details Component extends TableBaseImpl
+ * The details view when an alarm row is clicked from the Alarm view
+ *
+ * This is expected to be passed an 'id' and it makes a call
+ * to the WebSocket with an alarmDetailsRequest, and gets back an
+ * alarmDetailsResponse.
+ *
+ * The animated fly-in is controlled by the animation below
+ * The alarmDetailsState is attached to alarm-details-panel
+ * and is false (flies out) when id='' and true (flies in) when
+ * id has a value
+ */
+@Component({
+ selector: 'onos-alarmdetails',
+ templateUrl: './alarmdetails.component.html',
+ styleUrls: ['./alarmdetails.component.css',
+ '../../../../../web/gui2-fw-lib/lib/widget/panel.css',
+ '../../../../../web/gui2-fw-lib/lib/widget/panel-theme.css'
+ ],
+ animations: [
+ trigger('alarmDetailsState', [
+ 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 AlarmDetailsComponent extends DetailsPanelBaseImpl implements OnInit, OnDestroy, OnChanges {
+ @Input() id: string;
+
+ constructor(
+ protected fs: FnService,
+ protected log: LogService,
+ protected is: IconService,
+ protected wss: WebSocketService
+ ) {
+ super(fs, log, wss, 'alarmTable');
+ }
+
+ ngOnInit() {
+ this.init();
+ this.log.debug('Alarm Table Details Component initialized:', this.id);
+ }
+
+ /**
+ * Stop listening to alarmTableDetailsResponse on WebSocket
+ */
+ ngOnDestroy() {
+ this.destroy();
+ this.log.debug('Alarm Table Details Component destroyed');
+ }
+
+ /**
+ * Details Panel Data Request on row selection changes
+ * Should be called whenever id changes
+ * If id is empty, no request is made
+ */
+ ngOnChanges() {
+ if (this.id === '') {
+ return '';
+ } else {
+ const query = {
+ 'id': this.id
+ };
+ this.requestDetailsPanelData(query);
+ }
+ }
+}
diff --git a/apps/faultmanagement/fm-gui2-lib/lib/alarmtable/alarmtable.component.css b/apps/faultmanagement/fm-gui2-lib/lib/alarmtable/alarmtable.component.css
new file mode 100644
index 0000000..2ec51bf
--- /dev/null
+++ b/apps/faultmanagement/fm-gui2-lib/lib/alarmtable/alarmtable.component.css
@@ -0,0 +1,77 @@
+/*
+ * 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.
+ */
+
+/* css for alarm table view */
+#ov-alarm-table .tabular-header {
+ text-align: left;
+}
+
+#ov-alarm-table h2 {
+ display: inline-block;
+}
+
+#ov-alarm-table div.summary-list .table-header td {
+ font-weight: bold;
+ font-variant: small-caps;
+ text-transform: uppercase;
+ font-size: 10pt;
+ padding-top: 8px;
+ padding-bottom: 8px;
+ letter-spacing: 0.02em;
+ cursor: pointer;
+ background-color: #e5e5e6;
+ color: #3c3a3a;
+}
+
+#ov-alarm-table div.summary-list .table-body {
+ overflow:scroll;
+}
+
+#ov-alarm-table, div.ctrl-btns {
+}
+
+#ov-alarm-table th, td {
+ text-align: left;
+ padding: 8px;
+}
+
+@keyframes blinker {
+ 50% {
+ opacity: 0;
+ }
+}
+
+td.severity.CRITICAL {
+ background-color: #c72930;
+ color: white;
+ font-weight: bold;
+ animation: blinker 1s linear infinite;
+}
+
+td.severity.MAJOR {
+ background-color: #db7773;
+ color: white;
+ font-weight: bold;
+}
+
+td.severity.MINOR {
+ background-color: #007dc4;
+ color: white;
+}
+
+td.severity.WARNING {
+ background-color: #87d6f9;
+}
diff --git a/apps/faultmanagement/fm-gui2-lib/lib/alarmtable/alarmtable.component.html b/apps/faultmanagement/fm-gui2-lib/lib/alarmtable/alarmtable.component.html
new file mode 100644
index 0000000..da4ad92
--- /dev/null
+++ b/apps/faultmanagement/fm-gui2-lib/lib/alarmtable/alarmtable.component.html
@@ -0,0 +1,101 @@
+<!--
+~ 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="ov-alarm-table">
+ <onos-loading [theme]="'light'" [running]="loadingIconShown"></onos-loading>
+ <div class="tabular-header">
+ <h2>Alarms for {{ devId ? devId : "all devices" }} ({{ tableData.length }} total)</h2>
+ <div class="ctrl-btns">
+ <div class="refresh" (click)="toggleRefresh()">
+ <!-- See icon.theme.css for the defintions of the classes active and refresh-->
+ <onos-icon classes="{{ autoRefresh?'active refresh':'refresh' }}"
+ iconId="refresh" iconSize="36"
+ toolTip="{{ autoRefreshTip }}"></onos-icon>
+ </div>
+ <div class="separator"></div>
+ <!--div (click)="(!!selId) ? confirmAction(AlarmActionEnum.ACKNOWLEDGE) : ''">
+ <onos-icon classes="{{ ctrlBtnState.acknowledged?'active-rect play':'play' }}"
+ iconId="play" iconSize="42" toolTip="{{ acknowledgeTip }}"></onos-icon>
+ </div>
+ <div (click)="(!!selId) ? confirmAction(AlarmActionEnum.CLEAR) : ''">
+ <onos-icon classes="{{ ctrlBtnState.cleared?'active-rect stop':'stop' }}"
+ iconId="stop" iconSize="42" toolTip="{{ clearTip }}"></onos-icon>
+ </div-->
+ </div>
+ </div>
+
+ <div class="summary-list" class="summary-list" onosTableResize>
+ <div class="table-header">
+ <table>
+ <tr>
+ <td colId="alarmId" (click)="onSort('id')">Alarm Id
+ <onos-icon classes="active-sort" [iconSize]="10"
+ [iconId]="sortIcon('id')"></onos-icon>
+ </td>
+ <td colId="alarmDeviceId" (click)="onSort('alarmDeviceId')">Device
+ <onos-icon classes="active-sort" [iconSize]="10"
+ [iconId]="sortIcon('alarmDeviceId')"></onos-icon>
+ </td>
+ <td colId="alarmDesc" (click)="onSort('alarmDesc')">Description
+ <onos-icon classes="active-sort" [iconSize]="10"
+ [iconId]="sortIcon('alarmDesc')"></onos-icon>
+ </td>
+ <td colId="alarmSource" (click)="onSort('alarmSource')">Source
+ <onos-icon classes="active-sort" [iconSize]="10"
+ [iconId]="sortIcon('alarmSource')"></onos-icon>
+ </td>
+ <td colId="alarmTimeRaised" (click)="onSort('alarmTimeRaised')">Time
+ Raised
+ <onos-icon classes="active-sort" [iconSize]="10"
+ [iconId]="sortIcon('alarmTimeRaised')"></onos-icon>
+ </td>
+ <td colId="alarmSeverity" (click)="onSort('alarmSeverity')">Severity
+ <onos-icon classes="active-sort" [iconSize]="10"
+ [iconId]="sortIcon('alarmSeverity')"></onos-icon>
+ </td>
+ <td colId="alarmAcknowledged" class="table-icon"
+ (click)="onSort('alarmAcknowledged')">Ack
+ <onos-icon classes="active-sort" [iconSize]="10"
+ [iconId]="sortIcon('alarmAcknowledged')"></onos-icon>
+ </td>
+ </tr>
+ </table>
+ </div>
+
+ <div class="table-body">
+ <table>
+ <tr class="table-body" *ngIf="tableData.length === 0" class="no-data">
+ <td colspan="9">{{ annots.noRowsMsg }}</td>
+ </tr>
+ <tr *ngFor="let item of tableData | filter : tableDataFilter"
+ (click)="selectCallback($event, item)"
+ [ngClass]="{selected: item.id === selId, 'data-change': isChanged(item.id)}">
+ <td>{{ item.id }}</td>
+ <td>{{ item.alarmDeviceId }}</td>
+ <td>{{ item.alarmDesc }}</td>
+ <td>{{ item.alarmSource }}</td>
+ <td>{{ item.alarmTimeRaised }}</td>
+ <td [ngClass]="[item.alarmSeverity, 'severity']">{{ item.alarmSeverity }}</td>
+ <td class="table-icon">
+ <onos-icon [iconId]="ackIcon(item.alarmAcknowledged)"></onos-icon>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </div>
+
+ <onos-alarmdetails class="floatpanels" id="{{ selId }}"
+ (closeEvent)="deselectRow($event)"></onos-alarmdetails>
+</div>
diff --git a/apps/faultmanagement/fm-gui2-lib/lib/alarmtable/alarmtable.component.spec.ts b/apps/faultmanagement/fm-gui2-lib/lib/alarmtable/alarmtable.component.spec.ts
new file mode 100644
index 0000000..ba36a98
--- /dev/null
+++ b/apps/faultmanagement/fm-gui2-lib/lib/alarmtable/alarmtable.component.spec.ts
@@ -0,0 +1,96 @@
+/*
+ * 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 { ActivatedRoute, Params } from '@angular/router';
+import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
+import { FormsModule } from '@angular/forms';
+import { AlarmTableComponent } from './alarmtable.component';
+import { AlarmDetailsComponent } from '../alarmdetails/alarmdetails.component';
+import {
+ FnService,
+ IconService,
+ IconComponent,
+ LogService,
+ TableFilterPipe, LoadingComponent,
+} from '../../../../../web/gui2-fw-lib/public_api';
+
+import { of } from 'rxjs';
+import { } from 'jasmine';
+import { RouterTestingModule } from '@angular/router/testing';
+
+class MockActivatedRoute extends ActivatedRoute {
+ constructor(params: Params) {
+ super();
+ this.queryParams = of(params);
+ }
+}
+
+class MockIconService {
+ loadIconDef() { }
+}
+
+describe('AlarmTableComponent', () => {
+ let fs: FnService;
+ let ar: MockActivatedRoute;
+ let windowMock: Window;
+ let logServiceSpy: jasmine.SpyObj<LogService>;
+ let component: AlarmTableComponent;
+ let fixture: ComponentFixture<AlarmTableComponent>;
+
+ beforeEach(async(() => {
+ const logSpy = jasmine.createSpyObj('LogService', ['info', 'debug', 'warn', 'error']);
+ ar = new MockActivatedRoute({ 'debug': 'txrx' });
+
+ windowMock = <any>{
+ location: <any>{
+ hostname: 'foo',
+ host: 'foo',
+ port: '80',
+ protocol: 'http',
+ search: { debug: 'true' },
+ href: 'ws://foo:123/onos/ui/websock/path',
+ absUrl: 'ws://foo:123/onos/ui/websock/path'
+ }
+ };
+ fs = new FnService(ar, logSpy, windowMock);
+
+ TestBed.configureTestingModule({
+ imports: [BrowserAnimationsModule, FormsModule, RouterTestingModule],
+ declarations: [
+ AlarmTableComponent, AlarmDetailsComponent,
+ IconComponent, TableFilterPipe, LoadingComponent
+ ],
+ providers: [
+ { provide: FnService, useValue: fs },
+ { provide: LogService, useValue: logSpy },
+ { provide: IconService, useClass: MockIconService },
+ { provide: 'Window', useValue: windowMock },
+ ]
+ })
+ .compileComponents();
+ logServiceSpy = TestBed.get(LogService);
+ }));
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(AlarmTableComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/apps/faultmanagement/fm-gui2-lib/lib/alarmtable/alarmtable.component.ts b/apps/faultmanagement/fm-gui2-lib/lib/alarmtable/alarmtable.component.ts
new file mode 100644
index 0000000..9d50e11
--- /dev/null
+++ b/apps/faultmanagement/fm-gui2-lib/lib/alarmtable/alarmtable.component.ts
@@ -0,0 +1,186 @@
+/*
+ * 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, Input, Inject, OnInit, OnDestroy } from '@angular/core';
+import { ActivatedRoute } from '@angular/router';
+import {
+ FnService,
+ LogService,
+ WebSocketService,
+ SortDir, TableBaseImpl, TableResponse
+} from '../../../../../web/gui2-fw-lib/public_api';
+
+/**
+ * Model of the response from the WebSocket
+ */
+export interface AlarmTableResponse extends TableResponse {
+ alarmTables: Alarm[];
+}
+
+/**
+ * Model of the alarms returned from the WebSocket
+ */
+export interface Alarm {
+ id: string;
+ alarmDesc: string;
+ alarmDeviceId: string;
+ alarmSource: string;
+ alarmTimeRaised: string;
+ alarmTimeUpdated: string;
+ alarmTimeCleared: string;
+ alarmSeverity: string;
+}
+
+export enum AlarmAction {
+ NONE = 0,
+ ACKNOWLEDGE = 1,
+ CLEAR = 2,
+}
+
+/**
+ * Model of the Control Button
+ */
+export interface CtrlBtnState {
+ acknowledged: boolean;
+ cleared: boolean;
+ selection: string;
+}
+
+const ACKNOWLEDGED = 'ACKNOWLEDGED';
+const CLEARED = 'CLEARED';
+
+/**
+* ONOS GUI -- Alarm Table Component extends TableBaseImpl
+*/
+@Component({
+ selector: 'onos-alarmtable',
+ templateUrl: './alarmtable.component.html',
+ styleUrls: ['./alarmtable.component.css',
+ '../../../../../web/gui2-fw-lib/lib/widget//table.css',
+ '../../../../../web/gui2-fw-lib/lib/widget//table.theme.css'
+ ]
+})
+export class AlarmTableComponent extends TableBaseImpl implements OnInit, OnDestroy {
+ devId: string;
+ selRowAlarmId: string;
+ // TODO Add in LION translations
+ acknowledgeTip: string = 'Acknowledge';
+ clearTip: string = 'Clear';
+ AlarmActionEnum: any = AlarmAction;
+ alarmAction: AlarmAction = AlarmAction.NONE;
+ confirmMsg: string = '';
+ ctrlBtnState: CtrlBtnState;
+
+ constructor(
+ private route: ActivatedRoute,
+ @Inject('Window') private w: any,
+ protected log: LogService,
+ protected fs: FnService,
+ protected wss: WebSocketService,
+ ) {
+ super(fs, log, wss, 'alarmTable');
+
+ this.route.queryParams.subscribe(params => {
+ this.devId = params['devId'];
+
+ });
+
+ this.payloadParams = {
+ devId: this.devId
+ };
+
+ this.responseCallback = this.alarmResponseCb;
+
+ this.sortParams = {
+ firstCol: 'alarmTimeRaised',
+ firstDir: SortDir.desc,
+ secondCol: 'alarmDeviceId',
+ secondDir: SortDir.asc,
+ };
+
+ this.ctrlBtnState = <CtrlBtnState>{
+ acknowledged: false,
+ cleared: false
+ };
+ this.log.debug('AlarmTableComponent constructed');
+ }
+
+ ngOnInit() {
+ this.init();
+ this.log.debug('AlarmTableComponent initialized');
+ }
+
+ ngOnDestroy() {
+ this.destroy();
+ this.log.debug('AlarmTableComponent destroyed');
+ }
+
+ alarmResponseCb(data: AlarmTableResponse) {
+ this.log.debug('Alarm response received for ', data.alarmTables.length, 'alarm');
+ }
+
+ rowSelection(event: any, selRow: any) {
+ this.ctrlBtnState.acknowledged = this.selId && selRow && selRow.state === ACKNOWLEDGED;
+ this.ctrlBtnState.cleared = this.selId && selRow && selRow.cleared === CLEARED;
+ this.ctrlBtnState.selection = this.selId;
+ this.selRowAlarmId = selRow.appId;
+ this.log.debug('Row ', this.selId, 'selected', this.ctrlBtnState);
+ }
+
+ /**
+ * Perform one of the alarm actions - acknowledge or clear
+ * Raises a dialog which calls back the dOk() below
+ */
+ confirmAction(action: AlarmAction): void {
+ this.alarmAction = action;
+ const alarmActionLc = (<string>AlarmAction[this.alarmAction]).toLowerCase();
+
+ this.confirmMsg = alarmActionLc + ' ' + this.selId + '?';
+
+ this.log.debug('Initiating', this.alarmAction, 'of', this.selId);
+ }
+
+ /**
+ * Callback when the Confirm dialog is shown and a choice is made
+ */
+ dOk(choice: boolean) {
+ const alarmActionLc = (<string>AlarmAction[this.alarmAction]).toLowerCase();
+ if (choice) {
+ this.log.debug('Confirmed', alarmActionLc, 'on', this.selId);
+
+ /** commented out until backend is implemented
+ this.wss.sendEvent(APPMGMTREQ, {
+ action: alarmActionLc,
+ name: this.selId,
+ sortCol: this.sortParams.firstCol,
+ sortDir: SortDir[this.sortParams.firstDir],
+ });
+
+ this.wss.sendEvent(DETAILSREQ, { id: this.selId });
+ */
+ } else {
+ this.log.debug('Cancelled', alarmActionLc, 'on', this.selId);
+ }
+ this.confirmMsg = '';
+ }
+
+ ackIcon(acknowledged: string): string {
+ if (acknowledged === 'true') {
+ return 'active';
+ } else {
+ return 'appInactive';
+ }
+ }
+}
diff --git a/apps/faultmanagement/fm-gui2-lib/lib/fm-gui2-lib.module.ts b/apps/faultmanagement/fm-gui2-lib/lib/fm-gui2-lib.module.ts
new file mode 100644
index 0000000..85e09b6
--- /dev/null
+++ b/apps/faultmanagement/fm-gui2-lib/lib/fm-gui2-lib.module.ts
@@ -0,0 +1,38 @@
+/*
+ * 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 {NgModule} from '@angular/core';
+import {CommonModule} from '@angular/common';
+import {FormsModule} from '@angular/forms';
+import {RouterModule} from '@angular/router';
+import {
+ Gui2FwLibModule,
+} from '../../../../web/gui2-fw-lib/public_api';
+import {AlarmTableComponent} from './alarmtable/alarmtable.component';
+import {AlarmDetailsComponent} from './alarmdetails/alarmdetails.component';
+
+@NgModule({
+ imports: [
+ CommonModule,
+ FormsModule,
+ RouterModule,
+ RouterModule.forChild([{path: '', component: AlarmTableComponent}]),
+ Gui2FwLibModule
+ ],
+ declarations: [AlarmTableComponent, AlarmDetailsComponent],
+ exports: [AlarmTableComponent, AlarmDetailsComponent],
+})
+export class FmGui2LibModule {
+}