implement export all

This commit is contained in:
Ean Milligan
2026-04-24 14:28:01 -04:00
parent 31e3e13ab9
commit f412f06e10
7 changed files with 85 additions and 24 deletions

View File

@@ -11,8 +11,8 @@ interface Plan {
const makePlanButtons = (planId: string, deleted: boolean) =>
deleted
? `<button onclick="doAction('undelete','${planId}')">restore</button><button onclick="doAction('perm-delete','${planId}')">perm delete</button>`
: `<button onclick="openPlan('${planId}')">open</button><button onclick="sharePlan('${planId}')">share</button><button onclick="doAction('rename','${planId}')">rename</button><button onclick="doAction('move','${planId}')">move</button><button onclick="doAction('delete','${planId}')">delete</button>`;
? `<button class="btn" onclick="doAction('undelete','${planId}')">restore</button><button class="btn" onclick="doAction('perm-delete','${planId}')">perm delete</button>`
: `<button class="btn" onclick="openPlan('${planId}')">open</button><button class="btn" onclick="sharePlan('${planId}')">share</button><button class="btn" onclick="doAction('rename','${planId}')">rename</button><button class="btn" onclick="doAction('move','${planId}')">move</button><button class="btn" onclick="doAction('delete','${planId}')">delete</button>`;
const makePlanItem = (plan: Plan, deleted: boolean) =>
`<li>${plan.folder}${plan.folder && '/'}${plan.name} - ${plan.lastUpdated.toLocaleString()} - ${makePlanButtons(plan.id, deleted)}</li>`;
@@ -82,19 +82,6 @@ function doAction(action, planId) {
}
});
}
function exportPlans() {
fetch('/api/export/${userId}')
.catch((e) => {
e.text().then((text) => {
alert(text);
});
})
.then((r) => {
r.text().then((text) => {
alert(text);
});
});
}
function openPlan(planId) {
window.open(\`${config.api.publicDomain}share#\${planId}\`);
}
@@ -165,7 +152,7 @@ function deleteAccount() {
<p>Please note: anything modifying data will require you to enter your PIN again as both the web view you are looking at and server behind it are completely stateless for simplicity.</p>
<p>DateTimeStamps on this page are all displayed in the US Eastern time zone. I don't care enough to make this extremely basic page dynamic.</p>
<h3>${userName}'s Plans:</h3>
<button onclick="exportPlans()" disabled style="color:black;cursor:not-allowed;">WIP: export all plans</button>
<a href="/api/export/${userId}" download="${userName}-plans.zip" class="btn">download all plans</a>
<ul>
${plans.map((plan) => makePlanItem(plan, false)).join('')}
</ul>
@@ -173,6 +160,6 @@ ${plans.map((plan) => makePlanItem(plan, false)).join('')}
<ul>
${deletedPlans.map((plan) => makePlanItem(plan, true)).join('')}
</ul>
<button onclick="deleteAccount()">Delete my account</button>
<button class="btn" onclick="deleteAccount()">Delete my account</button>
</div>`;
};

View File

@@ -20,6 +20,15 @@ a {
text-decoration:none;
color:white;
}
.btn {
font: 13.333px Sans;
padding: 1px 6px;
border: 1px outset buttonborder;
border-radius: 3px;
color: buttontext;
background-color: buttonface;
text-decoration: none;
}
li {
margin:0.5rem 0;
}