@@ -47,6 +47,12 @@ Component for handling display/download of job results.
4747 <template v-else-if =" jobStatus == ' running' " >
4848 The calculation is running and will be ready soon.
4949 </template >
50+ <template v-else-if =" jobStatus == ' error' " >
51+ An error occured while processing the calculation.
52+ </template >
53+ <template v-else-if =" jobStatus == ' complete' " >
54+ Calculation is complete. Results are loading.
55+ </template >
5056 <template v-else >
5157 Calculation has not been submitted.
5258 </template >
@@ -88,20 +94,37 @@ export default class JobResults extends Vue {
8894 this .initializeResults ();
8995 }
9096 } else {
91- this .awaitCompletion ();
97+ this .pollUntilComplete ();
9298 }
9399 }
94100 deactivated() {
95101 clearTimeout (this .timeout );
96102 }
97- awaitCompletion() {
98- // emit an event to fetch the job and check the new status
99- this .$emit (" reload-job" );
100- if (this .jobStatus == " complete" ) {
103+ async pollUntilComplete() {
104+ const token = await this .$auth .getTokenSilently ();
105+ this .awaitCompletion (token );
106+ }
107+ async awaitCompletion(token : string ) {
108+ // fetch the job status until we find something meaningful to report.
109+ const statusRequest = await Jobs .jobStatus (
110+ token ,
111+ this .job .object_id
112+ ).then (response => response .json ());
113+ const jobStatus = statusRequest .status ;
114+ if (jobStatus != this .jobStatus ) {
115+ // Emit an event to reload the job when the status has changed so that
116+ // JobHandler can react accordingly.
117+ this .$emit (" reload-job" );
118+ }
119+ if (jobStatus == " complete" ) {
120+ // load results when complete
101121 this .initializeResults ();
122+ } else if (jobStatus == " error" ) {
123+ // discontinue polling
124+ return ;
102125 } else {
103- // If the job was not complete, check for
104- this .timeout = setTimeout (this .awaitCompletion , 1000 );
126+ // Wait 1 second and poll for status update
127+ this .timeout = setTimeout (this .awaitCompletion . bind ( this , token ) , 1000 );
105128 }
106129 }
107130 initializeResults() {
@@ -116,7 +139,8 @@ export default class JobResults extends Vue {
116139 selected: " " ,
117140 timeseriesData: null ,
118141 summaryData: {},
119- loadedSummaryData: []
142+ loadedSummaryData: [],
143+ errors: null
120144 };
121145 }
122146 get labelledSummaryResults() {
0 commit comments