Newer
Older
import BootstrapModal from "@/components/modals/BootstrapModal.vue";
import { computed, onMounted, watch, reactive } from "vue";
import { useS3ObjectStore } from "@/stores/s3objects";
const objectRepository = useS3ObjectStore();
const props = defineProps<{
modalID: string;
objectKey: string | undefined;
bucket: string;
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const detailState = reactive<{
loading: boolean;
error: boolean;
}>({
loading: true,
error: false,
});
const metaIdentifier = computed<string>(() => {
return props.bucket + "/" + props.objectKey;
});
watch(props, (newProps) => {
detailState.loading = true;
if (newProps.objectKey) {
fetchMetaInfo(newProps.bucket, newProps.objectKey);
}
});
function fetchMetaInfo(bucket: string, key: string) {
detailState.loading = true;
detailState.error = false;
objectRepository
.fetchS3ObjectMeta(bucket, key, () => {
detailState.loading = false;
})
.catch(() => {
detailState.error = true;
});
}
onMounted(() => {
if (props.objectKey) {
fetchMetaInfo(props.bucket, props.objectKey);
}
});
modal-label="Object Detail Modal"
<h4>File Details</h4>
</template>
<template v-slot:body>
<div class="container-fluid">
<table class="table table-hover table-sm table-borderless">
<tbody>
<tr>
<th scope="row" class="col-4">Bucket</th>
<td class="col-8">{{ props.bucket }}</td>
<td>{{ props.objectKey }}</td>
<th scope="row">Size</th>
<td v-if="detailState.error">N/A</td>
<td v-else-if="detailState.loading" class="placeholder-glow">
<span class="placeholder col-2"></span>
</td>
<td v-else>
filesize(
objectRepository.objectMetaMapping[metaIdentifier]
.ContentLength ?? 0,
{
base: 2,
standard: "jedec",
},
)
<td v-if="detailState.error">N/A</td>
<td v-else-if="detailState.loading" class="placeholder-glow">
<span class="placeholder col-6"></span>
</td>
<td v-else>
dayjs(
objectRepository.objectMetaMapping[metaIdentifier]
.LastModified,
).format("YYYY-MM-DD HH:mm:ss")
<th scope="row">Content Type</th>
<td v-if="detailState.error">N/A</td>
<td v-else-if="detailState.loading" class="placeholder-glow">
<span class="placeholder col-5"></span>
</td>
<td v-else>
{{
objectRepository.objectMetaMapping[metaIdentifier].ContentType
}}
</td>
</tr>
<tr>
<th scope="row">ETag</th>
<td v-if="detailState.error">N/A</td>
<td v-else-if="detailState.loading" class="placeholder-glow">
<span class="placeholder col-10"></span>
</td>
<td v-else>
{{ objectRepository.objectMetaMapping[metaIdentifier].ETag }}
</td>
</tr>
</tbody>
</table>
</div>
</template>
<template v-slot:footer>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">
Close
</button>
</template>
</bootstrap-modal>
</template>
<style scoped>
th {
font-weight: bold;
text-align: end;
}
</style>