Skip to content
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

feat: support more date type in studio @common #28

Merged
merged 1 commit into from
Oct 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion app/assets/config/locale/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,10 @@
"defineFields": "Define Properties",
"setTTL": "Set TTL",
"uniqProperty": "Property name cannot be duplicated",
"timestampFormat": "Supported data inserting methods: <br />1. call function now() <br />2. Time string, for example: '2019-10-01 10:00:00' <br />3. Input the timestamp directly, namely the number of seconds from 1970-01-01 00:00:00",
"timestampFormat": "Supported data inserting methods: <br />1. call function now() <br />2. call function timestamp(), for example: timestamp('2021-07-05T06:18:43.984000') <br />3. Input the timestamp directly, namely the number of seconds from 1970-01-01 00:00:00",
"dateFormat": "Supported data inserting methods: <br />Call function date(), for example: date('2021-03-17')",
"timeFormat": "Supported data inserting methods: <br />Call function time(), for example: time('17:53:59')",
"datetimeFormat": "Supported data inserting methods: <br />Call function datetime(), for example: datetime('2021-03-17T17:53:59')",
"cancelOperation": "Do you want to close this panel",
"cancelPropmt": "If you close the panel, the configuration will be deleted automatically. Are you sure that you want to close the panel?",
"fieldDisabled": "A TTL configuration is set for this property, so it cannot be edited. If you want to edit this property, delete the TTL configuration.",
Expand Down
5 changes: 4 additions & 1 deletion app/assets/config/locale/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,10 @@
"defineFields": "定义属性",
"setTTL": "设置TTL",
"uniqProperty": "属性名称不允许重名",
"timestampFormat": "时间类型支持插入方式: <br />1. 调用函数 now() <br />2. 时间字符串,例如:'2019-10-01 10:00:00' <br />3. 直接输入时间戳,即从 1970-01-01 00:00:00 开始的秒数",
"timestampFormat": "时间类型支持插入方式: <br />1. 调用函数 now() <br />2. 调用函数 timestamp(),例如:timestamp('2021-07-05T06:18:43.984000') <br />3. 直接输入时间戳,即从 1970-01-01 00:00:00 开始的秒数",
"dateFormat": "日期类型支持插入方式: <br /> 调用函数 date(),例如:date('2021-03-17')",
"timeFormat": "时间类型支持插入方式: <br /> 调用函数 time(),例如time('17:53:59')",
"datetimeFormat": "日期时间类型支持插入方式: <br /> 调用函数 datetime(),例如:datetime('2021-03-17T17:53:59')",
"cancelOperation": "是否取消配置并关闭面板",
"cancelPropmt": "关闭面板将删除所有属性,是否继续?",
"fieldDisabled": "该属性被 ttl_col 引用,不支持更改操作,如要更改,请先更新 ttl",
Expand Down
14 changes: 8 additions & 6 deletions app/assets/modules/Import/Tasks/ConfigEdge/Edge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { connect } from 'react-redux';

import CSVPreviewLink from '#assets/components/CSVPreviewLink';
import { IDispatch, IRootState } from '#assets/store';
import { dataType } from '#assets/utils/constant';

import './Edge.less';

Expand Down Expand Up @@ -114,12 +115,13 @@ class Edge extends React.Component<IProps> {
disabled={record.name === 'srcId' || record.name === 'dstId'}
onChange={type => this.handleChangeEdgeType(record, type)}
>
<Option value={'int'}>{'int'}</Option>
<Option value={'string'}>{'string'}</Option>
<Option value={'bool'}>{'bool'}</Option>
<Option value={'float'}>{'float'}</Option>
<Option value={'double'}>{'double'}</Option>
<Option value={'timestamp'}>{'timestamp'}</Option>
{dataType.map(item => {
return (
<Option value={item.value} key={item.value}>
{item.label}
</Option>
);
})}
</Select>
),
},
Expand Down
14 changes: 8 additions & 6 deletions app/assets/modules/Import/Tasks/ConfigVertex/Tag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { connect } from 'react-redux';

import CSVPreviewLink from '#assets/components/CSVPreviewLink';
import { IDispatch, IRootState } from '#assets/store';
import { dataType } from '#assets/utils/constant';

import './Tag.less';

