Skip to content

Commit cb7bff9

Browse files
authored
Merge pull request #94 from LCOGT/fix/show-operation-output
More Readable Status handling
2 parents d335def + cff6bb4 commit cb7bff9

File tree

1 file changed

+64
-20
lines changed

1 file changed

+64
-20
lines changed

src/components/DataSession/OperationPipeline.vue

Lines changed: 64 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,35 @@ function operationBtnColor(index) {
5656
async function pollOperationCompletion(operationID) {
5757
const url = store.datalabApiBaseUrl + 'datasessions/' + props.session_id + '/operations/' + operationID + '/'
5858
59-
const updateOperationPercentages = (response) => {
60-
if (response && response.percent_completion !== undefined && response.status != 'COMPLETED') {
61-
operationPercentages.value[operationID] = response.percent_completion * DEC_TO_PERCENT
62-
} else {
63-
operationPercentages.value[operationID] = COMPLETE_PERCENT
64-
emit('operationCompleted', response)
65-
if (operationID in operationPollingTimers) {
66-
clearInterval(operationPollingTimers[operationID])
67-
setTimeout(clearPollingData(operationID), POLL_WAIT_TIME)
59+
const updateOperationStatus = (response) => {
60+
if(response){
61+
const operationStatus = response.status
62+
const percentCompletion = response.percent_completion
63+
64+
switch(operationStatus){
65+
case 'PENDING':
66+
break
67+
case 'IN_PROGRESS':
68+
operationPercentages.value[operationID] = percentCompletion * DEC_TO_PERCENT
69+
break
70+
case 'COMPLETED':
71+
operationPercentages.value[operationID] = COMPLETE_PERCENT
72+
emit('operationCompleted', response)
73+
if (operationID in operationPollingTimers) {
74+
clearInterval(operationPollingTimers[operationID])
75+
setTimeout(clearPollingData(operationID), POLL_WAIT_TIME)
76+
}
77+
break
78+
default:
79+
console.error('Unknown Operation Status:', operationStatus)
6880
}
6981
}
82+
else{
83+
console.error('No response on status for operation:', operationID)
84+
}
7085
}
7186
72-
await fetchApiCall({ url: url, method: 'GET', successCallback: updateOperationPercentages, failCallback: handleError })
87+
await fetchApiCall({ url: url, method: 'GET', successCallback: updateOperationStatus, failCallback: handleError })
7388
}
7489
7590
function clearPollingData(operationID) {
@@ -118,20 +133,44 @@ onBeforeUnmount(() => {
118133
<h3 class="operations">
119134
OPERATIONS
120135
</h3>
121-
<v-divider class="mb-6" />
122-
<v-row v-for="(operation, index) in operations" :key="operation.id" align="center" justify="center" class="mb-2">
123-
<v-btn :class="operationBtnColor(index)" variant="outlined" class="operation_button" @click="selectOperation(index)">
136+
<v-row
137+
v-for="(operation, index) in operations"
138+
:key="operation.id"
139+
align="center"
140+
justify="center"
141+
class="operation mb-2"
142+
>
143+
<v-btn
144+
:class="operationBtnColor(index)"
145+
variant="outlined"
146+
class="operation_button"
147+
@click="selectOperation(index)"
148+
>
124149
{{ index }}: {{ operation.name }}
125150
</v-btn>
126-
<v-progress-linear v-if="operationPercentages[operation.id] !== undefined" class="operation_completion"
127-
:model-value="operationPercentages[operation.id]" :height="5" />
151+
<v-progress-linear
152+
v-if="operationPercentages[operation.id] !== undefined"
153+
class="operation_completion"
154+
:model-value="operationPercentages[operation.id]"
155+
:height="5"
156+
/>
128157
</v-row>
129-
<v-divider class="mb-4 mt-4" />
130-
<v-btn variant="flat" class="addop_button">
158+
<v-btn
159+
variant="flat"
160+
class="addop_button"
161+
>
131162
Add Operation
132-
<v-dialog v-model="showWizardDialog" activator="parent" fullscreen transition="dialog-bottom-transition">
133-
<operation-wizard :images="images" @close-wizard="showWizardDialog = false"
134-
@add-operation="emit('addOperation', $event); showWizardDialog = false;" />
163+
<v-dialog
164+
v-model="showWizardDialog"
165+
activator="parent"
166+
fullscreen
167+
transition="dialog-bottom-transition"
168+
>
169+
<operation-wizard
170+
:images="images"
171+
@close-wizard="showWizardDialog = false"
172+
@add-operation="emit('addOperation', $event); showWizardDialog = false;"
173+
/>
135174
</v-dialog>
136175
</v-btn>
137176
</template>
@@ -143,6 +182,10 @@ onBeforeUnmount(() => {
143182
font-size: 2rem;
144183
}
145184
185+
.operation{
186+
margin-top: 1rem;
187+
}
188+
146189
.addop_button {
147190
width: 16rem;
148191
height: 4rem;
@@ -151,6 +194,7 @@ onBeforeUnmount(() => {
151194
background-color: var(--light-blue);
152195
font-weight: 700;
153196
color: white;
197+
margin-top: 1rem;
154198
}
155199
156200
.operation_button {

0 commit comments

Comments
 (0)