Sha256: 69a11e2cd6ae08c69e22a5c64337288860a65ff63cd210912eba4abbe36c3eb2

Contents?: true

Size: 1.8 KB

Versions: 36

Compression:

Stored size: 1.8 KB

Contents

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

36 entries across 36 versions & 1 rubygems

Version Path
foreman_rh_cloud-4.0.36 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-3.0.33 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-4.0.35 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-3.0.32 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-4.0.32 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-4.0.31 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-4.0.30 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-3.0.29 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-4.0.29 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-5.0.29 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-3.0.28 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-5.0.28 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-4.0.27 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-3.0.26 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-4.0.26 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-4.0.25.1 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-3.0.25 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-4.0.25 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-3.0.24.1 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-4.0.24.1 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js