generated from CDCgov/template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(185): Add extraction page with part 1 of integration (#231)
* feat(185): Add extraction page with part 1 of integration * feat(185): Add Cors, update shape type feat(185): Add Cors, update shape type * feat(185): Add Cors, update shape type
- Loading branch information
1 parent
1845c26
commit aecf3bc
Showing
15 changed files
with
420 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Page } from "../src/contexts/FilesContext"; | ||
import { ImageToTextResponse } from "./types/types"; | ||
|
||
export const AddFormData = async (args: Page): Promise<ImageToTextResponse | null> => { | ||
|
||
const { sourceImage, templateImage, fieldNames } = args; | ||
const form = new FormData(); | ||
form.append("source_image", sourceImage); | ||
form.append("segmentation_template", templateImage); | ||
form.append("labels", JSON.stringify(fieldNames)); | ||
form.append("", ""); | ||
console.log(args) | ||
try { | ||
const response = await fetch("http://localhost:8000/image_to_text/", { | ||
"method": "POST", | ||
body: form | ||
}) | ||
return await response.json() as ImageToTextResponse; | ||
} catch (error) { | ||
console.error(error); | ||
return null; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
export interface Label { | ||
color: string; | ||
label: string; | ||
type: string; | ||
} | ||
|
||
export type Labels = Label[]; | ||
|
||
export interface ImageToTextArgs { | ||
fieldNames: Labels; | ||
sourceImage: string; | ||
templateImage: string; | ||
} | ||
|
||
export type ImageToTextResponse = { | ||
[key: string]: [string, number]; | ||
}; | ||
|
||
export interface ResultItem { | ||
text: string; | ||
confidence: number; | ||
} | ||
|
||
export interface Submission { | ||
template_name: string; | ||
template_image: string; // Base64-encoded image string | ||
file_name: string; | ||
file_image: string; // Base64-encoded image string | ||
results: { | ||
[key: string]: ResultItem; // Allows any key with a ResultItem value | ||
}; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
.loading-wrapper { | ||
position: relative; | ||
} | ||
|
||
.loading-overlay { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
background-color: rgba(255, 255, 255, 0.8); /* Semi-transparent white */ | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
z-index: 10; | ||
} | ||
|
||
.loading-spinner { | ||
border: 8px solid rgba(0, 0, 0, 0.1); | ||
border-left-color: #000; | ||
border-radius: 50%; | ||
width: 50px; | ||
height: 50px; | ||
animation: spin 1s linear infinite; | ||
} | ||
|
||
@keyframes spin { | ||
0% { | ||
transform: rotate(0deg); | ||
} | ||
100% { | ||
transform: rotate(360deg); | ||
} | ||
} | ||
|
||
.loading-text { | ||
text-align: center; | ||
margin-top: 20px; | ||
color: #333; /* Color for the text */ | ||
} | ||
|
||
.loading-text h2 { | ||
font-size: 24px; | ||
margin-bottom: 10px; | ||
} | ||
|
||
.loading-text p { | ||
font-size: 16px; | ||
color: #666; /* Lighter color for subtitle */ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React from 'react'; | ||
import './LoadingWrapper.scss'; // You'll define some styles here | ||
|
||
interface LoadingWrapperProps { | ||
isLoading: boolean; | ||
children: React.ReactNode; | ||
title?: string; | ||
subtitle?: string; | ||
} | ||
|
||
const LoadingWrapper: React.FC<LoadingWrapperProps> = ({ | ||
isLoading, | ||
children, | ||
title = 'Loading', | ||
subtitle = 'Please wait a moment...', | ||
}) => { | ||
return ( | ||
<div className="loading-wrapper"> | ||
{children} | ||
{isLoading && ( | ||
<div className="loading-overlay"> | ||
<div className="loading-spinner"></div> | ||
<div className="loading-text"> | ||
<h2>{title}</h2> | ||
<p>{subtitle}</p> | ||
</div> | ||
</div> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default LoadingWrapper; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.