logitude-dashboard-library 1.2.87 → 1.2.90

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.
@@ -378,6 +378,9 @@ $dark-grey: #717585;
378
378
  margin: 4px 0;
379
379
  width: max-content;
380
380
  z-index: 1;
381
+ max-width: 400px;
382
+ white-space: pre-wrap;
383
+
381
384
  }
382
385
 
383
386
  .dl-tooltip:hover .dl-tooltiptext {
@@ -1,7 +1,9 @@
1
1
  /// <reference types="react" />
2
2
  import { ReactWidgetPM } from "../../../types/widget";
3
+ import { DataPointSelection } from '../../../types/SeriesMeasure';
3
4
  declare type ApexChartProps = {
4
5
  widget: ReactWidgetPM | null;
6
+ onSelectDataPoint: (dataPointSelection: DataPointSelection) => void;
5
7
  };
6
8
  declare const ApexChart: (props: ApexChartProps) => JSX.Element;
7
9
  export declare type ApexChartArgs = {
@@ -2,6 +2,7 @@
2
2
  import { Layouts } from "react-grid-layout";
3
3
  import ColumnChartComponent from "./ChartsComponents/ColumnChartComponent";
4
4
  import { ReactWidgetPM } from "../../types/widget";
5
+ import { DataPointSelection } from "../../types/SeriesMeasure";
5
6
  declare type DashboardDesignerProps = {
6
7
  editMode: boolean;
7
8
  dashboardLayouts: {
@@ -9,6 +10,7 @@ declare type DashboardDesignerProps = {
9
10
  };
10
11
  openEditWidget: (widget: ReactWidgetPM) => void;
11
12
  onLayoutChange: (layouts: Layouts) => void;
13
+ onSelectDataPoint: (dataPointSelection: DataPointSelection) => void;
12
14
  };
13
15
  declare const DashboardDesigner: (props: DashboardDesignerProps) => JSX.Element;
14
16
  export declare const layoutGridProps: {
@@ -1,4 +1,5 @@
1
1
  /// <reference types="react" />
2
+ import { DataPointSelection } from "../../types/SeriesMeasure";
2
3
  import { ReactWidgetPM } from "../../types/widget";
3
4
  declare type WidgetCardProps = {
4
5
  editBtnClicked(widget: any): any;
@@ -7,6 +8,7 @@ declare type WidgetCardProps = {
7
8
  el: any;
8
9
  dateFilter: any;
9
10
  isInEditMode: boolean;
11
+ onSelectDataPoint: (dataPointSelection: DataPointSelection) => void;
10
12
  };
11
13
  declare const WidgetCard: (props: WidgetCardProps, state: any) => JSX.Element;
12
14
  export default WidgetCard;
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ import "./styles.module.css";
3
3
  import { ReactDashboardPM } from './types/Dashboard';
4
4
  import { ReactWidgetPM } from './types/widget';
5
5
  import { DashboardDataBinding } from './types/DashboardDataBinding';
6
+ import { DataPointSelection } from './types/SeriesMeasure';
6
7
  declare type DashboardProps = {
7
8
  token: string;
8
9
  tenant: number;
@@ -12,6 +13,7 @@ declare type DashboardProps = {
12
13
  openAddEditDashboard: (dashboard: ReactDashboardPM | undefined) => void;
13
14
  onChangeDashboard: (dashboard: ReactDashboardPM | undefined) => void;
14
15
  onSaveDashboard: (dashboard: ReactDashboardPM | undefined) => void;
16
+ onSelectDataPoint: (dataPointSelection: DataPointSelection) => void;
15
17
  };
16
18
  declare const Dashboard: (props: DashboardProps) => JSX.Element;
17
19
  export default Dashboard;
package/dist/index.js CHANGED
@@ -13,6 +13,44 @@ var dialog = require('primereact/dialog');
13
13
  var ripple = require('primereact/ripple');
14
14
  var uuid = require('uuid');
15
15
 
16
+ function _unsupportedIterableToArray(o, minLen) {
17
+ if (!o) return;
18
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
19
+ var n = Object.prototype.toString.call(o).slice(8, -1);
20
+ if (n === "Object" && o.constructor) n = o.constructor.name;
21
+ if (n === "Map" || n === "Set") return Array.from(o);
22
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
23
+ }
24
+
25
+ function _arrayLikeToArray(arr, len) {
26
+ if (len == null || len > arr.length) len = arr.length;
27
+
28
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
29
+
30
+ return arr2;
31
+ }
32
+
33
+ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
34
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
35
+ if (it) return (it = it.call(o)).next.bind(it);
36
+
37
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
38
+ if (it) o = it;
39
+ var i = 0;
40
+ return function () {
41
+ if (i >= o.length) return {
42
+ done: true
43
+ };
44
+ return {
45
+ done: false,
46
+ value: o[i++]
47
+ };
48
+ };
49
+ }
50
+
51
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
52
+ }
53
+
16
54
  var Tools = /*#__PURE__*/function () {
17
55
  function Tools() {}
18
56
 
@@ -134,23 +172,31 @@ var ApexChart = function ApexChart(props) {
134
172
  error = _useState[0],
135
173
  setEror = _useState[1];
136
174
 
137
- var _useState2 = React.useState(false),
138
- isView = _useState2[0],
139
- setisView = _useState2[1];
175
+ var _useState2 = React.useState([]),
176
+ MeasuresIds = _useState2[0],
177
+ setMeasuresIds = _useState2[1];
178
+
179
+ var _useState3 = React.useState([]),
180
+ GroupByIds = _useState3[0],
181
+ setGroupByIds = _useState3[1];
140
182
 
141
- var _useState3 = React.useState(false),
142
- viewError = _useState3[0],
143
- setViewError = _useState3[1];
183
+ var _useState4 = React.useState(false),
184
+ isView = _useState4[0],
185
+ setisView = _useState4[1];
186
+
187
+ var _useState5 = React.useState(false),
188
+ viewError = _useState5[0],
189
+ setViewError = _useState5[1];
144
190
 
145
191
  var isDataLoaded = React.useRef(false);
146
192
  var hasDataError = React.useRef(false);
147
193
 
148
- var _useState4 = React.useState({
194
+ var _useState6 = React.useState({
149
195
  series: [],
150
196
  options: {}
151
197
  }),
152
- args = _useState4[0],
153
- serArgs = _useState4[1];
198
+ args = _useState6[0],
199
+ serArgs = _useState6[1];
154
200
 
155
201
  var isLoadingDrow = React.useRef(true);
156
202
  React.useEffect(function () {
@@ -163,19 +209,46 @@ var ApexChart = function ApexChart(props) {
163
209
  console.log('useEffect ApexChart', props.widget);
164
210
  var dashboardAnalyticsService = new DashboardAnalyticsService();
165
211
  dashboardAnalyticsService.getData(props.widget).then(function (result) {
212
+ fillIds(result.data);
166
213
  var data = getChartOptions(result.data);
167
214
  serArgs(data);
168
215
  isDataLoaded.current = true;
169
216
  hasDataError.current = false;
170
217
  updateView();
171
218
  }, function (error) {
219
+ var _error$response, _error$response$data, _error$response2, _error$response2$data;
220
+
172
221
  console.log('error', error);
173
- setEror(error.message);
222
+ if (error !== null && error !== void 0 && (_error$response = error.response) !== null && _error$response !== void 0 && (_error$response$data = _error$response.data) !== null && _error$response$data !== void 0 && _error$response$data.ErrorMessage) setEror(error === null || error === void 0 ? void 0 : (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : (_error$response2$data = _error$response2.data) === null || _error$response2$data === void 0 ? void 0 : _error$response2$data.ErrorMessage);else setEror(error.message);
174
223
  isDataLoaded.current = true;
175
224
  hasDataError.current = true;
176
225
  });
177
226
  }, [(_props$widget = props.widget) === null || _props$widget === void 0 ? void 0 : _props$widget.EntityId, (_props$widget2 = props.widget) === null || _props$widget2 === void 0 ? void 0 : _props$widget2.Filters, (_props$widget3 = props.widget) === null || _props$widget3 === void 0 ? void 0 : _props$widget3.WidgetMeasures]);
178
227
 
228
+ var fillIds = function fillIds(datas) {
229
+ var measuresIds = [];
230
+ var groupByIds = [];
231
+
232
+ for (var _iterator = _createForOfIteratorHelperLoose(datas), _step; !(_step = _iterator()).done;) {
233
+ var seriesMeasure = _step.value;
234
+ measuresIds.push(seriesMeasure.MeasureId);
235
+ }
236
+
237
+ for (var _iterator2 = _createForOfIteratorHelperLoose(datas), _step2; !(_step2 = _iterator2()).done;) {
238
+ var _seriesMeasure = _step2.value;
239
+
240
+ for (var _iterator3 = _createForOfIteratorHelperLoose(_seriesMeasure.SeriesMeasureVulues), _step3; !(_step3 = _iterator3()).done;) {
241
+ var vulue = _step3.value;
242
+ groupByIds.push(vulue.GroupById);
243
+ }
244
+
245
+ break;
246
+ }
247
+
248
+ setMeasuresIds(measuresIds);
249
+ setGroupByIds(groupByIds);
250
+ };
251
+
179
252
  var updateView = function updateView() {
180
253
  if (isDataLoaded.current && !isLoadingDrow.current && !hasDataError.current) {
181
254
  setisView(true);
@@ -193,9 +266,6 @@ var ApexChart = function ApexChart(props) {
193
266
  var categories = [];
194
267
 
195
268
  if (values && values[0]) {
196
- var s = values[0].SeriesMeasureVulues.map(function (z) {
197
- return z.Value;
198
- });
199
269
  series = values.map(function (e) {
200
270
  return {
201
271
  data: e.SeriesMeasureVulues.map(function (z) {
@@ -216,6 +286,9 @@ var ApexChart = function ApexChart(props) {
216
286
  type: 'line',
217
287
  zoom: {
218
288
  enabled: false
289
+ },
290
+ events: {
291
+ click: dataPointSelection
219
292
  }
220
293
  },
221
294
  dataLabels: {
@@ -248,9 +321,6 @@ var ApexChart = function ApexChart(props) {
248
321
  var categories = [];
249
322
 
250
323
  if (values && values[0]) {
251
- var s = values[0].SeriesMeasureVulues.map(function (z) {
252
- return z.Value;
253
- });
254
324
  series = values.map(function (e) {
255
325
  return {
256
326
  data: e.SeriesMeasureVulues.map(function (z) {
@@ -268,7 +338,10 @@ var ApexChart = function ApexChart(props) {
268
338
  options: {
269
339
  chart: {
270
340
  type: 'bar',
271
- height: 430
341
+ height: 430,
342
+ events: {
343
+ dataPointSelection: dataPointSelection
344
+ }
272
345
  },
273
346
  plotOptions: {
274
347
  bar: {
@@ -319,7 +392,10 @@ var ApexChart = function ApexChart(props) {
319
392
  series: series,
320
393
  options: {
321
394
  chart: {
322
- type: 'pie'
395
+ type: 'pie',
396
+ events: {
397
+ dataPointSelection: dataPointSelection
398
+ }
323
399
  },
324
400
  labels: labels
325
401
  }
@@ -346,9 +422,6 @@ var ApexChart = function ApexChart(props) {
346
422
  width: 380,
347
423
  type: 'donut',
348
424
  events: {
349
- markerClick: markerClick,
350
- legendClick: legendClick,
351
- click: chartClick,
352
425
  dataPointSelection: dataPointSelection
353
426
  }
354
427
  },
@@ -385,20 +458,11 @@ var ApexChart = function ApexChart(props) {
385
458
  });
386
459
  };
387
460
 
388
- var markerClick = function markerClick(e, chart, options) {
389
- console.log('markerClick e: any, chart?: any, options?: any', e, chart, options);
390
- };
391
-
392
- var chartClick = function chartClick(e, chart, options) {
393
- console.log('chartClick e: any, chart?: any, options?: any', e, chart, options);
394
- };
395
-
396
- var legendClick = function legendClick(chart, seriesIndex, options) {
397
- console.log('legendClick chart: any, seriesIndex?: number, options?: any', chart, seriesIndex, options);
398
- };
399
-
400
461
  var dataPointSelection = function dataPointSelection(e, chart, options) {
401
- console.log('dataPointSelection e: any, chart?: any, options?: any', e, chart, options);
462
+ props.onSelectDataPoint({
463
+ GroupById: GroupByIds[options.dataPointIndex],
464
+ MeasureId: MeasuresIds[options.seriesIndex]
465
+ });
402
466
  };
403
467
 
404
468
  var getChartOptions = function getChartOptions(values) {
@@ -489,7 +553,8 @@ var WidgetCard = function WidgetCard(props, state) {
489
553
  }, "Remove")))), React__default.createElement("div", {
490
554
  className: "dl-dashboard-widget"
491
555
  }, React__default.createElement(ApexChart, {
492
- widget: props.widget
556
+ widget: props.widget,
557
+ onSelectDataPoint: props.onSelectDataPoint
493
558
  })));
494
559
  };
495
560
 
@@ -644,7 +709,8 @@ var DashboardDesigner = function DashboardDesigner(props) {
644
709
  el: widget,
645
710
  dateFilter: dateFilter,
646
711
  editBtnClicked: editWidget,
647
- deleteBtnClicked: deletePanel
712
+ deleteBtnClicked: deletePanel,
713
+ onSelectDataPoint: props.onSelectDataPoint
648
714
  }));
649
715
  }))))));
650
716
  };
@@ -1035,6 +1101,7 @@ var Dashboard = function Dashboard(props) {
1035
1101
  }))) : null)), React.createElement("div", {
1036
1102
  className: 'dl-dashboard-body'
1037
1103
  }, React.createElement(DashboardDesigner, {
1104
+ onSelectDataPoint: props.onSelectDataPoint,
1038
1105
  editMode: isInEditMode,
1039
1106
  onLayoutChange: updateWidgets,
1040
1107
  dashboardLayouts: layouts,