@antelopejs/dms-media 0.3.1 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -180
- package/dist/db/models/mediaAssets.model.d.ts +1 -0
- package/dist/db/models/mediaEvents.model.d.ts +1 -0
- package/dist/db/models/mediaFavorites.model.d.ts +1 -0
- package/dist/db/models/mediaFolders.model.d.ts +1 -0
- package/dist/db/models/mediaUploads.model.d.ts +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/dist/test/antelope.test.js +5 -5
- package/dist/test/helpers/pages.js +3 -2
- package/dist/test/helpers/pages.js.map +1 -1
- package/dist/test/integration/frontend-module.test.d.ts +1 -0
- package/dist/test/integration/frontend-module.test.js +13 -0
- package/dist/test/integration/frontend-module.test.js.map +1 -0
- package/frontend-vue/app/components/FileProperties.vue +9 -3
- package/frontend-vue/app/components/FirstRun.vue +1 -1
- package/frontend-vue/app/components/ImageEditor.vue +43 -26
- package/frontend-vue/app/components/PresetCards.vue +3 -11
- package/frontend-vue/app/components/RecentFiles.vue +6 -14
- package/frontend-vue/app/components/UploadQueue.vue +1 -1
- package/frontend-vue/app/components/UploadStrip.vue +1 -1
- package/frontend-vue/app/components/dialogs/DestinationDialog.vue +1 -2
- package/frontend-vue/app/components/explorer/ExplorerInspector.vue +17 -16
- package/frontend-vue/app/components/explorer/ExplorerShell.vue +11 -3
- package/frontend-vue/app/components/explorer/ExplorerToolbar.vue +2 -1
- package/frontend-vue/app/components/field/AssetValue.vue +12 -13
- package/frontend-vue/app/components/file/FileViewer.vue +1 -14
- package/frontend-vue/app/composables/library/useLibraryListing.ts +180 -79
- package/frontend-vue/app/composables/library/useLibraryTree.ts +31 -15
- package/frontend-vue/app/composables/library/useMediaLibrary.ts +17 -7
- package/frontend-vue/app/composables/uploadLimits.ts +25 -0
- package/frontend-vue/app/composables/useAssetContent.ts +20 -0
- package/frontend-vue/app/composables/useCurrentFile.ts +10 -8
- package/frontend-vue/app/composables/useFieldFolders.ts +19 -18
- package/frontend-vue/app/composables/useFileDetails.ts +117 -90
- package/frontend-vue/app/composables/useMediaApi.ts +18 -24
- package/frontend-vue/package.json +2 -1
- package/frontend-vue/pnpm-lock.yaml +17 -2
- package/frontend-vue/tests/engines.test.ts +20 -0
- package/frontend-vue/tests/fixtures/inertia.ts +8 -0
- package/frontend-vue/tests/fixtures/serverRender.ts +200 -0
- package/frontend-vue/tests/fixtures/unhead.ts +3 -0
- package/frontend-vue/tests/fixtures/vueI18n.ts +4 -0
- package/frontend-vue/tests/libraryListing.test.ts +120 -0
- package/frontend-vue/tests/serverRender.test.ts +215 -0
- package/frontend-vue/vitest.config.ts +21 -0
- package/package.json +40 -16
- package/skills/dms-media/SKILL.md +64 -0
- package/src/index.ts +19 -2
- package/src/test/antelope.test.ts +5 -5
- package/src/test/helpers/pages.ts +3 -2
- package/src/test/integration/frontend-module.test.ts +13 -0
- package/frontend-vue/app/composables/useSharedTree.ts +0 -73
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import { useMounted } from '@vueuse/core'
|
|
2
3
|
import { Cropper, Preview } from 'vue-advanced-cropper'
|
|
3
4
|
import 'vue-advanced-cropper/dist/style.css'
|
|
4
|
-
import type { AssetDetails, DeliveryPreset, MediaAsset } from '../types/media'
|
|
5
|
+
import type { AssetDetails, DeliveryPreset, MediaAsset, PresetsResponse } from '../types/media'
|
|
5
6
|
import type { TransformOperations } from '../composables/useMediaApi'
|
|
6
7
|
import { type AspectOption, aspectOptions, FREE_ASPECT_ID, ORIGINAL_ASPECT_ID, type PixelSize, rotatedSize as turnSize } from '../utils/editorAspects'
|
|
7
8
|
|
|
@@ -85,16 +86,18 @@ const KEY_STEPS: Record<string, KeyStep> = {
|
|
|
85
86
|
const route = useDmsRoute()
|
|
86
87
|
const api = useMediaApi()
|
|
87
88
|
const { t } = useI18n()
|
|
89
|
+
const { keyLabel } = useKeyboardPlatform()
|
|
88
90
|
const toast = useToast()
|
|
89
91
|
const format = useMediaFormat()
|
|
90
92
|
const { confirm } = useConfirm()
|
|
91
93
|
const cropper = useTemplateRef<CropperHandle>('cropper')
|
|
92
94
|
const stage = useTemplateRef<HTMLElement>('stage')
|
|
93
95
|
const aspectGroup = useTemplateRef<HTMLElement>('aspectGroup')
|
|
94
|
-
const
|
|
95
|
-
const presets = ref<DeliveryPreset[]>([])
|
|
96
|
+
const isMounted = useMounted()
|
|
96
97
|
const source = ref<string | null>(null)
|
|
97
|
-
const
|
|
98
|
+
const sourceFailed = ref(false)
|
|
99
|
+
/** Counts the retries, so that a retry loads the image again. */
|
|
100
|
+
const attempt = ref(0)
|
|
98
101
|
const rotation = ref(0)
|
|
99
102
|
const aspect = ref(FREE_ASPECT_ID)
|
|
100
103
|
const change = ref<CropperChange | null>(null)
|
|
@@ -102,8 +105,20 @@ const isSaving = ref(false)
|
|
|
102
105
|
const isCropperReady = ref(false)
|
|
103
106
|
|
|
104
107
|
const assetId = computed(() => (typeof route.query.asset === 'string' ? route.query.asset : undefined))
|
|
108
|
+
/** The file's details, read with the page: a server render shows its name and whether it can be edited. */
|
|
109
|
+
const detailsRead = useApiData<AssetDetails>(() => (assetId.value ? MEDIA_READS.details(assetId.value) : null))
|
|
110
|
+
const details = computed(() => (detailsRead.error.value || detailsRead.placeholder.value ? null : detailsRead.data.value))
|
|
105
111
|
const asset = computed(() => details.value?.asset)
|
|
106
112
|
const isEditable = computed(() => Boolean(asset.value && isEditableAsset(asset.value)))
|
|
113
|
+
/** The delivery sizes previewed under the crop, which only the browser draws: left to the browser. */
|
|
114
|
+
const presetsRead = useApiData<PresetsResponse>(() => (isEditable.value ? MEDIA_READS.presets : null), { server: false })
|
|
115
|
+
const presets = computed<DeliveryPreset[]>(() => presetsRead.data.value?.presets ?? [])
|
|
116
|
+
const loadState = computed<LoadState>(() => {
|
|
117
|
+
const error = detailsRead.error.value
|
|
118
|
+
if (error && detailsRead.status.value !== 'pending') return isOutOfReachError(error) ? 'missing' : 'error'
|
|
119
|
+
if (sourceFailed.value) return 'error'
|
|
120
|
+
return asset.value ? 'ready' : 'loading'
|
|
121
|
+
})
|
|
107
122
|
const isEditing = computed(() => loadState.value === 'ready' && isEditable.value)
|
|
108
123
|
|
|
109
124
|
const imageSize = computed<PixelSize | undefined>(() => {
|
|
@@ -224,25 +239,18 @@ function resetEdits(): void {
|
|
|
224
239
|
isCropperReady.value = false
|
|
225
240
|
}
|
|
226
241
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
if (
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
loadState.value = 'ready'
|
|
240
|
-
if (!isEditable.value || !asset.value) return
|
|
241
|
-
void api.presets().then((response) => (presets.value = response.presets)).catch(() => undefined)
|
|
242
|
-
source.value = await editingSource(asset.value).catch(() => {
|
|
243
|
-
loadState.value = 'error'
|
|
244
|
-
return null
|
|
245
|
-
})
|
|
242
|
+
/** The image the cropper edits, loaded by the browser once the file is known to be editable. */
|
|
243
|
+
async function loadSource(target: MediaAsset): Promise<void> {
|
|
244
|
+
const url = await editingSource(target).catch(() => null)
|
|
245
|
+
if (asset.value?.id !== target.id) return
|
|
246
|
+
if (url) source.value = url
|
|
247
|
+
else sourceFailed.value = true
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
async function retry(): Promise<void> {
|
|
251
|
+
sourceFailed.value = false
|
|
252
|
+
await detailsRead.refresh()
|
|
253
|
+
attempt.value += 1
|
|
246
254
|
}
|
|
247
255
|
|
|
248
256
|
function onCropperReady(): void {
|
|
@@ -395,7 +403,16 @@ const notEditableDescription = computed(() =>
|
|
|
395
403
|
asset.value?.mimetype === VECTOR_MIMETYPE ? t('dms_media.editor.not_editable_vector') : t('dms_media.editor.not_editable_formats'),
|
|
396
404
|
)
|
|
397
405
|
|
|
398
|
-
watch(
|
|
406
|
+
watch(
|
|
407
|
+
() => [isMounted.value && isEditable.value ? asset.value?.id : undefined, attempt.value] as const,
|
|
408
|
+
([id]) => {
|
|
409
|
+
source.value = null
|
|
410
|
+
sourceFailed.value = false
|
|
411
|
+
resetEdits()
|
|
412
|
+
if (id && asset.value) void loadSource(asset.value)
|
|
413
|
+
},
|
|
414
|
+
{ immediate: true },
|
|
415
|
+
)
|
|
399
416
|
/** A fixed ratio starts as the largest frame of that ratio, centred on the image. */
|
|
400
417
|
watch(stencilRatio, async (ratio) => {
|
|
401
418
|
await nextTick()
|
|
@@ -436,7 +453,7 @@ definePageShortcuts(() => ({
|
|
|
436
453
|
variant="error"
|
|
437
454
|
:title="t('dms_media.editor.load_failed')"
|
|
438
455
|
:description="t('dms_media.editor.load_failed_description')"
|
|
439
|
-
:actions="[{ label: t('dms_media.actions.retry'), icon: 'i-ph-arrow-clockwise', onClick:
|
|
456
|
+
:actions="[{ label: t('dms_media.actions.retry'), icon: 'i-ph-arrow-clockwise', onClick: retry }]"
|
|
440
457
|
/>
|
|
441
458
|
<DmsEmptyState
|
|
442
459
|
v-else-if="asset && !isEditable"
|
|
@@ -572,7 +589,7 @@ definePageShortcuts(() => ({
|
|
|
572
589
|
:label="pending.length ? t('dms_media.editor.save', { count: pending.length }, pending.length) : t('dms_media.editor.save_none')"
|
|
573
590
|
@click="save"
|
|
574
591
|
>
|
|
575
|
-
<template #trailing><UKbd value="meta" size="sm" variant="subtle" /><UKbd value="S" size="sm" variant="subtle" /></template>
|
|
592
|
+
<template #trailing><UKbd :value="keyLabel('meta')" size="sm" variant="subtle" /><UKbd value="S" size="sm" variant="subtle" /></template>
|
|
576
593
|
</UButton>
|
|
577
594
|
<div class="grid grid-cols-2 gap-2">
|
|
578
595
|
<UButton block color="neutral" variant="outline" :label="t('dms_media.editor.discard')" @click="leave" />
|
|
@@ -29,25 +29,17 @@ interface PresetFact {
|
|
|
29
29
|
hint?: string
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
const api = useMediaApi()
|
|
33
32
|
const format = useMediaFormat()
|
|
34
33
|
const { t, te } = useI18n()
|
|
35
|
-
const
|
|
36
|
-
const
|
|
34
|
+
const presets = useApiData<ImageSizesResponse>(MEDIA_READS.presets)
|
|
35
|
+
const data = presets.data
|
|
36
|
+
const failed = computed(() => Boolean(presets.error.value) && presets.status.value !== 'pending')
|
|
37
37
|
const brokenExamples = ref(new Set<string>())
|
|
38
38
|
const BOX_SIZE = 140
|
|
39
39
|
const MIN_BOX_SIZE = 28
|
|
40
40
|
const UNBOUNDED_RATIO = 0.62
|
|
41
41
|
const DEFAULT_FIT = 'cover'
|
|
42
42
|
|
|
43
|
-
onMounted(async () => {
|
|
44
|
-
try {
|
|
45
|
-
data.value = (await api.presets()) as ImageSizesResponse
|
|
46
|
-
} catch {
|
|
47
|
-
failed.value = true
|
|
48
|
-
}
|
|
49
|
-
})
|
|
50
|
-
|
|
51
43
|
/** The example's own size, or a landscape stand-in when there is none. */
|
|
52
44
|
const sourceSize = computed<PixelSize>(() => {
|
|
53
45
|
const example = data.value?.example
|
|
@@ -2,24 +2,16 @@
|
|
|
2
2
|
import type { MediaAsset } from '../types/media'
|
|
3
3
|
import AssetThumb from './shared/AssetThumb.vue'
|
|
4
4
|
|
|
5
|
-
const api = useMediaApi()
|
|
6
5
|
const format = useMediaFormat()
|
|
7
6
|
const { t } = useI18n()
|
|
8
|
-
|
|
9
|
-
const {
|
|
10
|
-
const
|
|
7
|
+
// Read again on each library change, its own trigger: the page's refreshes leave it alone.
|
|
8
|
+
const recent = useApiData<{ assets: MediaAsset[] }>(MEDIA_READS.recent, { refreshOnPageRefresh: false })
|
|
9
|
+
const assets = computed(() => recent.data.value?.assets ?? [])
|
|
10
|
+
const { tree } = useLibraryTree()
|
|
11
|
+
const isLoading = computed(() => recent.status.value === 'pending' && !recent.data.value)
|
|
11
12
|
const SKELETONS = 6
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
try {
|
|
15
|
-
assets.value = (await api.recent()).assets
|
|
16
|
-
} finally {
|
|
17
|
-
isLoading.value = false
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
onMounted(() => void load())
|
|
22
|
-
onLibraryChange(load)
|
|
14
|
+
onLibraryChange(() => recent.refresh())
|
|
23
15
|
|
|
24
16
|
const foldersById = computed(() => new Map((tree.value?.folders ?? []).map((folder) => [folder.id, folder])))
|
|
25
17
|
</script>
|
|
@@ -9,7 +9,7 @@ const format = useMediaFormat()
|
|
|
9
9
|
const overlay = useOverlay()
|
|
10
10
|
const destinationDialog = overlay.create(DestinationDialog)
|
|
11
11
|
const { prefs, update } = useMediaPrefs()
|
|
12
|
-
const { tree, reload } =
|
|
12
|
+
const { tree, refresh: reload } = useLibraryTree()
|
|
13
13
|
const toasts = useUploadToasts()
|
|
14
14
|
const route = useDmsRoute()
|
|
15
15
|
const router = useDmsRouter()
|
|
@@ -6,7 +6,7 @@ const uploads = useUploadQueue()
|
|
|
6
6
|
const overlay = useOverlay()
|
|
7
7
|
const destinationDialog = overlay.create(DestinationDialog)
|
|
8
8
|
const { prefs, update } = useMediaPrefs()
|
|
9
|
-
const { tree, reload } =
|
|
9
|
+
const { tree, refresh: reload } = useLibraryTree()
|
|
10
10
|
const { t } = useI18n()
|
|
11
11
|
const toast = useUploadToasts()
|
|
12
12
|
const fileInput = useTemplateRef<HTMLInputElement>('fileInput')
|
|
@@ -19,7 +19,7 @@ const api = useMediaApi()
|
|
|
19
19
|
const toast = useToast()
|
|
20
20
|
const format = useMediaFormat()
|
|
21
21
|
const nameDialog = useOverlay().create(NameDialog)
|
|
22
|
-
const { tree, reload } =
|
|
22
|
+
const { tree, refresh: reload } = useLibraryTree()
|
|
23
23
|
const pickerRoot = useTemplateRef<HTMLElement>('pickerRoot')
|
|
24
24
|
const isCreating = ref(false)
|
|
25
25
|
|
|
@@ -87,7 +87,6 @@ const stopFocusing = watch(pickerRoot, (root) => {
|
|
|
87
87
|
setTimeout(() => root.querySelector('input')?.focus())
|
|
88
88
|
})
|
|
89
89
|
|
|
90
|
-
onMounted(() => void reload())
|
|
91
90
|
</script>
|
|
92
91
|
|
|
93
92
|
<template>
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import type { ApiDataResult } from '#dms-core/app/composables/auth/useApiData'
|
|
3
|
+
import type { ReadUrl } from '../../composables/useMediaApi'
|
|
4
|
+
import type { AssetDetails } from '../../types/media'
|
|
2
5
|
import AltTextField from '../shared/AltTextField.vue'
|
|
3
6
|
import AssetThumb from '../shared/AssetThumb.vue'
|
|
4
7
|
import FolderGlyph from '../shared/FolderGlyph.vue'
|
|
@@ -22,25 +25,23 @@ const assetPath = computed(() => folderPathLabel(assetFolder.value, library.tree
|
|
|
22
25
|
const canEdit = computed(() => (asset.value ? commands.canWriteAsset(asset.value) : false))
|
|
23
26
|
const isBrowse = library.mode === 'browse'
|
|
24
27
|
const PREVIEW_PRESET = 'preview'
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
// The preview uncropped, at the file's own ratio, and who added it, for the
|
|
29
|
+
// file in view: read while it is in view, shared with the other blocks
|
|
30
|
+
// reading the same file.
|
|
31
|
+
const assetId = computed(() => asset.value?.id)
|
|
32
|
+
const previewRead = useApiData<ReadUrl>(
|
|
33
|
+
() => (asset.value && isImageAsset(asset.value) ? MEDIA_READS.readUrl(asset.value.id) : null),
|
|
34
|
+
{ query: { preset: PREVIEW_PRESET } },
|
|
35
|
+
)
|
|
36
|
+
const detailsRead = useApiData<AssetDetails>(() => (assetId.value ? MEDIA_READS.details(assetId.value) : null))
|
|
27
37
|
|
|
28
|
-
/**
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
uploadedBy.value = null
|
|
32
|
-
const target = asset.value
|
|
33
|
-
if (!assetId || !target) return
|
|
34
|
-
const [read, details] = await Promise.all([
|
|
35
|
-
isImageAsset(target) ? library.api.readUrl(assetId, PREVIEW_PRESET).catch(() => undefined) : undefined,
|
|
36
|
-
library.api.details(assetId).catch(() => undefined),
|
|
37
|
-
])
|
|
38
|
-
if (asset.value?.id !== assetId) return
|
|
39
|
-
previewUrl.value = read?.url
|
|
40
|
-
uploadedBy.value = details?.uploadedBy ?? null
|
|
38
|
+
/** Nothing of the previous file shows while the next one's reads are under way. */
|
|
39
|
+
function isCurrent<T>(read: ApiDataResult<T>): boolean {
|
|
40
|
+
return !read.placeholder.value && !read.error.value
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
const previewUrl = computed(() => (isCurrent(previewRead) ? previewRead.data.value?.url : undefined))
|
|
44
|
+
const uploadedBy = computed(() => (isCurrent(detailsRead) ? (detailsRead.data.value?.uploadedBy ?? null) : null))
|
|
44
45
|
|
|
45
46
|
function saveAlt(alt: string): Promise<boolean> {
|
|
46
47
|
return asset.value ? library.actions.setAlt(asset.value, alt) : Promise.resolve(false)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import type { ExplorerHistory } from '../../composables/library/useExplorerLayout'
|
|
3
|
-
import type
|
|
3
|
+
import { type LibraryLocation, type ListingFilters, sameLocation } from '../../composables/library/useLibraryListing'
|
|
4
4
|
import type { MediaAsset, MediaFolder } from '../../types/media'
|
|
5
5
|
import MediaLightbox from '../shared/MediaLightbox.vue'
|
|
6
6
|
import BulkBar from './BulkBar.vue'
|
|
@@ -37,6 +37,9 @@ const library = provideMediaLibrary({
|
|
|
37
37
|
remaining: props.remaining,
|
|
38
38
|
scopeFolderId: props.scopeFolderId,
|
|
39
39
|
alreadyPicked: props.alreadyPicked,
|
|
40
|
+
// Started here rather than once mounted, so that a server render reads a link's folder with the page.
|
|
41
|
+
initialLocation: props.initialLocation ?? startLocation(),
|
|
42
|
+
initialFilters: props.initialFilters,
|
|
40
43
|
})
|
|
41
44
|
const layout = createExplorerLayout(root, {
|
|
42
45
|
scopeFolderId: props.scopeFolderId,
|
|
@@ -149,8 +152,13 @@ async function navigate(target: LibraryLocation, filters: Partial<ListingFilters
|
|
|
149
152
|
}
|
|
150
153
|
|
|
151
154
|
onMounted(async () => {
|
|
152
|
-
await library.tree.
|
|
153
|
-
|
|
155
|
+
await library.tree.ready()
|
|
156
|
+
const start = checkedLocation(props.initialLocation ?? startLocation())
|
|
157
|
+
// The listing started there, with its filters: opening it again would only reset them. The
|
|
158
|
+
// page still hears where it starts, as it does after a navigation.
|
|
159
|
+
if (!sameLocation(start, library.listing.location.value)) return navigate(start, props.initialFilters)
|
|
160
|
+
emit('location', library.listing.location.value)
|
|
161
|
+
emit('filters', library.listing.filters.value)
|
|
154
162
|
})
|
|
155
163
|
|
|
156
164
|
const isBrowse = props.mode === 'browse'
|
|
@@ -9,6 +9,7 @@ const { library, commands } = useExplorerContext()
|
|
|
9
9
|
const layout = useExplorerLayout()
|
|
10
10
|
const drop = useExplorerDrop()
|
|
11
11
|
const { t } = useI18n()
|
|
12
|
+
const { keyLabel } = useKeyboardPlatform()
|
|
12
13
|
const { prefs, update } = useMediaPrefs()
|
|
13
14
|
const searchInput = useTemplateRef<{ inputRef?: HTMLInputElement }>('search')
|
|
14
15
|
const query = ref('')
|
|
@@ -195,7 +196,7 @@ defineExpose({ focusSearch: () => searchInput.value?.inputRef?.focus() })
|
|
|
195
196
|
@click="clearQuery"
|
|
196
197
|
/>
|
|
197
198
|
<span v-else class="hidden items-center gap-0.5 sm:inline-flex [@media(pointer:coarse)]:hidden">
|
|
198
|
-
<UKbd value="meta" size="sm" />
|
|
199
|
+
<UKbd :value="keyLabel('meta')" size="sm" />
|
|
199
200
|
<UKbd value="/" size="sm" />
|
|
200
201
|
</span>
|
|
201
202
|
</template>
|
|
@@ -4,8 +4,6 @@ import AssetThumb from '../shared/AssetThumb.vue'
|
|
|
4
4
|
|
|
5
5
|
const props = defineProps<{ value: unknown }>()
|
|
6
6
|
const { t } = useI18n()
|
|
7
|
-
const api = useMediaApi()
|
|
8
|
-
const assets = ref<(MediaAsset | null)[]>([])
|
|
9
7
|
|
|
10
8
|
const SHOWN_NAMES = 2
|
|
11
9
|
|
|
@@ -18,21 +16,22 @@ const ids = computed<string[]>(() => {
|
|
|
18
16
|
const shownIds = computed(() => ids.value.slice(0, SHOWN_NAMES))
|
|
19
17
|
const hidden = computed(() => Math.max(ids.value.length - SHOWN_NAMES, 0))
|
|
20
18
|
|
|
21
|
-
/**
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Only the files the cell names are read, with the page: the others are
|
|
21
|
+
* counted. A file the server does not answer for shows as missing.
|
|
22
|
+
*/
|
|
23
|
+
const read = useApiData<(MediaAsset | null)[]>(
|
|
24
|
+
() => `dms-media:asset-names:${shownIds.value.join(',')}`,
|
|
25
|
+
({ $authFetch, signal }) =>
|
|
26
|
+
Promise.all(
|
|
27
|
+
shownIds.value.map((id) =>
|
|
28
|
+
$authFetch<{ asset: MediaAsset }>(MEDIA_READS.asset(id), { signal })
|
|
29
29
|
.then((response) => response.asset)
|
|
30
30
|
.catch(() => null),
|
|
31
31
|
),
|
|
32
|
-
)
|
|
33
|
-
},
|
|
34
|
-
{ immediate: true },
|
|
32
|
+
),
|
|
35
33
|
)
|
|
34
|
+
const assets = computed(() => (read.placeholder.value ? [] : (read.data.value ?? [])))
|
|
36
35
|
</script>
|
|
37
36
|
|
|
38
37
|
<template>
|
|
@@ -1,28 +1,15 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import type { MediaAsset } from '../../types/media'
|
|
3
|
-
import type { AssetContent } from '../../composables/useAssetContent'
|
|
4
3
|
import AssetThumb from '../shared/AssetThumb.vue'
|
|
5
4
|
|
|
6
5
|
const props = defineProps<{ asset: MediaAsset; siblings: MediaAsset[] }>()
|
|
7
6
|
const emit = defineEmits<{ open: [string]; fullscreen: [] }>()
|
|
8
|
-
const contents = useAssetContent()
|
|
9
7
|
const assetLink = useAssetLink()
|
|
10
8
|
const format = useMediaFormat()
|
|
11
9
|
const { t } = useI18n()
|
|
12
|
-
const content =
|
|
10
|
+
const content = useShownContent(() => props.asset)
|
|
13
11
|
const filmstrip = useTemplateRef<HTMLElement>('filmstrip')
|
|
14
12
|
|
|
15
|
-
watch(
|
|
16
|
-
() => [props.asset.id, props.asset.updatedAt],
|
|
17
|
-
async () => {
|
|
18
|
-
const shown = props.asset
|
|
19
|
-
content.value = { kind: 'none' }
|
|
20
|
-
const loaded = await contents.load(shown)
|
|
21
|
-
if (shown.id === props.asset.id) content.value = loaded
|
|
22
|
-
},
|
|
23
|
-
{ immediate: true },
|
|
24
|
-
)
|
|
25
|
-
|
|
26
13
|
watch(
|
|
27
14
|
() => props.asset.id,
|
|
28
15
|
async (id) => {
|