[webui] (attempt to) relativize all paths?

feat/vaults
Tomáš Mládek 2022-02-06 23:38:33 +01:00
parent 420efdfdb4
commit b51e41b643
No known key found for this signature in database
GPG Key ID: ED21612889E75EC5
14 changed files with 34 additions and 34 deletions

View File

@ -6,10 +6,10 @@
<title>UpEnd</title>
<link rel="icon" type="image/png" href="/assets/upend.svg" />
<link rel="stylesheet" href="/build/bundle.css" />
<link rel="icon" type="image/png" href="assets/upend.svg" />
<link rel="stylesheet" href="build/bundle.css" />
<script type="module" src="/build/main.js"></script>
<script type="module" src="build/main.js"></script>
</head>
<body></body>

View File

@ -34,7 +34,7 @@
const formData = new FormData();
formData.append("file", file);
const response = await fetch("/api/obj", {
const response = await fetch("api/obj", {
method: "PUT",
body: formData,
});

View File

@ -108,7 +108,7 @@
const change = ev.detail;
switch (change.type) {
case "create":
await fetch(`/api/obj`, {
await fetch(`api/obj`, {
method: "PUT",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
@ -119,10 +119,10 @@
});
break;
case "delete":
await fetch(`/api/obj/${change.address}`, { method: "DELETE" });
await fetch(`api/obj/${change.address}`, { method: "DELETE" });
break;
case "update":
await fetch(`/api/obj/${address}/${change.attribute}`, {
await fetch(`api/obj/${address}/${change.attribute}`, {
method: "PUT",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(change.value),
@ -140,7 +140,7 @@
if (!groupToAdd) {
return;
}
await fetch(`/api/obj`, {
await fetch(`api/obj`, {
method: "PUT",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
@ -157,12 +157,12 @@
}
async function removeGroup(address: string) {
await fetch(`/api/obj/${address}`, { method: "DELETE" });
await fetch(`api/obj/${address}`, { method: "DELETE" });
revalidate();
}
onMount(() => {
fetch(`/api/obj/${address}/LAST_VISITED`, {
fetch(`api/obj/${address}/LAST_VISITED`, {
method: "PUT",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ t: "Number", c: new Date().getTime() }),

View File

@ -35,19 +35,19 @@
<Spinner />
{/if}
<img
src="/api/thumb/{address}"
src="api/thumb/{address}"
alt={address}
on:load={() => (imageLoaded = address)}
on:error={() => (imageLoaded = address)}
/>
<audio controls preload="auto" src="/api/raw/{address}" />
<audio controls preload="auto" src="api/raw/{address}" />
{/if}
{#if video}
{#if imageLoaded != address}
<Spinner />
<img
src="/api/thumb/{address}"
src="api/thumb/{address}"
alt={address}
on:load={() => (imageLoaded = address)}
on:error={() => (imageLoaded = address)}
@ -57,18 +57,18 @@
<video
controls
preload="auto"
src="/api/raw/{address}"
poster="/api/thumb/{address}"
src="api/raw/{address}"
poster="api/thumb/{address}"
/>
{/if}
{/if}
{#if image}
<a target="_blank" href="/api/raw/{address}?inline=1">
<a target="_blank" href="api/raw/{address}?inline=1">
{#if imageLoaded != address}
<Spinner />
{/if}
<img
src="/api/thumb/{address}"
src="api/thumb/{address}"
alt={address}
on:load={() => (imageLoaded = address)}
on:error={() => (handled = false)}
@ -77,12 +77,12 @@
{/if}
{#if pdf}
<iframe
src="/api/raw/{address}?inline"
src="api/raw/{address}?inline"
title="PDF document of {address}"
/>
{/if}
{#if model}
<ModelViewer src="/api/raw/{address}" />
<ModelViewer src="api/raw/{address}" />
{/if}
</div>
{/if}

View File

@ -50,7 +50,7 @@
} in a default native application...`
)
);
fetch(`/api/raw/${address}?native=1`)
fetch(`api/raw/${address}?native=1`)
.then(async (response) => {
if (!response.ok) {
throw new Error(`${response.statusText} - ${await response.text()}`);
@ -89,7 +89,7 @@
<div class="separator" />
<div class="label" class:resolving title={displayLabel}>
{#if banner && isFile}
<a href="/api/raw/{address}">
<a href="api/raw/{address}">
<Ellipsis value={displayLabel} />
</a>
{:else if link}

View File

@ -8,7 +8,7 @@
$: textContent = (async () => {
const response = await fetch(
`/api/${mode == "preview" ? "thumb" : "raw"}/${address}`
`api/${mode == "preview" ? "thumb" : "raw"}/${address}`
);
const text = await response.text();
if (mode === "markdown") {

View File

@ -34,7 +34,7 @@
}
async function rescan() {
await fetch("/api/refresh", { method: "POST" });
await fetch("api/refresh", { method: "POST" });
jobsEmitter.emit("reload");
}
</script>

View File

@ -21,7 +21,7 @@
let timeout: number;
async function updateJobs() {
clearTimeout(timeout);
let request = await fetch("/api/jobs");
let request = await fetch("api/jobs");
jobs = await request.json();
activeJobs = Object.entries(jobs)

View File

@ -51,7 +51,7 @@
switch (type) {
case "attribute": {
const req = await fetch("/api/all/attributes");
const req = await fetch("api/all/attributes");
const allAttributes: string[] = await req.json();
options = allAttributes
.filter((attr) => attr.toLowerCase().includes(query.toLowerCase()))

View File

@ -21,7 +21,7 @@
{/if}
{#if handled}
<img
src="/api/thumb/{address}"
src="api/thumb/{address}"
alt="Thumbnail for {identity}..."
on:load={() => (loaded = address)}
on:error={() => (handled = false)}

View File

@ -10,7 +10,7 @@ const inFlightRequests: { [key: string]: Promise<UpListing> } = {};
export function useEntity(address: string) {
const { data, error, revalidate } = useSWR<ListingResult, unknown>(
`/api/obj/${address}`
`api/obj/${address}`
);
const entity: Readable<UpObject | undefined> = derived(data, ($listing) => {
@ -28,7 +28,7 @@ export function useEntity(address: string) {
}
export async function fetchEntry(address: string) {
const response = await fetch(`/api/raw/${address}`);
const response = await fetch(`api/raw/${address}`);
const data = await response.json();
const listing = new UpListing({ address: data });
return listing.entries[0];
@ -37,7 +37,7 @@ export async function fetchEntry(address: string) {
export function query(query: string) {
console.debug(`Querying: ${query}`);
const { data, error, revalidate } = useSWR<ListingResult, unknown>(
"/api/query",
"api/query",
{ method: "POST", body: query }
);
@ -58,7 +58,7 @@ export async function queryOnce(query: string): Promise<UpListing> {
if (!inFlightRequests[query]) {
console.debug(`Querying: ${query}`);
inFlightRequests[query] = new Promise((resolve, reject) => {
fetch("/api/query", { method: "POST", body: query, keepalive: true })
fetch("api/query", { method: "POST", body: query, keepalive: true })
.then(async (response) => {
resolve(new UpListing(await response.json()));
})

View File

@ -2,7 +2,7 @@ import { readable, Readable } from "svelte/store";
import type { VaultInfo } from "upend/types";
export const vaultInfo: Readable<VaultInfo> = readable(undefined, (set) => {
fetch("/api/info").then(async (response) => {
fetch("api/info").then(async (response) => {
set(await response.json());
});
});

View File

@ -25,7 +25,7 @@ export async function getObjects(
}
export async function createLabelled(label: string) {
const response = await fetch(`/api/obj`, {
const response = await fetch(`api/obj`, {
method: "PUT",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({

View File

@ -11,7 +11,7 @@
import { updateTitle } from "../util/title";
const roots = (async () => {
const response = await fetch("/api/hier_roots");
const response = await fetch("api/hier_roots");
const data = (await response.json()) as ListingResult;
const listing = new UpListing(data);
return Object.values(listing.objects).filter((obj) =>
@ -27,7 +27,7 @@
.slice(0, 25) as [string, number][];
const latestFiles = (async () => {
const response = await fetch("/api/files/latest");
const response = await fetch("api/files/latest");
const files = (await response.json()) as IFile[];
return files.slice(0, 25);
})();