Sha256: 047c1258b9321e0576ae126740cfb7a6bd82a93ed0016548946783ca26fb4dce

Contents?: true

Size: 1.7 KB

Versions: 6

Compression:

Stored size: 1.7 KB

Contents

import API from 'foremanReact/API';
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: { accounts, autoUploadEnabled, hostObfuscationEnabled },
    } = await API.get(inventoryUrl('accounts'));
    dispatch({
      type: INVENTORY_ACCOUNT_STATUS_POLLING,
      payload: {
        accounts,
        autoUploadEnabled,
        hostObfuscationEnabled,
      },
    });
  } 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) => dispatch => {
  let processController = null;
  let processStatusName = null;

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

  API.post(inventoryUrl(`${accountID}/${processController}`));
  dispatch({
    type: INVENTORY_PROCESS_RESTART,
    payload: {
      accountID,
      processStatusName,
    },
  });
};

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
foreman_rh_cloud-2.0.9 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-1.0.9 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-0.9.9 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-0.9.8 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-1.0.8 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-2.0.8 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js