T hoguet/issue16 #139
No files matched your search
@@ -57,8 +57,8 @@
|
||||
|
||||
::ng-deep .mat-mdc-progress-spinner {
|
||||
// Override Material spinner size
|
||||
width: 100px !important;
|
||||
height: 100px !important;
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
}
|
||||
|
||||
.spinner-text {
|
||||
|
||||
@@ -41,23 +41,25 @@ export class CalendarYear {
|
||||
console.log('Optimizing vacations with data:', vacationData);
|
||||
this.isLoading.set(true);
|
||||
this.loadingProgress.set(0);
|
||||
// Simulate server-side calculation with a small delay
|
||||
setTimeout(async () => {
|
||||
if (this.selectedDates) {
|
||||
// Create a copy to avoid mutating the original signal data
|
||||
const remainingDays = await this.selectedDates.optimizeVacations(
|
||||
{ ...vacationData },
|
||||
this.calendarSettingsService,
|
||||
this.calendarService,
|
||||
(progress: number) => {
|
||||
this.loadingProgress.set(progress);
|
||||
},
|
||||
);
|
||||
// Update the remaining vacation days signal
|
||||
this.userInput.remainingVacationDaysSignal.set(remainingDays);
|
||||
}
|
||||
this.isLoading.set(false);
|
||||
}, 1);
|
||||
// Defer execution to allow UI to update
|
||||
queueMicrotask(() => {
|
||||
void (async () => {
|
||||
if (this.selectedDates) {
|
||||
// Create a copy to avoid mutating the original signal data
|
||||
const remainingDays = await this.selectedDates.optimizeVacations(
|
||||
{ ...vacationData },
|
||||
this.calendarSettingsService,
|
||||
this.calendarService,
|
||||
(progress: number) => {
|
||||
this.loadingProgress.set(progress);
|
||||
},
|
||||
);
|
||||
// Update the remaining vacation days signal
|
||||
this.userInput.remainingVacationDaysSignal.set(remainingDays);
|
||||
}
|
||||
this.isLoading.set(false);
|
||||
})();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -509,7 +509,7 @@ export class SelectedDates implements SelectedDateInterface {
|
||||
|
||||
// Check if adjacent (next day) - this is the best case!
|
||||
if (nextStartTime - currentEndTime === oneDayInMs) {
|
||||
totalScore += 15; // Big bonus for adjacency
|
||||
totalScore += 15; // 50% increased bonus for adjacency; adjacency is highly valued in the scoring system
|
||||
} else if (nextStartTime > currentEndTime) {
|
||||
// Penalty based on days between the two dates
|
||||
const daysBetween = Math.floor((nextStartTime - currentEndTime) / oneDayInMs) - 1;
|
||||
@@ -555,13 +555,18 @@ export class SelectedDates implements SelectedDateInterface {
|
||||
const totalDays = initialVacations.cp + initialVacations.rtt + initialVacations.other;
|
||||
let processedDays = 0;
|
||||
|
||||
// Helper function to update progress
|
||||
// Helper function to update progress, throttled to every 5%
|
||||
let lastReportedProgress = 0;
|
||||
const PROGRESS_STEP = 5; // percent
|
||||
const updateProgress = async () => {
|
||||
if (progressCallback && totalDays > 0) {
|
||||
const progress = Math.round((processedDays / totalDays) * 100);
|
||||
progressCallback(progress);
|
||||
// Allow UI to update with a microtask
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
if (progress - lastReportedProgress >= PROGRESS_STEP || progress === 100) {
|
||||
progressCallback(progress);
|
||||
lastReportedProgress = progress;
|
||||
// Allow UI to update with a microtask
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user