浏览代码

连接 部署

xy 7 年之前
父节点
当前提交
61a4159959

+ 12 - 4
src/app/common/deploy/tencent/APIPathCard.js

@@ -79,10 +79,10 @@ class APIPathCard extends Component {
         };
     };
 
-    ok = () => {
+    ok = (id) => {
         let {apiGWName, apiGWDesc, requestMethod} = this.state;
         let varObj = {
-            id: idGen('path'),
+            id,
             user_id: this.props.userID,
             apiGWGroup_id: this.props.groupID,
             deploy_id: this.props.deployID,
@@ -201,7 +201,11 @@ class APIPathCard extends Component {
                 {
                     manageUsers.includes(this.props.userID) ?
                         <div>
-                            <Button onClick={this.ok} type='primary'><FormattedMessage id="save"/></Button>
+                            <Button onClick={()=>{
+                                const id = idGen('path');
+                                this.ok(id);
+                                this.props.pass(id, 'path');
+                            }} type='primary'><FormattedMessage id="save"/></Button>
                             {
                                 this.state.showOK === true?
                                     <Icon type="check-circle" theme="twoTone" twoToneColor="#52c41a"/>
@@ -214,7 +218,11 @@ class APIPathCard extends Component {
                             ''
                             :
                             <div>
-                                <Button onClick={this.ok} type='primary'><FormattedMessage id="save"/></Button>
+                                <Button onClick={()=>{
+                                    const id = idGen('path');
+                                    this.ok(id);
+                                    this.props.pass(id, 'path');
+                                }} type='primary'><FormattedMessage id="save"/></Button>
                                 {
                                     this.state.showOK === true?
                                         <Icon type="check-circle" theme="twoTone" twoToneColor="#52c41a"/>

+ 35 - 15
src/app/common/deploy/tencent/TencentConfig.js

@@ -22,6 +22,7 @@ class TencentConfig extends Component {
             couldDeploy: false,
             deployIdPassToPath: '',
             groupIdPassToPath: '',
+            pathIdPassToConfig: '',
             currentStep: 0
         };
     }
@@ -48,24 +49,40 @@ class TencentConfig extends Component {
             this.setState({
                 deployIdPassToPath: value
             });
-        else
+        else if (kind === 'group')
             this.setState({
                 groupIdPassToPath: value
+            });
+        else {
+            this.setState({
+                pathIdPassToConfig: value
             })
+        }
     };
 
     deployFC = (schema, deploy, api, group) => {
-
+        console.log('schema', schema);
+        console.log('deploy', deploy);
+        console.log('api', api);
+        console.log('group', group);
         if (schema && deploy && api && group) {
+            console.log('deploying');
             axios.get(`${deployUrl}`,
                 // axios.get(`http://localhost:8999/graphql/deployall`,
                 {
+                    // params: {
+                    //     'cloud-name': 'tencent',
+                    //     schema: "ecommerce_schemaID",
+                    //     deploy: "deploy_1544504304478_57468453",
+                    //     api: "path_1544504334478_82625598",
+                    //     group: "group_1544504325443_46750115"
+                    // }
                     params: {
                         'cloud-name': 'tencent',
-                        schema: "ecommerce_schemaID",
-                        deploy: "deploy_1544504304478_57468453",
-                        api: "path_1544504334478_82625598",
-                        group: "group_1544504325443_46750115"
+                        schema,
+                        deploy,
+                        api,
+                        group
                     }
                 })
                 .then((res) => {
@@ -81,7 +98,6 @@ class TencentConfig extends Component {
     };
 
     stepByStep = (stepNum) => {
-        console.log(2);
         this.setState({
             currentStep: stepNum
         })
@@ -118,21 +134,23 @@ class TencentConfig extends Component {
                             api = '',
                             cloudID = 'tencent_CloudID';
 
-
                         let dataProject = data.project_by_id;
                         let {cloud_id, apiGWGroup_id, deploy_id, projectType, schema_id, wxConfig_id, projectName} = dataProject;
 
                         let defaultName = projectName;
 
-                        console.log('ccc', cloud_id);
+                        if (projectType === 'graphql')
+                            schemaID = schema_id.id;
+                        else
+                            configID = wxConfig_id.id;
+
+                        // 如果 cloud_id 没有存储,说明尚未部署,即新的 project,使用 '视图 2'
+                        // 旧的 project 使用 '视图 1'
+
                         if (cloud_id !== null && cloud_id.cloudName === 'tencent') {
                             group = apiGWGroup_id;
                             deploy = deploy_id;
                             cloudID = cloud_id.id;
-                            if (projectType === 'graphql')
-                                schemaID = schema_id.id;
-                            else
-                                configID = wxConfig_id.id;
 
                             return (
                                 <div>
@@ -212,6 +230,7 @@ class TencentConfig extends Component {
                                                                                     trialcase={this.props.trialcase}
                                                                                     deployID={deploy ? deploy.id : this.state.deployIdPassToPath}
                                                                                     groupID={group ? group.id : this.state.groupIdPassToPath}
+                                                                                    pass={this.pass}
                                                                                 />
                                                                             </Card>
                                                                     }
@@ -241,7 +260,7 @@ class TencentConfig extends Component {
                                                         projectType === 'graphql' ?
                                                             schema_id.schemaState === 'ok' ?
                                                                 <Button type='primary'
-                                                                        onClick={() => this.deployFC(schemaID, deploy, api, group)}><FormattedMessage
+                                                                        onClick={() => this.deployFC(schemaID, deploy ? deploy.id : this.state.deployIdPassToPath, this.state.pathIdPassToConfig, group ? group.id : this.state.groupIdPassToPath)}><FormattedMessage
                                                                     id="deploy"/>!</Button>
                                                                 :
                                                                 <Button type='primary' disabled><FormattedMessage
@@ -360,6 +379,7 @@ class TencentConfig extends Component {
                                                                                             trialcase={this.props.trialcase}
                                                                                             deployID={deploy ? deploy.id : this.state.deployIdPassToPath}
                                                                                             groupID={group ? group.id : this.state.groupIdPassToPath}
+                                                                                            pass={this.pass}
                                                                                             stepByStep={this.stepByStep}
                                                                                         />
                                                                                     </Card>
@@ -404,7 +424,7 @@ class TencentConfig extends Component {
                                                                 projectType === 'graphql' ?
                                                                     schema_id.schemaState === 'ok' ?
                                                                         <Button type='primary'
-                                                                                onClick={() => this.deployFC(schemaID, deploy, api, group)}><FormattedMessage
+                                                                                onClick={() => this.deployFC(schemaID, deploy ? deploy.id : this.state.deployIdPassToPath, this.state.pathIdPassToConfig, group ? group.id : this.state.groupIdPassToPath)}><FormattedMessage
                                                                             id="deploy"/>!</Button>
                                                                         :
                                                                         <Button type='primary'

+ 1 - 1
src/app/graphqlService/component/graphql/Graphql.jsx

@@ -46,7 +46,7 @@ class Graphql extends Component {
                         }
                         let group = data.project_by_id.apiGWGroup_id;
                         if (this.state.api === '') {
-                            let domain = group.userDomain? group.userDomain : group.defaultDomain + '/' + group.environmentName;
+                            let domain = group.userDomain? group.userDomain : group.defaultDomain;
                             this.setState({
                                 // 多路径没做
                                 api: group.frontType.slice(0, 4) + '://' + domain + '/graphql',

+ 116 - 1
src/gql.js

@@ -862,6 +862,120 @@ const GET_PROJECT = `
                 }
         `;
 
+const UPDATE_PROJECT = `
+            mutation updateproject($id: ID, $updatedAt: String, $database_id: ID, $apiGWGroup_id: ID, $createdAt: String, $projectName: String, $deploy_id: ID, $projectType: String, $cloud_id: ID, $user_id: ID, $wxConfig_id: ID, $schema_id: ID) {
+              update_project(id: $id updatedAt: $updatedAt database_id: $database_id apiGWGroup_id: $apiGWGroup_id createdAt: $createdAt projectName: $projectName deploy_id: $deploy_id projectType: $projectType cloud_id: $cloud_id user_id: $user_id wxConfig_id: $wxConfig_id schema_id: $schema_id) {
+                updatedAt
+                database_id {
+                  dbPort
+                  updatedAt
+                  dbHost
+                  dbUsername
+                  dbPassword
+                  createdAt
+                  id
+            
+            
+                  dbName
+                }
+                apiGWGroup_id {
+                  environmentName
+                  userStatus
+                  defaultDomain
+                  updatedAt
+                  userDomain
+                  groupName
+                  createdAt
+                  frontType
+                  region
+                  serviceId
+                  status
+                  id
+            
+                }
+                createdAt
+                projectName
+                deploy_id {
+                  description
+                  updatedAt
+                  cosBucketName
+                  memorySize
+            
+                  createdAt
+                  subnetId
+                  cosObjectName
+                  region
+                  vpcId
+                  cosBucketRegion
+                  id
+            
+            
+                  serviceName
+                  timeout
+                  handler
+                  functionName
+                }
+                id
+                projectType
+                cloud_id {
+                  id
+            
+                  cloudName
+                  secretId
+                  secretKey
+                  appId
+                  createdAt
+                  updatedAt
+                }
+                user_id {
+                  email
+                  updatedAt
+                  password
+                  telephone
+                  nickname
+                  username
+                  createdAt
+                  openid
+                  id
+                  avatar
+                }
+                wxConfig_id {
+                  updatedAt
+                  mch_id
+                  appName
+                  notify_url
+                  appSecret
+                  createdAt
+                  appID
+                  token
+                  spbill_create_ip
+                  enter_url
+                  id
+                  pay_api_key
+            
+                  body
+                  welcome_words
+                  attach
+                }
+                schema_id {
+                  updatedAt
+                  schemaState
+                  authWrite
+                  authReadObjects
+                  createdAt
+                  authRead
+                  schemaName
+                  reference
+                  id
+                  schemaData
+                  authReadWrite
+            
+                  authWriteObjects
+                }
+              }
+            }
+        `;
+
 export {
     ADD_USER,
     GET_USER,
@@ -897,5 +1011,6 @@ export {
     SHOW_WXCONTENT,
     UPDATE_WXCONFIG,
     DELETE_WXCONFIG,
-    GET_PROJECT
+    GET_PROJECT,
+    UPDATE_PROJECT
 }