Skip to content

Commit b1fbf8c

Browse files
committed
less bugs, new sensors
1 parent 0a5de56 commit b1fbf8c

20 files changed

+528
-407
lines changed

interface/listnpm

295 KB
Binary file not shown.

interface/package-lock.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

interface/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"parse-ms": "^2.1.0",
2424
"react": "^17.0.1",
2525
"react-chartjs-2": "^2.11.1",
26-
"react-day-picker": "^8.0.0-beta.19",
26+
"react-day-picker": "^8.0.0-beta.17",
2727
"react-dom": "^17.0.1",
2828
"react-dropzone": "^11.3.1",
2929
"react-form-validator-core": "^1.1.1",

interface/public/app/icon.png

3.04 KB
Loading

interface/src/components/MenuAppBar.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ class MenuAppBar extends React.Component<MenuAppBarProps, MenuAppBarState> {
135135
<Divider />
136136
</Fragment>
137137
)}
138+
{authenticatedContext.me.admin?
138139
<List>
139140
<ListItem to='/wifi/' selected={path.startsWith('/wifi/')} button component={Link}>
140141
<ListItemIcon>
@@ -179,6 +180,7 @@ class MenuAppBar extends React.Component<MenuAppBarProps, MenuAppBarState> {
179180
<ListItemText primary="System" />
180181
</ListItem>
181182
</List>
183+
:""}
182184
</div>
183185
);
184186

interface/src/project/DataExplorer.tsx

+13-12
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
11
import React, { Component, useEffect, useState } from 'react';
2-
import { withSnackbar, WithSnackbarProps } from 'notistack';
2+
import { WithSnackbarProps } from 'notistack';
33
import { RouteComponentProps } from 'react-router-dom'
44

55
import { ENDPOINT_ROOT } from '../api';
66
import { restController, RestControllerProps, RestFormLoader, SectionContent, } from '../components';
7-
import { Box, Button, makeStyles, Table, TableBody, TableCell, TableHead, TableRow, Typography, WithStyles } from '@material-ui/core';
8-
import DeleteIcon from '@material-ui/icons/Delete';
7+
import { Box, Button, makeStyles, Typography, WithStyles } from '@material-ui/core';
98
import TimelineIcon from '@material-ui/icons/TimelineOutlined';
109
import GetApp from '@material-ui/icons/GetApp';
11-
import IconButton from '@material-ui/core/IconButton';
1210
import 'react-day-picker/style.css';
1311
import { DataFile, FilesState } from './types';
1412
import { LineChart, Line, CartesianGrid, XAxis, YAxis, ResponsiveContainer, Brush, Tooltip} from 'recharts'
15-
import { DateRange, DayPicker, SelectRangeEventHandler, DateAfter, DateBefore, DateBeforeAfter } from 'react-day-picker';
13+
import { DateRange, DayPicker, SelectRangeEventHandler, DateAfter, DateBefore } from 'react-day-picker';
1614
import { format } from 'date-fns';
17-
import { MenuAppBar } from '../components';
18-
import { merge, toInteger } from 'lodash';
19-
import { render } from 'react-dom';
15+
import { toInteger } from 'lodash';
2016
export const FILES_ENDPOINT = ENDPOINT_ROOT + "files";
2117

