mirror of
https://github.com/Lissy93/web-check.git
synced 2024-11-23 08:45:07 +01:00
Adds compatibility for skipped checks for server host reasons
This commit is contained in:
parent
dc651a7b1e
commit
7422d22538
@ -167,6 +167,9 @@ p {
|
|||||||
}
|
}
|
||||||
pre {
|
pre {
|
||||||
color: ${colors.danger};
|
color: ${colors.danger};
|
||||||
|
&.info {
|
||||||
|
color: ${colors.warning};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@ -202,7 +205,9 @@ const jobNames = [
|
|||||||
'sitemap',
|
'sitemap',
|
||||||
'hsts',
|
'hsts',
|
||||||
'security-txt',
|
'security-txt',
|
||||||
|
'social-tags',
|
||||||
'linked-pages',
|
'linked-pages',
|
||||||
|
'mail-server',
|
||||||
// 'whois',
|
// 'whois',
|
||||||
'features',
|
'features',
|
||||||
'carbon',
|
'carbon',
|
||||||
@ -360,7 +365,7 @@ const ProgressLoader = (props: { loadStatus: LoadingJob[], showModal: (err: Reac
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const showErrorModal = (name: string, state: LoadingState, timeTaken: number | undefined, error: string) => {
|
const showErrorModal = (name: string, state: LoadingState, timeTaken: number | undefined, error: string, isInfo?: boolean) => {
|
||||||
const errorContent = (
|
const errorContent = (
|
||||||
<ErrorModalContent>
|
<ErrorModalContent>
|
||||||
<Heading as="h3">Error Details for {name}</Heading>
|
<Heading as="h3">Error Details for {name}</Heading>
|
||||||
@ -368,7 +373,8 @@ const ProgressLoader = (props: { loadStatus: LoadingJob[], showModal: (err: Reac
|
|||||||
The {name} job failed with an {state} state after {timeTaken} ms.
|
The {name} job failed with an {state} state after {timeTaken} ms.
|
||||||
The server responded with the following error:
|
The server responded with the following error:
|
||||||
</p>
|
</p>
|
||||||
<pre>{error}</pre>
|
{ /* If isInfo == true, then add .info className to pre */}
|
||||||
|
<pre className={isInfo ? 'info' : 'error'}>{error}</pre>
|
||||||
</ErrorModalContent>
|
</ErrorModalContent>
|
||||||
);
|
);
|
||||||
props.showModal(errorContent);
|
props.showModal(errorContent);
|
||||||
@ -409,6 +415,7 @@ const ProgressLoader = (props: { loadStatus: LoadingJob[], showModal: (err: Reac
|
|||||||
<i>{(timeTaken && state !== 'loading') ? ` Took ${timeTaken} ms` : '' }</i>
|
<i>{(timeTaken && state !== 'loading') ? ` Took ${timeTaken} ms` : '' }</i>
|
||||||
{ (retry && state !== 'success' && state !== 'loading') && <FailedJobActionButton onClick={retry}>↻ Retry</FailedJobActionButton> }
|
{ (retry && state !== 'success' && state !== 'loading') && <FailedJobActionButton onClick={retry}>↻ Retry</FailedJobActionButton> }
|
||||||
{ (error && state === 'error') && <FailedJobActionButton onClick={() => showErrorModal(name, state, timeTaken, error)}>■ Show Error</FailedJobActionButton> }
|
{ (error && state === 'error') && <FailedJobActionButton onClick={() => showErrorModal(name, state, timeTaken, error)}>■ Show Error</FailedJobActionButton> }
|
||||||
|
{ (error && state === 'skipped') && <FailedJobActionButton onClick={() => showErrorModal(name, state, timeTaken, error, true)}>■ Show Reason</FailedJobActionButton> }
|
||||||
</li>
|
</li>
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
|
@ -38,21 +38,20 @@ const useMotherOfAllHooks = <ResultType = any>(params: UseIpAddressProps<ResultT
|
|||||||
const doTheFetch = () => {
|
const doTheFetch = () => {
|
||||||
return fetchRequest()
|
return fetchRequest()
|
||||||
.then((res: any) => {
|
.then((res: any) => {
|
||||||
if (!res) {
|
if (!res) { // No response :(
|
||||||
|
updateLoadingJobs(jobId, 'error', res.error || 'No response', reset);
|
||||||
|
} else if (res.error) { // Response returned an error message
|
||||||
updateLoadingJobs(jobId, 'error', res.error, reset);
|
updateLoadingJobs(jobId, 'error', res.error, reset);
|
||||||
throw new Error('No response');
|
} else if (res.skipped) { // Response returned a skipped message
|
||||||
}
|
updateLoadingJobs(jobId, 'skipped', res.skipped, reset);
|
||||||
if (res.error) {
|
} else { // Yay, everything went to plan :)
|
||||||
updateLoadingJobs(jobId, 'error', res.error, reset);
|
|
||||||
throw new Error(res.error);
|
|
||||||
}
|
|
||||||
// All went to plan, set results and mark as done
|
|
||||||
setResult(res);
|
setResult(res);
|
||||||
updateLoadingJobs(jobId, 'success', '', undefined, res);
|
updateLoadingJobs(jobId, 'success', '', undefined, res);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
// Something fucked up, log the error
|
// Something fucked up
|
||||||
updateLoadingJobs(jobId, 'error', err.error || err.message, reset);
|
updateLoadingJobs(jobId, 'error', err.error || err.message || 'Unknown error', reset);
|
||||||
throw err;
|
throw err;
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -69,6 +68,7 @@ const useMotherOfAllHooks = <ResultType = any>(params: UseIpAddressProps<ResultT
|
|||||||
pending: `Updating Data (${jobId})`,
|
pending: `Updating Data (${jobId})`,
|
||||||
success: `Completed (${jobId})`,
|
success: `Completed (${jobId})`,
|
||||||
error: `Failed to update (${jobId})`,
|
error: `Failed to update (${jobId})`,
|
||||||
|
skipped: `Skipped job (${jobId}), as no valid results for host`,
|
||||||
};
|
};
|
||||||
// Initiate fetch, and show progress toast
|
// Initiate fetch, and show progress toast
|
||||||
toast.promise(fetchyFetch, toastOptions).catch(() => {});
|
toast.promise(fetchyFetch, toastOptions).catch(() => {});
|
||||||
|
Loading…
Reference in New Issue
Block a user