summaryrefslogtreecommitdiffstats
path: root/usecaseui-portal/src/app/app.component.ts
blob: 7abec444868727e1c0f747159eef75c86a8553dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
    Copyright (C) 2019 CMCC, Inc. and others. All rights reserved.

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

            http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
*/
import { Component } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { ServiceListService } from "./core/services/serviceList.service";
import { HomesService } from "./core/services/homes.service";
import { NavigationEnd, Router } from '@angular/router';
import 'rxjs/add/operator/map';

@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.less']
})
export class AppComponent {

    public url: string = 'home';
    constructor(private translate: TranslateService, private myhttp: HomesService, private router: Router, ) {
        this.currentLanguageGet();
        this.getUrl();
    }

    // Get the current routing path
    getUrl() {
        this.router.events.map(event => {
            if (event instanceof NavigationEnd) {
                this.url = event['urlAfterRedirects'].slice(1)
            }
        }).subscribe(event => { })
    }

    //209.05.08 Get the currentLanguage
    currentloginId = null;
    currentLanguage = "en";
    currentLanguageGet() {
        this.currentloginId = sessionStorage.getItem("userId") || null;
        if (this.currentloginId != null) {
            this.myhttp.getCurrentLanguage(this.currentloginId)
                .subscribe(
                    (data) => {
                        console.log(data, "-------------getCurrentLanguage");
                        this.currentLanguage = data.languageAlias.toLowerCase();
                        this.translate.use(this.currentLanguage);
                        sessionStorage.setItem("DefaultLang", this.currentLanguage);
                    },
                    (err) => {
                        console.log(err);
                    }
                )
        } else {
            this.translate.setDefaultLang(this.currentLanguage);
            sessionStorage.setItem("DefaultLang", this.currentLanguage);
        }
    }

    // Whether the submenu expands the identifier
    get flag() {
        if (!this.url.indexOf('services')) {
            return true
        } else {
            return false
        }
    }
    get monitorflag() {
        if (!this.url.indexOf('fcaps')) {
            return true
        } else {
            return false
        }
    }
    // Whether the submenu expands the identifier
    get network_flag () {
        if(!this.url.indexOf('network')){
            return true
        }else{
            return false
        }
    }

}