Browse Source

webmanifest tests (not working)

probably not working because it is not served over HTTPS
master
Youen 9 months ago
parent
commit
1b81c2764d
  1. 14
      ESP32/src/vehicle-monitor.cpp
  2. 1
      WebApp/package.json
  3. 3
      WebApp/src/app.css
  4. 1
      WebApp/src/app.ts
  5. 1
      WebApp/src/index.html
  6. 8
      WebApp/src/manifest.webmanifest
  7. 8
      WebApp/webpack.config.js

14
ESP32/src/vehicle-monitor.cpp

@ -18,7 +18,7 @@
#include <limits>
#define DUMMY_DATA 0
#define DUMMY_DATA 1
AsyncWebServer server(80);
@ -262,6 +262,11 @@ void setup()
// Special case to send index.html without caching
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){ request->send(SPIFFS, "/www/index.html", "text/html"); });
server.serveStatic("/index.html", SPIFFS, "/www/index.html");
server.on("/manifest.webmanifest", HTTP_GET, [](AsyncWebServerRequest *request){
AsyncWebServerResponse* response = request->beginResponse(SPIFFS, "/www/manifest.webmanifest", "application/manifest+json; charset=utf-8");
//response->addHeader("Content-Disposition", "inline");
request->send(response);
});
// Log files (not cached)
server.serveStatic("/api/log", SPIFFS, "/log/");
@ -493,8 +498,11 @@ void loop()
if(altitudeChange > 0)
tripAscendingElevation += altitudeChange;
uint32_t newEnergy = entry.batteryVoltage * entry.batteryOutputCurrent * ((float)dt / 1000.0f);
tripMotorEnergy += newEnergy;
static float remainingEnergy = 0.0f;
float newEnergy = entry.batteryVoltage * entry.batteryOutputCurrent * ((float)dt / 1000.0f) + remainingEnergy;
uint32_t newEnergyIntegralJoules = (uint32_t)newEnergy;
remainingEnergy = newEnergy - (float)newEnergyIntegralJoules;
tripMotorEnergy += newEnergyIntegralJoules;
}
delay(isOnTrip ? 10 : 1000);

1
WebApp/package.json

@ -12,6 +12,7 @@
"devDependencies": {
"@types/mithril": "^2.0.9",
"bulma": "^0.9.3",
"copy-webpack-plugin": "^10.2.4",
"css-loader": "^6.7.1",
"html-webpack-plugin": "^5.5.0",
"mini-css-extract-plugin": "^2.6.0",

3
WebApp/src/app.css

@ -0,0 +1,3 @@
html {
font-size: 3.24vmin;
}

1
WebApp/src/app.ts

@ -5,6 +5,7 @@ import { RawDataPage } from 'pages/raw-data/raw-data-page';
import { DashboardPage } from 'pages/dashboard/dashboard-page';
require('../node_modules/bulma/css/bulma.css');
require('./app.css');
m.route(document.body, "/raw", {
"/dashboard": { render: () => m(Layout, m(DashboardPage)) },

1
WebApp/src/index.html

@ -3,6 +3,7 @@
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Ordinateur de bord</title>
<link rel="manifest" href="/manifest.webmanifest" />
</head>
<body>
<p>Chargement...</p>

8
WebApp/src/manifest.webmanifest

@ -0,0 +1,8 @@
{
"background_color": "purple",
"description": "Shows random fox pictures. Hey, at least it isn't cats.",
"display": "fullscreen",
"name": "Awesome fox pictures",
"short_name": "Foxes",
"start_url": "/index.html"
}

8
WebApp/webpack.config.js

@ -6,6 +6,7 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const PurgecssPlugin = require('purgecss-webpack-plugin');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
module.exports = {
entry: './src/app.ts',
@ -46,6 +47,11 @@ module.exports = {
new PurgecssPlugin({
paths: glob.sync('./src/**/*', { nodir: true }),
safelist: ['html', 'body']
})
}),
new CopyPlugin({
patterns: [
'src/manifest.webmanifest'
],
}),
]
};

Loading…
Cancel
Save