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
35import { Hyp3ApiService , ScenesService , Hyp3JobStatusService } from '@services' ;
46import {
@@ -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 } ,
0 commit comments