Sha256: 52d10b748c06c33fbd4f01931bc77f5341394073a92acb7bbb5bae068b1bc3a7
Contents?: true
Size: 1.8 KB
Versions: 12
Compression:
Stored size: 1.8 KB
Contents
import API from 'foremanReact/API'; import { timeToHoursNumber, resolveQuery } from './TasksDashboardHelper'; import { FOREMAN_TASKS_DASHBOARD_INIT, FOREMAN_TASKS_DASHBOARD_UPDATE_TIME, FOREMAN_TASKS_DASHBOARD_UPDATE_QUERY, TASKS_DASHBOARD_CURRENT_TIME, FOREMAN_TASKS_DASHBOARD_FETCH_TASKS_SUMMARY_REQUEST, FOREMAN_TASKS_DASHBOARD_FETCH_TASKS_SUMMARY_SUCCESS, FOREMAN_TASKS_DASHBOARD_FETCH_TASKS_SUMMARY_FAILURE, } from './TasksDashboardConstants'; import { selectTime } from './TasksDashboardSelectors'; export const initializeDashboard = ({ time, query }) => ({ type: FOREMAN_TASKS_DASHBOARD_INIT, payload: { time, query }, }); export const updateTime = time => ({ type: FOREMAN_TASKS_DASHBOARD_UPDATE_TIME, payload: time, }); export const updateQuery = (query, history) => (dispatch, getState) => { if (query.time === TASKS_DASHBOARD_CURRENT_TIME) query.time = selectTime(getState()); resolveQuery(query, history); dispatch({ type: FOREMAN_TASKS_DASHBOARD_UPDATE_QUERY, payload: query, }); }; export const fetchTasksSummary = (time, parentTaskID) => async dispatch => { try { dispatch(startRequest()); const hours = timeToHoursNumber(time); const url = parentTaskID ? `/foreman_tasks/tasks/summary/${parentTaskID}/sub_tasks/${hours}` : `/foreman_tasks/tasks/summary/${hours}`; const { data } = await API.get(url); return dispatch(requestSuccess(data)); } catch (error) { return dispatch(requestFailure(error)); } }; const startRequest = () => ({ type: FOREMAN_TASKS_DASHBOARD_FETCH_TASKS_SUMMARY_REQUEST, }); const requestSuccess = data => ({ type: FOREMAN_TASKS_DASHBOARD_FETCH_TASKS_SUMMARY_SUCCESS, payload: data, }); const requestFailure = error => ({ type: FOREMAN_TASKS_DASHBOARD_FETCH_TASKS_SUMMARY_FAILURE, payload: error, });
Version data entries
12 entries across 12 versions & 1 rubygems