Farmbot-Web-App/frontend/devices/state_to_props.ts

41 lines
1.6 KiB
TypeScript
Raw Normal View History

2017-06-29 12:54:02 -06:00
import { Everything } from "../interfaces";
2019-12-27 11:37:54 -07:00
import { Props } from "./interfaces";
2017-06-29 12:54:02 -06:00
import {
selectAllImages,
2018-03-07 22:08:00 -07:00
getDeviceAccountSettings,
2019-04-09 23:17:03 -06:00
maybeGetTimeSettings,
2017-06-29 12:54:02 -06:00
} from "../resources/selectors";
import {
2020-02-28 09:35:32 -07:00
sourceFbosConfigValue, sourceFwConfigValue,
} from "./components/source_config_value";
2019-12-27 11:37:54 -07:00
import { validFwConfig, validFbosConfig } from "../util";
import {
2020-02-28 09:35:32 -07:00
saveOrEditFarmwareEnv, getEnv, getShouldDisplayFn,
2018-11-01 11:17:18 -06:00
} from "../farmware/state_to_props";
2020-03-13 15:06:40 -06:00
import { getFbosConfig, getFirmwareConfig } from "../resources/getters";
2019-07-15 15:23:06 -06:00
import { getAllAlerts } from "../messages/state_to_props";
2017-06-29 12:54:02 -06:00
export function mapStateToProps(props: Everything): Props {
2018-01-27 02:29:13 -07:00
const { hardware } = props.bot;
const fbosConfig = validFbosConfig(getFbosConfig(props.resources.index));
2018-03-09 02:34:24 -07:00
const firmwareConfig = validFwConfig(getFirmwareConfig(props.resources.index));
2019-12-27 11:37:54 -07:00
const shouldDisplay = getShouldDisplayFn(props.resources.index, props.bot);
const env = getEnv(props.resources.index, shouldDisplay, props.bot);
2017-06-29 12:54:02 -06:00
return {
deviceAccount: getDeviceAccountSettings(props.resources.index),
auth: props.auth,
bot: props.bot,
dispatch: props.dispatch,
2017-11-30 20:43:35 -07:00
images: selectAllImages(props.resources.index),
resources: props.resources.index,
2018-01-27 02:29:13 -07:00
sourceFbosConfig: sourceFbosConfigValue(fbosConfig, hardware.configuration),
2018-03-09 02:34:24 -07:00
sourceFwConfig: sourceFwConfigValue(firmwareConfig, hardware.mcu_params),
2018-11-01 11:17:18 -06:00
shouldDisplay,
2018-03-08 21:03:02 -07:00
firmwareConfig,
2018-11-01 11:17:18 -06:00
env,
saveFarmwareEnv: saveOrEditFarmwareEnv(props.resources.index),
2019-04-09 23:17:03 -06:00
timeSettings: maybeGetTimeSettings(props.resources.index),
2019-07-15 15:23:06 -06:00
alerts: getAllAlerts(props.resources),
2017-06-29 12:54:02 -06:00
};
}