Skip to content

Commit

Permalink
deploy permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
ForrestFire0 committed Oct 22, 2024
1 parent b994186 commit da49b96
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ async function loadReturnPage() {

async function loadSettingsPage() {
setPage('settings')
renderSettings();
await renderSettings();
}


Expand Down
20 changes: 19 additions & 1 deletion src/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ export async function renderSettings() {
<button id="addItemButton">Add Item</button>
</fieldset>
<fieldset style="height: 100px; overflow-y: scroll">
<legend>Purchase / Refund History</legend>
<legend>Purchase / Refund History
<button id="downloadHistoryAsCSV">download</button>
</legend>
<table>
<tr>
<th>Section</th>
Expand Down Expand Up @@ -95,6 +97,22 @@ export async function renderSettings() {
renderSettings();
}

document.getElementById('downloadHistoryAsCSV').onclick = () => {
// Takes the entire history, writes it to a CSV file, and downloads it.
// First row should be labels. Same format as table.
// Note: The locale time string has a comma, so I just added the date AND time in separate columns.
const csv = Object.values(history).toReversed().map(({section, mission, action, what, time, who}) =>
`${section},${mission},${action},${what},${new Date(time).toLocaleString()},${who}`
).join('\n');
const header = 'Section,Mission,Action,What,Date,Time,TF\n';
const blob = new Blob([header + csv], {type: 'text/csv'});
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'history.csv';
a.click();
}

document.getElementById('done').onclick = () => {
setPage('home');
}
Expand Down

0 comments on commit da49b96

Please sign in to comment.