import urlJoin from 'url-join'; import mime from 'mime'; import moment from 'moment'; import { createResource, createSignal, For, Show } from 'solid-js'; import tippy from 'tippy.js'; import 'tippy.js/dist/tippy.css'; import 'tippy.js/themes/light.css'; import 'tippy.js/animations/shift-away.css'; import './app.sass'; import { Icon } from '@iconify-icon/solid'; import { clamp, sizeFmt } from './utils'; interface File { name: string type: 'file' | 'directory' size: number mtime: string } // const assets = ".web-static" const assets = "/" const host = "https://daisy-ddns.hydev.org/data/api" const path = window.location.pathname const fetchApi = async () => await (await fetch(urlJoin(host, path))).json() as File[] function getIcon(f: File) { if (f.type == "directory") return "/mime/folder.svg" const sp = f.name.split(".") const m = mime.getType(sp[sp.length - 1]) if (m) return urlJoin(assets, `mime/${m.replace("/", "-")}.svg`) else return urlJoin(assets, 'mime/application-blank.svg') } function getHref(f: File) { return f.type == "directory" ? urlJoin(path, f.name) : urlJoin(host, path, f.name) } export default function App() { let bcMax: number const [api] = createResource(fetchApi) const [bcLeft, setBcLeft] = createSignal(0) const paths = [window.location.host, ...path.split("/").filter(it => it)] // Handle wheel for breadcrumb function wheel(e: WheelEvent) { let direction = (e.detail < 0 || e.deltaY > 0) ? 1 : -1 setBcLeft(clamp(bcLeft() + direction * 20, 0, bcMax)) } // Set initial breadcrumb wheel to show the end path const initWheel = (w: HTMLDivElement) => setTimeout(() => setBcLeft(bcMax = Math.round(w.clientWidth - w.parentElement.clientWidth)), 100) return ( // Full screen container
{/* Content container */}

File Listing

{/* Breadcrumbs */} {api.loading && "Loading..."} {/* Files */}
); }