xy %!s(int64=7) %!d(string=hai) anos
pai
achega
c7425c2b71

+ 0 - 1
src/app/common/deploy/tencent/TencentConfig.js

@@ -359,7 +359,6 @@ class TencentConfig extends Component {
                                                         region={this.state.region}
                                                         trialcase={this.props.trialcase}
                                                         stepByStep={this.stepByStep(true)}
-                                                        userID={this.props.userID}
                                                         projectID={projectID}
                                                     />
                                                 </Card>

+ 89 - 4
src/app/common/manage/TencentResult.js

@@ -1,10 +1,21 @@
 import React, {Component} from 'react';
 import {FormattedMessage} from 'react-intl';
 import {Switch, Input, Icon, Spin, Row, Col, message} from 'antd';
-import {GET_PROJECT, SHOW_APIGWPATH, UPDATE_APIGROUP} from "../../../gql";
+import {
+    DELETE_APIGWPATH,
+    GET_PROJECT,
+    SHOW_APIGWPATH,
+    UPDATE_APIGROUP,
+    UPDATE_PROJECT_ONLY_STATUS
+} from "../../../gql";
+import {request} from 'graphql-request'
 import gql from "graphql-tag";
 import {Query, Mutation} from "react-apollo";
 import copy from 'copy-to-clipboard';
+import axios from 'axios';
+import {removeFC, removeAPI, graphqlUrl} from "../../../config";
+
+axios.defaults.withCredentials = true;
 
 class TencentResult extends Component {
     constructor(props) {
@@ -27,6 +38,7 @@ class TencentResult extends Component {
                         let group = data.project_by_id.apiGWGroup_id || {};
                         let projectType = data.project_by_id.projectType || 'graphql';
                         let projectStatus = data.project_by_id.projectStatus || 'created';
+                        let cloudID = data.project_by_id.cloud_id || 'tencent_CloudID';
                         return (
                             <div>
                                 {
@@ -79,6 +91,9 @@ class TencentResult extends Component {
                                                     group={group}
                                                     projectType={projectType}
                                                     switchMenu={this.props.switchMenu}
+                                                    cloudID={cloudID}
+                                                    projectID={projectID}
+                                                    userID={this.props.userID}
                                                 />
                                             </div>
                                         </div>
@@ -163,7 +178,7 @@ class APIGWPathResult extends Component {
 
     render() {
         let {group, projectType} = this.props;
-        let {id, frontType, defaultDomain, environmentName} = group;
+        let {id} = group;
         return (
             <Query query={gql(SHOW_APIGWPATH)} variables={{apiGWGroup_id: id}} fetchPolicy={'network-only'}>
                 {
@@ -206,8 +221,14 @@ class APIGWPathResult extends Component {
                                                                 <span className={'schema-table-content'}>{path.apiGWDesc}</span>
                                                             </Col>
                                                             <Col span={3}>
-                                                                {/*<span className={'schema-table-content name'}>删除</span>*/}
-                                                                {/*&nbsp;*/}
+                                                                <DeletePathSpan
+                                                                    cloudID={this.props.cloudID}
+                                                                    groupID={id}
+                                                                    path={path}
+                                                                    projectID={this.props.projectID}
+                                                                    userID={this.props.userID}
+                                                                />
+                                                                &nbsp;
                                                                 {
                                                                     projectType === 'graphql'?
                                                                         <span className={'schema-table-content name'}
@@ -238,3 +259,67 @@ class APIGWPathResult extends Component {
         )
     }
 }
+
+class DeletePathSpan extends Component {
+    constructor(props) {
+        super(props);
+        this.state = {
+
+        }
+    }
+
+    render() {
+        return (
+            <Mutation
+                mutation={gql(DELETE_APIGWPATH)}
+                refetchQueries={[{query: gql(SHOW_APIGWPATH), variables: {apiGWGroup_id: this.props.groupID}}]}
+            >
+                {(delete_apiGWPath, {loading, error}) => {
+                    if (error)
+                        return 'error';
+                    if (loading)
+                        return <Spin style={{marginLeft: 3}}/>;
+
+                    return (
+                        <span className={'schema-table-content name'} onClick={() => {
+                                  let _this = this;
+                                  axios.get(`${removeAPI}`, {
+                                      params: {
+                                          'cloud-id': `${_this.props.cloudID}`,
+                                          'api-id': `${_this.props.path.id}`
+                                      }
+                                  })
+                                      .then((res) => {
+                                          console.log('delete api');
+                                          if (res.data !== '') {
+
+                                              console.log('path id', _this.props.path.id, 'user id', _this.props.userID);
+
+                                              if(_this.props.path.id && _this.props.userID) {
+                                                  delete_apiGWPath(_this.props.path.id, _this.props.userID);
+
+                                                  // 写回 project 状态
+                                                  request(graphqlUrl, UPDATE_PROJECT_ONLY_STATUS, {
+                                                      id: this.props.projectID,
+                                                      updatedAt: new Date().getTime(),
+                                                      projectStatus: 'grouped'
+                                                  });
+                                              }
+                                              console.log(res.data);
+                                          } else {
+                                              console.log('error');
+                                          }
+                                      })
+                                      .catch((err) => {
+                                          console.log(err);
+                                      });
+                              }}
+                        >
+                            删除
+                        </span>
+                    )
+                }}
+            </Mutation>
+        )
+    }
+}

+ 3 - 1
src/config.js

@@ -29,9 +29,11 @@ const backendGQ = backend + '/graphql';
 const genJsUrl = backendGQ + '/genjs';
 const checkSchemaUrl = backendGQ + '/compile';
 const deployUrl = backendGQ + '/deployall';
+const removeFC = backendGQ + '/removefc';
+const removeAPI = backendGQ + '/removeapi';
 
 // 管理员配置
 // 通过在该数组中添加 userID,可以管理 trialcase 的增删改查
 const manageUsers = ['xy_1_je9{d\'\'_32sD+'];
 
-export {getIdUrl, loginUrl, registerUrl, checkSchemaUrl, deployUrl, genJsUrl, graphqlUrl, manageUsers}
+export {getIdUrl, loginUrl, registerUrl, checkSchemaUrl, deployUrl, genJsUrl, graphqlUrl, manageUsers, removeFC, removeAPI}

+ 9 - 0
src/gql.js

@@ -631,6 +631,12 @@ const UPDATE_APIGWPATH = `
         `;
 
 
+const DELETE_APIGWPATH = `
+            mutation deleteapiGWPath($id: ID, $user_id: ID) {
+                delete_apiGWPath(id: $id user_id: $user_id)
+            }
+        `;
+
 
 const SHOW_ALL_WXCONFIG = `
             query WXCONFIG($user_id: ID) {
@@ -970,6 +976,8 @@ const UPDATE_NOTIFICATION = `
             }
         `;
 
+
+
 export {
     ADD_USER,
     GET_USER,
@@ -998,6 +1006,7 @@ export {
     SHOW_APIGWPATH,
     ADD_APIGWPATH,
     UPDATE_APIGWPATH,
+    DELETE_APIGWPATH,
     ADD_PROJECT_AND_WX,
     SHOW_ALL_WXCONFIG,
     SHOW_WXCONFIG,