[ONOS-7995] upgrade roadm custom view from GUI to GUI2
1. [Finished] Optical-related device view
2. [Finished] Port view
3. [Finished] Power config on Port view (Private implementation)
4. [Finished] Protocol view for TAPI device
Change-Id: Ie9b81cfa9991a7af2dd485a5df3fe582df830d27
Signed-off-by: Boyuan Yan <boyuan@opennetworking.org>
diff --git a/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/karma.conf.js b/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/karma.conf.js
new file mode 100644
index 0000000..4c5f8d0
--- /dev/null
+++ b/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/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
+ });
+};
diff --git a/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/ng-package.json b/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/ng-package.json
new file mode 100644
index 0000000..a085aff
--- /dev/null
+++ b/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/ng-package.json
@@ -0,0 +1,7 @@
+{
+ "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
+ "dest": "../../dist/roadm-gui-lib",
+ "lib": {
+ "entryFile": "src/public_api.ts"
+ }
+}
\ No newline at end of file
diff --git a/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/package.json b/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/package.json
new file mode 100644
index 0000000..e7bc367
--- /dev/null
+++ b/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/package.json
@@ -0,0 +1,19 @@
+{
+ "name": "roadm-gui-lib",
+ "version": "1.0.0",
+ "description": "ONOS roadm GUI",
+ "keywords": "ONOS SDN Controller ONF Open Networking Foundation",
+ "homepage": "https://onosproject.org/",
+ "bugs": "support@opennetworking.org",
+ "license": "Apache-2.0",
+ "repository": {
+ "type" : "git",
+ "url" : "https://github.com/opennetworkinglab/onos.git"
+ },
+ "peerDependencies": {
+ "@angular/common": "^7.0.0",
+ "@angular/core": "^7.0.0",
+ "gui2-fw-lib": "^2.1.1",
+ "d3": "^5.9.2"
+ }
+}
diff --git a/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/src/lib/port/port.component.css b/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/src/lib/port/port.component.css
new file mode 100644
index 0000000..00e195a
--- /dev/null
+++ b/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/src/lib/port/port.component.css
@@ -0,0 +1,88 @@
+/* css for ROADM port table view */
+
+#ov-roadm-port h2 {
+ display: inline-block;
+}
+
+/* Panel Styling */
+#ov-roadm-port-item-details-panel.floatpanel {
+ position: absolute;
+ top: 115px;
+}
+
+.light #ov-roadm-port-item-details-panel.floatpanel {
+ background-color: rgb(229, 234, 237);
+}
+.dark #ov-roadm-port-item-details-panel.floatpanel {
+ background-color: #3A4042;
+}
+
+#ov-roadm-port-item-details-panel h3 {
+ margin: 0;
+ font-size: large;
+}
+
+#ov-roadm-port-item-details-panel h4 {
+ margin: 0;
+}
+
+#ov-roadm-port-item-details-panel td {
+ padding: 5px;
+}
+
+#ov-roadm-port-item-details-panel td.label {
+ font-style: italic;
+ opacity: 0.8;
+}
+
+#ov-roadm-port .table-header span.units {
+ font-variant: normal;
+ text-transform: none;
+}
+
+/* Editable Target Power field */
+#ov-roadm-port .editable span {
+ width: 100%;
+ display: inline-block;
+}
+
+#ov-roadm-port .editable span.target-power:hover {
+ color: #009fdb
+}
+
+#ov-roadm-port .editable input {
+ padding: 0;
+}
+#ov-roadm-port .editable button {
+ margin: 0;
+ padding: 0px 5px 0px 5px;
+}
+
+#ov-roadm-port .editable input {
+ width: 80px;
+}
+
+#ov-roadm-port .editable .input-error {
+ color: red;
+ font-size: 10px;
+ width: 180px;
+}
+
+#ov-roadm-port .mode-select .mode-title {
+ margin: 0;
+ font-weight:bold;
+ font-size: 16px;
+}
+
+#ov-roadm-port .mode-select .mode-fail {
+ color: red;
+ font-size: 10px;
+}
+
+#ov-roadm-port .mode-select select {
+ width: 250px;
+}
+
+#ov-roadm-port .mode-select button {
+ width: 100px;
+}
\ No newline at end of file
diff --git a/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/src/lib/port/port.component.html b/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/src/lib/port/port.component.html
new file mode 100644
index 0000000..2a001ef
--- /dev/null
+++ b/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/src/lib/port/port.component.html
@@ -0,0 +1,137 @@
+<!--
+~ 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.
+-->
+<!-- Port partial HTML -->
+<div id="ov-roadm-port">
+ <onos-loading [theme]="'light'" [running]="loadingIconShown"></onos-loading>
+ <div class="tabular-header">
+ <h2>
+ Ports for Roadm Device {{devId}} ({{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="42" toolTip="{{ autoRefreshTip }}"></onos-icon>
+ </div>
+
+ <div class="separator"></div>
+
+ <div routerLink="/roadm-gui" [queryParams]="{ devId: devId }" routerLinkActive="active">
+ <onos-icon classes="{{ devId ? 'active-rect':undefined }}" iconId="deviceTable" iconSize="42" toolTip="{{deviceTip}}"></onos-icon>
+ </div>
+
+ <!--<div routerLink="/flow" [queryParams]="{ devId: devId }" routerLinkActive="active">-->
+ <!--<onos-icon classes="{{ devId ? 'active-rect' :undefined}}" iconId="flowTable" iconSize="42" toolTip="{{ flowTip }}"></onos-icon>-->
+ <!--</div>-->
+
+ <div>
+ <onos-icon classes="{{ devId ? 'current-view' :undefined}}" iconId="portTable" iconSize="42"></onos-icon>
+ </div>
+
+ </div>
+
+ <div class="search">
+ <input id="searchinput" [(ngModel)]="tableDataFilter.queryStr" type="search" #search placeholder="Search" />
+ <select [(ngModel)]="tableDataFilter.queryBy">
+ <option value="" disabled>Search By</option>
+ <option value="$">All Fields</option>
+ <option value="id">Port ID</option>
+ <option value="name">Pkts Received</option>
+ <option value="type">Pkts Sent</option>
+ <option value="enabled">Bytes Received</option>
+ <option value="grid">Bytes Sent</option>
+ <option value="hasTargetPower">Pkts RX Dropped</option>
+ </select>
+ </div>
+ </div>
+
+ <div class="summary-list" onosTableResize>
+ <div class="table-header">
+ <table>
+ <tr>
+ <td colId="id" (click)="onSort('id')">Port ID
+ <onos-icon classes="active-sort" [iconSize]="10" [iconId]="sortIcon('id')"></onos-icon>
+ </td>
+ <td colId="reversePort" (click)="onSort('reversePort')">Reverse Port
+ <onos-icon classes="active-sort" [iconSize]="10" [iconId]="sortIcon('reversePort')"></onos-icon>
+ </td>
+ <td colId="name" (click)="onSort('name')">Name
+ <onos-icon classes="active-sort" [iconSize]="10" [iconId]="sortIcon('name')"></onos-icon>
+ </td>
+ <td colId="type" (click)="onSort('type')">Type
+ <onos-icon classes="active-sort" [iconSize]="10" [iconId]="sortIcon('type')"></onos-icon>
+ </td>
+ <td colId="enabled" (click)="onSort('enabled')">Enabled
+ <onos-icon classes="active-sort" [iconSize]="10" [iconId]="sortIcon('enabled')"></onos-icon>
+ </td>
+ <td colId="minFreq" (click)="onSort('minFreq')">Min Freq (GHz)
+ <onos-icon classes="active-sort" [iconSize]="10" [iconId]="sortIcon('minFreq')"></onos-icon>
+ </td>
+ <td colId="maxFreq" (click)="onSort('maxFreq')">Max Freq (GHz)
+ <onos-icon classes="active-sort" [iconSize]="10" [iconId]="sortIcon('maxFreq')"></onos-icon>
+ </td>
+ <td colId="grid" (click)="onSort('grid')">Grid (GHz)
+ <onos-icon classes="active-sort" [iconSize]="10" [iconId]="sortIcon('grid')"></onos-icon>
+ </td>
+ <td colId="powerRange" (click)="onSort('powerRange')">Power Range (dBm)
+ <onos-icon classes="active-sort" [iconSize]="10" [iconId]="sortIcon('powerRange')"></onos-icon>
+ </td>
+ <td colId="currentPower" (click)="onSort('currentPower')">Current Power (dBm)
+ <onos-icon classes="active-sort" [iconSize]="10" [iconId]="sortIcon('currentPower')"></onos-icon>
+ </td>
+ <td colId="targetPower" (click)="onSort('targetPower')">Target Power (dBm)
+ <onos-icon classes="active-sort" [iconSize]="10" [iconId]="sortIcon('targetPower')"></onos-icon>
+ </td>
+ <td colId="hasTargetPower" (click)="onSort('hasTargetPower')">Has Target Power
+ <onos-icon classes="active-sort" [iconSize]="10" [iconId]="sortIcon('hasTargetPower')"></onos-icon>
+ </td>
+ <td colId="serviceState" (click)="onSort('serviceState')">Service State
+ <onos-icon classes="active-sort" [iconSize]="10" [iconId]="sortIcon('serviceState')"></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 port of tableData | filter : tableDataFilter" (click)="selectCallback($event, port)" [ngClass]="{selected: port.id === selId, 'data-change': isChanged(port.id)}">
+ <td>{{port.id}}</td>
+ <td [ngClass]="(isDelta() ? 'delta' : '')">{{port.reversePort}}</td>
+ <td [ngClass]="(isDelta() ? 'delta' : '')">{{port.name}}</td>
+ <td [ngClass]="(isDelta() ? 'delta' : '')">{{port.type}}</td>
+ <td [ngClass]="(isDelta() ? 'delta' : '')">{{port.enabled}}</td>
+ <td [ngClass]="(isDelta() ? 'delta' : '')">{{port.minFreq}}</td>
+ <td [ngClass]="(isDelta() ? 'delta' : '')">{{port.maxFreq}}</td>
+ <td [ngClass]="(isDelta() ? 'delta' : '')">{{port.grid}}</td>
+ <td [ngClass]="(isDelta() ? 'delta' : '')">{{port.powerRange}}</td>
+ <td [ngClass]="(isDelta() ? 'delta' : '')">{{port.currentPower}}</td>
+ <td [ngClass]="(isDelta() ? 'delta' : '')">{{port.targetPower}}
+ <form [formGroup]="powerForm" (ngSubmit)="submitPower(devId, port.id)" >
+ <input type="text" formControlName="newPower" required>
+ <button type="submit">Submit</button>
+ </form>
+ </td>
+ <td [ngClass]="(isDelta() ? 'delta' : '')">{{port.hasTargetPower}}</td>
+ <td [ngClass]="(isDelta() ? 'delta' : '')">{{port.serviceState}}</td>
+ </tr>
+ </table>
+ </div>
+ </div>
+</div>
diff --git a/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/src/lib/port/port.component.ts b/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/src/lib/port/port.component.ts
new file mode 100644
index 0000000..34a2bdf
--- /dev/null
+++ b/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/src/lib/port/port.component.ts
@@ -0,0 +1,214 @@
+/*
+ * 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 { Component, OnDestroy, OnInit } from '@angular/core';
+import {
+ FnService,
+ LogService,
+ PrefsService,
+ WebSocketService,
+ SortDir, TableBaseImpl, TableResponse
+} from 'gui2-fw-lib';
+import { ActivatedRoute } from '@angular/router';
+import {FormGroup, FormControl} from '@angular/forms';
+
+/**
+ * Model of the response from WebSocket
+ */
+interface RoadmPortTableResponse extends TableResponse {
+ roadmPorts: RoadmPort[];
+}
+
+/**
+ * Model of the roadm ports returned from the WebSocket
+ */
+interface RoadmPort {
+ id: string;
+ reversePort: string;
+ name: string;
+ type: string;
+ enabled: string;
+ minFreq: string;
+ maxFreq: string;
+ grid: string;
+ powerRange: string;
+ currentPower: string;
+ targetPower: string;
+ hasTargetPower: string;
+ serviceState: string;
+}
+
+interface FilterToggleState {
+ devId: string;
+ nzFilter: boolean;
+ showDelta: boolean;
+}
+
+const defaultPortPrefsState = {
+ nzFilter: 1,
+ showDelta: 0,
+};
+
+/**
+ * ONOS GUI -- Port View Component
+ */
+@Component({
+ selector: 'roadm-port',
+ templateUrl: './port.component.html',
+ styleUrls: ['./port.component.css', '../../../fw/widget/table.css', '../../../fw/widget/table.theme.css']
+})
+export class RoadmPortComponent extends TableBaseImpl implements OnInit, OnDestroy {
+ devId: string;
+ nzFilter: boolean = true;
+ showDelta: boolean = false;
+ prefsState = {};
+ toggleState: FilterToggleState;
+
+ powerForm: FormGroup;
+ SET_POWER_REQ = 'roadmSetTargetPowerRequest';
+ SET_POWER_RESP = 'roadmSetTargetPowerResponse';
+
+ restorePrefsConfig; // Function
+
+ deviceTip = 'Show device table';
+
+ constructor(protected fs: FnService,
+ protected log: LogService,
+ protected ar: ActivatedRoute,
+ protected wss: WebSocketService,
+ protected prefs: PrefsService
+ ) {
+ super(fs, log, wss, 'roadmPort');
+ this.ar.queryParams.subscribe(params => {
+ this.devId = params['devId'];
+
+ });
+
+ this.payloadParams = {
+ devId: this.devId
+ };
+
+ this.responseCallback = this.portResponseCb;
+ this.restorePrefsConfig = this.restoreConfigFromPrefs;
+
+ this.sortParams = {
+ firstCol: 'id',
+ firstDir: SortDir.desc,
+ secondCol: 'type',
+ secondDir: SortDir.asc,
+ };
+ }
+
+ ngOnInit() {
+ this.init();
+ this.createForm();
+ this.wss.bindHandlers(new Map<string, (data) => void>([
+ [this.SET_POWER_RESP, (data) => this.powerConfigCb(data)]
+ ]));
+ this.log.debug('RoadmPortComponent initialized');
+ }
+
+ createForm() {
+ this.powerForm = new FormGroup({
+ newPower: new FormControl(''),
+ });
+ this.log.debug('Create Form');
+ }
+
+ ngOnDestroy() {
+ this.destroy();
+ this.log.debug('RoadmPortComponent destroyed');
+ }
+
+ portResponseCb(data: RoadmPortTableResponse) {
+ this.log.debug('Roadm Port response received for ', data.roadmPorts.length, 'port');
+ }
+
+ isNz(): boolean {
+ return this.nzFilter;
+ }
+
+ isDelta(): boolean {
+ return this.showDelta;
+ }
+
+ toggleNZState(b?: any) {
+ if (b === undefined) {
+ this.nzFilter = !this.nzFilter;
+ } else {
+ this.nzFilter = b;
+ }
+ this.payloadParams = this.filterToggleState();
+ this.updatePrefsState('nzFilter', this.nzFilter);
+ this.forceRefesh();
+ }
+
+ toggleDeltaState(b?: any) {
+ if (b === undefined) {
+ this.showDelta = !this.showDelta;
+ } else {
+ this.showDelta = b;
+ }
+
+ this.payloadParams = this.filterToggleState();
+ this.updatePrefsState('showDelta', this.showDelta);
+ this.forceRefesh();
+ }
+
+ updatePrefsState(what: any, b: any) {
+ this.prefsState[what] = b ? 1 : 0;
+ this.prefs.setPrefs('port_prefs', this.prefsState);
+ }
+
+ filterToggleState(): FilterToggleState {
+ return this.toggleState = {
+ devId: this.devId,
+ nzFilter: this.nzFilter,
+ showDelta: this.showDelta,
+ };
+ }
+
+ forceRefesh() {
+ this.requestTableData();
+ }
+
+ restoreConfigFromPrefs() {
+ this.prefsState = this.prefs.asNumbers(
+ this.prefs.getPrefs('port_prefs', defaultPortPrefsState, )
+ );
+
+ this.log.debug('Port - Prefs State:', this.prefsState);
+ this.toggleDeltaState(this.prefsState['showDelta']);
+ this.toggleNZState(this.prefsState['nzFilter']);
+ }
+
+ submitPower(devId, port) {
+ this.log.debug('Set power of port ', port, 'in device ', devId, 'as value ', this.powerForm.value['newPower'], 'dBm.');
+ this.wss.sendEvent(this.SET_POWER_REQ, {
+ 'targetPower': this.powerForm.value['newPower'],
+ 'devId': devId,
+ 'id': port,
+ });
+ }
+
+ powerConfigCb(data) {
+ if (!data.valid) {
+ const info = 'The power config operation is failed. The reason is: \n' + data.message;
+ alert(info);
+ } else {
+ this.log.debug('The power config operation is successful!');
+ }
+ }
+}
diff --git a/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/src/lib/roadm-gui-lib.module.ts b/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/src/lib/roadm-gui-lib.module.ts
new file mode 100644
index 0000000..1296ce2
--- /dev/null
+++ b/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/src/lib/roadm-gui-lib.module.ts
@@ -0,0 +1,42 @@
+/*
+ * 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 { NgModule } from '@angular/core';
+import { CommonModule } from '@angular/common';
+import { Gui2FwLibModule } from 'gui2-fw-lib';
+import { RoadmDeviceComponent } from './roadm/roadm.component';
+import { RoadmRoutingModule } from './roadm-routing.module';
+import { FormsModule, ReactiveFormsModule } from '@angular/forms';
+import { RoadmPortComponent } from './port/port.component';
+
+@NgModule({
+ declarations: [
+ RoadmDeviceComponent,
+ RoadmPortComponent,
+ ],
+ imports: [
+ RoadmRoutingModule,
+ Gui2FwLibModule,
+ CommonModule,
+ FormsModule,
+ ReactiveFormsModule
+ ],
+ exports: [
+ RoadmDeviceComponent,
+ RoadmPortComponent,
+ ]
+})
+export class RoadmGuiLibModule { }
diff --git a/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/src/lib/roadm-routing.module.ts b/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/src/lib/roadm-routing.module.ts
new file mode 100644
index 0000000..87d8bfc
--- /dev/null
+++ b/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/src/lib/roadm-routing.module.ts
@@ -0,0 +1,41 @@
+/*
+ * 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 { NgModule } from '@angular/core';
+import { Routes, RouterModule } from '@angular/router';
+import { RoadmDeviceComponent } from './roadm/roadm.component';
+import { RoadmPortComponent } from './port/port.component';
+
+const appRoutes: Routes = [
+ {
+ path: 'roadm-port-gui',
+ component: RoadmPortComponent
+ },
+ {
+ path: '',
+ component: RoadmDeviceComponent
+ },
+];
+
+/**
+ * ONOS GUI -- Roadm View Feature Routing Module - allows it to be lazy loaded
+ *
+ * See https://angular.io/guide/lazy-loading-ngmodules
+ */
+@NgModule({
+ imports: [RouterModule.forChild(appRoutes)],
+ exports: [RouterModule]
+})
+export class RoadmRoutingModule { }
diff --git a/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/src/lib/roadm/roadm.component.css b/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/src/lib/roadm/roadm.component.css
new file mode 100644
index 0000000..a49562c
--- /dev/null
+++ b/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/src/lib/roadm/roadm.component.css
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+
+#ov-roadm {
+ padding: 20px;
+ color: navy;
+}
+
+#ov-roadm .button-panel {
+ margin: 10px;
+ width: 200px;
+ background-color: #ccf;
+}
+
+#ov-roadm .my-button {
+ cursor: pointer;
+ padding: 4px;
+ text-align: center;
+ color: white;
+ background-color: #99d;
+}
+
+#ov-roadm .number {
+ font-size: 140%;
+ text-align: right;
+}
+
+#ov-roadm .quote {
+ margin: 10px 20px;
+ font-style: italic;
+}
\ No newline at end of file
diff --git a/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/src/lib/roadm/roadm.component.disabledspec.ts b/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/src/lib/roadm/roadm.component.disabledspec.ts
new file mode 100644
index 0000000..815fc0b
--- /dev/null
+++ b/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/src/lib/roadm/roadm.component.disabledspec.ts
@@ -0,0 +1,97 @@
+/*
+ * 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 { async, ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { RoadmDeviceComponent } from './roadm.component';
+import {ActivatedRoute, Params} from '@angular/router';
+import {CommonModule} from '@angular/common';
+import { of } from 'rxjs';
+import { } from 'jasmine';
+import {
+ FnService,
+ IconService,
+ IconComponent,
+ LogService,
+ TableFilterPipe,
+ LoadingComponent,
+ Gui2FwLibModule,
+} from 'gui2-fw-lib';
+import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
+import {FormsModule} from '@angular/forms';
+import {RouterTestingModule} from '@angular/router/testing';
+
+class MockActivatedRoute extends ActivatedRoute {
+ constructor(params: Params) {
+ super();
+ this.queryParams = of(params);
+ }
+}
+
+class MockIconService {
+ loadIconDef() { }
+}
+
+describe('RoadmDeviceComponent', () => {
+ let fs: FnService;
+ let ar: MockActivatedRoute;
+ let windowMock: Window;
+ let logServiceSpy: jasmine.SpyObj<LogService>;
+ let component: RoadmDeviceComponent;
+ let fixture: ComponentFixture<RoadmDeviceComponent>;
+
+ 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, CommonModule, FormsModule, RouterTestingModule, Gui2FwLibModule],
+ declarations: [
+ RoadmDeviceComponent
+ ],
+ 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(RoadmDeviceComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/src/lib/roadm/roadm.component.html b/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/src/lib/roadm/roadm.component.html
new file mode 100644
index 0000000..3068d77
--- /dev/null
+++ b/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/src/lib/roadm/roadm.component.html
@@ -0,0 +1,115 @@
+<!--
+~ 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.
+-->
+<div id="ov-device">
+ <onos-loading [theme]="'light'" [running]="loadingIconShown"></onos-loading>
+ <div class="tabular-header">
+ <h2>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="42" toolTip="{{ autoRefreshTip }}"></onos-icon>
+ </div>
+ <div class="separator"></div>
+
+ <!--<div>-->
+ <!--<onos-icon classes="{{ selId ? 'current-view':undefined }}" iconId="deviceTable" iconSize="42"></onos-icon>-->
+ <!--</div>-->
+
+ <!--<div (click)="navto('/flow')">-->
+ <!--<onos-icon classes="{{ selId ? 'active-rect' :undefined}}" iconId="flowTable" iconSize="42" toolTip="{{ flowTip }}"></onos-icon>-->
+ <!--</div>-->
+
+ <div (click)="navto('/roadm-gui/roadm-port-gui')">
+ <onos-icon classes="{{ selId ? 'active-rect' :undefined}}" iconId="portTable" iconSize="42" toolTip="{{ portTip }}"></onos-icon>
+ </div>
+
+ </div>
+ <div class="search">
+ <input id="searchinput" [(ngModel)]="tableDataFilter.queryStr" type="search" #search placeholder="Search" />
+ <select [(ngModel)]="tableDataFilter.queryBy">
+ <option value="" disabled>Search By</option>
+ <option value="$">All Fields</option>
+ <option value="id">Device-Id</option>
+ <option value="name">Name</option>
+ <option value="protocol">Protocol</option>
+ </select>
+ </div>
+ </div>
+
+ <div id="summary-list" class="summary-list" onosTableResize>
+ <div class="table-header">
+ <table>
+ <tr>
+ <td colId="available" class="table-icon"></td>
+ <td colId="type" class="table-icon"></td>
+ <td colId="name" (click)="onSort('name')">Friendly Name
+ <onos-icon classes="active-sort" [iconSize]="10" [iconId]="sortIcon('name')"></onos-icon>
+ </td>
+ <td colId="id" (click)="onSort('id')">Device ID
+ <onos-icon classes="active-sort" [iconSize]="10" [iconId]="sortIcon('id')"></onos-icon>
+ </td>
+ <td colId="master" [ngClass]="{width: '130px'}" (click)="onSort('master')">Master
+ <onos-icon classes="active-sort" [iconSize]="10" [iconId]="sortIcon('master')"></onos-icon>
+ </td>
+ <td colId="ports" [ngClass]="{width: '70px'}" (click)="onSort('ports')">Ports
+ <onos-icon classes="active-sort" [iconSize]="10" [iconId]="sortIcon('ports')"></onos-icon>
+ </td>
+ <td colId="vendor" (click)="onSort('vendor')">Vendor
+ <onos-icon classes="active-sort" [iconSize]="10" [iconId]="sortIcon('vendor')"></onos-icon>
+ </td>
+ <td colId="hwVersion" (click)="onSort('hwVersion')">H/W Version
+ <onos-icon classes="active-sort" [iconSize]="10" [iconId]="sortIcon('hwVersion')"></onos-icon>
+ </td>
+ <td colId="swVersion" (click)="onSort('swVersion')">S/W Version
+ <onos-icon classes="active-sort" [iconSize]="10" [iconId]="sortIcon('swVersion')"></onos-icon>
+ </td>
+ <td colId="protocol" [ngClass]="{width: '100px'}" (click)="onSort('protocol')">Protocol
+ <onos-icon classes="active-sort" [iconSize]="10" [iconId]="sortIcon('protocol')"></onos-icon>
+ </td>
+ <td colId="type" (click)="onSort('type')">Type
+ <onos-icon classes="active-sort" [iconSize]="10" [iconId]="sortIcon('type')"></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 dev of tableData | filter : tableDataFilter" (click)="selectCallback($event, dev)" [ngClass]="{selected: dev.id === selId, 'data-change': isChanged(dev.id)}">
+ <td class="table-icon">
+ <onos-icon classes="{{ dev._iconid_available}}" iconId={{dev._iconid_available}}></onos-icon>
+ </td>
+ <td class="table-icon">
+ <onos-icon classes="{{dev._iconid_type? 'active-type':undefined}}" iconId="{{dev._iconid_type}}"></onos-icon>
+ </td>
+ <td>{{ dev.name }}</td>
+ <td>{{ dev.id }}</td>
+ <td>{{ dev.master }}</td>
+ <td>{{ dev.ports }}</td>
+ <td>{{ dev.vendor }}</td>
+ <td>{{ dev.hwVersion }}</td>
+ <td>{{ dev.swVersion }}</td>
+ <td>{{ dev.protocol }}</td>
+ <td>{{ dev.type }}</td>
+ </tr>
+ </table>
+ </div>
+ </div>
+
+ <!--<onos-devicedetails class="floatpanels" id="{{ selId }}" (closeEvent)="deselectRow($event)"></onos-devicedetails>-->
+</div>
diff --git a/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/src/lib/roadm/roadm.component.ts b/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/src/lib/roadm/roadm.component.ts
new file mode 100644
index 0000000..592be6b
--- /dev/null
+++ b/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/src/lib/roadm/roadm.component.ts
@@ -0,0 +1,120 @@
+/*
+ * 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 { Component, OnInit, OnDestroy} from '@angular/core';
+
+import {
+ FnService,
+ LogService,
+ WebSocketService,
+ SortDir, TableBaseImpl, TableResponse
+} from 'gui2-fw-lib';
+
+import { ActivatedRoute, Router } from '@angular/router';
+
+/**
+ * Model of the response from WebSocket
+ */
+interface RoadmDeviceTableResponse extends TableResponse {
+ roadms: RoadmDevice[];
+}
+
+/**
+ * Model of the ROADM devices returned from the WebSocket
+ */
+interface RoadmDevice {
+ available: boolean;
+ chassisid: string;
+ hwVersion: string;
+ id: string;
+ master: string;
+ Vendor: string;
+ name: string;
+ ports: number;
+ protocol: string;
+ serial: string;
+ swVersion: string;
+ type: string;
+ _iconid_available: string;
+ _iconid_type: string;
+}
+
+
+/**
+ * ONOS GUI -- Roadm Device View Component
+ */
+@Component({
+ selector: 'roadm-device',
+ templateUrl: './roadm.component.html',
+ styleUrls: ['./roadm.component.css', './roadm.theme.css', '../../../fw/widget/table.css', '../../../fw/widget/table.theme.css']
+})
+export class RoadmDeviceComponent extends TableBaseImpl implements OnInit, OnDestroy {
+
+ // TODO: Update for LION
+ flowTip = 'Show flow view for selected device';
+ portTip = 'Show port view for selected device';
+ groupTip = 'Show group view for selected device';
+ meterTip = 'Show meter view for selected device';
+ pipeconfTip = 'Show pipeconf view for selected device';
+
+ constructor(
+ protected fs: FnService,
+ protected log: LogService,
+ protected as: ActivatedRoute,
+ protected router: Router,
+ protected wss: WebSocketService,
+ ) {
+ super(fs, log, wss, 'roadm');
+ this.responseCallback = this.deviceResponseCb;
+
+ this.as.queryParams.subscribe(params => {
+ this.selId = params['devId'];
+
+ });
+
+ this.payloadParams = {
+ devId: this.selId
+ };
+
+ this.sortParams = {
+ firstCol: 'name',
+ firstDir: SortDir.asc,
+ secondCol: 'id',
+ secondDir: SortDir.desc,
+ };
+ }
+
+ ngOnInit() {
+ this.init();
+ this.log.debug('RoadmDeviceComponent initialized');
+ }
+
+ ngOnDestroy() {
+ this.destroy();
+ this.log.debug('RoadmDeviceComponent destroyed');
+ }
+
+ deviceResponseCb(data: RoadmDeviceTableResponse) {
+ this.log.debug('Device response received for ', data.roadms.length, 'roadm devices');
+ }
+
+ navto(path) {
+ this.log.debug('navigate');
+ if (this.selId) {
+ this.router.navigate([path], { queryParams: { devId: this.selId } });
+ }
+ }
+
+}
diff --git a/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/src/lib/roadm/roadm.theme.css b/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/src/lib/roadm/roadm.theme.css
new file mode 100644
index 0000000..cdc0aba
--- /dev/null
+++ b/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/src/lib/roadm/roadm.theme.css
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ */
+
+/*
+ ONOS GUI -- Roadm Device View (theme) -- CSS file
+ */
+
+.light #device-details-panel .bottom th {
+ background-color: #e5e5e6;
+}
+
+.light #device-details-panel .bottom tr:nth-child(odd) {
+ background-color: #fbfbfb;
+}
+.light #device-details-panel .bottom tr:nth-child(even) {
+ background-color: #f4f4f4;
+}
+#ov-device .tabular-header {
+ text-align: left;
+}
+#ov-device 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-device div.summary-list .table-body {
+ overflow:scroll;
+}
+#ov-device h2 {
+ display: inline-block;
+}
+
+#ov-device, div.ctrl-btns {
+}
+
+#ov-device th, td {
+ text-align: left;
+ padding: 8px;
+}
diff --git a/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/src/public_api.ts b/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/src/public_api.ts
new file mode 100644
index 0000000..41f518d
--- /dev/null
+++ b/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/src/public_api.ts
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+
+/*
+ * Public API Surface of roadm-gui-lib
+ */
+
+export * from './lib/roadm-gui-lib.module';
+export * from './lib/roadm-routing.module';
+export * from './lib/roadm/roadm.component';
+export * from './lib/port/port.component';
diff --git a/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/src/test.ts b/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/src/test.ts
new file mode 100644
index 0000000..3e4cb26
--- /dev/null
+++ b/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/src/test.ts
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+
+// This file is required by karma.conf.js and loads recursively all the .spec and framework files
+
+import 'core-js/es7/reflect';
+import 'zone.js/dist/zone';
+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/roadm/web/roadm-gui/projects/roadm-gui-lib/tsconfig.lib.json b/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/tsconfig.lib.json
new file mode 100644
index 0000000..3fe337f
--- /dev/null
+++ b/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/tsconfig.lib.json
@@ -0,0 +1,32 @@
+{
+ "extends": "../../tsconfig.json",
+ "compilerOptions": {
+ "outDir": "../../out-tsc/lib",
+ "target": "es2015",
+ "module": "es2015",
+ "moduleResolution": "node",
+ "declaration": true,
+ "sourceMap": true,
+ "inlineSources": true,
+ "emitDecoratorMetadata": true,
+ "experimentalDecorators": true,
+ "importHelpers": true,
+ "types": [],
+ "lib": [
+ "dom",
+ "es2018"
+ ]
+ },
+ "angularCompilerOptions": {
+ "annotateForClosureCompiler": true,
+ "skipTemplateCodegen": true,
+ "strictMetadataEmit": true,
+ "fullTemplateTypeCheck": true,
+ "strictInjectionParameters": true,
+ "enableResourceInlining": true
+ },
+ "exclude": [
+ "src/test.ts",
+ "**/*.spec.ts"
+ ]
+}
diff --git a/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/tsconfig.spec.json b/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/tsconfig.spec.json
new file mode 100644
index 0000000..16da33d
--- /dev/null
+++ b/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/tsconfig.spec.json
@@ -0,0 +1,17 @@
+{
+ "extends": "../../tsconfig.json",
+ "compilerOptions": {
+ "outDir": "../../out-tsc/spec",
+ "types": [
+ "jasmine",
+ "node"
+ ]
+ },
+ "files": [
+ "src/test.ts"
+ ],
+ "include": [
+ "**/*.spec.ts",
+ "**/*.d.ts"
+ ]
+}
diff --git a/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/tslint.json b/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/tslint.json
new file mode 100644
index 0000000..2a22888
--- /dev/null
+++ b/apps/roadm/web/roadm-gui/projects/roadm-gui-lib/tslint.json
@@ -0,0 +1,17 @@
+{
+ "extends": "../../tslint.json",
+ "rules": {
+ "directive-selector": [
+ true,
+ "attribute",
+ "roadm",
+ "camelCase"
+ ],
+ "component-selector": [
+ true,
+ "element",
+ "roadm",
+ "kebab-case"
+ ]
+ }
+}