Add app progress on file uploads.

This commit is contained in:
Patrick Fic
2025-04-09 14:18:43 -07:00
parent 1aa9e96e16
commit 27da03ec58
2 changed files with 28 additions and 0 deletions

View File

@@ -42,6 +42,7 @@ import DecodeTtl from "./decode-ttl";
import { DecodedTtl } from "./decode-ttl.interface";
import DecodeVeh from "./decode-veh";
import { DecodedVeh } from "./decode-veh.interface";
import setAppProgressbar from "../util/setAppProgressBar";
async function ImportJob(filepath: string): Promise<void> {
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.
//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);
setAppProgressbar(0.15);
const ad1: DecodedAd1 = await DecodeAD1(extensionlessFilePath);
setAppProgressbar(0.2);
const ad2: DecodedAD2 = await DecodeAD2(extensionlessFilePath);
setAppProgressbar(0.25);
const veh: DecodedVeh = await DecodeVeh(extensionlessFilePath);
setAppProgressbar(0.3);
const lin: DecodedLin = await DecodeLin(extensionlessFilePath);
setAppProgressbar(0.35);
const pfh: DecodedPfh = await DecodePfh(extensionlessFilePath);
setAppProgressbar(0.4);
const pfl: DecodedPfl = await DecodePfl(extensionlessFilePath);
setAppProgressbar(0.45);
const pft: DecodedPft = await DecodePft(extensionlessFilePath);
setAppProgressbar(0.5);
const pfm: DecodedPfm = await DecodePfm(extensionlessFilePath);
setAppProgressbar(0.55);
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
setAppProgressbar(0.65);
const ttl: DecodedTtl = await DecodeTtl(extensionlessFilePath);
setAppProgressbar(0.7);
const pfp: DecodedPfp = await DecodePfp(extensionlessFilePath);
setAppProgressbar(0.75);
const jobObjectUncleaned: RawJobDataObject = {
...env,
@@ -89,6 +104,7 @@ async function ImportJob(filepath: string): Promise<void> {
// Replace owner information with claimant information if necessary
const jobObject = ReplaceOwnerInfoWithClaimant(jobObjectUncleaned);
setAppProgressbar(0.8);
if (import.meta.env.DEV) {
// Save jobObject to a timestamped JSON file
@@ -126,6 +142,7 @@ async function ImportJob(filepath: string): Promise<void> {
issupplement: false,
jobid: null,
};
setAppProgressbar(0.85);
const existingVehicleRecord: VehicleQueryResult = await client.request(
QUERY_VEHICLE_BY_VIN_TYPED,
@@ -141,6 +158,7 @@ async function ImportJob(filepath: string): Promise<void> {
console.log("Available Job record to upload;", newAvailableJob);
setAppProgressbar(0.95);
const existingJobRecord: QueryJobByClmNoResult = await client.request(
QUERY_JOB_BY_CLM_NO_TYPED,
{ clm_no: jobObject.clm_no },
@@ -157,6 +175,7 @@ async function ImportJob(filepath: string): Promise<void> {
jobInput: [newAvailableJob],
},
);
setAppProgressbar(-1);
new Notification({
title: "Job Imported",
body: `Job ${newAvailableJob.cieca_id} imported successfully`,

View 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;