feat: upd ASC_CM_476

main
Artem-Darius Weber 1 year ago
parent 709efb3f01
commit b834899df4

@ -6,8 +6,15 @@
<component name="ChangeListManager">
<list default="true" id="fa9b3ab0-bfd5-4e07-8e87-da3d901a4d2e" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
<change beforePath="$PROJECT_DIR$/weather_platform/apps/agw/src/measures/measures.controller.ts" beforeDir="false" afterPath="$PROJECT_DIR$/weather_platform/apps/agw/src/measures/measures.controller.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/weather_platform/apps/py-tg-bot-weather-agent/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/weather_platform/apps/py-tg-bot-weather-agent/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/weather_platform/package-lock.json" beforeDir="false" afterPath="$PROJECT_DIR$/weather_platform/package-lock.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/weather_platform/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/weather_platform/package.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/weather_platform/pages/src/lib/dashboard/dashboard.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/weather_platform/pages/src/lib/dashboard/dashboard.tsx" afterDir="false" />
<change beforePath="$PROJECT_DIR$/weather_platform/ui-modules/src/index.ts" beforeDir="false" afterPath="$PROJECT_DIR$/weather_platform/ui-modules/src/index.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/weather_platform/ui-modules/src/lib/sensors-humidity-graph/sensors-humidity-graph.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/weather_platform/ui-modules/src/lib/sensors-humidity-graph/sensors-humidity-graph.tsx" afterDir="false" />
<change beforePath="$PROJECT_DIR$/weather_platform/ui-modules/src/lib/sensors-temperature-graph/sensors-temperature-graph.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/weather_platform/ui-modules/src/lib/sensors-temperature-graph/sensors-temperature-graph.tsx" afterDir="false" />
<change beforePath="$PROJECT_DIR$/weather_platform/ui/src/index.ts" beforeDir="false" afterPath="$PROJECT_DIR$/weather_platform/ui/src/index.ts" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -19,11 +26,15 @@
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"last_opened_file_path": "/Users/darius/Desktop/ASC/CyberGarden/kempt-kinkajou/weather_platform/ui-modules/src/lib/potantial-probleme-sensors-table",
"node.js.selected.package.tslint": "(autodetect)",
"ts.external.directory.path": "/Users/darius/Desktop/ASC/CyberGarden/kempt-kinkajou/weather_platform/node_modules/typescript/lib"
}
}]]></component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/weather_platform/ui-modules/src/lib/potantial-probleme-sensors-table" />
</key>
<key name="MoveFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/assets" />
</key>

