Refine Maxi task board UX
This commit is contained in:
@@ -21,6 +21,7 @@ const openClawToken = process.env.OPENCLAW_GATEWAY_TOKEN || "";
|
||||
|
||||
const states = ["Backlog", "In progress", "Review", "Done", "Blocked"];
|
||||
const priorities = ["Low", "Medium", "High"];
|
||||
const assignees = ["luna", "maxi"];
|
||||
let db;
|
||||
|
||||
function mustEnv(name) {
|
||||
@@ -64,12 +65,12 @@ async function loadDb() {
|
||||
await mkdir(dataDir, { recursive: true });
|
||||
if (existsSync(dbPath)) {
|
||||
db = JSON.parse(await readFile(dbPath, "utf8"));
|
||||
db.settings = { openClawBaseUrl, defaultAssignee: "bao", timezone: "Europe/Berlin", ...(db.settings || {}) };
|
||||
if (!db.settings.defaultAssignee || db.settings.defaultAssignee.toLowerCase() === "luna") db.settings.defaultAssignee = "bao";
|
||||
db.settings = { openClawBaseUrl, defaultAssignee: "luna", timezone: "Europe/Berlin", ...(db.settings || {}) };
|
||||
db.settings.defaultAssignee = normalizeAssignee(db.settings.defaultAssignee);
|
||||
for (const task of db.tasks || []) {
|
||||
if (task.state === "In Progress") task.state = "In progress";
|
||||
if (task.priority === "Normal" || task.priority === "Urgent") task.priority = task.priority === "Urgent" ? "High" : "Medium";
|
||||
if (!task.assignee || task.assignee.toLowerCase() === "luna") task.assignee = "bao";
|
||||
task.assignee = normalizeAssignee(task.assignee);
|
||||
}
|
||||
await saveDb();
|
||||
} else {
|
||||
@@ -85,7 +86,7 @@ async function loadDb() {
|
||||
tasks: seedTasks(),
|
||||
settings: {
|
||||
openClawBaseUrl,
|
||||
defaultAssignee: "bao",
|
||||
defaultAssignee: "luna",
|
||||
timezone: "Europe/Berlin"
|
||||
}
|
||||
};
|
||||
@@ -102,7 +103,7 @@ function seedTasks() {
|
||||
detail: "Login, Board und Einstellungen pruefen; OpenClaw-Verbindung muss auf Maxis Gateway zeigen.",
|
||||
state: "Review",
|
||||
priority: "High",
|
||||
assignee: "bao",
|
||||
assignee: "luna",
|
||||
createdAt: now,
|
||||
updatedAt: now
|
||||
},
|
||||
@@ -112,7 +113,7 @@ function seedTasks() {
|
||||
detail: "Backlog als Eingang fuer Maxis operative Aufgaben nutzen.",
|
||||
state: "Backlog",
|
||||
priority: "Medium",
|
||||
assignee: "bao",
|
||||
assignee: "luna",
|
||||
createdAt: now,
|
||||
updatedAt: now
|
||||
}
|
||||
@@ -138,6 +139,11 @@ function send(res, status, value, headers = {}) {
|
||||
res.end(body);
|
||||
}
|
||||
|
||||
function normalizeAssignee(value) {
|
||||
const normalized = String(value || "").trim().toLowerCase();
|
||||
return assignees.includes(normalized) ? normalized : "luna";
|
||||
}
|
||||
|
||||
function getCookie(req, name) {
|
||||
const header = req.headers.cookie || "";
|
||||
return header.split(";").map((x) => x.trim()).find((x) => x.startsWith(`${name}=`))?.slice(name.length + 1);
|
||||
@@ -252,7 +258,7 @@ async function handleApi(req, res) {
|
||||
detail: String(body.detail || "").trim(),
|
||||
state: states.includes(body.state) ? body.state : "Backlog",
|
||||
priority: priorities.includes(body.priority) ? body.priority : "Medium",
|
||||
assignee: String(body.assignee || db.settings.defaultAssignee || "bao").trim(),
|
||||
assignee: normalizeAssignee(body.assignee || db.settings.defaultAssignee),
|
||||
createdAt: now,
|
||||
updatedAt: now
|
||||
};
|
||||
@@ -274,7 +280,7 @@ async function handleApi(req, res) {
|
||||
if (typeof body.detail === "string") task.detail = body.detail.trim();
|
||||
if (states.includes(body.state)) task.state = body.state;
|
||||
if (priorities.includes(body.priority)) task.priority = body.priority;
|
||||
if (typeof body.assignee === "string") task.assignee = body.assignee.trim();
|
||||
if (typeof body.assignee === "string") task.assignee = normalizeAssignee(body.assignee);
|
||||
task.updatedAt = new Date().toISOString();
|
||||
await saveDb();
|
||||
send(res, 200, { task });
|
||||
@@ -296,7 +302,7 @@ async function handleApi(req, res) {
|
||||
|
||||
if (url.pathname === "/api/settings" && req.method === "PATCH") {
|
||||
const body = await readJson(req);
|
||||
if (typeof body.defaultAssignee === "string") db.settings.defaultAssignee = body.defaultAssignee.trim() || "bao";
|
||||
if (typeof body.defaultAssignee === "string") db.settings.defaultAssignee = normalizeAssignee(body.defaultAssignee);
|
||||
if (typeof body.timezone === "string") db.settings.timezone = body.timezone.trim() || "Europe/Berlin";
|
||||
await saveDb();
|
||||
send(res, 200, { settings: db.settings, openClaw: await openClawStatus() });
|
||||
|
||||
Reference in New Issue
Block a user