blob: 337b1046949c16a0b6d151e93d2ff3a90c01221f [file] [log] [blame]
Sean Condon83fc39f2018-04-19 18:56:13 +01001/*
Sean Condonf4f54a12018-10-10 23:25:46 +01002 * Copyright 2018-present Open Networking Foundation
Sean Condon83fc39f2018-04-19 18:56:13 +01003 *
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 { Injectable } from '@angular/core';
Sean Condon87b78502018-09-17 20:53:24 +010017import { HttpClient } from '@angular/common/http';
Sean Condon83fc39f2018-04-19 18:56:13 +010018import { FnService } from '../util/fn.service';
Sean Condon5ca00262018-09-06 17:55:25 +010019import { LogService } from '../log.service';
Sean Condon83fc39f2018-04-19 18:56:13 +010020
Sean Condon87b78502018-09-17 20:53:24 +010021export interface UiView {
22 id: string;
23 icon: string;
24 cat: string;
25 label: string;
26}
27
Sean Condon83fc39f2018-04-19 18:56:13 +010028/**
29 * ONOS GUI -- Navigation Service
30 */
Sean Condon5ca00262018-09-06 17:55:25 +010031@Injectable({
32 providedIn: 'root',
33})
Sean Condon83fc39f2018-04-19 18:56:13 +010034export class NavService {
35 public showNav = false;
36
Sean Condon87b78502018-09-17 20:53:24 +010037 uiPlatformViews = new Array<UiView>();
38 uiNetworkViews = new Array<UiView>();
39 uiOtherViews = new Array<UiView>();
40 uiHiddenViews = new Array<UiView>();
41
Sean Condon83fc39f2018-04-19 18:56:13 +010042 constructor(
43 private _fn_: FnService,
Sean Condon87b78502018-09-17 20:53:24 +010044 private log: LogService,
45 private httpClient: HttpClient
Sean Condon83fc39f2018-04-19 18:56:13 +010046 ) {
47 this.log.debug('NavService constructed');
48 }
49
50 hideNav() {
51 this.showNav = !this.showNav;
52 if (!this.showNav) {
53 this.log.debug('Hiding Nav menu');
54 }
55 }
56
57 toggleNav() {
58 this.showNav = !this.showNav;
59 if (this.showNav) {
60 this.log.debug('Showing Nav menu');
61 } else {
62 this.log.debug('Hiding Nav menu');
63 }
64 }
65
Sean Condon87b78502018-09-17 20:53:24 +010066 getUiViews() {
67 this.uiPlatformViews = new Array<UiView>();
68 this.uiNetworkViews = new Array<UiView>();
69 this.uiOtherViews = new Array<UiView>();
70 this.uiHiddenViews = new Array<UiView>();
71 this.httpClient.get('rs/nav/uiextensions').subscribe((v: UiView[]) => {
72 v.forEach((uiView: UiView) => {
73 if (uiView.cat === 'PLATFORM') {
74 this.uiPlatformViews.push(uiView);
75 } else if (uiView.cat === 'NETWORK') {
Sean Condonaa4366d2018-11-02 14:29:01 +000076 if ( uiView.id !== 'topo') {
77 this.uiNetworkViews.push(uiView);
78 }
Sean Condon87b78502018-09-17 20:53:24 +010079 } else if (uiView.cat === 'HIDDEN') {
80 this.uiHiddenViews.push(uiView);
81 } else {
82 this.uiOtherViews.push(uiView);
83 }
84 });
85 });
86 }
87
Sean Condon83fc39f2018-04-19 18:56:13 +010088}