Skip to content

Commit

Permalink
Actually working
Browse files Browse the repository at this point in the history
  • Loading branch information
Charlie Kapsiak committed Oct 28, 2024
1 parent 048deb1 commit e31b268
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 38 deletions.
2 changes: 1 addition & 1 deletion src/lib/config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export let config = {
add_component_url: "http://cmslab1.spa.umn.edu/Factory/EngineDB/add_component.py"
add_component_url: "https://cmslab1.spa.umn.edu/Factory/EngineDB/add_component.py"
};
59 changes: 26 additions & 33 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -39,31 +39,33 @@
data.append('full_id', engine_barcode);
const response = await fetch(config.add_component_url, {
method: "POST",
body: data,
});
if (!response.ok) {
throw new Error(`Response status: ${response.status}`);
}
engine_barcode = null;
ldo_barcode = null;
const text = await response.text();
const resp = text.split("Begin")[1].split("End")[0].trim()
console.log(resp);
if (resp.includes("Error")){
var opts = nok_opts;
} else {
var opts = ok_opts;
try{
const response = await fetch(config.add_component_url, {
method: "POST",
body: data,
});
if (!response.ok) {
throw new Error(`Response status: ${response.status}`);
}
engine_barcode = null;
ldo_barcode = null;
const text = await response.text();
const resp = text.split("Begin")[1].split("End")[0].trim()
let opts = null;
if (resp.includes("Error")){
opts = nok_opts;
} else {
opts = ok_opts;
}
toast.push(resp, opts)
} catch (err){
toast.push(err.toString(), nok_opts)
}
toast.push(resp, opts)
}
let is_decoding=false;
Expand All @@ -80,15 +82,9 @@
const t = data;
if (data.request === 'Engine') {
engine_barcode = t.value;
//is_engine_code_valid = engine_code_regex.test(engine_barcode)
} else {
ldo_barcode = t.value;
//is_ldo_code_valid = ldo_code_regex.test(ldo_barcode)
}
console.log(engine_barcode)
console.log(ldo_barcode)
}
Expand All @@ -105,8 +101,6 @@
&& is_ldo_code_valid
}
</script>


Expand Down Expand Up @@ -142,7 +136,6 @@
/>
</div>
<div class="column is-full">
<!-- <button disabled={!ok_to_submit} class="button is-success is-fullwidth" on:click={handleSubmit}>Submit</button> -->
<button disabled={!ok_to_submit} class="button is-success is-fullwidth" on:click={handleSubmit}>Submit</button>
</div>
</div>
Expand Down
6 changes: 2 additions & 4 deletions src/routes/BarcodeBox.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,12 @@
</button>
</div>
</div>
{#if barcode !== null || is_loading || true}
{#if barcode !== null || is_loading}
<div class="columns">
<div class="column">
<div class="control" class:is-loading={is_loading}>
<!-- <input class="input" type="text" value="{barcode}" readonly disabled/> -->
<input class="input" type="text" bind:value={barcode}/>
<input class="input" type="text" bind:value={barcode} readonly disabled/>
</div>
<!-- <span class="is-size-6"> {barcode} </span> -->
</div>
</div>
{/if}
Expand Down

0 comments on commit e31b268

Please sign in to comment.