Sha256: f65891542d724c103f7d9fc57fde5f508e229bdc0059f26910955be6e8b49ae1

Contents?: true

Size: 1.51 KB

Versions: 15

Compression:

Stored size: 1.51 KB

Contents

import API from 'foremanReact/API';
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 },
    } = await API.get('accounts');
    dispatch({
      type: INVENTORY_ACCOUNT_STATUS_POLLING,
      payload: {
        accounts,
      },
    });
  } 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(`${accountID}/${processController}`);
  dispatch({
    type: INVENTORY_PROCESS_RESTART,
    payload: {
      accountID,
      processStatusName,
    },
  });
};

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
foreman_rh_cloud-0.9.4.1 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-1.0.4.1 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-1.0.4 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-2.0.4 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_rh_cloud-0.9.4 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_inventory_upload-2.0.4.pre.2 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_inventory_upload-2.0.4.pre.1 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_inventory_upload-2.0.3 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_inventory_upload-1.0.3 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_inventory_upload-0.9.2 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_inventory_upload-1.0.2 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_inventory_upload-0.9.1 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_inventory_upload-1.0.1 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_inventory_upload-0.9.0 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js
foreman_inventory_upload-1.0.0 webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js