Skip to content

Commit

Permalink
less bugs, new sensors
Browse files Browse the repository at this point in the history
  • Loading branch information
raomin committed Mar 14, 2021
1 parent 0a5de56 commit b1fbf8c
Show file tree
Hide file tree
Showing 20 changed files with 528 additions and 407 deletions.
Binary file added interface/listnpm
Binary file not shown.
6 changes: 3 additions & 3 deletions interface/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion interface/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"parse-ms": "^2.1.0",
"react": "^17.0.1",
"react-chartjs-2": "^2.11.1",
"react-day-picker": "^8.0.0-beta.19",
"react-day-picker": "^8.0.0-beta.17",
"react-dom": "^17.0.1",
"react-dropzone": "^11.3.1",
"react-form-validator-core": "^1.1.1",
Expand Down
Binary file modified interface/public/app/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions interface/src/components/MenuAppBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ class MenuAppBar extends React.Component<MenuAppBarProps, MenuAppBarState> {
<Divider />
</Fragment>
)}
{authenticatedContext.me.admin?
<List>
<ListItem to='/wifi/' selected={path.startsWith('/wifi/')} button component={Link}>
<ListItemIcon>
Expand Down Expand Up @@ -179,6 +180,7 @@ class MenuAppBar extends React.Component<MenuAppBarProps, MenuAppBarState> {
<ListItemText primary="System" />
</ListItem>
</List>
:""}
</div>
);

Expand Down
25 changes: 13 additions & 12 deletions interface/src/project/DataExplorer.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
import React, { Component, useEffect, useState } from 'react';
import { withSnackbar, WithSnackbarProps } from 'notistack';
import { WithSnackbarProps } from 'notistack';
import { RouteComponentProps } from 'react-router-dom'

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

