logitude-dashboard-library 1.3.2 → 1.3.5

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.
package/dist/index.js CHANGED
@@ -2,15 +2,12 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
2
2
 
3
3
  var React = require('react');
4
4
  var React__default = _interopDefault(React);
5
- var button = require('primereact/button');
6
5
  var reactGridLayout = require('react-grid-layout');
7
6
  var ReactApexChart = _interopDefault(require('react-apexcharts'));
8
7
  var axios = _interopDefault(require('axios'));
8
+ var button = require('primereact/button');
9
9
  var overlaypanel = require('primereact/overlaypanel');
10
10
  var progressspinner = require('primereact/progressspinner');
11
- var dropdown = require('primereact/dropdown');
12
- var dialog = require('primereact/dialog');
13
- var ripple = require('primereact/ripple');
14
11
  var uuid = require('uuid');
15
12
 
16
13
  function _unsupportedIterableToArray(o, minLen) {
@@ -362,7 +359,7 @@ var ApexChart = function ApexChart(props) {
362
359
  }
363
360
  },
364
361
  dataLabels: {
365
- enabled: true,
362
+ enabled: false,
366
363
  offsetX: -6,
367
364
  style: {
368
365
  fontSize: '12px',
@@ -418,6 +415,9 @@ var ApexChart = function ApexChart(props) {
418
415
  },
419
416
  labels: labels,
420
417
  colors: colors,
418
+ tooltip: {
419
+ fillSeriesColor: false
420
+ },
421
421
  noData: {
422
422
  text: 'No Data Found'
423
423
  }
@@ -428,22 +428,22 @@ var ApexChart = function ApexChart(props) {
428
428
  var CreateColors = function CreateColors(count) {
429
429
  GroupCount.current = count;
430
430
  var colors = [];
431
- CreateDeferuntColors(colors, 0, 100, 50);
431
+ CreateDifferentColors(colors, 0, 100, 50);
432
432
  if (GroupCount.current <= 0) return colors;
433
- CreateDeferuntColors(colors, 15, 100, 50);
433
+ CreateDifferentColors(colors, 15, 100, 50);
434
434
  if (GroupCount.current <= 0) return colors;
435
- CreateDeferuntColors(colors, 0, 50, 50);
435
+ CreateDifferentColors(colors, 0, 50, 50);
436
436
  if (GroupCount.current <= 0) return colors;
437
- CreateDeferuntColors(colors, 15, 50, 50);
437
+ CreateDifferentColors(colors, 15, 50, 50);
438
438
  if (GroupCount.current <= 0) return colors;
439
- CreateDeferuntColors(colors, 0, 50, 30);
439
+ CreateDifferentColors(colors, 0, 50, 30);
440
440
  if (GroupCount.current <= 0) return colors;
441
- CreateDeferuntColors(colors, 15, 50, 30);
441
+ CreateDifferentColors(colors, 15, 50, 30);
442
442
  if (GroupCount.current <= 0) return colors;
443
443
  return undefined;
444
444
  };
445
445
 
446
- var CreateDeferuntColors = function CreateDeferuntColors(colors, startAngle, s, v) {
446
+ var CreateDifferentColors = function CreateDifferentColors(colors, startAngle, s, v) {
447
447
  for (var index = 0; GroupCount.current > 0 && index < 12; index++) {
448
448
  var color = "hsl(" + (startAngle + index * 30) + "deg " + s + "% " + v + "%)";
449
449
  colors.push(color);
@@ -513,6 +513,9 @@ var ApexChart = function ApexChart(props) {
513
513
  },
514
514
  labels: labels,
515
515
  colors: colors,
516
+ tooltip: {
517
+ fillSeriesColor: false
518
+ },
516
519
  noData: {
517
520
  text: 'No Data Found'
518
521
  }
@@ -800,204 +803,32 @@ var layoutGridProps = {
800
803
  useCSSTransforms: true
801
804
  };
802
805
 
803
- var DashBoardService = /*#__PURE__*/function () {
804
- function DashBoardService() {
805
- this.tableName = 'DashBoard';
806
- this._ApiServices = new ApiServices();
807
- }
808
-
809
- var _proto = DashBoardService.prototype;
810
-
811
- _proto.getDataByFilters = function getDataByFilters(filters) {
812
- return this._ApiServices.getByFilters("/api/" + this.tableName + "Views/getbyfilters?", filters);
813
- };
814
-
815
- _proto.add = function add(data) {
816
- return this._ApiServices.post("/api/DashBoards", data);
817
- };
818
-
819
- return DashBoardService;
820
- }();
821
-
822
- var WidgetTypeListService = /*#__PURE__*/function () {
823
- function WidgetTypeListService() {
824
- this._ApiServices = new ApiServices();
825
- }
826
-
827
- var _proto = WidgetTypeListService.prototype;
828
-
829
- _proto.getDataByFilters = function getDataByFilters(filters) {
830
- return this._ApiServices.getByFilters("/api/WidgetTypeViews/getbyfilters?", filters);
831
- };
832
-
833
- _proto.getAll = function getAll() {
834
- return this._ApiServices.get("/api/WidgetTypeViews/getall");
835
- };
836
-
837
- return WidgetTypeListService;
838
- }();
839
-
840
- function deepClone(obj) {
841
- return JSON.parse(JSON.stringify(obj));
842
- }
843
-
844
806
  var Dashboard = function Dashboard(props) {
845
807
  var _props$token;
846
808
 
847
- var newWidgetWidth = 3;
848
- var newWidgetHeight = 5;
849
-
850
- var _useState = React.useState([]),
851
- dashbords = _useState[0],
852
- setDashbords = _useState[1];
853
-
854
- var _useState2 = React.useState(undefined),
855
- currentDashbord = _useState2[0],
856
- setCurrentDashbord = _useState2[1];
857
-
858
- var _useState3 = React.useState(undefined),
859
- beforEditDashbord = _useState3[0],
860
- setBeforEditDashbord = _useState3[1];
861
-
862
- var _useState4 = React.useState(false),
863
- hasChanges = _useState4[0],
864
- setHasChanges = _useState4[1];
865
-
866
- var _useState5 = React.useState(false),
867
- isInEditMode = _useState5[0],
868
- setIsInEditMode = _useState5[1];
869
-
870
- var _useState6 = React.useState(),
871
- WidgetTypes = _useState6[0],
872
- setWidgetTypes = _useState6[1];
873
-
874
- var _useState7 = React.useState({
809
+ var _useState = React.useState({
875
810
  lg: []
876
811
  }),
877
- layouts = _useState7[0],
878
- setLayouts = _useState7[1];
812
+ Widgetlayouts = _useState[0],
813
+ setWidgetLayouts = _useState[1];
879
814
 
880
- var _useState8 = React.useState(false),
881
- cancelConfirmDialog = _useState8[0],
882
- setCancelConfirmDialog = _useState8[1];
815
+ var _useState2 = React.useState(false),
816
+ isInEditMode = _useState2[0],
817
+ setIsInEditMode = _useState2[1];
883
818
 
884
- var dashboardMoreButtonToggle = React.createRef();
885
- var dashboardService = new DashBoardService();
886
- var widgetTypeListService = new WidgetTypeListService();
887
819
  React.useEffect(function () {
888
- getWidgetTypes();
889
- props.dataBinding.onGetDashboard.subscribe(function (e) {
890
- console.log('onGetDashboard.subscribe', e);
891
- setCurrentDashbord(e);
892
- applyLayouts(e);
820
+ props.dataBinding.onGetLayouts.subscribe(function (layouts) {
821
+ applyLayouts(layouts);
893
822
  });
894
- props.dataBinding.onGetAllDashboards.subscribe(function (e) {
895
- console.log('onGetAllDashboard.subscribe', e);
896
- setDashbords(e);
897
- });
898
- props.dataBinding.onAddUpdateWidget.subscribe(function (isUpdated) {
899
- if (!isUpdated) return;
900
- setHasChanges(true);
823
+ props.dataBinding.isOnEditLayout.subscribe(function (e) {
824
+ setIsInEditMode(e);
901
825
  });
902
826
  }, []);
903
827
  if ((props === null || props === void 0 ? void 0 : (_props$token = props.token) === null || _props$token === void 0 ? void 0 : _props$token.length) > 0) localStorage.setItem("token", props === null || props === void 0 ? void 0 : props.token);
904
828
 
905
- var getWidgetTypes = function getWidgetTypes() {
906
- widgetTypeListService.getAll().then(function (data) {
907
- setWidgetTypes(data.data);
908
- });
909
- };
910
-
911
- var EditDashBoard = function EditDashBoard() {
912
- var _dashboardMoreButtonT;
913
-
914
- props.openAddEditDashboard(currentDashbord);
915
- dashboardMoreButtonToggle === null || dashboardMoreButtonToggle === void 0 ? void 0 : (_dashboardMoreButtonT = dashboardMoreButtonToggle.current) === null || _dashboardMoreButtonT === void 0 ? void 0 : _dashboardMoreButtonT.hide();
916
- };
917
-
918
- var addWidget = function addWidget(widgetCode) {
919
- var position = EvaluateNewWidgetPosition();
920
- props.openAddEditWidget({
921
- TypeCode: widgetCode,
922
- StartPotistion: position.x + "," + position.y,
923
- EndPosition: position.w + "," + position.h,
924
- ChangeSetOp: 'Insert'
925
- });
926
- };
927
-
928
- var EvaluateNewWidgetPosition = function EvaluateNewWidgetPosition() {
929
- var widgetYPosition = 0;
930
- var widgetXPosition = 0;
931
- var allLayouts = layouts["lg"].map(function (e) {
932
- return e.Layout;
933
- });
934
-
935
- for (var y = 0; true; y++) {
936
- widgetYPosition = y;
937
-
938
- for (var x = 0; x < 10; x++) {
939
- widgetXPosition = x;
940
- var exisitWidgetInNewPosition = allLayouts.find(function (e) {
941
- return e && widgetXPosition < e.x + e.w && widgetXPosition + newWidgetWidth > e.x && widgetYPosition < e.y + e.h && widgetYPosition + newWidgetHeight > e.y;
942
- });
943
- if (!exisitWidgetInNewPosition) return {
944
- x: widgetXPosition,
945
- y: widgetYPosition,
946
- w: newWidgetWidth,
947
- h: newWidgetHeight
948
- };
949
- }
950
- }
951
- };
952
-
953
- var editLayout = function editLayout() {
954
- var _dashboardMoreButtonT2;
955
-
956
- setIsInEditMode(true);
957
- setHasChanges(false);
958
- dashboardMoreButtonToggle === null || dashboardMoreButtonToggle === void 0 ? void 0 : (_dashboardMoreButtonT2 = dashboardMoreButtonToggle.current) === null || _dashboardMoreButtonT2 === void 0 ? void 0 : _dashboardMoreButtonT2.hide();
959
- setBeforEditDashbord(deepClone(currentDashbord));
960
- };
961
-
962
- var save = function save() {
963
- setIsInEditMode(false);
964
- console.log('onSaveDashboard > ', currentDashbord);
965
- props.onSaveDashboard(currentDashbord);
966
- onHide();
967
- setHasChanges(false);
968
- };
969
-
970
- var cancelSave = function cancelSave() {
971
- if (!hasChanges) {
972
- setIsInEditMode(false);
973
- setHasChanges(false);
974
- } else {
975
- setCancelConfirmDialog(true);
976
- }
977
- };
978
-
979
- var dontSave = function dontSave() {
980
- setHasChanges(false);
981
- setIsInEditMode(false);
982
- props.dataBinding.onGetDashboard.next(beforEditDashbord);
983
- setCancelConfirmDialog(false);
984
- };
985
-
986
- var changeDashboard = function changeDashboard(event) {
987
- if (event.value == (currentDashbord === null || currentDashbord === void 0 ? void 0 : currentDashbord.Id)) return;
988
- var dasboard = dashbords.find(function (e) {
989
- return e.Id == event.value;
990
- });
991
- props.onChangeDashboard(dasboard);
992
- props.dataBinding.onGetDashboard.next(dasboard);
993
- };
994
-
995
- var applyLayouts = function applyLayouts(dashbord) {
996
- if (!(dashbord !== null && dashbord !== void 0 && dashbord.Widgets)) return;
997
- var layout = {
998
- lg: []
999
- };
1000
- dashbord === null || dashbord === void 0 ? void 0 : dashbord.Widgets.map(function (widget) {
829
+ var applyLayouts = function applyLayouts(widgets) {
830
+ if (!widgets) return;
831
+ widgets.lg.map(function (widget) {
1001
832
  if (widget.Id && widget.Id.length > 0) widget.key = widget.Id;else widget.key = uuid.v4();
1002
833
  widget.Layout = {
1003
834
  minH: 5,
@@ -1008,10 +839,9 @@ var Dashboard = function Dashboard(props) {
1008
839
  x: +widget.StartPotistion.split(',')[0],
1009
840
  y: +widget.StartPotistion.split(',')[1]
1010
841
  };
1011
- layout.lg.push(widget);
1012
842
  });
1013
- console.log('setLayouts -- > ', layout);
1014
- setLayouts(layout);
843
+ console.log('setLayouts -- > ', widgets);
844
+ setWidgetLayouts(widgets);
1015
845
  };
1016
846
 
1017
847
  var updateWidgets = function updateWidgets(layouts) {
@@ -1025,160 +855,28 @@ var Dashboard = function Dashboard(props) {
1025
855
  return;
1026
856
  }
1027
857
  });
1028
- var widgets = [];
1029
- currentDashbord === null || currentDashbord === void 0 ? void 0 : currentDashbord.Widgets.forEach(function (widget) {
858
+ Widgetlayouts.lg.forEach(function (widget) {
1030
859
  if (layoutsDic[widget.key]) {
1031
860
  widget.StartPotistion = layoutsDic[widget.key].x + "," + layoutsDic[widget.key].y;
1032
861
  widget.EndPosition = layoutsDic[widget.key].w + "," + layoutsDic[widget.key].h;
1033
862
  widget.Layout = layoutsDic[widget.key];
1034
- widgets.push(widget);
1035
863
  }
1036
864
  });
1037
-
1038
- if (currentDashbord) {
1039
- currentDashbord.Widgets = widgets;
1040
- }
1041
-
1042
- console.log('after update widget', currentDashbord);
1043
- setHasChanges(true);
1044
- };
1045
-
1046
- var renderCancelConfirmDialogFooter = function renderCancelConfirmDialogFooter() {
1047
- return React.createElement("div", {
1048
- className: 'dl-flex-row-end'
1049
- }, React.createElement(button.Button, {
1050
- label: "Cancel",
1051
- onClick: function onClick() {
1052
- return onHide();
1053
- },
1054
- className: "p-button-secondary"
1055
- }), React.createElement(button.Button, {
1056
- label: "Don't Save",
1057
- onClick: function onClick() {
1058
- return dontSave();
1059
- },
1060
- className: "p-button-secondary"
1061
- }), React.createElement(button.Button, {
1062
- label: "Save",
1063
- onClick: function onClick() {
1064
- return save();
1065
- },
1066
- autoFocus: true,
1067
- className: "p-button-warning"
1068
- }));
1069
- };
1070
-
1071
- var onHide = function onHide() {
1072
- setCancelConfirmDialog(false);
865
+ console.log('after update widget', Widgetlayouts);
866
+ props.onChangeLayouts(Widgetlayouts);
1073
867
  };
1074
868
 
1075
869
  return React.createElement("div", {
1076
870
  className: 'dl-full-hight'
1077
871
  }, React.createElement("div", {
1078
- className: 'dl-dashboard-header dl-card'
1079
- }, React.createElement("div", {
1080
- className: 'dl-flex-row dl-custom-btn'
1081
- }, React.createElement("div", {
1082
- className: 'dl-title-1'
1083
- }, currentDashbord === null || currentDashbord === void 0 ? void 0 : currentDashbord.Name), React.createElement(button.Button, {
1084
- icon: "pi pi-ellipsis-v",
1085
- onClick: function onClick(e) {
1086
- var _dashboardMoreButtonT3;
1087
-
1088
- return dashboardMoreButtonToggle === null || dashboardMoreButtonToggle === void 0 ? void 0 : (_dashboardMoreButtonT3 = dashboardMoreButtonToggle.current) === null || _dashboardMoreButtonT3 === void 0 ? void 0 : _dashboardMoreButtonT3.toggle(e);
1089
- },
1090
- className: "p-button p-button-icon-only p-button-rounded p-button-text"
1091
- }, React.createElement(ripple.Ripple, null)), React.createElement(overlaypanel.OverlayPanel, {
1092
- ref: dashboardMoreButtonToggle,
1093
- className: "buttons-overlay"
1094
- }, React.createElement("div", {
1095
- className: "buttons-list"
1096
- }, React.createElement("div", {
1097
- onClick: function onClick() {
1098
- return EditDashBoard();
1099
- }
1100
- }, "Edit"), React.createElement("div", {
1101
- onClick: editLayout
1102
- }, "Edit Layout")))), React.createElement("div", {
1103
- className: 'dl-flex-row'
1104
- }, !isInEditMode ? React.createElement("div", {
1105
- className: 'dl-flex-row'
1106
- }, React.createElement("div", {
1107
- style: {
1108
- width: "161px"
1109
- }
1110
- }, React.createElement(dropdown.Dropdown, {
1111
- value: [],
1112
- options: dashbords,
1113
- optionValue: "Id",
1114
- optionLabel: "Name",
1115
- onChange: changeDashboard,
1116
- placeholder: "Choose Dashboard",
1117
- optionDisabled: function optionDisabled(option) {
1118
- return option === null || option === void 0 ? void 0 : option.Disabled;
1119
- },
1120
- scrollHeight: "300px",
1121
- style: {
1122
- width: '100%'
1123
- }
1124
- })), React.createElement(button.Button, {
1125
- icon: "pi pi-plus",
1126
- onClick: function onClick() {
1127
- return props.openAddEditDashboard(undefined);
1128
- },
1129
- className: "dl-dashboard-add p-button-rounded p-button-success"
1130
- })) : null, isInEditMode ? React.createElement("div", {
1131
- className: 'dl-flex-row'
1132
- }, React.createElement(button.Button, {
1133
- label: "Cancel",
1134
- className: "p-button-secondary dl-m-r-s ",
1135
- onClick: cancelSave
1136
- }), React.createElement(dialog.Dialog, {
1137
- header: "Unsaved Changes",
1138
- visible: cancelConfirmDialog,
1139
- style: {
1140
- width: '50vw'
1141
- },
1142
- footer: renderCancelConfirmDialogFooter(),
1143
- onHide: onHide
1144
- }, React.createElement("p", null, "This Dashboard has unsaved changes do you want to save it?")), hasChanges ? React.createElement(button.Button, {
1145
- label: "Save",
1146
- form: "frm",
1147
- onClick: save,
1148
- autoFocus: true,
1149
- className: "p-button-warning "
1150
- }) : null, !hasChanges ? React.createElement(button.Button, {
1151
- label: "Save",
1152
- form: "frm",
1153
- onClick: save,
1154
- autoFocus: true,
1155
- className: "p-button-secondary "
1156
- }) : null, React.createElement("div", {
1157
- style: {
1158
- width: '192px',
1159
- marginLeft: '15px'
1160
- }
1161
- }, React.createElement(dropdown.Dropdown, {
1162
- options: WidgetTypes,
1163
- optionValue: "Code",
1164
- optionLabel: "Name",
1165
- onChange: function onChange(e) {
1166
- return addWidget(e.value);
1167
- },
1168
- placeholder: "Add Component",
1169
- optionDisabled: function optionDisabled(option) {
1170
- return option === null || option === void 0 ? void 0 : option.Disabled;
1171
- },
1172
- scrollHeight: "300px"
1173
- }))) : null)), React.createElement("div", {
1174
872
  className: 'dl-dashboard-body'
1175
873
  }, React.createElement(DashboardDesigner, {
1176
874
  onSelectDataPoint: props.onSelectDataPoint,
1177
875
  editMode: isInEditMode,
1178
876
  onLayoutChange: updateWidgets,
1179
- dashboardLayouts: layouts,
877
+ dashboardLayouts: Widgetlayouts,
1180
878
  openEditWidget: function openEditWidget(widget) {
1181
- return props.openAddEditWidget(widget);
879
+ return props.openEditWidget(widget);
1182
880
  }
1183
881
  })));
1184
882
  };