Sha256: da36cb5d222a72e2292d6f7fa5c14b0b9e38c2ea6288e86672f3dc14820b050f

Contents?: true

Size: 1.8 KB

Versions: 47

Compression:

Stored size: 1.8 KB

Contents

import { API } from 'foremanReact/redux/API';
import { addToast } from 'foremanReact/components/ToastsList';
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

47 entries across 47 versions & 1 rubygems

Version Path
foreman_rh_cloud-9.0.59 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-11.0.2 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-11.0.1 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-11.0.0 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-9.0.58 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-10.0.2 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-9.0.57 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-10.0.1 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-9.0.56 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-9.0.55 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-9.0.54 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-9.0.53 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-9.0.52 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-8.0.52 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-9.0.51 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-8.0.51 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-7.0.48 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-7.0.47 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-8.0.50 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-8.0.49 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js