logitude-dashboard-library 1.2.21 → 1.2.24
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/assets/styles/dl-dashboard.scss +18 -1
- package/dist/features/Dashboard/dashboard-dialog/dashboard-dialog-component.d.ts +7 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +287 -12
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +288 -13
- package/dist/index.modern.js.map +1 -1
- package/dist/services/ApiServices.d.ts +10 -0
- package/dist/services/DashBoardService.d.ts +10 -0
- package/dist/services/DataService.d.ts +2 -0
- package/dist/services/session.d.ts +5 -0
- package/dist/services/tools.d.ts +3 -0
- package/dist/types/APIResult.d.ts +5 -0
- package/dist/types/Dashboard.d.ts +11 -0
- package/package.json +1 -1
package/dist/index.modern.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import React__default, { useRef, useState, createRef, createElement } from 'react';
|
|
1
|
+
import React__default, { useRef, useState, createRef, useEffect, createElement } from 'react';
|
|
2
|
+
import { Button } from 'primereact/button';
|
|
2
3
|
import { WidthProvider, Responsive } from 'react-grid-layout';
|
|
3
4
|
import _ from 'lodash';
|
|
4
5
|
import { Dropdown } from 'primereact/dropdown';
|
|
5
6
|
import { Dialog } from 'primereact/dialog';
|
|
6
7
|
import { InputText } from 'primereact/inputtext';
|
|
7
|
-
import { Button } from 'primereact/button';
|
|
8
8
|
import axios from 'axios';
|
|
9
9
|
import ReactApexChart from 'react-apexcharts';
|
|
10
10
|
import { OverlayPanel } from 'primereact/overlaypanel';
|
|
11
|
+
import { InputTextarea } from 'primereact/inputtextarea';
|
|
11
12
|
|
|
12
13
|
function _extends() {
|
|
13
14
|
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
@@ -41,14 +42,37 @@ function _setPrototypeOf(o, p) {
|
|
|
41
42
|
return _setPrototypeOf(o, p);
|
|
42
43
|
}
|
|
43
44
|
|
|
45
|
+
var Tools = /*#__PURE__*/function () {
|
|
46
|
+
function Tools() {}
|
|
47
|
+
|
|
48
|
+
Tools.GetLogitudeURL = function GetLogitudeURL() {
|
|
49
|
+
var logitude_url = location.href.replace('index.html', '');
|
|
50
|
+
|
|
51
|
+
if (location.href.indexOf('localhost') > -1) {
|
|
52
|
+
logitude_url = 'http://localhost:9996';
|
|
53
|
+
} else {
|
|
54
|
+
var urlArr = location.href.split("/index.html");
|
|
55
|
+
var url = urlArr[0];
|
|
56
|
+
url = url.replace(url.substring(url.lastIndexOf('/'), url.length), "");
|
|
57
|
+
logitude_url = url;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return logitude_url;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
return Tools;
|
|
64
|
+
}();
|
|
65
|
+
|
|
44
66
|
var DataService = /*#__PURE__*/function () {
|
|
45
|
-
function DataService() {
|
|
67
|
+
function DataService() {
|
|
68
|
+
this._apiUrl = Tools.GetLogitudeURL();
|
|
69
|
+
}
|
|
46
70
|
|
|
47
71
|
var _proto = DataService.prototype;
|
|
48
72
|
|
|
49
73
|
_proto.getObjectTables = function getObjectTables(filters) {
|
|
50
74
|
var token = this.getTokenFromStorage();
|
|
51
|
-
var apiURL =
|
|
75
|
+
var apiURL = this._apiUrl + "/api/ObjectTableViews/getbyfilters?";
|
|
52
76
|
apiURL = this.ConcatFiltersToURL(filters, apiURL);
|
|
53
77
|
return axios.get(apiURL, {
|
|
54
78
|
headers: {
|
|
@@ -60,7 +84,7 @@ var DataService = /*#__PURE__*/function () {
|
|
|
60
84
|
|
|
61
85
|
_proto.getObjectFields = function getObjectFields(filters) {
|
|
62
86
|
var token = this.getTokenFromStorage();
|
|
63
|
-
var apiURL =
|
|
87
|
+
var apiURL = this._apiUrl + "/api/ObjectFieldViews/getbyfilters?";
|
|
64
88
|
apiURL = this.ConcatFiltersToURL(filters, apiURL);
|
|
65
89
|
return axios.get(apiURL, {
|
|
66
90
|
headers: {
|
|
@@ -72,7 +96,7 @@ var DataService = /*#__PURE__*/function () {
|
|
|
72
96
|
|
|
73
97
|
_proto.getDataByFilters = function getDataByFilters(filters, tableName) {
|
|
74
98
|
var token = this.getTokenFromStorage();
|
|
75
|
-
var apiURL = "
|
|
99
|
+
var apiURL = this._apiUrl + "/api/" + tableName + "Views/getbyfilters?";
|
|
76
100
|
apiURL = this.ConcatFiltersToURL(filters, apiURL);
|
|
77
101
|
return axios.get(apiURL, {
|
|
78
102
|
headers: {
|
|
@@ -1064,9 +1088,7 @@ var DashboardDesigner = function DashboardDesigner() {
|
|
|
1064
1088
|
setWidgetToEdit = _useState13[1];
|
|
1065
1089
|
|
|
1066
1090
|
var renderPageHeader = function renderPageHeader() {
|
|
1067
|
-
return React__default.createElement("
|
|
1068
|
-
className: "dl-dashboard-header"
|
|
1069
|
-
}, React__default.createElement("div", {
|
|
1091
|
+
return React__default.createElement("div", {
|
|
1070
1092
|
className: "dl-heder-row"
|
|
1071
1093
|
}, React__default.createElement("div", {
|
|
1072
1094
|
style: {
|
|
@@ -1085,7 +1107,7 @@ var DashboardDesigner = function DashboardDesigner() {
|
|
|
1085
1107
|
return option === null || option === void 0 ? void 0 : option.Disabled;
|
|
1086
1108
|
},
|
|
1087
1109
|
scrollHeight: "300px"
|
|
1088
|
-
})))
|
|
1110
|
+
})));
|
|
1089
1111
|
};
|
|
1090
1112
|
|
|
1091
1113
|
function addComponent(componentType) {
|
|
@@ -1351,11 +1373,264 @@ var WidgetTypes = [{
|
|
|
1351
1373
|
Disabled: true
|
|
1352
1374
|
}];
|
|
1353
1375
|
|
|
1376
|
+
var ApiServices = /*#__PURE__*/function () {
|
|
1377
|
+
function ApiServices() {
|
|
1378
|
+
this._apiUrl = Tools.GetLogitudeURL();
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
var _proto = ApiServices.prototype;
|
|
1382
|
+
|
|
1383
|
+
_proto.getByFilters = function getByFilters(api, filters) {
|
|
1384
|
+
var token = this.getTokenFromStorage();
|
|
1385
|
+
var apiURL = "" + this._apiUrl + api;
|
|
1386
|
+
apiURL = this.ConcatFiltersToURL(filters, apiURL);
|
|
1387
|
+
return axios.get(apiURL, {
|
|
1388
|
+
headers: {
|
|
1389
|
+
'Content-Type': 'application/json',
|
|
1390
|
+
'Token': token
|
|
1391
|
+
}
|
|
1392
|
+
});
|
|
1393
|
+
};
|
|
1394
|
+
|
|
1395
|
+
_proto.post = function post(api, date) {
|
|
1396
|
+
var token = this.getTokenFromStorage();
|
|
1397
|
+
var apiURL = "" + this._apiUrl + api;
|
|
1398
|
+
return axios.post(apiURL, date, {
|
|
1399
|
+
headers: {
|
|
1400
|
+
'Content-Type': 'application/json',
|
|
1401
|
+
'Token': token
|
|
1402
|
+
}
|
|
1403
|
+
});
|
|
1404
|
+
};
|
|
1405
|
+
|
|
1406
|
+
_proto.getTokenFromStorage = function getTokenFromStorage() {
|
|
1407
|
+
return window.localStorage.getItem("token") || '';
|
|
1408
|
+
};
|
|
1409
|
+
|
|
1410
|
+
_proto.ConcatFiltersToURL = function ConcatFiltersToURL(filters, urlparameters) {
|
|
1411
|
+
var mykeys = Object.keys(filters);
|
|
1412
|
+
var addtionalFiltersValues = null;
|
|
1413
|
+
|
|
1414
|
+
for (var i in mykeys) {
|
|
1415
|
+
var propName = mykeys[i];
|
|
1416
|
+
var propValue = filters[propName];
|
|
1417
|
+
var ignoreFilter = propName.indexOf("Operator") > 0 && propValue == "Equals" || propName == "AdditionalFilters";
|
|
1418
|
+
|
|
1419
|
+
if (urlparameters != "?") {
|
|
1420
|
+
urlparameters = urlparameters.concat('&');
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1423
|
+
if (!ignoreFilter) {
|
|
1424
|
+
propValue = propValue ? encodeURIComponent(propValue) : '';
|
|
1425
|
+
urlparameters = urlparameters.concat(propName.concat('=').concat(propValue));
|
|
1426
|
+
}
|
|
1427
|
+
|
|
1428
|
+
if (propName == "AdditionalFilters" && propValue.length > 0) {
|
|
1429
|
+
addtionalFiltersValues = JSON.stringify(propValue);
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1433
|
+
if (addtionalFiltersValues) {
|
|
1434
|
+
urlparameters = urlparameters.concat("&AdditionalFilters=").concat(addtionalFiltersValues);
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1437
|
+
return urlparameters;
|
|
1438
|
+
};
|
|
1439
|
+
|
|
1440
|
+
return ApiServices;
|
|
1441
|
+
}();
|
|
1442
|
+
|
|
1443
|
+
var DashBoardService = /*#__PURE__*/function () {
|
|
1444
|
+
function DashBoardService() {
|
|
1445
|
+
this.tableName = 'DashBoard';
|
|
1446
|
+
this._ApiServices = new ApiServices();
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1449
|
+
var _proto = DashBoardService.prototype;
|
|
1450
|
+
|
|
1451
|
+
_proto.getDataByFilters = function getDataByFilters(filters) {
|
|
1452
|
+
return this._ApiServices.getByFilters("/api/" + this.tableName + "Views/getbyfilters?", filters);
|
|
1453
|
+
};
|
|
1454
|
+
|
|
1455
|
+
_proto.add = function add(data) {
|
|
1456
|
+
return this._ApiServices.post("/api/DashBoards", data);
|
|
1457
|
+
};
|
|
1458
|
+
|
|
1459
|
+
return DashBoardService;
|
|
1460
|
+
}();
|
|
1461
|
+
|
|
1462
|
+
var Session = function Session() {};
|
|
1463
|
+
|
|
1464
|
+
var DashboardDialogComponent = function DashboardDialogComponent(props) {
|
|
1465
|
+
var _useState = useState(''),
|
|
1466
|
+
name = _useState[0],
|
|
1467
|
+
setName = _useState[1];
|
|
1468
|
+
|
|
1469
|
+
var _useState2 = useState(''),
|
|
1470
|
+
description = _useState2[0],
|
|
1471
|
+
setDescription = _useState2[1];
|
|
1472
|
+
|
|
1473
|
+
var _useState3 = useState(props.display),
|
|
1474
|
+
displayAddDashboard = _useState3[0],
|
|
1475
|
+
setDisplayAddDashboard = _useState3[1];
|
|
1476
|
+
|
|
1477
|
+
var _useState4 = useState({}),
|
|
1478
|
+
validation = _useState4[0],
|
|
1479
|
+
setValidation = _useState4[1];
|
|
1480
|
+
|
|
1481
|
+
useEffect(function () {
|
|
1482
|
+
setDisplayAddDashboard(props.display);
|
|
1483
|
+
}, [props.display]);
|
|
1484
|
+
|
|
1485
|
+
var onSave = function onSave() {
|
|
1486
|
+
if (!checkFormValidation()) return;
|
|
1487
|
+
var dashBoardService = new DashBoardService();
|
|
1488
|
+
var dasboard = {
|
|
1489
|
+
Name: name,
|
|
1490
|
+
Description: description,
|
|
1491
|
+
Tenant: Session.Tenant,
|
|
1492
|
+
UpdatedByUserId: Session.CurrentUserId,
|
|
1493
|
+
CreatedByUserId: Session.CurrentUserId
|
|
1494
|
+
};
|
|
1495
|
+
dashBoardService.add(dasboard).then(function (e) {
|
|
1496
|
+
onCancel();
|
|
1497
|
+
});
|
|
1498
|
+
};
|
|
1499
|
+
|
|
1500
|
+
var checkFormValidation = function checkFormValidation() {
|
|
1501
|
+
var isValid = true;
|
|
1502
|
+
var formValidation = {};
|
|
1503
|
+
|
|
1504
|
+
if ((name === null || name === void 0 ? void 0 : name.length) == 0) {
|
|
1505
|
+
formValidation['name'] = true;
|
|
1506
|
+
isValid = false;
|
|
1507
|
+
} else {
|
|
1508
|
+
formValidation['name'] = false;
|
|
1509
|
+
}
|
|
1510
|
+
|
|
1511
|
+
console.log(formValidation['name']);
|
|
1512
|
+
setValidation(formValidation);
|
|
1513
|
+
return isValid;
|
|
1514
|
+
};
|
|
1515
|
+
|
|
1516
|
+
var onCancel = function onCancel() {
|
|
1517
|
+
setDisplayAddDashboard(false);
|
|
1518
|
+
props.onClose();
|
|
1519
|
+
clear();
|
|
1520
|
+
};
|
|
1521
|
+
|
|
1522
|
+
var clear = function clear() {
|
|
1523
|
+
setDescription('');
|
|
1524
|
+
setName('');
|
|
1525
|
+
};
|
|
1526
|
+
|
|
1527
|
+
return React__default.createElement(Dialog, {
|
|
1528
|
+
header: "New Dashboard",
|
|
1529
|
+
visible: displayAddDashboard,
|
|
1530
|
+
style: {
|
|
1531
|
+
width: 'auto'
|
|
1532
|
+
},
|
|
1533
|
+
onHide: onCancel
|
|
1534
|
+
}, React__default.createElement("form", {
|
|
1535
|
+
id: "dashboard-crd",
|
|
1536
|
+
name: "dashboard-crd"
|
|
1537
|
+
}, React__default.createElement("div", {
|
|
1538
|
+
className: "form"
|
|
1539
|
+
}, React__default.createElement("div", {
|
|
1540
|
+
className: "form-field"
|
|
1541
|
+
}, React__default.createElement("label", {
|
|
1542
|
+
htmlFor: "dashboard-name"
|
|
1543
|
+
}, "Name"), React__default.createElement(InputText, {
|
|
1544
|
+
id: "dashboard-name",
|
|
1545
|
+
className: "p-inputtext-sm " + (validation['name'] ? 'p-invalid' : ''),
|
|
1546
|
+
value: name,
|
|
1547
|
+
required: true,
|
|
1548
|
+
onChange: function onChange(e) {
|
|
1549
|
+
setName(e.target.value);
|
|
1550
|
+
}
|
|
1551
|
+
})), React__default.createElement("div", {
|
|
1552
|
+
className: "form-field"
|
|
1553
|
+
}, React__default.createElement("label", {
|
|
1554
|
+
htmlFor: "dashboard-description"
|
|
1555
|
+
}, "Description"), React__default.createElement(InputTextarea, {
|
|
1556
|
+
id: "dashboard-description",
|
|
1557
|
+
className: "p-inputtext-sm",
|
|
1558
|
+
value: description,
|
|
1559
|
+
onChange: function onChange(e) {
|
|
1560
|
+
setDescription(e.target.value);
|
|
1561
|
+
}
|
|
1562
|
+
}))), React__default.createElement("div", {
|
|
1563
|
+
className: "dialog-footer dl-m-t-s"
|
|
1564
|
+
}, React__default.createElement(Button, {
|
|
1565
|
+
label: "Cancel",
|
|
1566
|
+
className: "p-button-text",
|
|
1567
|
+
onClick: onCancel
|
|
1568
|
+
}), React__default.createElement(Button, {
|
|
1569
|
+
label: "Ok",
|
|
1570
|
+
form: "frm",
|
|
1571
|
+
onClick: onSave,
|
|
1572
|
+
autoFocus: true
|
|
1573
|
+
}))));
|
|
1574
|
+
};
|
|
1575
|
+
|
|
1354
1576
|
var Dashboard = function Dashboard(props) {
|
|
1355
|
-
|
|
1356
|
-
|
|
1577
|
+
var _props$token;
|
|
1578
|
+
|
|
1579
|
+
var _useState = useState([]),
|
|
1580
|
+
dashbords = _useState[0],
|
|
1581
|
+
setDashbords = _useState[1];
|
|
1582
|
+
|
|
1583
|
+
var _useState2 = useState(false),
|
|
1584
|
+
displayAddDashboard = _useState2[0],
|
|
1585
|
+
setDisplayAddDashboard = _useState2[1];
|
|
1586
|
+
|
|
1587
|
+
var dashboardService = new DashBoardService();
|
|
1588
|
+
useEffect(function () {
|
|
1589
|
+
getDashboards();
|
|
1590
|
+
}, []);
|
|
1591
|
+
Session.CurrentUserId = props.userId;
|
|
1592
|
+
Session.Tenant = props.tenant;
|
|
1593
|
+
Session.Token = props.token;
|
|
1594
|
+
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);
|
|
1595
|
+
|
|
1596
|
+
var onDashboardDialogClose = function onDashboardDialogClose() {
|
|
1597
|
+
getDashboards();
|
|
1598
|
+
setDisplayAddDashboard(false);
|
|
1599
|
+
};
|
|
1600
|
+
|
|
1601
|
+
var getDashboards = function getDashboards() {
|
|
1602
|
+
dashboardService.getDataByFilters(new ApiQueryFilters()).then(function (data) {
|
|
1603
|
+
console.log(data);
|
|
1604
|
+
setDashbords(data.data.Result);
|
|
1605
|
+
});
|
|
1606
|
+
};
|
|
1607
|
+
|
|
1608
|
+
return createElement("div", null, createElement("div", {
|
|
1609
|
+
className: 'dl-dashboard-header dl-card'
|
|
1610
|
+
}, createElement("div", null, createElement(Button, {
|
|
1611
|
+
icon: "pi pi-plus",
|
|
1612
|
+
onClick: function onClick() {
|
|
1613
|
+
return setDisplayAddDashboard(true);
|
|
1614
|
+
},
|
|
1615
|
+
className: "dl-dashboard-add p-button-rounded p-button-success",
|
|
1616
|
+
"aria-label": "Search"
|
|
1617
|
+
})), createElement(DashboardDialogComponent, {
|
|
1618
|
+
display: displayAddDashboard,
|
|
1619
|
+
onClose: onDashboardDialogClose
|
|
1620
|
+
}), createElement(Dropdown, {
|
|
1621
|
+
value: [],
|
|
1622
|
+
options: dashbords,
|
|
1623
|
+
optionValue: "Id",
|
|
1624
|
+
optionLabel: "Name",
|
|
1625
|
+
onChange: function onChange(e) {},
|
|
1626
|
+
placeholder: "Choose Dashboard",
|
|
1627
|
+
optionDisabled: function optionDisabled(option) {
|
|
1628
|
+
return option === null || option === void 0 ? void 0 : option.Disabled;
|
|
1629
|
+
},
|
|
1630
|
+
scrollHeight: "300px"
|
|
1631
|
+
})), createElement("div", {
|
|
1357
1632
|
className: 'dl-dashboard-body'
|
|
1358
|
-
}, createElement(DashboardDesigner, null));
|
|
1633
|
+
}, createElement(DashboardDesigner, null)));
|
|
1359
1634
|
};
|
|
1360
1635
|
|
|
1361
1636
|
export default Dashboard;
|