import { Component, OnInit } from '@angular/core'; import { UserService } from './components/userentity/user.service'; import { ManageDiscountCodeService } from './components/managediscountcode/managediscountcode.service'; import { SubscriptionPriceService } from './components/subscriptionprice/subscriptionprice.service'; import { LicenseService } from './components/licenseentity/license.service'; import { ReportService } from './components/reports/report.service'; import { UserManageRightsModel } from './components/userentity/datamodel'; //import { MyAuthService } from './shared/my-auth.service'; import { GlobalService } from './shared/global'; import { Router, NavigationEnd } from '@angular/router'; //import { HttpClient } from '@angular/common/http'; //import { HttpErrorResponse } from '@angular/common/http'; //import { Observable } from 'rxjs/Observable'; @Component({ selector: 'app-component', templateUrl: '../app/app.component.html', providers: [UserService, ManageDiscountCodeService, SubscriptionPriceService, LicenseService, ReportService] }) export class AppComponent implements OnInit { public obj: any; public objMenu: Array=[]; public objMenuGernal: any; public menustaus: string; public submenustaus: string; public UpdateProfileVisible: boolean; public UserManageRightsList: Array; constructor(private userservice: UserService, public global: GlobalService, private router: Router, ) { } ngOnInit(): void { this.menustaus = "True"; this.global.getJSON().subscribe(data => { this.obj = data["AdminSections"] for (let i = 0; i < 7; i++) { if (this.obj[i].Id == this.global.UserType) { if (this.global.UserTypeName == "General Admin") { this.userservice.GetGeneralAdminMenu({ UserId: this.global.UserId, UserType: this.global.UserTypeName }).subscribe(x => { console.log(x); this.UserManageRightsList = x; this.objMenuGernal = this.obj[i].HeaderMenu; //this.objMenuGernal = this.objMenu; //this.objMenu=''; for (var imenu = 0; imenu < this.objMenuGernal.length; imenu++) { for (var k = 0; k < this.UserManageRightsList.length; k++) { if (this.objMenuGernal[imenu].HeaderMenuName == this.UserManageRightsList[k].Title) { // this.global.objMenu.push(this.objMenuGernal[imenu]); this.objMenu.push(this.objMenuGernal[imenu]); break; } } } this.router.navigate(['/updateuserprofile']); }, error => { }); } else { this.objMenu = this.obj[i].HeaderMenu; this.router.navigate(['/updateuserprofile']); } } } }, error => console.log(error)); } logout() { localStorage.removeItem('loggedInUserDetails'); //window.location.href = this.global.LiveURL; window.location.href = window.location.origin; } Product() { //window.location.href = this.global.LiveURL; window.location.href = window.location.origin; //this.router.navigate([this.global.LiveURL]); } }