blob: f568dc8791ab727501a715b911dfeaeb4e8a21de [file] [log] [blame]
Sean Condon28ecc5f2018-06-25 12:50:16 +01001/*
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 { FnService } from '../util/fn.service';
Sean Condon5ca00262018-09-06 17:55:25 +010017import { LogService } from '../log.service';
Sean Condon28ecc5f2018-06-25 12:50:16 +010018
19
20/**
21 * Base model of panel view - implemented by Panel components
22 */
23export interface PanelBase {
24 showPanel(cb: any): void;
25 hidePanel(cb: any): void;
26 togglePanel(cb: any): void;
Sean Condon28ecc5f2018-06-25 12:50:16 +010027 panelIsVisible(): boolean;
Sean Condon28ecc5f2018-06-25 12:50:16 +010028}
29
30/**
31 * ONOS GUI -- Widget -- Panel Base class
32 *
33 * Replacing the panel service in the old implementation
34 */
35export abstract class PanelBaseImpl implements PanelBase {
36
Sean Condonf4f54a12018-10-10 23:25:46 +010037 on: boolean;
Sean Condon28ecc5f2018-06-25 12:50:16 +010038
Sean Condon55c30532018-10-29 12:26:57 +000039 protected constructor(
Sean Condon28ecc5f2018-06-25 12:50:16 +010040 protected fs: FnService,
Sean Condon55c30532018-10-29 12:26:57 +000041 protected log: LogService
Sean Condon28ecc5f2018-06-25 12:50:16 +010042 ) {
43// this.log.debug('Panel base class constructed');
44 }
45
46 showPanel(cb) {
Sean Condon28ecc5f2018-06-25 12:50:16 +010047 this.on = true;
Sean Condon28ecc5f2018-06-25 12:50:16 +010048 }
49
50 hidePanel(cb) {
Sean Condon28ecc5f2018-06-25 12:50:16 +010051 this.on = false;
Sean Condon28ecc5f2018-06-25 12:50:16 +010052 }
53
54 togglePanel(cb): boolean {
55 if (this.on) {
56 this.hidePanel(cb);
57 } else {
58 this.showPanel(cb);
59 }
60 return this.on;
61 }
62
Sean Condon28ecc5f2018-06-25 12:50:16 +010063 panelIsVisible(): boolean {
64 return this.on;
65 }
66
Sean Condon28ecc5f2018-06-25 12:50:16 +010067 /**
68 * A dummy implementation of the lionFn until the response is received and the LION
69 * bundle is received from the WebSocket
70 */
71 dummyLion(key: string): string {
72 return '%' + key + '%';
73 }
74}