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