|
|
@@ -116,6 +116,7 @@ class Step2 extends Component {
|
|
|
render() {
|
|
|
let {userID, getCloudDetail} = this.props;
|
|
|
let {check} = this.state;
|
|
|
+ // recheck 的作用在于当取消或者保存后重新检测 cloud, 然后通过getCloudDetail传值到父组件
|
|
|
return (
|
|
|
<div className='step-block'>
|
|
|
第二步:填写腾讯云秘钥,一键部署
|
|
|
@@ -220,6 +221,7 @@ class CloudQueryAndConfig extends Component {
|
|
|
|
|
|
render() {
|
|
|
let {visible, confirmLoading, cloudName} = this.state;
|
|
|
+ // cloudconfig 组件引用外层组件公用,修改时应注意
|
|
|
return (
|
|
|
<div>
|
|
|
<Button type='primary' onClick={this.showModal}>填写秘钥</Button>
|
|
|
@@ -297,6 +299,65 @@ class NameAndDB extends Component {
|
|
|
this._isMounted = false;
|
|
|
}
|
|
|
|
|
|
+ // 首先存储 .edn 文件到 ioobot 的 cos,然后调用下面的 deploy 函数
|
|
|
+ storeEdnAndDeploy = (secretID, secretKey, appId, bucketName, dbKind, userID, admin, username, password, db, host, customName, cloudID) => {
|
|
|
+ // store *.edn to cos
|
|
|
+ secretID = secretID ? secretID : 'AKIDkYBvY0LOJ2bzCDmnMjz4xgFertmVJlVE'
|
|
|
+ secretKey = secretKey ? secretKey : 'zwjKk29TdcYP8g2FG5kCSWmz3wcH92lN'
|
|
|
+ appId = appId ? appId : '1254337200'
|
|
|
+ // mongodb 和 fc-db 区分配置
|
|
|
+ let deployConf = dbKind === 'mongodb' ?
|
|
|
+ ` {:secretId "${secretID}"\n` +
|
|
|
+ ` :secretKey "${secretKey}"\n` +
|
|
|
+ ` :appId "${appId}"\n` +
|
|
|
+ ' :region "ap-beijing" \n' +
|
|
|
+ ' }\n'
|
|
|
+ :
|
|
|
+ ` {:secretId "${secretID}"\n` +
|
|
|
+ ` :secretKey "${secretKey}"\n` +
|
|
|
+ ` :appId "${appId}"\n` +
|
|
|
+ ' :region "ap-beijing"\n' +
|
|
|
+ ' :bucket "fc-db"\n' +
|
|
|
+ ' :trustStore "/etc/ssl/certs/java/cacerts"\n' +
|
|
|
+ ` :fc-db-store "save/${bucketName}.dat"\n` +
|
|
|
+ ' :fc-db-dir "fc-db"\n' +
|
|
|
+ ' :local-tmp-dir "/tmp"\n' +
|
|
|
+ ' :local-db-file "fcdb.dat"\n' +
|
|
|
+ ' :update-tx? true \n' +
|
|
|
+ ' :force-down? true\n' +
|
|
|
+ ' }';
|
|
|
+
|
|
|
+ let a = axios.post(storeFile, {
|
|
|
+ 'file-name': `${bucketName}/${dbKind}/${userID}/deploy-conf.edn`,
|
|
|
+ bucket: 'case',
|
|
|
+ cont: deployConf
|
|
|
+ });
|
|
|
+
|
|
|
+ let cont = '{:uri {\n' +
|
|
|
+ `:auth {:admin-db "${admin}"\n` +
|
|
|
+ ` :u "${username}"\n` +
|
|
|
+ ` :p "${password}"\n` +
|
|
|
+ ` :host "${host}"}}\n` +
|
|
|
+ ` :db-name "${db}"}`;
|
|
|
+
|
|
|
+ // fc-db 不用存此文件,故直接返回 status: 200
|
|
|
+ let b = dbKind === 'mongodb' ?
|
|
|
+ axios.post(storeFile, {
|
|
|
+ 'file-name': `${bucketName}/${dbKind}/${userID}/mongo-config.edn`,
|
|
|
+ bucket: 'case',
|
|
|
+ cont
|
|
|
+ })
|
|
|
+ :
|
|
|
+ Promise.resolve({status: 200});
|
|
|
+
|
|
|
+ Promise.all([a, b]).then(value => {
|
|
|
+ if (value.every(res => res.status === 200)) {
|
|
|
+ console.log('store file success , start deploying');
|
|
|
+ this.deploy(userID, dbKind, bucketName, customName, cloudID);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
deploy = (userID, dbKind, bucketName, customName, cloudID) => {
|
|
|
this._isMounted = true;
|
|
|
let _this = this;
|
|
|
@@ -330,6 +391,7 @@ class NameAndDB extends Component {
|
|
|
'path': "/*"
|
|
|
})
|
|
|
.then(function (response) {
|
|
|
+ // 以下操作为写入数据库
|
|
|
console.log('response', response);
|
|
|
if (response['data']['apigw-result'] && response['data']['fc-result']) {
|
|
|
// 处理数据
|
|
|
@@ -458,62 +520,6 @@ class NameAndDB extends Component {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- storeEdnAndDeploy = (secretID, secretKey, appId, bucketName, dbKind, userID, admin, username, password, db, host, customName, cloudID) => {
|
|
|
- // store *.edn to cos
|
|
|
- secretID = secretID ? secretID : 'AKIDkYBvY0LOJ2bzCDmnMjz4xgFertmVJlVE'
|
|
|
- secretKey = secretKey ? secretKey : 'zwjKk29TdcYP8g2FG5kCSWmz3wcH92lN'
|
|
|
- appId = appId ? appId : '1254337200'
|
|
|
- let deployConf = dbKind === 'mongodb' ?
|
|
|
- ` {:secretId "${secretID}"\n` +
|
|
|
- ` :secretKey "${secretKey}"\n` +
|
|
|
- ` :appId "${appId}"\n` +
|
|
|
- ' :region "ap-beijing" \n' +
|
|
|
- ' }\n'
|
|
|
- :
|
|
|
- ` {:secretId "${secretID}"\n` +
|
|
|
- ` :secretKey "${secretKey}"\n` +
|
|
|
- ` :appId "${appId}"\n` +
|
|
|
- ' :region "ap-beijing"\n' +
|
|
|
- ' :bucket "fc-db"\n' +
|
|
|
- ' :trustStore "/etc/ssl/certs/java/cacerts"\n' +
|
|
|
- ` :fc-db-store "save/${bucketName}.dat"\n` +
|
|
|
- ' :fc-db-dir "fc-db"\n' +
|
|
|
- ' :local-tmp-dir "/tmp"\n' +
|
|
|
- ' :local-db-file "fcdb.dat"\n' +
|
|
|
- ' :update-tx? true \n' +
|
|
|
- ' :force-down? true\n' +
|
|
|
- ' }';
|
|
|
-
|
|
|
- let a = axios.post(storeFile, {
|
|
|
- 'file-name': `${bucketName}/${dbKind}/${userID}/deploy-conf.edn`,
|
|
|
- bucket: 'case',
|
|
|
- cont: deployConf
|
|
|
- });
|
|
|
-
|
|
|
- let cont = '{:uri {\n' +
|
|
|
- `:auth {:admin-db "${admin}"\n` +
|
|
|
- ` :u "${username}"\n` +
|
|
|
- ` :p "${password}"\n` +
|
|
|
- ` :host "${host}"}}\n` +
|
|
|
- ` :db-name "${db}"}`;
|
|
|
-
|
|
|
- let b = dbKind === 'mongodb' ?
|
|
|
- axios.post(storeFile, {
|
|
|
- 'file-name': `${bucketName}/${dbKind}/${userID}/mongo-config.edn`,
|
|
|
- bucket: 'case',
|
|
|
- cont
|
|
|
- })
|
|
|
- :
|
|
|
- Promise.resolve({status: 200});
|
|
|
-
|
|
|
- Promise.all([a, b]).then(value => {
|
|
|
- if (value.every(res => res.status === 200)) {
|
|
|
- console.log('store file success , start deploying');
|
|
|
- this.deploy(userID, dbKind, bucketName, customName, cloudID);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
render() {
|
|
|
let {
|
|
|
visible,
|
|
|
@@ -670,6 +676,7 @@ class Step5 extends Component {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// 该组件作用在于 store wx.edn to cos
|
|
|
class Wechat extends Component {
|
|
|
constructor(props) {
|
|
|
super(props)
|
|
|
@@ -870,6 +877,12 @@ class Step6 extends Component {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// 该组件作用在于 重新部署 fc
|
|
|
+// 因为需要同名覆盖,所以要求输入同名的函数名
|
|
|
+// 目前不直接在 step before存入共同父组件再传递回来,是因为
|
|
|
+// 考虑到用户刷新,数据将消失
|
|
|
+// 如果需要上述操作,可以考虑限制用户每种案例部署一个,通过查询数据库来实现自动填写
|
|
|
+// 目前的限制一个,在于限制了用户实际部署的,但在前端没有限制个数
|
|
|
class WechatDeploy extends Component {
|
|
|
constructor(props) {
|
|
|
super(props)
|