add dev mode support
This commit is contained in:
2668
rust/src_webpack/package-lock.json
generated
2668
rust/src_webpack/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,9 +1,11 @@
|
||||
{
|
||||
"devDependencies": {
|
||||
"copy-webpack-plugin": "^12.0.2",
|
||||
"ts-loader": "^9.5.1",
|
||||
"typescript": "^5.3.3",
|
||||
"webpack": "^5.89.0",
|
||||
"webpack-cli": "^5.1.4"
|
||||
"webpack-cli": "^5.1.4",
|
||||
"webpack-dev-server": "^5.1.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"source-map-loader": "^4.0.1"
|
||||
|
@@ -1,3 +1,6 @@
|
||||
declare var PUBLIC_URL: string;
|
||||
|
||||
|
||||
let battery_flash_button = document.getElementById("battery_flash_button") as HTMLButtonElement;
|
||||
let battery_flash_file = document.getElementById("battery_flash_file") as HTMLInputElement;
|
||||
let battery_flash_message = document.getElementById("battery_flash_message") as HTMLElement;
|
||||
@@ -36,6 +39,6 @@ battery_flash_button.onclick = async function (){
|
||||
//ajax.open("POST", "/flashbattery");
|
||||
//ajax.send(battery_flash_file.files[0]);
|
||||
|
||||
ajax.open("POST", "/flashbattery?flash=true");
|
||||
ajax.open("POST", PUBLIC_URL + "/flashbattery?flash=true");
|
||||
ajax.send(battery_flash_file.files[0]);
|
||||
};
|
||||
|
@@ -1,3 +1,6 @@
|
||||
declare var PUBLIC_URL: string;
|
||||
console.log("Url is " + PUBLIC_URL);
|
||||
|
||||
interface PlantConfig {
|
||||
ap_ssid: string,
|
||||
ssid: string,
|
||||
@@ -64,14 +67,14 @@ function setTime(){
|
||||
time : new Date().toISOString()
|
||||
}
|
||||
var pretty = JSON.stringify(value, undefined, 1);
|
||||
fetch("/time", {
|
||||
fetch(PUBLIC_URL + "/time", {
|
||||
method :"POST",
|
||||
body: pretty
|
||||
})
|
||||
}
|
||||
|
||||
function updateTime(){
|
||||
fetch("/data")
|
||||
fetch(PUBLIC_URL +"/data")
|
||||
.then(response => response.json())
|
||||
.then(json => json as GetData)
|
||||
.then(time => {
|
||||
@@ -119,7 +122,7 @@ export function scanWifi(){
|
||||
scanButton.disabled = false;
|
||||
alert("Failed to start see console")
|
||||
}
|
||||
ajax.open("POST", "/wifiscan");
|
||||
ajax.open("POST", PUBLIC_URL+"/wifiscan");
|
||||
ajax.send();
|
||||
}
|
||||
|
||||
@@ -453,7 +456,7 @@ let fromWrapper = (() => {
|
||||
|
||||
submitFormBtn.onclick = function (){
|
||||
updateJson()
|
||||
fetch("/set_config", {
|
||||
fetch(PUBLIC_URL+"/set_config", {
|
||||
method :"POST",
|
||||
body: json.value,
|
||||
|
||||
@@ -465,7 +468,7 @@ let fromWrapper = (() => {
|
||||
|
||||
}
|
||||
|
||||
fetch("/get_config")
|
||||
fetch(PUBLIC_URL+"/get_config")
|
||||
.then(response => response.json())
|
||||
.then(loaded => {
|
||||
var currentConfig = loaded as PlantConfig;
|
||||
|
131
rust/src_webpack/src/index.html
Normal file
131
rust/src_webpack/src/index.html
Normal file
@@ -0,0 +1,131 @@
|
||||
<html>
|
||||
<head>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<input type="button" id="test" value="Test">
|
||||
<h2>Current Firmware</h2>
|
||||
<div>
|
||||
<div id="firmware_buildtime">Buildtime loading</div>
|
||||
<div id="firmware_githash">Build githash loading</div>
|
||||
</div>
|
||||
<h2>Time</h2>
|
||||
<div>
|
||||
<div id="esp_time">Esp time</div>
|
||||
<div id="rtc_time">Rtc time</div>
|
||||
<div id="browser_time">Rtc time</div>
|
||||
<div>Store Browser time into esp and rtc</div>
|
||||
<input type="button" id="time_upload" value="write">
|
||||
</div>
|
||||
|
||||
<h2>firmeware OTA v3</h2>
|
||||
|
||||
<form id="upload_form" method="post">
|
||||
<input type="file" name="file1" id="file1"><br>
|
||||
<progress id="progressBar" value="0" max="100" style="width:300px;"></progress>
|
||||
<h3 id="status"></h3>
|
||||
<h3 id="answer"></h3>
|
||||
<p id="loaded_n_total"></p>
|
||||
</form>
|
||||
|
||||
<div>
|
||||
<h2>WIFI</h2>
|
||||
<input type="button" id="scan" value="Scan">
|
||||
<br>
|
||||
<label for="ap_ssid">AP SSID:</label>
|
||||
<input type="text" id="ap_ssid" list="ssidlist">
|
||||
|
||||
<label for="ssid">SSID:</label>
|
||||
<input type="text" id="ssid" list="ssidlist">
|
||||
<datalist id="ssidlist">
|
||||
<option value="Not scanned yet">
|
||||
</datalist>
|
||||
<label for="ssid">Password:</label>
|
||||
<input type="text" id="password">
|
||||
</div>
|
||||
|
||||
|
||||
<h2>config</h2>
|
||||
|
||||
<div id="configform">
|
||||
<h3>Mqtt:</h3>
|
||||
<div>
|
||||
<input type="text" id="mqtt_url">
|
||||
MQTT Url
|
||||
</div>
|
||||
<div>
|
||||
<input type="text" id="base_topic">
|
||||
Base Topic
|
||||
</div>
|
||||
|
||||
|
||||
<h3>Tank:</h3>
|
||||
<div>
|
||||
<input type="checkbox" id="tank_sensor_enabled">
|
||||
Enable Tank Sensor
|
||||
</div>
|
||||
<div>
|
||||
<input type="checkbox" id="tank_allow_pumping_if_sensor_error">
|
||||
Allow Pumping if Sensor Error
|
||||
</div>
|
||||
|
||||
|
||||
<div>
|
||||
<input type="number" min="2" max="500000" id="tank_useable_ml">
|
||||
Tank Size mL
|
||||
</div>
|
||||
<div>
|
||||
<input type="number" min="1" max="500000" id="tank_warn_percent">
|
||||
Tank Warn Percent (mapped in relation to empty and full)
|
||||
</div>
|
||||
<div>
|
||||
<input type="number" min="0" max="100" id="tank_empty_percent">
|
||||
Tank Empty Percent (% max move)
|
||||
</div>
|
||||
<div>
|
||||
<input type="number" min="0" max="100" id="tank_full_percent">
|
||||
Tank Full Percent (% max move)
|
||||
</div>
|
||||
|
||||
<h3>Light:</h3>
|
||||
<div>
|
||||
Start
|
||||
<select type="time" id="night_lamp_time_start">
|
||||
</select>
|
||||
Stop
|
||||
<select type="time" id="night_lamp_time_end">
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<input type="checkbox" id="night_lamp_only_when_dark">
|
||||
Light only when dark
|
||||
</div>
|
||||
|
||||
<h2>Battery Firmeware (bq34z100 may be R2)</h2>
|
||||
<form id="upload_form" method="post">
|
||||
<input type="file" name="battery_flash_file" id="battery_flash_file"><br>
|
||||
<progress id="battery_flash_progressBar" value="0" max="100" style="width:300px;"></progress>
|
||||
<input type="button" name="battery_flash_button" id="battery_flash_button"><br>
|
||||
<h3 id="battery_flash_status"></h3>
|
||||
<p id="battery_flash_loaded_n_total"></p>
|
||||
<div style="height: 100px; display: block; overflow-y: auto;" id = "battery_flash_message"></div>
|
||||
</form>
|
||||
|
||||
<h3>Plants:</h3>
|
||||
|
||||
|
||||
<div>
|
||||
<input type="number" min="2" max="100" id="max_consecutive_pump_count">
|
||||
Max consecutive pump count:
|
||||
</div>
|
||||
|
||||
<div id="plants"></div>
|
||||
</div>
|
||||
<button id="submit">Submit</button>
|
||||
<div id="submit_status"></div>
|
||||
<br>
|
||||
<textarea id="json" cols=50 rows=10></textarea>
|
||||
<script src="bundle.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
@@ -1,3 +1,6 @@
|
||||
declare var PUBLIC_URL: string;
|
||||
|
||||
|
||||
export function uploadFile() {
|
||||
var file1 = document.getElementById("file1") as HTMLInputElement;
|
||||
var loaded_n_total = document.getElementById("loaded_n_total");
|
||||
@@ -29,7 +32,7 @@ export function uploadFile() {
|
||||
status.innerHTML = ajax.responseText;
|
||||
answer.innerHTML = "aborted";
|
||||
}, false);
|
||||
ajax.open("POST", "/ota");
|
||||
ajax.open("POST", PUBLIC_URL+"/ota");
|
||||
ajax.send(file);
|
||||
}
|
||||
|
||||
@@ -45,7 +48,7 @@ let firmware_buildtime = document.getElementById("firmware_buildtime") as HTMLDi
|
||||
let firmware_githash = document.getElementById("firmware_githash") as HTMLDivElement;
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
fetch("/version")
|
||||
fetch(PUBLIC_URL+"/version")
|
||||
.then(response => response.json())
|
||||
.then(json => json as VersionInfo)
|
||||
.then(versionInfo => {
|
||||
|
@@ -1,10 +1,37 @@
|
||||
|
||||
const webpack = require('webpack');
|
||||
const CopyPlugin = require("copy-webpack-plugin");
|
||||
const path = require('path');
|
||||
|
||||
const isDevServer = process.env.WEBPACK_SERVE;
|
||||
console.log("Dev server is " + isDevServer);
|
||||
var host;
|
||||
if (isDevServer){
|
||||
host = 'http://10.23.43.24';
|
||||
} else {
|
||||
host = '';
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
mode: "development",
|
||||
entry: ['./src/form.ts','./src/ota.ts', "./src/battery.ts"],
|
||||
devtool: 'inline-source-map',
|
||||
plugins: [
|
||||
new CopyPlugin({
|
||||
patterns: [
|
||||
{
|
||||
from: "src/index.html",
|
||||
to: "index.html"
|
||||
}
|
||||
]
|
||||
}),
|
||||
new webpack.DefinePlugin({
|
||||
PUBLIC_URL: JSON.stringify(host),
|
||||
}),
|
||||
new webpack.EnvironmentPlugin({
|
||||
redirect: 'true'
|
||||
})
|
||||
|
||||
],
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
@@ -21,4 +48,6 @@ module.exports = {
|
||||
filename: 'bundle.js',
|
||||
path: path.resolve(__dirname, '../src/webserver'),
|
||||
},
|
||||
devServer: {
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user