2026-09-01 08:43:25 +02:00
|
|
|
<script lang="ts">
|
|
|
|
|
import {
|
|
|
|
|
AlertTriangle,
|
|
|
|
|
ArrowDown,
|
|
|
|
|
ArrowUp,
|
|
|
|
|
Check,
|
|
|
|
|
CircleHelp,
|
|
|
|
|
HardDrive,
|
|
|
|
|
Plus,
|
|
|
|
|
RefreshCw,
|
|
|
|
|
Save,
|
|
|
|
|
Server,
|
|
|
|
|
SlidersHorizontal,
|
|
|
|
|
Trash2,
|
|
|
|
|
} from '@lucide/svelte'
|
|
|
|
|
import { onDestroy, onMount } from 'svelte'
|
2026-09-03 00:16:55 +02:00
|
|
|
import { Badge, Button, Card, EmptyState, notify, SectionTitle } from '@gabriel20xx/web-ui'
|
2026-09-01 08:43:25 +02:00
|
|
|
import { get, post } from '$lib/api'
|
|
|
|
|
import { pageActions } from '$lib/stores/page-actions.svelte'
|
|
|
|
|
|
|
|
|
|
type Json = Record<string, unknown>
|
2026-09-03 00:16:55 +02:00
|
|
|
type StatusTone = 'default' | 'primary' | 'success' | 'warning' | 'danger'
|
2026-09-01 08:43:25 +02:00
|
|
|
type ConnectionStatus = { label: string; tone: StatusTone; title?: string }
|
|
|
|
|
type MountEntry = { type: string; path: string }
|
|
|
|
|
type TransferLimit = { uploadKbps: string; downloadKbps: string }
|
|
|
|
|
type LoginState = Record<string, boolean>
|
|
|
|
|
type PageOption = { label: string; token: string }
|
|
|
|
|
type ExternalConnection = {
|
|
|
|
|
id: string
|
|
|
|
|
label: string
|
|
|
|
|
baseUrl: string
|
|
|
|
|
queuePauseEnabled: boolean
|
|
|
|
|
queuePausePath: string
|
|
|
|
|
queuePauseDurationSeconds: string
|
|
|
|
|
queuePauseEndpointUrl: string
|
|
|
|
|
uploadLimitKbps: string
|
|
|
|
|
downloadLimitKbps: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type SettingsResponse = { settings?: Record<string, unknown> }
|
|
|
|
|
|
|
|
|
|
const DEFAULT_PROJECTS = [
|
|
|
|
|
'MediaConfig',
|
|
|
|
|
'MediaModerator',
|
|
|
|
|
'MediaViewer',
|
|
|
|
|
'MediaTools',
|
|
|
|
|
'MediaAnalyzer',
|
|
|
|
|
'MediaDownloader',
|
|
|
|
|
'MediaKiosk',
|
|
|
|
|
'MediaServant',
|
|
|
|
|
'MediaMobile',
|
|
|
|
|
]
|
|
|
|
|
const ALL_MONOREPO_PROJECTS = [
|
|
|
|
|
'MediaAnalyzer',
|
|
|
|
|
'MediaDesktop',
|
|
|
|
|
'MediaDownloader',
|
|
|
|
|
'MediaTools',
|
|
|
|
|
'MediaKiosk',
|
|
|
|
|
'MediaMobile',
|
|
|
|
|
'MediaModerator',
|
|
|
|
|
'MediaServant',
|
|
|
|
|
'MediaViewer',
|
|
|
|
|
]
|
|
|
|
|
const NO_MOUNTS_PROJECTS = ['MediaConfig', 'MediaServant', 'MediaMobile']
|
|
|
|
|
const DEFAULT_EXTERNAL_QUEUE_PAUSE_PATH = '/api/job_pops/pause'
|
|
|
|
|
const FALLBACK_MOUNT_TYPES = ['media', 'thumbnails', 'input', 'output', 'copy', 'loras', 'models', 'downloads']
|
|
|
|
|
const PORT_MAP: Record<string, string> = {
|
|
|
|
|
mediamoderator: '8090',
|
|
|
|
|
mediaviewer: '8080',
|
|
|
|
|
mediatools: '8080',
|
|
|
|
|
mediaanalyzer: '3000',
|
|
|
|
|
mediadownloader: '8082',
|
|
|
|
|
mediakiosk: '8095',
|
|
|
|
|
mediaservant: '3003',
|
|
|
|
|
mediaconfig: '3005',
|
|
|
|
|
}
|
|
|
|
|
const PROJECT_AVAILABLE_MOUNTS: Record<string, string[]> = {
|
|
|
|
|
mediamoderator: ['media', 'thumbnails'],
|
|
|
|
|
mediaviewer: ['media', 'thumbnails', 'funscripts'],
|
|
|
|
|
mediatools: ['downloads', 'generated', 'converted', 'converter input', 'generator input', 'generator copy'],
|
|
|
|
|
mediadownloader: ['downloads'],
|
|
|
|
|
mediaanalyzer: ['images', 'videos', 'audios', 'funscripts', 'models', 'thumbnails'],
|
|
|
|
|
mediaservant: ['media', 'output'],
|
|
|
|
|
mediakiosk: ['media'],
|
|
|
|
|
mediaconfig: [],
|
|
|
|
|
}
|
|
|
|
|
const PROJECT_PAGE_OPTIONS: Record<string, PageOption[]> = {
|
|
|
|
|
mediaanalyzer: [
|
|
|
|
|
{ label: 'Analyzer', token: '/' },
|
|
|
|
|
{ label: 'Converter', token: '/convert' },
|
|
|
|
|
{ label: 'About', token: '/about' },
|
|
|
|
|
],
|
|
|
|
|
mediaconfig: [
|
|
|
|
|
{ label: 'Mounts', token: '/' },
|
|
|
|
|
{ label: 'Parameters', token: '/parameters' },
|
|
|
|
|
{ label: 'About', token: '/about' },
|
|
|
|
|
],
|
|
|
|
|
mediadisktop: [{ label: 'Desktop App', token: '/' }],
|
|
|
|
|
mediadownloader: [
|
|
|
|
|
{ label: 'Downloader', token: '#' },
|
|
|
|
|
{ label: 'Scheduler', token: '#schedules' },
|
|
|
|
|
{ label: 'Downloads', token: '#downloads' },
|
|
|
|
|
],
|
|
|
|
|
mediatools: [
|
|
|
|
|
{ label: 'Generator', token: '/' },
|
|
|
|
|
{ label: 'Downloader', token: '/downloader' },
|
|
|
|
|
{ label: 'Converter', token: '/converter' },
|
|
|
|
|
{ label: 'Schedules', token: '/schedules' },
|
|
|
|
|
{ label: 'Library', token: '/library' },
|
|
|
|
|
{ label: 'About', token: '/about' },
|
|
|
|
|
],
|
|
|
|
|
mediakiosk: [
|
|
|
|
|
{ label: 'Kiosk', token: '/' },
|
|
|
|
|
{ label: 'About', token: '/about' },
|
|
|
|
|
],
|
|
|
|
|
mediamobile: [{ label: 'Mobile App', token: '/' }],
|
|
|
|
|
mediamoderator: [
|
|
|
|
|
{ label: 'Dashboard', token: '/' },
|
|
|
|
|
{ label: 'Users', token: '/users' },
|
|
|
|
|
{ label: 'Media', token: '/media' },
|
|
|
|
|
{ label: 'About', token: '/about' },
|
|
|
|
|
],
|
|
|
|
|
mediaservant: [
|
|
|
|
|
{ label: 'Overview', token: '/' },
|
|
|
|
|
{ label: 'Files', token: '/files' },
|
|
|
|
|
{ label: 'About', token: '/about' },
|
|
|
|
|
],
|
|
|
|
|
mediaviewer: [
|
|
|
|
|
{ label: 'Library', token: '/' },
|
|
|
|
|
{ label: 'Feed', token: '/feed' },
|
|
|
|
|
{ label: 'Search', token: '/search' },
|
|
|
|
|
{ label: 'Playlists', token: '/playlists' },
|
|
|
|
|
{ label: 'Tags', token: '/tags' },
|
|
|
|
|
{ label: 'About', token: '/about' },
|
|
|
|
|
],
|
|
|
|
|
}
|
|
|
|
|
// Extra feature-setting prefixes for a project's base instance, beyond its own `${key}_` connection settings.
|
|
|
|
|
const PROJECT_SETTING_PREFIXES: Record<string, string[]> = {
|
|
|
|
|
mediatools: ['converter_', 'mediatools_'],
|
|
|
|
|
mediaanalyzer: ['analyzer_', 'conversion_settings', 'mediaanalyzer_'],
|
|
|
|
|
mediakiosk: [
|
|
|
|
|
'kiosk_',
|
|
|
|
|
'mediakiosk_',
|
|
|
|
|
'server_display_duration',
|
|
|
|
|
'default_display_duration',
|
|
|
|
|
'default_preload_count',
|
|
|
|
|
],
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let { panel = 'mounts' }: { panel?: string } = $props()
|
|
|
|
|
let settings = $state<Record<string, string>>({})
|
|
|
|
|
let projects = $state<string[]>([...DEFAULT_PROJECTS])
|
|
|
|
|
let mounts = $state<Record<string, MountEntry[]>>({})
|
|
|
|
|
let urls = $state<Record<string, string>>({})
|
|
|
|
|
let labels = $state<Record<string, string>>({})
|
|
|
|
|
let transferLimits = $state<Record<string, TransferLimit>>({})
|
|
|
|
|
let loginStates = $state<Record<string, LoginState>>({})
|
|
|
|
|
let externalConnections = $state<ExternalConnection[]>([])
|
|
|
|
|
let statuses = $state<Record<string, ConnectionStatus>>({})
|
|
|
|
|
let projectToAdd = $state('')
|
|
|
|
|
let loading = $state(true)
|
|
|
|
|
let saving = $state(false)
|
|
|
|
|
let checkingAll = $state(false)
|
|
|
|
|
let error = $state('')
|
|
|
|
|
let saveTimer: ReturnType<typeof setTimeout> | undefined
|
|
|
|
|
|
|
|
|
|
const regularProjects = $derived(projects.filter((project) => project !== 'MediaConfig' && !isServant(project)))
|
|
|
|
|
const servantProjects = $derived(projects.filter((project) => isServant(project)))
|
|
|
|
|
|
|
|
|
|
const settingGroups = $derived.by(() => {
|
|
|
|
|
const allKeys = Object.keys(settings)
|
|
|
|
|
|
|
|
|
|
const projectMatchers = projects.map((project) => {
|
|
|
|
|
const baseKey = projectKey(getBaseProject(project))
|
|
|
|
|
const instanceKey = projectKey(project)
|
|
|
|
|
const isPrimary = instanceKey === baseKey
|
|
|
|
|
const prefixes = isPrimary ? [`${baseKey}_`, ...(PROJECT_SETTING_PREFIXES[baseKey] || [])] : [`${instanceKey}_`]
|
|
|
|
|
const siblingPrefixes = isPrimary
|
|
|
|
|
? projects
|
|
|
|
|
.filter(
|
|
|
|
|
(other) =>
|
|
|
|
|
other !== project && projectKey(getBaseProject(other)) === baseKey && projectKey(other) !== baseKey,
|
|
|
|
|
)
|
|
|
|
|
.map((other) => `${projectKey(other)}_`)
|
|
|
|
|
: []
|
|
|
|
|
const matches = (key: string) =>
|
|
|
|
|
prefixes.some((prefix) => key.startsWith(prefix)) && !siblingPrefixes.some((prefix) => key.startsWith(prefix))
|
|
|
|
|
return { title: getInstanceLabel(project), matches }
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const projectGroups = projectMatchers
|
|
|
|
|
.map(({ title, matches }) => ({
|
|
|
|
|
key: title,
|
|
|
|
|
title,
|
|
|
|
|
entries: allKeys.filter((key) => matches(key)).map((key) => [key, settings[key]] as [string, string]),
|
|
|
|
|
}))
|
|
|
|
|
.filter((group) => group.entries.length > 0)
|
|
|
|
|
|
|
|
|
|
const globalEntries = allKeys
|
|
|
|
|
.filter((key) => !projectMatchers.some(({ matches }) => matches(key)))
|
|
|
|
|
.map((key) => [key, settings[key]] as [string, string])
|
|
|
|
|
|
|
|
|
|
return { projectGroups, globalEntries }
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
function stringValue(value: unknown): string {
|
|
|
|
|
return value === undefined || value === null ? '' : String(value)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function parseJson<T>(value: unknown, fallback: T): T {
|
|
|
|
|
if (typeof value !== 'string' || !value.trim()) return fallback
|
|
|
|
|
try {
|
|
|
|
|
return JSON.parse(value) as T
|
|
|
|
|
} catch {
|
|
|
|
|
return fallback
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function projectKey(project: string): string {
|
|
|
|
|
return String(project || '').toLowerCase()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getBaseProject(project: string): string {
|
|
|
|
|
return String(project || '').replace(/_\d+$/, '')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getInstanceLabel(project: string): string {
|
|
|
|
|
const match = String(project || '').match(/_(\d+)$/)
|
|
|
|
|
return match ? `${getBaseProject(project)} (${match[1]})` : project
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function isServant(project: string): boolean {
|
|
|
|
|
return getBaseProject(project).toLowerCase() === 'mediaservant'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function isNoMounts(project: string): boolean {
|
|
|
|
|
return NO_MOUNTS_PROJECTS.some((item) => item.toLowerCase() === getBaseProject(project).toLowerCase())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function normalizePageToken(value: unknown): string {
|
|
|
|
|
const raw = stringValue(value).trim()
|
|
|
|
|
if (!raw) return '/'
|
|
|
|
|
if (raw.startsWith('#')) return raw.toLowerCase()
|
|
|
|
|
try {
|
|
|
|
|
const parsed = new URL(raw, 'http://localhost')
|
|
|
|
|
const pathname = String(parsed.pathname || '/').toLowerCase()
|
|
|
|
|
const search = parsed.searchParams.toString().toLowerCase()
|
|
|
|
|
const hash = String(parsed.hash || '').toLowerCase()
|
|
|
|
|
if (hash && (pathname === '/' || pathname === '') && !search) return hash
|
|
|
|
|
return search ? `${pathname}?${search}` : pathname
|
|
|
|
|
} catch {
|
|
|
|
|
return raw.toLowerCase()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function pageOptionsFor(project: string): PageOption[] {
|
|
|
|
|
const configured = PROJECT_PAGE_OPTIONS[getBaseProject(project).toLowerCase()]
|
|
|
|
|
return (configured && configured.length > 0 ? configured : [{ label: 'Main', token: '/' }]).map((page) => ({
|
|
|
|
|
label: page.label,
|
|
|
|
|
token: normalizePageToken(page.token),
|
|
|
|
|
}))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function isEnabledFlag(value: unknown): boolean {
|
|
|
|
|
if (value === true || value === 1) return true
|
|
|
|
|
const normalized = stringValue(value).trim().toLowerCase()
|
|
|
|
|
return normalized === 'true' || normalized === '1' || normalized === 'yes' || normalized === 'on'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function buildLoginState(project: string, rawValue: unknown): LoginState {
|
|
|
|
|
const state: LoginState = {}
|
|
|
|
|
const pageOptions = pageOptionsFor(project)
|
|
|
|
|
pageOptions.forEach((page) => {
|
|
|
|
|
state[page.token] = false
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
if (isEnabledFlag(rawValue)) {
|
|
|
|
|
pageOptions.forEach((page) => {
|
|
|
|
|
state[page.token] = true
|
|
|
|
|
})
|
|
|
|
|
return state
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (rawValue && typeof rawValue === 'object' && !Array.isArray(rawValue)) {
|
|
|
|
|
const normalizedRaw: Record<string, boolean> = {}
|
|
|
|
|
Object.entries(rawValue as Json).forEach(([rawToken, rawFlag]) => {
|
|
|
|
|
if (rawToken.startsWith('__') || !isEnabledFlag(rawFlag)) return
|
|
|
|
|
normalizedRaw[normalizePageToken(rawToken)] = true
|
|
|
|
|
})
|
|
|
|
|
pageOptions.forEach((page) => {
|
|
|
|
|
state[page.token] = normalizedRaw[page.token] === true
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
return state
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function loginChecked(project: string, token: string): boolean {
|
|
|
|
|
return loginStates[projectKey(project)]?.[token] === true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function serializeLoginState(project: string): boolean | Record<string, boolean> {
|
|
|
|
|
const options = pageOptionsFor(project)
|
|
|
|
|
const state = loginStates[projectKey(project)] || buildLoginState(project, false)
|
|
|
|
|
const selected = options.filter((page) => state[page.token] === true)
|
|
|
|
|
if (selected.length === 0) return false
|
|
|
|
|
if (selected.length === options.length) return true
|
|
|
|
|
return Object.fromEntries(selected.map((page) => [page.token, true]))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function normalizeProjects(rawValue: unknown): string[] {
|
|
|
|
|
const rawProjects = Array.isArray(rawValue) ? rawValue : DEFAULT_PROJECTS
|
|
|
|
|
const seen: string[] = []
|
|
|
|
|
const configured: string[] = []
|
|
|
|
|
for (const rawProject of rawProjects) {
|
|
|
|
|
const project = stringValue(rawProject).trim()
|
|
|
|
|
if (!project || projectKey(project) === 'mediaconfig' || seen.includes(projectKey(project))) continue
|
|
|
|
|
seen.push(projectKey(project))
|
|
|
|
|
configured.push(project)
|
|
|
|
|
}
|
|
|
|
|
return ['MediaConfig', ...configured]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function normalizeMounts(rawValue: unknown): Record<string, MountEntry[]> {
|
|
|
|
|
const normalized: Record<string, MountEntry[]> = {}
|
|
|
|
|
if (!rawValue || typeof rawValue !== 'object' || Array.isArray(rawValue)) return normalized
|
|
|
|
|
Object.entries(rawValue as Json).forEach(([rawProject, rawEntries]) => {
|
|
|
|
|
if (!Array.isArray(rawEntries)) return
|
|
|
|
|
normalized[projectKey(rawProject)] = rawEntries.map((rawEntry) => {
|
|
|
|
|
const entry = rawEntry && typeof rawEntry === 'object' ? (rawEntry as Json) : {}
|
|
|
|
|
return { type: stringValue(entry.type), path: stringValue(entry.path) }
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
return normalized
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function mountsFromLegacyMappings(rawValue: unknown): Record<string, MountEntry[]> {
|
|
|
|
|
const converted: Record<string, MountEntry[]> = {}
|
|
|
|
|
if (!rawValue || typeof rawValue !== 'object' || Array.isArray(rawValue)) return converted
|
|
|
|
|
Object.entries(rawValue as Json).forEach(([rawProject, rawGroups]) => {
|
|
|
|
|
if (!rawGroups || typeof rawGroups !== 'object' || Array.isArray(rawGroups)) return
|
|
|
|
|
const entries: MountEntry[] = []
|
|
|
|
|
Object.entries(rawGroups as Json).forEach(([type, rawPaths]) => {
|
|
|
|
|
const paths = Array.isArray(rawPaths) ? rawPaths : [rawPaths]
|
|
|
|
|
paths.forEach((rawPath) => {
|
|
|
|
|
const path = stringValue(rawPath).trim()
|
|
|
|
|
if (path) entries.push({ type, path })
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
if (entries.length > 0) converted[projectKey(rawProject)] = entries
|
|
|
|
|
})
|
|
|
|
|
return converted
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function createExternalConnectionId(): string {
|
|
|
|
|
return `ext_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function normalizeExternalConnection(rawValue: unknown): ExternalConnection {
|
|
|
|
|
const raw = rawValue && typeof rawValue === 'object' && !Array.isArray(rawValue) ? (rawValue as Json) : {}
|
|
|
|
|
const pausePath = stringValue(raw.queuePausePath).trim()
|
|
|
|
|
return {
|
|
|
|
|
id: stringValue(raw.id).trim() || createExternalConnectionId(),
|
|
|
|
|
label: stringValue(raw.label).trim(),
|
|
|
|
|
baseUrl: stringValue(raw.baseUrl).trim(),
|
|
|
|
|
queuePauseEnabled: isEnabledFlag(raw.queuePauseEnabled),
|
|
|
|
|
queuePausePath: pausePath || DEFAULT_EXTERNAL_QUEUE_PAUSE_PATH,
|
|
|
|
|
queuePauseDurationSeconds: stringValue(raw.queuePauseDurationSeconds).trim(),
|
|
|
|
|
queuePauseEndpointUrl: stringValue(raw.queuePauseEndpointUrl).trim(),
|
|
|
|
|
uploadLimitKbps: stringValue(raw.uploadLimitKbps).trim(),
|
|
|
|
|
downloadLimitKbps: stringValue(raw.downloadLimitKbps).trim(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function normalizeExternalConnections(rawValue: unknown): ExternalConnection[] {
|
|
|
|
|
if (!Array.isArray(rawValue)) return []
|
|
|
|
|
const usedIds: string[] = []
|
|
|
|
|
return rawValue.map((rawConnection) => {
|
|
|
|
|
const connection = normalizeExternalConnection(rawConnection)
|
|
|
|
|
let id = connection.id
|
|
|
|
|
while (usedIds.includes(id)) id = createExternalConnectionId()
|
|
|
|
|
usedIds.push(id)
|
|
|
|
|
return { ...connection, id }
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function createEmptyExternalConnection(): ExternalConnection {
|
|
|
|
|
return normalizeExternalConnection({ queuePausePath: DEFAULT_EXTERNAL_QUEUE_PAUSE_PATH })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function normalizeUrl(rawValue: string, id = ''): string {
|
|
|
|
|
let value = rawValue.trim()
|
|
|
|
|
if (!value) return value
|
|
|
|
|
if (!/^https?:\/\//i.test(value)) value = `http://${value}`
|
|
|
|
|
const match = value.match(/^(https?):\/\/([^/?#]+)([/?#].*)?$/i)
|
|
|
|
|
if (!match) return value
|
|
|
|
|
const port = PORT_MAP[getBaseProject(id).toLowerCase()]
|
|
|
|
|
const authority = match[2]
|
|
|
|
|
const hasPort = authority.startsWith('[') ? /^\[[^\]]+\]:\d+$/.test(authority) : /:\d+$/.test(authority)
|
|
|
|
|
if (port && !hasPort) {
|
|
|
|
|
value = `${match[1]}://${authority}:${port}${match[3] || ''}`
|
|
|
|
|
}
|
|
|
|
|
return value.replace(/\/$/, '')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function eventValue(event: Event): string {
|
|
|
|
|
return (event.currentTarget as HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement).value
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function eventChecked(event: Event): boolean {
|
|
|
|
|
return (event.currentTarget as HTMLInputElement).checked
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function scheduleSave() {
|
|
|
|
|
if (saveTimer) clearTimeout(saveTimer)
|
|
|
|
|
saveTimer = setTimeout(() => {
|
|
|
|
|
saveTimer = undefined
|
|
|
|
|
void save()
|
|
|
|
|
}, 600)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function setUrl(project: string, value: string) {
|
|
|
|
|
const key = projectKey(project)
|
|
|
|
|
urls = { ...urls, [key]: value }
|
|
|
|
|
settings = { ...settings, [`${key}_url`]: value }
|
|
|
|
|
scheduleSave()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function setLabel(project: string, value: string) {
|
|
|
|
|
const key = projectKey(project)
|
|
|
|
|
labels = { ...labels, [key]: value }
|
|
|
|
|
settings = { ...settings, [`${key}_label`]: value }
|
|
|
|
|
scheduleSave()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function setTransferLimit(project: string, field: keyof TransferLimit, value: string) {
|
|
|
|
|
const key = projectKey(project)
|
|
|
|
|
transferLimits = {
|
|
|
|
|
...transferLimits,
|
|
|
|
|
[key]: {
|
|
|
|
|
uploadKbps: transferLimits[key]?.uploadKbps || '',
|
|
|
|
|
downloadKbps: transferLimits[key]?.downloadKbps || '',
|
|
|
|
|
[field]: value,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
settings = { ...settings, [`${key}_${field === 'uploadKbps' ? 'upload' : 'download'}_limit_kbps`]: value }
|
|
|
|
|
scheduleSave()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function updateSetting(key: string, value: string) {
|
|
|
|
|
settings = { ...settings, [key]: value }
|
|
|
|
|
scheduleSave()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function updateLoginState(project: string, token: string, enabled: boolean) {
|
|
|
|
|
const key = projectKey(project)
|
|
|
|
|
const current = loginStates[key] || buildLoginState(project, false)
|
|
|
|
|
loginStates = { ...loginStates, [key]: { ...current, [token]: enabled } }
|
|
|
|
|
scheduleSave()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function setLoginForAll(project: string, enabled: boolean) {
|
|
|
|
|
const state: LoginState = {}
|
|
|
|
|
pageOptionsFor(project).forEach((page) => {
|
|
|
|
|
state[page.token] = enabled
|
|
|
|
|
})
|
|
|
|
|
loginStates = { ...loginStates, [projectKey(project)]: state }
|
|
|
|
|
void save()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function availableMountTypes(project: string, currentType = ''): string[] {
|
|
|
|
|
const configured = PROJECT_AVAILABLE_MOUNTS[getBaseProject(project).toLowerCase()] || FALLBACK_MOUNT_TYPES
|
|
|
|
|
return currentType && !configured.includes(currentType) ? [...configured, currentType] : configured
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function updateMount(project: string, index: number, field: keyof MountEntry, value: string) {
|
|
|
|
|
const key = projectKey(project)
|
|
|
|
|
const current = mounts[key] || []
|
|
|
|
|
const next = current.map((mount, mountIndex) => (mountIndex === index ? { ...mount, [field]: value } : mount))
|
|
|
|
|
mounts = { ...mounts, [key]: next }
|
|
|
|
|
scheduleSave()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function addMount(project: string) {
|
|
|
|
|
const key = projectKey(project)
|
|
|
|
|
mounts = { ...mounts, [key]: [...(mounts[key] || []), { type: '', path: '' }] }
|
|
|
|
|
void save()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function removeMount(project: string, index: number) {
|
|
|
|
|
const key = projectKey(project)
|
|
|
|
|
mounts = { ...mounts, [key]: (mounts[key] || []).filter((_, mountIndex) => mountIndex !== index) }
|
|
|
|
|
void save()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function moveMount(project: string, index: number, direction: -1 | 1) {
|
|
|
|
|
const key = projectKey(project)
|
|
|
|
|
const next = [...(mounts[key] || [])]
|
|
|
|
|
const target = index + direction
|
|
|
|
|
if (target < 0 || target >= next.length) return
|
|
|
|
|
const [moved] = next.splice(index, 1)
|
|
|
|
|
next.splice(target, 0, moved)
|
|
|
|
|
mounts = { ...mounts, [key]: next }
|
|
|
|
|
void save()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function updateExternal(id: string, field: keyof Omit<ExternalConnection, 'id'>, value: string | boolean) {
|
|
|
|
|
externalConnections = externalConnections.map((connection) =>
|
|
|
|
|
connection.id === id ? { ...connection, [field]: value } : connection,
|
|
|
|
|
)
|
|
|
|
|
scheduleSave()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function addExternal() {
|
|
|
|
|
externalConnections = [...externalConnections, createEmptyExternalConnection()]
|
|
|
|
|
void save()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function removeExternal(id: string) {
|
|
|
|
|
externalConnections = externalConnections.filter((connection) => connection.id !== id)
|
|
|
|
|
statuses = Object.fromEntries(Object.entries(statuses).filter(([key]) => key !== `external:${id}`))
|
|
|
|
|
void save()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function addProject() {
|
|
|
|
|
const base = projectToAdd
|
|
|
|
|
if (!base) return
|
|
|
|
|
let candidate = base
|
|
|
|
|
let number = 2
|
|
|
|
|
while (projects.some((project) => project.toLowerCase() === candidate.toLowerCase())) {
|
|
|
|
|
candidate = `${base}_${number++}`
|
|
|
|
|
}
|
|
|
|
|
projects = [...projects, candidate]
|
|
|
|
|
projectToAdd = ''
|
|
|
|
|
void save()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function removeProject(project: string) {
|
|
|
|
|
if (projectKey(project) === 'mediaconfig') return
|
|
|
|
|
projects = projects.filter((item) => item !== project)
|
|
|
|
|
void save()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function moveProject(project: string, direction: -1 | 1) {
|
|
|
|
|
const next = [...regularProjects]
|
|
|
|
|
const index = next.indexOf(project)
|
|
|
|
|
const target = index + direction
|
|
|
|
|
if (index < 0 || target < 0 || target >= next.length) return
|
|
|
|
|
const [moved] = next.splice(index, 1)
|
|
|
|
|
next.splice(target, 0, moved)
|
|
|
|
|
projects = ['MediaConfig', ...next, ...servantProjects]
|
|
|
|
|
void save()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function addServant() {
|
|
|
|
|
let candidate = 'MediaServant'
|
|
|
|
|
let number = 2
|
|
|
|
|
while (projects.some((project) => project.toLowerCase() === candidate.toLowerCase())) {
|
|
|
|
|
candidate = `MediaServant_${number++}`
|
|
|
|
|
}
|
|
|
|
|
projects = [...projects, candidate]
|
|
|
|
|
void save()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function removeServant(project: string) {
|
|
|
|
|
projects = projects.filter((item) => item !== project)
|
|
|
|
|
void save()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function moveServant(project: string, direction: -1 | 1) {
|
|
|
|
|
const regular = projects.filter((item) => !isServant(item))
|
|
|
|
|
const servants = [...servantProjects]
|
|
|
|
|
const index = servants.indexOf(project)
|
|
|
|
|
const target = index + direction
|
|
|
|
|
if (index < 0 || target < 0 || target >= servants.length) return
|
|
|
|
|
const [moved] = servants.splice(index, 1)
|
|
|
|
|
servants.splice(target, 0, moved)
|
|
|
|
|
projects = [...regular, ...servants]
|
|
|
|
|
void save()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function statusFor(key: string): ConnectionStatus {
|
2026-09-03 00:16:55 +02:00
|
|
|
return statuses[key] || { label: 'Unknown', tone: 'default' }
|
2026-09-01 08:43:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function checkTarget(key: string, rawUrl: string, project: string | null, id: string) {
|
|
|
|
|
const url = normalizeUrl(rawUrl, id)
|
|
|
|
|
if (url && id) {
|
|
|
|
|
urls = { ...urls, [id]: url }
|
|
|
|
|
}
|
|
|
|
|
if (!url) {
|
2026-09-03 00:16:55 +02:00
|
|
|
statuses = { ...statuses, [key]: { label: 'No URL', tone: 'default' } }
|
2026-09-01 08:43:25 +02:00
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
statuses = { ...statuses, [key]: { label: 'Checking…', tone: 'primary' } }
|
|
|
|
|
try {
|
|
|
|
|
const result = await post<{ ok?: boolean; service?: string | null; mismatch?: boolean; error?: string }>(
|
|
|
|
|
'/api/check-connection',
|
|
|
|
|
{ url, project },
|
|
|
|
|
)
|
|
|
|
|
if (!result.ok) {
|
|
|
|
|
statuses = { ...statuses, [key]: { label: 'Offline', tone: 'danger' } }
|
|
|
|
|
} else if (result.mismatch) {
|
|
|
|
|
const service = result.service || 'unknown service'
|
|
|
|
|
statuses = {
|
|
|
|
|
...statuses,
|
|
|
|
|
[key]: {
|
|
|
|
|
label: `Wrong: ${service}`,
|
|
|
|
|
tone: 'warning',
|
|
|
|
|
title: project ? `Expected ${project} but got ${service}` : undefined,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
statuses = { ...statuses, [key]: { label: 'Connected', tone: 'success' } }
|
|
|
|
|
}
|
|
|
|
|
} catch {
|
|
|
|
|
statuses = { ...statuses, [key]: { label: 'Error', tone: 'danger' } }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function checkConnection(projectOrKey: string) {
|
|
|
|
|
const key = projectKey(projectOrKey)
|
|
|
|
|
const configuredProject = projects.find((project) => projectKey(project) === key)
|
|
|
|
|
const project = configuredProject ? getBaseProject(configuredProject) : key === 'comfyui' ? 'comfyui' : null
|
|
|
|
|
await checkTarget(key, urls[key] || '', project, key)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function checkExternalConnection(id: string) {
|
|
|
|
|
const connection = externalConnections.find((item) => item.id === id)
|
|
|
|
|
if (!connection) return
|
|
|
|
|
const url = normalizeUrl(connection.baseUrl)
|
|
|
|
|
if (url !== connection.baseUrl) {
|
|
|
|
|
externalConnections = externalConnections.map((item) => (item.id === id ? { ...item, baseUrl: url } : item))
|
|
|
|
|
}
|
|
|
|
|
await checkTarget(`external:${id}`, url, null, '')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function checkAllConnections() {
|
|
|
|
|
checkingAll = true
|
|
|
|
|
try {
|
|
|
|
|
await checkConnection('comfyui')
|
|
|
|
|
for (const connection of externalConnections) await checkExternalConnection(connection.id)
|
|
|
|
|
await checkConnection('mediaconfig')
|
|
|
|
|
for (const servant of servantProjects) await checkConnection(servant)
|
|
|
|
|
for (const project of regularProjects) await checkConnection(project)
|
|
|
|
|
} finally {
|
|
|
|
|
checkingAll = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function buildPayload(): Record<string, string> {
|
|
|
|
|
const payload: Record<string, string> = { ...settings }
|
|
|
|
|
payload.comfyui_url = normalizeUrl(urls.comfyui || '', 'comfyui')
|
|
|
|
|
|
|
|
|
|
projects.forEach((project) => {
|
|
|
|
|
const key = projectKey(project)
|
|
|
|
|
payload[`${key}_url`] = normalizeUrl(urls[key] || '', key)
|
|
|
|
|
payload[`${key}_label`] = labels[key] || ''
|
|
|
|
|
if (!isNoMounts(project)) {
|
|
|
|
|
payload[`${key}_upload_limit_kbps`] = transferLimits[key]?.uploadKbps || ''
|
|
|
|
|
payload[`${key}_download_limit_kbps`] = transferLimits[key]?.downloadKbps || ''
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const configuredLabels: Record<string, string> = {}
|
|
|
|
|
projects.forEach((project) => {
|
|
|
|
|
configuredLabels[projectKey(project)] = labels[projectKey(project)] || ''
|
|
|
|
|
})
|
|
|
|
|
const configuredLogin: Record<string, boolean | Record<string, boolean>> = {}
|
|
|
|
|
projects.forEach((project) => {
|
|
|
|
|
configuredLogin[projectKey(project)] = serializeLoginState(project)
|
|
|
|
|
})
|
|
|
|
|
const cleanedMounts: Record<string, MountEntry[]> = {}
|
|
|
|
|
Object.entries(mounts).forEach(([key, entries]) => {
|
|
|
|
|
const valid = entries.filter((entry) => entry.type.trim() || entry.path.trim())
|
|
|
|
|
if (valid.length > 0) cleanedMounts[key] = valid
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
payload.configured_projects = JSON.stringify(projects)
|
|
|
|
|
payload.configured_labels = JSON.stringify(configuredLabels)
|
|
|
|
|
payload.configured_login_required = JSON.stringify(configuredLogin)
|
|
|
|
|
payload.configured_mounts = JSON.stringify(cleanedMounts)
|
|
|
|
|
payload.configured_external_connections = JSON.stringify(normalizeExternalConnections(externalConnections))
|
|
|
|
|
return payload
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function save() {
|
|
|
|
|
if (saving) return
|
|
|
|
|
saving = true
|
|
|
|
|
try {
|
|
|
|
|
const payload = buildPayload()
|
|
|
|
|
await post('/api/settings', payload)
|
|
|
|
|
settings = { ...settings, ...payload }
|
|
|
|
|
notify.success('Settings saved.')
|
|
|
|
|
} catch (reason) {
|
|
|
|
|
notify.error(reason instanceof Error ? reason.message : 'Unable to save settings.')
|
|
|
|
|
} finally {
|
|
|
|
|
saving = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function load() {
|
|
|
|
|
loading = true
|
|
|
|
|
error = ''
|
|
|
|
|
try {
|
|
|
|
|
const response = await get<SettingsResponse>('/api/settings')
|
|
|
|
|
const nextSettings: Record<string, string> = {}
|
|
|
|
|
Object.entries(response.settings || {}).forEach(([key, value]) => {
|
|
|
|
|
nextSettings[key] = stringValue(value)
|
|
|
|
|
})
|
|
|
|
|
settings = nextSettings
|
|
|
|
|
|
|
|
|
|
const configuredProjects = parseJson<unknown>(nextSettings.configured_projects, DEFAULT_PROJECTS)
|
|
|
|
|
const nextProjects = normalizeProjects(configuredProjects)
|
|
|
|
|
projects = nextProjects
|
|
|
|
|
|
|
|
|
|
const configuredMounts = parseJson<unknown>(nextSettings.configured_mounts, null)
|
|
|
|
|
const legacyMappings = parseJson<unknown>(nextSettings.mounts_path_mappings, null)
|
|
|
|
|
mounts = normalizeMounts(configuredMounts || mountsFromLegacyMappings(legacyMappings))
|
|
|
|
|
|
|
|
|
|
const configuredLabels = parseJson<Json>(nextSettings.configured_labels, {})
|
|
|
|
|
const nextUrls: Record<string, string> = { comfyui: nextSettings.comfyui_url || '' }
|
|
|
|
|
const nextLabels: Record<string, string> = {}
|
|
|
|
|
const nextLimits: Record<string, TransferLimit> = {}
|
|
|
|
|
nextProjects.forEach((project) => {
|
|
|
|
|
const key = projectKey(project)
|
|
|
|
|
nextUrls[key] = nextSettings[`${key}_url`] || ''
|
|
|
|
|
nextLabels[key] = stringValue(configuredLabels[key] ?? nextSettings[`${key}_label`])
|
|
|
|
|
nextLimits[key] = {
|
|
|
|
|
uploadKbps: nextSettings[`${key}_upload_limit_kbps`] || '',
|
|
|
|
|
downloadKbps: nextSettings[`${key}_download_limit_kbps`] || '',
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
urls = nextUrls
|
|
|
|
|
labels = nextLabels
|
|
|
|
|
transferLimits = nextLimits
|
|
|
|
|
|
|
|
|
|
const configuredLogin = parseJson<Json>(nextSettings.configured_login_required, {})
|
|
|
|
|
const nextLoginStates: Record<string, LoginState> = {}
|
|
|
|
|
nextProjects.forEach((project) => {
|
|
|
|
|
const key = projectKey(project)
|
|
|
|
|
const baseKey = projectKey(getBaseProject(project))
|
|
|
|
|
nextLoginStates[key] = buildLoginState(project, configuredLogin[key] ?? configuredLogin[baseKey])
|
|
|
|
|
})
|
|
|
|
|
loginStates = nextLoginStates
|
|
|
|
|
externalConnections = normalizeExternalConnections(
|
|
|
|
|
parseJson<unknown>(nextSettings.configured_external_connections, []),
|
|
|
|
|
)
|
|
|
|
|
statuses = {}
|
|
|
|
|
} catch (reason) {
|
|
|
|
|
error = reason instanceof Error ? reason.message : 'Unable to load configuration.'
|
|
|
|
|
} finally {
|
|
|
|
|
loading = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onMount(() => {
|
|
|
|
|
void load().then(() => {
|
|
|
|
|
if (panel === 'mounts') return checkConnection('mediaconfig')
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
onDestroy(() => {
|
|
|
|
|
if (saveTimer) clearTimeout(saveTimer)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
$effect(() => {
|
|
|
|
|
pageActions.snippet = saveAction
|
|
|
|
|
return () => {
|
|
|
|
|
if (pageActions.snippet === saveAction) pageActions.snippet = null
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
{#snippet saveAction()}
|
|
|
|
|
<Button size="sm" onclick={() => void save()} disabled={saving || loading}>
|
|
|
|
|
<Save class="size-4" />{saving ? 'Saving...' : 'Save'}
|
|
|
|
|
</Button>
|
|
|
|
|
{/snippet}
|
|
|
|
|
|
|
|
|
|
{#snippet settingFields(entries: [string, string][])}
|
|
|
|
|
<div class="grid gap-4 sm:grid-cols-2">
|
|
|
|
|
{#each entries as [key, value] (key)}
|
|
|
|
|
<label class="block text-xs font-medium text-muted-fg">
|
|
|
|
|
{key.replaceAll('_', ' ')}
|
|
|
|
|
<input
|
|
|
|
|
{value}
|
|
|
|
|
oninput={(event) => updateSetting(key, eventValue(event))}
|
|
|
|
|
class="mt-1 h-10 w-full rounded-md border border-border bg-bg px-3 text-sm text-fg outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
|
|
|
/>
|
|
|
|
|
</label>
|
|
|
|
|
{/each}
|
|
|
|
|
</div>
|
|
|
|
|
{/snippet}
|
|
|
|
|
|
|
|
|
|
{#snippet loginControls(project: string)}
|
|
|
|
|
<div class="rounded-md border border-border bg-bg/70 p-3">
|
|
|
|
|
<div class="flex items-center justify-between gap-2">
|
|
|
|
|
<span class="text-xs font-semibold text-fg">Require Login Per Tab/Page</span>
|
|
|
|
|
<div class="inline-flex items-center gap-1">
|
|
|
|
|
<Button variant="secondary" size="sm" onclick={() => setLoginForAll(project, true)}>All</Button>
|
|
|
|
|
<Button variant="secondary" size="sm" onclick={() => setLoginForAll(project, false)}>None</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="mt-3 grid grid-cols-1 gap-2 sm:grid-cols-2">
|
|
|
|
|
{#each pageOptionsFor(project) as page (page.token)}
|
|
|
|
|
<label class="inline-flex items-center gap-2 text-xs text-muted-fg">
|
|
|
|
|
<input
|
|
|
|
|
type="checkbox"
|
|
|
|
|
checked={loginChecked(project, page.token)}
|
|
|
|
|
onchange={(event) => updateLoginState(project, page.token, eventChecked(event))}
|
|
|
|
|
class="size-4 rounded border-border bg-bg accent-primary"
|
|
|
|
|
/>
|
|
|
|
|
<span>{page.label}</span>
|
|
|
|
|
</label>
|
|
|
|
|
{/each}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
{/snippet}
|
|
|
|
|
|
|
|
|
|
<div class="space-y-4">
|
|
|
|
|
{#if error}
|
|
|
|
|
<div class="flex items-center gap-2 rounded-md border border-danger/30 bg-danger/10 px-4 py-3 text-sm text-danger">
|
|
|
|
|
<AlertTriangle class="size-4" />{error}
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
|
|
{#if loading}
|
|
|
|
|
<div class="media-shimmer h-64 rounded-lg border border-border"></div>
|
|
|
|
|
{:else if panel === 'mounts'}
|
|
|
|
|
<Card class="space-y-5">
|
|
|
|
|
<SectionTitle
|
|
|
|
|
title="Main instances"
|
|
|
|
|
description="Connect the local ComfyUI dependency, external services, and this MediaConfig instance."
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<div class="rounded-md border border-border bg-bg/60 p-4">
|
|
|
|
|
<div class="flex flex-wrap items-center justify-between gap-3">
|
|
|
|
|
<div>
|
|
|
|
|
<p class="text-sm font-semibold text-fg">ComfyUI</p>
|
|
|
|
|
<p class="mt-1 text-xs text-muted-fg">The image-generation service used by MediaTools.</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="flex items-center gap-2">
|
2026-09-03 00:16:55 +02:00
|
|
|
<Badge variant={statusFor('comfyui').tone} title={statusFor('comfyui').title}
|
2026-09-01 08:43:25 +02:00
|
|
|
>{statusFor('comfyui').label}</Badge
|
|
|
|
|
>
|
|
|
|
|
<Button variant="secondary" size="sm" onclick={() => void checkConnection('comfyui')}>Check</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<label class="mt-4 block text-xs font-medium text-muted-fg">
|
|
|
|
|
ComfyUI URL
|
|
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
value={urls.comfyui || ''}
|
|
|
|
|
oninput={(event) => setUrl('comfyui', eventValue(event))}
|
|
|
|
|
placeholder="http://localhost:8188"
|
|
|
|
|
class="mt-1 h-10 w-full rounded-md border border-border bg-surface px-3 text-sm text-fg outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
|
|
|
/>
|
|
|
|
|
</label>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="border-t border-border pt-5">
|
|
|
|
|
<div class="flex flex-wrap items-start justify-between gap-3">
|
|
|
|
|
<SectionTitle
|
|
|
|
|
title="External connections"
|
|
|
|
|
description="Optional services can pause their queue and use MediaServant bandwidth limits."
|
|
|
|
|
/>
|
|
|
|
|
<Button variant="secondary" size="sm" onclick={addExternal}><Plus class="size-4" />Add connection</Button>
|
|
|
|
|
</div>
|
|
|
|
|
{#if externalConnections.length === 0}
|
|
|
|
|
<p class="mt-4 text-xs italic text-muted-fg">No external connections configured.</p>
|
|
|
|
|
{:else}
|
|
|
|
|
<div class="mt-4 space-y-4">
|
|
|
|
|
{#each externalConnections as connection, index (connection.id)}
|
|
|
|
|
<div class="rounded-md border border-border bg-bg/60 p-4">
|
|
|
|
|
<div class="flex flex-wrap items-center justify-between gap-3">
|
|
|
|
|
<div class="flex items-center gap-2">
|
|
|
|
|
<p class="text-sm font-semibold text-fg">
|
|
|
|
|
{connection.label || `External Connection ${index + 1}`}
|
|
|
|
|
</p>
|
|
|
|
|
<Badge
|
2026-09-03 00:16:55 +02:00
|
|
|
variant={statusFor(`external:${connection.id}`).tone}
|
2026-09-01 08:43:25 +02:00
|
|
|
title={statusFor(`external:${connection.id}`).title}
|
|
|
|
|
>
|
|
|
|
|
{statusFor(`external:${connection.id}`).label}
|
|
|
|
|
</Badge>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="flex items-center gap-2">
|
|
|
|
|
<Button variant="secondary" size="sm" onclick={() => void checkExternalConnection(connection.id)}
|
|
|
|
|
>Check</Button
|
|
|
|
|
>
|
|
|
|
|
<Button
|
|
|
|
|
variant="danger"
|
|
|
|
|
size="icon"
|
|
|
|
|
aria-label="Remove external connection"
|
|
|
|
|
title="Remove connection"
|
|
|
|
|
onclick={() => removeExternal(connection.id)}><Trash2 class="size-4" /></Button
|
|
|
|
|
>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="mt-4 grid gap-4 md:grid-cols-2">
|
|
|
|
|
<label class="block text-xs font-medium text-muted-fg">
|
|
|
|
|
Display Name
|
|
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
value={connection.label}
|
|
|
|
|
oninput={(event) => updateExternal(connection.id, 'label', eventValue(event))}
|
|
|
|
|
placeholder={`External Connection ${index + 1}`}
|
|
|
|
|
class="mt-1 h-10 w-full rounded-md border border-border bg-surface px-3 text-sm text-fg outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
|
|
|
/>
|
|
|
|
|
</label>
|
|
|
|
|
<label class="block text-xs font-medium text-muted-fg">
|
|
|
|
|
Base URL
|
|
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
value={connection.baseUrl}
|
|
|
|
|
oninput={(event) => updateExternal(connection.id, 'baseUrl', eventValue(event))}
|
|
|
|
|
placeholder="http://service:3000"
|
|
|
|
|
class="mt-1 h-10 w-full rounded-md border border-border bg-surface px-3 text-sm text-fg outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
|
|
|
/>
|
|
|
|
|
</label>
|
|
|
|
|
<label class="block text-xs font-medium text-muted-fg">
|
|
|
|
|
Pause Endpoint Path
|
|
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
value={connection.queuePausePath}
|
|
|
|
|
oninput={(event) => updateExternal(connection.id, 'queuePausePath', eventValue(event))}
|
|
|
|
|
placeholder={DEFAULT_EXTERNAL_QUEUE_PAUSE_PATH}
|
|
|
|
|
class="mt-1 h-10 w-full rounded-md border border-border bg-surface px-3 text-sm text-fg outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
|
|
|
/>
|
|
|
|
|
</label>
|
|
|
|
|
<label class="block text-xs font-medium text-muted-fg">
|
|
|
|
|
Pause Endpoint URL (optional)
|
|
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
value={connection.queuePauseEndpointUrl}
|
|
|
|
|
oninput={(event) => updateExternal(connection.id, 'queuePauseEndpointUrl', eventValue(event))}
|
|
|
|
|
placeholder="Uses the base URL when blank"
|
|
|
|
|
class="mt-1 h-10 w-full rounded-md border border-border bg-surface px-3 text-sm text-fg outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
|
|
|
/>
|
|
|
|
|
</label>
|
|
|
|
|
<label class="block text-xs font-medium text-muted-fg">
|
|
|
|
|
Pause Duration (seconds)
|
|
|
|
|
<input
|
|
|
|
|
type="number"
|
|
|
|
|
min="0"
|
|
|
|
|
step="1"
|
|
|
|
|
value={connection.queuePauseDurationSeconds}
|
|
|
|
|
oninput={(event) => updateExternal(connection.id, 'queuePauseDurationSeconds', eventValue(event))}
|
|
|
|
|
placeholder="0"
|
|
|
|
|
class="mt-1 h-10 w-full rounded-md border border-border bg-surface px-3 text-sm text-fg outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
|
|
|
/>
|
|
|
|
|
</label>
|
|
|
|
|
<div class="flex items-end">
|
|
|
|
|
<label class="inline-flex items-center gap-2 pb-2 text-xs text-muted-fg">
|
|
|
|
|
<input
|
|
|
|
|
type="checkbox"
|
|
|
|
|
checked={connection.queuePauseEnabled}
|
|
|
|
|
onchange={(event) => updateExternal(connection.id, 'queuePauseEnabled', eventChecked(event))}
|
|
|
|
|
class="size-4 rounded border-border bg-surface accent-primary"
|
|
|
|
|
/>
|
|
|
|
|
Use this connection for queue pause/resume
|
|
|
|
|
</label>
|
|
|
|
|
</div>
|
|
|
|
|
<label class="block text-xs font-medium text-muted-fg">
|
|
|
|
|
Upload Limit (KB/s)
|
|
|
|
|
<input
|
|
|
|
|
type="number"
|
|
|
|
|
min="0"
|
|
|
|
|
step="1"
|
|
|
|
|
value={connection.uploadLimitKbps}
|
|
|
|
|
oninput={(event) => updateExternal(connection.id, 'uploadLimitKbps', eventValue(event))}
|
|
|
|
|
placeholder="Unlimited"
|
|
|
|
|
class="mt-1 h-10 w-full rounded-md border border-border bg-surface px-3 text-sm text-fg outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
|
|
|
/>
|
|
|
|
|
</label>
|
|
|
|
|
<label class="block text-xs font-medium text-muted-fg">
|
|
|
|
|
Download Limit (KB/s)
|
|
|
|
|
<input
|
|
|
|
|
type="number"
|
|
|
|
|
min="0"
|
|
|
|
|
step="1"
|
|
|
|
|
value={connection.downloadLimitKbps}
|
|
|
|
|
oninput={(event) => updateExternal(connection.id, 'downloadLimitKbps', eventValue(event))}
|
|
|
|
|
placeholder="Unlimited"
|
|
|
|
|
class="mt-1 h-10 w-full rounded-md border border-border bg-surface px-3 text-sm text-fg outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
|
|
|
/>
|
|
|
|
|
</label>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
{/each}
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="border-t border-border pt-5">
|
|
|
|
|
<SectionTitle
|
|
|
|
|
title="MediaConfig instance"
|
|
|
|
|
description="The URL and page-level login rules used when other services link back here."
|
|
|
|
|
/>
|
|
|
|
|
<div class="mt-4 rounded-md border border-border bg-bg/60 p-4">
|
|
|
|
|
<div class="flex flex-wrap items-center justify-between gap-3">
|
|
|
|
|
<div class="flex items-center gap-2">
|
|
|
|
|
<p class="text-sm font-semibold text-fg">{labels.mediaconfig || 'MediaConfig'}</p>
|
|
|
|
|
{#if labels.mediaconfig}<span class="text-xs text-muted-fg">(MediaConfig)</span>{/if}
|
2026-09-03 00:16:55 +02:00
|
|
|
<Badge variant={statusFor('mediaconfig').tone} title={statusFor('mediaconfig').title}
|
2026-09-01 08:43:25 +02:00
|
|
|
>{statusFor('mediaconfig').label}</Badge
|
|
|
|
|
>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="flex items-center gap-2">
|
|
|
|
|
<Button variant="secondary" size="sm" onclick={() => void checkConnection('mediaconfig')}>Check</Button>
|
2026-09-03 00:16:55 +02:00
|
|
|
<Badge variant="primary"><Check class="size-3" />Self</Badge>
|
2026-09-01 08:43:25 +02:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="mt-4 grid gap-4 md:grid-cols-2">
|
|
|
|
|
<label class="block text-xs font-medium text-muted-fg">
|
|
|
|
|
Display Name
|
|
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
value={labels.mediaconfig || ''}
|
|
|
|
|
oninput={(event) => setLabel('MediaConfig', eventValue(event))}
|
|
|
|
|
placeholder="MediaConfig"
|
|
|
|
|
class="mt-1 h-10 w-full rounded-md border border-border bg-surface px-3 text-sm text-fg outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
|
|
|
/>
|
|
|
|
|
</label>
|
|
|
|
|
<label class="block text-xs font-medium text-muted-fg">
|
|
|
|
|
MediaConfig URL
|
|
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
value={urls.mediaconfig || ''}
|
|
|
|
|
oninput={(event) => setUrl('MediaConfig', eventValue(event))}
|
|
|
|
|
placeholder="http://localhost:3005"
|
|
|
|
|
class="mt-1 h-10 w-full rounded-md border border-border bg-surface px-3 text-sm text-fg outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
|
|
|
/>
|
|
|
|
|
</label>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="mt-4">{@render loginControls('MediaConfig')}</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</Card>
|
|
|
|
|
|
|
|
|
|
<Card class="space-y-5">
|
|
|
|
|
<div class="flex flex-wrap items-start justify-between gap-3">
|
|
|
|
|
<SectionTitle
|
|
|
|
|
title="MediaServant instances"
|
|
|
|
|
description="Configure the URL for each running MediaServant instance. All services use these URLs to proxy media requests."
|
|
|
|
|
/>
|
|
|
|
|
<Button variant="secondary" size="sm" onclick={addServant}><Plus class="size-4" />Add instance</Button>
|
|
|
|
|
</div>
|
|
|
|
|
{#if servantProjects.length === 0}
|
|
|
|
|
<EmptyState
|
|
|
|
|
title="No servant instances configured"
|
|
|
|
|
message="Add an instance to configure its URL and page-level login rules."
|
|
|
|
|
/>
|
|
|
|
|
{:else}
|
|
|
|
|
<div class="grid gap-4 md:grid-cols-2">
|
|
|
|
|
{#each servantProjects as project, index (project)}
|
|
|
|
|
<div class="min-w-0 rounded-md border border-border bg-bg/60 p-4">
|
|
|
|
|
<div class="flex flex-wrap items-center justify-between gap-3">
|
|
|
|
|
<div class="flex min-w-0 items-center gap-2">
|
|
|
|
|
<p class="truncate text-sm font-semibold text-fg">
|
|
|
|
|
{labels[projectKey(project)] || getInstanceLabel(project)}
|
|
|
|
|
</p>
|
|
|
|
|
{#if labels[projectKey(project)]}<span class="text-xs text-muted-fg"
|
|
|
|
|
>({getInstanceLabel(project)})</span
|
|
|
|
|
>{/if}
|
2026-09-03 00:16:55 +02:00
|
|
|
<Badge variant={statusFor(projectKey(project)).tone} title={statusFor(projectKey(project)).title}
|
2026-09-01 08:43:25 +02:00
|
|
|
>{statusFor(projectKey(project)).label}</Badge
|
|
|
|
|
>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="flex items-center gap-1">
|
|
|
|
|
<Button
|
|
|
|
|
variant="ghost"
|
|
|
|
|
size="icon"
|
|
|
|
|
aria-label="Move instance up"
|
|
|
|
|
title="Move up"
|
|
|
|
|
disabled={index === 0}
|
|
|
|
|
onclick={() => moveServant(project, -1)}><ArrowUp class="size-4" /></Button
|
|
|
|
|
>
|
|
|
|
|
<Button
|
|
|
|
|
variant="ghost"
|
|
|
|
|
size="icon"
|
|
|
|
|
aria-label="Move instance down"
|
|
|
|
|
title="Move down"
|
|
|
|
|
disabled={index === servantProjects.length - 1}
|
|
|
|
|
onclick={() => moveServant(project, 1)}><ArrowDown class="size-4" /></Button
|
|
|
|
|
>
|
|
|
|
|
<Button variant="secondary" size="sm" onclick={() => void checkConnection(project)}>Check</Button>
|
|
|
|
|
<Button
|
|
|
|
|
variant="danger"
|
|
|
|
|
size="icon"
|
|
|
|
|
aria-label="Remove instance"
|
|
|
|
|
title="Remove instance"
|
|
|
|
|
onclick={() => removeServant(project)}><Trash2 class="size-4" /></Button
|
|
|
|
|
>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="mt-4 space-y-4">
|
|
|
|
|
<label class="block text-xs font-medium text-muted-fg">
|
|
|
|
|
Display Name
|
|
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
value={labels[projectKey(project)] || ''}
|
|
|
|
|
oninput={(event) => setLabel(project, eventValue(event))}
|
|
|
|
|
placeholder={getInstanceLabel(project)}
|
|
|
|
|
class="mt-1 h-10 w-full rounded-md border border-border bg-surface px-3 text-sm text-fg outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
|
|
|
/>
|
|
|
|
|
</label>
|
|
|
|
|
<label class="block text-xs font-medium text-muted-fg">
|
|
|
|
|
MediaServant URL
|
|
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
value={urls[projectKey(project)] || ''}
|
|
|
|
|
oninput={(event) => setUrl(project, eventValue(event))}
|
|
|
|
|
placeholder="http://localhost:3003"
|
|
|
|
|
class="mt-1 h-10 w-full rounded-md border border-border bg-surface px-3 text-sm text-fg outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
|
|
|
/>
|
|
|
|
|
</label>
|
|
|
|
|
{@render loginControls(project)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
{/each}
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
</Card>
|
|
|
|
|
|
|
|
|
|
<Card class="space-y-5">
|
|
|
|
|
<div class="flex flex-wrap items-start justify-between gap-3">
|
|
|
|
|
<SectionTitle
|
|
|
|
|
title="Connected projects & mounts"
|
|
|
|
|
description="Configure URLs, global rules, and mount paths for active projects."
|
|
|
|
|
/>
|
|
|
|
|
<Button variant="secondary" size="sm" onclick={() => void checkAllConnections()} disabled={checkingAll}>
|
|
|
|
|
<RefreshCw class="size-4" />{checkingAll ? 'Checking…' : 'Check all'}
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="flex flex-col gap-2 sm:flex-row">
|
|
|
|
|
<select
|
|
|
|
|
value={projectToAdd}
|
|
|
|
|
onchange={(event) => (projectToAdd = eventValue(event))}
|
|
|
|
|
class="h-10 min-w-0 flex-1 rounded-md border border-border bg-bg px-3 text-sm text-fg outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
|
|
|
>
|
|
|
|
|
<option value="">Select a project to add…</option>
|
|
|
|
|
{#each ALL_MONOREPO_PROJECTS.filter((project) => !isServant(project)) as project (project)}
|
|
|
|
|
<option value={project}>{project}</option>
|
|
|
|
|
{/each}
|
|
|
|
|
</select>
|
|
|
|
|
<Button onclick={addProject} disabled={!projectToAdd}><Plus class="size-4" />Add</Button>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{#if regularProjects.length === 0}
|
|
|
|
|
<EmptyState
|
|
|
|
|
title="No connected projects"
|
|
|
|
|
message="Select a project above to add its URL, login rules, and mount paths."
|
|
|
|
|
/>
|
|
|
|
|
{:else}
|
|
|
|
|
<div class="grid gap-4 md:grid-cols-2 xl:grid-cols-3">
|
|
|
|
|
{#each regularProjects as project, index (project)}
|
|
|
|
|
{@const key = projectKey(project)}
|
|
|
|
|
<div class="min-w-0 rounded-md border border-border bg-bg/60 p-4">
|
|
|
|
|
<div class="flex items-start justify-between gap-3">
|
|
|
|
|
<div class="min-w-0">
|
|
|
|
|
<div class="flex min-w-0 flex-wrap items-center gap-2">
|
|
|
|
|
<p class="truncate text-sm font-semibold text-fg">{labels[key] || getInstanceLabel(project)}</p>
|
|
|
|
|
{#if labels[key]}<span class="text-xs text-muted-fg">({getInstanceLabel(project)})</span>{/if}
|
2026-09-03 00:16:55 +02:00
|
|
|
<Badge variant={statusFor(key).tone} title={statusFor(key).title}>{statusFor(key).label}</Badge>
|
2026-09-01 08:43:25 +02:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="flex shrink-0 items-center gap-1">
|
|
|
|
|
<Button
|
|
|
|
|
variant="ghost"
|
|
|
|
|
size="icon"
|
|
|
|
|
aria-label="Move project up"
|
|
|
|
|
title="Move up"
|
|
|
|
|
disabled={index === 0}
|
|
|
|
|
onclick={() => moveProject(project, -1)}><ArrowUp class="size-4" /></Button
|
|
|
|
|
>
|
|
|
|
|
<Button
|
|
|
|
|
variant="ghost"
|
|
|
|
|
size="icon"
|
|
|
|
|
aria-label="Move project down"
|
|
|
|
|
title="Move down"
|
|
|
|
|
disabled={index === regularProjects.length - 1}
|
|
|
|
|
onclick={() => moveProject(project, 1)}><ArrowDown class="size-4" /></Button
|
|
|
|
|
>
|
|
|
|
|
<Button variant="secondary" size="sm" onclick={() => void checkConnection(project)}>Check</Button>
|
|
|
|
|
<Button
|
|
|
|
|
variant="danger"
|
|
|
|
|
size="icon"
|
|
|
|
|
aria-label="Remove project"
|
|
|
|
|
title="Remove project"
|
|
|
|
|
onclick={() => removeProject(project)}><Trash2 class="size-4" /></Button
|
|
|
|
|
>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="mt-4 space-y-4">
|
|
|
|
|
<label class="block text-xs font-medium text-muted-fg">
|
|
|
|
|
Display Name
|
|
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
value={labels[key] || ''}
|
|
|
|
|
oninput={(event) => setLabel(project, eventValue(event))}
|
|
|
|
|
placeholder={getInstanceLabel(project)}
|
|
|
|
|
class="mt-1 h-10 w-full rounded-md border border-border bg-surface px-3 text-sm text-fg outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
|
|
|
/>
|
|
|
|
|
</label>
|
|
|
|
|
<label class="block text-xs font-medium text-muted-fg">
|
|
|
|
|
Project URL
|
|
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
value={urls[key] || ''}
|
|
|
|
|
oninput={(event) => setUrl(project, eventValue(event))}
|
|
|
|
|
placeholder="http://localhost or https://…"
|
|
|
|
|
class="mt-1 h-10 w-full rounded-md border border-border bg-surface px-3 text-sm text-fg outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
|
|
|
/>
|
|
|
|
|
</label>
|
|
|
|
|
{#if !isNoMounts(project)}
|
|
|
|
|
<div class="grid gap-3 sm:grid-cols-2">
|
|
|
|
|
<label class="block text-xs font-medium text-muted-fg">
|
|
|
|
|
MediaServant Upload Limit (KB/s)
|
|
|
|
|
<input
|
|
|
|
|
type="number"
|
|
|
|
|
min="0"
|
|
|
|
|
step="1"
|
|
|
|
|
value={transferLimits[key]?.uploadKbps || ''}
|
|
|
|
|
oninput={(event) => setTransferLimit(project, 'uploadKbps', eventValue(event))}
|
|
|
|
|
placeholder="Unlimited"
|
|
|
|
|
class="mt-1 h-10 w-full rounded-md border border-border bg-surface px-3 text-sm text-fg outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
|
|
|
/>
|
|
|
|
|
</label>
|
|
|
|
|
<label class="block text-xs font-medium text-muted-fg">
|
|
|
|
|
MediaServant Download Limit (KB/s)
|
|
|
|
|
<input
|
|
|
|
|
type="number"
|
|
|
|
|
min="0"
|
|
|
|
|
step="1"
|
|
|
|
|
value={transferLimits[key]?.downloadKbps || ''}
|
|
|
|
|
oninput={(event) => setTransferLimit(project, 'downloadKbps', eventValue(event))}
|
|
|
|
|
placeholder="Unlimited"
|
|
|
|
|
class="mt-1 h-10 w-full rounded-md border border-border bg-surface px-3 text-sm text-fg outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
|
|
|
/>
|
|
|
|
|
</label>
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
{@render loginControls(project)}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{#if !isNoMounts(project)}
|
|
|
|
|
<div class="mt-5 border-t border-border pt-4">
|
|
|
|
|
<div class="flex items-center justify-between gap-2">
|
|
|
|
|
<h4 class="text-xs font-semibold text-fg">Mount paths</h4>
|
|
|
|
|
<Button variant="secondary" size="sm" onclick={() => addMount(project)}
|
|
|
|
|
><Plus class="size-3" />Add mount</Button
|
|
|
|
|
>
|
|
|
|
|
</div>
|
|
|
|
|
{#if (mounts[key] || []).length === 0}
|
|
|
|
|
<p class="mt-3 text-xs italic text-muted-fg">No mounts configured.</p>
|
|
|
|
|
{:else}
|
|
|
|
|
<div class="mt-3 space-y-2">
|
|
|
|
|
{#each mounts[key] || [] as mount, mountIndex (mountIndex)}
|
|
|
|
|
<div class="flex flex-col gap-2 sm:flex-row sm:items-center">
|
|
|
|
|
<select
|
|
|
|
|
value={mount.type}
|
|
|
|
|
onchange={(event) => updateMount(project, mountIndex, 'type', eventValue(event))}
|
|
|
|
|
aria-label={`${getInstanceLabel(project)} mount type`}
|
|
|
|
|
class="h-9 w-full shrink-0 rounded-md border border-border bg-surface px-2 text-xs text-fg outline-none focus-visible:ring-2 focus-visible:ring-ring sm:w-32"
|
|
|
|
|
>
|
|
|
|
|
<option value="">Select type</option>
|
|
|
|
|
{#each availableMountTypes(project, mount.type) as type (type)}
|
|
|
|
|
<option value={type}>{type}</option>
|
|
|
|
|
{/each}
|
|
|
|
|
</select>
|
|
|
|
|
<div class="flex min-w-0 flex-1 items-center gap-2">
|
|
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
value={mount.path}
|
|
|
|
|
oninput={(event) => updateMount(project, mountIndex, 'path', eventValue(event))}
|
|
|
|
|
placeholder="Path (e.g. /mnt/media)"
|
|
|
|
|
class="h-9 min-w-0 flex-1 rounded-md border border-border bg-surface px-2 text-xs text-fg outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
|
|
|
/>
|
|
|
|
|
<div class="flex shrink-0 items-center gap-1">
|
|
|
|
|
<Button
|
|
|
|
|
variant="ghost"
|
|
|
|
|
size="icon"
|
|
|
|
|
aria-label="Move mount up"
|
|
|
|
|
title="Move up"
|
|
|
|
|
disabled={mountIndex === 0}
|
|
|
|
|
onclick={() => moveMount(project, mountIndex, -1)}><ArrowUp class="size-3" /></Button
|
|
|
|
|
>
|
|
|
|
|
<Button
|
|
|
|
|
variant="ghost"
|
|
|
|
|
size="icon"
|
|
|
|
|
aria-label="Move mount down"
|
|
|
|
|
title="Move down"
|
|
|
|
|
disabled={mountIndex === (mounts[key] || []).length - 1}
|
|
|
|
|
onclick={() => moveMount(project, mountIndex, 1)}><ArrowDown class="size-3" /></Button
|
|
|
|
|
>
|
|
|
|
|
<Button
|
|
|
|
|
variant="danger"
|
|
|
|
|
size="icon"
|
|
|
|
|
aria-label="Remove mount"
|
|
|
|
|
title="Remove mount"
|
|
|
|
|
onclick={() => removeMount(project, mountIndex)}><Trash2 class="size-3" /></Button
|
|
|
|
|
>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
{/each}
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|
|
|
|
|
{/each}
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
</Card>
|
|
|
|
|
{:else}
|
|
|
|
|
<div class="grid gap-4 lg:grid-cols-[minmax(0,1fr)_320px]">
|
|
|
|
|
<div class="space-y-4">
|
|
|
|
|
{#if Object.keys(settings).length === 0}
|
|
|
|
|
<Card class="space-y-5">
|
|
|
|
|
<SectionTitle
|
|
|
|
|
title="Global settings"
|
|
|
|
|
description="Values are stored by MediaConfig and consumed by the services at runtime."
|
|
|
|
|
/>
|
|
|
|
|
<EmptyState
|
|
|
|
|
title="No editable settings returned"
|
|
|
|
|
message="The settings API may require an administrator session or the database may still be initializing."
|
|
|
|
|
/>
|
|
|
|
|
</Card>
|
|
|
|
|
{:else}
|
|
|
|
|
<Card class="space-y-5">
|
|
|
|
|
<SectionTitle title="Global settings" description="Shared values that aren't scoped to a single project." />
|
|
|
|
|
{#if settingGroups.globalEntries.length === 0}
|
|
|
|
|
<p class="text-xs text-muted-fg">Every returned setting belongs to a specific project below.</p>
|
|
|
|
|
{:else}
|
|
|
|
|
{@render settingFields(settingGroups.globalEntries)}
|
|
|
|
|
{/if}
|
|
|
|
|
</Card>
|
|
|
|
|
{#each settingGroups.projectGroups as group (group.key)}
|
|
|
|
|
<Card class="space-y-5">
|
|
|
|
|
<SectionTitle title={group.title} />
|
|
|
|
|
{@render settingFields(group.entries)}
|
|
|
|
|
</Card>
|
|
|
|
|
{/each}
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|
|
|
|
|
<Card class="space-y-4">
|
|
|
|
|
<SectionTitle title="Configuration groups" />
|
|
|
|
|
<div class="space-y-3">
|
|
|
|
|
<div class="flex gap-3">
|
|
|
|
|
<SlidersHorizontal class="mt-0.5 size-4 text-primary" />
|
|
|
|
|
<div>
|
|
|
|
|
<p class="text-sm font-medium text-fg">Parameters</p>
|
|
|
|
|
<p class="mt-1 text-xs text-muted-fg">
|
|
|
|
|
Service concurrency, models, generators, converters, and viewer behavior.
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="flex gap-3">
|
|
|
|
|
<HardDrive class="mt-0.5 size-4 text-primary" />
|
|
|
|
|
<div>
|
|
|
|
|
<p class="text-sm font-medium text-fg">Mounts</p>
|
|
|
|
|
<p class="mt-1 text-xs text-muted-fg">
|
|
|
|
|
Shared file roots are configured in the Mounts workspace and resolved by MediaServant.
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="flex gap-3">
|
|
|
|
|
<CircleHelp class="mt-0.5 size-4 text-primary" />
|
|
|
|
|
<div>
|
|
|
|
|
<p class="text-sm font-medium text-fg">Runtime safety</p>
|
|
|
|
|
<p class="mt-1 text-xs text-muted-fg">Sensitive credentials are never echoed by the settings endpoint.</p>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="flex gap-3">
|
|
|
|
|
<Server class="mt-0.5 size-4 text-primary" />
|
|
|
|
|
<div>
|
|
|
|
|
<p class="text-sm font-medium text-fg">Service checks</p>
|
|
|
|
|
<p class="mt-1 text-xs text-muted-fg">
|
|
|
|
|
Connection checks verify health and warn when the responding service is not the expected project.
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</Card>
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|