Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
WIP: Real API calls
  • Loading branch information
DrJKL committed Dec 1, 2025
commit 3a18d27b9d7e02b69b3f1a94568ccbd0dcbec9fc
8 changes: 5 additions & 3 deletions src/components/dialog/confirm/ConfirmBody.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
<div
class="flex flex-col px-4 py-2 text-sm text-muted-foreground border-t border-border-default"
>
<p v-if="confirmationText">
{{ confirmationText }}
<p v-if="promptText">
{{ promptText }}
</p>
</div>
</template>
<script setup lang="ts">
import type { MaybeRefOrGetter } from 'vue'

defineProps<{
confirmationText?: string
promptText?: MaybeRefOrGetter<string>
}>()
</script>
19 changes: 14 additions & 5 deletions src/platform/assets/components/AssetCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ import EditableText from '@/components/common/EditableText.vue'
import { showConfirmDialog } from '@/components/dialog/confirm/confirmDialog'
import AssetBadgeGroup from '@/platform/assets/components/AssetBadgeGroup.vue'
import type { AssetDisplayItem } from '@/platform/assets/composables/useAssetBrowser'
import { assetService } from '@/platform/assets/services/assetService'
import { useSettingStore } from '@/platform/settings/settingStore'
import { useDialogStore } from '@/stores/dialogStore'
import { cn } from '@/utils/tailwindUtil'
Expand Down Expand Up @@ -163,15 +164,14 @@ const { isLoading, error } = useImage({
alt: asset.name
})

async function confirmDeletion() {
function confirmDeletion() {
dropdownMenuButton.value?.hide()
const confirmDialog = showConfirmDialog({
headerProps: {
title: 'Delete this model?'
},
props: {
confirmationText:
'This model will be permanently removed from your library.'
promptText: 'This model will be permanently removed from your library.'
},
footerProps: {
confirmText: 'Delete',
Expand All @@ -182,7 +182,13 @@ async function confirmDeletion() {
onCancel: () => {
closeDialog(confirmDialog)
},
onConfirm: () => {
onConfirm: async () => {
try {
await assetService.deleteAsset(asset.id)
// TODO: Remove this from the list on success.
} catch (err: unknown) {
console.error(err)
}
closeDialog(confirmDialog)
}
}
Expand All @@ -194,9 +200,12 @@ function startAssetRename() {
isEditing.value = true
}

function assetRename(newName?: string) {
async function assetRename(newName?: string) {
isEditing.value = false
if (newName) {
await assetService.updateAsset(asset.id, {
name: newName
})
newNameRef.value = newName
}
}
Expand Down
27 changes: 27 additions & 0 deletions src/platform/assets/services/assetService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,32 @@ function createAssetService() {
}
}

/**
* Updae metadata of an asset by ID
* Only available in cloud environment
*
* @param id - The asset ID (UUID)
* @param newData - The data to update
* @returns Promise<void>
* @throws Error if update fails
*/
async function updateAsset(
id: string,
newData: Partial<AssetMetadata>
): Promise<string> {
const res = await api.fetchApi(`${ASSETS_ENDPOINT}/${id}`, {
method: 'PUT',
body: JSON.stringify(newData)
})

if (!res.ok) {
throw new Error(
`Unable to update asset ${id}: Server returned ${res.status}`
)
}
return res.json()
}

/**
* Retrieves metadata from a download URL without downloading the file
*
Expand Down Expand Up @@ -360,6 +386,7 @@ function createAssetService() {
getAssetDetails,
getAssetsByTag,
deleteAsset,
updateAsset,
getAssetMetadata,
uploadAssetFromUrl
}
Expand Down