blob: fef5123ee5021afa15e44738d4ecc12a9607808e [file] [log] [blame]
Sean Condon83fc39f2018-04-19 18:56:13 +01001/*
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 Condon2aa86092018-07-16 09:04:05 +010016import { Directive, ElementRef } from '@angular/core';
Sean Condon83fc39f2018-04-19 18:56:13 +010017import { FnService } from '../util/fn.service';
18import { LogService } from '../../log.service';
Sean Condon83fc39f2018-04-19 18:56:13 +010019
20/**
21 * ONOS GUI -- Widget -- Table Resize Directive
22 */
23@Directive({
Sean Condon2aa86092018-07-16 09:04:05 +010024 selector: '[onosTableResize]',
Sean Condon83fc39f2018-04-19 18:56:13 +010025})
26export class TableResizeDirective {
27
28 constructor(
29 private fs: FnService,
Sean Condon2aa86092018-07-16 09:04:05 +010030 public log: LogService,
31 private el: ElementRef,
Sean Condon83fc39f2018-04-19 18:56:13 +010032 ) {
Sean Condon2aa86092018-07-16 09:04:05 +010033
34 this.windowSize();
Sean Condon83fc39f2018-04-19 18:56:13 +010035 this.log.debug('TableResizeDirective constructed');
36 }
37
Sean Condon2aa86092018-07-16 09:04:05 +010038 windowSize() {
39 const wsz = this.fs.windowSize(0, 30);
40 this.el.nativeElement.style.width = wsz.width + 'px';
41 }
Sean Condon83fc39f2018-04-19 18:56:13 +010042}