audiobookshelf/client/components/cards/ItemTaskRunningCard.vue

95 lines
2.0 KiB
Vue
Raw Normal View History

2023-03-05 12:15:36 +01:00
<template>
2023-05-27 21:51:03 +02:00
<div class="flex items-center px-1 overflow-hidden">
<div class="w-8 flex items-center justify-center">
<!-- <div class="text-lg"> -->
<span v-if="isFinished" :class="taskIconStatus" class="material-icons text-base">{{ actionIcon }}</span>
2023-03-05 12:15:36 +01:00
<widgets-loading-spinner v-else />
2023-05-27 21:51:03 +02:00
<!-- </div> -->
2023-03-05 12:15:36 +01:00
</div>
<div class="flex-grow px-2 taskRunningCardContent">
<p class="truncate text-sm">{{ title }}</p>
<p class="truncate text-xs text-gray-300">{{ description }}</p>
<p v-if="isFailed && failedMessage" class="text-xs truncate text-red-500">{{ failedMessage }}</p>
</div>
</div>
</template>
<script>
export default {
props: {
task: {
type: Object,
default: () => {}
}
},
data() {
return {}
},
computed: {
title() {
return this.task.title || 'No Title'
},
description() {
return this.task.description || ''
},
details() {
return this.task.details || 'Unknown'
},
isFinished() {
2023-05-27 21:51:03 +02:00
return !!this.task.isFinished
2023-03-05 12:15:36 +01:00
},
isFailed() {
2023-05-27 21:51:03 +02:00
return !!this.task.isFailed
},
isSuccess() {
return this.isFinished && !this.isFailed
2023-03-05 12:15:36 +01:00
},
failedMessage() {
return this.task.error || ''
},
action() {
return this.task.action || ''
},
actionIcon() {
2023-05-27 21:51:03 +02:00
if (this.isFailed) {
return 'error'
} else if (this.isSuccess) {
return 'done'
}
2023-03-05 12:15:36 +01:00
switch (this.action) {
case 'download-podcast-episode':
return 'cloud_download'
case 'encode-m4b':
return 'sync'
default:
return 'settings'
}
},
taskIconStatus() {
if (this.isFinished && this.isFailed) {
return 'text-red-500'
}
if (this.isFinished && !this.isFailed) {
return 'text-green-500'
}
return ''
}
},
2023-05-27 21:51:03 +02:00
methods: {},
2023-03-05 12:15:36 +01:00
mounted() {}
}
</script>
<style>
.taskRunningCardContent {
2023-05-27 21:51:03 +02:00
width: calc(100% - 84px);
height: 60px;
2023-03-05 12:15:36 +01:00
display: flex;
flex-direction: column;
justify-content: center;
}
</style>