diff --git a/app.js b/app.js index 5fb88ab..9ae2776 100644 --- a/app.js +++ b/app.js @@ -16,6 +16,15 @@ const {Div, DOM} = Gale({ border: `1px solid black`, borderRadius: `5px`, padding: `1rem` + }, + BlockScreen:{ + position: "fixed", + zIndex: "9999", + top: "0", + left: "0", + width: "100%", + height: "100%", + background: "rgba(128, 128, 128, 0.5)" } }); @@ -87,11 +96,14 @@ async function WRITE(path, part, time, data) /** @type {Van.State} */ const loggedIn = van.state(false); +const blocking = van.state(false); + /** @type {(room_id:string, graphParts:TYPES.GraphParts)=>HTMLElement} */ function Room(room_id, graphParts) { const rerender = van.state(0); - + blocking.val; + return Div.Plain( Div.Plain("Users:"), @@ -99,15 +111,14 @@ function Room(room_id, graphParts) Object.entries(graphParts.User).map(([user_id, user])=>{ return ()=>{ - rerender.val; + //rerender.val; return Div.Part( DOM.div.Plain(user.name), ()=>{ return DOM.button.Plain( - {async onclick(){ - rerender.val++ - loggedIn.val = user; + {onclick(){ + loggedIn.val = (loggedIn.val == user) ? false : user; }}, loggedIn.val == user ? "this is me" : "impersonate" ) @@ -162,11 +173,14 @@ function Room(room_id, graphParts) DOM.strong(data), )), Div.Plain( - loggedIn.val ? DOM.button({async onclick(){ + loggedIn.val ? DOM.button({onclick(){ if(loggedIn.val) { - await data.make(loggedIn.val, "NEW"); - rerender.val++; + blocking.val = true; + data.make(loggedIn.val, "NEW").then(()=>{ + blocking.val = false; + rerender.val++; + }); } }}, "Add work!") : null @@ -237,6 +251,10 @@ function Room(room_id, graphParts) }), ), + ()=>{ + return blocking.val ? Div.BlockScreen() : null + } + ) } diff --git a/graph/graph.js b/graph/graph.js index 81ba8cb..58b3735 100644 --- a/graph/graph.js +++ b/graph/graph.js @@ -106,7 +106,6 @@ export function Room({user, role, part, desk, pass}) const handle = await FSAccess.getDirectoryHandle(); const path = ["store", context.Path, passID, user.id+".json"]; let text = await FSAccess.Read(handle, path) || "{}"; - console.log("json loaded", text); /** @type {TYPES.UserPassFile} */ const json = JSON.parse(text); @@ -140,7 +139,6 @@ export function Room({user, role, part, desk, pass}) { const handle = await FSAccess.getDirectoryHandle(); const text = await FSAccess.Read(handle, ["store", context.Path, passID, userID+".json"]); - console.log("json loaded", text); /** @type {TYPES.UserPassFile} */ const json = JSON.parse(text); @@ -174,7 +172,6 @@ export function Room({user, role, part, desk, pass}) } } - console.log("load complete", PartList); // update the graph Object.values(DeskList).forEach((deskObj)=>Scan(deskObj, passObj)); diff --git a/graph/types.ts b/graph/types.ts index 857b448..90758c4 100644 --- a/graph/types.ts +++ b/graph/types.ts @@ -2,7 +2,7 @@ export type User = {name:string, id:string, desk:Set}; export type Role = {name:string, id:string, user:User[]}; export type Desk = {name:string, id:string, need:Part[], time:number[], make:Part[], pass:Map, mode:string, role:Role[]}; export type Pass = {name:string, id:string, path:string, live:boolean, load:()=>Promise, dump:()=>void}; -export type Part = {name:string, id:string, pass:Mapvoid}>, need:Desk[], make:Desk[]}; +export type Part = {name:string, id:string, pass:MapPromise}>, need:Desk[], make:Desk[]}; export type Work = [time:number, data:string, user:User]; export type Flag = {need:number[], make:number[]}