Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ae89ac642e | |||
| dfffa59094 | |||
| ec85ab6a34 | |||
| 76d4c4be73 | |||
| ef1fb55057 |
31
app.js
31
app.js
@ -59,25 +59,6 @@ const blocking = van.state(false);
|
||||
|
||||
const showDesks = van.state(true, "desks");
|
||||
|
||||
function Input(handler=(str)=>{})
|
||||
{
|
||||
const input = DOM.textarea({style:"vertical-align:text-top; width:500px; height:200px;"});
|
||||
|
||||
let submitButton = Div.Plain(DOM.button({onclick(){
|
||||
handler(input.value);
|
||||
input.value = "";
|
||||
mountPoint.remove();
|
||||
}}, "submit value"));
|
||||
|
||||
let cancelButton = DOM.button({onclick(){
|
||||
input.value = "";
|
||||
mountPoint.remove();
|
||||
}}, "cancel")
|
||||
|
||||
const mountPoint = Div.Plain({onclick(e){e.stopPropagation();}}, input, cancelButton, submitButton);
|
||||
return mountPoint;
|
||||
}
|
||||
|
||||
/** @type {(inParts:Record<string, TYPES.Part>, inPasses:Record<string, TYPES.Pass>)=>HTMLElement} */
|
||||
function Parts(inParts, inPasses)
|
||||
{
|
||||
@ -103,7 +84,7 @@ function Parts(inParts, inPasses)
|
||||
return DOM.table.GapVertical(rows);
|
||||
}
|
||||
|
||||
const deskRender = van.state(0);
|
||||
//const deskRender = van.state(0);
|
||||
|
||||
/** @type {(part:TYPES.Part, pass:TYPES.Pass, closeHandler:()=>void)=>HTMLElement} */
|
||||
function PartEditor(part, pass, closeHandler)
|
||||
@ -240,7 +221,7 @@ function Desks(inDesks)
|
||||
}
|
||||
else
|
||||
{
|
||||
attributes.class = caution ? Tag("PartCaution") : Tag("PartEmpty")
|
||||
attributes.class = Tag("PartEmpty")
|
||||
}
|
||||
|
||||
if(scan.need_dirty.includes(index))
|
||||
@ -255,7 +236,13 @@ function Desks(inDesks)
|
||||
)
|
||||
);
|
||||
}),
|
||||
DOM.td(Div.Icon("⇉")),
|
||||
DOM.td(
|
||||
Div.Icon("⇉"),
|
||||
scan.due_date ? Div.Part(
|
||||
scan.due_date.toLocaleDateString(),
|
||||
scan.due_date.toLocaleTimeString()
|
||||
) : " "
|
||||
),
|
||||
desk.make.map((part, index, array)=>
|
||||
{
|
||||
const partPass = part.pass.get(pass);
|
||||
|
||||
43
deep/mock-user-folder/graph/room.js
Normal file
43
deep/mock-user-folder/graph/room.js
Normal file
@ -0,0 +1,43 @@
|
||||
//@ts-check
|
||||
import CreateAllRooms, {Room} from "../../graph/graph.js";
|
||||
|
||||
const user = {
|
||||
u1:"Seth T",
|
||||
u4:"Sarah S",
|
||||
u5:"Adam M",
|
||||
u6:"Matt Y",
|
||||
u7:"Seth F",
|
||||
u8:"Brittany F"
|
||||
};
|
||||
|
||||
export default CreateAllRooms({
|
||||
room_01:Room({
|
||||
user,
|
||||
role:{
|
||||
dev:["Development", "u1"],
|
||||
write:["Writing", "u5"],
|
||||
admin:["Admin", "u4"]
|
||||
},
|
||||
part:{
|
||||
p1:["Page title"],
|
||||
p2:["Page slug"],
|
||||
p3:["Page preview"],
|
||||
p4:["Page Project"],
|
||||
p5:["Page Corrections", "loop"],
|
||||
},
|
||||
desk:{
|
||||
d1:["Write page metas", ["admin", "write"], { }, "p1", "p2"],
|
||||
d2:["Build Page preview", ["admin", "dev" ], {p1:1, p2:1, p5:4}, "p3", "p4"],
|
||||
d3:["Proof Page", ["admin", "write"], {p3:1, }, "p5" ]
|
||||
},
|
||||
pass:{
|
||||
pass_01:["January"],
|
||||
//pass_02:["February"],
|
||||
//pass_03:["March"],
|
||||
//pass_04:["April"],
|
||||
//pass_05:["May"],
|
||||
//pass_06:["June"],
|
||||
//pass_07:["July"],
|
||||
}
|
||||
})
|
||||
});
|
||||
@ -1,6 +1,8 @@
|
||||
/** @import * as TYPES from "./types.ts" */
|
||||
import * as FSAccess from "../store-directory-handle.js";
|
||||
|
||||
export const noop = "no-op";
|
||||
|
||||
/** @type {TYPES.GraphBuilder} */
|
||||
export function Room({user, role, part, desk, pass})
|
||||
{
|
||||
@ -32,8 +34,9 @@ export function Room({user, role, part, desk, pass})
|
||||
const PartList = part;
|
||||
for(let partId in part)
|
||||
{
|
||||
const name = part[partId];
|
||||
PartList[partId] = /** @type {TYPES.Part} */({name, id:partId, need:[], make:[], pass:new Map()});
|
||||
const [name, loop] = part[partId];
|
||||
|
||||
PartList[partId] = /** @type {TYPES.Part} */({name, id:partId, need:[], make:[], pass:new Map(), loop:loop});
|
||||
}
|
||||
|
||||
// mutate desks
|
||||
@ -42,7 +45,7 @@ export function Room({user, role, part, desk, pass})
|
||||
const DeskList = desk;
|
||||
for(let deskId in desk)
|
||||
{
|
||||
const [name, roleIDs, mode, needObj, ...makePartIDs] = desk[deskId];
|
||||
const [name, roleIDs, needObj, ...makePartIDs] = desk[deskId];
|
||||
/** @type {TYPES.Part[]}*/ const need =[];
|
||||
/** @type {number[]}*/ const time =[];
|
||||
|
||||
@ -50,7 +53,6 @@ export function Room({user, role, part, desk, pass})
|
||||
const deskObj = {
|
||||
name,
|
||||
id:deskId,
|
||||
mode,
|
||||
need,
|
||||
time,
|
||||
make:[],
|
||||
@ -160,6 +162,7 @@ export function Room({user, role, part, desk, pass})
|
||||
{
|
||||
passCheck.time = latest;
|
||||
}
|
||||
//payload.sort()
|
||||
passCheck.work = /** @type {TYPES.Work[]}*/(payload);
|
||||
}
|
||||
|
||||
@ -225,32 +228,87 @@ const Scan =(desk, pass)=>
|
||||
let makeMin = Infinity;
|
||||
let needMax = -Infinity;
|
||||
|
||||
// added for estimation
|
||||
let estMin = Infinity;
|
||||
let estMax = -Infinity;
|
||||
let estSum = 0;
|
||||
|
||||
/*
|
||||
|
||||
Loop parts:
|
||||
- always considered clean when the leading value is a no-op
|
||||
- as a need, considered clean when empty
|
||||
|
||||
*/
|
||||
|
||||
/** @type {(part:TYPES.Part)=>[time:number, value:string|undefined, part:TYPES.Part]} */
|
||||
const lookup =(part)=>
|
||||
{
|
||||
const partPass = part.pass.get(pass);
|
||||
const partPassTime = partPass?.time || 0;
|
||||
const partPassValue = partPass?.work.find(t=>t[0] == partPassTime)?.[1];
|
||||
return [partPassTime, partPassValue, part];
|
||||
}
|
||||
|
||||
// update needMax
|
||||
for(let i=0; i<desk.need.length; i++)
|
||||
{
|
||||
const part = desk.need[i];
|
||||
const partPassTime = part.pass.get(pass)?.time || 0;
|
||||
if(partPassTime > needMax) needMax = partPassTime;
|
||||
if(!partPassTime) emptyNeed.push(i)
|
||||
const [time, value, part] = lookup(desk.need[i]);
|
||||
|
||||
if(part.loop)
|
||||
{
|
||||
if(!value || value == noop)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// update makeMin AND dirty check makes
|
||||
if(time > needMax) needMax = time;
|
||||
if(!time) emptyNeed.push(i);
|
||||
}
|
||||
|
||||
// update makeMin AND dirtyMakes
|
||||
for(let i=0; i<desk.make.length; i++)
|
||||
{
|
||||
const part = desk.make[i];
|
||||
const partPassTime = part.pass.get(pass)?.time || 0;
|
||||
if(partPassTime < makeMin) makeMin = partPassTime;
|
||||
if(partPassTime < needMax) dirtyMake.push(i);
|
||||
if(!partPassTime) emptyMake.push(i)
|
||||
const [time] = lookup(desk.make[i]);
|
||||
|
||||
if(time < makeMin) makeMin = time;
|
||||
if(time < needMax) dirtyMake.push(i);
|
||||
if(!time) emptyMake.push(i)
|
||||
|
||||
}
|
||||
|
||||
// dirty check needs
|
||||
// dirtyNeeds
|
||||
for(let i=0; i<desk.need.length; i++)
|
||||
{
|
||||
const part = desk.need[i];
|
||||
const partPassTime = part.pass.get(pass)?.time || 0;
|
||||
if(partPassTime > makeMin) dirtyNeed.push(i);
|
||||
const [time, value, part] = lookup(desk.need[i]);
|
||||
|
||||
if(part.loop)
|
||||
{
|
||||
if(!value || value == noop)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
desk.pass.set(pass, {need_dirty:dirtyNeed, make_dirty:dirtyMake, need_empty:emptyNeed, make_empty:emptyMake})
|
||||
if(time > makeMin)
|
||||
{
|
||||
dirtyNeed.push(i);
|
||||
|
||||
// estimation
|
||||
if(time < estMin) estMin = time;
|
||||
const allottedTime = desk.time[i] * 1000 * 60 * 60;
|
||||
const projectedTime = time + allottedTime;
|
||||
estSum += allottedTime;
|
||||
if(projectedTime > estMax) estMax = projectedTime;
|
||||
}
|
||||
}
|
||||
|
||||
estSum += estMin;
|
||||
let stamp = estSum;
|
||||
if(estMax > estSum)
|
||||
{
|
||||
stamp = estMax;
|
||||
}
|
||||
desk.pass.set(pass, {need_dirty:dirtyNeed, make_dirty:dirtyMake, need_empty:emptyNeed, make_empty:emptyMake, due_date:isFinite(stamp) ? new Date(stamp) : undefined})
|
||||
};
|
||||
@ -1,17 +1,17 @@
|
||||
export type User = {name:string, id:string, desk:Set<Desk>};
|
||||
export type Role = {name:string, id:string, user:User[]};
|
||||
export type Desk = {name:string, id:string, need:Part[], time:number[], make:Part[], pass:Map<Pass, Scan>, mode:string, role:Role[]};
|
||||
export type Desk = {name:string, id:string, need:Part[], time:number[], make:Part[], pass:Map<Pass, Scan>, role:Role[]};
|
||||
export type Pass = {name:string, id:string, path:string, live:boolean, load:()=>Promise<void>, dump:()=>void};
|
||||
export type Part = {name:string, id:string, pass:Map<Pass, {time:number, work:Work[], make:(user:User, data:string)=>Promise<void>}>, need:Desk[], make:Desk[]};
|
||||
export type Part = {name:string, id:string, pass:Map<Pass, {time:number, work:Work[], make:(user:User, data:string)=>Promise<void>}>, need:Desk[], make:Desk[], loop?:boolean};
|
||||
export type Work = [time:number, data:string, user:User];
|
||||
export type Scan = {need_dirty:number[], make_dirty:number[], need_empty:number[], make_empty:number[]}
|
||||
export type Scan = {need_dirty:number[], make_dirty:number[], need_empty:number[], make_empty:number[], due_date?:Date}
|
||||
|
||||
export type GraphBuilder=
|
||||
<
|
||||
Users extends Record<string, string>,
|
||||
Roles extends Record<string, [ name:string, ...users:Array<keyof Users>]>,
|
||||
Parts extends Record<string, string>,
|
||||
Desks extends Record<string, [ name:string, roles:Array<keyof Roles>, mode:"all"|"one", need:Partial<Record<keyof Parts, number>>, ...make:Array<keyof Parts>]>,
|
||||
Parts extends Record<string, [ name:string, loop?:"loop"] >,
|
||||
Desks extends Record<string, [ name:string, roles:Array<keyof Roles>, need:Partial<Record<keyof Parts, number>>, ...make:Array<keyof Parts>]>,
|
||||
>
|
||||
(
|
||||
params:{
|
||||
|
||||
@ -19,23 +19,25 @@ export default CreateAllRooms({
|
||||
admin:["Admin", "u4"]
|
||||
},
|
||||
part:{
|
||||
p1:"Page title",
|
||||
p2:"Page slug",
|
||||
p3:"Page preview",
|
||||
p4:"Page Project",
|
||||
p1:["Page title"],
|
||||
p2:["Page slug"],
|
||||
p3:["Page preview"],
|
||||
p4:["Page Project"],
|
||||
p5:["Page Corrections", "loop"],
|
||||
},
|
||||
desk:{
|
||||
d1:["Write page metas", ["admin", "write"], "all", {}, "p1", "p2"],
|
||||
d2:["Build Page preview", ["admin", "dev"], "all", {p1:1, p2:1}, "p3", "p4"]
|
||||
d1:["Write page metas", ["admin", "write"], { }, "p1", "p2"],
|
||||
d2:["Build Page preview", ["admin", "dev" ], {p1:1, p2:1, p5:1}, "p3", "p4"],
|
||||
d3:["Proof Page", ["admin", "write"], {p3:1, }, "p5" ]
|
||||
},
|
||||
pass:{
|
||||
pass_01:["January"],
|
||||
pass_02:["February"],
|
||||
pass_03:["March"],
|
||||
pass_04:["April"],
|
||||
pass_05:["May"],
|
||||
pass_06:["June"],
|
||||
pass_07:["July"],
|
||||
//pass_02:["February"],
|
||||
//pass_03:["March"],
|
||||
//pass_04:["April"],
|
||||
//pass_05:["May"],
|
||||
//pass_06:["June"],
|
||||
//pass_07:["July"],
|
||||
}
|
||||
})
|
||||
});
|
||||
@ -29,8 +29,13 @@ async function Interceptor(event)
|
||||
const text = await FSAccess.Read(handle, parts);
|
||||
if(text)
|
||||
{
|
||||
console.log("successful intercept:", pathname);
|
||||
return new Response(text, options);
|
||||
}
|
||||
else
|
||||
{
|
||||
console.log("failed intercept:", pathname);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user