✨ File bundle
This commit is contained in:
50
DysonNetwork.Drive/Client/src/components/BundleSelect.vue
Normal file
50
DysonNetwork.Drive/Client/src/components/BundleSelect.vue
Normal file
@@ -0,0 +1,50 @@
|
||||
<template>
|
||||
<n-select
|
||||
v-model:value="selectedBundle"
|
||||
:options="options"
|
||||
placeholder="Select a bundle"
|
||||
@update:value="handleBundleChange"
|
||||
filterable
|
||||
remote
|
||||
:loading="loading"
|
||||
@search="handleSearch"
|
||||
clearable
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { NSelect } from 'naive-ui'
|
||||
import { ref, onMounted } from 'vue'
|
||||
|
||||
const emit = defineEmits(['update:bundle'])
|
||||
|
||||
const selectedBundle = ref<string | null>(null)
|
||||
const loading = ref(false)
|
||||
const options = ref<any[]>([])
|
||||
|
||||
async function fetchBundles(term: string | null = null) {
|
||||
loading.value = true
|
||||
try {
|
||||
const resp = await fetch(`/api/bundles/me?${term ? `term=${term}` : ''}`)
|
||||
const data = await resp.json()
|
||||
options.value = data.map((bundle: any) => ({
|
||||
label: bundle.name,
|
||||
value: bundle.id,
|
||||
}))
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch bundles:', error)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handleSearch(query: string) {
|
||||
fetchBundles(query)
|
||||
}
|
||||
|
||||
function handleBundleChange(value: string) {
|
||||
emit('update:bundle', value)
|
||||
}
|
||||
|
||||
onMounted(() => fetchBundles())
|
||||
</script>
|
@@ -89,7 +89,7 @@ import type { SnFilePool } from '@/types/pool'
|
||||
|
||||
import * as tus from 'tus-js-client'
|
||||
|
||||
const props = defineProps<{ filePool: string | null; modeAdvanced: boolean; pools: SnFilePool[] }>()
|
||||
const props = defineProps<{ filePool: string | null; modeAdvanced: boolean; pools: SnFilePool[]; bundleId?: string }>()
|
||||
|
||||
const filePass = ref<string>('')
|
||||
const fileExpire = ref<number | null>(null)
|
||||
@@ -117,6 +117,7 @@ function customRequest({
|
||||
if (props.filePool) requestHeaders['X-FilePool'] = props.filePool
|
||||
if (filePass.value) requestHeaders['X-FilePass'] = filePass.value
|
||||
if (fileExpire.value) requestHeaders['X-FileExpire'] = fileExpire.value.toString()
|
||||
if (props.bundleId) requestHeaders['X-FileBundle'] = props.bundleId
|
||||
const upload = new tus.Upload(file.file, {
|
||||
endpoint: '/api/tus',
|
||||
retryDelays: [0, 3000, 5000, 10000, 20000],
|
||||
|
Reference in New Issue
Block a user