@ -18,6 +18,21 @@ import {Measures} from "@weather-platform/prisma-clients/Measures";
// eslint-disable-next-line @nx/enforce-module-boundaries
import {MeasureGetDTOClass} from "../../../measures-service/src/DTO/MeasureGetDTOClass.dto";
function calculateTemperature(ThermistorPin: number): number {
const R1 = 10000; // Value of R1 on the module
const c1 = 0.001129148;
const c2 = 0.000234125;
const c3 = 0.0000000876741;
const Vo: number = ThermistorPin;
const R2: number = R1 * (1023.0 / Vo - 1.0); // Calculate the resistance on the thermistor
const logR2: number = Math.log(R2);
let T: number = 1.0 / (c1 + c2 * logR2 + c3 * logR2 * logR2 * logR2); // Temperature in Kelvin
T = T - 273.15; // Convert Kelvin to Celsius
return T;
}
@Controller('measures')
export class MeasuresController {
constructor(
@ -78,6 +93,10 @@ export class MeasuresController {
@Param('msg_value') msg_value: string,
): Promise<Partial<MeasuresCreateSuccessResponse> | null> {
if (msg_type === 'temperature') {
msg_value = calculateTemperature(Number(msg_value)).toString();
}
const measure_create_data: MeasureCreateDTOLocalClass = {
sendedInDate: sendedInDate,
sensor_uuid: sensor_uuid,

@ -12,7 +12,7 @@ from langchain.agents import create_json_agent, AgentExecutor
from langchain.agents.agent_toolkits import JsonToolkit
import os
OPENAI_API = "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"
OPENAI_API = "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"
os.environ["LANGCHAIN_TRACING_V2"] = "true"
os.environ["LANGCHAIN_ENDPOINT"] = "https://api.smith.langchain.com"
@ -59,7 +59,7 @@ def fetch_get_weather_data(params={}):
response = requests.get(AGW_URL + 'api/v1/measures/get-for-ai')
response.raise_for_status()
data = response.json()
return data[0]
return data[-10:]
except requests.exceptions.RequestException as e:
print('Error fetching data:', e)
return None

@ -16,6 +16,7 @@
"@nestjs/swagger": "^7.1.13",
"@nx/devkit": "16.10.0",
"@nx/plugin": "^16.10.0",
"@pbe/react-yandex-maps": "^1.2.5",
"@prisma/client": "^5.4.1",
"@swc/helpers": "~0.5.2",
"axios": "^1.0.0",
@ -4346,6 +4347,20 @@
"url": "https://opencollective.com/parcel"
}
},
"node_modules/@pbe/react-yandex-maps": {
"version": "1.2.5",
"resolved": "https://registry.npmjs.org/@pbe/react-yandex-maps/-/react-yandex-maps-1.2.5.tgz",
"integrity": "sha512-cBojin5e1fPx9XVCAqHQJsCnHGMeBNsP0TrNfpWCrPFfxb30ye+JgcGr2mn767Gbr1d+RufBLRiUcX2kaiAwjQ==",
"dependencies": {
"@types/yandex-maps": "2.1.29"
},
"engines": {
"node": ">=16"
},
"peerDependencies": {
"react": "^16.x || ^17.x || ^18.x"
}
},
"node_modules/@phenomnomnominal/tsquery": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/@phenomnomnominal/tsquery/-/tsquery-5.0.1.tgz",
@ -5739,6 +5754,11 @@
"@types/node": "*"
}
},
"node_modules/@types/yandex-maps": {
"version": "2.1.29",
"resolved": "https://registry.npmjs.org/@types/yandex-maps/-/yandex-maps-2.1.29.tgz",
"integrity": "sha512-nuibRWj3RU/9KXlCzTrRtDE+n6V9l7NbT9JakicqZ5OXIdwyb6blvV2Uwn6lB58WYm3DSUDP2I2AWlnWMc8z2w=="
},
"node_modules/@types/yargs": {
"version": "17.0.26",
"resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.26.tgz",

@ -12,6 +12,7 @@
"@nestjs/swagger": "^7.1.13",
"@nx/devkit": "16.10.0",
"@nx/plugin": "^16.10.0",
"@pbe/react-yandex-maps": "^1.2.5",
"@prisma/client": "^5.4.1",
"@swc/helpers": "~0.5.2",
"axios": "^1.0.0",

@ -1,15 +1,16 @@
import styles from './dashboard.module.scss';
import {
AgregatorCreateForm,
AgregatorTable,
SensorsHumidityGraph,
SensorsTemperatureGraph
AgregatorTable, PotantialProblemeSensorsTable,
SensorsHumidityGraph, SensorsLuminGraph,
SensorsTemperatureGraph, SensorsVebrationsGraph
} from "@weather-platform/ui-modules";
import {BaseLayout} from "@weather-platform/layout";
import {useEffect, useState} from "react";
import {Prisma, Measures} from "@weather-platform/prisma-clients/Measures";
import axios from "axios";
import {AGW_URL} from "../../../../agw";
import {SensorsOnMap} from "@weather-platform/ui";
/* eslint-disable-next-line */
export interface DashboardProps {}
@ -29,11 +30,21 @@ export function Dashboard(props: DashboardProps) {
const [dataTemperature, setDataTemperature] = useState<Measures[]>([]);
const [dataHumidity, setDataHumidity] = useState<Measures[]>([]);
const [dataBright, setDataBright] = useState<Measures[]>([]);
const [dataVibration, setDataVibration] = useState<Measures[]>([]);
const updateMeasureTmpData = async () => {
const response = await fetchGetMeasuresList({
where: {
type: 'temperature',
},
take: 120,
orderBy: {
time: 'desc',
},
select: {
type: true,
value: true,
}
});
if (response !== null) {
@ -45,6 +56,14 @@ export function Dashboard(props: DashboardProps) {
const response = await fetchGetMeasuresList({
where: {
type: 'humidity',
},
take: 120,
orderBy: {
time: 'desc',
},
select: {
type: true,
value: true,
}
});
if (response !== null) {
@ -52,9 +71,49 @@ export function Dashboard(props: DashboardProps) {
}
};
const updateMeasureBrightData = async () => {
const response = await fetchGetMeasuresList({
where: {
type: 'brighness',
},
take: 120,
orderBy: {
time: 'desc',
},
select: {
type: true,
value: true,
}
});
if (response !== null) {
setDataBright(response);
}
};
const updateMeasureVibrationData = async () => {
const response = await fetchGetMeasuresList({
where: {
type: 'vibration',
},
take: 120,
orderBy: {
time: 'desc',
},
select: {
type: true,
value: true,
}
});
if (response !== null) {
setDataVibration(response);
}
};
function upd() {
updateMeasureTmpData();
updateMeasureHumidityData();
updateMeasureBrightData();
updateMeasureVibrationData();
}
useEffect(() => {
@ -65,9 +124,21 @@ export function Dashboard(props: DashboardProps) {
return (
<BaseLayout>
<div className="flex px-4 py-2 w-full">
<SensorsTemperatureGraph data={dataTemperature}/>
<SensorsHumidityGraph data={dataHumidity}/>
<div className={'w-full h-full'}>
<div className="flex space-x-2 w-full h-[40%]">
<div className="w-2/3">
<SensorsOnMap/>
</div>
<div className="w-1/3">
<SensorsVebrationsGraph data={dataVibration}/>
</div>
</div>
<div className="flex px-4 space-x-2 my-4 py-2 w-full">
<SensorsTemperatureGraph data={dataTemperature}/>
<SensorsHumidityGraph data={dataHumidity}/>
<SensorsLuminGraph data={dataBright}/>
</div>
<PotantialProblemeSensorsTable/>
</div>
</BaseLayout>
);

@ -1,3 +1,6 @@
export * from './lib/sensors-vebrations-graph/sensors-vebrations-graph';
export * from './lib/potantial-probleme-sensors-table/potantial-probleme-sensors-table';
export * from './lib/sensors-lumin-graph/sensors-lumin-graph';
export * from './lib/sensors-humidity-graph/sensors-humidity-graph';
export * from './lib/sensors-temperature-graph/sensors-temperature-graph';
export * from './lib/sensors-table-item/sensors-table-item';

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

@ -0,0 +1,7 @@
/*
* Replace this with your own classes
*
* e.g.
* .container {
* }
*/

@ -0,0 +1,10 @@
import { render } from '@testing-library/react';
import PotantialProblemeSensorsTable from './potantial-probleme-sensors-table';
describe('PotantialProblemeSensorsTable', () => {
it('should render successfully', () => {
const { baseElement } = render(<PotantialProblemeSensorsTable />);
expect(baseElement).toBeTruthy();
});
});

@ -0,0 +1,191 @@
import styles from './potantial-probleme-sensors-table.module.scss';
import {Measures, Prisma} from "@weather-platform/prisma-clients/Measures";
import axios from "axios";
import {AGW_URL} from "../../../../agw";
import {useEffect, useState} from "react";
import AgregatorTableItem from "../agregator-table-item/agregator-table-item";
import OK from './ok-status.gif';
import { Chart as ChartJS, ArcElement, Tooltip, Legend } from 'chart.js';
import { Pie } from 'react-chartjs-2';
/* eslint-disable-next-line */
export interface PotantialProblemeSensorsTableProps {}
ChartJS.register(ArcElement, Tooltip, Legend);
export function PotantialProblemeSensorsTable(
props: PotantialProblemeSensorsTableProps
) {
const fetchGetMeasuresList = async (params: Prisma.MeasuresFindManyArgs = {}) => {
try {
const response = await axios.post( AGW_URL + '/api/v1/measures/get-with-params', params);
const data = response.data;
return data;
} catch (error) {
console.error('Error fetching data:', error);
return null;
}
};
const [measures, setMeasures] = useState<Measures[] | null>(null);
const twoHoursAgo = new Date(Date.now() - 2 * 60 * 60 * 1000);
const updateMeasureData = async () => {
const response = await fetchGetMeasuresList({
where: {
sensor_uuid: {
not: {
in: [],
},
},
time: {
gte: twoHoursAgo.toISOString(),
},
},
});
if (response !== null) {
setMeasures(response);
}
};
const [measuresCount, setMeasuresCount] = useState<number>(0);
const updateAllMeasureData = async () => {
const response = await fetchGetMeasuresList({
select: {
uuid: true,
}
});
if (response !== null) {
setMeasuresCount(response.length);
}
};
function upd() {
updateAllMeasureData();
updateMeasureData();
}
useEffect(() => {
upd();
const interval = setInterval(upd, 5000);
return () => clearInterval(interval);
}, []);
const data = {
labels: ['Fatal', 'Success'],
datasets: [
{
label: '# of Votes',
data: [measures?.length || 0, measuresCount],
backgroundColor: [
'rgba(255, 99, 132, 0.2)',
'rgba(54, 162, 235, 0.2)',
],
borderColor: [
'rgba(255, 99, 132, 1)',
'rgba(54, 162, 235, 1)',
],
borderWidth: 1,
},
],
};
return (
<div className="w-full px-4">
<h1 className={'text-center font-bold text-2xl'}>Incorect get data from Sensors</h1>
<div className="px-4 py-4 sm:-mx-8 sm:px-8 w-full flex space-x-2">
<div className="inline-block overflow-hidden rounded-lg shadow ring-1 ring-gray-100 w-3/4">
<table className="min-w-full leading-normal">
<thead>
<tr>
<th scope="col"
className="px-5 py-3 text-sm font-normal text-left text-gray-800 uppercase bg-white border-b border-gray-200">
Type / Value
</th>
<th scope="col"
className="px-5 py-3 text-sm font-normal text-left text-gray-800 uppercase bg-white border-b border-gray-200">
Last connection
</th>
<th scope="col"
className="px-5 py-3 text-sm font-normal text-left text-gray-800 uppercase bg-white border-b border-gray-200">
Sensor
</th>
<th scope="col"
className="px-5 py-3 text-sm font-normal text-left text-gray-800 uppercase bg-white border-b border-gray-200">
Created at
</th>
<th scope="col"
className="px-5 py-3 text-sm font-normal text-left text-gray-800 uppercase bg-white border-b border-gray-200">
status
</th>
</tr>
</thead>
<tbody>
{
measures?.map(
(measure, key) => (
<tr>
<td className="px-5 py-5 text-sm bg-white border-b border-gray-200">
<div className="ml-3">
<p className="text-gray-900 whitespace-no-wrap">
{ measure.type } / { measure.value }
</p>
</div>
</td>
<td className="px-5 py-5 text-sm bg-white border-b border-gray-200">
<p className="text-gray-900 whitespace-no-wrap">
{ measure.time.toString() }
</p>
</td>
<td className="px-5 py-5 text-sm bg-white border-b border-gray-200">
<p className="text-gray-900 whitespace-no-wrap">
<span
className="relative inline-block px-3 py-1 font-semibold leading-tight bg-gray-200 rounded-lg">
{ measure.sensor_uuid }
</span>
</p>
</td>
<td className="px-5 py-5 text-sm bg-white border-b border-gray-200">
<p className="text-gray-900 whitespace-no-wrap">
{ measure.createdAt.toString() }
</p>
</td>
<td className="px-5 py-5 text-sm bg-white border-b border-gray-200">
<span
className="relative inline-block px-3 py-1 font-semibold leading-tight text-green-900">
<span aria-hidden="true"
className="absolute inset-0 bg-green-200 rounded-full opacity-50">
</span>
<span className="relative">
deactive
</span>
</span>
</td>
</tr>
)
)
}
</tbody>
</table>
{
measures?.length === 0 && <div className={'flex items-center justify-center justify-items-center space-x-2 py-2 w-full'}>
<img src={OK} className={'h-6 w-6'} alt=""/>
<p>Notion not found. All sensors working correct!</p>
</div>
}
</div>
<div className="w-1/4">
<Pie data={data} />
</div>
</div>
</div>
);
}
export default PotantialProblemeSensorsTable;

@ -29,7 +29,7 @@ const options = {
},
title: {
display: true,
text: "Sensors Temperature Graph",
text: "Sensors Humidity Graph",
},
},
};
@ -47,6 +47,7 @@ export interface SensorsHumidityGraphProps {
export function SensorsHumidityGraph(props: SensorsHumidityGraphProps) {
const labels = props.data.map(item => parseInt(item.time));
const Humidities = props.data.map(item => parseInt(item.value));
Humidities.reverse();
const data = {
labels,

@ -0,0 +1,7 @@
/*
* Replace this with your own classes
*
* e.g.
* .container {
* }
*/

@ -0,0 +1,10 @@
import { render } from '@testing-library/react';
import SensorsLuminGraph from './sensors-lumin-graph';
describe('SensorsLuminGraph', () => {
it('should render successfully', () => {
const { baseElement } = render(<SensorsLuminGraph />);
expect(baseElement).toBeTruthy();
});
});

@ -0,0 +1,74 @@
import styles from './sensors-lumin-graph.module.scss';
import {
CategoryScale,
Chart as ChartJS,
Legend,
LinearScale,
LineElement,
PointElement,
Title,
Tooltip
} from "chart.js";
import {Line} from "react-chartjs-2";
ChartJS.register(
CategoryScale,
LinearScale,
PointElement,
LineElement,
Title,
Tooltip,
Legend,
);
const options = {
responsive: true,
plugins: {
legend: {
position: "top" as const,
},
title: {
display: true,
text: "Sensors Bright Graph",
},
},
};
interface DataPoint {
time: string;
value: string;
}
/* eslint-disable-next-line */
export interface SensorsLuminGraphProps {
data: DataPoint[];
}
export function SensorsLuminGraph(props: SensorsLuminGraphProps) {
const labels = props.data.map(item => parseInt(item.time));
const Lumen = props.data.map(item => parseInt(item.value));
Lumen.reverse();
const data = {
labels,
datasets: [
{
label: "Bright",
data: Lumen,
borderColor: 'rgb(255, 165, 0)',
backgroundColor: 'rgba(255, 165, 0, 0.5)',
},
],
};
return (
<div className={'w-1/3 '}>
<div className={'p-4 bg-white shadow-lg rounded-xl ring-1 ring-gray-100'}>
<Line options={options} data={data} />
</div>
</div>
);
}
export default SensorsLuminGraph;

@ -48,6 +48,7 @@ export function SensorsTemperatureGraph(props: SensorsTemperatureGraphProps) {
const labels = props.data.map(item => parseInt(item.time));
const temperatures = props.data.map(item => parseInt(item.value));
temperatures.reverse();
const data = {
labels,

@ -0,0 +1,7 @@
/*
* Replace this with your own classes
*
* e.g.
* .container {
* }
*/

@ -0,0 +1,10 @@
import { render } from '@testing-library/react';
import SensorsVebrationsGraph from './sensors-vebrations-graph';
describe('SensorsVebrationsGraph', () => {
it('should render successfully', () => {
const { baseElement } = render(<SensorsVebrationsGraph />);
expect(baseElement).toBeTruthy();
});
});

@ -0,0 +1,73 @@
import styles from './sensors-vebrations-graph.module.scss';
import {Line} from "react-chartjs-2";
import {
Chart as ChartJS,
CategoryScale,
LinearScale,
PointElement,
LineElement,
Title,
Tooltip,
Legend,
} from "chart.js";
ChartJS.register(
CategoryScale,
LinearScale,
PointElement,
LineElement,
Title,
Tooltip,
Legend,
);
export const options = {
responsive: true,
plugins: {
legend: {
position: "top" as const,
},
title: {
display: true,
text: "Sensors Vibration Graph",
},
},
};
interface DataPoint {
time: string;
value: string;
}
/* eslint-disable-next-line */
export interface SensorsVebrationsGraphProps {
data: DataPoint[];
}
export function SensorsVebrationsGraph(props: SensorsVebrationsGraphProps) {
const labels = props.data.map(item => parseInt(item.time));
const vibrations = props.data.map(item => parseInt(item.value));
vibrations.reverse();
const data = {
labels,
datasets: [
{
label: "Vibration",
data: vibrations,
borderColor: "rgb(255, 99, 132)",
backgroundColor: "rgba(255, 99, 132, 0.5)",
},
],
};
return (
<div className={'w-full h-full '}>
<div className={'p-4 bg-white shadow-lg rounded-xl ring-1 ring-gray-100'}>
<Line options={options} data={data} />
</div>
</div>
);
}
export default SensorsVebrationsGraph;

@ -1,2 +1,3 @@
export * from './lib/sensors-on-map/sensors-on-map';
export * from './lib/nav-link/nav-link';
export * from './lib/ui';

@ -0,0 +1,7 @@
/*
* Replace this with your own classes
*
* e.g.
* .container {
* }
*/

@ -0,0 +1,10 @@
import { render } from '@testing-library/react';
import SensorsOnMap from './sensors-on-map';
describe('SensorsOnMap', () => {
it('should render successfully', () => {
const { baseElement } = render(<SensorsOnMap />);
expect(baseElement).toBeTruthy();
});
});

@ -0,0 +1,112 @@
import styles from './sensors-on-map.module.scss';
import {YMaps, Map, Circle, Clusterer, Placemark} from '@pbe/react-yandex-maps';
import {Prisma, Sensor} from "@weather-platform/prisma-clients/Sensors";
import {Prisma as PrismaAgr, Agregator} from "@weather-platform/prisma-clients/Agregators";
import axios from "axios";
import {AGW_URL} from "../../../../agw";
import {useEffect, useState} from "react";
/* eslint-disable-next-line */
export interface SensorsOnMapProps {}
export function SensorsOnMap(props: SensorsOnMapProps) {
const fetchGetSensorsList = async (params: Prisma.SensorFindManyArgs = {}) => {
try {
const response = await axios.post( AGW_URL + '/api/v1/sensors/get-with-params', params);
const data = response.data;
return data;
} catch (error) {
console.error('Error fetching data:', error);
return null;
}
};
const [sensors, setSensors] = useState<Sensor[] | null>(null);
const updateSensorsData = async () => {
const response = await fetchGetSensorsList({
select: {
lat: true,
lng: true,
}
});
if (response !== null) {
setSensors(response);
}
};
const fetchGetAgregatorsList = async (params: PrismaAgr.AgregatorFindManyArgs = {}) => {
try {
const response = await axios.post( AGW_URL + '/api/v1/agregator/get-with-params', params);
const data = response.data;
return data;
} catch (error) {
console.error('Error fetching data:', error);
return null;
}
};
const [agregators, setAgregators] = useState<Agregator[] | null>(null);
const updateAgregatorsData = async () => {
const response = await fetchGetAgregatorsList({
select: {
lat: true,
lng: true,
}
});
if (response !== null) {
setAgregators(response);
}
};
function upd() {
updateAgregatorsData();
updateSensorsData();
}
useEffect(() => {
upd();
const interval = setInterval(upd, 30000);
return () => clearInterval(interval);
}, []);
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
// const mergedArray = [...agregators, ...sensors];
// const temperatures = agregators.map(item => [item.lng, item.lat]);
// console.log(temperatures);
return (
<div className="rounded-2xl w-full h-full mx-4">
<YMaps>
<Map defaultState={{ center: [47.2362, 38.8969], zoom: 11 }} width={"100%"} height={"100%"}>
<Circle
geometry={[[47.205577, 38.941490], 5000]}
options={{
draggable: false,
fillColor: "#DB709377",
strokeColor: "#990066",
strokeOpacity: 0.8,
strokeWidth: 5,
}}
/>
<Clusterer
options={{
preset: "islands#invertedVioletClusterIcons",
groupByCoordinates: false,
}}
>
{agregators?.map((agregator:any, index:any) => (
<Placemark key={index} geometry={{ type: "Point", coordinates: [agregator.lat, agregator.lng] }} />
))}
{sensors?.map((agregator:any, index:any) => (
<Placemark key={index} geometry={{ type: "Point", coordinates: [agregator.lat, agregator.lng] }} />
))}
</Clusterer>
</Map>
</YMaps>
</div>
);
}
export default SensorsOnMap;
Loading…
Cancel
Save