GUI2 implementation of device/flow/port/group/meter/host/link/tunnel view
Review comments incorporated.
Change-Id: I45dd6570961cc3e0f4ffddb7acbf02cd7d860de5
diff --git a/web/gui2/src/main/webapp/app/view/meter/meter-routing.module.ts b/web/gui2/src/main/webapp/app/view/meter/meter-routing.module.ts
new file mode 100644
index 0000000..83a432e
--- /dev/null
+++ b/web/gui2/src/main/webapp/app/view/meter/meter-routing.module.ts
@@ -0,0 +1,33 @@
+/*
+* 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 { Routes, RouterModule } from '@angular/router';
+
+import { MeterComponent } from './meter/meter.component';
+
+
+const meterRoutes: Routes = [
+ {
+ path: '',
+ component: MeterComponent
+ }
+];
+
+@NgModule({
+ imports: [RouterModule.forChild(meterRoutes)],
+ exports: [RouterModule]
+})
+export class MeterRoutingModule { }
diff --git a/web/gui2/src/main/webapp/app/view/meter/meter.module.ts b/web/gui2/src/main/webapp/app/view/meter/meter.module.ts
new file mode 100644
index 0000000..90263b2
--- /dev/null
+++ b/web/gui2/src/main/webapp/app/view/meter/meter.module.ts
@@ -0,0 +1,37 @@
+/*
+* 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 { SvgModule } from '../../fw/svg/svg.module';
+import { WidgetModule } from '../../fw/widget/widget.module';
+
+
+import { MeterRoutingModule } from './meter-routing.module';
+import { MeterComponent } from './meter/meter.component';
+
+import { FormsModule } from '@angular/forms';
+
+@NgModule({
+ imports: [
+ CommonModule,
+ SvgModule,
+ MeterRoutingModule,
+ FormsModule,
+ WidgetModule
+ ],
+ declarations: [MeterComponent]
+})
+export class MeterModule { }
diff --git a/web/gui2/src/main/webapp/app/view/meter/meter/meter.component.css b/web/gui2/src/main/webapp/app/view/meter/meter/meter.component.css
new file mode 100644
index 0000000..809ab49
--- /dev/null
+++ b/web/gui2/src/main/webapp/app/view/meter/meter/meter.component.css
@@ -0,0 +1,58 @@
+/*
+ * 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 -- Meter View (layout) -- CSS file
+ */
+
+#ov-meter h2 {
+ display: inline-block;
+}
+
+#ov-meter div.ctrl-btns {
+}
+
+#ov-meter td {
+ text-align: center;
+}
+
+#ov-meter td.bands {
+ text-align: left;
+}
+
+#ov-meter td.right {
+ text-align: right;
+}
+
+#ov-meter .tabular-header {
+ text-align: left;
+}
+#ov-meter 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-meter div.summary-list td.bands {
+ padding-left: 36px;
+}
\ No newline at end of file
diff --git a/web/gui2/src/main/webapp/app/view/meter/meter/meter.component.html b/web/gui2/src/main/webapp/app/view/meter/meter/meter.component.html
new file mode 100644
index 0000000..bfeb407
--- /dev/null
+++ b/web/gui2/src/main/webapp/app/view/meter/meter/meter.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-meter">
+ <div class="tabular-header">
+ <h2> Meter for Device {{id}} ({{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="/device" [queryParams]="{ devId: id }" routerLinkActive="active">
+ <onos-icon classes="{{ id ? 'active-rect':undefined }}" iconId="deviceTable" iconSize="42" toolTip="{{deviceTip}}"></onos-icon>
+ </div>
+ <div routerLink="/flow" [queryParams]="{ devId: id }" routerLinkActive="active">
+ <onos-icon classes="{{ id ? 'active-rect' :undefined}}" iconId="flowTable" iconSize="42" toolTip="{{ flowTip }}"></onos-icon>
+ </div>
+ <div routerLink="/port" [queryParams]="{ devId: id }" routerLinkActive="active">
+ <onos-icon classes="{{ id ? 'active-rect' :undefined}}" iconId="portTable" iconSize="42" toolTip="{{ portTip }}"></onos-icon>
+ </div>
+ <div routerLink="/group" [queryParams]="{ devId: id }" routerLinkActive="active">
+ <onos-icon classes="{{ id ? 'active-rect' :undefined}}" iconId="groupTable" iconSize="42" toolTip="{{ groupTip }}"></onos-icon>
+ </div>
+ <div>
+ <onos-icon classes="{{ id ? 'current-view' :undefined}}" iconId="meterTable" iconSize="42"></onos-icon>
+ </div>
+ <div routerLink="/pipeconf" [queryParams]="{ devId: id }" routerLinkActive="active">
+ <onos-icon classes="{{ id ? 'active-rect' :undefined}}" iconId="pipeconfTable" iconSize="42" toolTip="{{ pipeconfTip }}"></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">Meter ID</option>
+ <option value="app_id">App ID</option>
+ <option value="state">State</option>
+ </select>
+ </div>
+ </div>
+ <div class="summary-list" onosTableResize>
+ <div class="table-header">
+ <table>
+ <tr>
+ <td colId="id" (click)="onSort('id')">Meter ID
+ <onos-icon classes="active-sort" [iconSize]="10" [iconId]="sortIcon('id')"></onos-icon>
+ </td>
+ <td colId="app_id" (click)="onSort('app_id')">App ID
+ <onos-icon classes="active-sort" [iconSize]="10" [iconId]="sortIcon('app_id')"></onos-icon>
+ </td>
+ <td colId="state" (click)="onSort('state')">State
+ <onos-icon classes="active-sort" [iconSize]="10" [iconId]="sortIcon('state')"></onos-icon>
+ </td>
+ <td colId="packets" (click)="onSort('packets')">Packets
+ <onos-icon classes="active-sort" [iconSize]="10" [iconId]="sortIcon('packets')"></onos-icon>
+ </td>
+ <td colId="bytes" (click)="onSort('bytes')">
+ Bytes
+ <onos-icon classes="active-sort" [iconSize]="10" [iconId]="sortIcon('bytes')"></onos-icon>
+ </td>
+ </tr>
+ </table>
+ </div>
+
+ <div class="table-body">
+ <table>
+ <tr class="table-body" *ngIf="tableData.length === 0" class="no-data">
+ <td colspan="5">{{annots.noRowsMsg}}</td>
+ </tr>
+ <ng-template ngFor let-meter [ngForOf]="tableData | filter : tableDataFilter">
+ <tr (click)="selectCallback($event, meter)" [ngClass]="{selected: meter.id === selId, 'data-change': isChanged(meter.id)}">
+ <td>{{meter.id}}</td>
+ <td>{{meter.app_id}}</td>
+ <td>{{meter.state}}</td>
+ <td>{{meter.packets}}</td>
+ <td>{{meter.bytes}}</td>
+ </tr>
+ <tr>
+ <td class="bands" colspan="5" [innerHTML]="meter.bands"></td>
+ </tr>
+ </ng-template>
+ </table>
+ </div>
+ </div>
+</div>
\ No newline at end of file
diff --git a/web/gui2/src/main/webapp/app/view/meter/meter/meter.component.spec.ts b/web/gui2/src/main/webapp/app/view/meter/meter/meter.component.spec.ts
new file mode 100644
index 0000000..e17ff50
--- /dev/null
+++ b/web/gui2/src/main/webapp/app/view/meter/meter/meter.component.spec.ts
@@ -0,0 +1,196 @@
+/*
+* 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 { DebugElement } from '@angular/core';
+import { By } from '@angular/platform-browser';
+import { MeterComponent } from './meter.component';
+import { LogService } from '../../../log.service';
+import { DialogService } from '../../../fw/layer/dialog.service';
+import { FnService } from '../../../fw/util/fn.service';
+import { IconComponent } from '../../../fw/svg/icon/icon.component';
+import { IconService } from '../../../fw/svg/icon.service';
+import { KeyService } from '../../../fw/util/key.service';
+import { LionService } from '../../../fw/util/lion.service';
+import { LoadingService } from '../../../fw/layer/loading.service';
+import { ThemeService } from '../../../fw/util/theme.service';
+import { TableFilterPipe } from '../../../fw/widget/tablefilter.pipe';
+import { UrlFnService } from '../../../fw/remote/urlfn.service';
+import { WebSocketService } from '../../../fw/remote/websocket.service';
+import { of, Subject } from 'rxjs';
+import { } from 'jasmine';
+import { RouterTestingModule } from '@angular/router/testing';
+
+
+class MockActivatedRoute extends ActivatedRoute {
+ constructor(params: Params) {
+ super();
+ this.queryParams = of(params);
+ }
+}
+
+
+class MockDialogService { }
+
+class MockFnService { }
+
+class MockIconService {
+ loadIconDef() { }
+}
+
+class MockKeyService { }
+
+class MockLoadingService {
+ startAnim() { }
+ stop() { }
+ waiting() { }
+}
+
+class MockThemeService { }
+
+class MockUrlFnService { }
+
+class MockWebSocketService {
+ createWebSocket() { }
+ isConnected() { return false; }
+ unbindHandlers() { }
+ bindHandlers() { }
+}
+
+
+/**
+ * ONOS GUI -- Meter Panel View -- Unit Tests
+ */
+
+describe('MeterComponent', () => {
+
+ let fs: FnService;
+ let ar: MockActivatedRoute;
+ let windowMock: Window;
+ let logServiceSpy: jasmine.SpyObj<LogService>;
+ let component: MeterComponent;
+ let fixture: ComponentFixture<MeterComponent>;
+
+ const bundleObj = {
+ 'core.view.Meter': {
+ test: 'test1'
+ }
+ };
+
+ const mockLion = (key) => {
+ return bundleObj[key] || '%' + key + '%';
+ };
+
+
+
+ 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: [MeterComponent, IconComponent, TableFilterPipe],
+ providers: [
+ { provide: DialogService, useClass: MockDialogService },
+ { provide: FnService, useValue: fs },
+ { provide: IconService, useClass: MockIconService },
+ { provide: KeyService, useClass: MockKeyService },
+ {
+ provide: LionService, useFactory: (() => {
+ return {
+ bundle: ((bundleId) => mockLion),
+ ubercache: new Array(),
+ loadCbs: new Map<string, () => void>([])
+ };
+ })
+ },
+ { provide: LoadingService, useClass: MockLoadingService },
+ { provide: LogService, useValue: logSpy },
+ { provide: ThemeService, useClass: MockThemeService },
+ { provide: UrlFnService, useClass: MockUrlFnService },
+ { provide: WebSocketService, useClass: MockWebSocketService },
+ { provide: 'Window', useValue: windowMock },
+ ]
+ })
+ .compileComponents();
+ logServiceSpy = TestBed.get(LogService);
+ }));
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(MeterComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+
+
+ it('should have a div.tabular-header inside a div#ov-meter', () => {
+ const metDe: DebugElement = fixture.debugElement;
+ const divDe = metDe.query(By.css('div#ov-meter div.tabular-header'));
+ expect(divDe).toBeTruthy();
+ });
+
+ it('should have a h2 inside the div.tabular-header', () => {
+ const metDe: DebugElement = fixture.debugElement;
+ const divDe = metDe.query(By.css('div#ov-meter div.tabular-header h2'));
+ const div: HTMLElement = divDe.nativeElement;
+ expect(div.textContent).toEqual(' Meter for Device (0 Total )');
+ });
+
+ it('should have a refresh button inside the div.tabular-header', () => {
+ const metDe: DebugElement = fixture.debugElement;
+ const divDe = metDe.query(By.css('div#ov-meter div.tabular-header div.ctrl-btns div.refresh'));
+ expect(divDe).toBeTruthy();
+ });
+
+
+ it('should have a div.summary-list inside a div#ov-meter', () => {
+ const hostDe: DebugElement = fixture.debugElement;
+ const divDe = hostDe.query(By.css('div#ov-meter div.summary-list'));
+ expect(divDe).toBeTruthy();
+ });
+
+ it('should have a div.table-header inside a div.summary-list inside a div#ov-meter', () => {
+ const hostDe: DebugElement = fixture.debugElement;
+ const divDe = hostDe.query(By.css('div#ov-meter div.summary-list div.table-header'));
+ expect(divDe).toBeTruthy();
+ });
+
+ it('should have a div.table-body inside a div.summary-list inside a div#ov-meter', () => {
+ const hostDe: DebugElement = fixture.debugElement;
+ const divDe = hostDe.query(By.css('div#ov-meter div.summary-list div.table-body'));
+ expect(divDe).toBeTruthy();
+ });
+});
diff --git a/web/gui2/src/main/webapp/app/view/meter/meter/meter.component.ts b/web/gui2/src/main/webapp/app/view/meter/meter/meter.component.ts
new file mode 100644
index 0000000..e026e1c
--- /dev/null
+++ b/web/gui2/src/main/webapp/app/view/meter/meter/meter.component.ts
@@ -0,0 +1,107 @@
+/*
+* 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, OnDestroy, OnInit } from '@angular/core';
+import { SortDir, TableBaseImpl, TableResponse } from '../../../fw/widget/table.base';
+import { WebSocketService } from '../../../fw/remote/websocket.service';
+import { LogService } from '../../../log.service';
+import { LoadingService } from '../../../fw/layer/loading.service';
+import { FnService } from '../../../fw/util/fn.service';
+import { ActivatedRoute } from '@angular/router';
+
+/**
+* Model of the response from WebSocket
+*/
+interface MeterTableResponse extends TableResponse {
+ meters: Meter[];
+}
+
+/**
+* Model of the meter returned from the WebSocket
+*/
+interface Meter {
+ id: string;
+ appId: string;
+ state: string;
+ packets: string;
+ bytes: string;
+}
+
+/**
+ * ONOS GUI -- Meter View Component
+ */
+@Component({
+ selector: 'onos-meter',
+ templateUrl: './meter.component.html',
+ styleUrls: ['./meter.component.css', './meter.theme.css',
+ '../../../fw/widget/table.css', '../../../fw/widget/table.theme.css']
+})
+export class MeterComponent extends TableBaseImpl implements OnInit, OnDestroy {
+
+ id: string;
+ brief: boolean = true;
+
+ // TODO: Update for LION
+ deviceTip = 'Show device table';
+ detailTip = 'Switch to detail view';
+ flowTip = 'Show flow view for selected device';
+ portTip = 'Show port view for selected device';
+ groupTip = 'Show group view for selected device';
+ pipeconfTip = 'Show pipeconf view for selected device';
+
+ constructor(
+ protected fs: FnService,
+ protected log: LogService,
+ protected ls: LoadingService,
+ protected as: ActivatedRoute,
+ protected wss: WebSocketService,
+ ) {
+ super(fs, ls, log, wss, 'meter');
+ this.as.queryParams.subscribe(params => {
+ this.id = params['devId'];
+ });
+
+ this.payloadParams = {
+ devId: this.id
+ };
+
+ this.responseCallback = this.meterResponseCb;
+ this.sortParams = {
+ firstCol: 'id',
+ firstDir: SortDir.desc,
+ secondCol: 'app_id',
+ secondDir: SortDir.asc,
+ };
+ }
+
+ ngOnInit() {
+ this.init();
+ this.log.debug('MeterComponent initialized');
+ }
+
+ ngOnDestroy() {
+ this.destroy();
+ this.log.debug('MeterComponent destroyed');
+ }
+
+ meterResponseCb(data: MeterTableResponse) {
+ this.log.debug('Meter response received for ', data.meters.length, 'meter');
+ }
+
+ briefToggle() {
+ this.brief = !this.brief;
+ }
+
+}
diff --git a/web/gui2/src/main/webapp/app/view/meter/meter/meter.theme.css b/web/gui2/src/main/webapp/app/view/meter/meter/meter.theme.css
new file mode 100644
index 0000000..9f4dea4
--- /dev/null
+++ b/web/gui2/src/main/webapp/app/view/meter/meter/meter.theme.css
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2016-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 -- Meter View (theme) -- CSS file
+ */
+
+
+/* a "logical" row is made up of 2 "physical" rows -- color as such */
+#ov-meter tr:nth-child(4n + 1),
+#ov-meter tr:nth-child(4n + 2) {
+ background-color: #fbfbfb;
+}
+#ov-meter tr:nth-child(4n + 3),
+#ov-meter tr:nth-child(4n) {
+ background-color: #f4f4f4;
+ }
+
+/* highlighted color */
+#ov-meter tr:nth-child(4n + 1).data-change,
+#ov-meter tr:nth-child(4n + 2).data-change,
+#ov-meter tr:nth-child(4n + 3).data-change,
+#ov-meter tr:nth-child(4n).data-change {
+ background-color: #FDFFDC;
+}
+
+
+/* ========== DARK Theme ========== */
+
+.dark #ov-meter tr:nth-child(4n + 1),
+.dark #ov-meter tr:nth-child(4n + 2) {
+ background-color: #333333;
+}
+.dark #ov-meter tr:nth-child(4n + 3),
+.dark #ov-meter tr:nth-child(4n) {
+ background-color: #3a3a3a;
+}
+
+.dark #ov-meter tr:nth-child(4n + 1).data-change,
+.dark #ov-meter tr:nth-child(4n + 2).data-change,
+.dark #ov-meter tr:nth-child(4n + 3).data-change,
+.dark #ov-meter tr:nth-child(4n).data-change {
+ background-color: #423708;
+}
+
+