Commit b1d542cf by Muhammad Usman

refactoring completed

parent 76ee0e06
......@@ -4,7 +4,6 @@ import { ActivatedRoute, Router } from '@angular/router';
import { takeUntil } from 'rxjs/operators';
import { BaseComponent } from '../../base/base.component';
import { AuthService } from '../../services/auth.service';
import { HelperService } from '../../services/helper.service';
import { ToasterService } from '../../services/toaster.service';
import { EXTERNAL_LINKS } from '../../config/constants';
import { UtilsService } from '../../../oneit/services/utils.service';
......@@ -27,7 +26,6 @@ export class ResetPasswordComponent extends BaseComponent implements OnInit {
@ViewChild('form') form: NgForm;
constructor(
private helperService: HelperService,
private activatedRoute: ActivatedRoute,
private toasterService: ToasterService,
private authService: AuthService,
......@@ -57,7 +55,6 @@ export class ResetPasswordComponent extends BaseComponent implements OnInit {
.pipe(takeUntil(this.componentInView))
.subscribe(response => {
this.isLoading = false;
this.helperService.oneItHttpResponse(response);
if (response.passwordChanged) {
this.toasterService.success('Password changed.');
this.router.navigate(['/my-career-web/auth/login']);
......
......@@ -14,14 +14,14 @@ export class CareerHistoryComponent extends BaseComponent implements OnInit {
activeTab = '';
constructor(
private r: Router,
private ar: ActivatedRoute
private router: Router,
private activatedRoute: ActivatedRoute
) {
super();
}
ngOnInit() {
this.ar.params
this.activatedRoute.params
.pipe(takeUntil(this.componentInView))
.subscribe(params => {
if (params.screen) {
......@@ -31,11 +31,11 @@ export class CareerHistoryComponent extends BaseComponent implements OnInit {
}
exit(): void {
this.r.navigate(['/my-career-web/dashboard/home']);
this.router.navigate(['/my-career-web/dashboard/home']);
}
tabChanged($event): void {
this.r.navigate([`/my-career-web/career-history/${this.tabs[$event.index]}`]);
this.router.navigate([`/my-career-web/career-history/${this.tabs[$event.index]}`]);
}
}
import { Component, EventEmitter, OnInit, Output, ViewChild } from '@angular/core';
import { PersonalDetailsService } from '../../../services/personal-details.service';
import { CareerProfileModel } from '../../../models/career-profile.model';
import { HelperService } from '../../../services/helper.service';
import { UtilsService } from '../../../../oneit/services/utils.service';
import { ConfirmationService } from 'primeng/api';
import { NgForm } from '@angular/forms';
......@@ -27,10 +26,9 @@ export class EducationComponent extends BaseComponent implements OnInit {
@Output() educationSaved = new EventEmitter();
constructor(
private ps: PersonalDetailsService,
private us: UtilsService,
private cs: ConfirmationService,
private hs: HelperService
private personalDetailsService: PersonalDetailsService,
private utilsService: UtilsService,
private confirmationService: ConfirmationService
) {
super();
}
......@@ -41,7 +39,7 @@ export class EducationComponent extends BaseComponent implements OnInit {
getCareerProfile(): void {
this.isLoading = true;
this.ps.getCareerProfile(this.assocs)
this.personalDetailsService.getCareerProfile(this.assocs)
.pipe(takeUntil(this.componentInView))
.subscribe(response => {
this.isLoading = false;
......@@ -51,11 +49,11 @@ export class EducationComponent extends BaseComponent implements OnInit {
edu.WhenCompletedField = UtilsService.convertStringToDate(edu.WhenCompleted);
})
}
this.us.addObjsToJSONByObjectID(this.updatedObjs, this.careerProfile.EducationCertificates);
this.utilsService.addObjsToJSONByObjectID(this.updatedObjs, this.careerProfile.EducationCertificates);
this.addEducation(true);
this.isLoading = false;
}, err => {
this.hs.handleHttpError(err);
this.utilsService.handleError(err);
this.isLoading = false;
})
}
......@@ -64,49 +62,48 @@ export class EducationComponent extends BaseComponent implements OnInit {
const newModel = new EducationModel();
newModel.CareerProfile = this.careerProfile.ObjectID;
if (initLoad && (!this.careerProfile.EducationCertificates || this.careerProfile.EducationCertificates.length === 0)) {
this.us.addMultiRefObject(newModel, this.careerProfile, 'EducationCertificates', this.createdObjs);
this.utilsService.addMultiRefObject(newModel, this.careerProfile, 'EducationCertificates', this.createdObjs);
} else if (!initLoad) {
this.us.addMultiRefObject(newModel, this.careerProfile, 'EducationCertificates', this.createdObjs);
this.utilsService.addMultiRefObject(newModel, this.careerProfile, 'EducationCertificates', this.createdObjs);
}
}
removeEducation(exp): void {
this.cs.confirm({
this.confirmationService.confirm({
message:'Are you sure you want to remove this education?',
accept: () => {
this.us.removeMultiRefObject(exp, this.careerProfile, 'EducationCertificates', this.createdObjs, this.updatedObjs, this.deletedObjs);
this.utilsService.removeMultiRefObject(exp, this.careerProfile, 'EducationCertificates', this.createdObjs, this.updatedObjs, this.deletedObjs);
}
})
}
saveEducation(): void {
this.hs.validateAllFormFields(this.form);
if (this.form.invalid) {
return ;
this.utilsService.showAllErrorMessages();
}
this.careerProfile.EducationCertificates.forEach(exp => {
exp.WhenCompleted = UtilsService.convertDateToString(exp.WhenCompletedField);
});
this.isSaving = true;
this.ps.saveProfile(this.createdObjs, this.updatedObjs, this.deletedObjs)
this.personalDetailsService.saveProfile(this.createdObjs, this.updatedObjs, this.deletedObjs)
.pipe(takeUntil(this.componentInView))
.subscribe(res => {
this.isSaving = false;
this.hs.oneItHttpResponse(res);
this.utilsService.handleError(res);
this.educationSaved.emit();
}, err => {
this.hs.handleHttpError(err);
this.utilsService.handleError(err);
this.isSaving = false;
})
}
getCertificates($event): void {
this.ps.getCertifications({CertificateName: $event.query})
this.personalDetailsService.getCertifications({CertificateName: $event.query})
.pipe(takeUntil(this.componentInView))
.subscribe(response => {
this.certifications = response;
}, err => {
this.hs.handleHttpError(err);
this.utilsService.handleError(err);
})
}
......
import { Component, OnInit } from '@angular/core';
import { PersonalDetailsService } from '../../../services/personal-details.service';
import { CareerProfileModel } from '../../../models/career-profile.model';
import { HelperService } from '../../../services/helper.service';
import { UtilsService } from '../../../../oneit/services/utils.service';
import { BaseComponent } from '../../../base/base.component';
import { takeUntil } from 'rxjs/operators';
......@@ -17,9 +16,8 @@ export class PublishComponent extends BaseComponent implements OnInit {
careerProfile = new CareerProfileModel();
constructor(
private ps: PersonalDetailsService,
private us: UtilsService,
private hs: HelperService
private personalDetailsService: PersonalDetailsService,
private utilsService: UtilsService
) {
super();
}
......@@ -30,29 +28,27 @@ export class PublishComponent extends BaseComponent implements OnInit {
getCareerProfile(): void {
this.isLoading = true;
this.ps.getCareerProfile(this.assocs)
this.personalDetailsService.getCareerProfile(this.assocs)
.pipe(takeUntil(this.componentInView))
.subscribe(response => {
this.isLoading = false;
this.hs.oneItHttpResponse(response);
this.careerProfile = response;
this.updatedObjs[this.careerProfile.ObjectID] = this.careerProfile;
}, err => {
this.hs.handleHttpError(err);
this.isLoading = false;
this.utilsService.handleError(err);
})
}
saveProfile(): void {
this.isSaving = true;
this.ps.saveProfile(this.createdObjs, this.updatedObjs, this.deletedObjs)
this.personalDetailsService.saveProfile(this.createdObjs, this.updatedObjs, this.deletedObjs)
.pipe(takeUntil(this.componentInView))
.subscribe(res => {
this.isSaving = false;
this.hs.oneItHttpResponse(res);
}, err => {
this.hs.handleHttpError(err);
this.isSaving = false;
this.isLoading = false;
this.utilsService.handleError(err);
})
}
......
import { Component, EventEmitter, OnInit, Output, ViewChild } from '@angular/core';
import { PersonalDetailsService } from '../../../services/personal-details.service';
import { HelperService } from '../../../services/helper.service';
import { CareerProfileModel } from '../../../models/career-profile.model';
import { UtilsService } from '../../../../oneit/services/utils.service';
import { ConfirmationService } from 'primeng/api';
......@@ -26,10 +25,9 @@ export class ReferencesComponent extends BaseComponent implements OnInit {
@Output() refereeSaved = new EventEmitter();
constructor(
private ps: PersonalDetailsService,
private us: UtilsService,
private cs: ConfirmationService,
private hs: HelperService
private personalDetailsService: PersonalDetailsService,
private utilsService: UtilsService,
private confirmationService: ConfirmationService
) {
super();
}
......@@ -40,17 +38,17 @@ export class ReferencesComponent extends BaseComponent implements OnInit {
getCareerProfile(): void {
this.isLoading = true;
this.ps.getCareerProfile(this.assocs)
this.personalDetailsService.getCareerProfile(this.assocs)
.pipe(takeUntil(this.componentInView))
.subscribe(response => {
this.isLoading = false;
this.careerProfile = response;
this.us.addObjsToJSONByObjectID(this.updatedObjs, this.careerProfile.Referees);
this.utilsService.addObjsToJSONByObjectID(this.updatedObjs, this.careerProfile.Referees);
this.addReferee(true);
this.isLoading = false;
}, err => {
this.hs.handleHttpError(err);
this.isLoading = false;
this.utilsService.handleError(err);
})
}
......@@ -64,36 +62,34 @@ export class ReferencesComponent extends BaseComponent implements OnInit {
const newModel = new RefereeModel();
newModel.CareerProfile = this.careerProfile.ObjectID;
if (initLoad && (!this.careerProfile.Referees || this.careerProfile.Referees.length === 0)) {
this.us.addMultiRefObject(newModel, this.careerProfile, 'Referees', this.createdObjs);
this.utilsService.addMultiRefObject(newModel, this.careerProfile, 'Referees', this.createdObjs);
} else if (!initLoad) {
this.us.addMultiRefObject(newModel, this.careerProfile, 'Referees', this.createdObjs);
this.utilsService.addMultiRefObject(newModel, this.careerProfile, 'Referees', this.createdObjs);
}
}
removeReferee(ref): void {
this.cs.confirm({
this.confirmationService.confirm({
message:'Are you sure you want to remove this skill?',
accept: () => {
this.us.removeMultiRefObject(ref, this.careerProfile, 'Referees', this.createdObjs, this.updatedObjs, this.deletedObjs);
this.utilsService.removeMultiRefObject(ref, this.careerProfile, 'Referees', this.createdObjs, this.updatedObjs, this.deletedObjs);
}
})
}
saveReferees(): void {
this.hs.validateAllFormFields(this.form);
if (this.form.invalid) {
return ;
return this.utilsService.clearErrorMessages();
}
this.isSaving = true;
this.ps.saveProfile(this.createdObjs, this.updatedObjs, this.deletedObjs)
this.personalDetailsService.saveProfile(this.createdObjs, this.updatedObjs, this.deletedObjs)
.pipe(takeUntil(this.componentInView))
.subscribe(res => {
this.isSaving = false;
this.hs.oneItHttpResponse(res);
this.refereeSaved.emit();
}, err => {
this.hs.handleHttpError(err);
this.isSaving = false;
this.isLoading = false;
this.utilsService.handleError(err);
})
}
......
......@@ -5,7 +5,6 @@ import { NgForm } from '@angular/forms';
import { PersonalDetailsService } from '../../../services/personal-details.service';
import { UtilsService } from '../../../../oneit/services/utils.service';
import { ConfirmationService } from 'primeng/api';
import { HelperService } from '../../../services/helper.service';
import { takeUntil } from 'rxjs/operators';
import { CareerSkillModel, SkillModel } from '../../../models/career-skill.model';
......@@ -25,10 +24,9 @@ export class SkillsComponent extends BaseComponent implements OnInit {
@Output() skillsSaved = new EventEmitter();
constructor(
private ps: PersonalDetailsService,
private us: UtilsService,
private cs: ConfirmationService,
private hs: HelperService
private personalDetailsService: PersonalDetailsService,
private utilsService: UtilsService,
private confirmationService: ConfirmationService
) {
super();
}
......@@ -40,37 +38,37 @@ export class SkillsComponent extends BaseComponent implements OnInit {
getCareerProfile(): void {
this.isLoading = true;
this.ps.getCareerProfile(this.assocs)
this.personalDetailsService.getCareerProfile(this.assocs)
.pipe(takeUntil(this.componentInView))
.subscribe(response => {
this.isLoading = false;
this.careerProfile = response;
this.us.addObjsToJSONByObjectID(this.updatedObjs, this.careerProfile.Skills);
this.utilsService.addObjsToJSONByObjectID(this.updatedObjs, this.careerProfile.Skills);
this.addSkill(true);
this.isLoading = false;
}, err => {
this.hs.handleHttpError(err);
this.isLoading = false;
this.utilsService.handleError(err);
})
}
getSkills($event): void {
this.ps.getSkills({Description: $event.query})
this.personalDetailsService.getSkills({Description: $event.query})
.pipe(takeUntil(this.componentInView))
.subscribe(response => {
this.skills = response;
}, err => {
this.hs.handleHttpError(err);
this.utilsService.handleError(err);
})
}
getSkillRatings(): void {
this.ps.getSkillRatings()
this.personalDetailsService.getSkillRatings()
.pipe(takeUntil(this.componentInView))
.subscribe(response => {
this.ratings = response;
}, err => {
this.hs.handleHttpError(err);
this.utilsService.handleError(err);
})
}
......@@ -78,36 +76,34 @@ export class SkillsComponent extends BaseComponent implements OnInit {
const newModel = new CareerSkillModel();
newModel.CareerProfile = this.careerProfile.ObjectID;
if (initLoad && (!this.careerProfile.Skills || this.careerProfile.Skills.length === 0)) {
this.us.addMultiRefObject(newModel, this.careerProfile, 'Skills', this.createdObjs);
this.utilsService.addMultiRefObject(newModel, this.careerProfile, 'Skills', this.createdObjs);
} else if (!initLoad) {
this.us.addMultiRefObject(newModel, this.careerProfile, 'Skills', this.createdObjs);
this.utilsService.addMultiRefObject(newModel, this.careerProfile, 'Skills', this.createdObjs);
}
}
removeSkill(exp): void {
this.cs.confirm({
this.confirmationService.confirm({
message:'Are you sure you want to remove this skill?',
accept: () => {
this.us.removeMultiRefObject(exp, this.careerProfile, 'Skills', this.createdObjs, this.updatedObjs, this.deletedObjs);
this.utilsService.removeMultiRefObject(exp, this.careerProfile, 'Skills', this.createdObjs, this.updatedObjs, this.deletedObjs);
}
})
}
saveSkill(): void {
this.hs.validateAllFormFields(this.form);
if (this.form.invalid) {
return ;
return this.utilsService.showAllErrorMessages();
}
this.isSaving = true;
this.ps.saveProfile(this.createdObjs, this.updatedObjs, this.deletedObjs)
this.personalDetailsService.saveProfile(this.createdObjs, this.updatedObjs, this.deletedObjs)
.pipe(takeUntil(this.componentInView))
.subscribe(res => {
this.isSaving = false;
this.hs.oneItHttpResponse(res);
this.skillsSaved.emit();
}, err => {
this.hs.handleHttpError(err);
this.isSaving = false;
this.utilsService.handleError(err);
})
}
......
......@@ -3,7 +3,6 @@ import { BaseComponent } from '../../../base/base.component';
import { CareerProfileModel } from '../../../models/career-profile.model';
import { PersonalDetailsService } from '../../../services/personal-details.service';
import { UtilsService } from '../../../../oneit/services/utils.service';
import { HelperService } from '../../../services/helper.service';
import { takeUntil } from 'rxjs/operators';
@Component({
......@@ -17,9 +16,8 @@ export class TemplatesComponent extends BaseComponent implements OnInit {
careerProfile = new CareerProfileModel();
constructor(
private ps: PersonalDetailsService,
private us: UtilsService,
private hs: HelperService
private personalDetailsService: PersonalDetailsService,
private utilsService: UtilsService
) {
super();
}
......@@ -30,15 +28,14 @@ export class TemplatesComponent extends BaseComponent implements OnInit {
getCareerProfile(): void {
this.isLoading = true;
this.ps.getCareerProfile(this.assocs)
this.personalDetailsService.getCareerProfile(this.assocs)
.pipe(takeUntil(this.componentInView))
.subscribe(response => {
this.isLoading = false;
this.hs.oneItHttpResponse(response);
this.careerProfile = response;
}, err => {
this.hs.handleHttpError(err);
this.isLoading = false;
this.utilsService.handleError(err);
})
}
......
......@@ -3,7 +3,6 @@ import { BaseComponent } from '../../../base/base.component';
import { takeUntil } from 'rxjs/operators';
import { CareerProfileModel } from '../../../models/career-profile.model';
import { PersonalDetailsService } from '../../../services/personal-details.service';
import { HelperService } from '../../../services/helper.service';
import { UtilsService } from '../../../../oneit/services/utils.service';
import { WorkExperienceModel } from '../../../models/work-experience.model';
import { NgForm } from '@angular/forms';
......@@ -24,10 +23,9 @@ export class WorkHistoryComponent extends BaseComponent implements OnInit {
@Output() workSaved = new EventEmitter();
constructor(
private ps: PersonalDetailsService,
private us: UtilsService,
private cs: ConfirmationService,
private hs: HelperService
private personalDetailsService: PersonalDetailsService,
private utilsService: UtilsService,
private confirmationService: ConfirmationService
) {
super();
}
......@@ -38,7 +36,7 @@ export class WorkHistoryComponent extends BaseComponent implements OnInit {
getCareerProfile(): void {
this.isLoading = true;
this.ps.getCareerProfile(this.assocs)
this.personalDetailsService.getCareerProfile(this.assocs)
.pipe(takeUntil(this.componentInView))
.subscribe(response => {
this.isLoading = false;
......@@ -49,11 +47,11 @@ export class WorkHistoryComponent extends BaseComponent implements OnInit {
exp.EndMonthField = UtilsService.convertStringToDate(exp.EndMonth);
})
}
this.us.addObjsToJSONByObjectID(this.updatedObjs, this.careerProfile.WorkExperiences);
this.utilsService.addObjsToJSONByObjectID(this.updatedObjs, this.careerProfile.WorkExperiences);
this.addWorkExperience(true);
}, err => {
this.hs.handleHttpError(err);
this.isLoading = false;
this.utilsService.handleError(err);
})
}
......@@ -61,49 +59,47 @@ export class WorkHistoryComponent extends BaseComponent implements OnInit {
const newModel = new WorkExperienceModel();
newModel.CareerProfile = this.careerProfile.ObjectID;
if (initLoad && (!this.careerProfile.WorkExperiences || this.careerProfile.WorkExperiences.length === 0)) {
this.us.addMultiRefObject(newModel, this.careerProfile, 'WorkExperiences', this.createdObjs);
this.utilsService.addMultiRefObject(newModel, this.careerProfile, 'WorkExperiences', this.createdObjs);
} else if (!initLoad) {
this.us.addMultiRefObject(newModel, this.careerProfile, 'WorkExperiences', this.createdObjs);
this.utilsService.addMultiRefObject(newModel, this.careerProfile, 'WorkExperiences', this.createdObjs);
}
}
getJobTitles($event): void {
this.ps.getJobTitles({JobTitle: $event.query})
this.personalDetailsService.getJobTitles({JobTitle: $event.query})
.pipe(takeUntil(this.componentInView))
.subscribe(response => {
this.jobTitles = response.filter(r => r.JobTitle);
}, err => {
this.hs.handleHttpError(err);
this.utilsService.handleError(err);
})
}
removeExperience(exp): void {
this.cs.confirm({
this.confirmationService.confirm({
message:'Are you sure you want to remove this experience?',
accept: () => {
this.us.removeMultiRefObject(exp, this.careerProfile, 'WorkExperiences', this.createdObjs, this.updatedObjs, this.deletedObjs);
this.utilsService.removeMultiRefObject(exp, this.careerProfile, 'WorkExperiences', this.createdObjs, this.updatedObjs, this.deletedObjs);
}
})
}
saveWorkHistory(): void {
this.hs.validateAllFormFields(this.form);
if (this.form.invalid) {
return ;
return this.utilsService.showAllErrorMessages();
}
this.careerProfile.WorkExperiences.forEach(exp => {
exp.StartMonth = UtilsService.convertDateToString(exp.StartMonthField);
exp.EndMonth = UtilsService.convertDateToString(exp.EndMonthField);
});
this.isSaving = true;
this.ps.saveProfile(this.createdObjs, this.updatedObjs, this.deletedObjs)
this.personalDetailsService.saveProfile(this.createdObjs, this.updatedObjs, this.deletedObjs)
.pipe(takeUntil(this.componentInView))
.subscribe(res => {
this.isSaving = false;
this.hs.oneItHttpResponse(res);
this.workSaved.emit();
}, err => {
this.hs.handleHttpError(err);
this.utilsService.handleError(err);
this.isSaving = false;
})
}
......
......@@ -4,7 +4,6 @@ import { PersonalDetailsService } from '../../services/personal-details.service'
import { takeUntil } from 'rxjs/operators';
import { UtilsService } from '../../../oneit/services/utils.service';
import { CareerProfileModel } from '../../models/career-profile.model';
import { HelperService } from '../../services/helper.service';
@Component({
selector: 'app-profile-tasks',
......
......@@ -10,9 +10,9 @@ import { UtilsService } from '../../oneit/services/utils.service';
export class HomeGuard implements CanActivate {
constructor(
private r: Router,
private as: ApiService,
private us: UtilsService
private router: Router,
private apiService: ApiService,
private utilsService: UtilsService
) {
}
......@@ -23,15 +23,14 @@ export class HomeGuard implements CanActivate {
environment: environment.envName,
queryType: 'All'
};
return this.as.post('svc/EnvironmentInformation', params)
return this.apiService.post('svc/EnvironmentInformation', params)
.map(
data => {
// if (this.us.isSuccessfulResponse(data)) {
if (data.result === 'ok') {
if (this.utilsService.isSuccessfulResponse(data)) {
if (data.UserName !== 'noprivauthtoken') {
return true;
}
this.r.navigate(['/my-career-web/auth/login']);
this.router.navigate(['/my-career-web/auth/login']);
return false;
}
......
......@@ -11,9 +11,9 @@ import { UtilsService } from '../../oneit/services/utils.service';
export class PublicGuard implements CanActivate {
constructor(
private r: Router,
private as: ApiService,
private us: UtilsService
private router: Router,
private apiService: ApiService,
private utilsService: UtilsService
) {
}
......@@ -25,12 +25,12 @@ export class PublicGuard implements CanActivate {
queryType: 'All'
};
return this.as.post('svc/EnvironmentInformation', params)
return this.apiService.post('svc/EnvironmentInformation', params)
.map(
data => {
if (this.us.isSuccessfulResponse(data)) {
if (this.utilsService.isSuccessfulResponse(data)) {
if (data.UserName !== 'noprivauthtoken') {
this.r.navigate(['/my-career-web/dashboard']);
this.router.navigate(['/my-career-web/dashboard']);
return false;
}
......
......@@ -6,7 +6,6 @@ import { takeUntil } from 'rxjs/operators';
import { UtilsService } from '../../../oneit/services/utils.service';
import { PersonalDetailsService } from '../../services/personal-details.service';
import { CareerProfileModel } from '../../models/career-profile.model';
import { HelperService } from '../../services/helper.service';
import { IntroLetterService } from '../../services/intro-letter.service';
import { NgForm } from '@angular/forms';
......@@ -25,18 +24,17 @@ export class IntroLetterComponent extends BaseComponent implements OnInit {
@ViewChild('form') form: NgForm;
constructor(
private ar: ActivatedRoute,
private ps: PersonalDetailsService,
private is: IntroLetterService,
private hs: HelperService,
private us: UtilsService,
private r: Router
private activatedRoute: ActivatedRoute,
private personalDetailsService: PersonalDetailsService,
private introLetterService: IntroLetterService,
private utilsService: UtilsService,
private router: Router
) {
super();
}
ngOnInit() {
this.ar.params
this.activatedRoute.params
.pipe(takeUntil(this.componentInView))
.subscribe(params => {
if (params.id && params.id !== 'new') {
......@@ -51,57 +49,51 @@ export class IntroLetterComponent extends BaseComponent implements OnInit {
getCareerProfile(): void {
this.isLoadingSkillAndExp = true;
const assocs = ['WorkExperiences', 'Skills.Skill'];
this.ps.getCareerProfile(assocs)
this.personalDetailsService.getCareerProfile(assocs)
.pipe(takeUntil(this.componentInView))
.subscribe(response => {
this.isLoadingSkillAndExp = false;
this.hs.oneItHttpResponse(response);
this.careerProfile = response;
if (!this.isEditMode) {
this.introductionLetter = new IntroductionLetterModel();
this.introductionLetter.Candidate = this.careerProfile.Candidate;
this.us.createObject(this.introductionLetter, this.createdObjs);
this.utilsService.createObject(this.introductionLetter, this.createdObjs);
}
console.log(this.careerProfile);
}, err => {
this.isLoadingSkillAndExp = false;
this.hs.handleHttpError(err);
this.utilsService.handleError(err);
})
}
getIntroLetter(): void {
this.isLoading = true;
this.is.getIntroLetter(this.introLetterId)
this.introLetterService.getIntroLetter(this.introLetterId)
.pipe(takeUntil(this.componentInView))
.subscribe(response => {
this.isLoading = false;
this.hs.oneItHttpResponse(response);
this.introductionLetter = response;
this.updatedObjs[this.introductionLetter.ObjectID] = this.introductionLetter;
console.log(this.introductionLetter);
}, err => {
this.hs.handleHttpError(err);
this.utilsService.handleError(err);
this.isLoading = false;
})
}
saveIntroLetter(): void {
this.hs.validateAllFormFields(this.form);
if (this.form.invalid) {
return;
return this.utilsService.showAllErrorMessages();
}
this.isLoading = true;
this.is.saveIntroLetters(this.createdObjs, this.updatedObjs, this.deletedObjs)
this.introLetterService.saveIntroLetters(this.createdObjs, this.updatedObjs, this.deletedObjs)
.pipe(takeUntil(this.componentInView))
.subscribe(response => {
this.isLoading = false;
this.hs.oneItHttpResponse(response);
if (response.created && response.created[this.introductionLetter.ObjectID]) {
this.r.navigate([`my-career-web/intro-letters/${response.created[this.introductionLetter.ObjectID]}`])
this.router.navigate([`my-career-web/intro-letters/${response.created[this.introductionLetter.ObjectID]}`])
}
}, err => {
this.utilsService.handleError(err);
this.isLoading = false;
this.hs.handleHttpError(err);
});
}
......
......@@ -2,8 +2,8 @@ import { Component, OnInit } from '@angular/core';
import { BaseComponent } from '../../base/base.component';
import { IntroLetterService } from '../../services/intro-letter.service';
import { takeUntil } from 'rxjs/operators';
import { HelperService } from '../../services/helper.service';
import { IntroductionLetterModel } from '../../models/introduction-letter.model';
import { UtilsService } from '../../../oneit/services/utils.service';
@Component({
selector: 'app-intro-letters',
......@@ -16,7 +16,7 @@ export class IntroLettersComponent extends BaseComponent implements OnInit {
constructor(
private introLetterService: IntroLetterService,
private helperService: HelperService
private utilService: UtilsService
) {
super();
}
......@@ -31,12 +31,10 @@ export class IntroLettersComponent extends BaseComponent implements OnInit {
.pipe(takeUntil(this.componentInView))
.subscribe(response => {
this.isLoading = false;
this.helperService.oneItHttpResponse(response);
this.introLetters = response;
console.log(this.introLetters);
}, err => {
this.isLoading = false;
this.helperService.handleHttpError(err);
this.utilService.handleError(err);
})
}
......
......@@ -3,7 +3,6 @@ import { NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { PrimeNGModules } from '../../utils/common.modules.import';
import { AssessmentService } from '../services/assessment.service';
import { HelperService } from '../services/helper.service';
import { PersonalDetailsService } from '../services/personal-details.service';
import { ToasterService } from '../services/toaster.service';
import { FormControlComponent } from './form-control/form-control.component';
......@@ -52,7 +51,6 @@ const PIPES = [
],
providers: [
ToasterService,
HelperService,
PersonalDetailsService,
AssessmentService,
IntroLetterService
......
......@@ -4,10 +4,10 @@ import { takeUntil } from 'rxjs/operators';
import { AppService } from '../../../app.service';
import { BaseComponent } from '../../base/base.component';
import { CareerProfileModel } from '../../models/career-profile.model';
import { HelperService } from '../../services/helper.service';
import { PersonalDetailsService } from '../../services/personal-details.service';
import { ToasterService } from '../../services/toaster.service';
import { Router } from '@angular/router';
import { UtilsService } from '../../../oneit/services/utils.service';
@Component({
selector: 'app-personal-details',
......@@ -30,11 +30,11 @@ export class PersonalDetailsComponent extends BaseComponent implements OnInit {
@ViewChild('form') form: NgForm;
constructor(
private ps: PersonalDetailsService,
private ts: ToasterService,
private hs: HelperService,
private aps: AppService,
private r: Router
private personalDetailsService: PersonalDetailsService,
private toasterService: ToasterService,
private appService: AppService,
private utilsService: UtilsService,
private router: Router
) {
super();
}
......@@ -47,43 +47,43 @@ export class PersonalDetailsComponent extends BaseComponent implements OnInit {
getEmploymentStatuses(): void {
this.isLoadingStatuses = true;
this.ps.getEmploymentStatuses()
this.personalDetailsService.getEmploymentStatuses()
.pipe(takeUntil(this.componentInView))
.subscribe(response => {
this.employmentStatuses = response;
this.isLoadingStatuses = false;
}, err => {
this.hs.handleHttpError(err);
this.isLoadingStatuses = false;
this.utilsService.handleError(err);
})
}
getEmploymentPreferences(): void {
this.isLoadingPreferences = true;
this.ps.getEmploymentPreferences()
this.personalDetailsService.getEmploymentPreferences()
.pipe(takeUntil(this.componentInView))
.subscribe(response => {
this.employmentPreferences = response;
this.isLoadingPreferences = false;
}, err => {
this.hs.handleHttpError(err);
this.isLoadingPreferences = false;
this.utilsService.handleError(err);
})
}
getJobTitles($event): void {
this.ps.getJobTitles({JobTitle: $event.query})
this.personalDetailsService.getJobTitles({JobTitle: $event.query})
.pipe(takeUntil(this.componentInView))
.subscribe(response => {
this.jobTitles = response.filter(r => r.JobTitle);
}, err => {
this.hs.handleHttpError(err);
this.utilsService.handleError(err);
})
}
getCareerProfile(): void {
this.isLoading = true;
this.ps.getCareerProfile(this.assocs)
this.personalDetailsService.getCareerProfile(this.assocs)
.pipe(takeUntil(this.componentInView))
.subscribe(response => {
this.careerProfile = response;
......@@ -93,36 +93,34 @@ export class PersonalDetailsComponent extends BaseComponent implements OnInit {
if (this.careerProfile.Candidate.EmploymentPreference) {
this.careerProfile.Candidate.EmploymentPreference = this.careerProfile.Candidate.EmploymentPreference.map(p => p.Value);
}
this.ps.careerProfileUpdated = this.careerProfile;
this.personalDetailsService.careerProfileUpdated = this.careerProfile;
this.isLoading = false;
}, err => {
this.hs.handleHttpError(err);
this.isLoading = false;
this.utilsService.handleError(err);
})
}
updateProfile(): void {
this.hs.validateAllFormFields(this.form);
if (this.form.invalid) {
return ;
return this.utilsService.showAllErrorMessages();
}
this.careerProfile.Candidate.User.UserName = this.careerProfile.Candidate.User.Email;
this.isSaving = true;
this.ps.saveProfile(this.createdObjs, this.updatedObjs, this.deletedObjs)
this.personalDetailsService.saveProfile(this.createdObjs, this.updatedObjs, this.deletedObjs)
.pipe(takeUntil(this.componentInView))
.subscribe(res => {
this.isSaving = false;
this.hs.oneItHttpResponse(res);
this.ps.careerProfileUpdated = this.careerProfile;
this.ts.success('Profile updated.');
this.personalDetailsService.careerProfileUpdated = this.careerProfile;
this.toasterService.success('Profile updated.');
if (!this.asChildComponent) {
this.r.navigate(['/my-career-web/dashboard/home']);
this.router.navigate(['/my-career-web/dashboard/home']);
} else {
this.detailsSaved.emit();
}
}, err => {
this.hs.handleHttpError(err);
this.isSaving = false;
this.utilsService.handleError(err);
})
}
......@@ -142,7 +140,7 @@ export class PersonalDetailsComponent extends BaseComponent implements OnInit {
connectWithSocial(type): void {
this.isLoading = true;
this.aps.socicalMediaLogin(type)
this.appService.socicalMediaLogin(type)
.pipe(takeUntil(this.componentInView))
.subscribe(data => {
this.isLoading = false;
......@@ -153,7 +151,7 @@ export class PersonalDetailsComponent extends BaseComponent implements OnInit {
},
err => {
this.isLoading = false;
this.hs.handleHttpError(err);
this.utilsService.handleError(err);
}
)
}
......
......@@ -7,47 +7,47 @@ import { UtilsService } from '../../oneit/services/utils.service';
export class AssessmentService {
constructor(
private us: UtilsService,
private ss: SearchService
private utilsService: UtilsService,
private searchService: SearchService
) { }
getWorkStyle(assocs = []): Observable<any> {
return this.ss.getObjects('WorkStyle', 'All', '', assocs, null, null, null, null)
return this.searchService.getObjects('WorkStyle', 'All', '', assocs, null, null, null, null)
.map(
data => {
return this.us.convertResponseToObjects(data, assocs);
return this.utilsService.convertResponseToObjects(data, assocs);
}
)
}
getWorkPreferences(assocs = []): Observable<any> {
return this.ss.getObjects('WorkPreferences', 'All', '', assocs, null, null, null, null)
return this.searchService.getObjects('WorkPreferences', 'All', '', assocs, null, null, null, null)
.map(
data => {
return this.us.convertResponseToObjects(data, assocs);
return this.utilsService.convertResponseToObjects(data, assocs);
}
)
}
getDiversityProfile(assocs = []): Observable<any> {
return this.ss.getObjects('DiversityProfile', 'All', '', assocs, null, null, null, null)
return this.searchService.getObjects('DiversityProfile', 'All', '', assocs, null, null, null, null)
.map(
data => {
return this.us.convertResponseToObjects(data, assocs);
return this.utilsService.convertResponseToObjects(data, assocs);
}
)
}
saveWorkStyle(params): Observable<any> {
return this.us.processObjects('SaveWorkStyle', params);
return this.utilsService.processObjects('SaveWorkStyle', params);
}
saveWorkPreferences(params): Observable<any> {
return this.us.processObjects('SaveWorkPreferences', params);
return this.utilsService.processObjects('SaveWorkPreferences', params);
}
saveDiversityProfile(params): Observable<any> {
return this.us.processObjects('SaveDiversityProfile', params);
return this.utilsService.processObjects('SaveDiversityProfile', params);
}
......
import { HttpErrorResponse } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { FormArray, FormControl, FormGroup } from '@angular/forms';
import { ToasterService } from './toaster.service';
@Injectable()
export class HelperService {
constructor(
private ts: ToasterService
) {
}
validateAllFormFields(form?: any): void {
const formObj = typeof form.form ? form.form : form;
Object
.keys(form.controls)
.forEach(field => {
const control = formObj.get(field);
if (control instanceof FormControl) {
control.markAsDirty({onlySelf: true});
control.markAsTouched({onlySelf: true});
} else if (control instanceof FormGroup) {
this.validateAllFormFields(control);
} else if (control instanceof FormArray) {
control.controls.forEach(ctrl => {
if (ctrl instanceof FormControl) {
ctrl.markAsDirty({onlySelf: true});
ctrl.markAsTouched({onlySelf: true});
} else if (ctrl instanceof FormGroup) {
this.validateAllFormFields(ctrl);
}
});
}
});
}
handleHttpError(httpError: HttpErrorResponse): void {
let message;
message = httpError.error.errors ? httpError.error.errors[Object.keys(httpError.error.errors)[0]] : httpError.error.message;
switch (httpError.status) {
case 401:
break;
case 403:
break;
case 404:
break;
case 422:
break;
case 500:
message = 'Internal server error';
break;
case 0:
message = 'No internet connection.';
break;
default:
break;
}
this.ts.error(message, 'Request Error');
}
oneItHttpResponse(response): void {
if (response.status === 'error') {
this.ts.error(response.errorDetails[0]);
throw new Error('Error on success response');
}
}
}
......@@ -10,33 +10,33 @@ import { IntroductionLetterModel } from '../models/introduction-letter.model';
export class IntroLetterService {
constructor(
private us: UtilsService,
private ss: SearchService,
private svs: SaveService
private utilsService: UtilsService,
private searchService: SearchService,
private saveService: SaveService
) {
}
getIntroLetters(queryParams = {}, assocs = []): Observable<any> {
return this.ss.getObjects(SERVICES.INTRODUCTION_LETTERS, 'All', queryParams, assocs, null, null, null, null)
return this.searchService.getObjects(SERVICES.INTRODUCTION_LETTERS, 'All', queryParams, assocs, null, null, null, null)
.map(
data => {
return this.us.convertResponseToObjects(data, assocs);
return this.utilsService.convertResponseToObjects(data, assocs);
}
)
}
getIntroLetter(id, assocs = []): Observable<IntroductionLetterModel> {
return this.ss.getObjects(SERVICES.INTRODUCTION_LETTERS, 'ByID', {id: id}, assocs, null, null, null, null)
return this.searchService.getObjects(SERVICES.INTRODUCTION_LETTERS, 'ByID', {id: id}, assocs, null, null, null, null)
.map(
data => {
return this.us.convertResponseToObjects(data, assocs)[0];
return this.utilsService.convertResponseToObjects(data, assocs)[0];
}
)
}
saveIntroLetters(createdObjs, updatedObjs, deleteObjs): Observable<any> {
return this.svs.saveObjectsWithDefaultSvc(createdObjs, updatedObjs, deleteObjs, true);
return this.saveService.saveObjectsWithDefaultSvc(createdObjs, updatedObjs, deleteObjs, true);
}
}
......@@ -22,63 +22,63 @@ export class PersonalDetailsService {
}
constructor(
private es: EnumService,
private us: UtilsService,
private ss: SearchService,
private svs: SaveService
private enumService: EnumService,
private utilsService: UtilsService,
private searchService: SearchService,
private saveService: SaveService
) {
}
getEmploymentStatuses(): Observable<any> {
return this.es.getEnums('EmploymentStatuses', true);
return this.enumService.getEnums('EmploymentStatuses', true);
}
getEmploymentPreferences(): Observable<any> {
return this.es.getEnums('EmploymentPreferences', true);
return this.enumService.getEnums('EmploymentPreferences', true);
}
getJobTitles(queryParams = {}, assocs = []): Observable<any> {
return this.ss.getObjects(SERVICES.JOB_TITLES, 'All', queryParams, assocs, null, null, null, null)
return this.searchService.getObjects(SERVICES.JOB_TITLES, 'All', queryParams, assocs, null, null, null, null)
.map(
data => {
return this.us.convertResponseToObjects(data, assocs);
return this.utilsService.convertResponseToObjects(data, assocs);
}
)
}
getSkills(queryParams = {}, assocs = []): Observable<any> {
return this.ss.getObjects(SERVICES.SKILLS, 'All', queryParams, assocs, null, null, null, null)
return this.searchService.getObjects(SERVICES.SKILLS, 'All', queryParams, assocs, null, null, null, null)
.map(
data => {
return this.us.convertResponseToObjects(data, assocs);
return this.utilsService.convertResponseToObjects(data, assocs);
}
)
}
getCertifications(queryParams = {}, assocs = []): Observable<any> {
return this.ss.getObjects(SERVICES.CERTIFICATIONS, 'All', queryParams, assocs, 'Autocomplete', null, null, null)
return this.searchService.getObjects(SERVICES.CERTIFICATIONS, 'All', queryParams, assocs, 'Autocomplete', null, null, null)
.map(
data => {
return this.us.convertResponseToObjects(data, assocs);
return this.utilsService.convertResponseToObjects(data, assocs);
}
)
}
getSkillRatings(): Observable<any> {
return this.es.getEnums('SkillRatings', true);
return this.enumService.getEnums('SkillRatings', true);
}
getCareerProfile(assocs = []): Observable<CareerProfileModel> {
return this.ss.getObjects(SERVICES.CAREER_PROFILES, 'All', {}, assocs, null, null, null, null)
return this.searchService.getObjects(SERVICES.CAREER_PROFILES, 'All', {}, assocs, null, null, null, null)
.map(
data => {
return this.us.convertResponseToObjects(data, assocs)[0];
return this.utilsService.convertResponseToObjects(data, assocs)[0];
}
)
}
saveProfile(createdObjs, updatedObjs, deletedObjs): Observable<any> {
return this.svs.saveObjects('svc/SavePersonalDetails',createdObjs, updatedObjs, deletedObjs, true);
return this.saveService.saveObjects('svc/SavePersonalDetails',createdObjs, updatedObjs, deletedObjs, true);
}
}
......@@ -6,22 +6,22 @@ import { MessageService } from 'primeng/api';
export class ToasterService {
constructor(
private ms: MessageService
private messageService: MessageService
) { }
error(txt, title = 'Error'): void {
this.ms.add({severity: 'error', summary: title, detail: txt, life: 3000});
this.messageService.add({severity: 'error', summary: title, detail: txt, life: 3000});
}
success(txt, title = 'Success'): void {
this.ms.add({severity: 'success', summary: title, detail: txt, life: 3000});
this.messageService.add({severity: 'success', summary: title, detail: txt, life: 3000});
}
warning(txt, title = 'Warning'): void {
this.ms.add({severity: 'warn', summary: title, detail: txt, life: 3000});
this.messageService.add({severity: 'warn', summary: title, detail: txt, life: 3000});
}
info(txt, title = 'Notification'): void {
this.ms.add({severity: 'info', summary: title, detail: txt, life: 3000});
this.messageService.add({severity: 'info', summary: title, detail: txt, life: 3000});
}
}
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