last fix i hope
This commit is contained in:
@@ -32,7 +32,7 @@
|
|||||||
<!-- Map View -->
|
<!-- Map View -->
|
||||||
@if (viewMode() === 'map') {
|
@if (viewMode() === 'map') {
|
||||||
<app-candidates-map
|
<app-candidates-map
|
||||||
[candidates]="applicationList()"
|
[candidates]="this.dataService.cachedApplicationList()"
|
||||||
[cities]="availableCities()">
|
[cities]="availableCities()">
|
||||||
</app-candidates-map>
|
</app-candidates-map>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,16 +43,15 @@ export class ApplicationListComponent implements OnInit {
|
|||||||
snackBar = inject(MatSnackBar)
|
snackBar = inject(MatSnackBar)
|
||||||
environment = environment;
|
environment = environment;
|
||||||
|
|
||||||
applicationList = signal<any[]>([]);
|
|
||||||
searchTerm = signal('');
|
searchTerm = signal('');
|
||||||
filterCity = signal('');
|
filterCity = signal('');
|
||||||
sortField = signal<string>('fullName');
|
sortField = signal<string>('fullName');
|
||||||
viewMode = signal<'map' | 'charts'>('map');
|
viewMode = signal<'map' | 'charts'>('map');
|
||||||
|
|
||||||
availableCities = signal<City[]>(CITY_LIST);
|
availableCities = signal<City[]>(CITY_LIST);
|
||||||
|
|
||||||
filteredList = computed(() => {
|
filteredList = computed(() => {
|
||||||
const apps = this.applicationList();
|
const apps = this.dataService.cachedApplicationList();
|
||||||
const term = this.searchTerm().toLowerCase();
|
const term = this.searchTerm().toLowerCase();
|
||||||
const city = this.filterCity();
|
const city = this.filterCity();
|
||||||
|
|
||||||
@@ -99,7 +98,7 @@ export class ApplicationListComponent implements OnInit {
|
|||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
effect(() => {
|
effect(() => {
|
||||||
const data = this.applicationList();
|
const data = this.dataService.cachedApplicationList();
|
||||||
|
|
||||||
if (data.length === 0) {
|
if (data.length === 0) {
|
||||||
this.ageChartData.set({ labels: [], datasets: [] });
|
this.ageChartData.set({ labels: [], datasets: [] });
|
||||||
@@ -183,27 +182,27 @@ export class ApplicationListComponent implements OnInit {
|
|||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.dataService.loadCandidateList().subscribe(data => {
|
this.dataService.loadCandidateList().subscribe(data => {
|
||||||
this.applicationList.set(data);
|
this.dataService.cachedApplicationList.set(data);
|
||||||
this.availableCities.set(this.getUniqueCities(data));
|
this.availableCities.set(this.getUniqueCities(data));
|
||||||
});
|
});
|
||||||
|
|
||||||
this.socketService.onCandidateRegistered().subscribe(newCandidate => {
|
this.socketService.onCandidateRegistered().subscribe(newCandidate => {
|
||||||
this.applicationList.update(list => [newCandidate, ...list]);
|
this.dataService.cachedApplicationList.update(list => [newCandidate, ...list]);
|
||||||
this.availableCities.set(this.getUniqueCities(this.applicationList()));
|
this.availableCities.set(this.getUniqueCities(this.dataService.cachedApplicationList()));
|
||||||
});
|
});
|
||||||
|
|
||||||
this.socketService.onCandidateUpdated().subscribe(updatedCandidate => {
|
this.socketService.onCandidateUpdated().subscribe(updatedCandidate => {
|
||||||
this.applicationList.update(list =>
|
this.dataService.cachedApplicationList.update(list =>
|
||||||
list.map(app => app.id === updatedCandidate.id ? updatedCandidate : app)
|
list.map(app => app.id === updatedCandidate.id ? updatedCandidate : app)
|
||||||
);
|
);
|
||||||
this.availableCities.set(this.getUniqueCities(this.applicationList()));
|
this.availableCities.set(this.getUniqueCities(this.dataService.cachedApplicationList()));
|
||||||
});
|
});
|
||||||
|
|
||||||
this.socketService.onCandidateDeleted().subscribe(deletedCandidateId => {
|
this.socketService.onCandidateDeleted().subscribe(deletedCandidateId => {
|
||||||
this.applicationList.update(list =>
|
this.dataService.cachedApplicationList.update(list =>
|
||||||
list.filter(app => app.id !== deletedCandidateId)
|
list.filter(app => app.id !== deletedCandidateId)
|
||||||
);
|
);
|
||||||
this.availableCities.set(this.getUniqueCities(this.applicationList()));
|
this.availableCities.set(this.getUniqueCities(this.dataService.cachedApplicationList()));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
<mat-icon>chevron_left</mat-icon>
|
<mat-icon>chevron_left</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
<span class="navigation-info">
|
<span class="navigation-info">
|
||||||
{{ currentIndex() + 1 }} of {{ applicationList().length }}
|
{{ currentIndex() + 1 }} of {{ this.dataService.cachedApplicationList().length }}
|
||||||
</span>
|
</span>
|
||||||
<button
|
<button
|
||||||
mat-icon-button
|
mat-icon-button
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ export class ApplicationComponent implements OnInit {
|
|||||||
|
|
||||||
|
|
||||||
currentApplication = signal<any>(null);
|
currentApplication = signal<any>(null);
|
||||||
applicationList = signal<any[]>([]);
|
|
||||||
currentIndex = signal<number>(-1);
|
currentIndex = signal<number>(-1);
|
||||||
environment = environment;
|
environment = environment;
|
||||||
|
|
||||||
@@ -56,7 +55,7 @@ export class ApplicationComponent implements OnInit {
|
|||||||
canGoToPrevious = computed(() => this.currentIndex() > 0);
|
canGoToPrevious = computed(() => this.currentIndex() > 0);
|
||||||
canGoToNext = computed(() =>
|
canGoToNext = computed(() =>
|
||||||
this.currentIndex() >= 0 &&
|
this.currentIndex() >= 0 &&
|
||||||
this.currentIndex() < this.applicationList().length - 1
|
this.currentIndex() < this.dataService.cachedApplicationList().length - 1
|
||||||
);
|
);
|
||||||
|
|
||||||
canEdit = computed(() => {
|
canEdit = computed(() => {
|
||||||
@@ -70,13 +69,11 @@ export class ApplicationComponent implements OnInit {
|
|||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
if (this.dataService.cachedApplicationList().length > 0) {
|
if (this.dataService.cachedApplicationList().length > 0) {
|
||||||
this.applicationList.set(this.dataService.cachedApplicationList());
|
|
||||||
this.initializeApplication();
|
this.initializeApplication();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.dataService.loadCandidateList().subscribe({
|
this.dataService.loadCandidateList().subscribe({
|
||||||
next: (data) => {
|
next: (data) => {
|
||||||
this.applicationList.set(data);
|
|
||||||
this.initializeApplication();
|
this.initializeApplication();
|
||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error) => {
|
||||||
@@ -101,7 +98,7 @@ export class ApplicationComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const applicationId = Number.parseInt(id, 10);
|
const applicationId = Number.parseInt(id, 10);
|
||||||
const foundIndex = this.applicationList().findIndex(app => app.id === applicationId);
|
const foundIndex = this.dataService.cachedApplicationList().findIndex(app => app.id === applicationId);
|
||||||
|
|
||||||
if (foundIndex === -1) {
|
if (foundIndex === -1) {
|
||||||
alert('Application not found');
|
alert('Application not found');
|
||||||
@@ -140,7 +137,7 @@ export class ApplicationComponent implements OnInit {
|
|||||||
if (this.canGoToPrevious()) {
|
if (this.canGoToPrevious()) {
|
||||||
const newIndex = this.currentIndex() - 1;
|
const newIndex = this.currentIndex() - 1;
|
||||||
this.currentIndex.set(newIndex);
|
this.currentIndex.set(newIndex);
|
||||||
const prevId = this.applicationList()[newIndex].id;
|
const prevId = this.dataService.cachedApplicationList()[newIndex].id;
|
||||||
this.loadApplication(prevId)?.subscribe();
|
this.loadApplication(prevId)?.subscribe();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -149,7 +146,7 @@ export class ApplicationComponent implements OnInit {
|
|||||||
if (this.canGoToNext()) {
|
if (this.canGoToNext()) {
|
||||||
const newIndex = this.currentIndex() + 1;
|
const newIndex = this.currentIndex() + 1;
|
||||||
this.currentIndex.set(newIndex);
|
this.currentIndex.set(newIndex);
|
||||||
const nextId = this.applicationList()[newIndex].id;
|
const nextId = this.dataService.cachedApplicationList()[newIndex].id;
|
||||||
this.loadApplication(nextId)?.subscribe();
|
this.loadApplication(nextId)?.subscribe();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ export class SocketIOService {
|
|||||||
onCandidateRegistered(): Observable<any> {
|
onCandidateRegistered(): Observable<any> {
|
||||||
return new Observable(observer => {
|
return new Observable(observer => {
|
||||||
this.socket.on('candidateRegistered', (data) => {
|
this.socket.on('candidateRegistered', (data) => {
|
||||||
console.log(data);
|
|
||||||
observer.next(data);
|
observer.next(data);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user