lml-main
Version:
This is now a mono repository published into many standalone packages.
49 lines • 2.16 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var redux_observable_1 = require("redux-observable");
var cosmoui_1 = require("cosmoui");
var actions_1 = require("../../allocation/actions");
var actions_2 = require("../actions");
exports.fetchJobsByStatusSuccess = function (action$, store) {
return action$.ofType(actions_2.FETCH_JOBS_BY_STATUS.SUCCESS)
.mergeMap(function (action) {
var res = [];
var _a = action.result, jobs = _a.jobs, scrMatches = _a.scrMatches, jobDelays = _a.jobDelays, jobStatuses = _a.jobStatuses, allocations = _a.allocations;
if (jobs) {
res.push(actions_2.setJobsByIdBatch(jobs));
}
if (jobStatuses) {
res.push(actions_2.setJobStatusSearch(jobStatuses, action.args.searchKey, action.args.params));
}
if (jobDelays) {
res.push(actions_2.setJobDelayBatch(jobDelays));
}
if (scrMatches) {
res.push(actions_2.setSmartMatchesBatch(scrMatches));
}
if (allocations && allocations.jobs) {
var parsedAllocations = Object.values(allocations.jobs).reduce(function (acc, curr) {
var actual = curr.actual, tag = curr.tag;
if (actual) {
acc.actual[actual.job.refId] = actual;
}
if (tag) {
acc.tag[tag.job.refId] = actual;
}
return acc;
}, {
actual: {},
tag: {}
});
res.push(actions_1.setAllocationsByIdBatch(parsedAllocations.actual));
res.push(actions_1.setTagsByIdBatch(parsedAllocations.tag));
}
return res;
});
};
exports.fetchJobsByStatusError = function (action$, store) {
return action$.ofType(actions_2.FETCH_JOBS_BY_STATUS.ERROR)
.mapTo(cosmoui_1.notificationError('There was a problem fetching jobs. Please refresh.'));
};
exports.fetchJobsByStatusEpics = redux_observable_1.combineEpics(exports.fetchJobsByStatusSuccess, exports.fetchJobsByStatusError);
//# sourceMappingURL=fetch-jobs-by-status.js.map