Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015-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 | */ |
Sean Condon | 2aa8609 | 2018-07-16 09:04:05 +0100 | [diff] [blame^] | 16 | import { Directive, ElementRef } from '@angular/core'; |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 17 | import { FnService } from '../util/fn.service'; |
| 18 | import { LogService } from '../../log.service'; |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 19 | |
| 20 | /** |
| 21 | * ONOS GUI -- Widget -- Table Resize Directive |
| 22 | */ |
| 23 | @Directive({ |
Sean Condon | 2aa8609 | 2018-07-16 09:04:05 +0100 | [diff] [blame^] | 24 | selector: '[onosTableResize]', |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 25 | }) |
| 26 | export class TableResizeDirective { |
| 27 | |
| 28 | constructor( |
| 29 | private fs: FnService, |
Sean Condon | 2aa8609 | 2018-07-16 09:04:05 +0100 | [diff] [blame^] | 30 | public log: LogService, |
| 31 | private el: ElementRef, |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 32 | ) { |
Sean Condon | 2aa8609 | 2018-07-16 09:04:05 +0100 | [diff] [blame^] | 33 | |
| 34 | this.windowSize(); |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 35 | this.log.debug('TableResizeDirective constructed'); |
| 36 | } |
| 37 | |
Sean Condon | 2aa8609 | 2018-07-16 09:04:05 +0100 | [diff] [blame^] | 38 | windowSize() { |
| 39 | const wsz = this.fs.windowSize(0, 30); |
| 40 | this.el.nativeElement.style.width = wsz.width + 'px'; |
| 41 | } |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 42 | } |