-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
73 changed files
with
3,210 additions
and
376 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 5 additions & 4 deletions
9
apps/platform/src/modules/advanced-config/advanced-config-entry.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
...ponent-config/config-item-render/default-feature-selection/feature-selection-only-one.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import { useDeepCompareEffect } from 'ahooks'; | ||
import { Select } from 'antd'; | ||
import { uniqBy } from 'lodash'; | ||
import { parse } from 'query-string'; | ||
import { useState } from 'react'; | ||
import { useLocation } from 'umi'; | ||
|
||
import { getGraphNodeOutput } from '@/services/secretpad/GraphController'; | ||
import { getProjectDatatable } from '@/services/secretpad/ProjectController'; | ||
|
||
import type { TableInfoType } from './type'; | ||
|
||
export interface IProps { | ||
/** 上游的输出表 */ | ||
tableKeys: TableInfoType[]; | ||
/** 上游输入的样本表 */ | ||
fromTableKey?: TableInfoType; | ||
onChange?: (values: string[]) => void; | ||
value?: string[]; | ||
} | ||
|
||
export const SingleTableFeatureSelection = (props: IProps) => { | ||
const { tableKeys: tables, fromTableKey: fromTable, value = [], onChange } = props; | ||
const [colsOptions, setCols] = useState<{ value: string; label: string }[]>([]); | ||
const { search } = useLocation(); | ||
|
||
const { projectId, dagId } = parse(search) as { projectId: string; dagId: string }; | ||
|
||
useDeepCompareEffect(() => { | ||
const getSchema = async () => { | ||
const tableFields: { colName: string; colType: string }[] = []; | ||
// 利用最上游输入的样本表 fromTable 和 上游的输出表(tables) 来进行获取特征 | ||
const schemaArr = fromTable ? [fromTable, ...tables] : tables; | ||
await Promise.all( | ||
schemaArr.map(async (s) => { | ||
const { datatableId, nodeId, graphNodeId } = s; | ||
|
||
if (!nodeId && graphNodeId) { | ||
const { data } = await getGraphNodeOutput({ | ||
projectId, | ||
graphId: dagId, | ||
graphNodeId, | ||
outputId: datatableId, | ||
}); | ||
|
||
if (data?.meta?.rows?.length) { | ||
data.meta.rows.forEach( | ||
({ fieldTypes, fields }: { fieldTypes: string; fields: string }) => { | ||
if (fieldTypes && fields) { | ||
const fieldList = fields.split(','); | ||
const fieldTypeList = fieldTypes.split(','); | ||
tableFields.push( | ||
...fieldList.map((f, i) => ({ | ||
colName: f, | ||
colType: fieldTypeList[i], | ||
})), | ||
); | ||
} | ||
}, | ||
); | ||
} | ||
} else { | ||
const { data } = await getProjectDatatable({ | ||
datatableId, | ||
nodeId, | ||
projectId, | ||
type: 'CSV', | ||
}); | ||
if (!data) return; | ||
const { configs } = data; | ||
configs.map((c) => { | ||
tableFields.push({ colName: c.colName, colType: c.colType }); | ||
}); | ||
} | ||
}), | ||
); | ||
const selectOptions = tableFields.map( | ||
(option: { colName: string; colType: string }) => ({ | ||
value: option.colName, | ||
label: option.colName, | ||
key: `${option.colName}_${option.colType}`, | ||
}), | ||
); | ||
const cols = uniqBy(selectOptions, 'key'); | ||
setCols(cols); | ||
}; | ||
getSchema(); | ||
}, [fromTable, tables]); | ||
|
||
return ( | ||
<Select | ||
maxCount={1} | ||
mode="multiple" | ||
value={value} | ||
onChange={onChange} | ||
options={colsOptions} | ||
showSearch | ||
filterOption={(input: string, option?: { label: string; value: string }) => | ||
(option?.label ?? '').toLowerCase().includes(input.toLowerCase()) | ||
} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
...form/src/modules/component-config/config-item-render/default-model-selection-template.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import { parse } from 'query-string'; | ||
import { useState, useEffect } from 'react'; | ||
import { Form, Select } from 'antd'; | ||
|
||
import type { RenderProp } from './config-render-protocol'; | ||
|
||
import { modelPackPage } from '@/services/secretpad/ModelManagementController'; | ||
import styles from '../index.less'; | ||
|
||
export const DefaultModelSelect: React.FC<RenderProp<string>> = (config) => { | ||
const { onChange, value, defaultVal, node, translation } = config; | ||
|
||
const [modelList, setModelList] = useState< | ||
{ | ||
modelName: string; | ||
modelId: string; | ||
}[] | ||
>([]); | ||
|
||
useEffect(() => { | ||
const getModelList = async () => { | ||
const { search } = window.location; | ||
const { projectId } = parse(search) as { projectId: string }; | ||
|
||
const { data, status } = await modelPackPage({ | ||
projectId: projectId, | ||
page: 1, | ||
size: 1000, | ||
}); | ||
if (status && status.code === 0 && data) { | ||
const modelList = (data?.modelPacks || []).map((item) => ({ | ||
modelName: item.modelName!, | ||
modelId: item.modelId!, | ||
})); | ||
setModelList(modelList); | ||
} else { | ||
setModelList([]); | ||
} | ||
}; | ||
getModelList(); | ||
}, []); | ||
|
||
return ( | ||
<Form.Item noStyle> | ||
<Form.Item | ||
label={ | ||
<div className={styles.configItemLabel}> | ||
{translation[node.name] || node.name} | ||
</div> | ||
} | ||
name={ | ||
node.prefixes && node.prefixes.length > 0 | ||
? node.prefixes.join('/') + '/' + node.name | ||
: node.name | ||
} | ||
messageVariables={{ label: translation[node.name] || node.name }} | ||
tooltip={ | ||
node.docString ? translation[node.docString] || node.docString : undefined | ||
} | ||
rules={[ | ||
{ | ||
required: node.isRequired, | ||
}, | ||
]} | ||
initialValue={defaultVal} | ||
colon={false} | ||
> | ||
<Select | ||
value={value} | ||
onChange={(val) => { | ||
onChange(val); | ||
}} | ||
showSearch | ||
filterOption={(input: string, option?: { label: string; value: string }) => | ||
(option?.label ?? '').toLowerCase().includes(input.toLowerCase()) | ||
} | ||
options={modelList.map((item) => ({ | ||
label: item.modelName, | ||
value: item.modelId, | ||
}))} | ||
></Select> | ||
</Form.Item> | ||
</Form.Item> | ||
); | ||
}; |
Oops, something went wrong.