@iotready/nextjs-components-library 1.0.0-preview20 → 1.0.0-preview22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,27 +1,26 @@
1
1
  import 'chartjs-adapter-moment';
2
2
  import 'moment/locale/it';
3
3
  import { Theme } from "@emotion/react";
4
- import { InfluxFillType } from '../../server-actions/types';
4
+ import { FilterTagMode, InfluxFillType } from '../../server-actions/types';
5
5
  type Measure = {
6
6
  name: string;
7
7
  description: string;
8
8
  polltime: number;
9
+ dwPolltime?: number;
9
10
  unit: string;
10
11
  stepped: boolean;
11
12
  };
12
- declare const TrendChart: ({ deviceId, measures1, annotationsData, measures2, enableDatePicker, handleGetInfluxData, handleExportDataCB, theme, initialTimeStart, initialTimeEnd, dwEnabled, dwCallback, dwHandled }: {
13
+ declare const TrendChart: ({ deviceId, measures1, annotationsDataFn, measures2, enableDatePicker, handleGetInfluxData, handleGetDwSlotsCB, handleExportDataCB, theme, initialTimeStart, initialTimeEnd }: {
13
14
  deviceId: string;
14
- annotationsData?: Array<[any, any]>;
15
+ annotationsDataFn?: () => Promise<any>;
15
16
  measures1?: Array<Measure>;
16
17
  measures2?: Array<Measure>;
17
18
  enableDatePicker: boolean;
18
- handleGetInfluxData: (measure: string, timeStart: number, timeEnd: number, deviceId: string, timeGroup: string, raw: boolean, fill?: InfluxFillType) => Promise<any>;
19
+ handleGetInfluxData: (measure: string, timeStart: number, timeEnd: number, deviceId: string, timeGroup: string, raw: boolean, fill?: InfluxFillType, filterTag?: number, includeTag?: FilterTagMode) => Promise<any>;
20
+ handleGetDwSlotsCB?: (timeStart: number, timeEnd: number, deviceID: string) => Promise<any>;
19
21
  handleExportDataCB?: (measure: string, timeStart: number, timeEnd: number, deviceId: string) => Promise<any>;
20
22
  theme: Theme;
21
23
  initialTimeStart?: number;
22
24
  initialTimeEnd?: number;
23
- dwEnabled?: boolean;
24
- dwCallback?: (val: boolean) => void;
25
- dwHandled?: boolean;
26
25
  }) => import("react/jsx-runtime").JSX.Element;
27
26
  export default TrendChart;
@@ -21,7 +21,7 @@ import { ThemeProvider } from '@mui/material/styles';
21
21
  import TimelineIcon from '@mui/icons-material/Timeline';
22
22
  import MuiTooltip from '@mui/material/Tooltip';
23
23
  import EditNoteIcon from '@mui/icons-material/EditNote';
24
- import AspectRatioIcon from '@mui/icons-material/AspectRatio';
24
+ import { FilterTagMode } from '../../server-actions/types';
25
25
  const lineOptions = {
26
26
  parsing: false,
27
27
  normalized: true,
@@ -126,15 +126,15 @@ const chartConfigByPeriod = {
126
126
  scaleUnit: 'year',
127
127
  }
128
128
  };
129
- function getChartPoints(data) {
130
- const points = data.results[0].series[0].values.map((row) => {
131
- return {
132
- x: moment.unix(row[0]),
133
- y: row[1]
134
- };
135
- });
136
- return points;
137
- }
129
+ // function getChartPoints(data: any): Point[] {
130
+ // const points: Point[] = data.results[0].series[0].values.map((row: any) => {
131
+ // return {
132
+ // x: moment.unix(row[0]),
133
+ // y: row[1]
134
+ // }
135
+ // });
136
+ // return points;
137
+ // }
138
138
  function getPollTime(intervalInSeconds, pollTime) {
139
139
  const CalculatedPollTime = Math.round(intervalInSeconds / 2880);
140
140
  if (CalculatedPollTime <= pollTime) {
@@ -145,51 +145,57 @@ function getPollTime(intervalInSeconds, pollTime) {
145
145
  }
146
146
  }
147
147
  function getCsvData(data, measures) {
148
- // Initialize the header with timestamp and measure names
149
- const headers = ["timestamp", ...measures.map(measure => measure.description || measure.name)];
150
- const csvData = [];
151
- // Add the header to the csvData
152
- csvData.push(headers);
153
- // Collect all timestamps and values for each measure
148
+ // Intestazioni CSV
149
+ const headers = [
150
+ 'timestamp',
151
+ ...measures.map(m => m.description || m.name)
152
+ ];
153
+ const csvRows = [headers];
154
+ // Mappa temporale: ISO string → { timestamp, [measureName]: value, … }
154
155
  const timestampMap = {};
155
- // Populate timestampMap with data for each timestamp
156
- data.forEach((obj) => {
157
- obj.results[0].series.forEach((series) => {
158
- series.values.forEach((value) => {
159
- const timestamp = moment.unix(value[0]).toISOString();
160
- if (!timestampMap[timestamp]) {
161
- timestampMap[timestamp] = { timestamp: timestamp };
162
- }
163
- const measureName = series.name; // Assuming the series name corresponds to the measure name
164
- if (measures.some(measure => measure.name === measureName)) {
165
- timestampMap[timestamp][measureName] = value[1]; // Assign the value to the measure
166
- }
167
- });
156
+ // Ogni serie corrisponde a measures[index]
157
+ data.forEach((series, index) => {
158
+ const measure = measures[index];
159
+ if (!measure)
160
+ return; // difesa su mismatch lunghezze
161
+ series.forEach(point => {
162
+ // usa moment per coerenza con prima versione
163
+ const ts = moment(point.x).toISOString();
164
+ if (!timestampMap[ts]) {
165
+ timestampMap[ts] = { timestamp: ts };
166
+ }
167
+ timestampMap[ts][measure.name] = point.y;
168
168
  });
169
169
  });
170
- // Sort timestamps in ascending order
171
- const sortedTimestamps = Object.keys(timestampMap).sort((a, b) => new Date(a).getTime() - new Date(b).getTime());
172
- // Create rows from sorted timestampMap
173
- sortedTimestamps.forEach(timestamp => {
174
- const entry = timestampMap[timestamp];
170
+ // Ordina i timestamp
171
+ const sortedTs = Object.keys(timestampMap)
172
+ .sort((a, b) => new Date(a).getTime() - new Date(b).getTime());
173
+ // Costruisci le righe CSV
174
+ sortedTs.forEach(ts => {
175
+ const entry = timestampMap[ts];
176
+ // prima colonna timestamp, poi i valori nelle colonne in ordine measures[]
175
177
  const row = [entry.timestamp];
176
- measures.forEach(measure => {
177
- // Push the corresponding value or an empty string if undefined
178
- row.push(entry[measure.name] !== undefined ? entry[measure.name] : "");
178
+ measures.forEach(m => {
179
+ row.push(entry[m.name] !== undefined
180
+ ? entry[m.name]
181
+ : '');
179
182
  });
180
- // Check if the row contains only empty values (besides the timestamp)
181
- const hasNonEmptyValues = row.slice(1).some(value => value !== null && value !== '' && value !== undefined);
182
- // If the row has at least one non-empty value, add it to csvData
183
- if (hasNonEmptyValues || row.length === 1) {
184
- csvData.push(row);
183
+ // optional: filtra le righe che non hanno alcun valore utile
184
+ const hasValue = row.slice(1).some(v => v !== '' && v !== null);
185
+ if (hasValue) {
186
+ csvRows.push(row);
185
187
  }
186
188
  });
187
- // Join rows into a CSV string
188
- return csvData.map(row => row.join(',')).join('\n');
189
+ // Unisci in stringa
190
+ return csvRows
191
+ .map(r => r.join(','))
192
+ .join('\n');
189
193
  }
190
194
  // eslint-disable-next-line no-unused-vars
191
- const TrendChart = ({ deviceId, measures1, annotationsData, measures2, enableDatePicker, handleGetInfluxData, handleExportDataCB, theme, initialTimeStart, initialTimeEnd, dwEnabled, dwCallback, dwHandled }) => {
195
+ const TrendChart = ({ deviceId, measures1, annotationsDataFn, measures2, enableDatePicker, handleGetInfluxData, handleGetDwSlotsCB, handleExportDataCB, theme, initialTimeStart, initialTimeEnd }) => {
192
196
  const [chartJsLoaded, setChartJsLoaded] = useState(false);
197
+ // Dichiarazione di annotationsData come funzione che ritorna una Promise<any>
198
+ const [annotationsData, setAnnotationsData] = useState([]);
193
199
  const [annotentionsEnabled, setAnnotationsEnabled] = useState(true);
194
200
  const [dataMeasures, setDataMeasures] = useState(null);
195
201
  const [chartPeriod, setChartPeriod] = useState('1D');
@@ -261,6 +267,20 @@ const TrendChart = ({ deviceId, measures1, annotationsData, measures2, enableDat
261
267
  setSpanGapsOption(spanG);
262
268
  };
263
269
  const handleChange = (event, newPeriod) => {
270
+ if (newPeriod == null) {
271
+ return;
272
+ }
273
+ if (chartPeriod === newPeriod) {
274
+ setChartLoading(true);
275
+ setZoomed(false);
276
+ setDatePickerUsed(false);
277
+ setCsvData('');
278
+ const periodConfig = chartConfigByPeriod[chartPeriod];
279
+ setTimeStart(Math.round(moment().subtract(periodConfig.from).valueOf() / 1000));
280
+ setTimeEnd(Math.round(moment().valueOf() / 1000));
281
+ setChartPeriod(chartPeriod);
282
+ setChartPeriodConfig(periodConfig);
283
+ }
264
284
  if (newPeriod && newPeriod !== chartPeriod) {
265
285
  setChartLoading(true);
266
286
  setZoomed(false);
@@ -297,9 +317,36 @@ const TrendChart = ({ deviceId, measures1, annotationsData, measures2, enableDat
297
317
  csvLinkRef.current?.link.click();
298
318
  }
299
319
  }, [csvData]);
320
+ useEffect(() => {
321
+ if (annotationsDataFn && annotentionsEnabled) {
322
+ (async () => {
323
+ const resp = await annotationsDataFn();
324
+ setAnnotationsData(resp);
325
+ })();
326
+ }
327
+ }, [annotationsDataFn, annotentionsEnabled]);
328
+ function getDwSlotsFromValues(dwValues) {
329
+ const slots = [];
330
+ let start = null;
331
+ for (const point of dwValues) {
332
+ if (point.y === 1 && start === null) {
333
+ start = point.x;
334
+ }
335
+ if (point.y === 0 && start !== null) {
336
+ slots.push({ start, end: point.x });
337
+ start = null;
338
+ }
339
+ }
340
+ return slots;
341
+ }
300
342
  const loadDatasets = async (chartPeriod) => {
301
343
  let intervalInSeconds = chartPeriod === "ALL" && !datePickerUsed && !zoomed ? 31536000 : timeEnd - timeStart;
302
344
  const rawQuery = intervalInSeconds < 86400;
345
+ let tempSlots = [];
346
+ if (handleGetDwSlotsCB) {
347
+ const dwValues = await handleGetDwSlotsCB(timeStart, timeEnd, deviceId);
348
+ tempSlots = getDwSlotsFromValues(dwValues);
349
+ }
303
350
  // Combine measures and track their source
304
351
  const allMeasures = [
305
352
  ...(measures1?.map(m => ({ ...m, source: 'measures1' })) || []),
@@ -307,11 +354,43 @@ const TrendChart = ({ deviceId, measures1, annotationsData, measures2, enableDat
307
354
  ];
308
355
  const datasetsPromises = allMeasures.map(async (measure) => {
309
356
  const polltime = getPollTime(intervalInSeconds, measure.polltime || 30);
310
- const influxData = await handleGetInfluxData(measure.name, timeStart, timeEnd, deviceId, polltime, !measure.polltime && rawQuery, dwEnabled ? "previous" : !measure.polltime ? "none" : "null");
311
- const points = getChartPoints(influxData);
357
+ let dwPoints = [];
358
+ let dwSlots = [];
359
+ if (measure.dwPolltime) {
360
+ const dwPolltime = getPollTime(intervalInSeconds, measure.dwPolltime);
361
+ // Query DW solo tag=100
362
+ const rawDwPoints = await handleGetInfluxData(measure.name, timeStart, timeEnd, deviceId, dwPolltime, false, "previous", 100, FilterTagMode.DW);
363
+ dwSlots = tempSlots;
364
+ if (dwSlots.length > 0) {
365
+ dwPoints = rawDwPoints.filter((p) => dwSlots.some(slot => p.x >= slot.start && p.x <= slot.end));
366
+ }
367
+ else {
368
+ dwPoints = rawDwPoints;
369
+ }
370
+ }
371
+ const stdRaw = await handleGetInfluxData(measure.name, timeStart, timeEnd, deviceId, polltime, !measure.polltime && rawQuery, !measure.polltime ? "none" : "null", 100, FilterTagMode.Exclude);
372
+ // Mappa sul formato Point
373
+ const stdPoints = stdRaw
374
+ .map((r) => ({ x: Number(r.x), y: r.y }))
375
+ .filter((p) => p.y !== null);
376
+ const filtered = dwSlots.length
377
+ ? stdPoints.filter((p) => !dwSlots.some(slot => p.x >= slot.start && p.x <= slot.end))
378
+ : stdPoints;
379
+ let combined;
380
+ // 6) Unisco e ordino
381
+ if (dwPoints.length > 2 && dwSlots.length > 0) {
382
+ combined = [...dwPoints, ...filtered]
383
+ .sort((a, b) => a.x - b.x);
384
+ }
385
+ else if (dwPoints.length > 2 && dwSlots.length <= 0) {
386
+ combined = [...dwPoints];
387
+ }
388
+ else {
389
+ combined = [...filtered];
390
+ }
312
391
  return {
313
392
  label: measure.description || measure.name,
314
- data: points,
393
+ data: combined,
315
394
  unit: measure.unit,
316
395
  borderWidth: 2,
317
396
  pointRadius: 1,
@@ -348,8 +427,8 @@ const TrendChart = ({ deviceId, measures1, annotationsData, measures2, enableDat
348
427
  if (max2 === null || datasetMax > max2)
349
428
  max2 = datasetMax;
350
429
  }
351
- if (time && (minTime === null || time.unix() < minTime))
352
- minTime = time.unix() - 86400;
430
+ if (time && (minTime === null || time < minTime))
431
+ minTime = Math.floor(time / 1000) - 86400;
353
432
  });
354
433
  const getPaddedMinMax = (min, max) => {
355
434
  if (min === null || max === null)
@@ -500,7 +579,7 @@ const TrendChart = ({ deviceId, measures1, annotationsData, measures2, enableDat
500
579
  loadDatasets(chartPeriod).then(() => {
501
580
  setChartLoading(false);
502
581
  });
503
- }, [measures1, timeEnd, timeStart, measures2, annotentionsEnabled, annotationsData, dwEnabled]);
582
+ }, [measures1, timeEnd, timeStart, measures2, annotentionsEnabled, annotationsData]);
504
583
  useEffect(() => {
505
584
  const loadZoomPlugin = async () => {
506
585
  const zoomPlugin = (await import('chartjs-plugin-zoom')).default;
@@ -592,7 +671,7 @@ const TrendChart = ({ deviceId, measures1, annotationsData, measures2, enableDat
592
671
  '& .MuiToggleButton-root': {
593
672
  color: 'text.primary', fontSize: '0.95rem', fontWeight: 'normal', paddingTop: '6px', paddingBottom: '6px'
594
673
  }
595
- }, disabled: chartLoading, children: [_jsx(ToggleButton, { value: "1D", sx: { px: 1 }, children: "1d" }), _jsx(ToggleButton, { value: "1W", sx: { px: 1 }, children: "1w" }), _jsx(ToggleButton, { value: "1M", sx: { px: 1 }, children: "1M" }), _jsx(ToggleButton, { value: "3M", sx: { px: 1 }, children: "3M" }), _jsx(ToggleButton, { value: "6M", sx: { px: 1 }, children: "6M" }), _jsx(ToggleButton, { value: "1Y", sx: { px: 1 }, children: "1Y" }), _jsx(ToggleButton, { value: "ALL", sx: { px: 1 }, children: "ALL" })] }), _jsx(MuiTooltip, { placement: "top", arrow: true, title: "Connect point values", children: _jsx(ToggleButton, { value: "check", color: "primary", size: "small", selected: spanGapsOption, disabled: chartLoading, onChange: () => handleSpanGaps(!spanGapsOption), sx: { ml: 1 }, children: _jsx(TimelineIcon, {}) }) }), annotationsData !== undefined && (_jsx(MuiTooltip, { placement: "top", arrow: true, title: "Show annotations", children: _jsx(ToggleButton, { value: "check", color: "primary", size: "small", selected: annotentionsEnabled, disabled: chartLoading, onChange: () => setAnnotationsEnabled(!annotentionsEnabled), sx: { ml: 1 }, children: _jsx(EditNoteIcon, {}) }) })), dwCallback !== undefined && dwEnabled != undefined && (_jsx(MuiTooltip, { placement: "top", arrow: true, title: "Show data window data", children: _jsx(ToggleButton, { value: "check", color: "primary", size: "small", selected: dwEnabled, disabled: chartLoading || !dwHandled, onChange: () => dwCallback(!dwEnabled), sx: { ml: 1 }, children: _jsx(AspectRatioIcon, {}) }) }))] })] }), _jsx(Box, { component: 'div', className: "chart-container", sx: { mt: 2, height: '100%' }, children: chartJsLoaded && !chartLoading && typeof window !== 'undefined' ?
674
+ }, disabled: chartLoading, children: [_jsx(ToggleButton, { value: "1D", sx: { px: 1 }, children: "1d" }), _jsx(ToggleButton, { value: "1W", sx: { px: 1 }, children: "1w" }), _jsx(ToggleButton, { value: "1M", sx: { px: 1 }, children: "1M" }), _jsx(ToggleButton, { value: "3M", sx: { px: 1 }, children: "3M" }), _jsx(ToggleButton, { value: "6M", sx: { px: 1 }, children: "6M" }), _jsx(ToggleButton, { value: "1Y", sx: { px: 1 }, children: "1Y" }), _jsx(ToggleButton, { value: "ALL", sx: { px: 1 }, children: "ALL" })] }), _jsx(MuiTooltip, { placement: "top", arrow: true, title: "Connect point values", children: _jsx(ToggleButton, { value: "check", color: "primary", size: "small", selected: spanGapsOption, disabled: chartLoading, onChange: () => handleSpanGaps(!spanGapsOption), sx: { ml: 1 }, children: _jsx(TimelineIcon, {}) }) }), annotationsData !== undefined && (_jsx(MuiTooltip, { placement: "top", arrow: true, title: "Show annotations", children: _jsx(ToggleButton, { value: "check", color: "primary", size: "small", selected: annotentionsEnabled, disabled: chartLoading, onChange: () => setAnnotationsEnabled(!annotentionsEnabled), sx: { ml: 1 }, children: _jsx(EditNoteIcon, {}) }) }))] })] }), _jsx(Box, { component: 'div', className: "chart-container", sx: { mt: 2, height: '100%' }, children: chartJsLoaded && !chartLoading && typeof window !== 'undefined' ?
596
675
  _jsx(_Fragment, { children: dataMeasures && (dataMeasures.length > 1 || (dataMeasures.length === 1 && dataMeasures[0].data?.length)) ?
597
676
  (_jsx(Line, { options: options, data: {
598
677
  // datasets: dataMeasures || [{ data: [] }]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iotready/nextjs-components-library",
3
- "version": "1.0.0-preview20",
3
+ "version": "1.0.0-preview22",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "build": "rm -rf dist && tsc --project tsconfig.build.json && cp package.json dist/",
@@ -1,4 +1,5 @@
1
- import { InfluxConfig, InfluxFillType } from "./types";
1
+ import { FilterTagMode, InfluxConfig, InfluxFillType } from "./types";
2
2
  export declare function getInfluxAlerts(influxConfig: InfluxConfig, fields: string[], limit: number, offset: number, sort: any, deviceID: string, timeStart: number, timeEnd: number): Promise<any>;
3
- export declare function getInfluxDataV1(influxConfig: InfluxConfig, field: string, timeStart: number, timeEnd: number, deviceID: string, timeGroup: string, raw: boolean, fill?: InfluxFillType, filterTag?: number): Promise<any>;
3
+ export declare function getDwSlots(influxConfig: InfluxConfig, timeStart: number, timeEnd: number, deviceID: string): Promise<any>;
4
+ export declare function getInfluxDataV1(influxConfig: InfluxConfig, field: string, timeStart: number, timeEnd: number, deviceID: string, timeGroup: string, raw: boolean, fill?: InfluxFillType, filterTag?: number, tagInclude?: FilterTagMode): Promise<any>;
4
5
  export declare function exportDataV1(influxConfig: InfluxConfig, field: string, timeStart: number, timeEnd: number, deviceID: string): Promise<any>;
@@ -1,6 +1,7 @@
1
1
  "use server";
2
2
  import { parse } from "csv-parse";
3
3
  import moment from "moment";
4
+ import { FilterTagMode } from "./types";
4
5
  export async function getInfluxAlerts(influxConfig, fields, limit, offset, sort, deviceID, timeStart, timeEnd) {
5
6
  const conditions = fields
6
7
  .map((field) => `r["valueName"] == "${field}"`)
@@ -74,20 +75,65 @@ export async function getInfluxAlerts(influxConfig, fields, limit, offset, sort,
74
75
  });
75
76
  const parsedCount = count.split("\n")[1].split(",");
76
77
  let countData = parsedCount[5];
77
- console.log("Count Data:", countData);
78
- console.log("Rows:", rows);
79
78
  return {
80
79
  data: rows,
81
80
  count: countData
82
81
  };
83
82
  }
84
- export async function getInfluxDataV1(influxConfig, field, timeStart, timeEnd, deviceID, timeGroup, raw, fill, filterTag) {
83
+ export async function getDwSlots(influxConfig, timeStart, timeEnd, deviceID) {
84
+ const field = "dw";
85
+ const query = `
86
+ SELECT ("value") FROM "${influxConfig.measurement}"
87
+ WHERE "deviceid" = '${deviceID}'
88
+ AND "valueName" = '${field}'
89
+ AND time >= '${moment.unix(timeStart).toISOString()}'
90
+ AND time <= '${moment.unix(timeEnd).toISOString()}'
91
+ `;
92
+ const response = await fetch(encodeURI(`${influxConfig.url}/query?db=${influxConfig.dbName}&epoch=s&q=${query}`), {
93
+ headers: {
94
+ Authorization: `Basic ${btoa(`${influxConfig.username}:${influxConfig.password}`)}`
95
+ }
96
+ });
97
+ if (!response.ok) {
98
+ throw new Error(`Failed to fetch DW data: ${response.statusText}`);
99
+ }
100
+ const data = await response.json();
101
+ const series = data?.results?.[0]?.series?.[0];
102
+ if (!series?.values || !Array.isArray(series.values)) {
103
+ return data; // niente da fare, ritorna i dati grezzi
104
+ }
105
+ const values = series.values;
106
+ // Modifiche ai valori
107
+ if (values.length > 0) {
108
+ // Aggiungi punto all'inizio se il primo valore è 0
109
+ if (values[0][1] === 0) {
110
+ values.unshift([moment.unix(timeStart).unix(), 1]);
111
+ }
112
+ // Aggiungi punto alla fine se l'ultimo valore è 1
113
+ if (values[values.length - 1][1] === 1) {
114
+ values.push([moment.unix(timeEnd).unix(), 0]);
115
+ }
116
+ }
117
+ return data; // stessa struttura di Influx, con values modificati
118
+ }
119
+ export async function getInfluxDataV1(influxConfig, field, timeStart, timeEnd, deviceID, timeGroup, raw, fill, filterTag, tagInclude = FilterTagMode.Include) {
85
120
  let query;
86
121
  let preStartValue = null;
87
- // Build filter for filterTag if provided
88
- const filterTagCondition = filterTag !== undefined && filterTag !== null
89
- ? ` AND ("d" = '${filterTag}' OR "d" !~ /./)`
90
- : "";
122
+ // Costruzione filtro tag
123
+ let filterTagCondition = "";
124
+ if (filterTag !== undefined && filterTag !== null) {
125
+ switch (tagInclude) {
126
+ case FilterTagMode.Include:
127
+ filterTagCondition = ` AND ("d" = '${filterTag}' OR "d" !~ /./)`;
128
+ break;
129
+ case FilterTagMode.Exclude:
130
+ filterTagCondition = ` AND ("d" != '${filterTag}' OR "d" !~ /./)`;
131
+ break;
132
+ case FilterTagMode.DW:
133
+ filterTagCondition = ` AND "d" = '${filterTag}'`;
134
+ break;
135
+ }
136
+ }
91
137
  if (raw) {
92
138
  query = `SELECT ("value") FROM "${influxConfig.measurement}" WHERE "deviceid" = '${deviceID}' AND "valueName" = '${field}'${filterTagCondition} AND time >= '${moment
93
139
  .unix(timeStart)
@@ -16,4 +16,9 @@ export type InfluxConfig = {
16
16
  username: string;
17
17
  password: string;
18
18
  };
19
+ export declare enum FilterTagMode {
20
+ Include = "include",// include tag + quelli senza tag
21
+ Exclude = "exclude",// esclude il tag
22
+ DW = "dw"
23
+ }
19
24
  export type InfluxFillType = "null" | "none" | "previous";
@@ -1 +1,6 @@
1
- export {};
1
+ export var FilterTagMode;
2
+ (function (FilterTagMode) {
3
+ FilterTagMode["Include"] = "include";
4
+ FilterTagMode["Exclude"] = "exclude";
5
+ FilterTagMode["DW"] = "dw"; // solo esattamente quel tag
6
+ })(FilterTagMode || (FilterTagMode = {}));