Added preloader, initial estimate decoder.
This commit is contained in:
@@ -1,12 +1,231 @@
|
||||
const { DBFFile } = require("dbffile");
|
||||
const path = require("path");
|
||||
const _ = require("lodash");
|
||||
|
||||
async function DecodeEstimate(filePath) {
|
||||
//Path to AD1
|
||||
let dbf = await DBFFile.open("C:\\VPS\\EMS\\687_3_A.LIN");
|
||||
console.log(`DBF file contains ${dbf.recordCount} records.`);
|
||||
console.log(`Field names: ${dbf.fields.map((f) => f.name).join(", ")}`);
|
||||
let records = await dbf.readRecords(100);
|
||||
for (let record of records) console.log(record);
|
||||
const parsedFilePath = path.parse(filePath);
|
||||
let extensionlessFilePath = `${parsedFilePath.dir}\\${parsedFilePath.name}`;
|
||||
|
||||
const ret = {
|
||||
...(await DecodeAd1File(extensionlessFilePath)),
|
||||
...(await DecodeVehFile(extensionlessFilePath)),
|
||||
...(await DecodeTtlFile(extensionlessFilePath)),
|
||||
...(await DecodeLinFile(extensionlessFilePath)),
|
||||
};
|
||||
return ret;
|
||||
}
|
||||
|
||||
async function DecodeAd1File(extensionlessFilePath) {
|
||||
let dbf = await DBFFile.open(`${extensionlessFilePath}A.AD1`);
|
||||
let records = await dbf.readRecords(1);
|
||||
return _.pick(records[0], [
|
||||
// "INS_CO_ID",
|
||||
"INS_CO_NM",
|
||||
// "INS_ADDR1",
|
||||
// "INS_ADDR2",
|
||||
// "INS_CITY",
|
||||
// "INS_ST",
|
||||
// "INS_ZIP",
|
||||
// "INS_CTRY",
|
||||
|
||||
// "INS_EA",
|
||||
// "POLICY_NO",
|
||||
// "DED_AMT",
|
||||
// "DED_STATUS",
|
||||
// "ASGN_NO",
|
||||
// "ASGN_DATE",
|
||||
// "ASGN_TYPE",
|
||||
"CLM_NO",
|
||||
// "CLM_OFC_ID",
|
||||
// "CLM_OFC_NM",
|
||||
// "CLM_ADDR1",
|
||||
// "CLM_ADDR2",
|
||||
// "CLM_CITY",
|
||||
// "CLM_ST",
|
||||
// "CLM_ZIP",
|
||||
// "CLM_CTRY",
|
||||
// "CLM_PH1",
|
||||
// "CLM_PH1X",
|
||||
// "CLM_PH2",
|
||||
// "CLM_PH2X",
|
||||
// "CLM_FAX",
|
||||
// "CLM_FAXX",
|
||||
// "CLM_CT_LN",
|
||||
// "CLM_CT_FN",
|
||||
// "CLM_TITLE",
|
||||
// "CLM_CT_PH",
|
||||
// "CLM_CT_PHX",
|
||||
// "CLM_EA",
|
||||
// "PAYEE_NMS",
|
||||
// "PAY_TYPE",
|
||||
// "PAY_DATE",
|
||||
// "PAY_CHKNM",
|
||||
// "PAY_AMT",
|
||||
// "AGT_CO_ID",
|
||||
// "AGT_CO_NM",
|
||||
// "AGT_ADDR1",
|
||||
// "AGT_ADDR2",
|
||||
// "AGT_CITY",
|
||||
// "AGT_ST",
|
||||
// "AGT_ZIP",
|
||||
// "AGT_CTRY",
|
||||
// "AGT_PH1",
|
||||
// "AGT_PH1X",
|
||||
// "AGT_PH2",
|
||||
// "AGT_PH2X",
|
||||
// "AGT_FAX",
|
||||
// "AGT_FAXX",
|
||||
// "AGT_CT_LN",
|
||||
// "AGT_CT_FN",
|
||||
// "AGT_CT_PH",
|
||||
// "AGT_CT_PHX",
|
||||
// "AGT_EA",
|
||||
// "AGT_LIC_NO",
|
||||
// "LOSS_DATE",
|
||||
// "LOSS_TYPE",
|
||||
// "LOSS_DESC",
|
||||
// "THEFT_IND",
|
||||
// "CAT_NO",
|
||||
// "TLOS_IND",
|
||||
// "CUST_PR",
|
||||
// "INSD_LN",
|
||||
// "INSD_FN",
|
||||
// "INSD_TITLE",
|
||||
// "INSD_CO_NM",
|
||||
// "INSD_ADDR1",
|
||||
// "INSD_ADDR2",
|
||||
// "INSD_CITY",
|
||||
// "INSD_ST",
|
||||
// "INSD_ZIP",
|
||||
// "INSD_CTRY",
|
||||
// "INSD_PH1",
|
||||
// "INSD_PH1X",
|
||||
// "INSD_PH2",
|
||||
// "INSD_PH2X",
|
||||
// "INSD_FAX",
|
||||
// "INSD_FAXX",
|
||||
// "INSD_EA",
|
||||
"OWNR_LN",
|
||||
"OWNR_FN",
|
||||
// "OWNR_TITLE",
|
||||
// "OWNR_CO_NM",
|
||||
// "OWNR_ADDR1",
|
||||
// "OWNR_ADDR2",
|
||||
// "OWNR_CITY",
|
||||
// "OWNR_ST",
|
||||
// "OWNR_ZIP",
|
||||
// "OWNR_CTRY",
|
||||
// "OWNR_PH1",
|
||||
// "OWNR_PH1X",
|
||||
// "OWNR_PH2",
|
||||
// "OWNR_PH2X",
|
||||
// "OWNR_FAX",
|
||||
// "OWNR_FAXX",
|
||||
// "OWNR_EA",
|
||||
// "INS_PH1",
|
||||
// "INS_PH1X",
|
||||
// "INS_PH2",
|
||||
// "INS_PH2X",
|
||||
// "INS_FAX",
|
||||
// "INS_FAXX",
|
||||
// "INS_CT_LN",
|
||||
// "INS_CT_FN",
|
||||
// "INS_TITLE",
|
||||
// "INS_CT_PH",
|
||||
// "INS_CT_PHX",
|
||||
// "LOSS_CAT",
|
||||
]);
|
||||
}
|
||||
async function DecodeVehFile(extensionlessFilePath) {
|
||||
let dbf = await DBFFile.open(`${extensionlessFilePath}V.VEH`);
|
||||
let records = await dbf.readRecords(1);
|
||||
return _.pick(records[0], [
|
||||
// "IMPACT_1",
|
||||
// "IMPACT_2",
|
||||
// "DB_V_CODE",
|
||||
// "PLATE_NO",
|
||||
// "PLATE_ST",
|
||||
"V_VIN",
|
||||
// "V_COND",
|
||||
// "V_PROD_DT",
|
||||
"V_MODEL_YR",
|
||||
// "V_MAKECODE",
|
||||
"V_MAKEDESC",
|
||||
"V_MODEL",
|
||||
"V_TYPE",
|
||||
// "V_BSTYLE",
|
||||
// "V_TRIMCODE",
|
||||
// "TRIM_COLOR",
|
||||
// "V_MLDGCODE",
|
||||
// "V_ENGINE",
|
||||
// "V_COLOR",
|
||||
// "V_TONE",
|
||||
// "V_STAGE",
|
||||
// "PAINT_CD1",
|
||||
// "PAINT_CD2",
|
||||
// "PAINT_CD3",
|
||||
]);
|
||||
}
|
||||
async function DecodeTtlFile(extensionlessFilePath) {
|
||||
let dbf = await DBFFile.open(`${extensionlessFilePath}.TTL`);
|
||||
let records = await dbf.readRecords(1);
|
||||
return _.pick(records[0], ["CLM_TOTAL"]);
|
||||
}
|
||||
|
||||
async function DecodeLinFile(extensionlessFilePath) {
|
||||
let dbf = await DBFFile.open(`${extensionlessFilePath}.LIN`);
|
||||
let records = await dbf.readRecords();
|
||||
|
||||
let joblines = records.map((record) =>
|
||||
_.pick(record, [
|
||||
// "LINE_NO",
|
||||
"LINE_IND",
|
||||
// "LINE_REF",
|
||||
// "TRAN_CODE",
|
||||
// "DB_REF",
|
||||
"UNQ_SEQ",
|
||||
// "WHO_PAYS",
|
||||
"LINE_DESC",
|
||||
"PART_TYPE",
|
||||
// "PART_DESCJ",
|
||||
// "GLASS_FLAG",
|
||||
"OEM_PARTNO",
|
||||
// "PRICE_INC",
|
||||
// "ALT_PART_I",
|
||||
// "TAX_PART",
|
||||
"DB_PRICE",
|
||||
"ACT_PRICE",
|
||||
// "PRICE_J",
|
||||
// "CERT_PART",
|
||||
"PART_QTY",
|
||||
// "ALT_CO_ID",
|
||||
// "ALT_PARTNO",
|
||||
// "ALT_OVERRD",
|
||||
// "ALT_PARTM",
|
||||
// "PRT_DSMK_P",
|
||||
// "PRT_DSMK_M",
|
||||
// "MOD_LBR_TY",
|
||||
// "DB_HRS",
|
||||
// "MOD_LB_HRS",
|
||||
// "LBR_INC",
|
||||
// "LBR_OP",
|
||||
// "LBR_HRS_J",
|
||||
// "LBR_TYP_J",
|
||||
// "LBR_OP_J",
|
||||
// "PAINT_STG",
|
||||
// "PAINT_TONE",
|
||||
// "LBR_TAX",
|
||||
// "LBR_AMT",
|
||||
// "MISC_AMT",
|
||||
// "MISC_SUBLT",
|
||||
// "MISC_TAX",
|
||||
// "BETT_TYPE",
|
||||
// "BETT_PCTG",
|
||||
// "BETT_AMT",
|
||||
// "BETT_TAX",
|
||||
])
|
||||
);
|
||||
return { joblines: { data: joblines } };
|
||||
}
|
||||
|
||||
exports.DecodeEstimate = DecodeEstimate;
|
||||
|
||||
@@ -8,8 +8,10 @@ require("./file-watcher/file-watcher-ipc");
|
||||
console.log("*** Added IPC Handlers ***");
|
||||
|
||||
ipcMain.on("test", async (event, object) => {
|
||||
DecodeEstimate();
|
||||
event.sender.send("test-success", { success: true });
|
||||
console.log("Received test IPC Command");
|
||||
const job = await DecodeEstimate("C:\\VPS\\EMS\\687_3_A.AD1");
|
||||
|
||||
event.reply("test-success", { status: 0, message: null, data: job });
|
||||
});
|
||||
|
||||
// ipcMain.on("test-start", async (event, arg) => {
|
||||
|
||||
@@ -18,6 +18,8 @@ if (require("electron-squirrel-startup")) {
|
||||
app.quit();
|
||||
}
|
||||
|
||||
console.log(`${__dirname}/preload.js`);
|
||||
|
||||
var mainWindow = null;
|
||||
function createWindow() {
|
||||
// Create the browser window.
|
||||
@@ -26,8 +28,11 @@ function createWindow() {
|
||||
height: 600,
|
||||
title: "ImEX RPS",
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
enableRemoteModule: true,
|
||||
nodeIntegration: false,
|
||||
enableRemoteModule: false,
|
||||
worldSafeExecuteJavaScript: true,
|
||||
contextIsolation: true,
|
||||
preload: path.join(__dirname, "preload.js"), // use a preload script
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
31
electron/preload.js
Normal file
31
electron/preload.js
Normal file
@@ -0,0 +1,31 @@
|
||||
console.log("Running preloader!");
|
||||
const { contextBridge, ipcRenderer } = require("electron");
|
||||
|
||||
ipcRenderer.removeAllListeners();
|
||||
contextBridge.exposeInMainWorld("ipcRenderer", {
|
||||
send: (channel, data) => {
|
||||
// whitelist channels
|
||||
// let validChannels = ["toMain"];
|
||||
// if (validChannels.includes(channel)) {
|
||||
ipcRenderer.send(channel, data);
|
||||
//}
|
||||
},
|
||||
on: (channel, func) => {
|
||||
// let validChannels = ["fromMain"];
|
||||
// if (validChannels.includes(channel)) {
|
||||
// Deliberately strip event as it includes `sender`
|
||||
ipcRenderer.on(
|
||||
channel,
|
||||
func
|
||||
///(event, ...args) => func(...args)
|
||||
);
|
||||
// }
|
||||
},
|
||||
removeAllListeners: (...channels) => {
|
||||
// let validChannels = ["fromMain"];
|
||||
// if (validChannels.includes(channel)) {
|
||||
// Deliberately strip event as it includes `sender`
|
||||
ipcRenderer.removeAllListeners(...channels);
|
||||
// }
|
||||
},
|
||||
});
|
||||
@@ -17,6 +17,7 @@
|
||||
"electron-squirrel-startup": "^1.0.0",
|
||||
"firebase": "^7.23.0",
|
||||
"graphql": "^15.3.0",
|
||||
"lodash": "^4.17.20",
|
||||
"node-sass": "^4.14.1",
|
||||
"react": "^16.13.1",
|
||||
"react-dom": "^16.13.1",
|
||||
|
||||
@@ -4,7 +4,7 @@ import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import ipcTypes from "../../../ipc.types";
|
||||
|
||||
const { ipcRenderer } = window.require("electron");
|
||||
const { ipcRenderer } = window;
|
||||
//const settings = window.require("electron-settings");
|
||||
|
||||
const mapStateToProps = createStructuredSelector({});
|
||||
@@ -33,7 +33,7 @@ export function JobsPage() {
|
||||
ipcRenderer.send("test", { test: true });
|
||||
}}
|
||||
>
|
||||
TEST Generic IPC
|
||||
TEST
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => {
|
||||
|
||||
9
src/graphql/bodyshop.queries.js
Normal file
9
src/graphql/bodyshop.queries.js
Normal file
@@ -0,0 +1,9 @@
|
||||
import gql from "graphql-tag";
|
||||
export const QUERY_BODYSHOP = gql`
|
||||
query QUERY_BODYSHOP {
|
||||
bodyshops {
|
||||
id
|
||||
shopname
|
||||
}
|
||||
}
|
||||
`;
|
||||
@@ -1,12 +1,12 @@
|
||||
import ipcTypes from "../ipc.types";
|
||||
import { store } from "../redux/store";
|
||||
import { signOutStart } from "../redux/user/user.actions";
|
||||
const { ipcRenderer } = window.require("electron");
|
||||
// import { store } from "../redux/store";
|
||||
// import { signOutStart } from "../redux/user/user.actions";
|
||||
const { ipcRenderer } = window;
|
||||
|
||||
console.log("----Initializing IPC Listeners in React App.");
|
||||
|
||||
ipcRenderer.on(ipcTypes.default.filewatcher.startSuccess, (event, obj) => {
|
||||
console.log(ipcTypes.default.filewatcher.startSuccess, obj);
|
||||
ipcRenderer.on(ipcTypes.default.filewatcher.startSuccess, (event, ...obj) => {
|
||||
console.log(ipcTypes.default.filewatcher.startSuccess, event, obj);
|
||||
|
||||
store.dispatch(signOutStart());
|
||||
// store.dispatch(signOutStart());
|
||||
});
|
||||
|
||||
@@ -49,7 +49,10 @@ export const updateUserDetailsSuccess = (userDetails) => ({
|
||||
payload: userDetails,
|
||||
});
|
||||
|
||||
|
||||
export const setBodyshop = (bodyshop) => ({
|
||||
type: UserActionTypes.SET_SHOP_DETAILS,
|
||||
payload: bodyshop,
|
||||
});
|
||||
|
||||
export const setLocalFingerprint = (fingerprint) => ({
|
||||
type: UserActionTypes.SET_LOCAL_FINGERPRINT,
|
||||
|
||||
@@ -19,9 +19,11 @@ const INITIAL_STATE = {
|
||||
|
||||
const userReducer = (state = INITIAL_STATE, action) => {
|
||||
switch (action.type) {
|
||||
case UserActionTypes.SET_SHOP_DETAILS:
|
||||
return { ...state, bodyshop: action.payload };
|
||||
case UserActionTypes.SET_LOCAL_FINGERPRINT:
|
||||
return { ...state, fingerprint: action.payload };
|
||||
|
||||
|
||||
case UserActionTypes.VALIDATE_PASSWORD_RESET_START:
|
||||
case UserActionTypes.SEND_PASSWORD_RESET_EMAIL_START:
|
||||
return {
|
||||
@@ -73,7 +75,6 @@ const userReducer = (state = INITIAL_STATE, action) => {
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
case UserActionTypes.SIGN_IN_FAILURE:
|
||||
case UserActionTypes.SIGN_OUT_FAILURE:
|
||||
case UserActionTypes.EMAIL_SIGN_UP_FAILURE:
|
||||
@@ -81,7 +82,7 @@ const userReducer = (state = INITIAL_STATE, action) => {
|
||||
...state,
|
||||
error: action.payload,
|
||||
};
|
||||
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
getCurrentUser,
|
||||
updateCurrentUser,
|
||||
} from "../../firebase/firebase.utils";
|
||||
import { QUERY_BODYSHOP } from "../../graphql/bodyshop.queries";
|
||||
import client from "../../graphql/GraphQLClient";
|
||||
import { UPSERT_USER } from "../../graphql/user.queries";
|
||||
import {
|
||||
@@ -17,7 +18,9 @@ import {
|
||||
updateUserDetailsSuccess,
|
||||
validatePasswordResetFailure,
|
||||
validatePasswordResetSuccess,
|
||||
setBodyshop
|
||||
} from "./user.actions";
|
||||
|
||||
import UserActionTypes from "./user.types";
|
||||
|
||||
export function* onEmailSignInStart() {
|
||||
@@ -26,7 +29,6 @@ export function* onEmailSignInStart() {
|
||||
export function* signInWithEmail({ payload: { email, password } }) {
|
||||
try {
|
||||
const { user } = yield auth.signInWithEmailAndPassword(email, password);
|
||||
console.log("function*signInWithEmail -> user", user)
|
||||
|
||||
const result = yield client.mutate({
|
||||
mutation: UPSERT_USER,
|
||||
@@ -103,6 +105,11 @@ export function* onSignInSuccess() {
|
||||
}
|
||||
|
||||
export function* signInSuccessSaga({ payload }) {
|
||||
//Query for the Correct Bodyshop
|
||||
|
||||
const shop = yield client.query({ query: QUERY_BODYSHOP });
|
||||
|
||||
yield put(setBodyshop(shop.data.bodyshops[0]));
|
||||
// LogRocket.identify(payload.email);
|
||||
// if (!payload.email.includes("@imex.")) yield put(setInstanceId(payload.uid));
|
||||
// yield logImEXEvent("redux_sign_in_success");
|
||||
|
||||
@@ -16,3 +16,8 @@ export const selectPasswordReset = createSelector(
|
||||
[selectUser],
|
||||
(user) => user.passwordreset
|
||||
);
|
||||
|
||||
export const selectBodyshop = createSelector(
|
||||
[selectUser],
|
||||
(user) => user.bodyshop
|
||||
);
|
||||
Reference in New Issue
Block a user