|
|
@@ -1,19 +1,23 @@
|
|
|
import React, {Component} from 'react';
|
|
|
-import {Layout, Button, notification} from 'antd';
|
|
|
+import {Layout, Button, notification, Spin} from 'antd';
|
|
|
import {getCookie} from "../../../cookie";
|
|
|
import {graphqlUrl} from "../../../config";
|
|
|
import {SHOW_CLOUD} from "../../../gql";
|
|
|
import {request} from 'graphql-request'
|
|
|
+import axios from 'axios';
|
|
|
+
|
|
|
const {Content} = Layout;
|
|
|
+axios.defaults.withCredentials = true;
|
|
|
|
|
|
-class DeployCloudChoose extends Component{
|
|
|
- constructor(){
|
|
|
+class DeployCloudChoose extends Component {
|
|
|
+ constructor() {
|
|
|
super();
|
|
|
- this.state={
|
|
|
+ this.state = {
|
|
|
userID: 'demo',
|
|
|
secretId: '',
|
|
|
secretKey: '',
|
|
|
- appId: ''
|
|
|
+ appId: '',
|
|
|
+ disabled: false
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -26,7 +30,6 @@ class DeployCloudChoose extends Component{
|
|
|
|
|
|
// 查询是否设置 cloud
|
|
|
request(graphqlUrl, SHOW_CLOUD, {user_id: userID}).then(data => {
|
|
|
- console.log(data.cloud_by_props);
|
|
|
data.cloud_by_props.forEach(cloud => {
|
|
|
switch (cloud.cloudName) {
|
|
|
case 'tencent':
|
|
|
@@ -51,36 +54,96 @@ class DeployCloudChoose extends Component{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- render(){
|
|
|
- let {userID} = this.state;
|
|
|
- return(
|
|
|
+ deploy() {
|
|
|
+ let bucketName = '';
|
|
|
+ if (this.props.location && this.props.location.state) {
|
|
|
+ switch (this.props.location.state.schemaID) {
|
|
|
+ case 'order_schemaID':
|
|
|
+ bucketName = 'order';
|
|
|
+ break;
|
|
|
+ case 'ecommerce_schemaID':
|
|
|
+ bucketName = 'ec';
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (bucketName === '') {
|
|
|
+ console.log('state, 没有传值');
|
|
|
+ } else {
|
|
|
+ // 开始调用
|
|
|
+ console.log('开始调用');
|
|
|
+ this.setState({
|
|
|
+ disabled: true
|
|
|
+ });
|
|
|
+ let _this = this;
|
|
|
+ axios.post('http://deploy.ioobot.cn/api/deploy-all',
|
|
|
+ {
|
|
|
+ 'fc-name': this.state.userID + new Date().getTime(),
|
|
|
+ 'bucket': 'native-fc',
|
|
|
+ 'object-file': 'fc-only.zip',
|
|
|
+ 'res-bucket': 'case',
|
|
|
+ 'resources': '["appointment/schema.edn" "appointment/resolve-map.edn" "appointment/mongodb/mongo-config.edn" "appointment/mongodb/deploy-conf.edn"]',
|
|
|
+ 'service-name': this.state.userID + new Date().getTime(),
|
|
|
+ 'path': "/*"
|
|
|
+ })
|
|
|
+ .then(function (response) {
|
|
|
+ _this.setState({
|
|
|
+ disabled: false
|
|
|
+ });
|
|
|
+ _this.props.changeTabBar('my-deploy');
|
|
|
+ _this.props.history.push({
|
|
|
+ pathname: `/common/deploy`,
|
|
|
+ state: {}
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ })
|
|
|
+ .catch(function (error) {
|
|
|
+ console.log(error);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ render() {
|
|
|
+ let {userID, disabled} = this.state;
|
|
|
+ return (
|
|
|
<div className={'deploy-choose-cloud'}>
|
|
|
- <Layout style={{ padding: '24px',minHeight:'300px' }}>
|
|
|
- <Content style={{ padding: '20px 50px', background: '#fff' }}>
|
|
|
+ <Layout style={{padding: '24px', minHeight: '300px'}}>
|
|
|
+ <Content style={{padding: '20px 50px', background: '#fff'}}>
|
|
|
<div className={'choose-cloud'}>
|
|
|
- <span className={'choose-cloud-title'}>系统默认设置</span><span className={'choose-cloud-content'}>部署在系统云服务商,部署成功后返回结果</span>
|
|
|
+ <span className={'choose-cloud-title'}>系统默认设置</span><span
|
|
|
+ className={'choose-cloud-content'}>部署在系统云服务商,部署成功后返回结果</span>
|
|
|
</div>
|
|
|
<div className={'choose-cloud'}>
|
|
|
- <span className={'choose-cloud-title'}>自定义设置</span><span className={'choose-cloud-content'}>部署在自有云服务商,部署成功后返回结果,可登陆云服务商后台查看部署结果</span>
|
|
|
+ <span className={'choose-cloud-title'}>自定义设置</span><span
|
|
|
+ className={'choose-cloud-content'}>部署在自有云服务商,部署成功后返回结果,可登陆云服务商后台查看部署结果</span>
|
|
|
</div>
|
|
|
<div className={'choose-cloud-button-group'}>
|
|
|
- <Button className={'choose-cloud-button'} type='primary' onClick={()=>{
|
|
|
- console.log('默认')
|
|
|
- }}>系统默认部署</Button>
|
|
|
- <Button className={'choose-cloud-button'} type='primary' onClick={()=>{
|
|
|
- if(userID === 'demo') {
|
|
|
- notification['warning']({
|
|
|
- message: '需要登录',
|
|
|
- description: '后续使用,需要先登录',
|
|
|
- });
|
|
|
+ {
|
|
|
+ disabled ?
|
|
|
+ <Spin/>
|
|
|
+ :
|
|
|
+ <div>
|
|
|
+ <Button className={'choose-cloud-button'} type='primary' onClick={() => {
|
|
|
+ this.deploy();
|
|
|
+ }}>系统默认部署</Button>
|
|
|
+ <Button className={'choose-cloud-button'} type='primary' onClick={() => {
|
|
|
+ if (userID === 'demo') {
|
|
|
+ notification['warning']({
|
|
|
+ message: '需要登录',
|
|
|
+ description: '后续使用,需要先登录',
|
|
|
+ });
|
|
|
|
|
|
- this.props.history.push({
|
|
|
- pathname: `/login`
|
|
|
- })
|
|
|
- } else {
|
|
|
- console.log('已经登录')
|
|
|
- }
|
|
|
- }}>自定义参数设置</Button>
|
|
|
+ this.props.history.push({
|
|
|
+ pathname: `/login`
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.deploy();
|
|
|
+ }
|
|
|
+ }}>自定义参数设置</Button>
|
|
|
+ </div>
|
|
|
+ }
|
|
|
</div>
|
|
|
</Content>
|
|
|
</Layout>
|