diff --git a/src/components/atoms/error-result/error-result.atom.jsx b/src/components/atoms/error-result/error-result.atom.jsx index 8b170c2..9903c4a 100644 --- a/src/components/atoms/error-result/error-result.atom.jsx +++ b/src/components/atoms/error-result/error-result.atom.jsx @@ -1,11 +1,19 @@ import { Button, Result } from "antd"; import React from "react"; +import ipcTypes from "../../../ipc.types"; +const { ipcRenderer } = window; export default function ErrorResultAtom({ title, errorMessage, tryAgainCallback, }) { + ipcRenderer.send(ipcTypes.default.app.toMain.track, { + event: "ERROR_RESULT_ATOM_DISPLAYED", + title, + errorMessage, + }); + return ( ({ export function WatcherPollingMolecule({ appSettings }) { const handleChange = (val) => { + ipcRenderer.send(ipcTypes.default.app.toMain.track, { + event: "TOGGLE_NOTIFICATION", + enabled: val, + }); + ipcRenderer.send(ipcTypes.default.store.set, { enableNotifications: val, }); diff --git a/src/components/molecules/close-date-display/close-date-display.molecule.jsx b/src/components/molecules/close-date-display/close-date-display.molecule.jsx index df83547..a771319 100644 --- a/src/components/molecules/close-date-display/close-date-display.molecule.jsx +++ b/src/components/molecules/close-date-display/close-date-display.molecule.jsx @@ -3,8 +3,9 @@ import { DatePicker, message, Spin } from "antd"; import moment from "moment"; import React, { useState } from "react"; import { UPDATE_JOB } from "../../../graphql/jobs.queries"; +import ipcTypes from "../../../ipc.types"; import { DateFormat } from "../../../util/constants"; - +const { ipcRenderer } = window; export default function CloseDateDisplayMolecule({ jobId, close_date }) { const [editMode, setEditMode] = useState(false); const [value, setValue] = useState(moment(close_date)); @@ -12,6 +13,9 @@ export default function CloseDateDisplayMolecule({ jobId, close_date }) { const [updateJob] = useMutation(UPDATE_JOB); const handleChange = async (newDate) => { + ipcRenderer.send(ipcTypes.default.app.toMain.track, { + event: "SET_CLOSED_DATE", + }); setLoading(true); setValue(newDate); const result = await updateJob({ diff --git a/src/components/molecules/jobs-targets-stats/jobs-targets-stats.molecule.jsx b/src/components/molecules/jobs-targets-stats/jobs-targets-stats.molecule.jsx index a46ed48..5ea09dc 100644 --- a/src/components/molecules/jobs-targets-stats/jobs-targets-stats.molecule.jsx +++ b/src/components/molecules/jobs-targets-stats/jobs-targets-stats.molecule.jsx @@ -47,26 +47,48 @@ export function JobsTargetsStatsMolecule({ marginBottom: "1rem", }} > - - (jobRpsPc || 0) ? "tomato" : "seagreen", - }} - value={((jobRpsPc || 0) * 100).toFixed(1)} - suffix="%" - /> - - - - +
+ + (jobRpsPc || 0) ? "tomato" : "seagreen", + }} + value={((jobRpsPc || 0) * 100).toFixed(1)} + suffix="%" + /> +
+
+ + +
+
+ + +
); } diff --git a/src/components/molecules/reporting-jobs-list/reporting-jobs-list.molecule.jsx b/src/components/molecules/reporting-jobs-list/reporting-jobs-list.molecule.jsx index 16fa7ca..db64077 100644 --- a/src/components/molecules/reporting-jobs-list/reporting-jobs-list.molecule.jsx +++ b/src/components/molecules/reporting-jobs-list/reporting-jobs-list.molecule.jsx @@ -3,11 +3,16 @@ import React, { useState } from "react"; import { connect } from "react-redux"; import { Link } from "react-router-dom"; import { createStructuredSelector } from "reselect"; +import ipcTypes from "../../../ipc.types"; import { setSelectedJobId } from "../../../redux/application/application.actions"; + import { selectReportData, selectReportLoading, } from "../../../redux/reporting/reporting.selectors"; + +const { ipcRenderer } = window; + const mapStateToProps = createStructuredSelector({ reportingLoading: selectReportLoading, reportData: selectReportData, @@ -123,6 +128,10 @@ export function ReportingJobsListMolecule({ { + ipcRenderer.send(ipcTypes.default.app.toMain.track, { + event: "REPORTS_LIST_SEARCH", + query: val, + }); setSearchText(val); }} enterButton diff --git a/src/components/organisms/jobs-list-search/jobs-list-search.organism.jsx b/src/components/organisms/jobs-list-search/jobs-list-search.organism.jsx index fb527dc..5a9e5b6 100644 --- a/src/components/organisms/jobs-list-search/jobs-list-search.organism.jsx +++ b/src/components/organisms/jobs-list-search/jobs-list-search.organism.jsx @@ -4,10 +4,13 @@ import { Dropdown, List, Menu, Spin } from "antd"; import React, { useState } from "react"; import InfiniteScroll from "react-infinite-scroller"; import { SEARCH_JOBS_PAGINATED } from "../../../graphql/jobs.queries"; +import ipcTypes from "../../../ipc.types"; import ErrorResultAtom from "../../atoms/error-result/error-result.atom"; import JobsListItemMolecule from "../../molecules/jobs-list-item/jobs-list-item.molecule"; import JobsSearchFieldsMolecule from "../../molecules/jobs-search-fields/jobs-search-fields.molecule"; +const { ipcRenderer } = window; + const limit = 20; export default function JobsTableOrganism() { const [state, setState] = useState({ hasMore: true }); @@ -33,32 +36,35 @@ export default function JobsTableOrganism() { const handleInfiniteOnLoad = (page) => { if (fetchMore) - fetchMore({ - variables: { - offset: limit * page, - }, - updateQuery: (prev, { fetchMoreResult }) => { - if (!fetchMoreResult) { - console.log("No more results. Fetch More was empty."); - setState({ ...state, hasMore: false }); - return prev; - } - - const newCache = Object.assign({}, prev, { - jobs: [...prev.search_jobs, ...fetchMoreResult.search_jobs], - }); - - if ( - newCache.jobs.length >= data && - data.search_jobs_aggregate.aggregate.count - ) { - console.log("No more results."); - setState({ ...state, hasMore: false }); - } - - return newCache; - }, + ipcRenderer.send(ipcTypes.default.app.toMain.track, { + event: "FETCH_MORE_JOBS", }); + fetchMore({ + variables: { + offset: limit * page, + }, + updateQuery: (prev, { fetchMoreResult }) => { + if (!fetchMoreResult) { + console.log("No more results. Fetch More was empty."); + setState({ ...state, hasMore: false }); + return prev; + } + + const newCache = Object.assign({}, prev, { + jobs: [...prev.search_jobs, ...fetchMoreResult.search_jobs], + }); + + if ( + newCache.jobs.length >= data && + data.search_jobs_aggregate.aggregate.count + ) { + console.log("No more results."); + setState({ ...state, hasMore: false }); + } + + return newCache; + }, + }); }; if (error) diff --git a/src/components/test.jsx b/src/components/test.jsx deleted file mode 100644 index 22c0e3c..0000000 --- a/src/components/test.jsx +++ /dev/null @@ -1,48 +0,0 @@ -import { Button, Layout } from "antd"; -import React, { useEffect } from "react"; -import { connect } from "react-redux"; -import { createStructuredSelector } from "reselect"; -import ipcTypes from "../ipc.types"; - -const { ipcRenderer } = window.require("electron"); - -const mapStateToProps = createStructuredSelector({}); -const mapDispatchToProps = (dispatch) => ({}); - -export function App() { - useEffect(() => { - ipcRenderer.on("not a real channel", (event, obj) => { - console.log("not a real channel", obj); - }); - // Cleanup the listener events so that memory leaks are avoided. - return function cleanup() { - ipcRenderer.removeAllListeners("not a real channel"); - }; - }, []); - - return ( - - -
Header
-
- -
Welcome to your new react app. asdas sd
- - -
-
- ); -} -export default connect(mapStateToProps, mapDispatchToProps)(App); diff --git a/src/redux/application/application.reducer.js b/src/redux/application/application.reducer.js index 4cb31fe..5cb8ddc 100644 --- a/src/redux/application/application.reducer.js +++ b/src/redux/application/application.reducer.js @@ -1,3 +1,4 @@ +import ipcTypes from "../../ipc.types"; import ApplicationActionTypes from "./application.types"; const INITIAL_STATE = { watcherStatus: "Not Started", @@ -8,6 +9,8 @@ const INITIAL_STATE = { settings: {}, }; +const { ipcRenderer } = window; + const applicationReducer = (state = INITIAL_STATE, action) => { switch (action.type) { case ApplicationActionTypes.SET_WATCHED_PATHS: @@ -16,11 +19,17 @@ const applicationReducer = (state = INITIAL_STATE, action) => { watchedPaths: action.payload, }; case ApplicationActionTypes.ADD_WATCHED_PATH: + ipcRenderer.send(ipcTypes.default.app.toMain.track, { + event: "ADD_WATCHED_PATH", + }); return { ...state, watchedPaths: [...state.watchedPaths, action.payload], }; case ApplicationActionTypes.REMOVE_WATCHED_PATH: + ipcRenderer.send(ipcTypes.default.app.toMain.track, { + event: "REMOVE_WATCHED_PATH", + }); return { ...state, watchedPaths: state.watchedPaths.filter((p) => p !== action.payload), @@ -31,6 +40,10 @@ const applicationReducer = (state = INITIAL_STATE, action) => { watcherStatus: action.payload, }; case ApplicationActionTypes.SET_WATCHER_ERROR: + ipcRenderer.send(ipcTypes.default.app.toMain.track, { + event: "WATCHER_ERROR", + error: action.payload, + }); return { ...state, watcherError: action.payload, @@ -41,6 +54,9 @@ const applicationReducer = (state = INITIAL_STATE, action) => { selectedJobTargetPc: action.payload, }; case ApplicationActionTypes.SET_SELECTED_JOB_ID: + ipcRenderer.send(ipcTypes.default.app.toMain.track, { + event: "SET_SELECTED_JOB", + }); return { ...state, selectedJobId: action.payload }; case ApplicationActionTypes.SET_SETTINGS: return { ...state, settings: { ...state.settings, ...action.payload } }; diff --git a/src/redux/user/user.sagas.js b/src/redux/user/user.sagas.js index fa04b4a..007e6b5 100644 --- a/src/redux/user/user.sagas.js +++ b/src/redux/user/user.sagas.js @@ -92,6 +92,9 @@ export function* onSignOutStart() { export function* signOutStart() { try { + ipcRenderer.send(ipcTypes.default.app.toMain.track, { + event: "SIGN_OUT", + }); ipcRenderer.send(ipcTypes.default.fileWatcher.toMain.stop); yield auth.signOut(); yield put(signOutSuccess()); @@ -155,6 +158,10 @@ export function* onSendPasswordResetStart() { } export function* sendPasswordResetEmail({ payload }) { try { + ipcRenderer.send(ipcTypes.default.app.toMain.track, { + event: "RESET_PASSWORD", + email: payload, + }); yield auth.sendPasswordResetEmail(payload); yield put(sendPasswordResetSuccess());