|
|
@@ -26,7 +26,7 @@ class Table extends Component {
|
|
|
newColType: 'type',
|
|
|
types: ['ID', 'String', 'Int', 'Float', 'Boolean', 'DateTime'],
|
|
|
descriptions: ['description', 'key', 'non-null', 'non-null-list', 'list'],
|
|
|
- characterTips: false
|
|
|
+ characterTips: false,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -288,22 +288,22 @@ class UpdateTableButton extends Component {
|
|
|
super(props);
|
|
|
this.state = {
|
|
|
originTableName: props.currentTable,
|
|
|
- schemaCheck:false
|
|
|
+ schemaCheck: ''
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
- showConfirm = (schemaName, schemaID) => {
|
|
|
+ showConfirm = (schemaName, schemaID, data) => {
|
|
|
let _this = this;
|
|
|
|
|
|
if (this.props.add !== 'add') {
|
|
|
- this.props.history.push({
|
|
|
- pathname: `/graphql-service/my-create/${schemaName}`,
|
|
|
- state: {
|
|
|
- schemaName,
|
|
|
- schemaID
|
|
|
- }
|
|
|
- });
|
|
|
+ if(data.update_schema.schemaState === 'ok')
|
|
|
+ this.props.history.push({
|
|
|
+ pathname: `/graphql-service/my-create/${schemaName}`,
|
|
|
+ state: {
|
|
|
+ schemaName,
|
|
|
+ schemaID
|
|
|
+ }
|
|
|
+ });
|
|
|
} else {
|
|
|
confirm({
|
|
|
title: '添加成功',
|
|
|
@@ -324,7 +324,7 @@ class UpdateTableButton extends Component {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- checkSchema = (update_schema,schemaID,varobj,schemaCols) => {
|
|
|
+ checkSchema = (update_schema, schemaID, varobj, schemaCols) => {
|
|
|
update_schema({
|
|
|
variables: {
|
|
|
...varobj,
|
|
|
@@ -337,15 +337,25 @@ class UpdateTableButton extends Component {
|
|
|
.then((res) => {
|
|
|
console.log('check schema res', res);
|
|
|
if (res.data !== '') {
|
|
|
+ update_schema({
|
|
|
+ variables: {
|
|
|
+ ...varobj,
|
|
|
+ schemaData: JSON.stringify(schemaCols),
|
|
|
+ schemaState: 'ok',
|
|
|
+ }
|
|
|
+ });
|
|
|
_this.setState({
|
|
|
- schemaCheck:"checked-success",
|
|
|
+ schemaCheck: '',
|
|
|
});
|
|
|
}
|
|
|
})
|
|
|
.catch((err) => {
|
|
|
- console.log('err',err);
|
|
|
- console.log('err.response',err.response);
|
|
|
- console.log('err.response.data',err.response.data);
|
|
|
+ // console.log('err',err);
|
|
|
+ // console.log('err.response',err.response);
|
|
|
+ _this.setState({
|
|
|
+ schemaCheck: err.response.data,
|
|
|
+ });
|
|
|
+ console.log('err.response.data', err.response.data);
|
|
|
});
|
|
|
};
|
|
|
|
|
|
@@ -378,7 +388,7 @@ class UpdateTableButton extends Component {
|
|
|
return (
|
|
|
<Mutation
|
|
|
mutation={gql(UPDATE_SCHEMA)}
|
|
|
- onCompleted={() => this.showConfirm(schemaName, schemaID)}
|
|
|
+ onCompleted={(data) => this.showConfirm(schemaName, schemaID, data)}
|
|
|
refetchQueries={[{query: gql(SHOW_TABLE), variables: {schema_id: schemaID}}]}
|
|
|
>
|
|
|
|
|
|
@@ -432,14 +442,23 @@ class UpdateTableButton extends Component {
|
|
|
}
|
|
|
|
|
|
return (
|
|
|
- <div style={{display: 'inline-block'}}>
|
|
|
- <Button type="primary" onClick={() => {
|
|
|
- this.checkSchema(update_schema,schemaID,varobj,schemaCols);
|
|
|
- this.props.showTablePagination(this.props.page, this.props.pageSize, schemaCols);
|
|
|
- }}>
|
|
|
- <FormattedMessage id="save"/>
|
|
|
- </Button>
|
|
|
+ <div>
|
|
|
+ <div style={{display: 'inline-block'}}>
|
|
|
+ <Button type="primary" onClick={() => {
|
|
|
+ this.checkSchema(update_schema, schemaID, varobj, schemaCols);
|
|
|
+ this.props.showTablePagination(this.props.page, this.props.pageSize, schemaCols);
|
|
|
+ }}>
|
|
|
+ <FormattedMessage id="save"/>
|
|
|
+ </Button>
|
|
|
+ </div>
|
|
|
+ {
|
|
|
+ this.state.schemaCheck !== '' ?
|
|
|
+ <span> failed, cause '{this.state.schemaCheck}'</span>
|
|
|
+ :
|
|
|
+ ''
|
|
|
+ }
|
|
|
</div>
|
|
|
+
|
|
|
)
|
|
|
}}
|
|
|
</Mutation>
|