Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"@primevue/themes": "^4.0.7",
"@vueuse/core": "^11.3.0",
"dayjs": "^1.11.13",
"js-yaml": "^4.1.0",
"lodash": "^4.17.21",
"markdown-it": "^14.1.0",
"markdown-it-metadata-block": "^1.0.6",
Expand Down
12 changes: 3 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

171 changes: 168 additions & 3 deletions src/components/DialogCreateTask.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,27 @@
</template>
</ResponseInput>

<!-- Direct file URL indicator with folder selection -->
<div v-if="isDirectFile && modelUrl" class="flex flex-col gap-2">
<div
class="flex items-center gap-2 rounded bg-green-50 p-2 text-sm text-green-600"
>
<i class="pi pi-check-circle"></i>
<span>Direct file download detected</span>
</div>

<!-- Model Type/Folder Selection for direct downloads -->
<div class="flex items-center gap-2">
<label class="text-sm font-medium">{{ $t('modelType') }}:</label>
<ResponseSelect
v-model="selectedModelType"
:items="modelTypeOptions"
:type="'drop'"
class="flex-1"
/>
</div>
</div>

<div v-show="data.length > 0">
<ResponseSelect
v-model="current"
Expand Down Expand Up @@ -79,8 +100,13 @@ import { request } from 'hooks/request'
import { useToast } from 'hooks/toast'
import Button from 'primevue/button'
import { VersionModel, WithResolved } from 'types/typings'
import { previewUrlToFile } from 'utils/common'
import { ref } from 'vue'
import {
getFilenameFromUrl,
getModelTypeFromFilename,
isDirectFileUrl,
previewUrlToFile,
} from 'utils/common'
import { computed, ref, watch } from 'vue'

const { isMobile } = useConfig()
const { toast } = useToast()
Expand All @@ -89,14 +115,153 @@ const dialog = useDialog()

const modelUrl = ref<string>()

// Model type selection for direct downloads
const selectedModelType = ref<string>('checkpoints')

const modelTypeOptions = computed(() => [
{
label: 'Checkpoints',
value: 'checkpoints',
command: () => {
selectedModelType.value = 'checkpoints'
},
},
{
label: 'LoRA',
value: 'loras',
command: () => {
selectedModelType.value = 'loras'
},
},
{
label: 'ControlNet',
value: 'controlnet',
command: () => {
selectedModelType.value = 'controlnet'
},
},
{
label: 'VAE',
value: 'vae',
command: () => {
selectedModelType.value = 'vae'
},
},
{
label: 'Embeddings',
value: 'embeddings',
command: () => {
selectedModelType.value = 'embeddings'
},
},
{
label: 'Upscale Models',
value: 'upscale_models',
command: () => {
selectedModelType.value = 'upscale_models'
},
},
{
label: 'Diffusers',
value: 'diffusers',
command: () => {
selectedModelType.value = 'diffusers'
},
},
{
label: 'CLIP',
value: 'clip',
command: () => {
selectedModelType.value = 'clip'
},
},
{
label: 'CLIP Vision',
value: 'clip_vision',
command: () => {
selectedModelType.value = 'clip_vision'
},
},
{
label: 'UNet/Diffusion Models',
value: 'diffusion_models',
command: () => {
selectedModelType.value = 'diffusion_models'
},
},
{
label: 'Style Models',
value: 'style_models',
command: () => {
selectedModelType.value = 'style_models'
},
},
{
label: 'Hypernetworks',
value: 'hypernetworks',
command: () => {
selectedModelType.value = 'hypernetworks'
},
},
{
label: 'GLIGEN',
value: 'gligen',
command: () => {
selectedModelType.value = 'gligen'
},
},
{
label: 'PhotoMaker',
value: 'photomaker',
command: () => {
selectedModelType.value = 'photomaker'
},
},
{
label: 'VAE Approx',
value: 'vae_approx',
command: () => {
selectedModelType.value = 'vae_approx'
},
},
{
label: 'Classifiers',
value: 'classifiers',
command: () => {
selectedModelType.value = 'classifiers'
},
},
])

const isDirectFile = computed(() =>
modelUrl.value ? isDirectFileUrl(modelUrl.value) : false,
)

const { current, currentModel, data, search } = useModelSearch()

const searchModelsByUrl = async () => {
if (modelUrl.value) {
await search(modelUrl.value)
const modelType = isDirectFile.value ? selectedModelType.value : undefined
await search(modelUrl.value, modelType)
}
}

// Watch for direct file URL changes and set intelligent default
watch(modelUrl, (newUrl) => {
if (newUrl && isDirectFileUrl(newUrl)) {
const filename = getFilenameFromUrl(newUrl)
const suggestedType = getModelTypeFromFilename(filename)
selectedModelType.value = suggestedType
}
})

// Watch for model type changes on direct files and refresh the model
watch(selectedModelType, async () => {
if (isDirectFile.value && modelUrl.value) {
await search(modelUrl.value, selectedModelType.value)
}
})

const createDownTask = async (data: WithResolved<VersionModel>) => {
loading.show()

Expand Down
Loading
Loading