Expand Down Expand Up @@ -138,12 +139,13 @@ class Tag extends React.Component<IProps> {
value={value}
onChange={type => this.handleChangeTagType(record, tag, type)}
>
<Option value={'int'}>{'int'}</Option>
<Option value={'string'}>{'string'}</Option>
<Option value={'bool'}>{'bool'}</Option>
<Option value={'float'}>{'float'}</Option>
<Option value={'double'}>{'double'}</Option>
<Option value={'timestamp'}>{'timestamp'}</Option>
{dataType.map(item => {
return (
<Option value={item.value} key={item.value}>
{item.label}
</Option>
);
})}
</Select>
),
},
Expand Down
8 changes: 6 additions & 2 deletions app/assets/modules/Schema/Edge/Create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,15 @@ class CreateEdge extends React.Component<IProps, IState> {
</Col>
<Col span={5}>
<Form.Item {...itemLayout}>
{fields && fields[k] && fields[k].type === 'timestamp' ? (
{fields &&
fields[k] &&
['date', 'time', 'datetime', 'timestamp'].includes(
fields[k].type,
) ? (
<Popover
trigger="focus"
placement="right"
content={intl.getHTML('schema.timestampFormat')}
content={intl.getHTML(`schema.${fields[k].type}Format`)}
>
{getFieldDecorator(`fields[${k}].value`, {
initialValue: '',
Expand Down
2 changes: 1 addition & 1 deletion app/assets/modules/Schema/Edge/Edit.less
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
}

.ant-table-row {
td input {
td input:not(.ant-checkbox-input) {
width: 60%;
min-width: 200px;
}
Expand Down
6 changes: 4 additions & 2 deletions app/assets/modules/Schema/Edge/Edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -521,11 +521,13 @@ class EditEdge extends React.Component<IProps, IState> {
align: 'center' as const,
render: (record, row, index) => {
if (editRow === index) {
return row.type === 'timestamp' ? (
return ['date', 'time', 'datetime', 'timestamp'].includes(
row.type,
) ? (
<Popover
trigger="focus"
placement="right"
content={intl.getHTML('schema.timestampFormat')}
content={intl.getHTML(`schema.${row.type}Format`)}
>
<Input
value={editField!.value}
Expand Down
8 changes: 6 additions & 2 deletions app/assets/modules/Schema/Tag/Create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,15 @@ class CreateTag extends React.Component<IProps, IState> {
</Col>
<Col span={5}>
<Form.Item {...itemLayout}>
{fields && fields[k] && fields[k].type === 'timestamp' ? (
{fields &&
fields[k] &&
['date', 'time', 'datetime', 'timestamp'].includes(
fields[k].type,
) ? (
<Popover
trigger="focus"
placement="right"
content={intl.getHTML('schema.timestampFormat')}
content={intl.getHTML(`schema.${fields[k].type}Format`)}
>
{getFieldDecorator(`fields[${k}].value`, {
initialValue: '',
Expand Down
2 changes: 1 addition & 1 deletion app/assets/modules/Schema/Tag/Edit.less
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
}

.ant-table-row {
td input {
td input:not(.ant-checkbox-input) {
width: 60%;
min-width: 200px;
}
Expand Down
6 changes: 4 additions & 2 deletions app/assets/modules/Schema/Tag/Edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -520,11 +520,13 @@ class EditTag extends React.Component<IProps, IState> {
align: 'center' as const,
render: (record, row, index) => {
if (editRow === index) {
return row.type === 'timestamp' ? (
return ['date', 'time', 'datetime', 'timestamp'].includes(
row.type,
) ? (
<Popover
trigger="focus"
placement="right"
content={intl.getHTML('schema.timestampFormat')}
content={intl.getHTML(`schema.${row.type}Format`)}
>
<Input
value={editField!.value}
Expand Down
44 changes: 36 additions & 8 deletions app/assets/utils/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,6 @@ export const enumOfCompare = {
};

export const dataType = [
{
value: 'double',
label: 'double',
},
{
value: 'int',
label: 'int',
Expand All @@ -108,14 +104,46 @@ export const dataType = [
value: 'string',
label: 'string',
},
{
value: 'timestamp',
label: 'timestamp',
},
{
value: 'fixed_string',
label: 'fixed_string',
},
{
value: 'double',
label: 'double',
},
{
value: 'int32',
label: 'int32',
},
{
value: 'int16',
label: 'int16',
},
{
value: 'int8',
label: 'int8',
},
{
value: 'float',
label: 'float',
},
{
value: 'date',
label: 'date',
},
{
value: 'time',
label: 'time',
},
{
value: 'datetime',
label: 'datetime',
},
{
value: 'timestamp',
label: 'timestamp',
},
];

export const RELATION_OPERATORS = [
Expand Down