-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: fix empty props in template import #415
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,9 @@ const TemplateModal = (props: IProps) => { | |
const parseContent = yaml.load(content); | ||
if(typeof parseContent === 'object') { | ||
const connection = parseContent.clientSettings?.connection || {}; | ||
if(connection.address.startsWith('http')) { | ||
throw new Error(intl.get('import.noHttp')); | ||
} | ||
if(connection.address !== host) { | ||
throw new Error(intl.get('import.templateMatchError', { type: 'address' })); | ||
} | ||
|
@@ -50,6 +53,17 @@ const TemplateModal = (props: IProps) => { | |
throw new Error(intl.get('import.fileNotExist', { name: file.path })); | ||
} | ||
}); | ||
// empty props in yaml will converted to null, but its required in nebula-importer | ||
parseContent.files.forEach(file => { | ||
if(file.schema.edge) { | ||
file.schema.edge.props = file.schema.edge?.props || []; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. file.schema.edge.props ||= []; |
||
} | ||
if(file.schema.vertex) { | ||
file.schema.vertex?.tags.forEach(tag => { | ||
tag.props = tag.props || []; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
}); | ||
} | ||
}); | ||
setConfig(JSON.stringify(parseContent, null, 2)); | ||
form.setFieldsValue({ | ||
name: `task-${Date.now()}`, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,28 @@ | ||
@import '~@app/common.less'; | ||
.nebulaStats { | ||
.operations { | ||
.row { | ||
margin: 20px 0 17px; | ||
font-size: 14px; | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
} | ||
.operations { | ||
display: flex; | ||
align-items: center; | ||
font-size: 14px; | ||
:global(.ant-btn) { | ||
width: 110px; | ||
} | ||
.label, .tip{ | ||
margin-left: 30px; | ||
color: @darkGray; | ||
} | ||
.label::after { | ||
content: ": "; | ||
padding-right: 5px; | ||
} | ||
} | ||
.label, .tip{ | ||
margin-left: 30px; | ||
color: @darkGray; | ||
} | ||
.label::after { | ||
content: ": "; | ||
padding-right: 5px; | ||
} | ||
.totalItem { | ||
display: inline-block; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,17 @@ const SpaceStats = () => { | |
const timer = useRef<NodeJS.Timeout | null>(null); | ||
const { intl } = useI18n(); | ||
const { schema: { getJobStatus, submitStats, getStats, currentSpace } } = useStore(); | ||
const [data, setData] = useState([]); | ||
const [data, setData] = useState<{ | ||
list: { | ||
Type: string, | ||
Name: string, | ||
Count: number, | ||
}[], | ||
total: { | ||
vertices: number, | ||
edges: number, | ||
} | null | ||
} | null>(null); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. const [data, setData] = useState<{
list: { Type: string; Name: string; Count: number }[];
total?: { vertices: number; edges: number };
}>({ list: [], total: undefined }); |
||
const [updateTime, setUpdateTime] = useState(''); | ||
const [jobId, setJobId] = useState<any>(null); | ||
const [loading, setLoading] = useState(false); | ||
|
@@ -44,13 +54,30 @@ const SpaceStats = () => { | |
const initData = () => { | ||
setJobId(null); | ||
setUpdateTime(''); | ||
setData([]); | ||
setData({ | ||
list: [], | ||
total: null | ||
}); | ||
}; | ||
|
||
const getData = async () => { | ||
const { code, data } = await getStats(); | ||
if (code === 0) { | ||
setData(data.tables); | ||
const _data = data.tables.reduce((prev, cur) => { | ||
if (cur.Type === 'Space') { | ||
if(!prev.total) { | ||
prev.total = { | ||
vertex: 0, | ||
edge: 0, | ||
}; | ||
} | ||
prev.total[cur.Name] = cur.Count; | ||
} else { | ||
prev.list.push(cur); | ||
} | ||
return prev; | ||
}, { list: [], total: null }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. const nextData = data.tables.reduce((prev, cur) => {
if (cur.Type === 'Space') {
prev.total ||= { vertex: 0, edge: 0 };
prev.total[cur.Name] = cur.Count;
} else {
prev.list.push(cur);
}
return prev;
}, { list: [], total: undefined } as typeof data }); |
||
setData(_data); | ||
} | ||
}; | ||
|
||
|
@@ -99,25 +126,37 @@ const SpaceStats = () => { | |
const showTime = updateTime && jobId == null && !loading; | ||
return ( | ||
<div className={styles.nebulaStats}> | ||
<div className={styles.operations}> | ||
<Button | ||
type="primary" | ||
onClick={handleSubmitStats} | ||
loading={loading || jobId !== null} | ||
> | ||
{intl.get(updateTime ? 'schema.refresh' : 'schema.startStat')} | ||
</Button> | ||
{showTime ? <> | ||
<span className={styles.label}>{intl.get('schema.lastRefreshTime')}</span> | ||
<span> | ||
{dayjs(updateTime).format('YYYY-MM-DD HH:mm:ss')} | ||
</span> | ||
</> : <span className={styles.tip}> | ||
{intl.get('schema.statTip')} | ||
</span>} | ||
<div className={styles.row}> | ||
<div className={styles.operations}> | ||
<Button | ||
type="primary" | ||
onClick={handleSubmitStats} | ||
loading={loading || jobId !== null} | ||
> | ||
{intl.get(updateTime ? 'schema.refresh' : 'schema.startStat')} | ||
</Button> | ||
{showTime ? <> | ||
<span className={styles.label}>{intl.get('schema.lastRefreshTime')}</span> | ||
<span> | ||
{dayjs(updateTime).format('YYYY-MM-DD HH:mm:ss')} | ||
</span> | ||
</> : <span className={styles.tip}> | ||
{intl.get('schema.statTip')} | ||
</span>} | ||
</div> | ||
{data?.total && <div className={styles.totalCount}> | ||
<div className={styles.totalItem}> | ||
<span className={styles.label}>{intl.get('schema.totalVertices')}</span> | ||
<span>{data.total.vertices}</span> | ||
</div> | ||
<div className={styles.totalItem}> | ||
<span className={styles.label}>{intl.get('schema.totalEdges')}</span> | ||
<span>{data.total.edges}</span> | ||
</div> | ||
</div>} | ||
</div> | ||
<Table | ||
dataSource={data} | ||
dataSource={data?.list || []} | ||
columns={columns} | ||
rowKey="Name" | ||
locale={{ emptyText: <EmptyTableTip text={intl.get('empty.stats')} tip={intl.get('empty.statsTip')} /> }} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.