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,34 +30,14 @@ export class ProjectListComponent implements OnInit{ ...@@ -30,34 +30,14 @@ 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) { this.handelAll()
case 'all':
this.handelAll()
break;
case 'managed':
this.handelByManager()
break;
case 'leaded':
this.handelByLeader()
break;
default :
this.router.navigate(['/home'])
this.toastr.error('لقد طلبت صفحة غير موجودة ')
break ;
}
} }
handelAll() { handelAll() {
...@@ -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">
<a class="nav-link" [routerLink]="['/']">
<li class="nav-item"> <i class="fe fe-grid"></i>
<a class="nav-link" [routerLink]="['/']"> <span>الصفحة الرئيسية</span>
<i class="fe fe-grid"></i> </a>
<span>الصفحة الرئيسية</span> </li>
</a> <!-- End Dashboard Nav -->
</li><!-- End Dashboard Nav --> <li class="nav-heading" *ngIf="hasRole(alroles.SCIENTIFIC_DEPUTY)">
<li class="nav-heading">المتابعة</li> المتابعة
</li>
<li class="nav-item">
<a class="nav-link collapsed" <li class="nav-item" *ngIf="hasRole(alroles.SCIENTIFIC_DEPUTY)">
[routerLink]="['/tracks/uncompleted']" <a class="nav-link collapsed" [routerLink]="['/tracks/uncompleted']">
> <i class="fe fe-airplay"></i><span>المتابعات غير المكتملة</span>
<i class="fe fe-airplay"></i><span>المتابعات غير المكتملة</span> </a>
</a> </li>
<!-- End Components Nav -->
</li><!-- End Components Nav --> <li class="nav-item" *ngIf="hasRole(alroles.SCIENTIFIC_DEPUTY)">
<li class="nav-item"> <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" *ngIf="hasRole('Planner')">
<li class="nav-item" <a [routerLink]="['/types/create']" class="nav-link collapsed">
<i class="fe fe-edit-2"></i><span>إضافة نوع جديد</span>
*ngIf="hasRole('Planner')" </a>
</li>
>
<a [routerLink]="['/types/create']" class="nav-link collapsed " <li class="nav-heading">الجهات الطارحة</li>
<li class="nav-item">
> <a [routerLink]="['customers']" class="nav-link collapsed">
<i class="fe fe-edit-2"></i><span>إضافة نوع جديد</span> <i class="fe fe-map"></i><span> استعراض الجهات الطارحة</span>
</a> </a>
</li> </li>
<li class="nav-item">
<li class="nav-heading">الجهات الطارحة</li> <a
<li class="nav-item"> *ngIf="hasRole('Planner')"
<a [routerLink]="['customers']" class="nav-link collapsed "> [routerLink]="['/customers/create']"
<i class="fe fe-map"></i><span> استعراض الجهات الطارحة</span> class="nav-link collapsed"
</a> >
</li> <i class="fe fe-edit-2"></i><span>إضافة جهة طارحة</span>
<li class="nav-item"> </a>
<a </li>
*ngIf="hasRole('Planner')"
[routerLink]="['/customers/create']" class="nav-link collapsed " > <li class="nav-heading">إدارة المشاريع</li>
<i class="fe fe-edit-2"></i><span>إضافة جهة طارحة</span>
</a> <li class="nav-item" *ngIf="hasRole(alroles.SCIENTIFIC_DEPUTY)">
</li>
<a [routerLink]="['/projects/create']" class="nav-link collapsed">
<li class="nav-heading">إدارة المشاريع</li> <i class="bi fe-plus"></i><span>طرح مشروع</span>
</a>
<li class="nav-item"> </li>
<a [routerLink]="['/projects/create']" class="nav-link collapsed" > <li class="nav-item" *ngIf="hasRole(alroles.SCIENTIFIC_DEPUTY)">
<i class="bi fe-plus"></i><span>طرح مشروع</span> <a
</a> [routerLink]="['/projects']"
</li> [queryParams]="{ listType: 'all' }"
<li class="nav-item"> class="nav-link collapsed"
<a >
[routerLink]="['/projects']" <i class="bi bi-circle"></i><span>استعراض المشاريع</span>
[queryParams]="{ listType: 'all'}" </a>
class="nav-link collapsed"> </li>
<i class="bi bi-circle"></i><span>استعراض المشاريع</span> <li class="nav-item">
</a> <a
</li> [routerLink]="['/byCriterion']"
<li class="nav-item"> [queryParams]="{ listType: 'managed' }"
<a class="nav-link collapsed"
[routerLink]="['/projects']" >
[queryParams]="{ listType: 'managed'}" <i class="bi bi-circle"></i><span>المشاريع التي أديرها</span>
class="nav-link collapsed" </a>
> </li>
<i class="bi bi-circle"></i><span>المشاريع التي أديرها</span> <li class="nav-item">
</a> <a
</li> [routerLink]="['/byCriterion']"
<li class="nav-item"> [queryParams]="{ listType: 'leaded' }"
<a class="nav-link collapsed"
[routerLink]="['/projects']" >
[queryParams]="{ listType: 'leaded'}" <i class="bi bi-circle"></i><span>المشاريع التي أرأسها</span>
class="nav-link collapsed" </a>
> </li>
<i class="bi bi-circle"></i><span>المشاريع التي أرأسها</span>
</a> <li class="nav-heading">العمل</li>
</li>
<li [routerLink]="['/employees/participates', id]" class="nav-item">
<li class="nav-heading">العمل</li> <a class="nav-link collapsed">
<i class="bi bi-layout-text-window-reverse"></i
<li [routerLink]="['/employees/participates',id]" class="nav-item"> ><span>استعراض مساهماتي</span><i class="bi bi-chevron-down ms-auto"></i>
</a>
<a class="nav-link collapsed" > </li>
<i class="bi bi-layout-text-window-reverse"></i><span>استعراض مساهماتي</span><i class="bi bi-chevron-down ms-auto"></i> <li class="nav-item">
<a class="nav-link collapsed" [routerLink]="['/employees/profile']">
</a> <i class="bi bi-layout-text-window-reverse"></i><span>ملفي الشخصي</span
</li> ><i class="bi bi-chevron-down ms-auto"></i>
</a>
</li>
<li class="nav-item">
<a class="nav-link collapsed" [routerLink]="['/employees/profile']"> <li class="nav-heading">متفرقات</li>
<i class="bi bi-layout-text-window-reverse"></i><span>ملفي الشخصي</span><i class="bi bi-chevron-down ms-auto"></i> <li class="nav-item">
</a> <a [routerLink]="['/Project-FAQ']" class="nav-link collapsed">
<i class="bi bi-layout-text-window-reverse"></i
</li> ><span>ملامح المشروع</span><i class="bi bi-chevron-down ms-auto"></i>
</a>
<li class="nav-heading">متفرقات</li> </li>
<li class="nav-item">
<a [routerLink]="['/Project-FAQ']" class="nav-link collapsed" > <li class="nav-item">
<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">
</a> <i class="bi bi-layout-text-window-reverse"></i><span>مساعدة</span
</li> ><i class="bi bi-chevron-down ms-auto"></i>
</a>
<li class="nav-item"> </li>
<a [routerLink]="['/Help']" class="nav-link collapsed" > </ul>
<i class="bi bi-layout-text-window-reverse"></i><span>مساعدة</span><i class="bi bi-chevron-down ms-auto"></i> </aside>
</a> <!-- End Sidebar-->
</li>
</ul>
</aside><!-- 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