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/device/devicedetails/devicedetails.component.css b/web/gui2/src/main/webapp/app/view/device/devicedetails/devicedetails.component.css
new file mode 100644
index 0000000..a3903b0
--- /dev/null
+++ b/web/gui2/src/main/webapp/app/view/device/devicedetails/devicedetails.component.css
@@ -0,0 +1,114 @@
+/*
+ * 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.
+ */
+
+#device-details-panel.floatpanel {
+ z-index: 0;
+ font-size: 10pt;
+ top: 185px;
+}
+
+#device-details-panel.floatpanel a {
+ font-weight: bold;
+}
+
+#device-details-panel .container {
+ padding: 0 30px;
+}
+
+#device-details-panel .close-btn {
+ position: absolute;
+ right:5px;
+ top: 5px;
+ cursor: pointer;
+}
+
+#device-details-panel .dev-icon {
+ display: inline-block;
+ padding: 0 6px 0 0;
+ vertical-align: middle;
+}
+
+#device-details-panel h2 {
+ display: inline-block;
+ margin: 8px 0;
+ font-weight: bold;
+ font-size: 16pt;
+}
+
+#device-details-panel h2 input {
+ font-size: 0.90em;
+ width: 106%;
+}
+
+#device-details-panel .actionBtns div {
+ padding: 12px 6px;
+}
+
+#device-details-panel hr {
+ width: 100%;
+ margin: 2px auto;
+}
+
+#device-details-panel .top-tables {
+ font-size: 10pt;
+ white-space: nowrap;
+}
+
+#device-details-panel td.label {
+ font-weight: bold;
+ text-align: right;
+ padding-right: 6px;
+}
+
+#device-details-panel .bottom table {
+ border-spacing: 0;
+ height: 358px;
+ width: 520px;
+ overflow: auto;
+ display: block;
+}
+
+#device-details-panel .bottom th {
+ letter-spacing: 0.02em;
+}
+
+#device-details-panel .bottom th,
+#device-details-panel .bottom td {
+ padding: 6px 12px;
+ text-align: center;
+}
+
+#device-details-panel .top div.left {
+ float: left;
+ text-align: left;
+ padding: 0 10px 0 0;
+}
+
+#device-details-panel .top div.right {
+ display: inline-block;
+}
+
+#device-details-panel .editable {
+ border-bottom: 1px dashed #ca504b;
+}
+
+#device-details-panel .clickable {
+ cursor: pointer;
+}
+
+#device-details-panel .bottom thead tr {
+ background-color: #e5e5e6;
+}
\ No newline at end of file
diff --git a/web/gui2/src/main/webapp/app/view/device/devicedetails/devicedetails.component.html b/web/gui2/src/main/webapp/app/view/device/devicedetails/devicedetails.component.html
new file mode 100644
index 0000000..034b63b
--- /dev/null
+++ b/web/gui2/src/main/webapp/app/view/device/devicedetails/devicedetails.component.html
@@ -0,0 +1,111 @@
+<!--
+~ 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="device-details-panel" class="floatpanel" [@deviceDetailsState]="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>
+ <div class="dev-icon">
+ <onos-icon classes="{{detailsData._iconid_type? 'details-icon':undefined}}" iconId="{{detailsData._iconid_type}}" [iconSize]="40"></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">URI :</td>
+ <td class="value" width="80">{{detailsData.id}}</td>
+ </tr>
+ <tr>
+ <td class="label" width="110">Type :</td>
+ <td class="value" width="80">{{detailsData.type}}</td>
+ </tr>
+ <tr>
+ <td class="label" width="110">Master ID :</td>
+ <td class="value" width="80">{{detailsData.masterid}}</td>
+ </tr>
+ <tr>
+ <td class="label" width="110">Chassis ID :</td>
+ <td class="value" width="80">{{detailsData.chassisid}}</td>
+ </tr>
+ <tr>
+ <td class="label" width="110">Vendor :</td>
+ <td class="value" width="80">{{detailsData.mfr}}</td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+ <div class="right">
+ <table>
+ <tbody>
+ <tr>
+ <td class="label" width="110">H/W Version :</td>
+ <td class="value" width="80">{{detailsData.hw}}</td>
+ </tr>
+ <tr>
+ <td class="label" width="110">S/W Version :</td>
+ <td class="value" width="80">{{detailsData.sw}}</td>
+ </tr>
+ <tr>
+ <td class="label" width="110">Protocol :</td>
+ <td class="value" width="80">{{detailsData.protocol}}</td>
+ </tr>
+ <tr>
+ <td class="label" width="110">Serial # :</td>
+ <td class="value" width="80">{{detailsData.serial}}</td>
+ </tr>
+ <tr>
+ <td class="label" width="110">Pipeconf :</td>
+ <td class="value" width="80">{{detailsData.pipeconf}}</td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+ </div>
+ </div>
+ <hr>
+ </div>
+ <div class="bottom">
+ <h2 class="ports-title">Ports</h2>
+ <table>
+ <thead>
+ <tr>
+ <th>Enabled</th>
+ <th>ID</th>
+ <th>Speed</th>
+ <th>Type</th>
+ <th>Egress Links</th>
+ <th>Name</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr *ngFor="let port of detailsData.ports">
+ <td>{{port.enabled}}</td>
+ <td>{{port.id}}</td>
+ <td>{{port.speed}}</td>
+ <td>{{port.type}}</td>
+ <td>{{port.elinks_dest}}</td>
+ <td>{{port.name}}</td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+ </div>
+</div>
\ No newline at end of file
diff --git a/web/gui2/src/main/webapp/app/view/device/devicedetails/devicedetails.component.spec.ts b/web/gui2/src/main/webapp/app/view/device/devicedetails/devicedetails.component.spec.ts
new file mode 100644
index 0000000..5daa2ef
--- /dev/null
+++ b/web/gui2/src/main/webapp/app/view/device/devicedetails/devicedetails.component.spec.ts
@@ -0,0 +1,142 @@
+/*
+ * 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 { DeviceDetailsComponent } from './devicedetails.component';
+import { ActivatedRoute, Params } from '@angular/router';
+import { of } from 'rxjs/index';
+import { FnService } from '../../../fw/util/fn.service';
+import { LogService } from '../../../log.service';
+import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
+import { IconService } from '../../../fw/svg/icon.service';
+import { WebSocketService } from '../../../fw/remote/websocket.service';
+import { DebugElement } from '@angular/core';
+import { By } from '@angular/platform-browser';
+import { } from 'jasmine';
+import { IconComponent } from '../../../fw/svg/icon/icon.component';
+
+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('DeviceDetailsComponent', () => {
+ let fs: FnService;
+ let ar: MockActivatedRoute;
+ let windowMock: Window;
+ let logServiceSpy: jasmine.SpyObj<LogService>;
+ let component: DeviceDetailsComponent;
+ let fixture: ComponentFixture<DeviceDetailsComponent>;
+
+ 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: [DeviceDetailsComponent, 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(DeviceDetailsComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+
+ it('should have an div.close-btn div.top inside a div.container', () => {
+ const devDe: DebugElement = fixture.debugElement;
+ const divDe = devDe.query(By.css('div.container div.top div.close-btn'));
+ expect(divDe).toBeTruthy();
+ });
+
+ it('should have a div.dev-icon inside a div.top inside a div.container', () => {
+ const devDe: DebugElement = fixture.debugElement;
+ const divDe = devDe.query(By.css('div.container div.top div.dev-icon'));
+ const div: HTMLElement = divDe.nativeElement;
+ expect(div.textContent).toEqual('');
+ });
+
+ it('should have a div.top-content inside a div.top inside a div.container', () => {
+ const devDe: DebugElement = fixture.debugElement;
+ const divDe = devDe.query(By.css('div.container div.top div.top-content'));
+ expect(divDe).toBeTruthy();
+ });
+
+ it('should have a dev.left inside a div.top-tables inside a div.top-content', () => {
+ const devDe: DebugElement = fixture.debugElement;
+ const divDe = devDe.query(By.css('div.top-content div.top-tables div.left'));
+ const div: HTMLElement = divDe.nativeElement;
+ expect(div.textContent).toEqual('URI :Type :Master ID :Chassis ID :Vendor :');
+ });
+
+ it('should have a dev.right inside a div.top-tables inside a div.top-content', () => {
+ const devDe: DebugElement = fixture.debugElement;
+ const divDe = devDe.query(By.css('div.top-content div.top-tables div.right'));
+ const div: HTMLElement = divDe.nativeElement;
+ expect(div.textContent).toEqual('H/W Version :S/W Version :Protocol :Serial # :Pipeconf :');
+ });
+
+ it('should have a div.bottom inside a div.container', () => {
+ const devDe: DebugElement = fixture.debugElement;
+ const divDe = devDe.query(By.css('div.container div.bottom'));
+ expect(divDe).toBeTruthy();
+ });
+
+ it('should have a h2.ports-title inside a div.bottom inside a div.container', () => {
+ const devDe: DebugElement = fixture.debugElement;
+ const divDe = devDe.query(By.css('div.container div.bottom h2.ports-title'));
+ expect(divDe).toBeTruthy();
+ });
+});
diff --git a/web/gui2/src/main/webapp/app/view/device/devicedetails/devicedetails.component.ts b/web/gui2/src/main/webapp/app/view/device/devicedetails/devicedetails.component.ts
new file mode 100644
index 0000000..9e30eb7
--- /dev/null
+++ b/web/gui2/src/main/webapp/app/view/device/devicedetails/devicedetails.component.ts
@@ -0,0 +1,103 @@
+/*
+ * 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 } from '../../../fw/util/fn.service';
+import { LoadingService } from '../../../fw/layer/loading.service';
+import { LogService } from '../../../log.service';
+import { WebSocketService } from '../../../fw/remote/websocket.service';
+
+import { DetailsPanelBaseImpl } from '../../../fw/widget/detailspanel.base';
+import { IconService } from '../../../fw/svg/icon.service';
+
+/**
+ * The details view when a device row is clicked from the Device view
+ *
+ * This is expected to be passed an 'id' and it makes a call
+ * to the WebSocket with an deviceDetailsRequest, and gets back an
+ * deviceDetailsResponse.
+ *
+ * The animated fly-in is controlled by the animation below
+ * The deviceDetailsState is attached to device-details-panel
+ * and is false (flies out) when id='' and true (flies in) when
+ * id has a value
+ */
+@Component({
+ selector: 'onos-devicedetails',
+ templateUrl: './devicedetails.component.html',
+ styleUrls: ['./devicedetails.component.css',
+ '../../../fw/widget/panel.css', '../../../fw/widget/panel-theme.css'
+ ],
+ animations: [
+ trigger('deviceDetailsState', [
+ 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 DeviceDetailsComponent extends DetailsPanelBaseImpl implements OnInit, OnDestroy, OnChanges {
+ @Input() id: string;
+
+ constructor(protected fs: FnService,
+ protected ls: LoadingService,
+ protected log: LogService,
+ protected is: IconService,
+ protected wss: WebSocketService
+ ) {
+ super(fs, ls, log, wss, 'device');
+ }
+
+ ngOnInit() {
+ this.init();
+ this.log.debug('App Details Component initialized:', this.id);
+ }
+
+ /**
+ * Stop listening to appDetailsResponse on WebSocket
+ */
+ ngOnDestroy() {
+ this.destroy();
+ this.log.debug('App 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);
+ }
+ }
+
+}