fully stub out export
This commit is contained in:
4
mod.ts
4
mod.ts
@@ -75,7 +75,7 @@ Deno.serve({ port: config.api.port }, async (req) => {
|
|||||||
|
|
||||||
return genericResponse(STATUS_CODE.OK, JSON.stringify(plans));
|
return genericResponse(STATUS_CODE.OK, JSON.stringify(plans));
|
||||||
} else if (path.startsWith('/export/')) {
|
} else if (path.startsWith('/export/')) {
|
||||||
const userId = path.replace('/list/', '');
|
const userId = path.replace('/export/', '');
|
||||||
const userMatch = await dbClient.query('SELECT id FROM users WHERE id = ?', [userId]).catch(() => {
|
const userMatch = await dbClient.query('SELECT id FROM users WHERE id = ?', [userId]).catch(() => {
|
||||||
failed = true;
|
failed = true;
|
||||||
});
|
});
|
||||||
@@ -83,7 +83,7 @@ Deno.serve({ port: config.api.port }, async (req) => {
|
|||||||
if (!userMatch.length) return genericResponse(STATUS_CODE.NotFound, 'User ID does not exist.');
|
if (!userMatch.length) return genericResponse(STATUS_CODE.NotFound, 'User ID does not exist.');
|
||||||
|
|
||||||
// WIP: export plans to zip code goes here
|
// WIP: export plans to zip code goes here
|
||||||
return genericResponse(STATUS_CODE.NotImplemented, 'WIP');
|
return genericResponse(STATUS_CODE.NotImplemented, 'Export function WIP.');
|
||||||
}
|
}
|
||||||
} else if (req.method === 'POST' && path === '/enroll') {
|
} else if (req.method === 'POST' && path === '/enroll') {
|
||||||
const body = await req.json();
|
const body = await req.json();
|
||||||
|
|||||||
@@ -49,6 +49,11 @@ if(r.status===200){localStorage.setItem('name',userName);r.text().then((text)=>{
|
|||||||
else{r.text().then((text)=>{alert(text);});}
|
else{r.text().then((text)=>{alert(text);});}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
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}\`);}
|
function openPlan(planId){window.open(\`${config.api.publicDomain}#/share/\${planId}\`);}
|
||||||
async function sharePlan(planId){
|
async function sharePlan(planId){
|
||||||
const link=\`${config.api.publicDomain}#/share/\${planId}\`;
|
const link=\`${config.api.publicDomain}#/share/\${planId}\`;
|
||||||
@@ -59,6 +64,7 @@ catch (error){prompt('Failed to copy to clipboard, please select and copy the li
|
|||||||
<p>This is a very basic management page. Please excuse the number of alert/prompts that will come up when you click on things as it was the quickest way to build it out.</p>
|
<p>This is a very basic management page. Please excuse the number of alert/prompts that will come up when you click on things as it was the quickest way to build it out.</p>
|
||||||
<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>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>
|
||||||
<h3>${userName}'s Plans:</h3>
|
<h3>${userName}'s Plans:</h3>
|
||||||
|
<button onclick="exportPlans()" disabled style="color:black;cursor:not-allowed;">WIP: export all plans</button>
|
||||||
<ul>
|
<ul>
|
||||||
${plans.map((plan) => makePlanItem(plan, false)).join('')}
|
${plans.map((plan) => makePlanItem(plan, false)).join('')}
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
Reference in New Issue
Block a user