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 { LionService } from './fw/util/lion.service'; |
| 18 | import { LogService } from './log.service'; |
| 19 | import { KeyService } from './fw/util/key.service'; |
| 20 | import { ThemeService } from './fw/util/theme.service'; |
| 21 | import { GlyphService } from './fw/svg/glyph.service'; |
| 22 | import { VeilService } from './fw/layer/veil.service'; |
| 23 | import { PanelService } from './fw/layer/panel.service'; |
| 24 | import { FlashService } from './fw/layer/flash.service'; |
| 25 | import { QuickHelpService } from './fw/layer/quickhelp.service'; |
| 26 | import { EeService } from './fw/util/ee.service'; |
| 27 | import { WebSocketService } from './fw/remote/websocket.service'; |
| 28 | import { SpriteService } from './fw/svg/sprite.service'; |
| 29 | import { OnosService, View } from './onos.service'; |
| 30 | |
| 31 | // secret sauce |
| 32 | const sauce: string[] = [ |
| 33 | '6:69857666', |
| 34 | '9:826970', |
| 35 | '22:8069828667', |
| 36 | '6:698570688669887967', |
| 37 | '7:6971806889847186', |
| 38 | '22:8369867682', |
| 39 | '13:736583', |
| 40 | '7:667186698384', |
| 41 | '1:857780888778876787', |
| 42 | '20:70717066', |
| 43 | '24:886774868469', |
| 44 | '17:7487696973687580739078', |
| 45 | '14:70777086', |
| 46 | '17:7287687967', |
| 47 | '11:65678869706783687184', |
| 48 | '1:80777778', |
| 49 | '9:72696982', |
| 50 | '7:857165828967', |
| 51 | '11:8867696882678869759071' |
| 52 | // Add more sauce... |
| 53 | ]; |
| 54 | |
| 55 | function cap(s: string): string { |
| 56 | return s ? s[0].toUpperCase() + s.slice(1) : s; |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * The main ONOS Component - the root of the whole user interface |
| 61 | */ |
| 62 | @Component({ |
| 63 | selector: 'onos-root', |
| 64 | templateUrl: './onos.component.html', |
| 65 | styleUrls: ['./onos.component.css'] |
| 66 | }) |
| 67 | export class OnosComponent implements OnInit { |
| 68 | public title = 'onos'; |
| 69 | |
| 70 | // view ID to help page url map.. injected via the servlet |
| 71 | viewMap: View[] = [ |
| 72 | // {INJECTED-VIEW-DATA-START} |
| 73 | // {INJECTED-VIEW-DATA-END} |
| 74 | ]; |
| 75 | |
| 76 | defaultView = 'topo'; |
| 77 | // TODO Move this to OnosModule - warning servlet will have to be updated too |
| 78 | viewDependencies: string[] = []; |
| 79 | |
| 80 | constructor ( |
| 81 | private lion: LionService, |
| 82 | private ks: KeyService, |
| 83 | private ts: ThemeService, |
| 84 | private gs: GlyphService, |
| 85 | private vs: VeilService, |
| 86 | private ps: PanelService, |
| 87 | private flash: FlashService, |
| 88 | private qhs: QuickHelpService, |
| 89 | private ee: EeService, |
| 90 | private wss: WebSocketService, |
| 91 | private ss: SpriteService, |
| 92 | private log: LogService, |
| 93 | private onos: OnosService |
| 94 | ) { |
| 95 | |
| 96 | // This is not like onos.js of AngularJS 1.x In this new structure modules are |
| 97 | // imported instead in the OnosModule. view dependencies should be there too |
| 98 | // const moduleDependencies = coreDependencies.concat(this.viewDependencies); |
| 99 | |
| 100 | // Testing of debugging |
| 101 | log.debug('OnosComponent: testing logger.debug()'); |
| 102 | log.info('OnosComponent: testing logger.info()'); |
| 103 | log.warn('OnosComponent: testing logger.warn()'); |
| 104 | log.error('OnosComponent: testing logger.error()'); |
| 105 | |
| 106 | log.debug('OnosComponent constructed'); |
| 107 | } |
| 108 | |
| 109 | ngOnInit() { |
| 110 | this.viewMap.forEach(view => |
| 111 | this.viewDependencies.push('ov' + cap(view.id))); |
| 112 | |
| 113 | this.onos.viewMap = this.viewMap; |
| 114 | |
| 115 | // this.wss.createWebSocket({ |
| 116 | // wsport: Window.location.search().wsport |
| 117 | // }); |
| 118 | |
| 119 | // TODO: Enable this this.saucy(this.ee, this.ks); |
| 120 | this.log.debug('OnosComponent initialized'); |
| 121 | } |
| 122 | |
| 123 | saucy(ee, ks) { |
| 124 | const map = ee.genMap(sauce); |
| 125 | Object.keys(map).forEach(function (k) { |
| 126 | ks.addSeq(k, map[k]); |
| 127 | }); |
| 128 | } |
| 129 | } |