mirror of
https://github.com/zhigang1992/mitmproxy.git
synced 2026-04-23 20:00:09 +08:00
[web] FlowActions -> flows ducks
This commit is contained in:
@@ -39,61 +39,6 @@ export var ConnectionActions = {
|
||||
}
|
||||
};
|
||||
|
||||
export var FlowActions = {
|
||||
accept: function (flow) {
|
||||
$.post("/flows/" + flow.id + "/accept");
|
||||
},
|
||||
accept_all: function(){
|
||||
$.post("/flows/accept");
|
||||
},
|
||||
"delete": function(flow){
|
||||
$.ajax({
|
||||
type:"DELETE",
|
||||
url: "/flows/" + flow.id
|
||||
});
|
||||
},
|
||||
duplicate: function(flow){
|
||||
$.post("/flows/" + flow.id + "/duplicate");
|
||||
},
|
||||
replay: function(flow){
|
||||
$.post("/flows/" + flow.id + "/replay");
|
||||
},
|
||||
revert: function(flow){
|
||||
$.post("/flows/" + flow.id + "/revert");
|
||||
},
|
||||
update: function (flow, nextProps) {
|
||||
/*
|
||||
//Facebook Flux: We do an optimistic update on the client already.
|
||||
var nextFlow = _.cloneDeep(flow);
|
||||
_.merge(nextFlow, nextProps);
|
||||
AppDispatcher.dispatchViewAction({
|
||||
type: ActionTypes.FLOW_STORE,
|
||||
cmd: StoreCmds.UPDATE,
|
||||
data: nextFlow
|
||||
});
|
||||
*/
|
||||
$.ajax({
|
||||
type: "PUT",
|
||||
url: "/flows/" + flow.id,
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify(nextProps)
|
||||
});
|
||||
},
|
||||
clear: function(){
|
||||
$.post("/clear");
|
||||
},
|
||||
download: () => window.location = "/flows/dump",
|
||||
|
||||
upload: (file) => {
|
||||
let data = new FormData();
|
||||
data.append('file', file);
|
||||
fetchApi("/flows/dump", {
|
||||
method: 'post',
|
||||
body: data
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
export var Query = {
|
||||
SEARCH: "s",
|
||||
HIGHLIGHT: "h",
|
||||
|
||||
@@ -7,6 +7,7 @@ export const UPDATE_FILTER = 'FLOWS_UPDATE_FLOW_FILTER'
|
||||
export const UPDATE_HIGHLIGHT = 'FLOWS_UPDATE_FLOW_HIGHLIGHT'
|
||||
export const UPDATE_SORT = 'FLOWS_UPDATE_FLOW_SORT'
|
||||
export const SELECT = 'FLOWS_SELECT'
|
||||
export const REQUEST_ACTION = 'FLOWS_REQUEST_ACTION'
|
||||
|
||||
const defaultState = {
|
||||
selected: [],
|
||||
@@ -121,6 +122,88 @@ export function fetchData() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export function accept(flow) {
|
||||
fetch(`/flows/${flow.id}/accept`, { method: 'POST' })
|
||||
return { type: REQUEST_ACTION }
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export function acceptAll() {
|
||||
fetch('/flows/accept', { method: 'POST' })
|
||||
return { type: REQUEST_ACTION }
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export function delete(flow) {
|
||||
fetch(`/flows/${flow.id}`, { method: 'DELETE' })
|
||||
return { type: REQUEST_ACTION }
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export function duplicate(flow) {
|
||||
fetch(`/flows/${flow.id}/duplicate`, { method: 'POST' })
|
||||
return { type: REQUEST_ACTION }
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export function replay(flow) {
|
||||
fetch(`/flows/${flow.id}/replay`, { method: 'POST' })
|
||||
return { type: REQUEST_ACTION }
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export function revert(flow) {
|
||||
fetch(`/flows/${flow.id}/revert`, { method: 'POST' })
|
||||
return { type: REQUEST_ACTION }
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export function update(flow, body) {
|
||||
fetch(`/flows/${flow.id}`, { method: 'PUT', body })
|
||||
return { type: REQUEST_ACTION }
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export function clear() {
|
||||
fetch('/clear', { method: 'POST' })
|
||||
return { type: REQUEST_ACTION }
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export function download() {
|
||||
window.location = '/flows/dump'
|
||||
return { type: REQUEST_ACTION }
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export function upload(file) {
|
||||
const body = new FormData()
|
||||
body.append('file', file)
|
||||
fetch('/flows/dump', { method: 'post', body })
|
||||
return { type: REQUEST_ACTION }
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user