Skip to content

Commit 604052a

Browse files
committed
retrieve key label from offliner definition for task
1 parent e276db7 commit 604052a

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

ui/src/stores/main.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ export type TaskData = {
7272
downloadLink: string
7373
progress: number
7474
rank: number | undefined
75+
offlinerDefinitionVersion: string
7576
}
7677

7778
export type BlacklistEntry = {
@@ -133,6 +134,7 @@ export const useMainStore = defineStore('main', {
133134
this.taskData = (
134135
await axios.get<TaskData>(this.config.zimit_ui_api + '/requests/' + this.taskId)
135136
).data
137+
await this.loadOfflinerDefinitionVersion(this.taskData.offlinerDefinitionVersion)
136138
this.taskNotFound = false
137139
} catch (error) {
138140
this.handleError(this.t('requestStatus.errorRefreshing'), error)
@@ -202,6 +204,25 @@ export const useMainStore = defineStore('main', {
202204
this.offlinerNotFound = true
203205
}
204206
},
207+
async loadOfflinerDefinitionVersion(version: string) {
208+
if (version == this.currentOfflinerDefinitionVersion && this.offlinerDefinition) {
209+
return
210+
}
211+
try {
212+
const offlinerDefinition = (
213+
await axios.get<OfflinerDefinition>(
214+
this.config.zimfarm_api + '/offliners/zimit/' + version
215+
)
216+
).data
217+
this.offlinerDefinition = offlinerDefinition
218+
this.offlinerNotFound = false
219+
this.currentOfflinerDefinitionVersion = version
220+
} catch (error) {
221+
this.handleError(this.t('newRequest.errorFetchingDefinition'), error)
222+
this.offlinerNotFound = true
223+
this.currentOfflinerDefinitionVersion = undefined
224+
}
225+
},
205226
async getTrackerStatus() {
206227
try {
207228
const response = (

ui/src/views/RequestStatus.vue

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<script setup lang="ts">
2-
import { inject, onMounted, onBeforeUnmount, watch } from 'vue'
2+
import { inject, onBeforeUnmount, onMounted, watch } from 'vue'
33
import type { Config } from '../config'
44
import constants from '../constants'
5+
import type { OfflinerDefinition } from '../stores/main'
56
67
import { useRoute } from 'vue-router'
78
const route = useRoute()
@@ -13,6 +14,11 @@ const config = inject<Config>(constants.config)
1314
1415
let refreshInterval: ReturnType<typeof setInterval> | undefined
1516
17+
const getKeyLabel = (key: string, offlinerDefinition: OfflinerDefinition) => {
18+
const flag = offlinerDefinition.flags.find((flag) => flag.key == key || flag.data_key == key)
19+
return flag?.label
20+
}
21+
1622
onMounted(() => {
1723
Promise.all([mainStore.getTrackerStatus(), mainStore.loadTaskId(route.params.taskId)])
1824
@@ -85,7 +91,7 @@ watch(
8591
<p>{{ $t('requestStatus.requestRecorded') }}</p>
8692
<i18n-t v-if="mainStore.taskData.rank" keypath="requestStatus.rankMessage" tag="strong">
8793
<template #task_rank>
88-
{{ mainStore.taskData.rank + 1}}
94+
{{ mainStore.taskData.rank + 1 }}
8995
</template>
9096
</i18n-t>
9197
<p v-if="mainStore.taskData.hasEmail">{{ $t('requestStatus.bookmarkUrl') }}</p>
@@ -168,12 +174,13 @@ watch(
168174
<tbody>
169175
<tr
170176
v-for="(flag, index) in mainStore.taskData.flags.filter(
171-
(flag) => config?.task_status_hidden_flags.indexOf(flag.name) == -1
177+
(flag) =>
178+
config?.task_status_hidden_flags.indexOf(flag.name) == -1 && flag.value !== null
172179
)"
173180
:key="flag.name"
174181
:class="{ 'striped-row': index % 2 === 0 }"
175182
>
176-
<th>{{ flag.name }}</th>
183+
<th>{{ getKeyLabel(flag.name, mainStore.offlinerDefinition!) }}</th>
177184
<td>{{ flag.value }}</td>
178185
</tr>
179186
</tbody>

0 commit comments

Comments
 (0)