mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-10-09 16:02:38 +00:00
feat: remove res1 wrapping
This commit is contained in:
@@ -9,17 +9,13 @@
|
||||
let resultKind: 'json' | 'table-col' | 'table-row' | 'png' | 'file' | 'jpeg' | 'gif' | undefined =
|
||||
inferResultKind(result)
|
||||
|
||||
function isArray(obj: any) {
|
||||
return Object.prototype.toString.call(obj) === '[object Array]'
|
||||
}
|
||||
|
||||
function isRectangularArray(obj: any) {
|
||||
if (!isArray(obj) || obj.length == 0) {
|
||||
if (!Array.isArray(obj) || obj.length == 0) {
|
||||
return false
|
||||
}
|
||||
if (
|
||||
!Object.values(obj)
|
||||
.map(isArray)
|
||||
.map(Array.isArray)
|
||||
.reduce((a, b) => a && b)
|
||||
) {
|
||||
return false
|
||||
@@ -39,9 +35,9 @@
|
||||
if (result) {
|
||||
try {
|
||||
let keys = Object.keys(result)
|
||||
if (keys.length == 1 && isRectangularArray(result[keys[0]])) {
|
||||
if (isRectangularArray(result)) {
|
||||
return 'table-row'
|
||||
} else if (keys.map((k) => isArray(result[k])).reduce((a, b) => a && b)) {
|
||||
} else if (keys.map((k) => Array.isArray(result[k])).reduce((a, b) => a && b)) {
|
||||
return 'table-col'
|
||||
} else if (keys.length == 1 && keys[0] == 'png') {
|
||||
return 'png'
|
||||
@@ -57,7 +53,7 @@
|
||||
</script>
|
||||
|
||||
{#if result}
|
||||
{#if Object.keys(result).length > 0}<div>
|
||||
{#if typeof result == 'object' && Object.keys(result).length > 0}<div>
|
||||
The result keys are: <b>{Object.keys(result).join(', ')}</b>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
@@ -36,7 +36,7 @@ export function flowToMode(flow: Flow | any, mode: FlowMode): Flow {
|
||||
const oldModules = newFlow.value.modules.slice(1)
|
||||
|
||||
if (triggerModule) {
|
||||
triggerModule.stop_after_if_expr = 'result.res1.length == 0'
|
||||
triggerModule.stop_after_if_expr = 'result.length == 0'
|
||||
triggerModule.skip_if_stopped = true
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ export function flowToMode(flow: Flow | any, mode: FlowMode): Flow {
|
||||
input_transform: oldModules[0].input_transform,
|
||||
value: {
|
||||
type: 'forloopflow',
|
||||
iterator: { type: 'javascript', expr: 'result.res1' },
|
||||
iterator: { type: 'javascript', expr: 'result' },
|
||||
value: {
|
||||
modules: oldModules
|
||||
},
|
||||
@@ -231,10 +231,10 @@ export async function runFlowPreview(args: Record<string, any>, flow: Flow) {
|
||||
})
|
||||
}
|
||||
function computeFlowInputPull(previewResult: any | undefined, flowInputAsObject: any) {
|
||||
const iteratorValues = (previewResult?.res1 && Array.isArray(previewResult.res1)) ?
|
||||
const iteratorValues = (previewResult && Array.isArray(previewResult)) ?
|
||||
{
|
||||
_value: previewResult.res1[0],
|
||||
_index: `The current index of the iteration as a number (here from 0 to ${previewResult.res1.length - 1})`
|
||||
_value: previewResult[0],
|
||||
_index: `The current index of the iteration as a number (here from 0 to ${previewResult.length - 1})`
|
||||
} : {
|
||||
_value: 'The current value of the iteration as an object',
|
||||
_index: 'The current index of the iteration as a number'
|
||||
|
||||
Reference in New Issue
Block a user