mirror of
https://github.com/He4eT/simple-spaceapi.git
synced 2026-05-05 01:47:24 +00:00
SpaceAPI: network traffic sensor
This commit is contained in:
parent
a5fd0ccdc2
commit
30e06880e0
1 changed files with 35 additions and 7 deletions
|
|
@ -309,14 +309,16 @@ export default ({ strapi }: { strapi: Core.Strapi }) => ({
|
||||||
[
|
[
|
||||||
'machines',
|
'machines',
|
||||||
],
|
],
|
||||||
)).map((connection: {machines: Array<{name?: string, mac?: string}>}) => {
|
)).map((sensor: {machines: Array<{name?: string, mac?: string}>}) => {
|
||||||
if (!isEmpty(connection.machines)) {
|
if (!isEmpty(sensor.machines)) {
|
||||||
connection.machines = connection.machines.map(pickFields([
|
sensor.machines = sensor.machines.map(pickFields([
|
||||||
'name',
|
'name',
|
||||||
'mac',
|
'mac',
|
||||||
]));
|
]));
|
||||||
|
} else {
|
||||||
|
delete sensor.machines;
|
||||||
}
|
}
|
||||||
return connection;
|
return sensor;
|
||||||
});
|
});
|
||||||
|
|
||||||
const accountBalanceSensors = await getSensors(
|
const accountBalanceSensors = await getSensors(
|
||||||
|
|
@ -355,10 +357,9 @@ export default ({ strapi }: { strapi: Core.Strapi }) => ({
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
const networkTrafficSensors = await getSensors(
|
const networkTrafficSensors = (await getSensors(
|
||||||
'api::network-traffic-sensor.network-traffic-sensor',
|
'api::network-traffic-sensor.network-traffic-sensor',
|
||||||
[
|
[
|
||||||
'TODO',
|
|
||||||
'properties',
|
'properties',
|
||||||
'value',
|
'value',
|
||||||
'location',
|
'location',
|
||||||
|
|
@ -367,7 +368,34 @@ export default ({ strapi }: { strapi: Core.Strapi }) => ({
|
||||||
'description',
|
'description',
|
||||||
'lastchange',
|
'lastchange',
|
||||||
],
|
],
|
||||||
);
|
[
|
||||||
|
'properties.bits_per_second',
|
||||||
|
'properties.packets_per_second',
|
||||||
|
],
|
||||||
|
)).map((sensor: {properties: {bits_per_second: any, packets_per_second: any}}) => {
|
||||||
|
if (!isEmpty(sensor.properties)) {
|
||||||
|
delete sensor.properties['id'];
|
||||||
|
if (!isEmpty(sensor.properties.bits_per_second)) {
|
||||||
|
sensor.properties.bits_per_second = pickFields([
|
||||||
|
'value',
|
||||||
|
'maximum',
|
||||||
|
])(sensor.properties.bits_per_second);
|
||||||
|
} else {
|
||||||
|
delete sensor.properties.bits_per_second;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isEmpty(sensor.properties.packets_per_second)) {
|
||||||
|
sensor.properties.packets_per_second = pickFields([
|
||||||
|
'value',
|
||||||
|
])(sensor.properties.packets_per_second);
|
||||||
|
} else {
|
||||||
|
delete sensor.properties.packets_per_second;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
delete sensor.properties;
|
||||||
|
}
|
||||||
|
return sensor;
|
||||||
|
});
|
||||||
|
|
||||||
const sensors = {
|
const sensors = {
|
||||||
temperature: temperatureSensors,
|
temperature: temperatureSensors,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue