Commit f32c313a authored by hasan khaddour's avatar hasan khaddour

fix side bar

parent 4e3b3a70
<li class="nav-item"> <li class="nav-item">
<a class="nav-link " [class.collapsed]="item.haschild" data-bs-target="#components-nav" data-bs-toggle="collapse" href="#"> <a class="nav-link " [class.collapsed]="true" [routerLink]="[item.routing]">
<i class="fe fe-menu"></i><span>{{item.name}}</span><i class="bi bi-chevron-down ms-auto"></i> <i class="fe fe-menu"></i><span>{{item.name}}</span><i class="bi bi-chevron-down ms-auto"></i>
</a> </a>
<ul *ngFor="let i of item.child">
<nav-item [item]="i"></nav-item>
</ul>
</li><!-- End Components Nav --> </li><!-- End Components Nav -->
\ No newline at end of file
...@@ -2,10 +2,15 @@ import { Component, Input } from '@angular/core'; ...@@ -2,10 +2,15 @@ import { Component, Input } from '@angular/core';
export interface NavItem { export interface NavItem {
name : string , name : string ,
child : NavItem []| null, isCollapsed:boolean
haschild:boolean requiredRole : string ,
icon : string ,
isBar :boolean,
queryParams: string
routing : string
} }
@Component({ @Component({
selector: 'nav-item', selector: 'nav-item',
templateUrl: './nav-item.component.html', templateUrl: './nav-item.component.html',
......
import { NavItem } from "../componenets/nav-item/nav-item.component";
export const sideItems : NavItem[] =[
{
name:'الصفحة الرئيسية',
icon:'fe fe-grid',
routing:'/',
isCollapsed:true,
isBar:false ,
queryParams:'',
requiredRole:'employee'
},
{
name:'المتابعة',
icon:'',
routing:'',
isCollapsed:true,
isBar:true,
requiredRole:'employee',
queryParams:'',
},
{
name:'المتابعات غير المكتملة',
icon:'fe-menu',
routing:'/tracks/uncompleted',
isCollapsed:false,
isBar:false,
requiredRole:'employee',
queryParams:'',
},
{
name:'عمليات المتابعة',
icon:'fe-flag',
routing:'/tracks',
isCollapsed:false,
isBar:false,
requiredRole:'employee',
queryParams:'',
},
{
name:'أنواع المشاريع',
icon:'',
routing:'',
isCollapsed:false,
isBar:true,
requiredRole:'planner',
queryParams:'',
},
{
name:'استعراض أنواع المشاريع',
icon:'fe-map',
routing:'/types',
isCollapsed:false,
isBar:false,
requiredRole:'employee',
queryParams:'',
},
{
name:'إضافة نوع جديد',
icon:'fe-edit-2',
routing:'/types/create',
isCollapsed:false,
isBar:false,
requiredRole:'planner',
queryParams:'',
},
{
name:'الجهات الطارحة',
icon:'',
routing:'',
isCollapsed:false,
isBar:true,
requiredRole:'planner',
queryParams:'',
},
{
name:'استعراض الجهات الطارحة',
icon:'fe-map',
routing:'/customers',
isCollapsed:false,
isBar:false,
requiredRole:'employee',
queryParams:'',
},
{
name:'إضافة جهة طارحة',
icon:'fe-edit-2',
routing:'/customers/create',
isCollapsed:false,
isBar:false,
requiredRole:'planner',
queryParams:'',
},
{
name:'إدارة المشاريع',
icon:'',
routing:'',
isCollapsed:false,
isBar:true,
requiredRole:'employee',
queryParams:''
}
,
{
name:'طرح مشروع',
icon:'fe-plus',
routing:'/projects/create',
isCollapsed:false,
isBar:false,
queryParams:'',
requiredRole:'employee'
},
{
name:'استعراض المشاريع',
icon:'fe-map',
routing:'/projects',
queryParams:"{ listType: 'all'}",
isCollapsed:false,
isBar:false,
requiredRole:'scientific-deputy'
},
{
name:'المشاريع التي أدريرها',
icon:'fe-edit-2',
routing:'/customers/create',
isCollapsed:false,
isBar:false,
queryParams:"{ listType: 'managed'}",
requiredRole:'planner'
},
{
name:'المشاريع التي أرأسها',
icon:'fe-edit-2',
routing:'/customers/create',
isCollapsed:false,
isBar:false,
queryParams:"{ listType: 'leaded'}",
requiredRole:'planner'
},
{
name:'العمل',
icon:'',
routing:'',
isCollapsed:false,
isBar:true,
requiredRole:'employee',
queryParams:''
}
,
{
name:'استعراض مساهماتي',
icon:'fe-plus',
routing:'/projects/create',
isCollapsed:false,
isBar:false,
queryParams:'',
requiredRole:'employee'
},
{
name:'ملفي الشخصي',
icon:'fe-map',
routing:'/projects',
queryParams:"{ listType: 'all'}",
isCollapsed:false,
isBar:false,
requiredRole:'employee'
},
]
\ No newline at end of file
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
<aside dir="rtl" id="sidebar" class="sidebar" [class.toggled]="isToggled"> <aside dir="rtl" id="sidebar" class="sidebar" [class.toggled]="isToggled">
<ul class="sidebar-nav" id="sidebar-nav"> <ul class="sidebar-nav" id="sidebar-nav">
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" [routerLink]="['/']"> <a class="nav-link" [routerLink]="['/']">
<i class="fe fe-grid"></i> <i class="fe fe-grid"></i>
...@@ -11,18 +12,11 @@ ...@@ -11,18 +12,11 @@
<li class="nav-heading">المتابعة</li> <li class="nav-heading">المتابعة</li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link collapsed" data-bs-target="#components-nav" data-bs-toggle="collapse" > <a class="nav-link collapsed"
<i class="fe fe-menu"></i><span>إدارة المتابعة</span><i class="bi bi-chevron-down ms-auto"></i> [routerLink]="['/tracks/uncompleted']"
</a> >
<ul id="components-nav" class="nav-content collapse " data-bs-parent="#sidebar-nav"> <i class="fe fe-airplay"></i><span>المتابعات غير المكتملة</span>
<li> </a>
<a [routerLink]="['/tracks/uncompleted']">
<i class="fe fe-circle"></i><span>المتابعات غير المكتملة</span>
</a>
</li>
</ul>
</li><!-- End Components Nav --> </li><!-- End Components Nav -->
<li class="nav-item"> <li class="nav-item">
...@@ -37,8 +31,14 @@ ...@@ -37,8 +31,14 @@
<i class="fe fe-map"></i><span> استعراض أنواع المشاريع</span> <i class="fe fe-map"></i><span> استعراض أنواع المشاريع</span>
</a> </a>
</li> </li>
<li class="nav-item"> <li class="nav-item"
<a [routerLink]="['/types/create']" class="nav-link collapsed " >
*ngIf="hasRole('Planner')"
>
<a [routerLink]="['/types/create']" class="nav-link collapsed "
>
<i class="fe fe-edit-2"></i><span>إضافة نوع جديد</span> <i class="fe fe-edit-2"></i><span>إضافة نوع جديد</span>
</a> </a>
</li> </li>
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
<li class="nav-item"> <li class="nav-item">
<a [routerLink]="['/projects/create']" class="nav-link collapsed" > <a [routerLink]="['/projects/create']" class="nav-link collapsed" >
<i class="bi bi-circle"></i><span>طرح مشروع</span> <i class="bi fe-plus"></i><span>طرح مشروع</span>
</a> </a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
......
import { Component, Input, input, OnInit } from '@angular/core'; import { Component, Input, input, OnInit } from '@angular/core';
import { NavItem } from '../../componenets/nav-item/nav-item.component'; import { NavItem } from '../../componenets/nav-item/nav-item.component';
import { UserService } from '../../../core/services/authentication/user.service'; import { UserService } from '../../../core/services/authentication/user.service';
import { lastValueFrom } from 'rxjs';
@Component({ @Component({
selector: 'app-sidebar', selector: 'app-sidebar',
...@@ -10,12 +11,23 @@ import { UserService } from '../../../core/services/authentication/user.service' ...@@ -10,12 +11,23 @@ import { UserService } from '../../../core/services/authentication/user.service'
export class SidebarComponent implements OnInit { export class SidebarComponent implements OnInit {
id : number id : number
roles :string[]
constructor(private userService : UserService){} constructor(private userService : UserService){}
@Input() isToggled: Boolean; @Input() isToggled: Boolean;
ngOnInit(): void { ngOnInit(): void {
this.roles=this.userService.getCurrentUser().roles
this.id= this.userService.getEmployeeId(); this.id= this.userService.getEmployeeId();
} }
hasRole(roleName: string): boolean {
return this.roles.filter(e => e == roleName).length != 0
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment