Sean Condon | 28ecc5f | 2018-06-25 12:50:16 +0100 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | import { FnService } from '../util/fn.service'; |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 17 | import { LogService } from '../log.service'; |
Sean Condon | 28ecc5f | 2018-06-25 12:50:16 +0100 | [diff] [blame] | 18 | |
| 19 | |
| 20 | /** |
| 21 | * Base model of panel view - implemented by Panel components |
| 22 | */ |
| 23 | export interface PanelBase { |
| 24 | showPanel(cb: any): void; |
| 25 | hidePanel(cb: any): void; |
| 26 | togglePanel(cb: any): void; |
Sean Condon | 28ecc5f | 2018-06-25 12:50:16 +0100 | [diff] [blame] | 27 | panelIsVisible(): boolean; |
Sean Condon | 28ecc5f | 2018-06-25 12:50:16 +0100 | [diff] [blame] | 28 | } |
| 29 | |
| 30 | /** |
| 31 | * ONOS GUI -- Widget -- Panel Base class |
| 32 | * |
| 33 | * Replacing the panel service in the old implementation |
| 34 | */ |
| 35 | export abstract class PanelBaseImpl implements PanelBase { |
| 36 | |
Sean Condon | f4f54a1 | 2018-10-10 23:25:46 +0100 | [diff] [blame] | 37 | on: boolean; |
Sean Condon | 28ecc5f | 2018-06-25 12:50:16 +0100 | [diff] [blame] | 38 | |
Sean Condon | 55c3053 | 2018-10-29 12:26:57 +0000 | [diff] [blame] | 39 | protected constructor( |
Sean Condon | 28ecc5f | 2018-06-25 12:50:16 +0100 | [diff] [blame] | 40 | protected fs: FnService, |
Sean Condon | 55c3053 | 2018-10-29 12:26:57 +0000 | [diff] [blame] | 41 | protected log: LogService |
Sean Condon | 28ecc5f | 2018-06-25 12:50:16 +0100 | [diff] [blame] | 42 | ) { |
| 43 | // this.log.debug('Panel base class constructed'); |
| 44 | } |
| 45 | |
| 46 | showPanel(cb) { |
Sean Condon | 28ecc5f | 2018-06-25 12:50:16 +0100 | [diff] [blame] | 47 | this.on = true; |
Sean Condon | 28ecc5f | 2018-06-25 12:50:16 +0100 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | hidePanel(cb) { |
Sean Condon | 28ecc5f | 2018-06-25 12:50:16 +0100 | [diff] [blame] | 51 | this.on = false; |
Sean Condon | 28ecc5f | 2018-06-25 12:50:16 +0100 | [diff] [blame] | 52 | } |
| 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 Condon | 28ecc5f | 2018-06-25 12:50:16 +0100 | [diff] [blame] | 63 | panelIsVisible(): boolean { |
| 64 | return this.on; |
| 65 | } |
| 66 | |
Sean Condon | 28ecc5f | 2018-06-25 12:50:16 +0100 | [diff] [blame] | 67 | /** |
| 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 | } |