Skip to content

Commit ce85c70

Browse files
MMelchormario-nt
MMelchor
authored andcommitted
feat: [torrust#278] show torrent fields creation date created by encoding
Torrent details page now displays the creation date, created by and encoding fields.
1 parent de1ffdf commit ce85c70

File tree

5 files changed

+151
-0
lines changed

5 files changed

+151
-0
lines changed
+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<template>
2+
<div id="torrent-created-by" class="flex flex-col gap-6">
3+
<div class="flex flex-row items-center justify-between">
4+
<h2 class="mr-1 text-2xl font-medium text-left text-neutral-content/50">
5+
Created by
6+
</h2>
7+
<button
8+
class="flex flex-col items-center justify-center w-10 h-10 duration-200 bg-transparent text-base-content/50 hover:text-base-content rounded-xl"
9+
@click="collapsed = !collapsed"
10+
>
11+
<ChevronDownIcon class="w-6" :class="{ 'rotate-90': collapsed }" />
12+
</button>
13+
</div>
14+
<template v-if="!collapsed">
15+
<div class="flex flex-col w-full h-full p-6 grow bg-base-100 rounded-2xl">
16+
<template v-if="torrent.created_by">
17+
<Markdown :source="torrent.created_by" />
18+
</template>
19+
<template v-else>
20+
<span class="italic text-neutral-content">No created by field provided.</span>
21+
</template>
22+
</div>
23+
</template>
24+
</div>
25+
</template>
26+
27+
<script setup lang="ts">
28+
import { ChevronDownIcon } from "@heroicons/vue/24/solid";
29+
import { TorrentResponse } from "torrust-index-types-lib";
30+
import { PropType } from "vue";
31+
import { ref } from "#imports";
32+
import Markdown from "~/components/Markdown.vue";
33+
34+
const collapsed = ref(false);
35+
36+
const props = defineProps({
37+
torrent: {
38+
type: Object as PropType<TorrentResponse>,
39+
required: true
40+
}
41+
});
42+
</script>
43+
44+
<style scoped>
45+
46+
</style>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<template>
2+
<div id="torrent-creation-date" class="flex flex-col gap-6">
3+
<div class="flex flex-row items-center justify-between">
4+
<h2 class="mr-1 text-2xl font-medium text-left text-neutral-content/50">
5+
Creation Date
6+
</h2>
7+
<button
8+
class="flex flex-col items-center justify-center w-10 h-10 duration-200 bg-transparent text-base-content/50 hover:text-base-content rounded-xl"
9+
@click="collapsed = !collapsed"
10+
>
11+
<ChevronDownIcon class="w-6" :class="{ 'rotate-90': collapsed }" />
12+
</button>
13+
</div>
14+
<template v-if="!collapsed">
15+
<div class="flex flex-col w-full h-full p-6 grow bg-base-100 rounded-2xl">
16+
<template v-if="torrent.creation_date">
17+
<!--<Markdown :source="torrent.name" />-->
18+
{{ convertedDate }}
19+
</template>
20+
<template v-else>
21+
<span class="italic text-neutral-content">No creation date provided.</span>
22+
</template>
23+
</div>
24+
</template>
25+
</div>
26+
</template>
27+
28+
<script setup lang="ts">
29+
import { ChevronDownIcon } from "@heroicons/vue/24/solid";
30+
import { TorrentResponse } from "torrust-index-types-lib";
31+
import { PropType } from "vue";
32+
import { ref } from "#imports";
33+
import Markdown from "~/components/Markdown.vue";
34+
import { epochToUtc } from "~/src/helpers/DateConverter";
35+
36+
const collapsed = ref(false);
37+
38+
const props = defineProps({
39+
torrent: {
40+
type: Object as PropType<TorrentResponse>,
41+
required: true
42+
}
43+
});
44+
45+
// Takes the date in milliseconds/Epoch Time and converts it to human readable format
46+
const convertedDate = epochToUtc(props.torrent.creation_date);
47+
48+
</script>
49+
50+
<style scoped>
51+
52+
</style>

components/torrent/TorrentDetails.vue

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
<div v-if="torrent" class="flex flex-col flex-auto w-full gap-6">
1818
<TorrentDescriptionTab :torrent="torrent" @updated="reloadTorrent" />
1919
<TorrentCommentTab :torrent="torrent" @updated="reloadTorrent" />
20+
<TorrentCreationDateTab :torrent="torrent" @updated="reloadTorrent" />
21+
<TorrentCreatedByTab :torrent="torrent" @updated="reloadTorrent" />
22+
<TorrentEncodingTab :torrent="torrent" @updated="reloadTorrent" />
2023
<TorrentFilesTab :torrent="torrent" @updated="reloadTorrent" />
2124
<TorrentTrackersTab :torrent="torrent" @updated="reloadTorrent" />
2225
</div>
+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<template>
2+
<div id="torrent-encoding" class="flex flex-col gap-6">
3+
<div class="flex flex-row items-center justify-between">
4+
<h2 class="mr-1 text-2xl font-medium text-left text-neutral-content/50">
5+
Encoding
6+
</h2>
7+
<button
8+
class="flex flex-col items-center justify-center w-10 h-10 duration-200 bg-transparent text-base-content/50 hover:text-base-content rounded-xl"
9+
@click="collapsed = !collapsed"
10+
>
11+
<ChevronDownIcon class="w-6" :class="{ 'rotate-90': collapsed }" />
12+
</button>
13+
</div>
14+
<template v-if="!collapsed">
15+
<div class="flex flex-col w-full h-full p-6 grow bg-base-100 rounded-2xl">
16+
<template v-if="torrent.encoding">
17+
<Markdown :source="torrent.encoding" />
18+
</template>
19+
<template v-else>
20+
<span class="italic text-neutral-content">No encoding provided.</span>
21+
</template>
22+
</div>
23+
</template>
24+
</div>
25+
</template>
26+
27+
<script setup lang="ts">
28+
import { ChevronDownIcon } from "@heroicons/vue/24/solid";
29+
import { TorrentResponse } from "torrust-index-types-lib";
30+
import { PropType } from "vue";
31+
import { ref } from "#imports";
32+
import Markdown from "~/components/Markdown.vue";
33+
34+
const collapsed = ref(false);
35+
36+
const props = defineProps({
37+
torrent: {
38+
type: Object as PropType<TorrentResponse>,
39+
required: true
40+
}
41+
});
42+
</script>
43+
44+
<style scoped>
45+
46+
</style>

src/helpers/DateConverter.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export function epochToUtc (date: number) {
2+
const convertedDate = new Date(date * 1000);
3+
return convertedDate.toDateString();
4+
}

0 commit comments

Comments
 (0)