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_current_settings['locations'] = current_weathers
all_daily_settings['locations'] = daily_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_current_settings, open( "csv/current_weather.json", 'w+' ))
json.dump( all_daily_settings, open( "csv/daily_weather.json", 'w+' )) json.dump( all_daily_settings, open( "csv/daily_weather.json", 'w+' ))
@ -611,7 +611,7 @@ if __name__ == '__main__':
last_updates = {"stocks": "27/06/2021 07:05:39", "crypto": "27/06/2021 07:05:39", "news": "27/06/2021 07:05:39", "weather": "27/06/2021 07:05:39", "forex": "27/06/2021 07:05:39", "sports": "27/06/2021 07:05:39"} last_updates = {"stocks": "27/06/2021 07:05:39", "crypto": "27/06/2021 07:05:39", "news": "27/06/2021 07:05:39", "weather": "27/06/2021 07:05:39", "forex": "27/06/2021 07:05:39", "sports": "27/06/2021 07:05:39"}
t = time.time() t = time.time()
try: try:
while True: while True:

View File

@ -242,6 +242,12 @@ def restart():
os.system("sudo reboot now") os.system("sudo reboot now")
return index() 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']) @app.route("/save", methods = ['PUT', 'POST', 'GET'])
def save(): def save():
print('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", ""); availableFeature.setAttribute("class", "");
} else { } else {
availableFeature.setAttribute("class", "active"); availableFeature.setAttribute("class", "active");
// let getCustomImages = JSON.parse( let getCustomImages = JSON.parse(
// localStorage.getItem("customImages") localStorage.getItem("customImages")
// ); );
// let getCustomGifs = JSON.parse(localStorage.getItem("customGifs")); let getCustomGifs = JSON.parse(localStorage.getItem("customGifs"));
// let getCustomMsg = JSON.parse(localStorage.getItem("customMsg")); let getCustomMsg = JSON.parse(localStorage.getItem("customMsg"));
getCustomImages.map((value) => { getCustomImages.map((value) => {
let scrollSpeed1 = document.getElementById("inputScrollSpeed11"); let scrollSpeed1 = document.getElementById("inputScrollSpeed11");
@ -487,28 +487,28 @@ allFeaturesRemoveBtns.map((value, index) => {
console.log(item); console.log(item);
if (item.getAttribute("class") == "active") { if (item.getAttribute("class") == "active") {
if (item.parentElement.getAttribute("id") == "images-features") { 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( let filter = getImages.filter(
(value) => value.fileName !== item.innerText (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") { } 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( let filter = getGifs.filter(
(value) => value.fileName !== item.innerText (value) => value.fileName !== item.innerText
); );
// localStorage.setItem("customGifs", JSON.stringify(filter)); localStorage.setItem("customGifs", JSON.stringify(filter));
} else if ( } else if (
item.parentElement.getAttribute("id") == "messages-features" item.parentElement.getAttribute("id") == "messages-features"
) { ) {
// let getMsgs = JSON.parse(localStorage.getItem("customMsg")); let getMsgs = JSON.parse(localStorage.getItem("customMsg"));
let filter = getMsgs.filter( 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 { else {
item.remove(); item.remove();
@ -789,7 +789,7 @@ allFeaturesTextAddBtn.map((value, index) => {
displayCheck, displayCheck,
}; };
// let getCustomMsg = localStorage.getItem("customMsg"); let getCustomMsg = localStorage.getItem("customMsg");
let newValues = getCustomMsg && JSON.parse(getCustomMsg); let newValues = getCustomMsg && JSON.parse(getCustomMsg);
getCustomMsg && newValues.push(values); 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"); var stopButton = document.getElementById("stop-btn");
stopButton.addEventListener("click", () => { stopButton.addEventListener("click", () => {
@ -877,8 +885,8 @@ stopButton.addEventListener("click", () => {
var stopButton = document.getElementById("screensaver-btn"); var screensaverButton = document.getElementById("screensaver-btn");
stopButton.addEventListener("click", () => { screensaverButton.addEventListener("click", () => {
let anim = localStorage.getItem("inputAnimation"); let anim = localStorage.getItem("inputAnimation");
@ -1211,7 +1219,7 @@ allFeaturesFileAddBtn.map((value, index) => {
var tag = document.createElement("li"); var tag = document.createElement("li");
tag.innerHTML = allFeaturesFile[index].files[0].name; tag.innerHTML = allFeaturesFile[index].files[0].name;
if (index == 10) { if (index == 10) {
// let getCustomImg = localStorage.getItem("customImages"); let getCustomImg = localStorage.getItem("customImages");
let fileName = imagesFile.files[0].name; let fileName = imagesFile.files[0].name;
let scrollSpeed = document.getElementById("inputScrollSpeed11").value; let scrollSpeed = document.getElementById("inputScrollSpeed11").value;
let scrollSpeed2 = document.getElementById( let scrollSpeed2 = document.getElementById(
@ -1249,7 +1257,7 @@ allFeaturesFileAddBtn.map((value, index) => {
allFeatures[index].appendChild(tag); allFeatures[index].appendChild(tag);
} }
} else if (index == 11) { } else if (index == 11) {
// let getCustomGifs = localStorage.getItem("customGifs"); let getCustomGifs = localStorage.getItem("customGifs");
let fileName = allFeaturesFile[index].files[0].name; let fileName = allFeaturesFile[index].files[0].name;
let scrollSpeed = document.getElementById("inputScrollSpeed12").value; let scrollSpeed = document.getElementById("inputScrollSpeed12").value;
let scrollSpeed2 = document.getElementById( let scrollSpeed2 = document.getElementById(

View File

@ -84,6 +84,11 @@
</div> </div>
<div class="col-lg-2 col-md-2 col-sm-2"> <div class="col-lg-2 col-md-2 col-sm-2">
<a id="shutdown-btn" class="btn btn-danger">Shut Down</a> <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>
</div> </div>
<!-- End Button List --> <!-- End Button List -->