Skip to content

Commit 8db189d

Browse files
authored
Merge pull request #2532 from asfadmin/will/resubmit
Resubmit hyp3 project jobs
2 parents 49aacf1 + 50c6588 commit 8db189d

6 files changed

Lines changed: 64 additions & 51 deletions

File tree

src/app/components/results-menu/scene-files/scene-files.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
@if (!showUnzippedProductScreen) {
1515
<div>
1616
<mat-list class="products-list">
17-
@for (product of products; track product) {
17+
@for (product of products; track product.id) {
1818
<app-scene-file
1919
(toggle)="onToggleQueueProduct(product)"
2020
(unzip)="onOpenUnzipProduct($event)"
@@ -45,7 +45,7 @@ <h4>{{ 'RELATED_DATA' | translate }}</h4>
4545
</mat-list-item>
4646
}
4747

48-
@for (product of subqueryProducts; track product) {
48+
@for (product of subqueryProducts; track product.id) {
4949
@if (dynamicQueryLoaded()) {
5050
<app-scene-file
5151
(toggle)="onToggleQueueProduct(product)"

src/app/components/results-menu/scenes-list/scene/scene-controls/scene-controls.component.html

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,7 @@
6363

6464
@if (!isDownloadable(scene)) {
6565
<div class="scene-control ml-2">
66-
<app-hyp3-job-status-badge
67-
[job]="scene.metadata.job"
68-
[isFileDetails]="false"
69-
>
66+
<app-hyp3-job-status-badge [job]="scene.metadata.job">
7067
</app-hyp3-job-status-badge>
7168
</div>
7269
}
Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,48 @@
1-
@if (isExpired(job) && !isFileDetails) {
1+
@if (isExpired(job())) {
22
<mat-chip
33
class="clickable"
44
[matMenuTriggerFor]="resubmitJobMenu"
55
color="primary"
66
>{{ 'EXPIRED' | translate }}...
77
</mat-chip>
8-
} @else if (isFailed(job) && !isFileDetails) {
8+
} @else if (isFailed(job())) {
99
<mat-chip
1010
class="clickable"
1111
[matMenuTriggerFor]="resubmitJobMenu"
1212
color="primary"
1313
>{{ 'FAILED' | translate }}...
1414
</mat-chip>
15-
} @else if (isExpired(job) && isFileDetails) {
16-
<mat-chip color="primary">{{ 'EXPIRED' | translate }}</mat-chip>
17-
} @else if (isPending(job)) {
15+
} @else if (isPending(job())) {
1816
<mat-chip color="secondary">{{ 'PENDING' | translate }}</mat-chip>
19-
} @else if (isFailed(job) && isFileDetails) {
20-
<mat-chip color="accent">{{ 'FAILED' | translate }}</mat-chip>
21-
} @else if (isRunning(job)) {
17+
} @else if (isRunning(job())) {
2218
<mat-chip color="secondary">{{ 'RUNNING' | translate }}</mat-chip>
2319
}
2420

2521
<mat-menu #resubmitJobMenu="matMenu">
2622
<button
27-
(click)="onReviewExpiredJob()"
23+
(click)="onSubmitExpiredJob()"
2824
[disabled]="remaining < 1"
2925
mat-menu-item
3026
>
3127
{{ 'RESUBMIT_JOB' | translate }}...
3228
</button>
3329

34-
<button (click)="onReviewExpiredJobs()" mat-menu-item>
35-
{{ 'REQUEUE_PROJECT' | translate }} <b>({{ job.name }})</b>...
36-
</button>
30+
@if (expiredJobs.length > 0 || failedJobs.length > 0) {
31+
<button mat-menu-item [matMenuTriggerFor]="requeueProjectMenu">
32+
{{ 'REQUEUE_PROJECT' | translate }} <b>({{ job().name }})</b>...
33+
</button>
34+
}
35+
</mat-menu>
36+
37+
<mat-menu #requeueProjectMenu="matMenu">
38+
@if (expiredJobs.length > 0) {
39+
<button (click)="onQueueJobs(expiredJobs)" mat-menu-item>
40+
{{ 'REQUEUE_EXPIRED' | translate }} ({{ expiredJobs.length }} jobs)
41+
</button>
42+
}
43+
@if (failedJobs.length > 0) {
44+
<button (click)="onQueueJobs(failedJobs)" mat-menu-item>
45+
{{ 'REQUEUE_FAILED' | translate }} ({{ failedJobs.length }} jobs)
46+
</button>
47+
}
3748
</mat-menu>

src/app/components/shared/hyp3-job-status-badge/hyp3-job-status-badge.component.ts

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import { Component, OnInit, Input, inject } from '@angular/core';
1+
import { Component, OnInit, input, inject } from '@angular/core';
2+
import { toObservable } from '@angular/core/rxjs-interop';
3+
import { combineLatest } from 'rxjs';
24

35
import { Hyp3ApiService, ScenesService, Hyp3JobStatusService } from '@services';
46
import {
@@ -32,21 +34,19 @@ export class Hyp3JobStatusBadgeComponent implements OnInit {
3234
private dialog = inject(MatDialog);
3335
private store$ = inject<Store<AppState>>(Store);
3436

35-
@Input() job: Hyp3Job;
36-
@Input() isFileDetails = true;
37+
public job = input.required<Hyp3Job>();
38+
private job$ = toObservable(this.job);
39+
40+
public projectJobs: models.Hyp3Job[] = [];
41+
public expiredJobs: models.Hyp3Job[] = [];
42+
public failedJobs: models.Hyp3Job[] = [];
3743

38-
private jobs: models.Hyp3Job[];
3944
private costs: models.Hyp3Costs;
4045
private processingOptions: Hyp3ProcessingOptions;
41-
private projectName = '';
4246
private validateOnly = false;
4347
public remaining = 0;
4448

4549
ngOnInit(): void {
46-
this.store$
47-
.select(hyp3Store.getProcessingProjectName)
48-
.subscribe((projectName) => (this.projectName = projectName));
49-
5050
this.store$
5151
.select(hyp3Store.getProcessingOptions)
5252
.subscribe((options) => (this.processingOptions = options));
@@ -63,9 +63,18 @@ export class Hyp3JobStatusBadgeComponent implements OnInit {
6363
this.remaining = user.quota.remaining;
6464
});
6565

66-
this.scenesService.scenes$.subscribe((scenes) => {
67-
this.jobs = scenes.map((scene) => scene.metadata.job);
68-
});
66+
combineLatest([this.scenesService.scenes$, this.job$]).subscribe(
67+
([scenes, selectedJob]) => {
68+
this.projectJobs = scenes
69+
.map((scene) => scene.metadata.job)
70+
.filter((job) => selectedJob.name && selectedJob.name === job.name);
71+
72+
this.expiredJobs = this.projectJobs.filter((job) =>
73+
this.isExpired(job),
74+
);
75+
this.failedJobs = this.projectJobs.filter((job) => this.isFailed(job));
76+
},
77+
);
6978
}
7079

7180
public isExpired(job: Hyp3Job): boolean {
@@ -84,36 +93,29 @@ export class Hyp3JobStatusBadgeComponent implements OnInit {
8493
return this.hyp3JobStatus.isRunning(job);
8594
}
8695

87-
public onReviewExpiredJob() {
88-
const jobType = models.hyp3JobTypes[this.job.job_type as string];
96+
public onSubmitExpiredJob() {
97+
const jobType = models.hyp3JobTypes[this.job().job_type as string];
8998

9099
const job = {
91-
granules: this.job.scenes,
100+
granules: this.job().scenes,
92101
job_type: jobType,
93-
processingOptions: this.job.job_parameters,
102+
processingOptions: this.job().job_parameters,
94103
};
95104

96105
this.openConfirmationDialog(jobType, job);
97106
}
98107

99-
public onReviewExpiredJobs() {
108+
public onQueueJobs(jobs: Hyp3Job[]) {
100109
const job_types = hyp3JobTypes;
101110

102-
const projectJobs = this.jobs
103-
.filter(
104-
(job) =>
105-
job.name === this.job.name &&
106-
this.isExpired(job) &&
107-
!this.isFailed(job),
108-
)
109-
.map((job) => {
110-
return {
111-
granules: job.scenes,
112-
job_type: job_types[job.job_type as string],
113-
} as QueuedHyp3Job;
114-
});
115-
116-
this.store$.dispatch(new queueStore.AddJobs(projectJobs));
111+
const jobsToQueue = jobs.map((job) => {
112+
return {
113+
granules: job.scenes,
114+
job_type: job_types[job.job_type as string],
115+
} as QueuedHyp3Job;
116+
});
117+
118+
this.store$.dispatch(new queueStore.AddJobs(jobsToQueue));
117119
}
118120

119121
private openConfirmationDialog(jobType: models.Hyp3JobType, job) {
@@ -156,7 +158,6 @@ export class Hyp3JobStatusBadgeComponent implements OnInit {
156158
maxHeight: '500px',
157159
data: {
158160
jobTypesWithQueued: jobTypesWithQueued,
159-
projectName: this.projectName,
160161
processingOptions: options,
161162
validateOnly: this.validateOnly,
162163
},

src/assets/i18n/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -886,6 +886,8 @@
886886
"REQUEST_ACCESS_REJECTED": "Request for access has been rejected.",
887887
"REQUEST_ON_DEMAND_ACCESS": "Request On Demand Access",
888888
"REQUEUE_PROJECT": "Requeue project",
889+
"REQUEUE_FAILED": "Failed jobs",
890+
"REQUEUE_EXPIRED": "Expired jobs",
889891
"RESAMPLED_DEM_SRTM_OR_NED_USED_FOR_RTC_PROCESSING": "Resampled DEM (SRTM or NED) used for RTC processing.",
890892
"RESET_CHART_REFERENCE": "Reset chart reference",
891893
"RESET_TO_DEFAULT": "Reset to Default",

src/assets/i18n/es.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -886,6 +886,8 @@
886886
"REQUEST_ACCESS_REJECTED": "La solicitud de acceso ha sido rechazada.",
887887
"REQUEST_ON_DEMAND_ACCESS": "Solicitar acceso a On Demand",
888888
"REQUEUE_PROJECT": "Regresar el proyecto a la lista",
889+
"REQUEUE_FAILED": "Failed jobs",
890+
"REQUEUE_EXPIRED": "Expired jobs",
889891
"RESAMPLED_DEM_SRTM_OR_NED_USED_FOR_RTC_PROCESSING": "DEM remuestreado (SRTM o NED) utilizado para el procesamiento de RTC.",
890892
"RESET_CHART_REFERENCE": "Restablecer gráfico",
891893
"RESET_TO_DEFAULT": "Restablecer a los predeterminados",

0 commit comments

Comments
 (0)