Skip to content

Commit

Permalink
feat(downloadjson): add download as shortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
schirrel committed Jul 25, 2023
1 parent d4ffbca commit 1c54c2a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
6 changes: 3 additions & 3 deletions page/.firebase/hosting.cHVibGlj.cache
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ assets/css/style.css,1690294343983,48298a73e4a3d2cecef0cc5a33f9413eacd66b4dad995
assets/js/components.js,1690298353204,c2d70f1f24d3b9952ef9ce595fdaa5d16e8cc81bffc581c2cbd95bc0fe2657f1
assets/js/firebase.js,1675338834034,0fc4b19187ac04b74cdf0f281d09cbcb353e02a54468715dd5d24d180f7c00e5
assets/js/script.js,1675341863330,2e4e88a67941bf980503df3e6d5ce5eb61b00a73433fb8aa3e802a638bf95ee5
watch/index.html,1690295468387,78de29bcd3f6d3a7e3aea365b90182ece9c0bb6cf8e1c7b152385c7131fce11b
assets/css/watch.css,1690303462690,d5c3e16c5c1793bad4180add6735c393f0a9a3dd3d1666dad939635314d074e9
assets/js/watch.js,1690302694324,524366d3bb6cd2f018f60b4e4f8d550a1b6a13f2c37431eb1254f864c57a33da
assets/css/watch.css,1690305912611,9765b340d063c5e435818c68e270ad56fab4067c66adb7e3db0135e4fbdf01d2
watch/index.html,1690305946084,4725abbfe47d480e4cdd807d8a51ca7a4234e90b4a783b050fb47c64983ea54f
assets/js/watch.js,1690306042688,ea34af30a531cd6ad3e335b24c79e656260ed9e6faa4a4571277ec374735aabb
19 changes: 18 additions & 1 deletion page/public/assets/js/watch.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const watchButton = document.querySelector("#watchButton");
const table = document.querySelector("table");
const tableTbody = document.querySelector("table tbody");

const current = [];
const db = firebase.firestore();
const getArgumentsFormatted = (args) => {
if (Object.keys(args) && Object.keys(args).length === 1) {
Expand All @@ -17,6 +17,7 @@ const renderTable = (list) => {
return new Date(b.args.date) - new Date(a.args.date);
})
.map((data) => {
current.push(data);
const log = data.args;
return `
<tr class="${log.type}">
Expand Down Expand Up @@ -74,3 +75,19 @@ if (window.location.search) {
startWatcher(id);
}
}

window.addEventListener("keypress", ($event) => {
console.log($event);
if ($event.ctrlKey && $event.key === "d") {
const comd = confirm("Want to download the current log as json?");
if (comd === true) {
const dataStr =
"data:text/json;charset=utf-8," +
encodeURIComponent(JSON.stringify(current));
const dlAnchorElem = document.createElement("a");
dlAnchorElem.setAttribute("href", dataStr);
dlAnchorElem.setAttribute("download", `remote-logger-${loggerId.valueß}.json`);
dlAnchorElem.click();
}
}
});
2 changes: 0 additions & 2 deletions page/public/watch/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
<button id="watchButton" type="click">Watch</button>
</div>

<!-- <section id="loggerDevtools"></section> -->

<table hidden>
<thead>
<th>Date</th>
Expand Down

0 comments on commit 1c54c2a

Please sign in to comment.