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

add roles guard for projects

parent a076dc2c
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
"material": "^0.9.15", "material": "^0.9.15",
"moment": "^2.30.1", "moment": "^2.30.1",
"ngx-cookie-service": "^18.0.0", "ngx-cookie-service": "^18.0.0",
"ngx-gantt": "^0.3.5",
"ngx-pagination": "^6.0.3", "ngx-pagination": "^6.0.3",
"ngx-toastr": "^19.0.0", "ngx-toastr": "^19.0.0",
"rxjs": "~7.8.0", "rxjs": "~7.8.0",
...@@ -9177,8 +9178,7 @@ ...@@ -9177,8 +9178,7 @@
"node_modules/lodash": { "node_modules/lodash": {
"version": "4.17.21", "version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
"dev": true
}, },
"node_modules/lodash.debounce": { "node_modules/lodash.debounce": {
"version": "4.0.8", "version": "4.0.8",
...@@ -9956,6 +9956,17 @@ ...@@ -9956,6 +9956,17 @@
"@angular/core": "^18.0.0-rc.0" "@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": { "node_modules/ngx-i18nsupport": {
"version": "0.17.1", "version": "0.17.1",
"resolved": "https://registry.npmjs.org/ngx-i18nsupport/-/ngx-i18nsupport-0.17.1.tgz", "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' ...@@ -14,9 +14,9 @@ import { UserService } from '../../../core/services/authentication/user.service'
}) })
export class ProjectListComponent implements OnInit{ export class ProjectListComponent implements OnInit{
listType : string
projects : Project[] projects : Project[]
constructor( constructor(
private projectService : ProjectService, private projectService : ProjectService,
private toastr: ToastrService, private toastr: ToastrService,
...@@ -30,33 +30,13 @@ export class ProjectListComponent implements OnInit{ ...@@ -30,33 +30,13 @@ export class ProjectListComponent implements OnInit{
ngOnInit(): void { ngOnInit(): void {
this.route.queryParams.subscribe(params => {
this.listType = params['listType'];
}
);
this.loadProjects(); this.loadProjects();
} }
loadProjects():void{ loadProjects():void{
this.loadingService.show() this.loadingService.show()
switch (this.listType) {
case 'all':
this.handelAll() 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{ ...@@ -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 ...@@ -45,6 +45,7 @@ import { ChangeManagerModalComponent } from './components/projectModals/change-m
import { ChangeLeaderModalComponent } from './components/projectModals/change-leader-modal/change-leader-modal.component'; 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 { 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 { EditWeightModalComponent } from './components/step-modals/edit-weight-modal/edit-weight-modal.component';
import { ProjectBycreterionComponent } from './pages/project-bycreterion/project-bycreterion.component';
@NgModule({ @NgModule({
declarations: [ declarations: [
...@@ -80,7 +81,8 @@ import { EditWeightModalComponent } from './components/step-modals/edit-weight-m ...@@ -80,7 +81,8 @@ import { EditWeightModalComponent } from './components/step-modals/edit-weight-m
ChangeManagerModalComponent, ChangeManagerModalComponent,
ChangeLeaderModalComponent, ChangeLeaderModalComponent,
EditStepModalComponent, EditStepModalComponent,
EditWeightModalComponent EditWeightModalComponent,
ProjectBycreterionComponent
], ],
providers: [ providers: [
ProjectService, ProjectService,
......
...@@ -8,20 +8,21 @@ import { ProjectCreateComponent } from '../pages/project-create/project-create.c ...@@ -8,20 +8,21 @@ import { ProjectCreateComponent } from '../pages/project-create/project-create.c
import { ProjectDetailsComponent } from '../pages/project-details/project-details.component'; import { ProjectDetailsComponent } from '../pages/project-details/project-details.component';
import { ProjectListComponent } from '../pages/project-list/project-list.component'; import { ProjectListComponent } from '../pages/project-list/project-list.component';
import { StepListComponent } from '../pages/step-list/step-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 = [ const routes: Routes = [
{path:'',component :ProjectListComponent}, {path:'',component :ProjectListComponent,canActivate:[RoleGuard] , data: { roles: [ROLES.SCIENTIFIC_DEPUTY] }},
{ path: 'detail/:id', component: ProjectDetailsComponent }, { 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/steps', component: StepListComponent },
{ path: ':id/participants', component: ParticipantsListComponent }, { path: ':id/participants', component: ParticipantsListComponent },
{ path: ':id/spending', component: FinancialSpendingComponent }, { path: ':id/spending', component: FinancialSpendingComponent },
{ path: ':id/history/participationChange/:participantId',component:ParticipantChangesComponent}, { 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 { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { GanttModule } from 'ngx-gantt';
import { ReportsRoutingModule } from './routing/reports-routing.module'; import { ReportsRoutingModule } from './routing/reports-routing.module';
import { ProjectDefinitionComponent } from './pages/project-definition/project-definition.component'; import { ProjectDefinitionComponent } from './pages/project-definition/project-definition.component';
import { ProjectCompletionComponent } from './pages/project-completion/project-completion.component'; import { ProjectCompletionComponent } from './pages/project-completion/project-completion.component';
......
<!-- ======= Sidebar ======= --> <!-- ======= Sidebar ======= -->
<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>
<span>الصفحة الرئيسية</span> <span>الصفحة الرئيسية</span>
</a> </a>
</li><!-- End Dashboard Nav --> </li>
<li class="nav-heading">المتابعة</li> <!-- End Dashboard Nav -->
<li class="nav-heading" *ngIf="hasRole(alroles.SCIENTIFIC_DEPUTY)">
المتابعة
</li>
<li class="nav-item"> <li class="nav-item" *ngIf="hasRole(alroles.SCIENTIFIC_DEPUTY)">
<a class="nav-link collapsed" <a class="nav-link collapsed" [routerLink]="['/tracks/uncompleted']">
[routerLink]="['/tracks/uncompleted']"
>
<i class="fe fe-airplay"></i><span>المتابعات غير المكتملة</span> <i class="fe fe-airplay"></i><span>المتابعات غير المكتملة</span>
</a> </a>
</li>
</li><!-- End Components Nav --> <!-- End Components Nav -->
<li class="nav-item"> <li class="nav-item" *ngIf="hasRole(alroles.SCIENTIFIC_DEPUTY)">
<a class="nav-link collapsed " [routerLink]="['/tracks']"> <a class="nav-link collapsed" [routerLink]="['/tracks']">
<i class="fe fe-flag"></i><span> عمليات المتابعة</span> <i class="fe fe-flag"></i><span> عمليات المتابعة</span>
</a> </a>
</li> </li>
<li class="nav-heading">أنواع المشاريع</li> <li class="nav-heading">أنواع المشاريع</li>
<li class="nav-item"> <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> <i class="fe fe-map"></i><span> استعراض أنواع المشاريع</span>
</a> </a>
</li> </li>
<li class="nav-item" <li class="nav-item" *ngIf="hasRole('Planner')">
<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>
<li class="nav-heading">الجهات الطارحة</li> <li class="nav-heading">الجهات الطارحة</li>
<li class="nav-item"> <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> <i class="fe fe-map"></i><span> استعراض الجهات الطارحة</span>
</a> </a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a <a
*ngIf="hasRole('Planner')" *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> <i class="fe fe-edit-2"></i><span>إضافة جهة طارحة</span>
</a> </a>
</li> </li>
<li class="nav-heading">إدارة المشاريع</li> <li class="nav-heading">إدارة المشاريع</li>
<li class="nav-item"> <li class="nav-item" *ngIf="hasRole(alroles.SCIENTIFIC_DEPUTY)">
<a [routerLink]="['/projects/create']" class="nav-link collapsed" >
<a [routerLink]="['/projects/create']" class="nav-link collapsed">
<i class="bi fe-plus"></i><span>طرح مشروع</span> <i class="bi fe-plus"></i><span>طرح مشروع</span>
</a> </a>
</li> </li>
<li class="nav-item"> <li class="nav-item" *ngIf="hasRole(alroles.SCIENTIFIC_DEPUTY)">
<a <a
[routerLink]="['/projects']" [routerLink]="['/projects']"
[queryParams]="{ listType: 'all'}" [queryParams]="{ listType: 'all' }"
class="nav-link collapsed"> class="nav-link collapsed"
>
<i class="bi bi-circle"></i><span>استعراض المشاريع</span> <i class="bi bi-circle"></i><span>استعراض المشاريع</span>
</a> </a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a <a
[routerLink]="['/projects']" [routerLink]="['/byCriterion']"
[queryParams]="{ listType: 'managed'}" [queryParams]="{ listType: 'managed' }"
class="nav-link collapsed" class="nav-link collapsed"
> >
<i class="bi bi-circle"></i><span>المشاريع التي أديرها</span> <i class="bi bi-circle"></i><span>المشاريع التي أديرها</span>
...@@ -83,8 +80,8 @@ ...@@ -83,8 +80,8 @@
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a <a
[routerLink]="['/projects']" [routerLink]="['/byCriterion']"
[queryParams]="{ listType: 'leaded'}" [queryParams]="{ listType: 'leaded' }"
class="nav-link collapsed" class="nav-link collapsed"
> >
<i class="bi bi-circle"></i><span>المشاريع التي أرأسها</span> <i class="bi bi-circle"></i><span>المشاريع التي أرأسها</span>
...@@ -93,36 +90,34 @@ ...@@ -93,36 +90,34 @@
<li class="nav-heading">العمل</li> <li class="nav-heading">العمل</li>
<li [routerLink]="['/employees/participates',id]" class="nav-item"> <li [routerLink]="['/employees/participates', id]" class="nav-item">
<a class="nav-link collapsed">
<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>
<i class="bi bi-layout-text-window-reverse"></i><span>استعراض مساهماتي</span><i class="bi bi-chevron-down ms-auto"></i>
</a> </a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link collapsed" [routerLink]="['/employees/profile']"> <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> </a>
</li> </li>
<li class="nav-heading">متفرقات</li> <li class="nav-heading">متفرقات</li>
<li class="nav-item"> <li class="nav-item">
<a [routerLink]="['/Project-FAQ']" class="nav-link collapsed" > <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> <i class="bi bi-layout-text-window-reverse"></i
><span>ملامح المشروع</span><i class="bi bi-chevron-down ms-auto"></i>
</a> </a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a [routerLink]="['/Help']" class="nav-link collapsed" > <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> <i class="bi bi-layout-text-window-reverse"></i><span>مساعدة</span
><i class="bi bi-chevron-down ms-auto"></i>
</a> </a>
</li> </li>
</ul> </ul>
</aside>
</aside><!-- End Sidebar--> <!-- End Sidebar-->
\ No newline at end of file
...@@ -2,6 +2,7 @@ import { Component, Input, input, OnInit } from '@angular/core'; ...@@ -2,6 +2,7 @@ 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'; import { lastValueFrom } from 'rxjs';
import { ROLES } from '../../../core/constants/roles';
@Component({ @Component({
selector: 'app-sidebar', selector: 'app-sidebar',
...@@ -12,7 +13,7 @@ import { lastValueFrom } from 'rxjs'; ...@@ -12,7 +13,7 @@ import { lastValueFrom } from 'rxjs';
export class SidebarComponent implements OnInit { export class SidebarComponent implements OnInit {
id : number id : number
alroles =ROLES
roles :string[] 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