Send console message with healthy render
This commit is contained in:
@@ -7,12 +7,12 @@ const IdeConsole = () => {
|
||||
<div className="p-8 border-2 m-2 overflow-y-auto">
|
||||
<div>
|
||||
{state.consoleMessages?.map(({ type, message }, index) => (
|
||||
<div
|
||||
<pre
|
||||
className={'font-mono ' + (type === 'error' ? 'text-red-500' : '')}
|
||||
key={message + index}
|
||||
>
|
||||
-> {message}
|
||||
</div>
|
||||
{message}
|
||||
</pre>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -124,8 +124,7 @@ const IdeViewer = () => {
|
||||
useEffect(() => {
|
||||
setImage(
|
||||
state.objectData?.type === 'png' &&
|
||||
state.objectData?.data &&
|
||||
window.URL.createObjectURL(state.objectData?.data)
|
||||
'data:image/png;base64,' + state.objectData?.data
|
||||
)
|
||||
setIsDragging(false)
|
||||
}, [state.objectData])
|
||||
|
||||
@@ -50,20 +50,20 @@ export const render = async ({ code, settings }) => {
|
||||
status: 'error',
|
||||
message: {
|
||||
type: 'error',
|
||||
message: cleanedErrorMessage,
|
||||
message: addDateToLog(cleanedErrorMessage),
|
||||
},
|
||||
}
|
||||
}
|
||||
const data = await response.blob()
|
||||
const data = await response.json()
|
||||
return {
|
||||
status: 'healthy',
|
||||
objectData: {
|
||||
type: 'png',
|
||||
data,
|
||||
data: data.imageBase64,
|
||||
},
|
||||
message: {
|
||||
type: 'message',
|
||||
message: 'successful render',
|
||||
message: addDateToLog(data.result),
|
||||
},
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -75,7 +75,7 @@ export const render = async ({ code, settings }) => {
|
||||
status: 'error',
|
||||
message: {
|
||||
type: 'error',
|
||||
message: 'network issue',
|
||||
message: addDateToLog('network issue'),
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -87,3 +87,8 @@ const openScad = {
|
||||
}
|
||||
|
||||
export default openScad
|
||||
|
||||
function addDateToLog(message) {
|
||||
return `-> ${new Date().toLocaleString()}
|
||||
${message}`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user