Files
OmO Orchestrator 942ceda7e5 feat: add three sample uploadable mini-apps
Self-contained XHTML bundles (Shift Log, Tool Library, Gratitude Wall) that
mount through the real upload/publish path and use the window.commons SDK.
Published to /api/blob and verified mounting + executing in a real browser.
2026-11-20 02:30:03 -05:00

101 lines
4.1 KiB
HTML

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style>
.commons-app { font-family: system-ui, sans-serif; max-width: 560px; margin: 0 auto; padding: 16px; color: #1f2329; }
.commons-app h2 { font-size: 20px; margin: 0 0 4px; }
.commons-app .sub { color: #6b7280; font-size: 13px; margin: 0 0 16px; }
.commons-app .row { display: flex; gap: 8px; margin-bottom: 8px; }
.commons-app input { flex: 1; padding: 10px; border: 1px solid #d0d5dd; border-radius: 8px; font-size: 14px; }
.commons-app button { background: #1677FF; color: #fff; border: 0; border-radius: 8px; padding: 10px 16px; font-size: 14px; cursor: pointer; }
.commons-app button:hover { background: #0f5ed6; }
.commons-app h3 { font-size: 15px; margin: 18px 0 8px; }
.commons-app ul { list-style: none; padding: 0; margin: 0; }
.commons-app li { display: flex; justify-content: space-between; align-items: center; border: 1px solid #eef0f3; border-radius: 8px; padding: 10px 12px; margin-bottom: 6px; font-size: 14px; }
.commons-app li.out { background: #fff7ed; border-color: #fed7aa; }
.commons-app li .tag { font-size: 12px; color: #6b7280; }
.commons-app li button { padding: 6px 10px; font-size: 12px; }
.commons-app li.out button { background: #16a34a; }
.commons-app .empty { color: #9aa1ab; font-size: 13px; padding: 12px 0; }
</style>
</head>
<body>
<div class="commons-app">
<h2>Tool Library</h2>
<p class="sub">Shared tools in the Hollow. Borrow one, return it when you are done - every move is a signed event.</p>
<div class="row">
<input id="tool" type="text" placeholder="tool name (e.g. torque wrench)" />
<button id="add-btn" type="button">Check out</button>
</div>
<h3>Tools</h3>
<ul id="list"></ul>
<p id="empty" class="empty">No tools tracked yet. Check one out above.</p>
</div>
<script>
<![CDATA[
(function () {
var api = window.commons;
var listEl = document.getElementById("list");
var emptyEl = document.getElementById("empty");
function statusByTool(entries) {
var state = {};
for (var i = 0; i < entries.length; i++) {
var p = entries[i].payload;
if (!p || !p.tool) { continue; }
if (p.type === "toollibrary.borrow") { state[p.tool] = "out"; }
else if (p.type === "toollibrary.return") { state[p.tool] = "in"; }
}
return state;
}
function move(tool, type) {
api.eventlog.append({ type: type, tool: tool }).then(refresh);
}
function render(entries) {
var state = statusByTool(entries);
var tools = Object.keys(state).sort();
emptyEl.style.display = tools.length === 0 ? "block" : "none";
listEl.innerHTML = "";
tools.forEach(function (tool) {
var isOut = state[tool] === "out";
var li = document.createElement("li");
if (isOut) { li.className = "out"; }
var left = document.createElement("div");
var name = document.createElement("div");
name.textContent = tool;
var tag = document.createElement("div");
tag.className = "tag";
tag.textContent = isOut ? "checked out" : "available";
left.appendChild(name);
left.appendChild(tag);
var btn = document.createElement("button");
btn.type = "button";
btn.textContent = isOut ? "Return" : "Borrow";
btn.addEventListener("click", function () {
move(tool, isOut ? "toollibrary.return" : "toollibrary.borrow");
});
li.appendChild(left);
li.appendChild(btn);
listEl.appendChild(li);
});
}
function refresh() {
api.eventlog.readAll().then(render);
}
document.getElementById("add-btn").addEventListener("click", function () {
var tool = document.getElementById("tool").value.trim();
if (!tool) { return; }
document.getElementById("tool").value = "";
move(tool, "toollibrary.borrow");
});
refresh();
})();
]]>
</script>
</body>
</html>