|
@@ -1,6 +1,7 @@
|
|
|
import { Component, OnInit } from '@angular/core';
|
|
import { Component, OnInit } from '@angular/core';
|
|
|
-import { AuthService } from '../../../services/auth.service';
|
|
|
|
|
|
|
+import { AuthService } from '../../../services/auth2.service';
|
|
|
import { Router } from '@angular/router';
|
|
import { Router } from '@angular/router';
|
|
|
|
|
+import * as CryptoJS from 'crypto-js';
|
|
|
|
|
|
|
|
declare const $: any;
|
|
declare const $: any;
|
|
|
declare interface RouteInfo {
|
|
declare interface RouteInfo {
|
|
@@ -8,12 +9,11 @@ declare interface RouteInfo {
|
|
|
title: string;
|
|
title: string;
|
|
|
icon: string;
|
|
icon: string;
|
|
|
class: string;
|
|
class: string;
|
|
|
|
|
+ allowed_roles?:any;
|
|
|
}
|
|
}
|
|
|
export const ROUTES: RouteInfo[] = [
|
|
export const ROUTES: RouteInfo[] = [
|
|
|
{ path: '/dashboard', title: 'Dashboard', icon: 'dashboard', class: '' },
|
|
{ path: '/dashboard', title: 'Dashboard', icon: 'dashboard', class: '' },
|
|
|
- { path: '/organizations', title: 'Organizaciones', icon:'location_city', class: '' },
|
|
|
|
|
{ path: '/assets', title: 'Plantas', icon: 'wb_sunny', class: '' },
|
|
{ path: '/assets', title: 'Plantas', icon: 'wb_sunny', class: '' },
|
|
|
- //{ path: '/reports', title: 'Reportes', icon: 'assignment', class: '' },
|
|
|
|
|
{ path: '/profile', title: 'Perfil', icon: 'person', class: '' },
|
|
{ path: '/profile', title: 'Perfil', icon: 'person', class: '' },
|
|
|
//{ path: '/profile', title: 'Perfil', icon:'person', class: '' },
|
|
//{ path: '/profile', title: 'Perfil', icon:'person', class: '' },
|
|
|
/*{ path: '/table-list', title: 'Table List', icon:'content_paste', class: '' },
|
|
/*{ path: '/table-list', title: 'Table List', icon:'content_paste', class: '' },
|
|
@@ -24,6 +24,13 @@ export const ROUTES: RouteInfo[] = [
|
|
|
{ path: '/upgrade', title: 'Upgrade to PRO', icon:'unarchive', class: 'active-pro' },*/
|
|
{ path: '/upgrade', title: 'Upgrade to PRO', icon:'unarchive', class: 'active-pro' },*/
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
|
|
+// Extra options to show to the admin
|
|
|
|
|
+export const ADMIN_ROUTES: RouteInfo[] = [
|
|
|
|
|
+ { path: '/organizations', title: 'Organizaciones', icon:'location_city', class: '', allowed_roles: [3] },
|
|
|
|
|
+ { path: '/plants', title: 'Plantas', icon: 'poll', class: '', allowed_roles: [2, 3] },
|
|
|
|
|
+ { path: '/users', title: 'Usuarios', icon: 'people', class: '', allowed_roles: [3] },
|
|
|
|
|
+];
|
|
|
|
|
+
|
|
|
@Component({
|
|
@Component({
|
|
|
selector: 'app-sidebar',
|
|
selector: 'app-sidebar',
|
|
|
templateUrl: './sidebar.component.html',
|
|
templateUrl: './sidebar.component.html',
|
|
@@ -31,11 +38,25 @@ export const ROUTES: RouteInfo[] = [
|
|
|
})
|
|
})
|
|
|
export class SidebarComponent implements OnInit {
|
|
export class SidebarComponent implements OnInit {
|
|
|
menuItems: any[];
|
|
menuItems: any[];
|
|
|
|
|
+ adminMenuItems: any[];
|
|
|
|
|
+ adminMenu:boolean = false;
|
|
|
|
|
+ role_number:any;
|
|
|
|
|
|
|
|
- constructor(private auth: AuthService, private router: Router) { }
|
|
|
|
|
|
|
+ constructor(private auth: AuthService, private router: Router) {
|
|
|
|
|
+ console.log(localStorage.getItem("USER_MENU"));
|
|
|
|
|
+ var bytes = CryptoJS.AES.decrypt(localStorage.getItem("USER_MENU"), 'soma-inverlec-2019');
|
|
|
|
|
+ this.role_number = bytes.toString(CryptoJS.enc.Utf8);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
ngOnInit() {
|
|
|
this.menuItems = ROUTES.filter(menuItem => menuItem);
|
|
this.menuItems = ROUTES.filter(menuItem => menuItem);
|
|
|
|
|
+ this.adminMenuItems = ADMIN_ROUTES.filter(menuItem => menuItem);
|
|
|
|
|
+
|
|
|
|
|
+ // must be changed for the method that returns if it is an admin
|
|
|
|
|
+ if (this.auth.isLoggedIn() == true) {
|
|
|
|
|
+ this.adminMenu = true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
isMobileMenu() {
|
|
isMobileMenu() {
|