update
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"loop_activation": true,
|
||||
"loop_log": true,
|
||||
"boot_log": true,
|
||||
"deviceID": "XXXX",
|
||||
|
||||
@@ -60,27 +60,37 @@
|
||||
<form>
|
||||
|
||||
<div class="form-check form-switch mb-2">
|
||||
<input class="form-check-input" type="checkbox" role="switch" id="flexSwitchCheckDefault">
|
||||
<label class="form-check-label" for="flexSwitchCheckDefault">Loop Logs</label>
|
||||
<input class="form-check-input" type="checkbox" role="switch" id="flex_loop" onchange="update_config(this.checked)">
|
||||
<label class="form-check-label" for="flex_loop">Loop activation</label>
|
||||
</div>
|
||||
|
||||
<div class="form-check form-switch mb-2">
|
||||
<input class="form-check-input" type="checkbox" role="switch" id="flexSwitchCheckDefault">
|
||||
<label class="form-check-label" for="flexSwitchCheckDefault">Boot Logs</label>
|
||||
<input class="form-check-input" type="checkbox" role="switch" id="flex_loop_log">
|
||||
<label class="form-check-label" for="flex_loop_log">Loop Logs</label>
|
||||
</div>
|
||||
|
||||
<div class="form-check form-switch mb-2">
|
||||
<input class="form-check-input" type="checkbox" role="switch" id="flex_start_log">
|
||||
<label class="form-check-label" for="flex_start_log">Boot Logs</label>
|
||||
</div>
|
||||
|
||||
<div class="form-check mb-3">
|
||||
<input class="form-check-input" type="checkbox" value="" id="flexCheckDefault">
|
||||
<label class="form-check-label" for="flexCheckDefault">
|
||||
<input class="form-check-input" type="checkbox" value="" id="check_bme280s">
|
||||
<label class="form-check-label" for="check_bme280">
|
||||
Sonde temp/hum (BME280)
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="exampleInputEmail1" class="form-label">ssh tunnel port</label>
|
||||
<input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp">
|
||||
<label for="device_name" class="form-label">Device Name</label>
|
||||
<input type="text" class="form-control" id="device_name">
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="exampleInputPassword1" class="form-label">Password</label>
|
||||
<input type="password" class="form-control" id="exampleInputPassword1">
|
||||
<label for="device_ID" class="form-label">Device ID</label>
|
||||
<input type="text" class="form-control" id="device_ID" disabled>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
</form>
|
||||
</div>
|
||||
@@ -142,6 +152,29 @@ window.onload = function() {
|
||||
element.innerText = deviceName;
|
||||
});
|
||||
|
||||
//get BME check
|
||||
const checkbox = document.getElementById("check_bme280s");
|
||||
checkbox.checked = data.i2c_BME;
|
||||
|
||||
//loop activation
|
||||
const flex_loop = document.getElementById("flex_loop");
|
||||
flex_loop.checked = data.loop_activation;
|
||||
|
||||
//loop logs
|
||||
const flex_loop_log = document.getElementById("flex_loop_log");
|
||||
flex_loop_log.checked = data.loop_log;
|
||||
|
||||
//start logs
|
||||
const flex_start_log = document.getElementById("flex_start_log");
|
||||
flex_start_log.checked = data.boot_log;
|
||||
|
||||
//device name
|
||||
const device_name = document.getElementById("device_name");
|
||||
device_name.value = data.deviceName;
|
||||
|
||||
//device ID
|
||||
const device_ID = document.getElementById("device_ID");
|
||||
device_ID.value = data.deviceID.toUpperCase();
|
||||
|
||||
//get local RTC
|
||||
$.ajax({
|
||||
@@ -163,6 +196,21 @@ window.onload = function() {
|
||||
}
|
||||
|
||||
|
||||
function update_config(isChecked){
|
||||
console.log("Updated flex_loop:", isChecked);
|
||||
$.ajax({
|
||||
url: 'launcher.php?type=update_config',
|
||||
dataType: 'text', // Specify that you expect a JSON response
|
||||
method: 'GET', // Use GET or POST depending on your needs
|
||||
success: function(response) {
|
||||
console.log(response);
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error('AJAX request failed:', status, error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function updateGitPull(){
|
||||
console.log("Updating device (git pull)");
|
||||
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
<?php
|
||||
$type=$_GET['type'];
|
||||
|
||||
if ($type == "update_config") {
|
||||
echo "updating....";
|
||||
$configFile = '../config.json';
|
||||
$configData = json_decode(file_get_contents($configFile), true);
|
||||
$configData['loop_activation'] = true;
|
||||
file_put_contents($configFile, json_encode($configData, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
|
||||
echo "Config updated!";
|
||||
}
|
||||
|
||||
if ($type == "RTC_time") {
|
||||
$time = shell_exec("date '+%d/%m/%Y %H:%M:%S'");
|
||||
echo $time;
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
<?php
|
||||
$type=$_GET['type'];
|
||||
|
||||
if ($type == "update_config") {
|
||||
|
||||
echo "updating....";
|
||||
}
|
||||
|
||||
if ($type == "RTC_time") {
|
||||
$time = shell_exec("date '+%d/%m/%Y %H:%M:%S'");
|
||||
echo $time;
|
||||
|
||||
Reference in New Issue
Block a user