tweaks
This commit is contained in:
parent
f27e71839f
commit
4faccb4785
30
app-gale.js
30
app-gale.js
@ -32,15 +32,29 @@ async function EvaluateHandle()
|
|||||||
let handle = await FSHandle.getDirectoryHandle();
|
let handle = await FSHandle.getDirectoryHandle();
|
||||||
EvaluateHandle();
|
EvaluateHandle();
|
||||||
|
|
||||||
/** @type {(pass:TYPES.Pass)=>HTMLElement} */
|
/** @type {(pass:TYPES.Pass, parts:TYPES.GraphParts)=>()=>HTMLElement} */
|
||||||
function Pass(pass)
|
function Pass(pass, parts)
|
||||||
{
|
{
|
||||||
return Div.Plain(
|
const rerender = van.state(0);
|
||||||
Div.Title(
|
return ()=>{
|
||||||
DOM.span.Plain(pass.name),
|
console.log("rerendering...", rerender.val)
|
||||||
DOM.span.Plain(pass.path),
|
return Div.Plain(
|
||||||
|
Div.Title(
|
||||||
|
DOM.div.Plain(pass.name),
|
||||||
|
DOM.span.Plain(pass.path),
|
||||||
|
),
|
||||||
|
()=>{
|
||||||
|
return DOM.button.Plain(
|
||||||
|
{async onclick(){
|
||||||
|
await pass.load();
|
||||||
|
rerender.val++
|
||||||
|
}},
|
||||||
|
pass.live ? "Dump" : "Load"
|
||||||
|
)
|
||||||
|
},
|
||||||
|
|
||||||
)
|
)
|
||||||
)
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -56,7 +70,7 @@ function App()
|
|||||||
}, "Pick Directory"),
|
}, "Pick Directory"),
|
||||||
Object.entries(rooms.val).map(([room_id, graphParts])=>
|
Object.entries(rooms.val).map(([room_id, graphParts])=>
|
||||||
Object.entries(graphParts.Pass).map(([pass_id, pass])=>{
|
Object.entries(graphParts.Pass).map(([pass_id, pass])=>{
|
||||||
return Pass(pass)
|
return Pass(pass, graphParts)
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
121
app-original.js
121
app-original.js
@ -1,121 +0,0 @@
|
|||||||
/** @import * as TYPES from "./graph/types.ts" */
|
|
||||||
|
|
||||||
import * as FSHandle from "./store-directory-handle.js";
|
|
||||||
|
|
||||||
|
|
||||||
/** @type {(type:string, attributes?:Record<string, string>, ...children:Array<string|HTMLElement>)=>HTMLElement} */
|
|
||||||
const H =(type, attributes={}, ...children)=> {
|
|
||||||
const el =document.createElement(type);
|
|
||||||
Object.entries(attributes).forEach(([name, data])=>{
|
|
||||||
if(name.startsWith("on"))
|
|
||||||
{
|
|
||||||
el.addEventListener(name.substring(2), data);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
el.setAttribute(name, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
children.forEach(child=>
|
|
||||||
{
|
|
||||||
el.appendChild(typeof child == "string" ? document.createTextNode(child) : child);
|
|
||||||
});
|
|
||||||
return el;
|
|
||||||
}
|
|
||||||
const button = H("button");
|
|
||||||
const listRoom = H("ul");
|
|
||||||
|
|
||||||
/** @type {(errorAction?:()=>void)=>Promise<void>} */
|
|
||||||
async function ReloadAndRedraw(errorAction = ()=>{})
|
|
||||||
{
|
|
||||||
listRoom.innerHTML = "";
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
const handle = await FSHandle.getDirectoryHandle();
|
|
||||||
if(!handle)
|
|
||||||
{
|
|
||||||
console.log("no fs handle")
|
|
||||||
throw new Error("no fs handle set yet")
|
|
||||||
}
|
|
||||||
button.setAttribute("disabled", true);
|
|
||||||
button.innerText = "loading...";
|
|
||||||
|
|
||||||
const module = await import("./data/room.js"+"?rand="+Math.random());
|
|
||||||
/** @type {Record<string, TYPES.GraphParts>} */
|
|
||||||
const rooms = module.default();
|
|
||||||
button.innerText = "change directory";
|
|
||||||
console.log("rooms loaded:", rooms);
|
|
||||||
|
|
||||||
Redraw(rooms);
|
|
||||||
|
|
||||||
}
|
|
||||||
catch(e)
|
|
||||||
{
|
|
||||||
errorAction();
|
|
||||||
button.innerText = "select directory";
|
|
||||||
}
|
|
||||||
button.removeAttribute("disabled")
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function Redraw(rooms)
|
|
||||||
{
|
|
||||||
Object.entries(rooms).forEach(([roomID, roomData])=>
|
|
||||||
{
|
|
||||||
const listPass = H("ul");
|
|
||||||
Object.entries(roomData.Pass).forEach(([passID, passData])=>{
|
|
||||||
|
|
||||||
listPass.appendChild(H("li", {},
|
|
||||||
H("button", { onclick:async()=>
|
|
||||||
{
|
|
||||||
await passData.load();
|
|
||||||
globalThis.ROOM=roomData;
|
|
||||||
Redraw(rooms)
|
|
||||||
} }, passData.name),
|
|
||||||
))
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
const listPart = H("ul");
|
|
||||||
Object.entries(roomData.Part).forEach(([partId, partData])=>{
|
|
||||||
|
|
||||||
const listWork = H("dl");
|
|
||||||
|
|
||||||
partData.pass.entries().forEach(([pass, passMapper])=>{
|
|
||||||
listWork.appendChild(H("dt", {}, pass.name))
|
|
||||||
passMapper.work.forEach((w)=>{
|
|
||||||
listWork.appendChild(H("dd", {}, w.join(" ")))
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
listPart.appendChild(H("li", {},
|
|
||||||
H("h2", {}, partData.name),
|
|
||||||
listWork
|
|
||||||
));
|
|
||||||
})
|
|
||||||
|
|
||||||
listRoom.innerHTML = "";
|
|
||||||
listRoom.appendChild(
|
|
||||||
H("li", {},
|
|
||||||
H("div", {}, roomID),
|
|
||||||
listPass,
|
|
||||||
H("div", {}, listPart)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
await ReloadAndRedraw();
|
|
||||||
|
|
||||||
button.addEventListener("click", async()=>
|
|
||||||
{
|
|
||||||
const directory = await globalThis.showDirectoryPicker();
|
|
||||||
await FSHandle.setDirectoryHandle(directory);
|
|
||||||
await ReloadAndRedraw(()=>alert("Invalid directory"));
|
|
||||||
});
|
|
||||||
|
|
||||||
document.body.appendChild(button);
|
|
||||||
document.body.appendChild(listRoom);
|
|
||||||
@ -92,7 +92,6 @@ function Builder({user, role, part, desk, pass}, folderName)
|
|||||||
path:passID,
|
path:passID,
|
||||||
async load(){
|
async load(){
|
||||||
|
|
||||||
|
|
||||||
// make room for this pass to each part and desk
|
// make room for this pass to each part and desk
|
||||||
Object.values(PartList).forEach((partObj)=>
|
Object.values(PartList).forEach((partObj)=>
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user