Skip to content

Commit

Permalink
removed old share dialog and redirected to share center #424
Browse files Browse the repository at this point in the history
  • Loading branch information
io53 committed Aug 21, 2024
1 parent a04487c commit c7805be
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
5 changes: 1 addition & 4 deletions src/states/Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { useLocation, useNavigate, useParams, useSearchParams } from "react-rout
import SensorTypePicker from "../components/SensorTypePicker";
import DashboardViewType from "../components/DashboardViewType";
import { SearchIcon, CloseIcon } from "@chakra-ui/icons";
import ShareDialog from "../components/ShareDialog";
import { getSetting } from "../UnitHelper";
import EditNameDialog from "../components/EditNameDialog";
import ConfirmationDialog from "../components/ConfirmationDialog";
Expand Down Expand Up @@ -57,7 +56,6 @@ class Dashboard extends Component {
graphType: store.getDashboardGraphType(),
search: "",
currSize: '',
showShare: null,
rename: null,
showResetOrderConfirmation: false
}
Expand Down Expand Up @@ -305,7 +303,7 @@ class Dashboard extends Component {
dataFrom={this.state.from}
cardType={this.state.cardType}
graphType={this.state.graphType}
share={() => this.setState({ ...this.state, showShareFor: x })}
share={() => this.props.navigate('/shares?sensor=' + x.sensor)}
rename={() => this.setState({ ...this.state, rename: x })}
remove={() => this.removeSensorFromState(x.sensor)}
move={dir => {
Expand Down Expand Up @@ -399,7 +397,6 @@ class Dashboard extends Component {
</Box>
</Box>
</Box>
<ShareDialog open={this.state.showShareFor} onClose={() => this.setState({ ...this.state, showShareFor: null })} sensor={this.state.showShareFor} updateSensor={(s) => this.updateSensor(s)} />
<EditNameDialog open={this.state.rename} onClose={() => this.setState({ ...this.state, rename: null })} sensor={this.state.rename} updateSensor={(s) => this.updateSensor(s)} />
<ConfirmationDialog open={this.state.showResetOrderConfirmation} title="dialog_are_you_sure" description='reset_order_confirmation' onClose={(yes) => this.resetOrder(yes)} />
</>
Expand Down
12 changes: 4 additions & 8 deletions src/states/Sensor.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { Component } from "react";
import NetworkApi from '../NetworkApi'
import {
Heading,
IconButton,
Box,
Avatar,
Expand All @@ -21,16 +20,15 @@ import 'uplot/dist/uPlot.min.css';
import Graph from "../components/Graph";
import SensorReading from "../components/SensorReading";
import parse from "../decoder/parser";
import { MdChevronRight, MdInfo } from "react-icons/md"
import { MdChevronRight } from "react-icons/md"
import { withTranslation } from 'react-i18next';
import { getUnitHelper, localeNumber } from "../UnitHelper";
import { exportCSV, exportPDF, exportXLSX } from "../utils/export";
import withRouter from "../utils/withRouter"
import DurationText from "../components/DurationText";
import Store from "../Store";
import ShareDialog from "../components/ShareDialog";
import EditNameDialog from "../components/EditNameDialog";
import { addNewlines, addVariablesInString, uppercaseFirst } from "../TextHelper";
import { addVariablesInString, uppercaseFirst } from "../TextHelper";
import AlertItem from "../components/AlertItem";
import EditableText from "../components/EditableText";
import OffsetDialog from "../components/OffsetDialog";
Expand Down Expand Up @@ -192,7 +190,6 @@ class Sensor extends Component {
table: "",
resolvedMode: "",
editName: false,
showShare: false,
offsetDialog: null,
loadingImage: false,
updateGraphKey: 0,
Expand Down Expand Up @@ -397,8 +394,8 @@ class Sensor extends Component {
}
return new Date().getTime()
}
share(state) {
this.setState({ ...this.state, showShare: state })
share() {
this.props.router.navigate(`/shares?sensor=${this.props.sensor.sensor}`)
}
editName(state) {
this.setState({ ...this.state, editName: state })
Expand Down Expand Up @@ -816,7 +813,6 @@ class Sensor extends Component {
</Accordion>
</Box>
<EditNameDialog open={this.state.editName} onClose={() => this.editName(false)} sensor={this.props.sensor} updateSensor={this.props.updateSensor} />
<ShareDialog open={this.state.showShare} onClose={() => this.share(false)} sensor={this.props.sensor} updateSensor={this.props.updateSensor} />
<OffsetDialog open={this.state.offsetDialog} onClose={() => this.setState({ ...this.state, offsetDialog: null })} sensor={this.props.sensor} offsets={{ "Humidity": this.props.sensor.offsetHumidity, "Pressure": this.props.sensor.offsetPressure, "Temperature": this.props.sensor.offsetTemperature }} lastReading={this.getLatestReading()} updateSensor={this.props.updateSensor} />
<RemoveSensorDialog open={this.state.removeSensor} onClose={() => this.setState({ ...this.state, removeSensor: null })} sensor={this.props.sensor} updateSensor={this.props.updateSensor} t={t} remove={() => this.props.remove()} />
</Box>
Expand Down
6 changes: 6 additions & 0 deletions src/states/ShareCenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ const ShareCenter = () => {

useEffect(() => {
(async () => {
window.scrollTo(0, 0)
let user = new NetworkApi().getUser();
let resp = await new NetworkApi().getAllSensorsAsync();
if (resp.result === "success") {
Expand All @@ -111,6 +112,11 @@ const ShareCenter = () => {
}
}
setSensors(sensors)
const urlParams = new URLSearchParams(window.location.search);
const sensorParam = urlParams.get('sensor');
if (sensorParam) {
setSelectedSensors([sensorParam])
}
setLoading(false)
}
})();
Expand Down

0 comments on commit c7805be

Please sign in to comment.