format selectors

This commit is contained in:
Sérgio Ramos 2017-02-07 15:53:42 +00:00
parent 666a031eb3
commit b6c1d6aa2a

View File

@ -67,30 +67,30 @@ const isCollapsed = (collapsed, uuid) => collapsed.indexOf(uuid) >= 0;
const datasets = (metricsData, serviceOrInstanceMetrics, metricsUI) => const datasets = (metricsData, serviceOrInstanceMetrics, metricsUI) =>
serviceOrInstanceMetrics.map((soim) => ({ serviceOrInstanceMetrics.map((soim) => ({
...find(metricsData.datasets, [ 'uuid', soim.dataset ]), ...find(metricsData.datasets, ['uuid', soim.dataset]),
type: find(metricsData.types, [ 'id', soim.type ]), type: find(metricsData.types, ['id', soim.type]),
...metricsUI[soim.dataset] ...metricsUI[soim.dataset]
})); }));
const servicesByProjectId = (projectId) => createSelector( const servicesByProjectId = (projectId) => createSelector(
[services, projectById(projectId), collapsedServices, metricsData, metricsUI], [services, projectById(projectId), collapsedServices, metricsData, metricsUI],
(services, project, collapsed, metrics, metricsUI) => (services, project, collapsed, metrics, metricsUI) =>
services.filter((s) => s.project === project.uuid) services.filter((s) => s.project === project.uuid)
.map((service) => ({ .map((service) => ({
...service, ...service,
services: services.filter((s) => s.parent === service.uuid) services: services.filter((s) => s.parent === service.uuid)
})) }))
.filter((s) => !s.parent) .filter((s) => !s.parent)
.map((service) => ({ .map((service) => ({
...service,
metrics: datasets(metrics, service.metrics, metricsUI),
collapsed: isCollapsed(collapsed, service.uuid),
services: service.services.map((service) => ({
...service, ...service,
metrics: datasets(metrics, service.metrics, metricsUI), metrics: datasets(metrics, service.metrics, metricsUI),
collapsed: isCollapsed(collapsed, service.uuid), collapsed: isCollapsed(collapsed, service.uuid)
services: service.services.map((service) => ({
...service,
metrics: datasets(metrics, service.metrics, metricsUI),
collapsed: isCollapsed(collapsed, service.uuid)
}))
})) }))
}))
); );
const instancesByServiceId = (serviceId) => createSelector( const instancesByServiceId = (serviceId) => createSelector(
@ -102,12 +102,12 @@ const instancesByServiceId = (serviceId) => createSelector(
metricsUI metricsUI
], ],
(instances, service, collapsed, metrics, metricsUI) => (instances, service, collapsed, metrics, metricsUI) =>
instances.filter((i) => i.service === service.uuid) instances.filter((i) => i.service === service.uuid)
.map((instance) => ({ .map((instance) => ({
...instance, ...instance,
metrics: datasets(metrics, instance.metrics, metricsUI), metrics: datasets(metrics, instance.metrics, metricsUI),
collapsed: isCollapsed(collapsed, instance.uuid) collapsed: isCollapsed(collapsed, instance.uuid)
})) }))
); );
const metricsByServiceId = (serviceId) => createSelector( const metricsByServiceId = (serviceId) => createSelector(
@ -124,16 +124,17 @@ const metricTypeByUuid = (metricTypeUuid) => createSelector(
const instancesByProjectId = (projectId) => createSelector( const instancesByProjectId = (projectId) => createSelector(
[instances, projectById(projectId), collapsedInstances, metricsData], [instances, projectById(projectId), collapsedInstances, metricsData],
(instances, project, collapsed, metrics) => (instances, project, collapsed, metrics) =>
instances.filter((i) => i.project === project.uuid) instances.filter((i) => i.project === project.uuid)
.map((instance) => ({ .map((instance) => ({
...instance, ...instance,
metrics: datasets(metrics, instance.metrics), metrics: datasets(metrics, instance.metrics),
collapsed: isCollapsed(collapsed, instance.uuid) collapsed: isCollapsed(collapsed, instance.uuid)
})) }))
); );
const peopleByOrgId = (orgId) => createSelector( const peopleByOrgId = (orgId) => createSelector(
[members, orgById(orgId)], (members, org) => { [members, orgById(orgId)],
(members, org) => {
const matched = []; const matched = [];
if (Object.keys(org.members).length > 0) { if (Object.keys(org.members).length > 0) {
org.members.filter((m) => { org.members.filter((m) => {
@ -148,7 +149,8 @@ const peopleByOrgId = (orgId) => createSelector(
); );
const peopleByProjectId = (projectId) => createSelector( const peopleByProjectId = (projectId) => createSelector(
[members, projectById(projectId)], (members, prj) => { [members, projectById(projectId)],
(members, prj) => {
const matched = []; const matched = [];
if (Object.keys(prj.members).length > 0) { if (Object.keys(prj.members).length > 0) {
prj.members.filter((m) => { prj.members.filter((m) => {
@ -187,4 +189,4 @@ module.exports = {
peopleByProjectIdSelector: peopleByProjectId, peopleByProjectIdSelector: peopleByProjectId,
projectUISelector: projectsUI, projectUISelector: projectsUI,
projectIndexByIdSelect: projectIndexById, projectIndexByIdSelect: projectIndexById,
}; };