chunker ui redo
This commit is contained in:
@@ -2,45 +2,17 @@
|
||||
* GraphQL API client
|
||||
*/
|
||||
|
||||
import { gql } from "../../common/api/graphql";
|
||||
import { getAssets, scanMediaFolder } from "../../common/api/media";
|
||||
import type {
|
||||
MediaAsset,
|
||||
TranscodePreset,
|
||||
TranscodeJob,
|
||||
CreateJobRequest,
|
||||
SystemStatus,
|
||||
MediaAsset,
|
||||
} from "./types";
|
||||
|
||||
const GRAPHQL_URL = "/api/graphql";
|
||||
|
||||
async function gql<T>(query: string, variables?: Record<string, unknown>): Promise<T> {
|
||||
const response = await fetch(GRAPHQL_URL, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ query, variables }),
|
||||
});
|
||||
|
||||
const json = await response.json();
|
||||
|
||||
if (json.errors?.length) {
|
||||
throw new Error(json.errors[0].message);
|
||||
}
|
||||
|
||||
return json.data as T;
|
||||
}
|
||||
|
||||
// Assets
|
||||
export async function getAssets(): Promise<MediaAsset[]> {
|
||||
const data = await gql<{ assets: MediaAsset[] }>(`
|
||||
query {
|
||||
assets {
|
||||
id filename file_path status error_message file_size duration
|
||||
video_codec audio_codec width height framerate bitrate
|
||||
properties comments tags created_at updated_at
|
||||
}
|
||||
}
|
||||
`);
|
||||
return data.assets;
|
||||
}
|
||||
export { getAssets, scanMediaFolder };
|
||||
|
||||
export async function getAsset(id: string): Promise<MediaAsset> {
|
||||
const data = await gql<{ asset: MediaAsset }>(`
|
||||
@@ -55,20 +27,6 @@ export async function getAsset(id: string): Promise<MediaAsset> {
|
||||
return data.asset;
|
||||
}
|
||||
|
||||
export async function scanMediaFolder(): Promise<{
|
||||
found: number;
|
||||
registered: number;
|
||||
skipped: number;
|
||||
files: string[];
|
||||
}> {
|
||||
const data = await gql<{ scan_media_folder: { found: number; registered: number; skipped: number; files: string[] } }>(`
|
||||
mutation {
|
||||
scan_media_folder { found registered skipped files }
|
||||
}
|
||||
`);
|
||||
return data.scan_media_folder;
|
||||
}
|
||||
|
||||
// Presets
|
||||
export async function getPresets(): Promise<TranscodePreset[]> {
|
||||
const data = await gql<{ presets: TranscodePreset[] }>(`
|
||||
|
||||
Reference in New Issue
Block a user