Commit 96cafcae authored by hasan khaddour's avatar hasan khaddour

add roles guard for projects

parent a076dc2c
......@@ -36,6 +36,7 @@
"material": "^0.9.15",
"moment": "^2.30.1",
"ngx-cookie-service": "^18.0.0",
"ngx-gantt": "^0.3.5",
"ngx-pagination": "^6.0.3",
"ngx-toastr": "^19.0.0",
"rxjs": "~7.8.0",
......@@ -9177,8 +9178,7 @@
"node_modules/lodash": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
"dev": true
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
},
"node_modules/lodash.debounce": {
"version": "4.0.8",
......@@ -9956,6 +9956,17 @@
"@angular/core": "^18.0.0-rc.0"
}
},
"node_modules/ngx-gantt": {
"version": "0.3.5",
"resolved": "https://registry.npmjs.org/ngx-gantt/-/ngx-gantt-0.3.5.tgz",
"integrity": "sha512-zK7z9r8dFBBS3f2HdLxkNGsMsuEL13JZW7h54tZYgG2m80X7Fq0A8BqoQXVlkhmWdHLArlkEhi2hcgE3sWXUig==",
"peerDependencies": {
"@angular/core": "^5.2.8",
"lodash": "^4.17.5",
"rxjs": "^5.5.7",
"zone.js": "^0.8.20"
}
},
"node_modules/ngx-i18nsupport": {
"version": "0.17.1",
"resolved": "https://registry.npmjs.org/ngx-i18nsupport/-/ngx-i18nsupport-0.17.1.tgz",
......
<div class="row justify-content-center">
<div class="col-12">
<div class="row align-items-center my-4">
<div class="col">
<h2 class="h3 mb-0 page-title"> قائمة المشاريع </h2>
</div>
<div class="col-auto">
<button type="button" (click)="this.router.navigate(['projects/create'])" class="btn btn-primary"><span class="fe fe-file-plus fe-12 mr-2"></span>طرح مشروع</button>
</div>
</div>
<hr>
<div *ngIf="projects">
<div class="row" *ngIf="projects.length > 0">
<project-item class="col-4" *ngFor="let project of projects" [project]="project"></project-item>
</div>
<div class="row" *ngIf="projects.length == 0">
لا يوجد أي مشروع
</div>
</div>
</div>
</div>
import { Component } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { ToastrService } from 'ngx-toastr';
import { UserService } from '../../../core/services/authentication/user.service';
import { LoadingService } from '../../../core/services/loading/loading-service.service';
import { GetProjectsByProjectManagerRequest, GetProjectsByTeamLeaderRequest } from '../../models/requests/project-requests/GetProjectsByProjectManagerRequest';
import { Project } from '../../models/responses/project';
import { ProjectService } from '../../services/project.service';
@Component({
selector: 'project-bycreterion',
templateUrl: './project-bycreterion.component.html',
styleUrl: './project-bycreterion.component.css'
})
export class ProjectBycreterionComponent {
listType : string
projects : Project[]
constructor(
private projectService : ProjectService,
private toastr: ToastrService,
public router: Router,
private route :ActivatedRoute,
private userService : UserService,
private loadingService: LoadingService
) {
}
ngOnInit(): void {
this.route.queryParams.subscribe(params => {
this.listType = params['listType'];
}
);
this.loadProjects();
}
loadProjects():void{
this.loadingService.show()
switch (this.listType) {
case 'managed':
this.handelByManager()
break;
case 'leaded':
this.handelByLeader()
break;
default :
this.router.navigate(['/home'])
this.toastr.error('لقد طلبت صفحة غير موجودة ')
break ;
}
}
handelByManager(){
let request :GetProjectsByProjectManagerRequest = {
projectMangerId : this.userService.getEmployeeId(),
pageNumber: null ,
pageSize:null
}
this.projectService.getByProjectManger(request)
.subscribe(
{
next: (res)=>{
this.projects = res;
this.toastr.success("تم تحميل المشاريع بنجاح");
this.loadingService.hide()
},
error: (err)=>{
this.toastr.error("لقد حدث خظاء ما");
this.loadingService.hide()
}
}
);
}
handelByLeader(){
let request :GetProjectsByTeamLeaderRequest ={
teamLeaderrId : this.userService.getEmployeeId(),
pageNumber: null ,
pageSize:null
}
this.projectService.getByTeamLeader(request)
.subscribe(
{
next: (res)=>{
this.projects = res;
this.toastr.success("تم تحميل المشاريع بنجاح");
this.loadingService.hide()
},
error: (err)=>{
this.toastr.error("لقد حدث خظاء ما");
this.loadingService.hide()
}
}
);
}
}
......@@ -14,9 +14,9 @@ import { UserService } from '../../../core/services/authentication/user.service'
})
export class ProjectListComponent implements OnInit{
listType : string
projects : Project[]
constructor(
private projectService : ProjectService,
private toastr: ToastrService,
......@@ -30,33 +30,13 @@ export class ProjectListComponent implements OnInit{
ngOnInit(): void {
this.route.queryParams.subscribe(params => {
this.listType = params['listType'];
}
);
this.loadProjects();
}
loadProjects():void{
this.loadingService.show()
switch (this.listType) {
case 'all':
this.handelAll()
break;
case 'managed':
this.handelByManager()
break;
case 'leaded':
this.handelByLeader()
break;
default :
this.router.navigate(['/home'])
this.toastr.error('لقد طلبت صفحة غير موجودة ')
break ;
}
}
......@@ -77,59 +57,8 @@ export class ProjectListComponent implements OnInit{
}
);
}
handelByManager(){
let request :GetProjectsByProjectManagerRequest = {
projectMangerId : this.userService.getEmployeeId(),
pageNumber: null ,
pageSize:null
}
this.projectService.getByProjectManger(request)
.subscribe(
{
next: (res)=>{
this.projects = res;
this.toastr.success("تم تحميل المشاريع بنجاح");
this.loadingService.hide()
},
error: (err)=>{
this.toastr.error("لقد حدث خظاء ما");
this.loadingService.hide()
}
}
);
}
handelByLeader(){
let request :GetProjectsByTeamLeaderRequest ={
teamLeaderrId : this.userService.getEmployeeId(),
pageNumber: null ,
pageSize:null
}
this.projectService.getByTeamLeader(request)
.subscribe(
{
next: (res)=>{
this.projects = res;
this.toastr.success("تم تحميل المشاريع بنجاح");
this.loadingService.hide()
},
error: (err)=>{
this.toastr.error("لقد حدث خظاء ما");
this.loadingService.hide()
}
}
);
}
}
\ No newline at end of file
......@@ -45,6 +45,7 @@ import { ChangeManagerModalComponent } from './components/projectModals/change-m
import { ChangeLeaderModalComponent } from './components/projectModals/change-leader-modal/change-leader-modal.component';
import { EditStepModalComponent } from './components/step-modals/edit-step-modal/edit-step-modal.component';
import { EditWeightModalComponent } from './components/step-modals/edit-weight-modal/edit-weight-modal.component';
import { ProjectBycreterionComponent } from './pages/project-bycreterion/project-bycreterion.component';
@NgModule({
declarations: [
......@@ -80,7 +81,8 @@ import { EditWeightModalComponent } from './components/step-modals/edit-weight-m
ChangeManagerModalComponent,
ChangeLeaderModalComponent,
EditStepModalComponent,
EditWeightModalComponent
EditWeightModalComponent,
ProjectBycreterionComponent
],
providers: [
ProjectService,
......
......@@ -8,20 +8,21 @@ import { ProjectCreateComponent } from '../pages/project-create/project-create.c
import { ProjectDetailsComponent } from '../pages/project-details/project-details.component';
import { ProjectListComponent } from '../pages/project-list/project-list.component';
import { StepListComponent } from '../pages/step-list/step-list.component';
import { RoleGuard } from '../../core/guards/role.guard';
import { ROLES } from '../../core/constants/roles';
import { ProjectBycreterionComponent } from '../pages/project-bycreterion/project-bycreterion.component';
const routes: Routes = [
{path:'',component :ProjectListComponent},
{path:'',component :ProjectListComponent,canActivate:[RoleGuard] , data: { roles: [ROLES.SCIENTIFIC_DEPUTY] }},
{ path: 'detail/:id', component: ProjectDetailsComponent },
{ path: 'create', component: ProjectCreateComponent },
{ path: 'create', component: ProjectCreateComponent ,canActivate:[RoleGuard] , data: { roles: [ROLES.SCIENTIFIC_DEPUTY] }},
{ path: ':id/steps', component: StepListComponent },
{ path: ':id/participants', component: ParticipantsListComponent },
{ path: ':id/spending', component: FinancialSpendingComponent },
{ path: ':id/history/participationChange/:participantId',component:ParticipantChangesComponent},
{ path: ':id/attachments',component:ProjectAttachmentsComponent}
{ path: ':id/attachments',component:ProjectAttachmentsComponent},
{ path: 'byCriterion',component:ProjectBycreterionComponent}
];
......
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { GanttModule } from 'ngx-gantt';
import { ReportsRoutingModule } from './routing/reports-routing.module';
import { ProjectDefinitionComponent } from './pages/project-definition/project-definition.component';
import { ProjectCompletionComponent } from './pages/project-completion/project-completion.component';
......
<!-- ======= Sidebar ======= -->
<aside dir="rtl" id="sidebar" class="sidebar" [class.toggled]="isToggled">
<!-- ======= Sidebar ======= -->
<aside dir="rtl" id="sidebar" class="sidebar" [class.toggled]="isToggled">
<ul class="sidebar-nav" id="sidebar-nav">
<li class="nav-item">
<a class="nav-link" [routerLink]="['/']">
<i class="fe fe-grid"></i>
<span>الصفحة الرئيسية</span>
</a>
</li><!-- End Dashboard Nav -->
<li class="nav-heading">المتابعة</li>
</li>
<!-- End Dashboard Nav -->
<li class="nav-heading" *ngIf="hasRole(alroles.SCIENTIFIC_DEPUTY)">
المتابعة
</li>
<li class="nav-item">
<a class="nav-link collapsed"
[routerLink]="['/tracks/uncompleted']"
>
<li class="nav-item" *ngIf="hasRole(alroles.SCIENTIFIC_DEPUTY)">
<a class="nav-link collapsed" [routerLink]="['/tracks/uncompleted']">
<i class="fe fe-airplay"></i><span>المتابعات غير المكتملة</span>
</a>
</li><!-- End Components Nav -->
<li class="nav-item">
<a class="nav-link collapsed " [routerLink]="['/tracks']">
</li>
<!-- End Components Nav -->
<li class="nav-item" *ngIf="hasRole(alroles.SCIENTIFIC_DEPUTY)">
<a class="nav-link collapsed" [routerLink]="['/tracks']">
<i class="fe fe-flag"></i><span> عمليات المتابعة</span>
</a>
</li>
<li class="nav-heading">أنواع المشاريع</li>
<li class="nav-item">
<a [routerLink]="['/types']" class="nav-link collapsed ">
<a [routerLink]="['/types']" class="nav-link collapsed">
<i class="fe fe-map"></i><span> استعراض أنواع المشاريع</span>
</a>
</li>
<li class="nav-item"
*ngIf="hasRole('Planner')"
>
<a [routerLink]="['/types/create']" class="nav-link collapsed "
>
<li class="nav-item" *ngIf="hasRole('Planner')">
<a [routerLink]="['/types/create']" class="nav-link collapsed">
<i class="fe fe-edit-2"></i><span>إضافة نوع جديد</span>
</a>
</li>
<li class="nav-heading">الجهات الطارحة</li>
<li class="nav-item">
<a [routerLink]="['customers']" class="nav-link collapsed ">
<a [routerLink]="['customers']" class="nav-link collapsed">
<i class="fe fe-map"></i><span> استعراض الجهات الطارحة</span>
</a>
</li>
<li class="nav-item">
<a
*ngIf="hasRole('Planner')"
[routerLink]="['/customers/create']" class="nav-link collapsed " >
[routerLink]="['/customers/create']"
class="nav-link collapsed"
>
<i class="fe fe-edit-2"></i><span>إضافة جهة طارحة</span>
</a>
</li>
<li class="nav-heading">إدارة المشاريع</li>
<li class="nav-item">
<a [routerLink]="['/projects/create']" class="nav-link collapsed" >
<li class="nav-item" *ngIf="hasRole(alroles.SCIENTIFIC_DEPUTY)">
<a [routerLink]="['/projects/create']" class="nav-link collapsed">
<i class="bi fe-plus"></i><span>طرح مشروع</span>
</a>
</li>
<li class="nav-item">
<li class="nav-item" *ngIf="hasRole(alroles.SCIENTIFIC_DEPUTY)">
<a
[routerLink]="['/projects']"
[queryParams]="{ listType: 'all'}"
class="nav-link collapsed">
[queryParams]="{ listType: 'all' }"
class="nav-link collapsed"
>
<i class="bi bi-circle"></i><span>استعراض المشاريع</span>
</a>
</li>
<li class="nav-item">
<a
[routerLink]="['/projects']"
[queryParams]="{ listType: 'managed'}"
[routerLink]="['/byCriterion']"
[queryParams]="{ listType: 'managed' }"
class="nav-link collapsed"
>
<i class="bi bi-circle"></i><span>المشاريع التي أديرها</span>
......@@ -83,8 +80,8 @@
</li>
<li class="nav-item">
<a
[routerLink]="['/projects']"
[queryParams]="{ listType: 'leaded'}"
[routerLink]="['/byCriterion']"
[queryParams]="{ listType: 'leaded' }"
class="nav-link collapsed"
>
<i class="bi bi-circle"></i><span>المشاريع التي أرأسها</span>
......@@ -93,36 +90,34 @@
<li class="nav-heading">العمل</li>
<li [routerLink]="['/employees/participates',id]" class="nav-item">
<a class="nav-link collapsed" >
<i class="bi bi-layout-text-window-reverse"></i><span>استعراض مساهماتي</span><i class="bi bi-chevron-down ms-auto"></i>
<li [routerLink]="['/employees/participates', id]" class="nav-item">
<a class="nav-link collapsed">
<i class="bi bi-layout-text-window-reverse"></i
><span>استعراض مساهماتي</span><i class="bi bi-chevron-down ms-auto"></i>
</a>
</li>
<li class="nav-item">
<a class="nav-link collapsed" [routerLink]="['/employees/profile']">
<i class="bi bi-layout-text-window-reverse"></i><span>ملفي الشخصي</span><i class="bi bi-chevron-down ms-auto"></i>
<i class="bi bi-layout-text-window-reverse"></i><span>ملفي الشخصي</span
><i class="bi bi-chevron-down ms-auto"></i>
</a>
</li>
<li class="nav-heading">متفرقات</li>
<li class="nav-item">
<a [routerLink]="['/Project-FAQ']" class="nav-link collapsed" >
<i class="bi bi-layout-text-window-reverse"></i><span>ملامح المشروع</span><i class="bi bi-chevron-down ms-auto"></i>
<a [routerLink]="['/Project-FAQ']" class="nav-link collapsed">
<i class="bi bi-layout-text-window-reverse"></i
><span>ملامح المشروع</span><i class="bi bi-chevron-down ms-auto"></i>
</a>
</li>
<li class="nav-item">
<a [routerLink]="['/Help']" class="nav-link collapsed" >
<i class="bi bi-layout-text-window-reverse"></i><span>مساعدة</span><i class="bi bi-chevron-down ms-auto"></i>
<a [routerLink]="['/Help']" class="nav-link collapsed">
<i class="bi bi-layout-text-window-reverse"></i><span>مساعدة</span
><i class="bi bi-chevron-down ms-auto"></i>
</a>
</li>
</ul>
</aside><!-- End Sidebar-->
\ No newline at end of file
</aside>
<!-- End Sidebar-->
......@@ -2,6 +2,7 @@ import { Component, Input, input, OnInit } from '@angular/core';
import { NavItem } from '../../componenets/nav-item/nav-item.component';
import { UserService } from '../../../core/services/authentication/user.service';
import { lastValueFrom } from 'rxjs';
import { ROLES } from '../../../core/constants/roles';
@Component({
selector: 'app-sidebar',
......@@ -12,7 +13,7 @@ import { lastValueFrom } from 'rxjs';
export class SidebarComponent implements OnInit {
id : number
alroles =ROLES
roles :string[]
......
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