Sean Condon | 0c577f6 | 2018-11-18 22:40:05 +0000 | [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 { |
| 17 | Component, |
| 18 | Input, |
| 19 | OnChanges, |
| 20 | SimpleChanges |
| 21 | } from '@angular/core'; |
| 22 | import { Host } from '../../models'; |
| 23 | import {LogService} from 'gui2-fw-lib'; |
| 24 | |
| 25 | /** |
| 26 | * The Host node in the force graph |
| 27 | * |
| 28 | * Note 1: here the selector is given square brackets [] so that it can be |
| 29 | * inserted in SVG element like a directive |
| 30 | * Note 2: the selector is exactly the same as the @Input alias to make this |
| 31 | * directive trick work |
| 32 | */ |
| 33 | @Component({ |
| 34 | selector: '[onos-hostnodesvg]', |
| 35 | templateUrl: './hostnodesvg.component.html', |
| 36 | styleUrls: ['./hostnodesvg.component.css'] |
| 37 | }) |
| 38 | export class HostNodeSvgComponent implements OnChanges { |
| 39 | @Input() host: Host; |
| 40 | |
| 41 | constructor( |
| 42 | protected log: LogService |
| 43 | ) { |
| 44 | } |
| 45 | |
| 46 | ngOnChanges(changes: SimpleChanges) { |
| 47 | if (!this.host.x) { |
| 48 | this.host.x = 0; |
| 49 | this.host.y = 0; |
| 50 | } |
| 51 | } |
| 52 | } |