Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ config.py
config.json
*.pyc
*.swp
.log
.log*
.lock
11 changes: 11 additions & 0 deletions config_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ def upload(self):
json.dump(input_json, f, indent=2, separators=(',', ': '))
self.index()

@cherrypy.expose
def start(self):
with open(".lock", 'w') as f:
f.write("1")
self.index()

@cherrypy.expose
def stop(self):
with open(".lock", 'w') as f:
f.write("0")
self.index()

@cherrypy.expose
def log(self):
Expand Down
27 changes: 27 additions & 0 deletions html/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="serialize_script.js"></script>
<script>
// Run the start or stop method from config_webpage.py depending on slider position.
function startstop() {
var xhr = new XMLHttpRequest();
if (document.getElementById('start').checked == false) {
xhr.open('GET', 'stop', true);
xhr.onload = function () {
console.log(xhr.responseURL);
};
xhr.send(null);
} else {
xhr.open('GET', 'start', true);
xhr.onload = function () {
console.log(xhr.responseURL);
};
xhr.send(null);
}
}
</script>
<script>
function config_save() {
json_obj = $('#config_data').serializeJSON({checkboxUncheckedValue: "false", parseBooleans: true});
Expand Down Expand Up @@ -96,6 +115,14 @@
<div id="lcloud"><img src="chancetstorms.png" height="256" width="256"></div>
<div id="rcloud"><img src="chancetstorms.png" height="256" width="256"></div>
<div class="page_title">PiWeatherRock Configuration Page</div>
<div id="start_toggle">
<div class="left">Stop</div>
<label class="switch">
<input type="checkbox" id="start" onclick="startstop()">
<span class="slider round"></span>
</label>
<div class="right">Start</div>
</div>
<div name="version" id="version"></div>
<!-- Rounded switch -->
<div id="toggle">
Expand Down
3 changes: 3 additions & 0 deletions scripts/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
if key not in old_config.keys():
old_config[key] = new_config[key]

# Update version
old_config["version"] = new_config["version"]

with open("config.json", "w") as f:
json.dump(old_config, f)

Loading