Merge branch 'main' of github.com:jmwright/cadhub into main
This commit is contained in:
@@ -12,7 +12,7 @@ export const runCQ = async ({
|
|||||||
{
|
{
|
||||||
file: JSON.stringify(parameters),
|
file: JSON.stringify(parameters),
|
||||||
fileName: 'params.json',
|
fileName: 'params.json',
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
'a' + nanoid() // 'a' ensure nothing funny happens if it start with a bad character like "-", maybe I should pick a safer id generator :shrug:
|
'a' + nanoid() // 'a' ensure nothing funny happens if it start with a bad character like "-", maybe I should pick a safer id generator :shrug:
|
||||||
)
|
)
|
||||||
@@ -36,12 +36,12 @@ export const runCQ = async ({
|
|||||||
console.log('command', mainCommand)
|
console.log('command', mainCommand)
|
||||||
let consoleMessage = ''
|
let consoleMessage = ''
|
||||||
try {
|
try {
|
||||||
;([consoleMessage] = await Promise.all([
|
;[consoleMessage] = await Promise.all([
|
||||||
runCommand(mainCommand, 30000),
|
runCommand(mainCommand, 30000),
|
||||||
runCommand(customizerCommand, 30000)
|
runCommand(customizerCommand, 30000),
|
||||||
]))
|
])
|
||||||
const params = JSON.parse(
|
const params = JSON.parse(
|
||||||
await readFile(customizerPath, { encoding: 'ascii'})
|
await readFile(customizerPath, { encoding: 'ascii' })
|
||||||
)
|
)
|
||||||
await writeFiles(
|
await writeFiles(
|
||||||
[
|
[
|
||||||
@@ -63,6 +63,6 @@ export const runCQ = async ({
|
|||||||
)
|
)
|
||||||
return { consoleMessage, fullPath }
|
return { consoleMessage, fullPath }
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return { error: consoleMessage, fullPath }
|
return { error: consoleMessage || error, fullPath }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ export const render: DefaultKernelExport['render'] = async ({
|
|||||||
data: await stlToGeometry(window.URL.createObjectURL(blob)),
|
data: await stlToGeometry(window.URL.createObjectURL(blob)),
|
||||||
consoleMessage,
|
consoleMessage,
|
||||||
date: new Date(),
|
date: new Date(),
|
||||||
customizerParams: CadQueryToCadhubParams([customizerParams]), // TODO, should already be an array and not need to be wrapped in one.
|
customizerParams: CadQueryToCadhubParams(customizerParams),
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return createUnhealthyResponse(new Date())
|
return createUnhealthyResponse(new Date())
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ import { CadhubParams } from 'src/components/Customizer/customizerConverter'
|
|||||||
|
|
||||||
interface CadQueryParamsBase {
|
interface CadQueryParamsBase {
|
||||||
name: string
|
name: string
|
||||||
initial: number | string
|
initial: number | string | boolean
|
||||||
type?: 'number'
|
type?: 'number' | 'string' | 'boolean'
|
||||||
}
|
}
|
||||||
|
|
||||||
interface CadQueryNumberParam extends CadQueryParamsBase {
|
interface CadQueryNumberParam extends CadQueryParamsBase {
|
||||||
@@ -12,13 +12,19 @@ interface CadQueryNumberParam extends CadQueryParamsBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface CadQueryStringParam extends CadQueryParamsBase {
|
interface CadQueryStringParam extends CadQueryParamsBase {
|
||||||
|
type: 'string'
|
||||||
initial: string
|
initial: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface CadQueryBooleanParam extends CadQueryParamsBase {
|
||||||
|
type: 'boolean'
|
||||||
|
initial: boolean
|
||||||
|
}
|
||||||
|
|
||||||
export type CadQueryStringParams =
|
export type CadQueryStringParams =
|
||||||
| CadQueryNumberParam
|
| CadQueryNumberParam
|
||||||
| CadQueryStringParam
|
| CadQueryStringParam
|
||||||
|
| CadQueryBooleanParam
|
||||||
|
|
||||||
export function CadQueryToCadhubParams(
|
export function CadQueryToCadhubParams(
|
||||||
input: CadQueryStringParams[]
|
input: CadQueryStringParams[]
|
||||||
@@ -29,21 +35,29 @@ export function CadQueryToCadhubParams(
|
|||||||
caption: '',
|
caption: '',
|
||||||
name: param.name,
|
name: param.name,
|
||||||
}
|
}
|
||||||
if(param.type === 'number') {
|
switch (param.type) {
|
||||||
return {
|
case 'number':
|
||||||
type: 'number',
|
return {
|
||||||
input: 'default-number',
|
type: 'number',
|
||||||
...common,
|
input: 'default-number',
|
||||||
initial: Number(param.initial),
|
...common,
|
||||||
}
|
initial: param.initial,
|
||||||
}
|
}
|
||||||
return {
|
case 'string':
|
||||||
type: 'string',
|
return {
|
||||||
input: 'default-string',
|
type: 'string',
|
||||||
...common,
|
input: 'default-string',
|
||||||
initial: String(param.initial),
|
...common,
|
||||||
|
initial: param.initial,
|
||||||
|
}
|
||||||
|
case 'boolean':
|
||||||
|
return {
|
||||||
|
type: 'boolean',
|
||||||
|
input: 'default-boolean',
|
||||||
|
...common,
|
||||||
|
initial: param.initial,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.filter((a) => a)
|
.filter((a) => a)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user