feat: update demo page + add city_id for media and articles
This commit is contained in:
@@ -4,9 +4,12 @@ import {
|
||||
editSightStore,
|
||||
generateDefaultMediaName,
|
||||
clearBlobAndGLTFCache,
|
||||
authStore,
|
||||
snapshotStore,
|
||||
} from "@shared";
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { useEffect, useState, useRef } from "react";
|
||||
import { toast } from "react-toastify";
|
||||
import {
|
||||
Dialog,
|
||||
DialogTitle,
|
||||
@@ -247,12 +250,16 @@ export const UploadMediaDialog = observer(
|
||||
setIsLoading(true);
|
||||
setError(null);
|
||||
|
||||
const uploadStartTime = Date.now();
|
||||
|
||||
try {
|
||||
const effectiveMediaType = hardcodeType
|
||||
? (MEDIA_TYPE_VALUES[hardcodeType] as number)
|
||||
: mediaType;
|
||||
|
||||
const media = await uploadMedia(
|
||||
mediaFilename,
|
||||
hardcodeType
|
||||
? (MEDIA_TYPE_VALUES[hardcodeType] as number)
|
||||
: mediaType,
|
||||
effectiveMediaType,
|
||||
mediaFile,
|
||||
mediaName
|
||||
);
|
||||
@@ -263,6 +270,40 @@ export const UploadMediaDialog = observer(
|
||||
await afterUpload(media);
|
||||
}
|
||||
}
|
||||
|
||||
if (effectiveMediaType === 2) {
|
||||
const uploadDurationSec = Math.round((Date.now() - uploadStartTime) / 1000);
|
||||
const minutes = Math.floor(uploadDurationSec / 60);
|
||||
const seconds = uploadDurationSec % 60;
|
||||
const durationStr = minutes > 0
|
||||
? `${minutes} мин ${seconds} сек`
|
||||
: `${seconds} сек`;
|
||||
|
||||
const fileSizeMb = mediaFile.size / (1024 * 1024);
|
||||
const fileSizeStr = fileSizeMb >= 1024
|
||||
? `${(fileSizeMb / 1024).toFixed(2)} ГБ`
|
||||
: `${fileSizeMb.toFixed(1)} МБ`;
|
||||
|
||||
if (authStore.canRead("snapshots")) {
|
||||
try {
|
||||
await snapshotStore.getStorageInfo();
|
||||
const storage = snapshotStore.storageInfo;
|
||||
if (storage) {
|
||||
toast.success(
|
||||
`Видео (${fileSizeStr}) загружено за ${durationStr}. Свободно на диске: ${storage.available_disk_space_gb.toFixed(2)} ГБ из ${storage.total_disk_space_gb.toFixed(2)} ГБ`,
|
||||
{ autoClose: 8000 }
|
||||
);
|
||||
} else {
|
||||
toast.success(`Видео (${fileSizeStr}) загружено за ${durationStr}`, { autoClose: 6000 });
|
||||
}
|
||||
} catch {
|
||||
toast.success(`Видео (${fileSizeStr}) загружено за ${durationStr}`, { autoClose: 6000 });
|
||||
}
|
||||
} else {
|
||||
toast.success(`Видео (${fileSizeStr}) загружено за ${durationStr}`, { autoClose: 6000 });
|
||||
}
|
||||
}
|
||||
|
||||
setSuccess(true);
|
||||
|
||||
setTimeout(() => {
|
||||
|
||||
Reference in New Issue
Block a user