Skip to content

Commit

Permalink
Add proper handling for showing scheduled tasks for unknown devices.
Browse files Browse the repository at this point in the history
  • Loading branch information
rtibbles committed Jun 1, 2023
1 parent a605c9f commit 1768bce
Showing 1 changed file with 24 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@
<!-- creating the table-->
<CoreTable>
<template #tbody>
<tbody v-if="facilitySyncTasks.length > 0">
<tbody v-if="scheduledTasks.length > 0">
<tr>
<th>{{ coreString('deviceNameLabel') }}</th>
<th>{{ $tr('Schedule') }}</th>
<th>{{ coreString('statusLabel') }}</th>
<th></th>
</tr>
<tr
v-for="task in facilitySyncTasks"
v-for="task in scheduledTasks"
:key="task.id"
>
<td>
<span>{{ devicesById[getDeviceId(task)].device_name }}<br>
<span>{{ task.deviceName }}<br>
{{ task.extra_metadata.baseurl }}
</span>
</td>
Expand All @@ -63,21 +63,11 @@
</td>

<td>
<span
v-if="
devicesById[task.extra_metadata.device_id] &&
devicesById[task.extra_metadata.device_id].available
"
>
<span v-if="task.deviceAvailable">
<KIcon icon="onDevice" />
<span>{{ $tr('connected') }}</span>
</span>
<span
v-else-if="
devicesById[task.extra_metadata.device_id] &&
!devicesById[task.extra_metadata.device_id].isKDP
"
>
<span v-else-if="!task.isKDP">
<KIcon icon="disconnected" />
<span>{{ $tr('disconnected') }}</span>
</span>
Expand Down Expand Up @@ -165,7 +155,6 @@
// eslint-disable-next-line kolibri/vue-no-undefined-string-uses
device_name: kdpNameTranslator.$tr('syncToKDP'),
base_url: '',
isKDP: true,
},
}
);
Expand Down Expand Up @@ -196,6 +185,25 @@
facilitySyncTasks: [],
};
},
computed: {
scheduledTasks() {
return this.facilitySyncTasks.map(task => {
const deviceName = this.devicesById[this.getDeviceId(task)]
? this.devicesById[this.getDeviceId(task)].device_name
: task.extra_metadata.device_name;
const deviceAvailable =
this.devicesById[task.extra_metadata.device_id] &&
this.devicesById[task.extra_metadata.device_id].available;
const isKDP = task.type === TaskTypes.SYNCDATAPORTAL;
return {
...task,
deviceName,
deviceAvailable,
isKDP,
};
});
},
},
beforeMount() {
this.pollFacilityTasks();
this.fetchFacility();
Expand Down

0 comments on commit 1768bce

Please sign in to comment.