Added disable watcher on startup. RPS-8

This commit is contained in:
Patrick Fic
2020-10-26 09:51:38 -07:00
parent 7924b4207d
commit 89a8ad380f
13 changed files with 70 additions and 15 deletions

View File

@@ -5,6 +5,7 @@ const store = new Store({
enableNotifications: true,
filePaths: [],
accepted_ins_co: [],
runWatcherOnStartup: true,
polling: {
enabled: false,
pollingInterval: 1000,

View File

@@ -17,7 +17,10 @@ ipcMain.on(
);
ipcMain.on(ipcTypes.default.fileWatcher.toMain.start, async (event, arg) => {
StartWatcher();
if ((arg && arg.startup && store.get("runWatcherOnStartup")) || !arg) {
StartWatcher();
}
// event.sender.send(ipcTypes.default.fileWatcher.toRenderer.startSuccess);
event.sender.send(
ipcTypes.default.fileWatcher.toRenderer.filepathsList,

View File

@@ -15,7 +15,7 @@ const mapDispatchToProps = (dispatch) => ({
//setUserLanguage: language => dispatch(setUserLanguage(language))
});
export function WatcherPollingMolecule({ appSettings }) {
export function NotificationsToggleAtom({ appSettings }) {
const handleChange = (val) => {
ipcRenderer.send(ipcTypes.default.app.toMain.track, {
event: "TOGGLE_NOTIFICATION",
@@ -41,4 +41,4 @@ export function WatcherPollingMolecule({ appSettings }) {
export default connect(
mapStateToProps,
mapDispatchToProps
)(WatcherPollingMolecule);
)(NotificationsToggleAtom);

View File

@@ -1,4 +1,4 @@
export default (part_type) => {
const converter = (part_type) => {
switch (part_type) {
case "PAA":
return "A/M";
@@ -19,3 +19,5 @@ export default (part_type) => {
return part_type;
}
};
export default converter;

View File

@@ -0,0 +1,41 @@
import { 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 WatcherStartupAtom({ appSettings }) {
const handleChange = (val) => {
ipcRenderer.send(ipcTypes.default.app.toMain.track, {
event: "TOGGLE_WATCHER_ON_STARTUP",
enabled: val,
});
ipcRenderer.send(ipcTypes.default.store.set, {
runWatcherOnStartup: val,
});
};
return (
<div>
<DataLabel label="Run Watcher on Startup??">
<Switch
onChange={handleChange}
checked={appSettings && appSettings.runWatcherOnStartup}
/>
</DataLabel>
</div>
);
}
export default connect(mapStateToProps, mapDispatchToProps)(WatcherStartupAtom);

View File

@@ -18,7 +18,7 @@ export default function JobsDetailDescriptionMolecule({ loading, job }) {
ghost={false}
title={job.clm_no}
subTitle={job.ins_co_nm}
extra={[<DeleteJobAtom jobId={job.id} />]}
extra={[<DeleteJobAtom key="delete" jobId={job.id} />]}
>
<Descriptions column={{ xxl: 5, xl: 4, lg: 3, md: 3, sm: 2, xs: 1 }}>
<Descriptions.Item label="Owner">{`${job.ownr_fn} ${job.ownr_ln}`}</Descriptions.Item>

View File

@@ -154,10 +154,13 @@ export default function JobLinesTableMolecule({ loading, job }) {
x: true,
y: "20rem",
}}
summary={() => (
footer={() => (
<Table.Summary.Row>
<Table.Summary.Cell index={0}>Summary</Table.Summary.Cell>
<Table.Summary.Cell index={1}>
<Table.Summary.Cell index={5}>
This is a summary content
</Table.Summary.Cell>
<Table.Summary.Cell index={6}>
This is a summary content
</Table.Summary.Cell>
</Table.Summary.Row>

View File

@@ -5,7 +5,7 @@ import { createStructuredSelector } from "reselect";
import { selectSelectedJobTargetPc } from "../../../redux/application/application.selectors";
import {
CalculateJobRpsDollars,
CalculateJobRpsPc,
CalculateJobRpsPc
} from "../../../util/CalculateJobRps";
import ErrorResultAtom from "../../atoms/error-result/error-result.atom";
@@ -25,14 +25,16 @@ export function JobsTargetsStatsMolecule({
job,
selectedJobTargetPc,
}) {
// eslint-disable-next-line react-hooks/exhaustive-deps
const { actPriceSum, jobRpsDollars } = useCallback(
CalculateJobRpsDollars(job, true),
[job]
[job, CalculateJobRpsDollars]
);
// eslint-disable-next-line react-hooks/exhaustive-deps
const { dbPriceSum, jobRpsPc } = useCallback(
CalculateJobRpsPc(job, jobRpsDollars, true),
[job, jobRpsDollars]
[job, jobRpsDollars, CalculateJobRpsPc]
);
if (loading) return <Skeleton active />;

View File

@@ -5,7 +5,6 @@ import JobsListOrganism from "../../organisms/jobs-list-latest/jobs-list-latest.
import JobsListSearchOrganism from "../../organisms/jobs-list-search/jobs-list-search.organism";
export default function JobsPage() {
console.log("Jobs Page Rerender");
const selectedBreakpoint = Object.entries(Grid.useBreakpoint())
.filter((screen) => !!screen[1])
.slice(-1)[0];

View File

@@ -22,7 +22,7 @@ export function RoutesPage({ bodyshop }) {
errorMessage="You do not currently have access to any shop. Please reach out to technical support."
/>
);
console.log("routes render");
return (
<Layout style={{ background: "#fff", height: "100vh" }} hasSider>
<Layout.Sider

View File

@@ -2,6 +2,7 @@ import { Col, Row } from "antd";
import React, { useEffect } from "react";
import ipcTypes from "../../../ipc.types";
import NotificationsToggleAtom from "../../atoms/notifications-toggle/notifications-toggle.atom";
import WatcherStartupAtom from "../../atoms/watcher-startup/watcher-startup.atom";
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";
@@ -23,6 +24,7 @@ export default function SettingsPage() {
<WatcherManagerOrganism />
<WatcherPollingMolecule />
<NotificationsToggleAtom />
<WatcherStartupAtom />
</Col>
</Row>

View File

@@ -30,5 +30,5 @@ sagaMiddleWare.run(rootSaga);
export const persistor = persistStore(store);
export default { store, persistStore };
const epxortObj = { store, persistStore };
export default epxortObj;

View File

@@ -140,7 +140,9 @@ export function* signInSuccessSaga({ payload }) {
ipcTypes.default.app.toMain.setAcceptableInsCoNm,
shop.data.bodyshops[0].accepted_ins_co
);
ipcRenderer.send(ipcTypes.default.fileWatcher.toMain.start);
ipcRenderer.send(ipcTypes.default.fileWatcher.toMain.start, {
startup: true,
});
} else {
console.log("No bodyshop has been associated.");
yield put(setBodyshop(false));