utils#getDataFailedRequest JavaScript Examples
The following examples show how to use
utils#getDataFailedRequest.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: actions.js From dstack-server with Apache License 2.0 | 6 votes |
fetch = (userName, id, onSuccess: Function) => async (dispatch: Function) => {
dispatch({type: actionsTypes.FETCH});
try {
const request = await api.get(config.DASHBOARD_DETAILS(userName, id));
dispatch({
type: actionsTypes.FETCH_SUCCESS,
payload: request.data.dashboard,
});
if (onSuccess)
onSuccess(request.data);
} catch (e) {
dispatch({
type: actionsTypes.FETCH_FAIL,
payload: getDataFailedRequest(e),
});
}
}
Example #2
Source File: actions.js From dstack-server with Apache License 2.0 | 6 votes |
create = (userName, onSuccess: Function) => async (dispatch: Function) => {
dispatch({type: actionsTypes.CREATE});
try {
const request = await api.post(config.DASHBOARD_CREATE, {user: userName});
dispatch({type: actionsTypes.CREATE_SUCCESS});
dispatch({
type: actionsTypes.FETCH_SUCCESS,
payload: request.data.dashboard,
});
if (onSuccess)
onSuccess(request.data);
} catch (e) {
dispatch({
type: actionsTypes.CREATE_FAIL,
payload: getDataFailedRequest(e),
});
}
}
Example #3
Source File: actions.js From dstack-server with Apache License 2.0 | 6 votes |
update = (params, onSuccess: Function) => async (dispatch: Function) => {
dispatch({type: actionsTypes.UPDATE});
try {
const request = await api.post(config.DASHBOARD_UPDATE, params);
dispatch({
type: actionsTypes.UPDATE_SUCCESS,
payload: params,
});
if (onSuccess)
onSuccess(request.data);
} catch (e) {
dispatch({
type: actionsTypes.UPDATE_FAIL,
payload: getDataFailedRequest(e),
});
}
}
Example #4
Source File: actions.js From dstack-server with Apache License 2.0 | 6 votes |
deleteDashboard = (params, onSuccess: Function) => async (dispatch: Function) => {
dispatch({type: actionsTypes.DELETE});
try {
await api.post(config.DASHBOARD_DELETE, params);
dispatch({
type: actionsTypes.DELETE_SUCCESS,
payload: params,
});
if (onSuccess)
onSuccess();
} catch (e) {
dispatch({
type: actionsTypes.DELETE_FAIL,
payload: getDataFailedRequest(e),
});
}
}
Example #5
Source File: actions.js From dstack-server with Apache License 2.0 | 6 votes |
insertCard = (params, onSuccess: Function) => async (dispatch: Function) => {
dispatch({type: actionsTypes.CARDS_INSERT});
try {
const response = await api.post(config.DASHBOARD_CARDS_INSERT + '?attachments=true', params);
const {cards} = response.data.dashboard;
dispatch({
type: actionsTypes.CARDS_INSERT_SUCCESS,
payload: cards,
});
if (onSuccess)
onSuccess();
} catch (e) {
dispatch({
type: actionsTypes.CARDS_INSERT_FAIL,
payload: getDataFailedRequest(e),
});
}
}
Example #6
Source File: actions.js From dstack-server with Apache License 2.0 | 6 votes |
updateCard = (params, onSuccess: Function) => async (dispatch: Function, getState: Function) => {
const oldCards = getState().dashboards.details.data.cards;
dispatch({type: actionsTypes.CARDS_UPDATE});
try {
await api.post(config.DASHBOARD_CARDS_UPDATE, params);
dispatch({
type: actionsTypes.CARDS_UPDATE_SUCCESS,
payload: params,
});
if (onSuccess)
onSuccess();
} catch (e) {
console.log(oldCards, getState());
dispatch({
type: actionsTypes.CARDS_UPDATE_FAIL,
payload: {...getDataFailedRequest(e), cards: oldCards},
});
}
}
Example #7
Source File: actions.js From dstack-server with Apache License 2.0 | 6 votes |
deleteCard = (params, onSuccess: Function) => async (dispatch: Function) => {
dispatch({type: actionsTypes.CARDS_DELETE});
try {
await api.post(config.DASHBOARD_CARDS_DELETE, params);
dispatch({
type: actionsTypes.CARDS_DELETE_SUCCESS,
payload: params.stack,
});
if (onSuccess)
onSuccess();
} catch (e) {
dispatch({
type: actionsTypes.CARDS_DELETE_FAIL,
payload: getDataFailedRequest(e),
});
}
}
Example #8
Source File: actions.js From dstack-server with Apache License 2.0 | 6 votes |
fetchList = (userName, onSuccess: Function) => async (dispatch: Function) => {
dispatch({type: actionsTypes.FETCH});
try {
const request = await api.get(config.DASHBOARD_LIST(userName));
dispatch({
type: actionsTypes.FETCH_SUCCESS,
payload: request.data.dashboards,
});
if (onSuccess)
onSuccess();
} catch (e) {
dispatch({
type: actionsTypes.FETCH_FAIL,
payload: getDataFailedRequest(e),
});
}
}
Example #9
Source File: actions.js From dstack-server with Apache License 2.0 | 6 votes |
updateSettings = ({user, ...params}) => async (dispatch: Function) => {
dispatch({type: actionsTypes.UPDATE});
try {
const request = await api.post(config.UPDATE_SETTINGS_URL, {
user,
...params,
});
dispatch({
type: actionsTypes.UPDATE_SUCCESS,
payload: request.data,
});
} catch (e) {
dispatch({
type: actionsTypes.UPDATE_FAIL,
payload: getDataFailedRequest(e),
});
}
}
Example #10
Source File: actions.js From dstack-server with Apache License 2.0 | 6 votes |
fetchDetails = (userName, stack, attachmentFrame, onSuccess?: Function) => async (dispatch: Function) => {
dispatch({type: actionsTypes.FETCH});
try {
const request = await api.get(config.STACK_DETAILS(userName, stack));
dispatch({
type: actionsTypes.FETCH_SUCCESS,
payload: request.data.stack,
meta: {stack: `${userName}/${stack}`},
});
if (!attachmentFrame)
dispatch({
type: actionsTypes.FETCH_FRAME_SUCCESS,
payload: request.data.stack.head,
});
if (onSuccess)
onSuccess();
} catch (e) {
dispatch({
type: actionsTypes.FETCH_FAIL,
payload: getDataFailedRequest(e),
});
}
}
Example #11
Source File: actions.js From dstack-server with Apache License 2.0 | 6 votes |
fetchFrame = (userName, stack, frameId, onSuccess?: Function) => async (dispatch: Function) => {
dispatch({type: actionsTypes.FETCH_FRAME});
try {
const request = await api.get(config.STACK_FRAME(userName, stack, frameId));
dispatch({
type: actionsTypes.FETCH_FRAME_SUCCESS,
payload: request.data.frame,
});
if (onSuccess)
onSuccess();
} catch (e) {
dispatch({
type: actionsTypes.FETCH_FRAME_FAIL,
payload: getDataFailedRequest(e),
});
}
}
Example #12
Source File: actions.js From dstack-server with Apache License 2.0 | 6 votes |
update = ({stack, noUpdateStore, ...params}, onSuccess?: Function) =>
async (dispatch: Function, getState: Function) => {
const oldData = getState().stacks.details.data;
dispatch({
type: actionsTypes.UPDATE,
payload: !noUpdateStore ? params : {},
meta: {stack},
});
try {
await api.post(config.STACK_UPDATE, {
stack,
...params,
});
dispatch({
type: actionsTypes.UPDATE_SUCCESS,
meta: {stack},
});
if (onSuccess)
onSuccess();
} catch (e) {
dispatch({
type: actionsTypes.FETCH_FAIL,
payload: {...getDataFailedRequest(e), data: oldData},
meta: {stack},
});
}
}