2218
const useStyles = makeStyles((theme) => ({
@@ -124,7 +120,7 @@ function Calendar(props: ICalendarProps) {
124120
responses.forEach(response => {
125121
p1.push(response.arrayBuffer().then(buffer => {
126122
console.log("extractdp",response,response.url.split('/')[-1])
127-
ldatapoints = ldatapoints.concat(extractDP(buffer,indexes,Number(response.url.split('/').pop())));
123+
ldatapoints = ldatapoints.concat(extractDP(buffer,indexes,Number(response.url.split('/').pop()),range));
128124
console.log("file processed.")
129125
}));
130126
});
@@ -232,7 +228,9 @@ class DataViewForm extends Component<DataViewProps & WithStyles> {
232228
render() {
233229
if (this.props.graphData && this.props.graphIndex) {
234230
return (
231+
235232
this.props.graphIndex.map((keyindex, index) => (
233+
this.props.sensorInfos.get(keyindex.name)?.index ?
236234
<SectionContent title={keyindex.name} titleGutter key={index}>
237235
<ResponsiveContainer width="95%" height={400}>
238236
<LineChart height={300} data={this.props.graphData} syncId="datalab" >
@@ -244,7 +242,7 @@ class DataViewForm extends Component<DataViewProps & WithStyles> {
244242
<YAxis />
245243
<Tooltip labelFormatter={this.RenderTick} />
246244
<CartesianGrid stroke="#eee" strokeDasharray="5 5" />
247-
<Line type="linear" connectNulls={true} dataKey={keyindex.name} stroke={this.colors[index]} />
245+
<Line type="linear" connectNulls={true} dataKey={keyindex.name} />
248246
{/* <Line type="monotone" dataKey="pv" stroke="#82ca9d" /> */}
249247
</LineChart>
250248
</ResponsiveContainer>
@@ -261,6 +259,7 @@ class DataViewForm extends Component<DataViewProps & WithStyles> {
261259
Download all graph data
262260
</Button>
263261
</SectionContent>
262+
: ""
264263
))
265264
)
266265
}
@@ -310,12 +309,14 @@ function getMergedDP(datapoints: DataPoint[], maxValPerSensor=0):[any[] , Map<st
310309
return [merged,sampling];
311310
}
312311

313-
function extractDP(buffer: ArrayBuffer,indexes: IIndex[], tsstart:number): DataPoint[] {
312+
function extractDP(buffer: ArrayBuffer,indexes: IIndex[], tsstart:number, range:DateRange): DataPoint[] {
314313
var ret: DataPoint[] = [];
315314
var i=0;
316315
for (let offset = 0; offset *7 < buffer.byteLength; offset ++) {
317316
i++
318-
ret.push(ReadDataPoint(buffer.slice(7 * offset, 7 * offset + 7),indexes, tsstart));
317+
var point=ReadDataPoint(buffer.slice(7 * offset, 7 * offset + 7),indexes, tsstart);
318+
if (point.ts! *1000>+range.from && point.ts!*1000<+range.to!)
319+
ret.push(point);
319320
}
320321
return ret;
321322
}

interface/src/project/DemoInformation.tsx

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
import React, { Component,useEffect, useState} from 'react';
1+
import React, { Component} from 'react';
22
import { Typography, Grid, Card, CardContent, createStyles, WithStyles, Theme, withStyles } from '@material-ui/core';
33
import { WebSocketControllerProps, SectionContent, webSocketController } from '../components';
4-
import { LineChart, Line, CartesianGrid, XAxis, YAxis, ResponsiveContainer, Brush, Tooltip} from 'recharts'
4+
import { LineChart, Line, CartesianGrid, XAxis, YAxis, ResponsiveContainer, Tooltip} from 'recharts'
55

66
import { ENDPOINT_ROOT, WEB_SOCKET_ROOT } from '../api';
7-
import { toInteger } from 'lodash';
8-
import { redirectingAuthorizedFetch } from '../authentication';
9-
// import { Time } from '../ntp/types';
7+
108

119

1210
export const SENSOR_VALUE_WEBSOCKET_URL = WEB_SOCKET_ROOT + "sensorValue";

interface/src/project/FilesController.tsx

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
import React, { Component, } from 'react';
2-
import { withSnackbar, WithSnackbarProps } from 'notistack';
2+
import { WithSnackbarProps } from 'notistack';
33
import { RouteComponentProps } from 'react-router-dom'
44

5+
import { withAuthenticatedContext, AuthenticatedContextProps } from '../authentication';
6+
57
import { ENDPOINT_ROOT } from '../api';
68
import { ErrorButton, restController, RestControllerProps, RestFormLoader, SectionContent, } from '../components';
79
import { Box, Button, createStyles, Dialog, DialogActions, DialogContent, DialogTitle, Table, TableBody, TableCell, TableHead, TableRow, Theme, Typography, withStyles, WithStyles } from '@material-ui/core';
810
import DeleteIcon from '@material-ui/icons/Delete';
911
import GetApp from '@material-ui/icons/GetApp';
1012
import IconButton from '@material-ui/core/IconButton';
1113
import DeleteSweepIcon from '@material-ui/icons/DeleteSweep';
12-
import 'react-day-picker/style.css';
1314
import { DataFile, FilesState } from './types';
1415
import { format } from 'date-fns';
1516
import { toInteger } from 'lodash';
1617
import { redirectingAuthorizedFetch } from '../authentication';
17-
import { FormatAlignRight } from '@material-ui/icons';
1818
export const FILES_ENDPOINT = ENDPOINT_ROOT + "files";
1919

2020
const mystyles = (theme: Theme) => createStyles(
@@ -34,7 +34,7 @@ interface IState {
3434
}
3535

3636

37-
class FileList extends Component<FileListProps & RouteComponentProps & WithStyles<typeof mystyles>, IState > {
37+
class FileList extends Component<FileListProps & RouteComponentProps & AuthenticatedContextProps & WithStyles<typeof mystyles>, IState > {
3838

3939
state: IState={
4040
confirmDeleteAll: false,
@@ -147,19 +147,19 @@ class FileList extends Component<FileListProps & RouteComponentProps & WithStyle
147147
<TableCell>{file.diff == 0 ? "Unknown" : tsToTime(Number(file.end))}</TableCell>
148148
<TableCell>{file.nval}</TableCell>
149149
<TableCell>{toInteger(file.nval*7/1000)}KB</TableCell>
150-
<TableCell><IconButton size="small" aria-label="Delete" onClick={() => this.deleteFile(file)}><DeleteIcon /></IconButton></TableCell>
150+
<TableCell><IconButton disabled={!this.props.authenticatedContext.me.admin} size="small" aria-label="Delete" onClick={() => this.deleteFile(file)}><DeleteIcon /></IconButton></TableCell>
151151
<TableCell><a href={ENDPOINT_ROOT + "getjson"} download target="_blank"><IconButton size="small" aria-label="Download"><GetApp /></IconButton></a></TableCell>
152-
153152
</TableRow>
154153
))
155154
}
156155
</TableBody>
157156
</Table>
158157
<Box flexWrap="none" alignItems="right" padding={1} whiteSpace="nowrap">
159-
158+
{this.props.authenticatedContext.me.admin?
160159
<ErrorButton startIcon={<DeleteSweepIcon />} variant="contained" onClick={this.onDeleteAll}>
161160
Delete all
162161
</ErrorButton>
162+
:""}
163163
</Box>
164164
</SectionContent>
165165
{this.renderDeleteAllDialog()}
@@ -171,7 +171,7 @@ class FileList extends Component<FileListProps & RouteComponentProps & WithStyle
171171
}
172172
}
173173

174-
export default withStyles(mystyles)(restController(FILES_ENDPOINT, FileList));
174+
export default withAuthenticatedContext(withStyles(mystyles)(restController(FILES_ENDPOINT, FileList)));
175175

176176
function tsToTime(ts: number) {
177177
return format(ts * 1000, "yyyy-MM-dd HH:mm");

lib/framework/ESP8266React.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ esp_log_level_set("esp_littlefs", ESP_LOG_VERBOSE);
6060
server->serveStatic("/css/", ESPFS, "/www/css/");
6161
server->serveStatic("/fonts/", ESPFS, "/www/fonts/");
6262
server->serveStatic("/app/", ESPFS, "/www/app/");
63-
server->serveStatic("/raw/", ESPFS, "/data/d/");
6463
server->serveStatic("/favicon.ico", ESPFS, "/www/favicon.ico");
6564
server->serveStatic("/index.html", ESPFS, "/www/index.html");
6665
// Serving all other get requests with "/www/index.htm"

platformio.ini

+2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ lib_deps =
5656
Adafruit BMP085 Library
5757
Adafruit BusIO
5858
DHT sensor library
59+
HM330X by Tomoto
60+
Adafruit SGP30 Sensor
5961

6062
extra_configs =
6163
factory_settings.ini

0 commit comments

Comments
 (0)