blob: 0377c473dd6f5ffeaa20f1619a11db94a53c6a75 [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';
17import { LoadingService } from '../layer/loading.service';
Sean Condon5ca00262018-09-06 17:55:25 +010018import { LogService } from '../log.service';
Sean Condon28ecc5f2018-06-25 12:50:16 +010019
20
21/**
22 * Base model of panel view - implemented by Panel components
23 */
24export interface PanelBase {
25 showPanel(cb: any): void;
26 hidePanel(cb: any): void;
27 togglePanel(cb: any): void;
Sean Condon28ecc5f2018-06-25 12:50:16 +010028 panelIsVisible(): boolean;
Sean Condon28ecc5f2018-06-25 12:50:16 +010029}
30
31/**
32 * ONOS GUI -- Widget -- Panel Base class
33 *
34 * Replacing the panel service in the old implementation
35 */
36export abstract class PanelBaseImpl implements PanelBase {
37
Sean Condonf4f54a12018-10-10 23:25:46 +010038 on: boolean;
Sean Condon28ecc5f2018-06-25 12:50:16 +010039
40 constructor(
41 protected fs: FnService,
42 protected ls: LoadingService,
43 protected log: LogService,
Sean Condon28ecc5f2018-06-25 12:50:16 +010044 ) {
45// this.log.debug('Panel base class constructed');
46 }
47
48 showPanel(cb) {
Sean Condon28ecc5f2018-06-25 12:50:16 +010049 this.on = true;
Sean Condon28ecc5f2018-06-25 12:50:16 +010050 }
51
52 hidePanel(cb) {
Sean Condon28ecc5f2018-06-25 12:50:16 +010053 this.on = false;
Sean Condon28ecc5f2018-06-25 12:50:16 +010054 }
55
56 togglePanel(cb): boolean {
57 if (this.on) {
58 this.hidePanel(cb);
59 } else {
60 this.showPanel(cb);
61 }
62 return this.on;
63 }
64
Sean Condon28ecc5f2018-06-25 12:50:16 +010065 panelIsVisible(): boolean {
66 return this.on;
67 }
68
Sean Condon28ecc5f2018-06-25 12:50:16 +010069 /**
70 * A dummy implementation of the lionFn until the response is received and the LION
71 * bundle is received from the WebSocket
72 */
73 dummyLion(key: string): string {
74 return '%' + key + '%';
75 }
76}