added reset button and fixed javascript bugs

This commit is contained in:
Neythen Treloar 2022-02-26 16:35:15 +00:00
parent d71b2af8fb
commit 20bfab5574
6 changed files with 42 additions and 23 deletions

View File

@ -1 +1 @@
{"update_available": false, "first_boot": false}
{"update_available": false, "first_boot": true}

View File

@ -345,7 +345,7 @@ def updateWeather(api_key):
all_current_settings['locations'] = current_weathers
all_daily_settings['locations'] = daily_weathers
print(all_current_settings, all_daily_settings)
json.dump( all_current_settings, open( "csv/current_weather.json", 'w+' ))
json.dump( all_daily_settings, open( "csv/daily_weather.json", 'w+' ))

View File

@ -242,6 +242,12 @@ def restart():
os.system("sudo reboot now")
return index()
@app.route("/reset")
def reset():
print('reset')
os.system("sudo ./setup_config_files.sh")
return index()
@app.route("/save", methods = ['PUT', 'POST', 'GET'])
def save():
print('save')

File diff suppressed because one or more lines are too long

View File

@ -345,11 +345,11 @@ const addEventOnFeaturesList = () => {
availableFeature.setAttribute("class", "");
} else {
availableFeature.setAttribute("class", "active");
// let getCustomImages = JSON.parse(
// localStorage.getItem("customImages")
// );
// let getCustomGifs = JSON.parse(localStorage.getItem("customGifs"));
// let getCustomMsg = JSON.parse(localStorage.getItem("customMsg"));
let getCustomImages = JSON.parse(
localStorage.getItem("customImages")
);
let getCustomGifs = JSON.parse(localStorage.getItem("customGifs"));
let getCustomMsg = JSON.parse(localStorage.getItem("customMsg"));
getCustomImages.map((value) => {
let scrollSpeed1 = document.getElementById("inputScrollSpeed11");
@ -487,28 +487,28 @@ allFeaturesRemoveBtns.map((value, index) => {
console.log(item);
if (item.getAttribute("class") == "active") {
if (item.parentElement.getAttribute("id") == "images-features") {
// let getImages = JSON.parse(localStorage.getItem("customImages"));
let getImages = JSON.parse(localStorage.getItem("customImages"));
let filter = getImages.filter(
(value) => value.fileName !== item.innerText
);
// localStorage.setItem("customImages", JSON.stringify(filter));
localStorage.setItem("customImages", JSON.stringify(filter));
} else if (item.parentElement.getAttribute("id") == "gifs-features") {
// let getGifs = JSON.parse(localStorage.getItem("customGifs"));
let getGifs = JSON.parse(localStorage.getItem("customGifs"));
let filter = getGifs.filter(
(value) => value.fileName !== item.innerText
);
// localStorage.setItem("customGifs", JSON.stringify(filter));
localStorage.setItem("customGifs", JSON.stringify(filter));
} else if (
item.parentElement.getAttribute("id") == "messages-features"
) {
// let getMsgs = JSON.parse(localStorage.getItem("customMsg"));
let getMsgs = JSON.parse(localStorage.getItem("customMsg"));
let filter = getMsgs.filter(
(value) => value.messageName !== item.innerText
(value) => value.messageName !== item.innerText
);
// localStorage.setItem("customMsg", JSON.stringify(filter));
localStorage.setItem("customMsg", JSON.stringify(filter));
}
else {
item.remove();
@ -789,7 +789,7 @@ allFeaturesTextAddBtn.map((value, index) => {
displayCheck,
};
// let getCustomMsg = localStorage.getItem("customMsg");
let getCustomMsg = localStorage.getItem("customMsg");
let newValues = getCustomMsg && JSON.parse(getCustomMsg);
getCustomMsg && newValues.push(values);
@ -867,6 +867,14 @@ restartButton.addEventListener("click", () => {
});
});
var resetButton = document.getElementById("reset-btn");
resetButton.addEventListener("click", () => {
fetch("/reset", {
method: "GET",
});
});
var stopButton = document.getElementById("stop-btn");
stopButton.addEventListener("click", () => {
@ -877,8 +885,8 @@ stopButton.addEventListener("click", () => {
var stopButton = document.getElementById("screensaver-btn");
stopButton.addEventListener("click", () => {
var screensaverButton = document.getElementById("screensaver-btn");
screensaverButton.addEventListener("click", () => {
let anim = localStorage.getItem("inputAnimation");
@ -1211,7 +1219,7 @@ allFeaturesFileAddBtn.map((value, index) => {
var tag = document.createElement("li");
tag.innerHTML = allFeaturesFile[index].files[0].name;
if (index == 10) {
// let getCustomImg = localStorage.getItem("customImages");
let getCustomImg = localStorage.getItem("customImages");
let fileName = imagesFile.files[0].name;
let scrollSpeed = document.getElementById("inputScrollSpeed11").value;
let scrollSpeed2 = document.getElementById(
@ -1249,7 +1257,7 @@ allFeaturesFileAddBtn.map((value, index) => {
allFeatures[index].appendChild(tag);
}
} else if (index == 11) {
// let getCustomGifs = localStorage.getItem("customGifs");
let getCustomGifs = localStorage.getItem("customGifs");
let fileName = allFeaturesFile[index].files[0].name;
let scrollSpeed = document.getElementById("inputScrollSpeed12").value;
let scrollSpeed2 = document.getElementById(

View File

@ -85,6 +85,11 @@
<div class="col-lg-2 col-md-2 col-sm-2">
<a id="shutdown-btn" class="btn btn-danger">Shut Down</a>
</div>
<div class="col-lg-2 col-md-2 col-sm-2">
<a id="reset-btn" class="btn btn-danger">Reset User Settings</a>
</div>
</div>
<!-- End Button List -->