mirror of
https://github.com/alibaba/anyproxy.git
synced 2025-07-28 16:37:42 +00:00
add CA download page
This commit is contained in:
@@ -5,29 +5,26 @@
|
||||
|
||||
import React, { PropTypes } from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import ClassBind from 'classnames/bind';
|
||||
import { connect } from 'react-redux';
|
||||
import { message, Button, Spin, Select } from 'antd';
|
||||
import { message, Button, Spin } from 'antd';
|
||||
import ResizablePanel from 'component/resizable-panel';
|
||||
import { hideRootCA, updateIsRootCAExists } from 'action/globalStatusAction';
|
||||
import { MenuKeyMap } from 'common/Constant';
|
||||
import { getJSON, postJSON } from 'common/ApiUtil';
|
||||
import { getJSON, ajaxGet, postJSON } from 'common/ApiUtil';
|
||||
|
||||
import Style from './download-root-ca.less';
|
||||
import CommonStyle from '../style/common.less';
|
||||
|
||||
const certFileTypes = ['crt', 'cer', 'pem', 'der'];
|
||||
|
||||
class DownloadRootCA extends React.Component {
|
||||
constructor () {
|
||||
super();
|
||||
this.state = {
|
||||
loadingCAQr: false,
|
||||
generatingCA: false,
|
||||
fileType: certFileTypes[0]
|
||||
generatingCA: false
|
||||
};
|
||||
|
||||
this.onClose = this.onClose.bind(this);
|
||||
this.onFileTypeChange = this.onFileTypeChange.bind(this);
|
||||
this.getQrCodeContent = this.getQrCodeContent.bind(this);
|
||||
}
|
||||
|
||||
@@ -41,7 +38,7 @@ class DownloadRootCA extends React.Component {
|
||||
loadingCAQr: true
|
||||
});
|
||||
|
||||
getJSON('/api/getQrCode', { type: this.state.fileType })
|
||||
getJSON('/api/getQrCode')
|
||||
.then((response) => {
|
||||
this.setState({
|
||||
loadingCAQr: false,
|
||||
@@ -60,33 +57,12 @@ class DownloadRootCA extends React.Component {
|
||||
this.props.dispatch(hideRootCA());
|
||||
}
|
||||
|
||||
onFileTypeChange (value) {
|
||||
this.setState({
|
||||
fileType: value
|
||||
}, () => {
|
||||
this.fetchData();
|
||||
});
|
||||
}
|
||||
|
||||
getQrCodeContent () {
|
||||
const imgDomContent = { __html: this.state.CAQrCodeImageDom };
|
||||
const content = (
|
||||
<div className={Style.qrCodeWrapper} >
|
||||
<div dangerouslySetInnerHTML={imgDomContent} />
|
||||
<div>Scan to download rootCA.{this.state.fileType} to your Phone</div>
|
||||
<div>You can change the CA's file extension:
|
||||
<Select
|
||||
defaultValue={this.state.fileType}
|
||||
className={Style.fileSelect}
|
||||
onChange={this.onFileTypeChange}
|
||||
>
|
||||
{
|
||||
certFileTypes.map(key => (
|
||||
<Option key={key} value={key}>{key}</Option>
|
||||
))
|
||||
}
|
||||
</Select>
|
||||
</div>
|
||||
<span>Scan to download rootCA to your Phone</span>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -95,6 +71,7 @@ class DownloadRootCA extends React.Component {
|
||||
}
|
||||
|
||||
getGenerateRootCADiv () {
|
||||
|
||||
const doToggleRemoteIntercept = () => {
|
||||
postJSON('/api/generateRootCA')
|
||||
.then((result) => {
|
||||
@@ -150,8 +127,8 @@ class DownloadRootCA extends React.Component {
|
||||
</div>
|
||||
|
||||
<div className={Style.buttons} >
|
||||
<a href={`/fetchCrtFile?type=${this.state.fileType}`} target="_blank">
|
||||
<Button type="primary" size="large" >Download</Button>
|
||||
<a href="/fetchCrtFile" target="_blank">
|
||||
<Button type="primary" size="large" > Download </Button>
|
||||
</a>
|
||||
<span className={Style.tipSpan} >Or click the button to download.</span>
|
||||
</div>
|
||||
@@ -169,6 +146,7 @@ class DownloadRootCA extends React.Component {
|
||||
return (
|
||||
<ResizablePanel onClose={this.onClose} visible={panelVisible} >
|
||||
{this.props.globalStatus.isRootCAFileExists ? this.getDownloadDiv() : this.getGenerateRootCADiv()}
|
||||
|
||||
</ResizablePanel>
|
||||
);
|
||||
}
|
||||
|
@@ -55,9 +55,4 @@
|
||||
margin-top: 18px;
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
.fileSelect {
|
||||
width: 60px;
|
||||
margin-left: 8px;
|
||||
}
|
Reference in New Issue
Block a user