Skip to content

Commit

Permalink
serverHealth typo
Browse files Browse the repository at this point in the history
  • Loading branch information
interim17 committed Oct 31, 2023
1 parent bbb8ec7 commit 2394786
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 35 deletions.
8 changes: 4 additions & 4 deletions src/components/ConversionServerCheckModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ interface ConversionServerCheckModalProps {
}

/////PSEUDOCODE OF APPROACH/////
// call a function that sends a websocket request with server health check id
// receive message from websocket with server health check id
// 1) do this with an event listener
// viewer will have a method that sends a websocket request with server health check id
// if healthy receive message from websocket with server health check id
// store response or lack of response in redux

//when sim controller gets instatiated it will call configure network which will call create simulator connection
// when sim controller gets instatiated it will call configure network which will call create simulator connection
// i should add to create simulator connection a health check call
// simulariumController.sendServerHealthCheck()

Expand Down
59 changes: 28 additions & 31 deletions src/containers/ConversionForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ interface ConversionProps {
receiveFileToConvert: ActionCreator<ReceiveFileToConvertAction>;
setError: ActionCreator<SetErrorAction>;
simulariumController: SimulariumController;
serverHealthy: boolean;
serverHealth: boolean;
}

const validFileExtensions: ExtensionMap = {
Expand All @@ -66,45 +66,28 @@ const ConversionForm = ({
conversionProcessingData,
setError,
receiveFileToConvert,
serverHealthy,
simulariumController,
}: ConversionProps): JSX.Element => {
serverHealth,
}: // simulariumController,
ConversionProps): JSX.Element => {
const [fileToConvert, setFileToConvert] = useState<UploadFile>();
const [engineSelected, setEngineSelected] = useState<boolean>(false);
const [serverDown, setServerIsDown] = useState<boolean>(false);
const [isProcessing, setIsProcessing] = useState<boolean>(false);
const [fileTypeErrorModalOpen, setFileTypeErrorModalOpen] = useState(false);

const handleFileSelection = async (file: UploadFile) => {
setFileToConvert(file);
// necessarry to check if simController exists?
// if server is unhealthy, viewer state will update and throw modal
// below method doesn't exist yet:
// simulariumController.sendServerCheck();

//to simulate server being down when we upload:
setServerIsDown(true);

//TODO: once modal is dismissed it wont arise again
//unless "serverHealthy" changes in state
// should we refire the modal if a user ignores server check
// and tried to continue with next button?
//
};

console.log("serverHealth", serverHealth);
useEffect(() => {
// the ping from handleFileSelection should set this off
if (!serverHealthy) {
if (!serverHealth) {
setServerIsDown(true);
}
}, [serverHealthy]);
}, [serverHealth]);

const closeServerCheckModal = () => {
setServerIsDown(false);
};

const [isProcessing, setIsProcessing] = useState<boolean>(false);
const [fileTypeErrorModalOpen, setFileTypeErrorModalOpen] = useState(false);

const toggleModal = () => {
const toggleFileTypeModal = () => {
setFileTypeErrorModalOpen(!fileTypeErrorModalOpen);
};
const toggleProcessing = () => {
Expand All @@ -117,6 +100,20 @@ const ConversionForm = ({
setEngineSelected(true);
};

const handleFileSelection = async (file: UploadFile) => {
setFileToConvert(file);
// necessarry to check if simController exists?
// if server is down, viewer state will update and trigger modal
// below method doesn't exist yet:
// simulariumController.sendServerCheck();

// to simulate server being down when we upload:
setServerIsDown(true);

// toggle serverDown so that modal will close
// but unless serverHealth changes, Next button will be disabled
};

const validateFileType = (fileName: string) => {
const fileExtension = fileName.split(".").pop();
if (fileExtension) {
Expand All @@ -134,17 +131,17 @@ const ConversionForm = ({

// TODO: use conversion template data to render the form
console.log("conversion form data", conversionProcessingData);
const readyToConvert = fileToConvert && engineSelected;
const readyToConvert = fileToConvert && engineSelected && serverHealth;
const conversionForm = (
<div className={classNames(styles.container, theme.lightTheme)}>
{serverDown ? (
{serverDown && (
<ConversionServerCheckModal
closeModal={closeServerCheckModal}
/>
) : null}
)}
{fileTypeErrorModalOpen && (
<ConversionFileErrorModal
closeModal={toggleModal}
closeModal={toggleFileTypeModal}
engineType={conversionProcessingData.engineType}
/>
)}
Expand Down

0 comments on commit 2394786

Please sign in to comment.