Переглянути джерело

cloud config 展示 appID

xy 7 роки тому
батько
коміт
20e468f7f2
2 змінених файлів з 28 додано та 7 видалено
  1. 11 1
      src/gql.js
  2. 17 6
      src/login/CloudConfig.js

+ 11 - 1
src/gql.js

@@ -176,6 +176,10 @@ const ADD_CLOUD = `
                 appId: $appId 
             ) {
                 id
+                cloudName
+                secretId
+                secretKey
+                appId
             }
         }
     `;
@@ -187,19 +191,25 @@ const SHOW_CLOUD = `
                     cloudName
                     secretId
                     secretKey
+                    appId
                 }
             }
         `;
 
 const UPDATE_CLOUD = `
-        mutation updatecloud($id: ID, $secretId: String, $secretKey: String $updatedAt: String) {
+        mutation updatecloud($id: ID, $secretId: String, $secretKey: String $updatedAt: String, $appId: String) {
             update_cloud(
                 id: $id 
                 secretId: $secretId 
                 secretKey: $secretKey  
                 updatedAt: $updatedAt
+                appId: $appId
             ) {
                 id
+                cloudName
+                secretId
+                secretKey
+                appId
             }
         }
     `;

+ 17 - 6
src/login/CloudConfig.js

@@ -16,15 +16,18 @@ class CloudConfig extends Component {
             showOK: '',
             showNotOK: '',
             tencentCLoudID: '',
+            tenAppID: '',
             tenID: '',
             tenKey: '',
             aliyunCLoudID: '',
+            aliAppID: '',
             aliID: '',
             aliKey: '',
             awsCLoudID: '',
+            awsAppID: '',
             awsID: '',
             awsKey: '',
-            userID: getCookie('user_id')
+            userID: getCookie('user_id'),
         };
         request(graphqlUrl, SHOW_CLOUD, {user_id: this.state.userID}).then(
             data => {
@@ -34,12 +37,15 @@ class CloudConfig extends Component {
                 this.setState({
                     show: true,
                     tencentCLoudID: tencent ? tencent.id : '',
+                    tenAppID: tencent ? tencent.appId : '',
                     tenID: tencent ? tencent.secretId : '',
                     tenKey: tencent ? tencent.secretKey : '',
                     aliyunCLoudID: aliyun ? aliyun.id : '',
+                    aliAppID: aliyun ? aliyun.appId : '',
                     aliID: aliyun ? aliyun.secretId : '',
                     aliKey: aliyun ? aliyun.secretKey : '',
                     awsCLoudID: amazon ? amazon.id : '',
+                    awsAppID: amazon ? amazon.appId : '',
                     awsID: amazon ? amazon.secretId : '',
                     awsKey: amazon ? amazon.secretKey : ''
                 });
@@ -56,13 +62,13 @@ class CloudConfig extends Component {
         }
     };
 
-    submit = (id, cloudName, secretId, secretKey) => {
+    submit = (id, cloudName, secretId, secretKey, appId) => {
         return () => {
             if (id === '') {
                 let varObj = {
                     id: idGen('cloud'),
                     user_id: this.state.userID,
-                    appId: 'account-id',
+                    appId,
                     cloudName,
                     secretId,
                     secretKey,
@@ -97,6 +103,7 @@ class CloudConfig extends Component {
                     id,
                     secretId,
                     secretKey,
+                    appId,
                     updatedAt: new Date().getTime()
                 };
                 request(graphqlUrl, UPDATE_CLOUD, varObj).then(
@@ -142,13 +149,17 @@ class CloudConfig extends Component {
                         <span className='cloud-name'><FormattedMessage id="Tencent"/>: </span>
                         <div style={{marginBottom: 15}}>
                             <div>
+                                <div style={{marginBottom: 20}}>
+                                    <span className='item-title-cloud'>APP ID:</span>
+                                    <Input style={{width: 250}} value={this.state.tenAppID} onChange={this.inputChange('tenAppID')}/>
+                                </div>
                                 <div style={{marginBottom: 20}}>
                                     <span className='item-title-cloud'>secret ID:</span>
-                                    <Input style={{width: 250}} value={this.state.aliID} onChange={this.inputChange('tenID')}/>
+                                    <Input style={{width: 250}} value={this.state.tenID} onChange={this.inputChange('tenID')}/>
                                 </div>
                                 <div style={{marginBottom: 20}}>
                                     <span className='item-title-cloud'>secret Key:</span>
-                                    <Input style={{width: 250}} value={this.state.aliKey} onChange={this.inputChange('tenKey')}/>
+                                    <Input style={{width: 250}} value={this.state.tenKey} onChange={this.inputChange('tenKey')}/>
                                 </div>
                                 {
                                     this.state.showOK === 'tencent' ?
@@ -161,7 +172,7 @@ class CloudConfig extends Component {
                                 }
                             </div>
                             <Button type='primary'
-                                    onClick={this.submit(this.state.tencentCLoudID, 'tencent', this.state.tenID, this.state.tenKey)}>
+                                    onClick={this.submit(this.state.tencentCLoudID, 'tencent', this.state.tenID, this.state.tenKey, this.state.tenAppID)}>
                                 <FormattedMessage id="save"/>
                             </Button>
                         </div>