diff --git a/src/component/ComponentActions.tsx b/src/component/ComponentActions.tsx index 8556652..9e3ac32 100644 --- a/src/component/ComponentActions.tsx +++ b/src/component/ComponentActions.tsx @@ -172,7 +172,7 @@ export default function ComponentActions(props: Props) { refreshCallback={refreshCallback} canEdit={canEdit} /> - {/* */} + /> ); }; diff --git a/src/component/ExportDataSettings.tsx b/src/component/ExportDataSettings.tsx index 9fe8749..417c8d1 100644 --- a/src/component/ExportDataSettings.tsx +++ b/src/component/ExportDataSettings.tsx @@ -7,13 +7,16 @@ import { DialogContent, DialogTitle, Divider, - Grid, + Grid2 as Grid, InputAdornment, TextField, - Typography -} from "@material-ui/core"; -import { Theme } from "@material-ui/core/styles/createMuiTheme"; -import withStyles, { WithStyles } from "@material-ui/core/styles/withStyles"; + Typography, + Theme +} from "@mui/material" +//import { Theme } from "@material-ui/core/styles/createMuiTheme"; +//import withStyles, { WithStyles } from "@material-ui/core/styles/withStyles"; +import { withStyles, WithStyles } from "@mui/styles"; + import DateSelect from "common/time/DateSelect"; import { Component, Device, User } from "models"; import moment, { Moment } from "moment"; @@ -53,7 +56,7 @@ interface State { class ExportDataSettings extends React.Component { static contextType = ComponentAPIContext; - context!: React.ContextType; + declare context: React.ContextType; constructor(props: Props) { super(props); this.state = this.defaultSettings(props); @@ -90,12 +93,15 @@ class ExportDataSettings extends React.Component { }; submit = () => { + console.log("submit export request") const { device, component, newMeasurements, user } = this.props; const { startDate, endDate } = this.state; const { sampleMeasurements, listUnitMeasurements } = this.context; this.setState({ isLoading: true }); - if (newMeasurements) { + console.log("Device") + console.log(device) + // if (newMeasurements) { listUnitMeasurements( device.id(), component.key(), @@ -139,39 +145,39 @@ class ExportDataSettings extends React.Component { this.setState({ isLoading: false }); this.close(); }); - } else { - sampleMeasurements(device.id(), component.key(), startDate, endDate, 4294967295) - .then((response: any) => { - this.formatMeasurements(response.data.measurements) - .then((data: Array) => { - this.setState({ - isLoading: false - }); - this.exportData( - data - .map(entry => { - let out = entry; - out.Timestamp = moment(entry.Timestamp) - .local() - .format(); - return out; - }) - .sort(function(a, b) { - return a.Timestamp < b.Timestamp ? -1 : 1; - }) - ); - this.close(); - }) - .catch((error: any) => { - this.setState({ isLoading: false }); - this.close(); - }); - }) - .catch((error: any) => { - this.setState({ isLoading: false }); - this.close(); - }); - } + // } else { + // sampleMeasurements(device.id(), component.key(), startDate, endDate, 4294967295) + // .then((response: any) => { + // this.formatMeasurements(response.data.measurements) + // .then((data: Array) => { + // this.setState({ + // isLoading: false + // }); + // this.exportData( + // data + // .map(entry => { + // let out = entry; + // out.Timestamp = moment(entry.Timestamp) + // .local() + // .format(); + // return out; + // }) + // .sort(function(a, b) { + // return a.Timestamp < b.Timestamp ? -1 : 1; + // }) + // ); + // this.close(); + // }) + // .catch((error: any) => { + // this.setState({ isLoading: false }); + // this.close(); + // }); + // }) + // .catch((error: any) => { + // this.setState({ isLoading: false }); + // this.close(); + // }); + // } }; // formatExportedMeasurements(measurements: Array): Promise> { @@ -326,7 +332,6 @@ class ExportDataSettings extends React.Component { @@ -343,7 +348,7 @@ class ExportDataSettings extends React.Component { return ( - + { }} /> - + { label="Extract data from" /> - + Note: This process might take a while (depends on how much data is requested) diff --git a/src/providers/pond/deviceAPI.tsx b/src/providers/pond/deviceAPI.tsx index d422c59..fadad84 100644 --- a/src/providers/pond/deviceAPI.tsx +++ b/src/providers/pond/deviceAPI.tsx @@ -171,12 +171,12 @@ export default function DeviceProvider(props: PropsWithChildren) { let url = pondURL( "/devices/" + id + - (as ? "?as=" + as : "") + + "?as=" + as + (keys ? "&keys=" + keys.toString() : "") + (types ? "&types=" + types.toString() : ""), demo ); - return new Promise>((resolve, response) => { + return new Promise>((resolve, reject) => { get(url).then(resp => { resp.data = pond.Device.fromObject(resp.data) return resolve(resp)