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