From 8c3e988a8c95bae7235d5de4ba8e85e77988c395 Mon Sep 17 00:00:00 2001 From: Matthew Shao Date: Mon, 24 Jul 2017 20:34:15 +0800 Subject: [web] Add Download/Load button to OptionEditor. --- web/src/js/ducks/options.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'web/src/js/ducks/options.js') diff --git a/web/src/js/ducks/options.js b/web/src/js/ducks/options.js index 06144a3c..b22030a3 100644 --- a/web/src/js/ducks/options.js +++ b/web/src/js/ducks/options.js @@ -5,6 +5,7 @@ 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 = {} @@ -44,3 +45,14 @@ export function update(option, value) { sendUpdate(option, value, dispatch); } } + +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 }) +} -- cgit v1.2.3