Add app progress on file uploads.
This commit is contained in:
@@ -42,6 +42,7 @@ import DecodeTtl from "./decode-ttl";
|
|||||||
import { DecodedTtl } from "./decode-ttl.interface";
|
import { DecodedTtl } from "./decode-ttl.interface";
|
||||||
import DecodeVeh from "./decode-veh";
|
import DecodeVeh from "./decode-veh";
|
||||||
import { DecodedVeh } from "./decode-veh.interface";
|
import { DecodedVeh } from "./decode-veh.interface";
|
||||||
|
import setAppProgressbar from "../util/setAppProgressBar";
|
||||||
|
|
||||||
async function ImportJob(filepath: string): Promise<void> {
|
async function ImportJob(filepath: string): Promise<void> {
|
||||||
const parsedFilePath = path.parse(filepath);
|
const parsedFilePath = path.parse(filepath);
|
||||||
@@ -56,19 +57,33 @@ async function ImportJob(filepath: string): Promise<void> {
|
|||||||
|
|
||||||
//The below all end up returning parts of the job object.
|
//The below all end up returning parts of the job object.
|
||||||
//Some of them return additional info - e.g. owner or vehicle record data at both the job and corresponding table level.
|
//Some of them return additional info - e.g. owner or vehicle record data at both the job and corresponding table level.
|
||||||
|
setAppProgressbar(0.1);
|
||||||
const env: DecodedEnv = await DecodeEnv(extensionlessFilePath);
|
const env: DecodedEnv = await DecodeEnv(extensionlessFilePath);
|
||||||
|
setAppProgressbar(0.15);
|
||||||
const ad1: DecodedAd1 = await DecodeAD1(extensionlessFilePath);
|
const ad1: DecodedAd1 = await DecodeAD1(extensionlessFilePath);
|
||||||
|
setAppProgressbar(0.2);
|
||||||
const ad2: DecodedAD2 = await DecodeAD2(extensionlessFilePath);
|
const ad2: DecodedAD2 = await DecodeAD2(extensionlessFilePath);
|
||||||
|
setAppProgressbar(0.25);
|
||||||
const veh: DecodedVeh = await DecodeVeh(extensionlessFilePath);
|
const veh: DecodedVeh = await DecodeVeh(extensionlessFilePath);
|
||||||
|
setAppProgressbar(0.3);
|
||||||
const lin: DecodedLin = await DecodeLin(extensionlessFilePath);
|
const lin: DecodedLin = await DecodeLin(extensionlessFilePath);
|
||||||
|
setAppProgressbar(0.35);
|
||||||
const pfh: DecodedPfh = await DecodePfh(extensionlessFilePath);
|
const pfh: DecodedPfh = await DecodePfh(extensionlessFilePath);
|
||||||
|
setAppProgressbar(0.4);
|
||||||
const pfl: DecodedPfl = await DecodePfl(extensionlessFilePath);
|
const pfl: DecodedPfl = await DecodePfl(extensionlessFilePath);
|
||||||
|
setAppProgressbar(0.45);
|
||||||
const pft: DecodedPft = await DecodePft(extensionlessFilePath);
|
const pft: DecodedPft = await DecodePft(extensionlessFilePath);
|
||||||
|
setAppProgressbar(0.5);
|
||||||
const pfm: DecodedPfm = await DecodePfm(extensionlessFilePath);
|
const pfm: DecodedPfm = await DecodePfm(extensionlessFilePath);
|
||||||
|
setAppProgressbar(0.55);
|
||||||
const pfo: DecodedPfo = await DecodePfo(extensionlessFilePath); // TODO: This will be the `cieca_pfo` object
|
const pfo: DecodedPfo = await DecodePfo(extensionlessFilePath); // TODO: This will be the `cieca_pfo` object
|
||||||
|
setAppProgressbar(0.6);
|
||||||
const stl: DecodedStl = await DecodeStl(extensionlessFilePath); // TODO: This will be the `cieca_stl` object
|
const stl: DecodedStl = await DecodeStl(extensionlessFilePath); // TODO: This will be the `cieca_stl` object
|
||||||
|
setAppProgressbar(0.65);
|
||||||
const ttl: DecodedTtl = await DecodeTtl(extensionlessFilePath);
|
const ttl: DecodedTtl = await DecodeTtl(extensionlessFilePath);
|
||||||
|
setAppProgressbar(0.7);
|
||||||
const pfp: DecodedPfp = await DecodePfp(extensionlessFilePath);
|
const pfp: DecodedPfp = await DecodePfp(extensionlessFilePath);
|
||||||
|
setAppProgressbar(0.75);
|
||||||
|
|
||||||
const jobObjectUncleaned: RawJobDataObject = {
|
const jobObjectUncleaned: RawJobDataObject = {
|
||||||
...env,
|
...env,
|
||||||
@@ -89,6 +104,7 @@ async function ImportJob(filepath: string): Promise<void> {
|
|||||||
|
|
||||||
// Replace owner information with claimant information if necessary
|
// Replace owner information with claimant information if necessary
|
||||||
const jobObject = ReplaceOwnerInfoWithClaimant(jobObjectUncleaned);
|
const jobObject = ReplaceOwnerInfoWithClaimant(jobObjectUncleaned);
|
||||||
|
setAppProgressbar(0.8);
|
||||||
|
|
||||||
if (import.meta.env.DEV) {
|
if (import.meta.env.DEV) {
|
||||||
// Save jobObject to a timestamped JSON file
|
// Save jobObject to a timestamped JSON file
|
||||||
@@ -126,6 +142,7 @@ async function ImportJob(filepath: string): Promise<void> {
|
|||||||
issupplement: false,
|
issupplement: false,
|
||||||
jobid: null,
|
jobid: null,
|
||||||
};
|
};
|
||||||
|
setAppProgressbar(0.85);
|
||||||
|
|
||||||
const existingVehicleRecord: VehicleQueryResult = await client.request(
|
const existingVehicleRecord: VehicleQueryResult = await client.request(
|
||||||
QUERY_VEHICLE_BY_VIN_TYPED,
|
QUERY_VEHICLE_BY_VIN_TYPED,
|
||||||
@@ -141,6 +158,7 @@ async function ImportJob(filepath: string): Promise<void> {
|
|||||||
|
|
||||||
console.log("Available Job record to upload;", newAvailableJob);
|
console.log("Available Job record to upload;", newAvailableJob);
|
||||||
|
|
||||||
|
setAppProgressbar(0.95);
|
||||||
const existingJobRecord: QueryJobByClmNoResult = await client.request(
|
const existingJobRecord: QueryJobByClmNoResult = await client.request(
|
||||||
QUERY_JOB_BY_CLM_NO_TYPED,
|
QUERY_JOB_BY_CLM_NO_TYPED,
|
||||||
{ clm_no: jobObject.clm_no },
|
{ clm_no: jobObject.clm_no },
|
||||||
@@ -157,6 +175,7 @@ async function ImportJob(filepath: string): Promise<void> {
|
|||||||
jobInput: [newAvailableJob],
|
jobInput: [newAvailableJob],
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
setAppProgressbar(-1);
|
||||||
new Notification({
|
new Notification({
|
||||||
title: "Job Imported",
|
title: "Job Imported",
|
||||||
body: `Job ${newAvailableJob.cieca_id} imported successfully`,
|
body: `Job ${newAvailableJob.cieca_id} imported successfully`,
|
||||||
|
|||||||
9
src/main/util/setAppProgressBar.ts
Normal file
9
src/main/util/setAppProgressBar.ts
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import { getMainWindow } from "./toRenderer";
|
||||||
|
|
||||||
|
const setAppProgressbar = (progress: number): void => {
|
||||||
|
const mainWindow = getMainWindow();
|
||||||
|
if (mainWindow) {
|
||||||
|
mainWindow.setProgressBar(progress);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export default setAppProgressbar;
|
||||||
Reference in New Issue
Block a user