Added polling for watcher.
This commit is contained in:
26
src/components/atoms/data-label/data-label.atom.jsx
Normal file
26
src/components/atoms/data-label/data-label.atom.jsx
Normal file
@@ -0,0 +1,26 @@
|
||||
import React from "react";
|
||||
|
||||
export default function DataLabel({
|
||||
label,
|
||||
hideIfNull,
|
||||
children,
|
||||
vertical,
|
||||
visible = true,
|
||||
...props
|
||||
}) {
|
||||
if (!visible || (hideIfNull && !!!children)) return null;
|
||||
|
||||
return (
|
||||
<div {...props}>
|
||||
<div
|
||||
style={{
|
||||
display: vertical ? "block" : "inline-block",
|
||||
marginRight: ".2rem",
|
||||
}}
|
||||
>{`${label}: `}</div>
|
||||
<div style={{ display: vertical ? "block" : "inline-block" }}>
|
||||
{children}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,14 +1,16 @@
|
||||
export default (part_type) => {
|
||||
switch (part_type) {
|
||||
case "PAA":
|
||||
case "PAL":
|
||||
case "PAC":
|
||||
return "A/M";
|
||||
case "PAE":
|
||||
return "Exist.";
|
||||
case "PAN":
|
||||
case "PAP":
|
||||
return "OEM";
|
||||
case "PAL":
|
||||
return "LKQ";
|
||||
|
||||
default:
|
||||
return "?";
|
||||
return part_type;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
import { InputNumber, Switch } from "antd";
|
||||
import React from "react";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import ipcTypes from "../../../ipc.types";
|
||||
import { selectSettings } from "../../../redux/application/application.selectors";
|
||||
import DataLabel from "../../atoms/data-label/data-label.atom";
|
||||
const { ipcRenderer } = window;
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
//currentUser: selectCurrentUser
|
||||
appSettings: selectSettings,
|
||||
});
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
//setUserLanguage: language => dispatch(setUserLanguage(language))
|
||||
});
|
||||
|
||||
export function WatcherPollingMolecule({ appSettings }) {
|
||||
const handlePollingToggle = (val) => {
|
||||
ipcRenderer.send(ipcTypes.default.store.set, { "polling.enabled": val });
|
||||
};
|
||||
const handleIntervalChange = (val) => {
|
||||
ipcRenderer.send(ipcTypes.default.store.set, {
|
||||
"polling.pollingInterval": val,
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<DataLabel label="Polling Enabled? (Recommended for Network Monitoring)">
|
||||
<Switch
|
||||
onChange={handlePollingToggle}
|
||||
checked={
|
||||
appSettings && appSettings.polling && appSettings.polling.enabled
|
||||
}
|
||||
/>
|
||||
</DataLabel>
|
||||
<DataLabel label="Polling Interval">
|
||||
<InputNumber
|
||||
onChange={handleIntervalChange}
|
||||
value={
|
||||
appSettings &&
|
||||
appSettings.polling &&
|
||||
appSettings.polling.pollingInterval
|
||||
}
|
||||
/>
|
||||
</DataLabel>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(WatcherPollingMolecule);
|
||||
@@ -21,7 +21,6 @@ export function FilePathsList({ watchedPaths }) {
|
||||
ipcRenderer.send(ipcTypes.default.fileWatcher.toMain.filepathsGet);
|
||||
}, []);
|
||||
|
||||
console.log("watchedPaths", watchedPaths);
|
||||
return (
|
||||
<div>
|
||||
<Typography.Title>Watcher File Paths</Typography.Title>
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
import { Col, Row } from "antd";
|
||||
import React from "react";
|
||||
import React, { useEffect } from "react";
|
||||
import ipcTypes from "../../../ipc.types";
|
||||
import WatcherPollingMolecule from "../../molecules/watcher-polling/watcher-polling.molecule";
|
||||
import FilePathsListOrganism from "../../organisms/filepaths-list/filepaths-list.organism";
|
||||
import ShopSettingsOrganism from "../../organisms/shop-settings/shop-settings.organism";
|
||||
import WatcherManagerOrganism from "../../organisms/watcher-manager/watcher-manager.organism";
|
||||
const { ipcRenderer } = window;
|
||||
|
||||
export default function SettingsPage() {
|
||||
useEffect(() => {
|
||||
ipcRenderer.send(ipcTypes.default.store.getAll);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Row gutter={[16, 16]}>
|
||||
@@ -13,6 +20,7 @@ export default function SettingsPage() {
|
||||
</Col>
|
||||
<Col span={6}>
|
||||
<WatcherManagerOrganism />
|
||||
<WatcherPollingMolecule />
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
|
||||
@@ -9,6 +9,12 @@ exports.default = {
|
||||
setAcceptableInsCoNm: "setAcceptableInsCoNm",
|
||||
},
|
||||
},
|
||||
store: {
|
||||
get: "store__get",
|
||||
getAll: "store_getAll",
|
||||
set: "store_set",
|
||||
response: "store_response",
|
||||
},
|
||||
fileWatcher: {
|
||||
toMain: {
|
||||
filepathsGet: "filewatcher__filepathsget",
|
||||
@@ -16,6 +22,7 @@ exports.default = {
|
||||
stop: "filewatcher__stop",
|
||||
addPath: "filewatcher__addPath",
|
||||
removePath: "filewatcher__removePath",
|
||||
setPolling: "filewatcher__setPolling",
|
||||
},
|
||||
toRenderer: {
|
||||
filepathsList: "filewatcher__filepathslist",
|
||||
@@ -23,6 +30,7 @@ exports.default = {
|
||||
startFailure: "filewatcher__start-failure",
|
||||
stopSuccess: "filewatcher__stop-success",
|
||||
error: "filewatcher__error",
|
||||
getPolling: "filewatcher__getPolling",
|
||||
},
|
||||
},
|
||||
estimate: {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import ipcTypes from "../ipc.types";
|
||||
import {
|
||||
setSettings,
|
||||
setWatchedPaths,
|
||||
setWatcherStatus,
|
||||
} from "../redux/application/application.actions";
|
||||
@@ -52,3 +53,7 @@ ipcRenderer.on(
|
||||
await UpsertEstimate(obj);
|
||||
}
|
||||
);
|
||||
|
||||
ipcRenderer.on(ipcTypes.default.store.response, (event, obj) => {
|
||||
store.dispatch(setSettings(obj));
|
||||
});
|
||||
|
||||
@@ -38,3 +38,7 @@ export const setSelectedJobTargetPcSuccess = (pct) => ({
|
||||
type: ApplicationActionTypes.SET_SELECTED_JOB_TARGET_PC_SUCCESS,
|
||||
payload: pct,
|
||||
});
|
||||
export const setSettings = (settingsObj) => ({
|
||||
type: ApplicationActionTypes.SET_SETTINGS,
|
||||
payload: settingsObj,
|
||||
});
|
||||
|
||||
@@ -5,6 +5,7 @@ const INITIAL_STATE = {
|
||||
watcherError: null,
|
||||
selectedJobId: null,
|
||||
selectedJobTargetPc: 100,
|
||||
settings: {},
|
||||
};
|
||||
|
||||
const applicationReducer = (state = INITIAL_STATE, action) => {
|
||||
@@ -41,6 +42,9 @@ const applicationReducer = (state = INITIAL_STATE, action) => {
|
||||
};
|
||||
case ApplicationActionTypes.SET_SELECTED_JOB_ID:
|
||||
return { ...state, selectedJobId: action.payload };
|
||||
case ApplicationActionTypes.SET_SETTINGS:
|
||||
return { ...state, settings: { ...state.settings, ...action.payload } };
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
||||
@@ -26,3 +26,8 @@ export const selectSelectedJobTargetPc = createSelector(
|
||||
[selectApplication],
|
||||
(application) => application.selectedJobTargetPc
|
||||
);
|
||||
|
||||
export const selectSettings = createSelector(
|
||||
[selectApplication],
|
||||
(application) => application.settings
|
||||
);
|
||||
|
||||
@@ -7,5 +7,6 @@ const ApplicationActionTypes = {
|
||||
SET_SELECTED_JOB_ID: "SET_SELECTED_JOB_ID",
|
||||
SET_SELECTED_JOB_TARGET_PC: "SET_SELECTED_JOB_TARGET_PC",
|
||||
SET_SELECTED_JOB_TARGET_PC_SUCCESS: "SET_SELECTED_JOB_TARGET_PC_SUCCESS",
|
||||
SET_SETTINGS: "SET_SETTINGS",
|
||||
};
|
||||
export default ApplicationActionTypes;
|
||||
|
||||
Reference in New Issue
Block a user