Sha256: 63ccb9bcef1c20c6f1dce109a70aa79aa5b8ad6a50555c4b61a4b8a912c00879

Contents?: true

Size: 1.41 KB

Versions: 58

Compression:

Stored size: 1.41 KB

Contents

import { selectForemanTasks } from '../../ForemanTasksSelectors';
import {
  TASKS_DASHBOARD_AVAILABLE_TIMES,
  TASKS_SUMMARY_ZERO,
} from './TasksDashboardConstants';

export const selectTasksDashboard = state =>
  selectForemanTasks(state).tasksDashboard || {};

export const selectTime = state =>
  selectTasksDashboard(state).time || TASKS_DASHBOARD_AVAILABLE_TIMES.H24;

export const selectQuery = state => selectTasksDashboard(state).query || {};

export const calcStoppedOther = data =>
  (data?.cancelled?.total || 0) + (data?.pending?.total || 0);

export const selectTasksSummary = state => {
  const { running, paused, stopped, scheduled } =
    selectTasksDashboard(state).tasksSummary || TASKS_SUMMARY_ZERO;

  return {
    running: {
      last: running.recent,
      older: running.total - running.recent,
    },
    paused: {
      last: paused.recent,
      older: paused.total - paused.recent,
    },
    stopped: {
      results: {
        error: {
          total: stopped.by_result.error.total,
          last: stopped.by_result.error.recent,
        },
        warning: {
          total: stopped.by_result.warning.total,
          last: stopped.by_result.warning.recent,
        },
        success: {
          total: stopped.by_result.success.total,
          last: stopped.by_result.success.recent,
        },
      },
      other: calcStoppedOther(stopped.by_result),
    },
    scheduled: scheduled.total,
  };
};

Version data entries

58 entries across 58 versions & 1 rubygems

Version Path
foreman-tasks-5.2.0 webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardSelectors.js
foreman-tasks-5.1.1 webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardSelectors.js
foreman-tasks-5.1.0 webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardSelectors.js
foreman-tasks-4.1.5 webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardSelectors.js
foreman-tasks-4.1.4 webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardSelectors.js
foreman-tasks-4.1.3 webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardSelectors.js
foreman-tasks-3.0.6 webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardSelectors.js
foreman-tasks-5.0.0 webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardSelectors.js
foreman-tasks-4.1.2 webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardSelectors.js
foreman-tasks-4.1.1 webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardSelectors.js
foreman-tasks-4.0.1 webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardSelectors.js
foreman-tasks-4.1.0 webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardSelectors.js
foreman-tasks-3.0.5 webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardSelectors.js
foreman-tasks-4.0.0 webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardSelectors.js
foreman-tasks-3.0.4 webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardSelectors.js
foreman-tasks-3.0.3 webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardSelectors.js
foreman-tasks-3.0.2 webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardSelectors.js
foreman-tasks-3.0.1 webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardSelectors.js