This commit is contained in:
2025-03-13 22:08:06 +01:00
commit bab5571428
93 changed files with 4323 additions and 0 deletions
@@ -0,0 +1,126 @@
<template>
<v-card @click="show_files = !show_files">
<v-progress-linear height="20" :color="progressData.color" :model-value="progressData.value">
<!-- barre de progression -->
<v-progress-circular
v-if="!torrent.transmission_data.rateDownload && !torrent.transmission_data.rateUpload"
size="15"
indeterminate
:color="torrent.transmission_data.progress < 100 ? 'green':'red'"
/>
<v-icon
v-else
:color="torrent.transmission_data.rateDownload ? 'green':'red'"
:icon="torrent.transmission_data.rateDownload ? 'mdi-arrow-down-bold':'mdi-arrow-up-bold'"
/>
<strong style="padding-left: 5px">
{{progressData.value}}%
<strong
v-if="torrent.transmission_data.rateDownload || torrent.transmission_data.rateUpload"
>
({{torrent.transmission_data.rateDownload ? fs_speed_format(torrent.transmission_data.rateDownload):fs_speed_format(torrent.transmission_data.rateUpload)}}/s)
</strong>
</strong>
</v-progress-linear>
<v-row no-gutters>
<!-- ligne du haut -->
<v-col>
<v-card-text v-text="torrent.name"></v-card-text>
</v-col>
<v-col lg="1">
<v-card-text v-text="fs_format(torrent.size)"></v-card-text>
</v-col>
</v-row>
<v-row v-if="torrent.transmission_data.progress < 100" justify="end" no-gutters>
<!-- ligne du milieu -->
<v-col lg="2">
<v-card-text>remaining : {{fs_format(torrent.transmission_data.leftUntilDone)}}/{{progressData.eta}}</v-card-text>
</v-col>
</v-row>
<v-card-actions>
<v-btn :disabled="torrent.transmission_data.progress < 100" @click.stop="downloadClicked" color="green" :icon="torrent.count_files === 1 ? 'mdi-download':'mdi-folder-download'"/>
<v-dialog v-model="share_modal" max-width="600">
<template v-slot:activator="{props}">
<v-btn icon="mdi-share-variant" v-bind="props"/>
</template>
<TorrentShare :torrent="torrent"/>
</v-dialog>
<v-spacer/>
<v-btn @click.stop="deleteClicked" color="red" icon="mdi-delete-variant" :disabled="delete_disabled"/>
</v-card-actions>
<v-expand-transition>
<div v-if="show_files">
<v-divider />
<FileList v-if="show_files" :torrent_id="torrent.id" :is_download_finished="torrent.transmission_data.progress >= 100"/>
</div>
</v-expand-transition>
</v-card>
</template>
<script setup>
import {fs_format, fs_speed_format} from "@/plugins/utils.js";
import FileList from "@/components/torrent/FileList.vue";
import TorrentShare from "@/components/torrent/TorrentShare.vue";
</script>
<script>
import Cookies from "js-cookie";
import {toHHMMSS} from "@/plugins/utils.js";
export default {
emits: ["delete"],
props: {
torrent: {
required: true,
type: Object,
},
delete_disabled: {
required: true,
type: Boolean,
}
},
data(){
return {
show_files: false,
share_modal: false,
}
},
methods: {
async downloadClicked(){
if(this.torrent.transmission_data.progress < 100) return;
let a = document.createElement("a");
a.href = this.torrent.download_url;
a.setAttribute("download", "download");
a.click();
},
async deleteClicked(){
this.$emit("delete", this.torrent.id);
await fetch(`/api/torrents/${this.torrent.id}/`, {
method: "DELETE",
headers: {
"X-CSRFToken": Cookies.get("csrftoken"),
}
})
}
},
computed: {
progressData(){
let color = "red", value = 0, eta;
if(this.torrent.transmission_data.progress < 100){
color = "blue";
value = this.torrent.transmission_data.progress;
if(this.torrent.transmission_data.eta !== -1){
eta = toHHMMSS(this.torrent.transmission_data.eta);
}else{
eta = "-";
}
}else{
color = "green";
value = Number((this.torrent.transmission_data.uploadRatio / 5) * 100).toFixed(2)
if(value > 100) value = 100;
}
return {color, value, eta};
}
}
}
</script>