blob: 31a84f5d78cd77df5e2559961e54ae1ac2268eee [file] [log] [blame]
Sean Condond6f95bf2020-01-21 10:10:23 +00001/*
2 * Copyright 2020-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 */
16
17import {Component, OnInit, OnDestroy} from '@angular/core';
18import {WebSocketService, LogService, FnService, SortDir, TableBaseImpl, TableResponse} from 'gui2-fw-lib/public_api';
19
20/**
21 * Model of the response from the WebSocket
22 */
23export interface YangModel {
24 id: string;
25 revision: string;
26 modelId: string;
27}
28
29export interface YangModelDataResponse {
30 yangModels: YangModel[];
31}
32
33@Component({
34 selector: 'onos-yangtable',
35 templateUrl: './yangtable.component.html',
36 styleUrls: [
37 './yangtable.component.scss', 'yangtable.theme.scss',
38 '../../../../../web/gui2-fw-lib/lib/widget/table.css', '../../../../../web/gui2-fw-lib/lib/widget/table.theme.css'
39 ]
40})
41export class YangTableComponent extends TableBaseImpl implements OnInit, OnDestroy {
42 selectedModel: YangModel = undefined;
43
44 constructor(
45 protected log: LogService,
46 protected fs: FnService,
47 protected wss: WebSocketService,
48 ) {
49 super(fs, log, wss, 'yangModel');
50 this.log.debug('YangTableComponent constructed');
51 this.parentSelCb = this.rowSelectionParent;
52
53 this.sortParams = {
54 firstCol: 'id',
55 firstDir: SortDir.desc,
56 secondCol: 'revision',
57 secondDir: SortDir.asc,
58 };
59 }
60
61 ngOnInit() {
62 this.init();
63 this.log.debug('YangTableComponent initialized');
64 }
65
66 ngOnDestroy() {
67 this.destroy();
68 this.log.debug('YangTableComponent destroyed');
69 }
70
71 /**
72 * When the upload button is clicked pass this on to the file input (hidden)
73 */
74 triggerForm() {
75 document.getElementById('uploadFile')
76 .dispatchEvent(new MouseEvent('click'));
77 }
78
79 /**
80 * called when a row is selected - sets the state of control icons
81 */
82 rowSelectionParent(event: any, selRow: any) {
83 this.selectedModel = selRow;
84 }
85}