Sean Condon | f4f54a1 | 2018-10-10 23:25:46 +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 { Component, OnInit } from '@angular/core'; |
| 17 | import { ViewControllerImpl } from '../viewcontroller'; |
| 18 | import { |
| 19 | FnService, |
| 20 | LogService, |
| 21 | PrefsService, |
| 22 | IconService, |
| 23 | SvgUtilService |
| 24 | } from 'gui2-fw-lib'; |
| 25 | |
| 26 | /** |
| 27 | * ONOS GUI -- Topology No Connected Devices View. |
| 28 | * View that contains the 'No Connected Devices' message |
| 29 | * |
| 30 | * This component is an SVG snippet that expects to be in an SVG element with a view box of 1000x1000 |
| 31 | * |
| 32 | * It should be added to a template with a tag like <svg:g onos-nodeviceconnected /> |
| 33 | */ |
| 34 | @Component({ |
| 35 | selector: '[onos-nodeviceconnected]', |
| 36 | templateUrl: './nodeviceconnectedsvg.component.html', |
| 37 | styleUrls: ['./nodeviceconnectedsvg.component.css'] |
| 38 | }) |
| 39 | export class NoDeviceConnectedSvgComponent extends ViewControllerImpl implements OnInit { |
| 40 | |
| 41 | constructor( |
| 42 | protected fs: FnService, |
| 43 | protected log: LogService, |
| 44 | protected ps: PrefsService, |
| 45 | protected is: IconService, |
| 46 | protected sus: SvgUtilService |
| 47 | ) { |
| 48 | super(fs, log, ps); |
| 49 | this.is.loadIconDef('bird'); |
| 50 | this.log.debug('NoDeviceConnectedSvgComponent constructed'); |
| 51 | } |
| 52 | |
| 53 | ngOnInit() { |
| 54 | this.log.debug('NoDeviceConnectedSvgComponent initialized'); |
| 55 | } |
| 56 | |
| 57 | /* |
| 58 | * The whole SVG canvas is based on a 1000 by 1000 box |
| 59 | */ |
| 60 | centre(repositionBox: SVGRect) { |
| 61 | const scale: number = Number.parseFloat((1000 / repositionBox.width).toFixed(3)); |
| 62 | repositionBox.x -= Number.parseFloat((repositionBox.width * scale / 2).toFixed(0)); |
| 63 | repositionBox.y -= Number.parseFloat((repositionBox.height * scale / 2).toFixed(0)); |
| 64 | return this.sus.translate([repositionBox.x, repositionBox.y]) + '' + this.sus.scale(scale, scale); |
| 65 | } |
| 66 | |
| 67 | } |