writing works
This commit is contained in:
parent
7a54689f76
commit
5ac0b07bd7
7
app.js
7
app.js
@ -162,12 +162,11 @@ function Room(room_id, graphParts)
|
|||||||
DOM.strong(data),
|
DOM.strong(data),
|
||||||
)),
|
)),
|
||||||
Div.Plain(
|
Div.Plain(
|
||||||
loggedIn.val ? DOM.button({onclick(){
|
loggedIn.val ? DOM.button({async onclick(){
|
||||||
if(loggedIn.val)
|
if(loggedIn.val)
|
||||||
{
|
{
|
||||||
data.make(loggedIn.val, "NEW");
|
await data.make(loggedIn.val, "NEW");
|
||||||
rerender.val++
|
rerender.val++;
|
||||||
WRITE(["room", room_id, pass.id, loggedIn.val.id+".json"], part_id, new Date().getTime(), "NEW");
|
|
||||||
}
|
}
|
||||||
}}, "Add work!")
|
}}, "Add work!")
|
||||||
: null
|
: null
|
||||||
|
|||||||
@ -99,9 +99,27 @@ export function Room({user, role, part, desk, pass})
|
|||||||
// 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)=>
|
||||||
{
|
{
|
||||||
partObj.pass.set(passObj, {time:0, work:[], make(user, data)
|
partObj.pass.set(passObj, {time:0, work:[], async make(user, data)
|
||||||
{
|
{
|
||||||
this.time = Date.now();
|
this.time = Date.now();
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
let field = json[partObj.id];
|
||||||
|
if(!field)
|
||||||
|
{
|
||||||
|
field = [];
|
||||||
|
json[partObj.id] = field;
|
||||||
|
}
|
||||||
|
field.push([this.time, data]);
|
||||||
|
text = JSON.stringify(json, null, 2);
|
||||||
|
await FSAccess.Write(handle, path, text);
|
||||||
|
|
||||||
this.work.push(/** @type {TYPES.Work}*/([this.time, data, user]));
|
this.work.push(/** @type {TYPES.Work}*/([this.time, data, user]));
|
||||||
partObj.make.forEach((arg)=>{Scan(arg, passObj)});
|
partObj.make.forEach((arg)=>{Scan(arg, passObj)});
|
||||||
partObj.need.forEach((arg)=>{Scan(arg, passObj)});
|
partObj.need.forEach((arg)=>{Scan(arg, passObj)});
|
||||||
|
|||||||
@ -76,7 +76,7 @@ export async function Read(handle, parts)
|
|||||||
/** @type {(handle:FileSystemDirectoryHandle, parts:string[], text:string)=>Promise<boolean>} */
|
/** @type {(handle:FileSystemDirectoryHandle, parts:string[], text:string)=>Promise<boolean>} */
|
||||||
export async function Write(handle, parts, text)
|
export async function Write(handle, parts, text)
|
||||||
{
|
{
|
||||||
const fileHandle = await Dig(handle, parts);
|
const fileHandle = await Dig(handle, parts, true);
|
||||||
if(fileHandle)
|
if(fileHandle)
|
||||||
{
|
{
|
||||||
const writeable = await fileHandle.createWritable();
|
const writeable = await fileHandle.createWritable();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user