[web] Update options auto dump for frontend.

This commit is contained in:
Matthew Shao 2017-07-26 15:09:11 +08:00
parent 9d16cc7079
commit c7e41b32ab
3 changed files with 6 additions and 26 deletions

View File

@ -74,7 +74,7 @@ export function ChoicesOption({ value, onChange, choices, ...props }) {
return (
<select
onChange={(e) => onChange(e.target.value)}
selected={value}
value={value}
{...props}
>
{ choices.map(

View File

@ -3,7 +3,6 @@ import { connect } from "react-redux"
import * as modalAction from "../../ducks/ui/modal"
import * as optionAction from "../../ducks/options"
import Option from "./Option"
import FileChooser from '../../components/common/FileChooser'
import _ from "lodash"
function PureOptionHelp({help}){
@ -54,13 +53,14 @@ class PureOptionModal extends Component {
}
render() {
const { hideModal, options, download, upload } = this.props
const { hideModal, options, dump } = this.props
const { title } = this.state
return (
<div>
<div className="modal-header">
<button type="button" className="close" data-dismiss="modal" onClick={() => {
hideModal()
dump()
}}>
<i className="fa fa-fw fa-times"></i>
</button>
@ -90,17 +90,6 @@ class PureOptionModal extends Component {
</div>
<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>
)
@ -113,7 +102,6 @@ export default connect(
}),
{
hideModal: modalAction.hideModal,
download: optionAction.download,
upload: optionAction.upload,
dump: optionAction.dump,
}
)(PureOptionModal)

View File

@ -5,7 +5,6 @@ import _ from "lodash"
export const RECEIVE = 'OPTIONS_RECEIVE'
export const UPDATE = 'OPTIONS_UPDATE'
export const REQUEST_UPDATE = 'REQUEST_UPDATE'
export const SAVE = 'OPTION_SAVE'
const defaultState = {}
@ -46,13 +45,6 @@ export function update(option, value) {
}
}
export function download() {
window.location = '/options/dump'
return { type: SAVE }
}
export function upload(file) {
const body = new FormData()
body.append('file', file)
return dispatch => fetchApi('/options/dump', { method: 'POST', body })
export function dump() {
return dispatch => fetchApi('/options/dump', { method: 'POST' })
}