|
|
@ -1,4 +1,4 @@
|
|
|
|
import {ChangeDetectionStrategy, ChangeDetectorRef, Component} from "@angular/core";
|
|
|
|
import {ChangeDetectionStrategy, ChangeDetectorRef, Component, OnDestroy, OnInit} from "@angular/core";
|
|
|
|
import {JobService} from "../../../../services/job/job.service";
|
|
|
|
import {JobService} from "../../../../services/job/job.service";
|
|
|
|
import {JobType} from "../../../../../api/api-types/job";
|
|
|
|
import {JobType} from "../../../../../api/api-types/job";
|
|
|
|
import {MatDialog} from "@angular/material/dialog";
|
|
|
|
import {MatDialog} from "@angular/material/dialog";
|
|
|
@ -13,12 +13,12 @@ import {BehaviorSubject} from "rxjs";
|
|
|
|
styleUrls: ["./repository-maintenance.component.scss"],
|
|
|
|
styleUrls: ["./repository-maintenance.component.scss"],
|
|
|
|
changeDetection: ChangeDetectionStrategy.OnPush
|
|
|
|
changeDetection: ChangeDetectionStrategy.OnPush
|
|
|
|
})
|
|
|
|
})
|
|
|
|
export class RepositoryMaintenanceComponent {
|
|
|
|
export class RepositoryMaintenanceComponent implements OnInit, OnDestroy {
|
|
|
|
|
|
|
|
|
|
|
|
public jobState: { [Property in JobType]?: boolean } = {
|
|
|
|
public jobState: { [Property in JobType]?: boolean } = {
|
|
|
|
CalculateSizes: false,
|
|
|
|
CalculateSizes: false,
|
|
|
|
GenerateThumbnails: false,
|
|
|
|
GenerateThumbnails: false,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
private jobStatusInterval: any;
|
|
|
|
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
constructor(
|
|
|
|
private changeDetector: ChangeDetectorRef,
|
|
|
|
private changeDetector: ChangeDetectorRef,
|
|
|
@ -28,14 +28,23 @@ export class RepositoryMaintenanceComponent {
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ngOnDestroy(): void {
|
|
|
|
|
|
|
|
clearInterval(this.jobStatusInterval);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public async ngOnInit() {
|
|
|
|
|
|
|
|
await this.updateJobStatus();
|
|
|
|
|
|
|
|
this.jobStatusInterval = setInterval(() => this.updateJobStatus(), 10000);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async runJob(jobType: JobType, runAsync: boolean) {
|
|
|
|
public async runJob(jobType: JobType, runAsync: boolean) {
|
|
|
|
if (runAsync) {
|
|
|
|
if (runAsync) {
|
|
|
|
this.jobState[jobType] = true;
|
|
|
|
this.jobState[jobType] = true;
|
|
|
|
this.jobService.runJob(jobType).then(() => this.delay(1000)).catch(this.logger.error).finally(() => {
|
|
|
|
this.jobService.runJob(jobType).then(() => this.delay(1000)).catch(this.logger.error).finally(() => {
|
|
|
|
this.jobState[jobType] = false;
|
|
|
|
this.jobState[jobType] = false;
|
|
|
|
this.changeDetector.detectChanges();
|
|
|
|
this.changeDetector.markForCheck();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
this.changeDetector.detectChanges();
|
|
|
|
this.changeDetector.markForCheck();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
const dialog = this.dialog.open<BusyDialogComponent, BusyDialogData>(BusyDialogComponent, {
|
|
|
|
const dialog = this.dialog.open<BusyDialogComponent, BusyDialogData>(BusyDialogComponent, {
|
|
|
|
disableClose: true,
|
|
|
|
disableClose: true,
|
|
|
@ -48,13 +57,13 @@ export class RepositoryMaintenanceComponent {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
this.changeDetector.detectChanges();
|
|
|
|
this.changeDetector.markForCheck();
|
|
|
|
await this.jobService.runJob(jobType);
|
|
|
|
await this.jobService.runJob(jobType);
|
|
|
|
} catch (err: any) {
|
|
|
|
} catch (err: any) {
|
|
|
|
this.logger.error(err);
|
|
|
|
this.logger.error(err);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
dialog.close();
|
|
|
|
dialog.close();
|
|
|
|
this.changeDetector.detectChanges();
|
|
|
|
this.changeDetector.markForCheck();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -65,4 +74,12 @@ export class RepositoryMaintenanceComponent {
|
|
|
|
ms
|
|
|
|
ms
|
|
|
|
));
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private async updateJobStatus() {
|
|
|
|
|
|
|
|
const indexedTypes: JobType[] = ["CalculateSizes", "GenerateThumbnails"];
|
|
|
|
|
|
|
|
for (const jobType of indexedTypes) {
|
|
|
|
|
|
|
|
this.jobState[jobType] = await this.jobService.isJobRunning(jobType);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
this.changeDetector.markForCheck();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|