Seperate page init from construct

This commit is contained in:
2025-08-18 20:57:26 -07:00
parent 5fa8b37d50
commit 967069acd4
7 changed files with 26 additions and 24 deletions
@@ -28,12 +28,13 @@ export class CompanyComponent {
constructor( private http: HttpClient, private router: Router, private route: ActivatedRoute, private title: Title, public auth: Authentication ) { constructor( private http: HttpClient, private router: Router, private route: ActivatedRoute, private title: Title, public auth: Authentication ) {
this.title.setTitle("Companies | BoredCareers"); this.title.setTitle("Companies | BoredCareers");
if (!auth.isLoggedIn){ if (!auth.isLoggedIn){
router.navigate(["/"]); router.navigate(["/"]);
} }
};
http.get<Employee[]>("api/employee/").subscribe({ ngOnInit(){
this.http.get<Employee[]>("api/employee/").subscribe({
next: data => { next: data => {
this.Employers = data; this.Employers = data;
if (data[0] != null){ if (data[0] != null){
@@ -46,7 +47,7 @@ export class CompanyComponent {
this.ErrorMsg = err.error; this.ErrorMsg = err.error;
} }
}); });
}; }
changeSelectedCompany(companyID: number){ changeSelectedCompany(companyID: number){
this.http.get<Company>("api/company?CompanyID=" + companyID).subscribe({ this.http.get<Company>("api/company?CompanyID=" + companyID).subscribe({
@@ -24,14 +24,15 @@ export class CompanyEditorComponent {
constructor( private http: HttpClient, private router: Router, private route: ActivatedRoute, private title: Title, public auth: Authentication ) { constructor( private http: HttpClient, private router: Router, private route: ActivatedRoute, private title: Title, public auth: Authentication ) {
this.title.setTitle("Company - Editor | BoredCareers"); this.title.setTitle("Company - Editor | BoredCareers");
if (!auth.isLoggedIn){ if (!auth.isLoggedIn){
router.navigate(["/"]); router.navigate(["/"]);
} }
};
ngOnInit(){
// Query param CompanyID -> Edit // Query param CompanyID -> Edit
// Query param null -> New // Query param null -> New
}; }
ngAfterViewInit(){ ngAfterViewInit(){
this.formSteps.changes.subscribe(() => { this.formSteps.changes.subscribe(() => {
@@ -26,11 +26,12 @@ export class JobEditorComponent {
constructor( private http: HttpClient, private router: Router, private route: ActivatedRoute, private title: Title, public auth: Authentication ) { constructor( private http: HttpClient, private router: Router, private route: ActivatedRoute, private title: Title, public auth: Authentication ) {
this.title.setTitle("Jobs - Editor | BoredCareers"); this.title.setTitle("Jobs - Editor | BoredCareers");
if (!auth.isLoggedIn){ if (!auth.isLoggedIn){
router.navigate(["/"]); router.navigate(["/"]);
} }
}
ngOnInit(){
this.route.queryParams.subscribe(params => { this.route.queryParams.subscribe(params => {
const CompanyID = params['CompanyID'] ? +params['CompanyID'] : null; const CompanyID = params['CompanyID'] ? +params['CompanyID'] : null;
const JobID = params['JobID'] ? +params['JobID'] : null; const JobID = params['JobID'] ? +params['JobID'] : null;
@@ -23,12 +23,10 @@ export class JobsComponent {
constructor( private http: HttpClient, private router: Router, private route: ActivatedRoute, private title: Title, public auth: Authentication ) { constructor( private http: HttpClient, private router: Router, private route: ActivatedRoute, private title: Title, public auth: Authentication ) {
this.title.setTitle("Jobs | BoredCareers"); this.title.setTitle("Jobs | BoredCareers");
};
if (this.Page == 1){ ngOnInit(){
this.http.get<JobListing[]>("api/joblisting?PageQuantity=" + 10 + "&Page=" + 1).subscribe({
}
http.get<JobListing[]>("api/joblisting?PageQuantity=" + 10 + "&Page=" + 1).subscribe({
next: data => { next: data => {
this.JobListingPage = data; this.JobListingPage = data;
}, },
@@ -36,7 +34,6 @@ export class JobsComponent {
this.ErrorMsg = err.error; this.ErrorMsg = err.error;
} }
}); });
}
};
} }
@@ -22,7 +22,9 @@ export class JobViewerComponent {
constructor( private http: HttpClient, private router: Router, private route: ActivatedRoute, private title: Title, public auth: Authentication ) { constructor( private http: HttpClient, private router: Router, private route: ActivatedRoute, private title: Title, public auth: Authentication ) {
this.title.setTitle("Jobs - Viewer | BoredCareers"); this.title.setTitle("Jobs - Viewer | BoredCareers");
};
ngOnInit(){
this.route.queryParams.subscribe(params => { this.route.queryParams.subscribe(params => {
const JobID = params['JobID']; const JobID = params['JobID'];
if (JobID){ if (JobID){
@@ -43,13 +45,12 @@ export class JobViewerComponent {
} }
}) })
}else{ }else{
router.navigate(["/"]); this.router.navigate(["/"]);
} }
if (this.selectedJob != null){ if (this.selectedJob != null){
} }
}); });
}
};
} }
@@ -22,6 +22,12 @@ export class ResumesEditorComponent {
constructor( private http: HttpClient, private router: Router, private route: ActivatedRoute, private title: Title, public auth: Authentication ) { constructor( private http: HttpClient, private router: Router, private route: ActivatedRoute, private title: Title, public auth: Authentication ) {
this.title.setTitle("Resume - Editor | BoredCareers"); this.title.setTitle("Resume - Editor | BoredCareers");
if (!this.auth.isLoggedIn){
this.router.navigate(["/"]);
}
};
ngOnInit(){
this.route.queryParams.subscribe(params => { this.route.queryParams.subscribe(params => {
const ResumeID = params['ResumeID'] ? +params['ResumeID'] : null; const ResumeID = params['ResumeID'] ? +params['ResumeID'] : null;
if (ResumeID !== null){ if (ResumeID !== null){
@@ -37,12 +43,6 @@ export class ResumesEditorComponent {
}); });
} }
}); });
};
async ngOnInit(){
if (!this.auth.isLoggedIn){
this.router.navigate(["/"]);
}
} }
// Pagnation // // Pagnation //
@@ -20,11 +20,12 @@ export class ResumesComponent {
constructor( private http: HttpClient, private router: Router, private route: ActivatedRoute, private title: Title, public auth: Authentication ) { constructor( private http: HttpClient, private router: Router, private route: ActivatedRoute, private title: Title, public auth: Authentication ) {
this.title.setTitle("Resumes | BoredCareers"); this.title.setTitle("Resumes | BoredCareers");
if (!auth.isLoggedIn){ if (!auth.isLoggedIn){
router.navigate(["/"]); router.navigate(["/"]);
} }
};
ngOnInit(){
this.http.get<Resume[]>("api/resume").subscribe({ this.http.get<Resume[]>("api/resume").subscribe({
next: data => { next: data => {
this.myResumes = data; this.myResumes = data;
@@ -33,7 +34,7 @@ export class ResumesComponent {
console.log("Error fetching resumes: " + err.error); console.log("Error fetching resumes: " + err.error);
} }
}); });
}; }
changeSelectedResume(ResumeID: number){ changeSelectedResume(ResumeID: number){
this.http.get<Resume>("api/resume?ResumeID=" + ResumeID).subscribe({ this.http.get<Resume>("api/resume?ResumeID=" + ResumeID).subscribe({