large update wip
This commit is contained in:
46
src/app/services/candidate-data.service.ts
Normal file
46
src/app/services/candidate-data.service.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import { HttpClient } from "@angular/common/http";
|
||||
import { inject, Injectable, signal } from "@angular/core";
|
||||
import { environment } from "../../environments/environment.development";
|
||||
import { delay, tap } from "rxjs";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class CandidateDataService {
|
||||
httpClient = inject(HttpClient)
|
||||
isCandidatesListLoading = signal(false)
|
||||
isApplicationDetailsLoading = signal(false)
|
||||
cachedApplicationList: any[] = []
|
||||
|
||||
loadCandidateList() {
|
||||
this.isCandidatesListLoading.set(true)
|
||||
return this.httpClient.get<any>(`${environment.hostUrl}/app/candidates`).pipe(
|
||||
delay(500),
|
||||
tap((data) => {
|
||||
this.isCandidatesListLoading.set(false);
|
||||
this.cachedApplicationList = data;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
getApplicationDetails(id: number) {
|
||||
this.isApplicationDetailsLoading.set(true);
|
||||
return this.httpClient.get(`${environment.hostUrl}/app/candidate/${id}`).pipe(
|
||||
delay(500),
|
||||
tap(() => { this.isApplicationDetailsLoading.set(false) })
|
||||
);
|
||||
}
|
||||
|
||||
submitCandidateForm(data: FormData) {
|
||||
return this.httpClient.post(`${environment.hostUrl}/app/register`, data);
|
||||
}
|
||||
|
||||
updateCandidateForm(id: number, data: FormData) {
|
||||
return this.httpClient.put(
|
||||
`${environment.hostUrl}/app/candidate/${id}`,
|
||||
data
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
35
src/app/services/socket-io.service.ts
Normal file
35
src/app/services/socket-io.service.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { io } from "socket.io-client";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class SocketIOService {
|
||||
|
||||
socket = io('ws://localhost:3000');
|
||||
|
||||
onCandidateRegistered(): Observable<any> {
|
||||
return new Observable(observer => {
|
||||
this.socket.on('candidateRegistered', (data) => {
|
||||
observer.next(data);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
onCandidateUpdated(): Observable<any> {
|
||||
return new Observable(observer => {
|
||||
this.socket.on('candidateUpdated', (data) => {
|
||||
observer.next(data);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
this.socket.disconnect();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user