|
|
@@ -1,4 +1,5 @@
|
|
|
import React, {Component} from 'react';
|
|
|
+import axios from 'axios';
|
|
|
|
|
|
import {Layout, Select, Input, Icon, Button, notification, Spin, Modal} from 'antd';
|
|
|
import {UPDATE_SCHEMA, SHOW_SCHEMA, SHOW_TABLE} from "../../../../gql";
|
|
|
@@ -8,6 +9,7 @@ import {FormattedMessage} from 'react-intl';
|
|
|
import {Mutation, Query} from "react-apollo";
|
|
|
import {getCookie} from "../../../../cookie";
|
|
|
import {manageUsers} from "../../../../config";
|
|
|
+import {checkSchemaUrl} from '../../../../config';
|
|
|
|
|
|
const Option = Select.Option;
|
|
|
const {Content} = Layout;
|
|
|
@@ -285,7 +287,8 @@ class UpdateTableButton extends Component {
|
|
|
constructor(props) {
|
|
|
super(props);
|
|
|
this.state = {
|
|
|
- originTableName: props.currentTable
|
|
|
+ originTableName: props.currentTable,
|
|
|
+ schemaCheck:false
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -321,6 +324,31 @@ class UpdateTableButton extends Component {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+ checkSchema = (update_schema,schemaID,varobj,schemaCols) => {
|
|
|
+ update_schema({
|
|
|
+ variables: {
|
|
|
+ ...varobj,
|
|
|
+ schemaData: JSON.stringify(schemaCols)
|
|
|
+ }
|
|
|
+ });
|
|
|
+ let _this = this;
|
|
|
+
|
|
|
+ axios.get(`${checkSchemaUrl}?schema=${schemaID}`)
|
|
|
+ .then((res) => {
|
|
|
+ console.log('check schema res', res);
|
|
|
+ if (res.data !== '') {
|
|
|
+ _this.setState({
|
|
|
+ schemaCheck:"checked-success",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ console.log('err',err);
|
|
|
+ console.log('err.response',err.response);
|
|
|
+ console.log('err.response.data',err.response.data);
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
render() {
|
|
|
let schemaID = this.props.schemaID;
|
|
|
let schemaName = this.props.schemaName;
|
|
|
@@ -406,15 +434,10 @@ class UpdateTableButton extends Component {
|
|
|
return (
|
|
|
<div style={{display: 'inline-block'}}>
|
|
|
<Button type="primary" onClick={() => {
|
|
|
- update_schema({
|
|
|
- variables: {
|
|
|
- ...varobj,
|
|
|
- schemaData: JSON.stringify(schemaCols)
|
|
|
- }
|
|
|
- });
|
|
|
+ this.checkSchema(update_schema,schemaID,varobj,schemaCols);
|
|
|
this.props.showTablePagination(this.props.page, this.props.pageSize, schemaCols);
|
|
|
}}>
|
|
|
- save
|
|
|
+ <FormattedMessage id="save"/>
|
|
|
</Button>
|
|
|
</div>
|
|
|
)
|