179 lines
6.8 KiB
TypeScript
179 lines
6.8 KiB
TypeScript
import { Component, OnInit, QueryList, ViewChildren, ChangeDetectionStrategy } from '@angular/core';
|
|
import { ApiService } from 'src/app/app.api.service';
|
|
import { DataTransferService } from 'src/app/data.transfer.service';
|
|
import { Router, ActivatedRoute } from '@angular/router';
|
|
import { SearchEmployee } from 'src/app/_models/Employee/searchEmployee';
|
|
import { HRMNotificationService } from 'src/app/app.notification.service';
|
|
import { loadingPanelService } from 'src/app/hrm-loding panel/loding.panel.service';
|
|
import { DomSanitizer } from '@angular/platform-browser';
|
|
import { ExpansionPanelComponent } from "@progress/kendo-angular-layout";
|
|
import { Courses } from 'src/app/_models/LearningManagement/courses';
|
|
import { process, State } from '@progress/kendo-data-query';
|
|
import { ExcelExportData, ExcelExportComponent, } from '@progress/kendo-angular-excel-export';
|
|
import { LMSService } from 'src/app/_services/LearningManagement/lms.service';
|
|
import { EnumDifficultyLevel, EnumStatus } from 'src/app/_models/enums';
|
|
import { LMSTemplate } from 'src/app/_models/LearningManagement/lmstemplate';
|
|
import { Lessons } from 'src/app/_models/LearningManagement/lessons';
|
|
@Component({
|
|
selector: 'app-course-details',
|
|
templateUrl: './course-details.component.html',
|
|
styleUrls: ['./course-details.component.scss'],
|
|
changeDetection: ChangeDetectionStrategy.Eager,
|
|
standalone: false,
|
|
})
|
|
export class CourseDetailsComponent implements OnInit {
|
|
|
|
constructor(public apiService : ApiService,
|
|
private datatransferservice: DataTransferService,
|
|
private router: Router,public notificationService: HRMNotificationService,
|
|
public loadingpanelService: loadingPanelService, public lmsService : LMSService) {
|
|
this.apiService.selectedMenuName = "Course Details";
|
|
}
|
|
|
|
ratingValue : number = 4;
|
|
allLessons : any[] = [];
|
|
|
|
oCourse : Courses;
|
|
whomForThisCourses : any [] = [];
|
|
whatWillLearns : any [] = [];
|
|
howDoStarts : any [] = [];
|
|
courseIncludes : any [] = [];
|
|
lessons : Lessons [] = [];
|
|
lessonsAll : Lessons [] = [];
|
|
lessonsFilter : Lessons [] = [];
|
|
|
|
@ViewChildren(ExpansionPanelComponent)
|
|
panels: QueryList<ExpansionPanelComponent>;
|
|
|
|
ngOnInit(): void {
|
|
this.oCourse = this.datatransferservice.getData();
|
|
if(this.oCourse !== undefined && this.oCourse.id > 0){
|
|
this.loadCoursesData();
|
|
}
|
|
else if(this.oCourse === undefined){
|
|
this.router.navigateByUrl('/lms/user-courses-list');
|
|
}
|
|
}
|
|
loadCoursesData(){
|
|
this.loadingpanelService.ShowLoadingPanel = true;
|
|
this.lmsService.GetCourseForUser(this.oCourse.id).subscribe(
|
|
(resp: any) => {
|
|
;
|
|
this.oCourse = undefined;
|
|
this.oCourse = resp;
|
|
},
|
|
(err: any) => {
|
|
this.loadingpanelService.ShowLoadingPanel = false;
|
|
},
|
|
() => {
|
|
this.loadingpanelService.ShowLoadingPanel = false;
|
|
if(this.oCourse !== undefined && this.oCourse.id > 0){
|
|
//#region SET DATA
|
|
if(this.oCourse.targetedAudience !== undefined && this.oCourse.targetedAudience !== ""){
|
|
this.oCourse.targetedAudience.split(/, (?=\d+\.)/g).forEach(item => {
|
|
const [serial, ...descriptionParts] = item.split('.');
|
|
this.whomForThisCourses.push({
|
|
serial: parseInt(serial.trim(), 10),
|
|
targetAudience: descriptionParts.join('.').trim()
|
|
});
|
|
});
|
|
}
|
|
if(this.oCourse.learningOutcomes !== undefined && this.oCourse.learningOutcomes !== ""){
|
|
this.oCourse.learningOutcomes.split(/, (?=\d+\.)/g).forEach(item => {
|
|
const [serial, ...descriptionParts] = item.split('.');
|
|
this.whatWillLearns.push({
|
|
serial: parseInt(serial.trim(), 10),
|
|
learningOutcome: descriptionParts.join('.').trim()
|
|
});
|
|
});
|
|
}
|
|
if(this.oCourse.startGuideLine !== undefined && this.oCourse.startGuideLine !== ""){
|
|
this.oCourse.startGuideLine.split(/, (?=\d+\.)/g).forEach(item => {
|
|
const [serial, ...descriptionParts] = item.split('.');
|
|
this.howDoStarts.push({
|
|
serial: parseInt(serial.trim(), 10),
|
|
startGuideLine: descriptionParts.join('.').trim()
|
|
});
|
|
});
|
|
}
|
|
if(this.oCourse.courseIncludes !== undefined && this.oCourse.courseIncludes !== ""){
|
|
this.oCourse.courseIncludes.split(/, (?=\d+\.)/g).forEach(item => {
|
|
const [serial, ...descriptionParts] = item.split('.');
|
|
this.courseIncludes.push({
|
|
serial: parseInt(serial.trim(), 10),
|
|
courseInclude: descriptionParts.join('.').trim()
|
|
});
|
|
});
|
|
}
|
|
//#endregion
|
|
|
|
//#region FOR LESSONS
|
|
if(this.oCourse.lessons.length !== undefined && this.oCourse.lessons.length > 0){
|
|
this.lessons = this.oCourse.lessons;
|
|
this.lessonsAll = this.oCourse.lessons;
|
|
}
|
|
//#endregion
|
|
|
|
//#region FOR Template
|
|
if(this.oCourse.courseTemplate !== undefined){
|
|
this.oCourse.courseTemplate.fileData = this.oCourse.courseTemplate.fileTobase64;
|
|
}
|
|
//#endregion
|
|
}
|
|
}
|
|
);
|
|
}
|
|
onStartCourse(){
|
|
this.datatransferservice.setData(this.oCourse);
|
|
this.router.navigateByUrl('/lms/course-enroll');
|
|
}
|
|
public onAction(index: number): void {
|
|
this.panels.forEach((panel, idx) => {
|
|
if (idx !== index && panel.expanded) {
|
|
panel.toggle();
|
|
}
|
|
});
|
|
}
|
|
onBack(){
|
|
this.router.navigateByUrl('/lms/user-courses-list');
|
|
}
|
|
getImageSrc(templateData : LMSTemplate): string {
|
|
const base64String = templateData.fileAsByteArray;
|
|
return `data:image/png;base64,${base64String}`;
|
|
}
|
|
onFilter(inputValue: string): void{
|
|
this.lessonsFilter = [];
|
|
this.lessonsFilter = this.lessonsAll;
|
|
const selectedProperties = ['lessonTitle', 'lessonNo','duration'];
|
|
const filters = selectedProperties.map(field => ({
|
|
field: field,
|
|
operator: typeof this.lessonsFilter[0][field] === 'string' ? 'contains' : 'eq',
|
|
value: inputValue
|
|
}));
|
|
this.lessonsFilter = process(this.lessonsFilter, {
|
|
filter: {
|
|
logic: 'or',
|
|
filters: filters
|
|
}
|
|
}).data;
|
|
this.lessons = this.lessonsFilter;
|
|
}
|
|
getDifficultyLevelStringString(type : EnumDifficultyLevel): string{
|
|
let difficultyLevel : string = "";
|
|
switch (type) {
|
|
case EnumDifficultyLevel.Advanced:
|
|
difficultyLevel = "Advanced";
|
|
break;
|
|
case EnumDifficultyLevel.Beginner:
|
|
difficultyLevel = "Beginner";
|
|
break;
|
|
case EnumDifficultyLevel.Intermediate:
|
|
difficultyLevel = "Intermediate";
|
|
break;
|
|
default:
|
|
difficultyLevel = "";
|
|
}
|
|
return difficultyLevel;
|
|
}
|
|
}
|