add time_added field to FilesBlock; update file upload logic to set timestamp and improve file display in FileBlock with additional metadata

This commit is contained in:
F4ilji
2025-07-25 12:36:17 +05:00
parent e403203e72
commit 16e7b9fe46
10 changed files with 211 additions and 66 deletions
@@ -1,66 +1,75 @@
<template>
<template v-for="file in block.data.file">
<div class="mb-4">
<a class="" :href="'/storage/'+ file.path" download type="button">
<div class="flex border rounded-lg px-4 py-2 items-center justify-between duration-300 hover:bg-gray-100">
<div class="flex items-center justify-between">
<div class="min-w-[30px] min-h-[30px] bg-[#303030] flex justify-center items-center rounded-md mr-2">
<BasicIcon :name="file.expansion" class="w-5 h-5 text-white flex-shrink-0" />
</div>
<div>{{ textLimit(file.title, 70) }}</div>
</div>
<span class="text-sm text-gray-400">{{ file.size }}</span>
</div>
</a>
</div>
</template>
<template v-for="file in block.data.file">
<div class="mb-2">
<a target="_blank" class="" :href="'/storage/' + file.path" type="button">
<div
class="flex border rounded-lg px-4 py-2 items-center justify-between duration-300 hover:bg-gray-100"
>
<div class="flex items-center justify-between">
<div class="min-w-[30px] min-h-[30px] bg-[#303030] flex justify-center items-center rounded-md mr-3">
<BasicIcon
:name="file.expansion"
class="w-5 h-5 text-white flex-shrink-0"
/>
</div>
<div class="flex flex-col">
<span class="text-sm font-medium">{{ file.title }}</span>
<div class="flex items-center gap-1">
<span v-if="file?.time_added" class="text-xs text-gray-400">Обновлено {{ new Date(file.time_added * 1000).toLocaleDateString() }},</span>
<span class="text-xs text-gray-400">{{ file.size }}</span>
</div>
</div>
</div>
</div>
</a>
</div>
</template>
</template>
<script>
import slugify from "slugify";
import BasicIcon from "@/componentss/ui/icons/BasicIcon.vue";
export default {
name: "FileBlock",
components: {BasicIcon },
data() {
return {
toggler: false,
domainPath: null,
}
},
methods: {
generateSlug: function (text) {
return slugify(text, {
lower: true,
strict: true,
locale: 'ru'
});
},
textLimit(text, symbols) {
if (text.length > symbols) {
let LimitedText;
LimitedText = text.substring(0, symbols);
return LimitedText + "...";
}
return text;
},
},
mounted() {
this.domainPath = window.location.origin;
},
props: {
block: {
type: Object,
},
},
}
name: "FileBlock",
components: { BasicIcon },
data() {
return {
toggler: false,
domainPath: null,
};
},
methods: {
generateSlug: function (text) {
return slugify(text, {
lower: true,
strict: true,
locale: "ru",
});
},
textLimit(text, symbols) {
if (text.length > symbols) {
let LimitedText;
LimitedText = text.substring(0, symbols);
return LimitedText + "...";
}
return text;
},
},
mounted() {
this.domainPath = window.location.origin;
},
props: {
block: {
type: Object,
},
},
};
</script>
<style>
</style>
<style scoped>
.mask-fade {
mask-image: linear-gradient(to right, black 90%, transparent 100%);
-webkit-mask-image: linear-gradient(to right, black 90%, transparent 100%);
}
</style>