Selector to add primary and secondary to parent

Remove console log

Selector to add primary and secondary to parent
This commit is contained in:
JUDIT GRESKOVITS 2017-03-01 16:32:57 +00:00 committed by Judit Greskovits
parent ff2c70b7c5
commit 0f42f8021b
3 changed files with 53 additions and 26 deletions

View File

@ -667,7 +667,7 @@
"connections": [ "connections": [
"6a0eee76-c019-413b-9d5f-44712b55b993", "6a0eee76-c019-413b-9d5f-44712b55b993",
"6d31aff4-de1e-4042-a983-fbd23d5c530c", "6d31aff4-de1e-4042-a983-fbd23d5c530c",
"9572d367-c4ae-4fb1-8ad5-f5e3830e7034" "4ee4103e-1a52-4099-a48e-01588f597c70"
] ]
}, { }, {
"uuid": "6a0eee76-c019-413b-9d5f-44712b55b993", "uuid": "6a0eee76-c019-413b-9d5f-44712b55b993",

View File

@ -110,31 +110,58 @@ const servicesForTopology = (projectId) => createSelector(
[services, projectById(projectId)], [services, projectById(projectId)],
(services, project) => (services, project) =>
services.filter((s) => s.project === project.uuid) services.filter((s) => s.project === project.uuid)
.map((service) => ({ .reduce((acc, service, index, services) => {
...service, const getService = (s) => ({
uuid: service.uuid, ...s,
id: service.id, uuid: s.uuid,
name: service.name, id: s.id,
instances: instancesByServiceId(service.uuid).length, name: s.name,
connections: service.connections, instances: instancesByServiceId(s.uuid).length,
// tmp below connections: s.connections,
datacentres: 2, // tmp below
metrics: [ datacentres: 2,
{ metrics: [
name: 'CPU', {
value: '50%' name: 'CPU',
}, value: '50%'
{ },
name: 'Memory', {
value: '20%' name: 'Memory',
}, value: '20%'
{ },
name: 'Network', {
value: '2.9Kb/sec' name: 'Network',
value: '2.9Kb/sec'
}
],
healthy: true
});
const findService = (a, s, p) => s.uuid === p ? s : a;
if(service.parent) {
let parent = acc.reduce((a, s) =>
findService(a, s, service.parent), null);
if(!parent) {
parent = services.reduce((a, s) =>
findService(a, s, service.parent), null);
acc.push(parent);
} }
], if(!parent.children) {
healthy: true parent.children = [];
})) }
parent.children.push(
getService(service)
);
}
else {
const s = acc.reduce((a, s, i) => s.uuid === service.uuid, null);
if(!s) {
acc.push(
getService(service)
);
}
}
return acc;
}, [])
); );
const metricsByServiceId = (serviceId) => createSelector( const metricsByServiceId = (serviceId) => createSelector(

View File

@ -11,7 +11,7 @@ const StyledLine = styled.line`
const StyledCircle = styled.circle` const StyledCircle = styled.circle`
stroke: ${colors.base.secondaryActive}; stroke: ${colors.base.secondaryActive};
fill: colors.base.secondary; fill: ${colors.base.secondary};
stroke-width: 1.5; stroke-width: 1.5;
`; `;