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/flow/flow-routing.module.ts b/web/gui2/src/main/webapp/app/view/flow/flow-routing.module.ts
new file mode 100644
index 0000000..4ddf65f
--- /dev/null
+++ b/web/gui2/src/main/webapp/app/view/flow/flow-routing.module.ts
@@ -0,0 +1,36 @@
+/*
+ * 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 { FlowComponent } from './flow/flow.component';
+
+const flowRoutes: Routes = [
+    {
+        path: '',
+        component: FlowComponent
+    }
+];
+
+/**
+ * ONOS GUI -- Flows Tabular View Feature Routing Module - allows it to be lazy loaded
+ *
+ * See https://angular.io/guide/lazy-loading-ngmodules
+ */
+@NgModule({
+    imports: [RouterModule.forChild(flowRoutes)],
+    exports: [RouterModule]
+})
+export class FlowRoutingModule { }
diff --git a/web/gui2/src/main/webapp/app/view/flow/flow.module.ts b/web/gui2/src/main/webapp/app/view/flow/flow.module.ts
new file mode 100644
index 0000000..55d3c96
--- /dev/null
+++ b/web/gui2/src/main/webapp/app/view/flow/flow.module.ts
@@ -0,0 +1,41 @@
+/*
+ * 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 { FlowComponent } from './flow/flow.component';
+import { SvgModule } from '../../fw/svg/svg.module';
+import { WidgetModule } from '../../fw/widget/widget.module';
+import { FlowRoutingModule } from './flow-routing.module';
+import { FormsModule } from '@angular/forms';
+import { FlowDetailsComponent } from './flowdetails/flowdetails/flowdetails.component';
+
+/**
+ * ONOS GUI -- Flow View Module
+ */
+@NgModule({
+    imports: [
+        CommonModule,
+        SvgModule,
+        FlowRoutingModule,
+        FormsModule,
+        WidgetModule
+    ],
+    declarations: [
+        FlowComponent,
+        FlowDetailsComponent
+    ]
+})
+export class FlowModule { }
diff --git a/web/gui2/src/main/webapp/app/view/flow/flow/flow.component.css b/web/gui2/src/main/webapp/app/view/flow/flow/flow.component.css
new file mode 100644
index 0000000..3ed4d16
--- /dev/null
+++ b/web/gui2/src/main/webapp/app/view/flow/flow/flow.component.css
@@ -0,0 +1,102 @@
+/*
+ * 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 -- Flow View (layout) -- CSS file
+ */
+
+#ov-flow h2 {
+    display: inline-block;
+}
+
+#ov-flow div.ctrl-btns {
+}
+
+#ov-flow td {
+    text-align: center;
+}
+#ov-flow td.right {
+    text-align: right;
+}
+#ov-flow td.selector,
+#ov-flow td.treatment {
+    text-align: left;
+    padding-left: 36px;
+}
+
+#ov-flow .tabular-header {
+    text-align: left;
+}
+#ov-flow 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;
+}
+
+/* More in generic panel.css */
+
+#flow-details-panel.floatpanel {
+    z-index: 0;
+}
+
+
+#flow-details-panel .container {
+    padding: 8px 12px;
+}
+
+#flow-details-panel .close-btn {
+    position: absolute;
+    right: 12px;
+    top: 12px;
+    cursor: pointer;
+}
+
+#flow-details-panel .dev-icon {
+    display: inline-block;
+    padding: 0 6px 0 0;
+    vertical-align: middle;
+}
+
+#flow-details-panel h2 {
+    display: inline-block;
+    margin: 8px 0;
+    font-size: 16pt;
+    font-weight: lighter;
+}
+
+#flow-details-panel h3 {
+    display: inline-block;
+    margin: 8px 0;
+    font-size: 11pt;
+    font-variant: small-caps;
+    text-transform: uppercase;
+}
+
+#flow-details-panel .top-content table {
+    font-size: 10pt;
+}
+
+#flow-details-panel td.label {
+    font-weight: bold;
+    text-align: right;
+    padding-right: 6px;
+}
\ No newline at end of file
diff --git a/web/gui2/src/main/webapp/app/view/flow/flow/flow.component.html b/web/gui2/src/main/webapp/app/view/flow/flow/flow.component.html
new file mode 100644
index 0000000..a1b23df
--- /dev/null
+++ b/web/gui2/src/main/webapp/app/view/flow/flow/flow.component.html
@@ -0,0 +1,136 @@
+<!--
+~ 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-flow" xmlns="http://www.w3.org/1999/html">
+    <div class="tabular-header">
+        <h2>
+            {{lionFn('title_flows')}} {{id}} ({{ tableData.length }} {{ lionFn('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>
+            <span *ngIf="brief" (click)="briefToggle()">
+                <div>
+                    <onos-icon classes="{{ id ? 'active-rect' :undefined}}" iconId="plus" iconSize="42" toolTip="{{detailTip}}"></onos-icon>
+                </div>
+            </span>
+
+            <span *ngIf="!brief" (click)="briefToggle()">
+                <div>
+                    <onos-icon classes="{{ id ? 'active-rect' :undefined}}" iconId="minus" iconSize="42" toolTip="{{briefTip}}"></onos-icon>
+                </div>
+            </span>
+            <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>
+                <onos-icon classes="{{ id ? 'current-view' :undefined}}" iconId="flowTable" iconSize="42"></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 routerLink="/meter" [queryParams]="{ devId: id }" routerLinkActive="active">
+                <onos-icon classes="{{ id ? 'active-rect' :undefined}}" iconId="meterTable" iconSize="42" toolTip="{{ meterTip }}"></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="priority">{{lionFn('priority')}}</option>
+                <option value="tableName">{{lionFn('tableName')}}</option>
+                <option value="selector">{{lionFn('selector')}}</option>
+                <option value="treatment">{{lionFn('treatment')}}</option>
+                <option value="appName">{{lionFn('appName')}}</option>
+            </select>
+        </div>
+    </div>
+
+    <div class="summary-list" onosTableResize>
+        <div class="table-header">
+            <table>
+                <tr>
+                    <td colId="state" (click)="onSort('state')">{{lionFn('state')}}
+                        <onos-icon classes="active-sort" [iconSize]="10" [iconId]="sortIcon('state')"></onos-icon>
+                    </td>
+                    <td colId="packets" (click)="onSort('packets')">{{lionFn('packets')}}
+                        <onos-icon classes="active-sort" [iconSize]="10" [iconId]="sortIcon('packets')"></onos-icon>
+                    </td>
+                    <td colId="duration" (click)="onSort('duration')">{{lionFn('duration')}}
+                        <onos-icon classes="active-sort" [iconSize]="10" [iconId]="sortIcon('duration')"></onos-icon>
+                    </td>
+                    <td colId="priority" (click)="onSort('priority')">{{lionFn('priority')}}
+                        <onos-icon classes="active-sort" [iconSize]="10" [iconId]="sortIcon('priority')"></onos-icon>
+                    </td>
+                    <td colId="tableName" (click)="onSort('tableName')">{{lionFn('tableName')}}
+                        <onos-icon classes="active-sort" [iconSize]="10" [iconId]="sortIcon('tableName')"></onos-icon>
+                    </td>
+                    <td colId="selector" (click)="onSort('selector')">{{lionFn('selector')}}
+                        <onos-icon classes="active-sort" [iconSize]="10" [iconId]="sortIcon('selector')"></onos-icon>
+                    </td>
+                    <td colId="treatment" (click)="onSort('treatment')">{{lionFn('treatment')}}
+                        <onos-icon classes="active-sort" [iconSize]="10" [iconId]="sortIcon('treatment')"></onos-icon>
+                    </td>
+                    <td colId="appName" (click)="onSort('appName')">{{lionFn('appName')}}
+                        <onos-icon classes="active-sort" [iconSize]="10" [iconId]="sortIcon('appName')"></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>
+                <ng-template ngFor let-flow [ngForOf]="tableData | filter : tableDataFilter">
+                    <tr (click)="selectCallback($event, flow)" [ngClass]="{selected: flow.id === selId, 'data-change': isChanged(flow.id)}">
+                        <td>{{flow.state}}</td>
+                        <td>{{flow.packets}}</td>
+                        <td>{{flow.duration}}</td>
+                        <td>{{flow.priority}}</td>
+                        <td>{{flow.tableName}}</td>
+                        <td>{{flow.selector_c}}</td>
+                        <td>{{flow.treatment_c}}</td>
+                        <td>{{flow.appName}}</td>
+                    </tr>
+                    <tr (click)="selectCallback($event, flow)" [ngClass]="{selected: flow.id === selId, 'data-change': isChanged(flow.id)}" [hidden]="brief">
+                        <td class="selector" colspan="8">{{flow.selector}} </td>
+                    </tr>
+                    <tr (click)="selectCallback($event, flow)" [ngClass]="{selected: flow.id === selId, 'data-change': isChanged(flow.id)}" [hidden]="brief">
+                        <td class="treatment" colspan="8">{{flow.treatment}}</td>
+                    </tr>
+                </ng-template>
+            </table>
+        </div>
+    </div>
+    <onos-flowdetails class="floatpanels" flowId="{{ selId }}" appId="{{ selRowAppId }}" (closeEvent)="deselectRow($event)"></onos-flowdetails>
+</div>
\ No newline at end of file
diff --git a/web/gui2/src/main/webapp/app/view/flow/flow/flow.component.spec.ts b/web/gui2/src/main/webapp/app/view/flow/flow/flow.component.spec.ts
new file mode 100644
index 0000000..e6ed12a
--- /dev/null
+++ b/web/gui2/src/main/webapp/app/view/flow/flow/flow.component.spec.ts
@@ -0,0 +1,183 @@
+/*
+ * 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 { FlowComponent } from './flow.component';
+import { ActivatedRoute, Params } from '@angular/router';
+import { of } from 'rxjs/index';
+import { LogService } from '../../../log.service';
+import { FnService } from '../../../fw/util/fn.service';
+import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
+import { FormsModule } from '@angular/forms';
+import { RouterTestingModule } from '@angular/router/testing';
+import { TableFilterPipe } from '../../../fw/widget/tablefilter.pipe';
+import { IconComponent } from '../../../fw/svg/icon/icon.component';
+import { IconService } from '../../../fw/svg/icon.service';
+import { GlyphService } from '../../../fw/svg/glyph.service';
+import { KeyService } from '../../../fw/util/key.service';
+import { LoadingService } from '../../../fw/layer/loading.service';
+import { MastService } from '../../../fw/mast/mast.service';
+import { NavService } from '../../../fw/nav/nav.service';
+import { ThemeService } from '../../../fw/util/theme.service';
+import { WebSocketService } from '../../../fw/remote/websocket.service';
+import { DebugElement } from '@angular/core';
+import { By } from '@angular/platform-browser';
+import { LionService } from '../../../fw/util/lion.service';
+import { FlowDetailsComponent } from '../flowdetails/flowdetails/flowdetails.component';
+
+class MockActivatedRoute extends ActivatedRoute {
+    constructor(params: Params) {
+        super();
+        this.queryParams = of(params);
+    }
+}
+
+class MockIconService {
+    loadIconDef() { }
+}
+
+class MockGlyphService { }
+
+class MockKeyService { }
+
+class MockLoadingService {
+    startAnim() { }
+    stop() { }
+}
+
+class MockNavService { }
+
+class MockMastService { }
+
+class MockThemeService { }
+
+class MockWebSocketService {
+    createWebSocket() { }
+    isConnected() { return false; }
+    unbindHandlers() { }
+    bindHandlers() { }
+}
+
+/**
+ * ONOS GUI -- Flow View Module - Unit Tests
+ */
+
+describe('FlowComponent', () => {
+    let fs: FnService;
+    let ar: MockActivatedRoute;
+    let windowMock: Window;
+    let logServiceSpy: jasmine.SpyObj<LogService>;
+    let component: FlowComponent;
+    let fixture: ComponentFixture<FlowComponent>;
+
+    const bundleObj = {
+        'core.view.Flow': {
+            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: [FlowComponent, IconComponent, TableFilterPipe, FlowDetailsComponent],
+            providers: [
+                { provide: FnService, useValue: fs },
+                { provide: IconService, useClass: MockIconService },
+                { provide: GlyphService, useClass: MockGlyphService },
+                { provide: KeyService, useClass: MockKeyService },
+                {
+                    provide: LionService, useFactory: (() => {
+                        return {
+                            bundle: ((bundleId) => mockLion),
+                            ubercache: new Array(),
+                            loadCbs: new Map<string, () => void>([])
+                        };
+                    })
+                },
+                { provide: LoadingService, useClass: MockLoadingService },
+                { provide: MastService, useClass: MockMastService },
+                { provide: NavService, useClass: MockNavService },
+                { provide: LogService, useValue: logSpy },
+                { provide: ThemeService, useClass: MockThemeService },
+                { provide: WebSocketService, useClass: MockWebSocketService },
+                { provide: 'Window', useValue: windowMock },
+            ]
+        }).compileComponents();
+        logServiceSpy = TestBed.get(LogService);
+    }));
+
+    beforeEach(() => {
+        fixture = TestBed.createComponent(FlowComponent);
+        component = fixture.componentInstance;
+        fixture.detectChanges();
+    });
+
+    it('should create', () => {
+        expect(component).toBeTruthy();
+    });
+
+    it('should have a div.tabular-header inside a div#ov-flow', () => {
+        const flowDe: DebugElement = fixture.debugElement;
+        const divDe = flowDe.query(By.css('div#ov-flow div.tabular-header'));
+        expect(divDe).toBeTruthy();
+    });
+
+    it('should have a h2 inside the div.tabular-header', () => {
+        const flowDe: DebugElement = fixture.debugElement;
+        const divDe = flowDe.query(By.css('div#ov-flow div.tabular-header h2'));
+        const div: HTMLElement = divDe.nativeElement;
+        expect(div.textContent).toEqual(' %title_flows%  (0 %total%) ');
+    });
+
+    it('should have .table-header with "State..."', () => {
+        const flowDe: DebugElement = fixture.debugElement;
+        const divDe = flowDe.query(By.css('div#ov-flow div.table-header'));
+        const div: HTMLElement = divDe.nativeElement;
+        expect(div.textContent).toEqual('%state% %packets% %duration% %priority% %tableName% %selector% %treatment% %appName% ');
+    });
+
+    it('should have a refresh button inside the div.tabular-header', () => {
+        const flowDe: DebugElement = fixture.debugElement;
+        const divDe = flowDe.query(By.css('div#ov-flow div.tabular-header div.ctrl-btns div.refresh'));
+        expect(divDe).toBeTruthy();
+    });
+
+
+    it('should have a div.table-body ', () => {
+        const flowDe: DebugElement = fixture.debugElement;
+        const divDe = flowDe.query(By.css('div#ov-flow  div.table-body'));
+        expect(divDe).toBeTruthy();
+    });
+});
diff --git a/web/gui2/src/main/webapp/app/view/flow/flow/flow.component.ts b/web/gui2/src/main/webapp/app/view/flow/flow/flow.component.ts
new file mode 100644
index 0000000..96692a4
--- /dev/null
+++ b/web/gui2/src/main/webapp/app/view/flow/flow/flow.component.ts
@@ -0,0 +1,151 @@
+/*
+ * 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';
+import { LionService } from '../../../fw/util/lion.service';
+
+
+/**
+ * Model of the response from WebSocket
+ */
+interface FlowTableResponse extends TableResponse {
+    flows: Flow[];
+}
+
+/**
+ * Model of the flows returned from the WebSocket
+ */
+interface Flow {
+    state: string;
+    packets: string;
+    duration: string;
+    priority: string;
+    tableName: string;
+    selector: string;
+    treatment: string;
+    appName: string;
+}
+
+/**
+ * ONOS GUI -- Flow View Component
+ */
+@Component({
+    selector: 'onos-flow',
+    templateUrl: './flow.component.html',
+    styleUrls: ['./flow.component.css', './flow.theme.css', '../../../fw/widget/table.css', '../../../fw/widget/table.theme.css']
+})
+export class FlowComponent extends TableBaseImpl implements OnInit, OnDestroy {
+
+    lionFn; // Function
+    id: string;
+    brief: boolean;
+    selRowAppId: string;
+
+    deviceTip: string;
+    detailTip: string;
+    briefTip: string;
+    portTip: string;
+    groupTip: string;
+    meterTip: string;
+    pipeconfTip: string;
+
+    constructor(protected fs: FnService,
+        protected ls: LoadingService,
+        protected log: LogService,
+        protected as: ActivatedRoute,
+        protected wss: WebSocketService,
+        protected lion: LionService,
+    ) {
+        super(fs, ls, log, wss, 'flow');
+        this.as.queryParams.subscribe(params => {
+            this.id = params['devId'];
+
+        });
+        this.brief = true;
+
+        this.payloadParams = {
+            devId: this.id
+        };
+
+        this.responseCallback = this.flowResponseCb;
+
+        this.sortParams = {
+            firstCol: 'state',
+            firstDir: SortDir.desc,
+            secondCol: 'packets',
+            secondDir: SortDir.asc,
+        };
+
+        // We want doLion() to be called only after the Lion
+        // service is populated (from the WebSocket)
+        // If lion is not ready we make do with a dummy function
+        // As soon a lion gets loaded this function will be replaced with
+        // the real thing
+        if (this.lion.ubercache.length === 0) {
+            this.lionFn = this.dummyLion;
+            this.lion.loadCbs.set('flows', () => this.doLion());
+        } else {
+            this.doLion();
+        }
+
+        this.parentSelCb = this.rowSelection;
+    }
+
+    ngOnInit() {
+        this.init();
+        this.log.debug('FlowComponent initialized');
+    }
+
+    ngOnDestroy() {
+        this.lion.loadCbs.delete('flows');
+        this.destroy();
+        this.log.debug('FlowComponent destroyed');
+    }
+
+    flowResponseCb(data: FlowTableResponse) {
+        this.log.debug('Flow response received for ', data.flows.length, 'flow');
+    }
+
+    briefToggle() {
+        this.brief = !this.brief;
+    }
+
+    /**
+     * Read the LION bundle for App and set up the lionFn
+     */
+    doLion() {
+        this.lionFn = this.lion.bundle('core.view.Flow');
+
+        this.deviceTip = this.lionFn('tt_ctl_show_device');
+        this.detailTip = this.lionFn('tt_ctl_switcth_detailed');
+        this.briefTip = this.lionFn('tt_ctl_switcth_brief');
+        this.portTip = this.lionFn('tt_ctl_show_port');
+        this.groupTip = this.lionFn('tt_ctl_show_group');
+        this.meterTip = this.lionFn('tt_ctl_show_meter');
+        this.pipeconfTip = this.lionFn('tt_ctl_show_pipeconf');
+    }
+
+    rowSelection(event: any, selRow: any) {
+        this.selRowAppId = selRow.appId;
+    }
+
+}
diff --git a/web/gui2/src/main/webapp/app/view/flow/flow/flow.theme.css b/web/gui2/src/main/webapp/app/view/flow/flow/flow.theme.css
new file mode 100644
index 0000000..37738a9
--- /dev/null
+++ b/web/gui2/src/main/webapp/app/view/flow/flow/flow.theme.css
@@ -0,0 +1,80 @@
+/*
+ * 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 -- Flow View (theme) -- CSS file
+ */
+
+
+/* a "logical" row is made up of 3 "physical" rows -- color as such */
+ #ov-flow tr:nth-child(6n + 1),
+ #ov-flow tr:nth-child(6n + 2),
+ #ov-flow tr:nth-child(6n + 3) {
+    background-color: #fbfbfb;
+}
+ #ov-flow tr:nth-child(6n + 4),
+ #ov-flow tr:nth-child(6n + 5),
+ #ov-flow tr:nth-child(6n) {
+    background-color: #f4f4f4;
+}
+
+/* highlighted color */
+ #ov-flow tr:nth-child(6n + 1).data-change,
+ #ov-flow tr:nth-child(6n + 2).data-change,
+ #ov-flow tr:nth-child(6n + 3).data-change,
+ #ov-flow tr:nth-child(6n + 4).data-change,
+ #ov-flow tr:nth-child(6n + 5).data-change,
+ #ov-flow tr:nth-child(6n).data-change {
+    background-color: #FDFFDC;
+}
+
+#ov-flow td.selector,
+#ov-flow td.treatment {
+    opacity: 0.65;
+}
+
+/* ========== DARK Theme ========== */
+
+.dark #ov-flow tr:nth-child(6n + 1),
+.dark #ov-flow tr:nth-child(6n + 2),
+.dark #ov-flow tr:nth-child(6n + 3) {
+    background-color: #333333;
+}
+.dark #ov-flow tr:nth-child(6n + 4),
+.dark #ov-flow tr:nth-child(6n + 5),
+.dark #ov-flow tr:nth-child(6n) {
+    background-color: #3a3a3a;
+}
+
+.dark #ov-flow tr:nth-child(6n + 1).data-change,
+.dark #ov-flow tr:nth-child(6n + 2).data-change,
+.dark #ov-flow tr:nth-child(6n + 3).data-change,
+.dark #ov-flow tr:nth-child(6n + 4).data-change,
+.dark #ov-flow tr:nth-child(6n + 5).data-change,
+.dark #ov-flow tr:nth-child(6n).data-change {
+    background-color: #423708;
+}
+
+.light #flow-details-panel .bottom th {
+    background-color: #e5e5e6;
+}
+
+.light #flow-details-panel .bottom tr:nth-child(odd) {
+    background-color: #fbfbfb;
+}
+.light #flow-details-panel .bottom tr:nth-child(even) {
+    background-color: #f4f4f4;
+}
diff --git a/web/gui2/src/main/webapp/app/view/flow/flowdetails/flowdetails/flowdetails.component.css b/web/gui2/src/main/webapp/app/view/flow/flowdetails/flowdetails/flowdetails.component.css
new file mode 100644
index 0000000..2f11349
--- /dev/null
+++ b/web/gui2/src/main/webapp/app/view/flow/flowdetails/flowdetails/flowdetails.component.css
@@ -0,0 +1,66 @@
+/*
+ * 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.
+ */
+
+ #flow-details-panel.floatpanel {
+    z-index: 0;
+    padding-top: 10px;
+    font-size: 10pt;
+    top: 185px;
+}
+
+#flow-details-panel .container {
+    padding: 8px 12px;
+}
+
+#flow-details-panel .close-btn {
+    position: absolute;
+    right: 5px;
+    top: 5px;
+    cursor: pointer;
+}
+
+#flow-details-panel .flow-icon {
+    display: inline-block;
+    padding: 0 6px 0 0;
+    vertical-align: middle;
+}
+
+#flow-details-panel h2 {
+    display: inline-block;
+    margin: 8px 0;
+    font-weight: bold;
+    font-size: 16pt;
+}
+
+#flow-details-panel hr {
+    clear: both;
+    width: 100%;
+    margin: 2px auto;
+}
+
+#flow-details-panel td.label {
+    font-weight: bold;
+    text-align: right;
+    padding-right: 6px;
+}
+
+#flow-details-panel .scroll {
+    border-spacing: 0;
+    height: 400px;
+    width: 520px;
+    overflow: auto;
+    display: block;
+}
diff --git a/web/gui2/src/main/webapp/app/view/flow/flowdetails/flowdetails/flowdetails.component.html b/web/gui2/src/main/webapp/app/view/flow/flowdetails/flowdetails/flowdetails.component.html
new file mode 100644
index 0000000..05d0a47
--- /dev/null
+++ b/web/gui2/src/main/webapp/app/view/flow/flowdetails/flowdetails/flowdetails.component.html
@@ -0,0 +1,116 @@
+<!--
+~ 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="flow-details-panel" class="floatpanel" [@flowDetailsState]="flowId!=='' && !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="flow-icon">
+                <onos-icon classes="details-icon" iconId="flowTable" [iconSize]="42"></onos-icon>
+            </div>
+            <h2>{{ flowId }}</h2>
+            <div class="scroll">
+                <div class="top-content">
+                    <table>
+                        <tbody>
+                            <tr>
+                                <td class="label">{{ lionFn('flowId') }} :</td>
+                                <td class="value">{{ flowId }}</td>
+                            </tr>
+                            <tr>
+                                <td class="label">{{ lionFn('state') }} :</td>
+                                <td class="value">{{ detailsData.state }}</td>
+                            </tr>
+                            <tr>
+                                <td class="label">{{ lionFn('bytes') }} :</td>
+                                <td class="value">{{ detailsData.bytes }}</td>
+                            </tr>
+                            <tr>
+                                <td class="label">{{ lionFn('packets') }} :</td>
+                                <td class="value">{{ detailsData.packets }}</td>
+                            </tr>
+                            <tr>
+                                <td class="label">{{ lionFn('duration') }} :</td>
+                                <td class="value">{{ detailsData.duration }}</td>
+                            </tr>
+                            <tr>
+                                <td class="label">{{ lionFn('priority') }} :</td>
+                                <td class="value">{{ detailsData.priority }}</td>
+                            </tr>
+                            <tr>
+                                <td class="label">{{ lionFn('tableName') }} :</td>
+                                <td class="value">{{ detailsData.tableName }}</td>
+                            </tr>
+                            <tr>
+                                <td class="label">{{ lionFn('appName') }} :</td>
+                                <td class="value">{{ detailsData.appName }}</td>
+                            </tr>
+                            <tr>
+                                <td class="label">{{ lionFn('appId') }} :</td>
+                                <td class="value">{{ detailsData.appId }}</td>
+                            </tr>
+                            <tr>
+                                <td class="label">{{ lionFn('groupId') }} :</td>
+                                <td class="value">{{ detailsData.groupId }}</td>
+                            </tr>
+                            <tr>
+                                <td class="label">{{ lionFn('idleTimeout') }} :</td>
+                                <td class="value">{{ detailsData.idleTimeout }}</td>
+                            </tr>
+                            <tr>
+                                <td class="label">{{ lionFn('hardTimeout') }} :</td>
+                                <td class="value">{{ detailsData.hardTimeout }}</td>
+                            </tr>
+                            <tr>
+                                <td class="label">{{ lionFn('permanent') }} :</td>
+                                <td class="value">{{ detailsData.permanent }}</td>
+                            </tr>
+                        </tbody>
+                    </table>
+                </div>
+                <hr>
+                <h3>{{ lionFn('selector') }}</h3>
+                <div class="top-content">
+                    <table>
+                        <tbody>
+                            <tr>
+                                <td class="label">ETH_TYPE :</td>
+                                <td class="value">{{ detailsData.selector }}</td>
+                            </tr>
+                        </tbody>
+                    </table>
+                </div>
+                <hr>
+                <h3>{{ lionFn('treatment') }}</h3>
+                <div class="top-content">
+                    <table>
+                        <tbody>
+                            <tr>
+                                <td class="label">[imm]OUTPUT :</td>
+                                <td class="value">{{ immed(detailsData.treatment) }}</td>
+                            </tr>
+                            <tr>
+                                <td class="label">Clear deferred :</td>
+                                <td class="value">{{ clearDef(detailsData.treatment) }}</td>
+                            </tr>
+                        </tbody>
+                    </table>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
\ No newline at end of file
diff --git a/web/gui2/src/main/webapp/app/view/flow/flowdetails/flowdetails/flowdetails.component.spec.ts b/web/gui2/src/main/webapp/app/view/flow/flowdetails/flowdetails/flowdetails.component.spec.ts
new file mode 100644
index 0000000..8bbf482
--- /dev/null
+++ b/web/gui2/src/main/webapp/app/view/flow/flowdetails/flowdetails/flowdetails.component.spec.ts
@@ -0,0 +1,140 @@
+/*
+ * 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 { FlowDetailsComponent } from './flowdetails.component';
+import { ActivatedRoute, Params } from '@angular/router';
+import { of } from 'rxjs';
+import { FnService } from '../../../../fw/util/fn.service';
+import { LogService } from '../../../../log.service';
+import { IconService } from '../../../../fw/svg/icon.service';
+import { WebSocketService } from '../../../../fw/remote/websocket.service';
+import { IconComponent } from '../../../../fw/svg/icon/icon.component';
+import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
+import { DebugElement } from '@angular/core';
+import { By } from '@angular/platform-browser';
+
+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('FlowDetailsComponent', () => {
+    let fs: FnService;
+    let ar: MockActivatedRoute;
+    let windowMock: Window;
+    let logServiceSpy: jasmine.SpyObj<LogService>;
+    let component: FlowDetailsComponent;
+    let fixture: ComponentFixture<FlowDetailsComponent>;
+
+    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: [FlowDetailsComponent, 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(FlowDetailsComponent);
+        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 flowDe: DebugElement = fixture.debugElement;
+        const divDe = flowDe.query(By.css('div.container div.top div.close-btn'));
+        expect(divDe).toBeTruthy();
+    });
+
+    it('should have a div.flow-icon inside a div.top inside a div.container', () => {
+        const flowDe: DebugElement = fixture.debugElement;
+        const divDe = flowDe.query(By.css('div.container div.top div.flow-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 flowDe: DebugElement = fixture.debugElement;
+        const divDe = flowDe.query(By.css('div.container div.top div.top-content'));
+        expect(divDe).toBeTruthy();
+    });
+
+    it('should have a div.scroll inside a div.container', () => {
+        const flowDe: DebugElement = fixture.debugElement;
+        const divDe = flowDe.query(By.css('div.container div.scroll'));
+        expect(divDe).toBeTruthy();
+    });
+
+    it('should have a h2 inside a div.top inside a div.container', () => {
+        const flowDe: DebugElement = fixture.debugElement;
+        const divDe = flowDe.query(By.css('div.container div.top h2'));
+        expect(divDe).toBeTruthy();
+    });
+
+    it('should have a h3 inside a div.scroll inside a div.top inside a div.container', () => {
+        const flowDe: DebugElement = fixture.debugElement;
+        const divDe = flowDe.query(By.css('div.container div.top div.scroll h3'));
+        expect(divDe).toBeTruthy();
+    });
+
+    it('should have a hr inside a div.scroll inside a div.top inside a div.container', () => {
+        const flowDe: DebugElement = fixture.debugElement;
+        const divDe = flowDe.query(By.css('div.container div.top div.scroll hr'));
+        expect(divDe).toBeTruthy();
+    });
+});
diff --git a/web/gui2/src/main/webapp/app/view/flow/flowdetails/flowdetails/flowdetails.component.ts b/web/gui2/src/main/webapp/app/view/flow/flowdetails/flowdetails/flowdetails.component.ts
new file mode 100644
index 0000000..3197285
--- /dev/null
+++ b/web/gui2/src/main/webapp/app/view/flow/flowdetails/flowdetails/flowdetails.component.ts
@@ -0,0 +1,158 @@
+/*
+ * 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, OnInit, OnDestroy, OnChanges, Input, Output, EventEmitter } from '@angular/core';
+import { DetailsPanelBaseImpl } from '../../../../fw/widget/detailspanel.base';
+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 { LionService } from '../../../../fw/util/lion.service';
+import { trigger, state, style, transition, animate } from '@angular/animations';
+
+/**
+ * The details view when a flow is clicked from the flows view
+ *
+ * This is expected to be passed an 'id' and it makes a call
+ * to the WebSocket with a flowDetailsRequest, and gets back a
+ * flowDetailsResponse.
+ *
+ * The animated fly-in is controlled by the animation below
+ * The flowDetailsState is attached to flow-details-panel
+ * and is false (flies out) when id='' and true (flies in) when
+ * id has a value
+ */
+@Component({
+    selector: 'onos-flowdetails',
+    templateUrl: './flowdetails.component.html',
+    styleUrls: [
+        './flowdetails.component.css',
+        '../../../../fw/widget/panel.css', '../../../../fw/widget/panel-theme.css'
+    ],
+    animations: [
+        trigger('flowDetailsState', [
+            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 FlowDetailsComponent extends DetailsPanelBaseImpl implements OnInit, OnDestroy, OnChanges {
+
+    @Input() flowId: string;
+    @Input() appId: string;
+
+    @Output() closeEvent = new EventEmitter<string>();
+
+    lionFn; // Function
+
+    constructor(
+        protected fs: FnService,
+        protected ls: LoadingService,
+        protected log: LogService,
+        protected wss: WebSocketService,
+        protected lion: LionService,
+    ) {
+        super(fs, ls, log, wss, 'flow');
+        if (this.lion.ubercache.length === 0) {
+            this.lionFn = this.dummyLion;
+            this.lion.loadCbs.set('flowdetails', () => this.doLion());
+        } else {
+            this.doLion();
+        }
+    }
+
+    /**
+       * There is a possibility that a previous selection
+       * is already registered for call - if so wait 100ms
+       * for it to deregister - this is because in the list of
+       * flows we might have selected one higher up the list and
+       * it is now being processed here before an older selection
+       * farther down the list has been removed
+       */
+    ngOnInit() {
+        this.init();
+        this.log.debug('Flow Details Component initialized:', this.flowId);
+    }
+
+    /**
+     * Stop listening to flowDetailsResponse on WebSocket
+     */
+    ngOnDestroy() {
+        this.lion.loadCbs.delete('flowdetails');
+        this.destroy();
+        this.log.debug('Flow Details Component destroyed');
+    }
+
+    /**
+     * Details Panel Data Request on row selection changes
+     * Should be called whenever flow id changes
+     * If flowId or appId is empty, no request is made
+     */
+    ngOnChanges() {
+        if (this.flowId === '' || this.appId === '') {
+            return;
+        } else {
+            const query = {
+                'flowId': this.flowId,
+                'appId': this.appId
+            };
+            this.requestDetailsPanelData(query);
+        }
+    }
+
+    /**
+     * Read the LION bundle for Flow and set up the lionFn
+     */
+    doLion() {
+        this.lionFn = this.lion.bundle('core.view.Flow');
+    }
+
+    /**
+     * Return immediate value of flow treatment on flow details request
+     */
+    immed(treatmentData: any) {
+        if (treatmentData === undefined) {
+            return '';
+        } else {
+            return treatmentData.immed;
+        }
+    }
+
+    /**
+     * Return clear deferred value of flow treatment on flow details request
+     */
+    clearDef(treatmentData: any) {
+        if (treatmentData === undefined) {
+            return '';
+        } else {
+            return treatmentData.clearDef;
+        }
+    }
+
+    close() {
+        this.flowId = null;
+        this.appId = null;
+        this.closed = true;
+        this.closeEvent.emit(this.flowId);
+    }
+}