Commit b1d542cf by Muhammad Usman

refactoring completed

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