Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014-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 { DialogService } from '../../layer/dialog.service'; |
| 18 | import { LionService } from '../../util/lion.service'; |
| 19 | import { LogService } from '../../../log.service'; |
| 20 | import { NavService } from '../../nav/nav.service'; |
| 21 | import { WebSocketService } from '../../remote/websocket.service'; |
| 22 | |
| 23 | /** |
| 24 | * ONOS GUI -- Masthead Component |
| 25 | */ |
| 26 | @Component({ |
| 27 | selector: 'onos-mast', |
| 28 | templateUrl: './mast.component.html', |
| 29 | styleUrls: ['./mast.component.css', './mast.theme.css'] |
| 30 | }) |
| 31 | export class MastComponent implements OnInit { |
| 32 | public username; |
| 33 | |
| 34 | constructor( |
| 35 | private ds: DialogService, |
| 36 | private ls: LionService, |
| 37 | private log: LogService, |
| 38 | public ns: NavService, |
| 39 | private wss: WebSocketService |
| 40 | ) { |
| 41 | this.log.debug('MastComponent constructed'); |
| 42 | |
| 43 | } |
| 44 | |
| 45 | ngOnInit() { |
| 46 | // onosUser is a global set via the index.html generated source |
| 47 | // TODO: Fix onosuser below to get it from index.html like before |
| 48 | // TODO: Fix the lionService |
| 49 | this.username = 'onosUser'; // || this.getLion('unknown_user'); |
| 50 | |
| 51 | this.log.debug('MastComponent initialized'); |
| 52 | } |
| 53 | |
| 54 | |
| 55 | |
| 56 | /* In the case of Masthead, we cannot cache the lion bundle, because we |
| 57 | * call too early (before the lion data is uploaded from the server). |
| 58 | * So we'll dig into the lion service for each request... |
| 59 | */ |
| 60 | getLion(x: string): string { |
| 61 | // lion is a function that takes a string and returns a string |
| 62 | const lion: (string) => string = this.ls.bundle('core.fw.Mast'); |
| 63 | return lion(x); |
| 64 | } |
| 65 | |
| 66 | } |