blob: c13e2f50e6751436e6458eddd720fa44b9a8c3d1 [file] [log] [blame]
Bhavesh72ead492018-07-19 16:29:18 +05301/*
2* Copyright 2018-present Open Networking Foundation
3*
4* Licensed under the Apache License, Version 2.0 (the "License");
5* you may not use this file except in compliance with the License.
6* You may obtain a copy of the License at
7*
8* http://www.apache.org/licenses/LICENSE-2.0
9*
10* Unless required by applicable law or agreed to in writing, software
11* distributed under the License is distributed on an "AS IS" BASIS,
12* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13* See the License for the specific language governing permissions and
14* limitations under the License.
15*/
16import { Component, OnInit, OnDestroy } from '@angular/core';
17import { FnService } from '../../../fw/util/fn.service';
18import { LoadingService } from '../../../fw/layer/loading.service';
19import { LogService } from '../../../log.service';
20import { TableBaseImpl, TableResponse, SortDir } from '../../../fw/widget/table.base';
21import { WebSocketService } from '../../../fw/remote/websocket.service';
22
23interface HostTableResponse extends TableResponse {
24 hosts: Host[];
25}
26
27interface Host {
28 name: boolean;
29 id: string;
30 hw: string;
31 vlanId: string;
32 configured: string;
33 address: string;
34 location: string;
35 _iconid_type: string;
36}
37
38/**
39 * ONOS GUI -- Host View Component
40 */
41@Component({
42 selector: 'onos-host',
43 templateUrl: './host.component.html',
44 styleUrls: ['./host.component.css',
45 '../../../fw/widget/table.css', '../../../fw/widget/table.theme.css']
46})
47export class HostComponent extends TableBaseImpl implements OnInit, OnDestroy {
48
49 constructor(
50 protected fs: FnService,
51 protected ls: LoadingService,
52 protected log: LogService,
53 protected wss: WebSocketService,
54 ) {
55 super(fs, ls, log, wss, 'host');
56 this.responseCallback = this.hostResponseCb;
57 this.sortParams = {
58 firstCol: 'name',
59 firstDir: SortDir.desc,
60 secondCol: 'id',
61 secondDir: SortDir.asc,
62 };
63 }
64
65 ngOnInit() {
66 this.init();
67 this.log.debug('HostComponent initialized');
68 }
69
70 ngOnDestroy() {
71 this.destroy();
72 this.log.debug('HostComponent destroyed');
73 }
74
75 hostResponseCb(data: HostTableResponse) {
76 this.log.debug('Host response received for ', data.hosts.length, 'host');
77 }
78
79}