refactor: standardize design

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-03-03 21:55:48 -05:00
parent 31a33d8758
commit a59dbff9f1
25 changed files with 994 additions and 306 deletions
+18 -13
View File
@@ -6,15 +6,16 @@
import { ref, computed } from 'vue'
import type { Ref, ComputedRef } from 'vue'
import { useNodesStore, ROOT_ID } from '@FilesManager/stores/nodesStore'
import { FileEntityObject } from '@FilesManager/models/entity'
import { useNodesStore, ROOT_ID } from '@DocumentsManager/stores/nodesStore'
import { EntityObject } from '@DocumentsManager/models/entity'
import type { DocumentInterface } from '@DocumentsManager/types/document'
export interface FileUploadProgress {
file: File
progress: number
status: 'pending' | 'uploading' | 'completed' | 'error'
error?: string
entity?: FileEntityObject
entity?: EntityObject
/** Relative path within folder upload (e.g., "folder/subfolder/file.txt") */
relativePath?: string
}
@@ -230,9 +231,9 @@ export function useFileUpload(options: UseFileUploadOptions) {
providerId,
serviceId,
parentId,
{ label: folderName }
{ label: folderName, owner: '' }
)
folderIdMap.set(folderPath, collection.id)
folderIdMap.set(folderPath, String(collection.identifier))
} catch (e) {
console.error(`Failed to create folder: ${folderPath}`, e)
// Try to continue with other folders
@@ -246,7 +247,7 @@ export function useFileUpload(options: UseFileUploadOptions) {
const uploadFile = async (
uploadId: string,
folderIdMap?: Map<string, string>
): Promise<FileEntityObject | null> => {
): Promise<EntityObject | null> => {
const upload = uploads.value.get(uploadId)
if (!upload || upload.status !== 'pending') {
return null
@@ -278,12 +279,16 @@ export function useFileUpload(options: UseFileUploadOptions) {
const entity = await nodesStore.createEntity(
providerId,
serviceId,
targetCollection,
targetCollection || ROOT_ID,
{
'@type': 'documents.properties',
urid: null,
format: null,
encoding: null,
label: upload.file.name,
mime: upload.file.type || 'application/octet-stream',
size: upload.file.size,
}
} as DocumentInterface
)
upload.progress = 75
@@ -292,8 +297,8 @@ export function useFileUpload(options: UseFileUploadOptions) {
await nodesStore.writeEntity(
providerId,
serviceId,
targetCollection,
entity.id,
targetCollection || ROOT_ID,
String(entity.identifier),
content
)
@@ -325,9 +330,9 @@ export function useFileUpload(options: UseFileUploadOptions) {
}
// Upload all pending files
const uploadAll = async (): Promise<FileEntityObject[]> => {
const uploadAll = async (): Promise<EntityObject[]> => {
isUploading.value = true
const entities: FileEntityObject[] = []
const entities: EntityObject[] = []
try {
// Check if any uploads have relative paths (folder upload)
@@ -377,7 +382,7 @@ export function useFileUpload(options: UseFileUploadOptions) {
}
// Retry a failed upload
const retryUpload = async (uploadId: string): Promise<FileEntityObject | null> => {
const retryUpload = async (uploadId: string): Promise<EntityObject | null> => {
const upload = uploads.value.get(uploadId)
if (!upload || upload.status !== 'error') {
return null