'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _reactRedux = require('react-redux');
var _queryString = require('query-string');
var _queryString2 = _interopRequireDefault(_queryString);
var _JobMonitoring = require('../../../../generic/components/steps/JobMonitoring');
var _JobMonitoring2 = _interopRequireDefault(_JobMonitoring);
var _getNetworkError = require('../../../../../utils/getNetworkError');
var _getNetworkError2 = _interopRequireDefault(_getNetworkError);
var _getDisabledButtons = require('../../../../../utils/getDisabledButtons');
var _get = require('../../../../../utils/get');
var _get2 = _interopRequireDefault(_get);
var _redux = require('../../../../../redux');
var _projects = require('../../../../../redux/actions/projects');
var SimActions = _interopRequireWildcard(_projects);
function _interopRequireWildcard(obj) { Eif (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// ----------------------------------------------------------------------------
function getActions(props) {
var taskflow = props.taskflow;
var jobs = Object.keys(taskflow.jobMapById).map(function (id) {
return taskflow.jobMapById[id];
});
var actions = [];
taskflow.actions.forEach(function (action) {
actions.push(action);
});
// name is paraview and status is running -> visualize
if (jobs.some(function (job) {
return job.name === props.primaryJob && job.status === 'running';
})) {
actions.push('visualize');
} else if (taskflow.allComplete) {
actions.push('rerun');
}
return actions;
}
// ----------------------------------------------------------------------------
function onVisualize(props) {
var location = {
pathname: props.location.pathname,
search: _queryString2.default.stringify(Object.assign({}, _queryString2.default.parse(props.location.search), {
view: 'visualizer'
})),
state: props.location.state
};
(0, _redux.dispatch)(SimActions.saveSimulation(props.simulation, null, location));
}
// ----------------------------------------------------------------------------
exports.default = (0, _reactRedux.connect)(function (state, props) {
var taskflowId = null;
var activeProject = state.projects.active;
var activeSimulation = activeProject ? state.projects.simulations[activeProject].active : null;
if (activeSimulation) {
var simulation = state.simulations.mapById[activeSimulation];
taskflowId = simulation.steps.Visualization.metadata.taskflowId;
}
var taskflow = null;
if (taskflowId) {
taskflow = state.taskflows.mapById[taskflowId];
}
var cluster = null;
if ((0, _get2.default)(taskflow, 'flow.meta.cluster._id')) {
var clusterId = taskflow.flow.meta.cluster._id;
cluster = state.preferences.clusters.mapById[clusterId];
}
return {
getActions: getActions,
taskflow: taskflow,
taskflowId: taskflowId,
cluster: cluster,
disabledButtons: (0, _getDisabledButtons.getDisabledButtons)(state.network, taskflow),
error: (0, _getNetworkError2.default)(state, ['terminate_taskflow', 'delete_taskflow']),
actionFunctions: { onVisualize: onVisualize }
};
})(_JobMonitoring2.default);
|