const useStyles = makeStyles((theme) => ({
Expand Down Expand Up @@ -124,7 +120,7 @@ function Calendar(props: ICalendarProps) {
responses.forEach(response => {
p1.push(response.arrayBuffer().then(buffer => {
console.log("extractdp",response,response.url.split('/')[-1])
ldatapoints = ldatapoints.concat(extractDP(buffer,indexes,Number(response.url.split('/').pop())));
ldatapoints = ldatapoints.concat(extractDP(buffer,indexes,Number(response.url.split('/').pop()),range));
console.log("file processed.")
}));
});
Expand Down Expand Up @@ -232,7 +228,9 @@ class DataViewForm extends Component<DataViewProps & WithStyles> {
render() {
if (this.props.graphData && this.props.graphIndex) {
return (

this.props.graphIndex.map((keyindex, index) => (
this.props.sensorInfos.get(keyindex.name)?.index ?
<SectionContent title={keyindex.name} titleGutter key={index}>
<ResponsiveContainer width="95%" height={400}>
<LineChart height={300} data={this.props.graphData} syncId="datalab" >
Expand All @@ -244,7 +242,7 @@ class DataViewForm extends Component<DataViewProps & WithStyles> {
<YAxis />
<Tooltip labelFormatter={this.RenderTick} />
<CartesianGrid stroke="#eee" strokeDasharray="5 5" />
<Line type="linear" connectNulls={true} dataKey={keyindex.name} stroke={this.colors[index]} />
<Line type="linear" connectNulls={true} dataKey={keyindex.name} />
{/* <Line type="monotone" dataKey="pv" stroke="#82ca9d" /> */}
</LineChart>
</ResponsiveContainer>
Expand All @@ -261,6 +259,7 @@ class DataViewForm extends Component<DataViewProps & WithStyles> {
Download all graph data
</Button>
</SectionContent>
: ""
))
)
}
Expand Down Expand Up @@ -310,12 +309,14 @@ function getMergedDP(datapoints: DataPoint[], maxValPerSensor=0):[any[] , Map<st
return [merged,sampling];
}

function extractDP(buffer: ArrayBuffer,indexes: IIndex[], tsstart:number): DataPoint[] {
function extractDP(buffer: ArrayBuffer,indexes: IIndex[], tsstart:number, range:DateRange): DataPoint[] {
var ret: DataPoint[] = [];
var i=0;
for (let offset = 0; offset *7 < buffer.byteLength; offset ++) {
i++
ret.push(ReadDataPoint(buffer.slice(7 * offset, 7 * offset + 7),indexes, tsstart));
var point=ReadDataPoint(buffer.slice(7 * offset, 7 * offset + 7),indexes, tsstart);
if (point.ts! *1000>+range.from && point.ts!*1000<+range.to!)
ret.push(point);
}
return ret;
}
Expand Down
8 changes: 3 additions & 5 deletions interface/src/project/DemoInformation.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import React, { Component,useEffect, useState} from 'react';
import React, { Component} from 'react';
import { Typography, Grid, Card, CardContent, createStyles, WithStyles, Theme, withStyles } from '@material-ui/core';
import { WebSocketControllerProps, SectionContent, webSocketController } from '../components';
import { LineChart, Line, CartesianGrid, XAxis, YAxis, ResponsiveContainer, Brush, Tooltip} from 'recharts'
import { LineChart, Line, CartesianGrid, XAxis, YAxis, ResponsiveContainer, Tooltip} from 'recharts'

import { ENDPOINT_ROOT, WEB_SOCKET_ROOT } from '../api';
import { toInteger } from 'lodash';
import { redirectingAuthorizedFetch } from '../authentication';
// import { Time } from '../ntp/types';



export const SENSOR_VALUE_WEBSOCKET_URL = WEB_SOCKET_ROOT + "sensorValue";
Expand Down
16 changes: 8 additions & 8 deletions interface/src/project/FilesController.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import React, { Component, } from 'react';
import { withSnackbar, WithSnackbarProps } from 'notistack';
import { WithSnackbarProps } from 'notistack';
import { RouteComponentProps } from 'react-router-dom'

import { withAuthenticatedContext, AuthenticatedContextProps } from '../authentication';

import { ENDPOINT_ROOT } from '../api';
import { ErrorButton, restController, RestControllerProps, RestFormLoader, SectionContent, } from '../components';
import { Box, Button, createStyles, Dialog, DialogActions, DialogContent, DialogTitle, Table, TableBody, TableCell, TableHead, TableRow, Theme, Typography, withStyles, WithStyles } from '@material-ui/core';
import DeleteIcon from '@material-ui/icons/Delete';
import GetApp from '@material-ui/icons/GetApp';
import IconButton from '@material-ui/core/IconButton';
import DeleteSweepIcon from '@material-ui/icons/DeleteSweep';
import 'react-day-picker/style.css';
import { DataFile, FilesState } from './types';
import { format } from 'date-fns';
import { toInteger } from 'lodash';
import { redirectingAuthorizedFetch } from '../authentication';
import { FormatAlignRight } from '@material-ui/icons';
export const FILES_ENDPOINT = ENDPOINT_ROOT + "files";

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


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

state: IState={
confirmDeleteAll: false,
Expand Down Expand Up @@ -147,19 +147,19 @@ class FileList extends Component<FileListProps & RouteComponentProps & WithStyle
<TableCell>{file.diff == 0 ? "Unknown" : tsToTime(Number(file.end))}</TableCell>
<TableCell>{file.nval}</TableCell>
<TableCell>{toInteger(file.nval*7/1000)}KB</TableCell>
<TableCell><IconButton size="small" aria-label="Delete" onClick={() => this.deleteFile(file)}><DeleteIcon /></IconButton></TableCell>
<TableCell><IconButton disabled={!this.props.authenticatedContext.me.admin} size="small" aria-label="Delete" onClick={() => this.deleteFile(file)}><DeleteIcon /></IconButton></TableCell>
<TableCell><a href={ENDPOINT_ROOT + "getjson"} download target="_blank"><IconButton size="small" aria-label="Download"><GetApp /></IconButton></a></TableCell>

</TableRow>
))
}
</TableBody>
</Table>
<Box flexWrap="none" alignItems="right" padding={1} whiteSpace="nowrap">

{this.props.authenticatedContext.me.admin?
<ErrorButton startIcon={<DeleteSweepIcon />} variant="contained" onClick={this.onDeleteAll}>
Delete all
</ErrorButton>
:""}
</Box>
</SectionContent>
{this.renderDeleteAllDialog()}
Expand All @@ -171,7 +171,7 @@ class FileList extends Component<FileListProps & RouteComponentProps & WithStyle
}
}

export default withStyles(mystyles)(restController(FILES_ENDPOINT, FileList));
export default withAuthenticatedContext(withStyles(mystyles)(restController(FILES_ENDPOINT, FileList)));

function tsToTime(ts: number) {
return format(ts * 1000, "yyyy-MM-dd HH:mm");
Expand Down
1 change: 0 additions & 1 deletion lib/framework/ESP8266React.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ esp_log_level_set("esp_littlefs", ESP_LOG_VERBOSE);
server->serveStatic("/css/", ESPFS, "/www/css/");
server->serveStatic("/fonts/", ESPFS, "/www/fonts/");
server->serveStatic("/app/", ESPFS, "/www/app/");
server->serveStatic("/raw/", ESPFS, "/data/d/");
server->serveStatic("/favicon.ico", ESPFS, "/www/favicon.ico");
server->serveStatic("/index.html", ESPFS, "/www/index.html");
// Serving all other get requests with "/www/index.htm"
Expand Down
2 changes: 2 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ lib_deps =
Adafruit BMP085 Library
Adafruit BusIO
DHT sensor library
HM330X by Tomoto
Adafruit SGP30 Sensor

extra_configs =
factory_settings.ini
Expand Down
Loading

0 comments on commit b1fbf8c

Please sign in to comment.