@@ -47,6 +47,12 @@ Component for handling display/download of job results.
47
47
<template v-else-if =" jobStatus == ' running' " >
48
48
The calculation is running and will be ready soon.
49
49
</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 >
50
56
<template v-else >
51
57
Calculation has not been submitted.
52
58
</template >
@@ -88,20 +94,37 @@ export default class JobResults extends Vue {
88
94
this .initializeResults ();
89
95
}
90
96
} else {
91
- this .awaitCompletion ();
97
+ this .pollUntilComplete ();
92
98
}
93
99
}
94
100
deactivated() {
95
101
clearTimeout (this .timeout );
96
102
}
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
101
121
this .initializeResults ();
122
+ } else if (jobStatus == " error" ) {
123
+ // discontinue polling
124
+ return ;
102
125
} 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 );
105
128
}
106
129
}
107
130
initializeResults() {
@@ -116,7 +139,8 @@ export default class JobResults extends Vue {
116
139
selected: " " ,
117
140
timeseriesData: null ,
118
141
summaryData: {},
119
- loadedSummaryData: []
142
+ loadedSummaryData: [],
143
+ errors: null
120
144
};
121
145
}
122
146
get labelledSummaryResults() {
0 commit comments