Compare commits
2
Commits
b5e50f786b
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1b36fbaeba | ||
|
|
0de7a87938 |
@@ -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;
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
{{ formatMetadataPreviewMessage(row.metadata) }}
|
{{ formatMetadataPreviewMessage(row.metadata) }}
|
||||||
</span>
|
</span>
|
||||||
<span class="min-w-0 truncate" :class="uploadStatusClass(row.upload)">
|
<span class="min-w-0 truncate" :class="uploadStatusClass(row.upload)">
|
||||||
{{ formatUploadQueueMessage(row.upload) }}
|
{{ row.upload.message }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -105,18 +105,4 @@ const formatMetadataPreviewMessage = (entry: MetadataPreviewEntry): string => {
|
|||||||
|
|
||||||
return entry.message;
|
return entry.message;
|
||||||
};
|
};
|
||||||
|
|
||||||
const formatUploadQueueMessage = (entry: UploadQueueEntry): string => {
|
|
||||||
if (entry.status === 'uploading') {
|
|
||||||
const percent = entry.uploadPercent;
|
|
||||||
|
|
||||||
if (percent === null || percent === undefined) {
|
|
||||||
return entry.message;
|
|
||||||
}
|
|
||||||
|
|
||||||
return `${entry.message} ${percent}%`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return entry.message;
|
|
||||||
};
|
|
||||||
</script>
|
</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);
|
||||||
|
|||||||
@@ -16,8 +16,6 @@ import { prepareHotlinkUploadRequest } from '@/utils/upload/prepareHotlinkUpload
|
|||||||
import { prepareZkUploadRequest } from '@/utils/upload/prepareZkUploadRequest';
|
import { prepareZkUploadRequest } from '@/utils/upload/prepareZkUploadRequest';
|
||||||
import type { PreparedZkUploadRequest } from '@/types/upload/PreparedZkUploadRequest';
|
import type { PreparedZkUploadRequest } from '@/types/upload/PreparedZkUploadRequest';
|
||||||
import type { PreparedHotlinkUploadRequest } from '@/types/upload/PreparedHotlinkUploadRequest';
|
import type { PreparedHotlinkUploadRequest } from '@/types/upload/PreparedHotlinkUploadRequest';
|
||||||
import { percentFromAxiosProgress } from '@/utils/percentFromAxiosProgress';
|
|
||||||
import type { AxiosProgressEvent } from 'axios';
|
|
||||||
|
|
||||||
const UPLOAD_IDLE_MESSAGE = 'Waiting to upload...';
|
const UPLOAD_IDLE_MESSAGE = 'Waiting to upload...';
|
||||||
const UPLOAD_QUEUED_MESSAGE = 'Upload queued';
|
const UPLOAD_QUEUED_MESSAGE = 'Upload queued';
|
||||||
@@ -41,11 +39,10 @@ const UPLOAD_QUEUED_ENTRY: UploadQueueEntry = {
|
|||||||
message: UPLOAD_QUEUED_MESSAGE
|
message: UPLOAD_QUEUED_MESSAGE
|
||||||
};
|
};
|
||||||
|
|
||||||
const buildUploadingEntry = (uploadPercent: number | null = null): UploadQueueEntry => ({
|
const UPLOAD_UPLOADING_ENTRY: UploadQueueEntry = {
|
||||||
status: 'uploading',
|
status: 'uploading',
|
||||||
message: UPLOAD_UPLOADING_MESSAGE,
|
message: UPLOAD_UPLOADING_MESSAGE
|
||||||
uploadPercent
|
};
|
||||||
});
|
|
||||||
|
|
||||||
const UPLOAD_FAILED_ENTRY: UploadQueueEntry = {
|
const UPLOAD_FAILED_ENTRY: UploadQueueEntry = {
|
||||||
status: 'failed',
|
status: 'failed',
|
||||||
@@ -83,41 +80,17 @@ export const useUploadStore = defineStore('upload', () => {
|
|||||||
uploadByKey.value = {};
|
uploadByKey.value = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
const getUploadRequestHeaders = (altcha?: string) => (altcha ? { [ALTCHA_REQUEST_HEADER]: altcha } : undefined);
|
const uploadZk = async (body: CreateZkUploadRequest, altcha?: string): Promise<CreatedUploadResult> => {
|
||||||
|
|
||||||
const onUploadProgress = (queueKey: string, progressEvent: AxiosProgressEvent): void => {
|
|
||||||
const percent = percentFromAxiosProgress(progressEvent);
|
|
||||||
|
|
||||||
if (percent !== null) {
|
|
||||||
const entry = buildUploadingEntry(percent);
|
|
||||||
|
|
||||||
setUploadEntry(queueKey, entry);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const uploadZk = async (
|
|
||||||
body: CreateZkUploadRequest,
|
|
||||||
altcha: string | undefined,
|
|
||||||
queueKey: string
|
|
||||||
): Promise<CreatedUploadResult> => {
|
|
||||||
const { data } = await api.post<CreatedUploadResult>('/uploads/zk', body, {
|
const { data } = await api.post<CreatedUploadResult>('/uploads/zk', body, {
|
||||||
headers: getUploadRequestHeaders(altcha),
|
headers: getUploadRequestHeaders(altcha)
|
||||||
onUploadProgress: progressEvent => onUploadProgress(queueKey, progressEvent)
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
const uploadHotlink = async (
|
const uploadHotlink = async (body: CreateHotlinkUploadRequest, altcha?: string): Promise<CreatedUploadResult> => {
|
||||||
body: CreateHotlinkUploadRequest,
|
|
||||||
altcha: string | undefined,
|
|
||||||
queueKey: string
|
|
||||||
): Promise<CreatedUploadResult> => {
|
|
||||||
const { data } = await api.post<CreatedUploadResult>('/uploads/hotlink', body, {
|
const { data } = await api.post<CreatedUploadResult>('/uploads/hotlink', body, {
|
||||||
headers: getUploadRequestHeaders(altcha),
|
headers: getUploadRequestHeaders(altcha)
|
||||||
onUploadProgress: progressEvent => {
|
|
||||||
onUploadProgress(queueKey, progressEvent);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
@@ -129,6 +102,8 @@ export const useUploadStore = defineStore('upload', () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getUploadRequestHeaders = (altcha?: string) => (altcha ? { [ALTCHA_REQUEST_HEADER]: altcha } : undefined);
|
||||||
|
|
||||||
const uploadBatch = async (
|
const uploadBatch = async (
|
||||||
files: readonly File[],
|
files: readonly File[],
|
||||||
settings: UploadBatchSettingsForm,
|
settings: UploadBatchSettingsForm,
|
||||||
@@ -201,14 +176,11 @@ export const useUploadStore = defineStore('upload', () => {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const entry = buildUploadingEntry();
|
setUploadEntry(key, UPLOAD_UPLOADING_ENTRY);
|
||||||
|
|
||||||
setUploadEntry(key, entry);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { request, fragmentKey } = prepared;
|
const { request, fragmentKey } = prepared;
|
||||||
|
|
||||||
const result = await uploadZk(request, altcha, key);
|
const result = await uploadZk(request, altcha);
|
||||||
|
|
||||||
setUploadEntry(key, {
|
setUploadEntry(key, {
|
||||||
status: 'uploaded',
|
status: 'uploaded',
|
||||||
@@ -237,13 +209,11 @@ export const useUploadStore = defineStore('upload', () => {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const entry = buildUploadingEntry();
|
setUploadEntry(key, UPLOAD_UPLOADING_ENTRY);
|
||||||
|
|
||||||
setUploadEntry(key, entry);
|
|
||||||
try {
|
try {
|
||||||
const { request, secret } = prepared;
|
const { request, secret } = prepared;
|
||||||
|
|
||||||
const result = await uploadHotlink(request, altcha, key);
|
const result = await uploadHotlink(request, altcha);
|
||||||
|
|
||||||
setUploadEntry(key, {
|
setUploadEntry(key, {
|
||||||
status: 'uploaded',
|
status: 'uploaded',
|
||||||
@@ -283,6 +253,7 @@ export const useUploadStore = defineStore('upload', () => {
|
|||||||
} else {
|
} else {
|
||||||
setUploadEntry(key, { status: 'skipped', message: UPLOAD_SKIPPED_METADATA_MESSAGE });
|
setUploadEntry(key, { status: 'skipped', message: UPLOAD_SKIPPED_METADATA_MESSAGE });
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -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 };
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ export type UploadQueueEntry =
|
|||||||
| { status: 'idle'; message: string }
|
| { status: 'idle'; message: string }
|
||||||
| { status: 'queued'; message: string }
|
| { status: 'queued'; message: string }
|
||||||
| { status: 'preparing'; message: string }
|
| { status: 'preparing'; message: string }
|
||||||
| { status: 'uploading'; message: string; uploadPercent?: number | null }
|
| { status: 'uploading'; message: string }
|
||||||
| {
|
| {
|
||||||
status: 'uploaded';
|
status: 'uploaded';
|
||||||
message: string;
|
message: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user