Compare commits
4
Commits
6effab12eb
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1b36fbaeba | ||
|
|
0de7a87938 | ||
|
|
2290040242 | ||
|
|
af3109c564 |
Vendored
+1
@@ -28,5 +28,6 @@ declare module 'vue' {
|
|||||||
UploadQueueList: typeof import('./components/upload/UploadQueueList.vue')['default']
|
UploadQueueList: typeof import('./components/upload/UploadQueueList.vue')['default']
|
||||||
UploadSettingsPanel: typeof import('./components/upload/UploadSettingsPanel.vue')['default']
|
UploadSettingsPanel: typeof import('./components/upload/UploadSettingsPanel.vue')['default']
|
||||||
UploadShareResults: typeof import('./components/upload/UploadShareResults.vue')['default']
|
UploadShareResults: typeof import('./components/upload/UploadShareResults.vue')['default']
|
||||||
|
ViewerImageDisplay: typeof import('./components/viewer/ViewerImageDisplay.vue')['default']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<p v-if="!fileName" class="text-sm text-muted-foreground">Select an image to view its metadata.</p>
|
<p v-if="!fileName" class="text-sm text-muted-foreground">Select an image to view its metadata.</p>
|
||||||
|
|
||||||
<template v-else-if="entry.status === 'error' && !entry.output">
|
<template v-else-if="entry.status === 'error' && !entry.output">
|
||||||
<p class="text-sm text-destructive">{{ entry.message }}</p>
|
<p class="whitespace-pre-wrap text-sm text-destructive">{{ entry.detailMessage ?? entry.message }}</p>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-else-if="showMetadataTabs">
|
<template v-else-if="showMetadataTabs">
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
<MetadataOutputPanel v-if="tabBody?.kind === 'output'">{{ tabBody.text }}</MetadataOutputPanel>
|
<MetadataOutputPanel v-if="tabBody?.kind === 'output'">{{ tabBody.text }}</MetadataOutputPanel>
|
||||||
|
|
||||||
<p v-else-if="tabBody?.kind === 'error'" class="text-sm text-destructive">{{ tabBody.text }}</p>
|
<p v-else-if="tabBody?.kind === 'error'" class="whitespace-pre-wrap text-sm text-destructive">{{ tabBody.text }}</p>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<p v-else class="text-sm text-muted-foreground">{{ entry.message }}</p>
|
<p v-else class="text-sm text-muted-foreground">{{ entry.message }}</p>
|
||||||
@@ -83,7 +83,7 @@ const tabBody = computed((): MetadataTabBody | null => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (entry.status === 'error') {
|
if (entry.status === 'error') {
|
||||||
return { kind: 'error', text: entry.message };
|
return { kind: 'error', text: entry.detailMessage ?? entry.message };
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -97,10 +97,10 @@ const formatMetadataPreviewMessage = (entry: MetadataPreviewEntry): string => {
|
|||||||
const percent = wasmDownloadPercent.value;
|
const percent = wasmDownloadPercent.value;
|
||||||
|
|
||||||
if (percent === null) {
|
if (percent === null) {
|
||||||
return 'Downloading ExifTool…';
|
return entry.message;
|
||||||
}
|
}
|
||||||
|
|
||||||
return `Downloading ExifTool… ${percent}%`;
|
return `${entry.message} ${percent}%`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return entry.message;
|
return entry.message;
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
<template>
|
||||||
|
<div class="flex w-full min-h-0 flex-col items-center justify-center gap-3 text-center">
|
||||||
|
<img
|
||||||
|
:src="src"
|
||||||
|
decoding="async"
|
||||||
|
class="mx-auto block h-auto w-auto max-h-[min(calc(100dvh-12rem),calc(100vh-12rem))] max-w-[min(100%,calc(100vw-2rem))] object-contain"
|
||||||
|
:class="{ hidden: visuallyHidden }"
|
||||||
|
@load="emit('load')"
|
||||||
|
@error="emit('error')"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<a
|
||||||
|
v-if="!visuallyHidden"
|
||||||
|
:href="src"
|
||||||
|
class="text-sm text-muted-foreground underline-offset-2 hover:text-foreground hover:underline"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
target="_blank"
|
||||||
|
>
|
||||||
|
Open full image
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
defineProps({
|
||||||
|
src: {
|
||||||
|
type: String,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
visuallyHidden: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
load: [];
|
||||||
|
error: [];
|
||||||
|
}>();
|
||||||
|
</script>
|
||||||
@@ -3,6 +3,7 @@ import { ref } from 'vue';
|
|||||||
import { useExiftoolStore } from '@/stores/exiftool';
|
import { useExiftoolStore } from '@/stores/exiftool';
|
||||||
import type { MetadataPreviewEntry } from '@/types/metadata/MetadataPreview';
|
import type { MetadataPreviewEntry } from '@/types/metadata/MetadataPreview';
|
||||||
import { makeKeyFromFile } from '@/utils/file/makeKeyFromFile';
|
import { makeKeyFromFile } from '@/utils/file/makeKeyFromFile';
|
||||||
|
import { resolveErrorMessage } from '@/utils/resolveErrorMessage';
|
||||||
|
|
||||||
const METADATA_IDLE_MESSAGE = 'Waiting to load metadata...';
|
const METADATA_IDLE_MESSAGE = 'Waiting to load metadata...';
|
||||||
const EXIFTOOL_INITIALIZING_MESSAGE = 'Downloading ExifTool…';
|
const EXIFTOOL_INITIALIZING_MESSAGE = 'Downloading ExifTool…';
|
||||||
@@ -17,11 +18,6 @@ const METADATA_IDLE_PREVIEW: MetadataPreviewEntry = {
|
|||||||
message: METADATA_IDLE_MESSAGE
|
message: METADATA_IDLE_MESSAGE
|
||||||
};
|
};
|
||||||
|
|
||||||
const METADATA_LOAD_ERROR_PREVIEW: MetadataPreviewEntry = {
|
|
||||||
status: 'error',
|
|
||||||
message: METADATA_LOAD_ERROR_MESSAGE
|
|
||||||
};
|
|
||||||
|
|
||||||
const EXIFTOOL_PREPARE_ERROR_PREVIEW: MetadataPreviewEntry = {
|
const EXIFTOOL_PREPARE_ERROR_PREVIEW: MetadataPreviewEntry = {
|
||||||
status: 'error',
|
status: 'error',
|
||||||
message: EXIFTOOL_PREPARE_ERROR_MESSAGE
|
message: EXIFTOOL_PREPARE_ERROR_MESSAGE
|
||||||
@@ -96,9 +92,15 @@ export const useMetadataStore = defineStore('metadata', () => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('[metadata] read failed', { file: file.name, error });
|
console.error('[metadata] read failed', { file: file.name, error });
|
||||||
|
|
||||||
setPreviewEntry(key, METADATA_LOAD_ERROR_PREVIEW);
|
const entry: MetadataPreviewEntry = {
|
||||||
|
status: 'error',
|
||||||
|
message: METADATA_LOAD_ERROR_MESSAGE,
|
||||||
|
detailMessage: resolveErrorMessage(error, METADATA_LOAD_ERROR_MESSAGE)
|
||||||
|
};
|
||||||
|
|
||||||
return METADATA_LOAD_ERROR_PREVIEW;
|
setPreviewEntry(key, entry);
|
||||||
|
|
||||||
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
let strippedBlob: Blob;
|
let strippedBlob: Blob;
|
||||||
@@ -116,6 +118,7 @@ export const useMetadataStore = defineStore('metadata', () => {
|
|||||||
const entry: MetadataPreviewEntry = {
|
const entry: MetadataPreviewEntry = {
|
||||||
status: 'error',
|
status: 'error',
|
||||||
message: METADATA_STRIP_ERROR_MESSAGE,
|
message: METADATA_STRIP_ERROR_MESSAGE,
|
||||||
|
detailMessage: resolveErrorMessage(error, METADATA_STRIP_ERROR_MESSAGE),
|
||||||
output
|
output
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -136,9 +139,16 @@ export const useMetadataStore = defineStore('metadata', () => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('[metadata] read after strip failed', { file: file.name, error });
|
console.error('[metadata] read after strip failed', { file: file.name, error });
|
||||||
|
|
||||||
setPreviewEntry(key, METADATA_LOAD_ERROR_PREVIEW);
|
const entry: MetadataPreviewEntry = {
|
||||||
|
status: 'error',
|
||||||
|
message: METADATA_LOAD_ERROR_MESSAGE,
|
||||||
|
detailMessage: resolveErrorMessage(error, METADATA_LOAD_ERROR_MESSAGE),
|
||||||
|
output
|
||||||
|
};
|
||||||
|
|
||||||
return METADATA_LOAD_ERROR_PREVIEW;
|
setPreviewEntry(key, entry);
|
||||||
|
|
||||||
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
setStrippedBlob(key, strippedBlob);
|
setStrippedBlob(key, strippedBlob);
|
||||||
|
|||||||
@@ -3,4 +3,4 @@ export type MetadataPreviewEntry =
|
|||||||
| { status: 'initializing'; message: string }
|
| { status: 'initializing'; message: string }
|
||||||
| { status: 'processing'; message: string }
|
| { status: 'processing'; message: string }
|
||||||
| { status: 'ready'; message: string; output: string; afterStripOutput: string }
|
| { status: 'ready'; message: string; output: string; afterStripOutput: string }
|
||||||
| { status: 'error'; message: string; output?: string };
|
| { status: 'error'; message: string; output?: string; detailMessage?: string };
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import type { AxiosProgressEvent } from 'axios';
|
||||||
|
import { describe, expect, it } from 'vitest';
|
||||||
|
import { percentFromAxiosProgress } from '@/utils/percentFromAxiosProgress';
|
||||||
|
|
||||||
|
const progress = (loaded: number, total?: number): AxiosProgressEvent =>
|
||||||
|
({
|
||||||
|
loaded,
|
||||||
|
total,
|
||||||
|
bytes: 0,
|
||||||
|
lengthComputable: total !== undefined
|
||||||
|
}) as AxiosProgressEvent;
|
||||||
|
|
||||||
|
describe('percentFromAxiosProgress', () => {
|
||||||
|
it('returns null when total is missing', () => {
|
||||||
|
expect(percentFromAxiosProgress(progress(50))).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns rounded percent from loaded and total', () => {
|
||||||
|
expect(percentFromAxiosProgress(progress(250, 1000))).toBe(25);
|
||||||
|
expect(percentFromAxiosProgress(progress(1, 3))).toBe(33.33);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('caps at 100', () => {
|
||||||
|
expect(percentFromAxiosProgress(progress(200, 100))).toBe(100);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import type { AxiosProgressEvent } from 'axios';
|
||||||
|
|
||||||
|
export const percentFromAxiosProgress = (progressEvent: AxiosProgressEvent): number | null => {
|
||||||
|
if (!progressEvent.total) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const percent = Math.min(100, (progressEvent.loaded / progressEvent.total) * 100);
|
||||||
|
|
||||||
|
return parseFloat(percent.toFixed(2));
|
||||||
|
};
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<main
|
<main class="flex min-h-0 w-full flex-1 flex-col items-center justify-center px-4 py-4 sm:px-6">
|
||||||
class="mx-auto flex w-full max-w-lg flex-1 flex-col items-center justify-center gap-3 px-4 py-6 text-center sm:px-6 sm:py-8"
|
|
||||||
>
|
|
||||||
<p v-if="state === 'invalidLink'" class="text-sm text-muted-foreground">
|
<p v-if="state === 'invalidLink'" class="text-sm text-muted-foreground">
|
||||||
This viewing link is incomplete. Use the hotlink URL from your upload results.
|
This viewing link is incomplete. Use the hotlink URL from your upload results.
|
||||||
</p>
|
</p>
|
||||||
@@ -11,11 +9,10 @@
|
|||||||
<template v-else>
|
<template v-else>
|
||||||
<p v-if="state === 'loading'" class="text-sm text-muted-foreground sm:text-base">Loading image...</p>
|
<p v-if="state === 'loading'" class="text-sm text-muted-foreground sm:text-base">Loading image...</p>
|
||||||
|
|
||||||
<img
|
<ViewerImageDisplay
|
||||||
v-if="imageSrc"
|
v-if="imageSrc"
|
||||||
:src="imageSrc"
|
:src="imageSrc"
|
||||||
class="max-h-[min(80vh,100dvh)] w-full object-contain"
|
:visually-hidden="state === 'loading'"
|
||||||
:class="{ hidden: state === 'loading' }"
|
|
||||||
@load="onImageLoad"
|
@load="onImageLoad"
|
||||||
@error="onImageError"
|
@error="onImageError"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<main
|
<main class="flex min-h-0 w-full flex-1 flex-col items-center justify-center px-4 py-4 sm:px-6">
|
||||||
class="mx-auto flex w-full max-w-lg flex-1 flex-col items-center justify-center gap-3 px-4 py-6 text-center sm:px-6 sm:py-8"
|
|
||||||
>
|
|
||||||
<p v-if="state === 'loading'" class="text-sm text-muted-foreground sm:text-base">Loading image...</p>
|
<p v-if="state === 'loading'" class="text-sm text-muted-foreground sm:text-base">Loading image...</p>
|
||||||
|
|
||||||
<p v-else-if="state === 'invalidLink'" class="text-sm text-muted-foreground">
|
<p v-else-if="state === 'invalidLink'" class="text-sm text-muted-foreground">
|
||||||
@@ -37,10 +35,9 @@
|
|||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<img
|
<ViewerImageDisplay
|
||||||
v-else-if="state === 'image' && imageObjectUrl"
|
v-else-if="state === 'image' && imageObjectUrl"
|
||||||
:src="imageObjectUrl"
|
:src="imageObjectUrl"
|
||||||
class="max-h-[min(80vh,100dvh)] w-full object-contain"
|
|
||||||
/>
|
/>
|
||||||
</main>
|
</main>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import axios from 'axios';
|
|||||||
import { EXIFTOOL_WORKER_INIT_JPEG } from '@/consts/exiftoolWorkerInitJpeg';
|
import { EXIFTOOL_WORKER_INIT_JPEG } from '@/consts/exiftoolWorkerInitJpeg';
|
||||||
import type { ExiftoolWorkerInMessage } from '@/types/workers/exiftoolWorkerInMessage';
|
import type { ExiftoolWorkerInMessage } from '@/types/workers/exiftoolWorkerInMessage';
|
||||||
import type { ExiftoolWorkerJob } from '@/types/workers/exiftoolWorkerJob';
|
import type { ExiftoolWorkerJob } from '@/types/workers/exiftoolWorkerJob';
|
||||||
|
import { percentFromAxiosProgress } from '@/utils/percentFromAxiosProgress';
|
||||||
import { resolveErrorMessage } from '@/utils/resolveErrorMessage';
|
import { resolveErrorMessage } from '@/utils/resolveErrorMessage';
|
||||||
import { toArrayBuffer } from '@/utils/toArrayBuffer';
|
import { toArrayBuffer } from '@/utils/toArrayBuffer';
|
||||||
|
|
||||||
@@ -18,15 +19,13 @@ const fetchZeroperlWasm = async (): Promise<Response> => {
|
|||||||
const { data } = await axios.get<ArrayBuffer>(zeroperlWasmUrl, {
|
const { data } = await axios.get<ArrayBuffer>(zeroperlWasmUrl, {
|
||||||
responseType: 'arraybuffer',
|
responseType: 'arraybuffer',
|
||||||
onDownloadProgress: progressEvent => {
|
onDownloadProgress: progressEvent => {
|
||||||
if (!progressEvent.total) {
|
const percent = percentFromAxiosProgress(progressEvent);
|
||||||
|
|
||||||
|
if (percent === null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const percent = Math.min(100, (progressEvent.loaded / progressEvent.total) * 100);
|
self.postMessage({ type: 'wasm-download-progress', percent });
|
||||||
|
|
||||||
const rounded = parseFloat(percent.toFixed(2));
|
|
||||||
|
|
||||||
self.postMessage({ type: 'wasm-download-progress', percent: rounded });
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user