mirror of
https://github.com/MrPatben8/konduktor.git
synced 2026-11-27 10:22:51 +01:00
Implemented path remapping
This commit is contained in:
1 parent
1e8c53e693
commit
b130f1469e
12 files changed
+968
-16
No files matched your search
@@ -158,6 +158,34 @@ export interface SaveResult {
|
||||
playlists: number
|
||||
}
|
||||
|
||||
export interface PathMapping {
|
||||
from: string
|
||||
to: string
|
||||
}
|
||||
|
||||
export interface RemapSample {
|
||||
from: string
|
||||
to: string
|
||||
exists: boolean
|
||||
}
|
||||
|
||||
export interface RemapPreview {
|
||||
total: number
|
||||
matched: number
|
||||
existing: number
|
||||
samples: RemapSample[]
|
||||
}
|
||||
|
||||
export interface RemapResult {
|
||||
rewritten: number
|
||||
backup: string | null
|
||||
}
|
||||
|
||||
export interface PrefixSuggestions {
|
||||
primary: string
|
||||
groups: { prefix: string; count: number }[]
|
||||
}
|
||||
|
||||
// API origin. In the packaged desktop app the frontend is served from
|
||||
// tauri://localhost, so it can't use relative /api paths — the Tauri shell
|
||||
// injects window.__KONDUKTOR_API__ (the sidecar's http://127.0.0.1:<port>)
|
||||
@@ -211,6 +239,20 @@ export const api = {
|
||||
listDir: (path?: string) =>
|
||||
getJSON<FsListing>(`/api/fs/list${path ? `?path=${encodeURIComponent(path)}` : ''}`),
|
||||
|
||||
// ---- path remapping (per-collection OS-path prefix translation) ----
|
||||
getPathMapping: () => getJSON<PathMapping>('/api/collection/path-mapping'),
|
||||
suggestPrefix: () =>
|
||||
getJSON<PrefixSuggestions>('/api/collection/path-mapping/suggest'),
|
||||
putPathMapping: (m: PathMapping) =>
|
||||
send<PathMapping>('PUT', '/api/collection/path-mapping', m),
|
||||
previewRemap: (from: string, to: string) =>
|
||||
getJSON<RemapPreview>(
|
||||
`/api/collection/path-mapping/preview?from=${encodeURIComponent(from)}&to=${encodeURIComponent(to)}`,
|
||||
),
|
||||
// Write-back: permanently rewrite matching LOCATIONs in the .nml (backup-first).
|
||||
remapPaths: (from: string, to: string) =>
|
||||
send<RemapResult>('POST', '/api/collection/remap-paths', { from, to }),
|
||||
|
||||
stats: () => getJSON<Stats>('/api/stats'),
|
||||
facets: () => getJSON<Facets>('/api/facets'),
|
||||
playlists: () => getJSON<PlaylistNode[]>('/api/playlists'),
|
||||
|
||||
Reference in new issue
Block a user