Skip to content

Commit

Permalink
Upload Download POC
Browse files Browse the repository at this point in the history
  • Loading branch information
UnacceptableBehaviour committed Feb 13, 2025
1 parent 24c556a commit a0b302d
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 7 deletions.
4 changes: 2 additions & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,8 @@
</div>
<span class="flexrow-middle-space space-box"></span>
<div class="cloud-butn">
<img id="export-button-down" src="static/assets/icons/butn-DWN.svg" alt="Export">
<img id="export-button-up" src="static/assets/icons/butn-UP.svg" alt="Export">
<img id="export_button_get" src="static/assets/icons/butn-DWN.svg" alt="Export">
<img id="export_button_save" src="static/assets/icons/butn-UP.svg" alt="Export">
</div>
</div>

Expand Down
7 changes: 2 additions & 5 deletions docs/static/paycheck.css
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,6 @@ body {
align-items: center;
}

.flexrow-button-header-button {
/*text-align: center;*/
}

.flexrow-button-header-text {
flex-grow: 1;
Expand Down Expand Up @@ -212,7 +209,7 @@ body {
}


#calc_button, #export-button-up, #export-button-down {
#calc_button, #export_button_save, #export_button_get {
width: 10vw;
}
#quick_calc_hrs {
Expand Down Expand Up @@ -404,7 +401,7 @@ label.imgSelect input[accept*="image"] {


#ct_debug {
disply: none;
display: none;
}


Expand Down
38 changes: 38 additions & 0 deletions docs/static/paycheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,28 @@ class PayCycle4wk {
});
}

retrieveFromServer() {
fetch("https://127.0.0.1:50015/save", {
method: "GET",
headers: {
"Content-Type": "application/json",
}
})
.then((response) => {
if (!response.ok) {
throw new Error("Network response was not ok");
}
return response.json();
})
.then((data) => {
console.log("Successfully retrieved from server:", data);
// Process the retrieved data as needed
})
.catch((error) => {
console.error("There was a problem with the fetch operation:", error);
});
}

// call on submit & week change
updateModelFromForms() {
// cycle through days parse content into relevant object
Expand Down Expand Up @@ -1015,6 +1037,22 @@ window.addEventListener('load',function(){
});
}

// export_button_save
// export_button_get
if (document.querySelector('#export_button_save')) {
document.querySelector('#export_button_save').addEventListener('click', function(event){
console.log('[ S A V E ] JSON >> clicked');
pc.persistentSave(true); // true - push to cloud
});
}

if (document.querySelector('#export_button_get')) {
document.querySelector('#export_button_get').addEventListener('click', function(event){
console.log('[ G E T ] JSON >> clicked');
pc.retrieveFromServer();
});
}

// SERVICE WORKER i/f
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/paycheck/service_worker.js')
Expand Down

0 comments on commit a0b302d

Please sign in to comment.