mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-26 02:10:59 +00:00
[web] Update options auto dump for frontend.
This commit is contained in:
parent
9d16cc7079
commit
c7e41b32ab
@ -74,7 +74,7 @@ export function ChoicesOption({ value, onChange, choices, ...props }) {
|
|||||||
return (
|
return (
|
||||||
<select
|
<select
|
||||||
onChange={(e) => onChange(e.target.value)}
|
onChange={(e) => onChange(e.target.value)}
|
||||||
selected={value}
|
value={value}
|
||||||
{...props}
|
{...props}
|
||||||
>
|
>
|
||||||
{ choices.map(
|
{ choices.map(
|
||||||
|
@ -3,7 +3,6 @@ import { connect } from "react-redux"
|
|||||||
import * as modalAction from "../../ducks/ui/modal"
|
import * as modalAction from "../../ducks/ui/modal"
|
||||||
import * as optionAction from "../../ducks/options"
|
import * as optionAction from "../../ducks/options"
|
||||||
import Option from "./Option"
|
import Option from "./Option"
|
||||||
import FileChooser from '../../components/common/FileChooser'
|
|
||||||
import _ from "lodash"
|
import _ from "lodash"
|
||||||
|
|
||||||
function PureOptionHelp({help}){
|
function PureOptionHelp({help}){
|
||||||
@ -54,13 +53,14 @@ class PureOptionModal extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { hideModal, options, download, upload } = this.props
|
const { hideModal, options, dump } = this.props
|
||||||
const { title } = this.state
|
const { title } = this.state
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className="modal-header">
|
<div className="modal-header">
|
||||||
<button type="button" className="close" data-dismiss="modal" onClick={() => {
|
<button type="button" className="close" data-dismiss="modal" onClick={() => {
|
||||||
hideModal()
|
hideModal()
|
||||||
|
dump()
|
||||||
}}>
|
}}>
|
||||||
<i className="fa fa-fw fa-times"></i>
|
<i className="fa fa-fw fa-times"></i>
|
||||||
</button>
|
</button>
|
||||||
@ -90,17 +90,6 @@ class PureOptionModal extends Component {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="modal-footer">
|
<div className="modal-footer">
|
||||||
<button type="button" className="btn btn-default" onClick={download}>
|
|
||||||
<i className="fa fa-download"></i>
|
|
||||||
Download
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<FileChooser
|
|
||||||
icon="fa-upload"
|
|
||||||
onOpenFile={file => {upload(file); alert('Option configuration loaded!')}}
|
|
||||||
text="Load"
|
|
||||||
className="btn btn-primary"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
@ -113,7 +102,6 @@ export default connect(
|
|||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
hideModal: modalAction.hideModal,
|
hideModal: modalAction.hideModal,
|
||||||
download: optionAction.download,
|
dump: optionAction.dump,
|
||||||
upload: optionAction.upload,
|
|
||||||
}
|
}
|
||||||
)(PureOptionModal)
|
)(PureOptionModal)
|
||||||
|
@ -5,7 +5,6 @@ import _ from "lodash"
|
|||||||
export const RECEIVE = 'OPTIONS_RECEIVE'
|
export const RECEIVE = 'OPTIONS_RECEIVE'
|
||||||
export const UPDATE = 'OPTIONS_UPDATE'
|
export const UPDATE = 'OPTIONS_UPDATE'
|
||||||
export const REQUEST_UPDATE = 'REQUEST_UPDATE'
|
export const REQUEST_UPDATE = 'REQUEST_UPDATE'
|
||||||
export const SAVE = 'OPTION_SAVE'
|
|
||||||
|
|
||||||
const defaultState = {}
|
const defaultState = {}
|
||||||
|
|
||||||
@ -46,13 +45,6 @@ export function update(option, value) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function download() {
|
export function dump() {
|
||||||
window.location = '/options/dump'
|
return dispatch => fetchApi('/options/dump', { method: 'POST' })
|
||||||
return { type: SAVE }
|
|
||||||
}
|
|
||||||
|
|
||||||
export function upload(file) {
|
|
||||||
const body = new FormData()
|
|
||||||
body.append('file', file)
|
|
||||||
return dispatch => fetchApi('/options/dump', { method: 'POST', body })
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user