Sha256: c307da534cb1057cb8b4d08dc5253af2beb6a1911ee79c4fbd55ec86bb79dbd0

Contents?: true

Size: 1.79 KB

Versions: 19

Compression:

Stored size: 1.79 KB

Contents

import API from 'foremanReact/API';
import { addToast } from 'foremanReact/redux/actions/toasts';
import { inventoryUrl } from '../../ForemanInventoryHelpers';
import {
  INVENTORY_ACCOUNT_STATUS_POLLING,
  INVENTORY_ACCOUNT_STATUS_POLLING_ERROR,
  INVENTORY_ACCOUNT_STATUS_POLLING_START,
  INVENTORY_ACCOUNT_STATUS_POLLING_STOP,
  INVENTORY_PROCESS_RESTART,
} from './AccountListConstants';

export const fetchAccountsStatus = () => async dispatch => {
  try {
    const { data } = await API.get(inventoryUrl('accounts'));
    dispatch({
      type: INVENTORY_ACCOUNT_STATUS_POLLING,
      payload: data,
    });
  } catch (error) {
    dispatch({
      type: INVENTORY_ACCOUNT_STATUS_POLLING_ERROR,
      payload: {
        error: error.message,
      },
    });
  }
};

export const startAccountStatusPolling = pollingProcessID => ({
  type: INVENTORY_ACCOUNT_STATUS_POLLING_START,
  payload: {
    pollingProcessID,
  },
});

export const stopAccountStatusPolling = pollingProcessID => dispatch => {
  clearInterval(pollingProcessID);
  dispatch({
    type: INVENTORY_ACCOUNT_STATUS_POLLING_STOP,
  });
};

export const restartProcess = (accountID, activeTab) => async dispatch => {
  let processController = null;
  let processStatusName = null;

  if (activeTab === 'uploading') {
    processController = 'uploads';
    processStatusName = 'upload_report_status';
  } else {
    processController = 'reports';
    processStatusName = 'generate_report_status';
  }

  try {
    await API.post(inventoryUrl(`${accountID}/${processController}`));
    dispatch({
      type: INVENTORY_PROCESS_RESTART,
      payload: {
        accountID,
        processStatusName,
      },
    });
  } catch (error) {
    dispatch(
      addToast({
        sticky: true,
        type: 'error',
        message: error.message,
      })
    );
  }
};

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
foreman_rh_cloud-2.0.18.1 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-1.0.18 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-2.0.18 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-1.0.17 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-2.0.17 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-2.0.16 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-1.0.16 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-1.0.15 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-2.0.15 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-3.0.14 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-2.0.14 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-1.0.14 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-0.9.14 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-0.9.13.1 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-1.0.13.1 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-2.0.13.1 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-0.9.13 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-1.0.13 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-2.0.13 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js