logitude-dashboard-library 1.2.23 → 1.2.26

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.
@@ -25,7 +25,7 @@ $dark-grey: #717585;
25
25
 
26
26
  .dl-dashboard-header {
27
27
  display: flex;
28
- justify-content: space-between;
28
+ flex-direction: row-reverse;
29
29
 
30
30
  }
31
31
 
@@ -264,4 +264,21 @@ $dark-grey: #717585;
264
264
 
265
265
  .hidden {
266
266
  display: none;
267
+ }
268
+
269
+ .dl-dashboard-add{
270
+ //height: 40px !important;
271
+ margin: 3px 3px 0px 8px !important;
272
+ //width: 40px !important ;
273
+ }
274
+
275
+ .dl-card{
276
+ border-radius: 19px;
277
+ background-color: #f5f6fb;
278
+ padding: 6px 0px 0px 0px;
279
+ margin: 0px 0px 10px 0px;
280
+ }
281
+
282
+ .dl-m-t-s{
283
+ margin-top: 10px;
267
284
  }
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ export declare type DashboardDialogProps = {
3
+ display: boolean;
4
+ onClose: () => void;
5
+ };
6
+ declare const DashboardDialogComponent: (props: DashboardDialogProps) => JSX.Element;
7
+ export default DashboardDialogComponent;
package/dist/index.d.ts CHANGED
@@ -2,6 +2,8 @@
2
2
  import "./styles.module.css";
3
3
  declare type DashboardProps = {
4
4
  token: string;
5
+ tenant: number;
6
+ userId: string;
5
7
  };
6
8
  declare const Dashboard: (props: DashboardProps) => JSX.Element;
7
9
  export default Dashboard;
package/dist/index.js CHANGED
@@ -2,15 +2,16 @@ 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');
5
6
  var reactGridLayout = require('react-grid-layout');
6
7
  var _ = _interopDefault(require('lodash'));
7
8
  var dropdown = require('primereact/dropdown');
8
9
  var dialog = require('primereact/dialog');
9
10
  var inputtext = require('primereact/inputtext');
10
- var button = require('primereact/button');
11
11
  var axios = _interopDefault(require('axios'));
12
12
  var ReactApexChart = _interopDefault(require('react-apexcharts'));
13
13
  var overlaypanel = require('primereact/overlaypanel');
14
+ var inputtextarea = require('primereact/inputtextarea');
14
15
 
15
16
  function _extends() {
16
17
  _extends = Object.assign ? Object.assign.bind() : function (target) {
@@ -1091,8 +1092,6 @@ var DashboardDesigner = function DashboardDesigner() {
1091
1092
 
1092
1093
  var renderPageHeader = function renderPageHeader() {
1093
1094
  return React__default.createElement("div", {
1094
- className: "dl-dashboard-header"
1095
- }, React__default.createElement("div", {
1096
1095
  className: "dl-heder-row"
1097
1096
  }, React__default.createElement("div", {
1098
1097
  style: {
@@ -1111,7 +1110,7 @@ var DashboardDesigner = function DashboardDesigner() {
1111
1110
  return option === null || option === void 0 ? void 0 : option.Disabled;
1112
1111
  },
1113
1112
  scrollHeight: "300px"
1114
- }))));
1113
+ })));
1115
1114
  };
1116
1115
 
1117
1116
  function addComponent(componentType) {
@@ -1377,11 +1376,268 @@ var WidgetTypes = [{
1377
1376
  Disabled: true
1378
1377
  }];
1379
1378
 
1379
+ var ApiServices = /*#__PURE__*/function () {
1380
+ function ApiServices() {
1381
+ this._apiUrl = Tools.GetLogitudeURL();
1382
+ }
1383
+
1384
+ var _proto = ApiServices.prototype;
1385
+
1386
+ _proto.getByFilters = function getByFilters(api, filters) {
1387
+ var token = this.getTokenFromStorage();
1388
+ var apiURL = "" + this._apiUrl + api;
1389
+ apiURL = this.ConcatFiltersToURL(filters, apiURL);
1390
+ return axios.get(apiURL, {
1391
+ headers: {
1392
+ 'Content-Type': 'application/json',
1393
+ 'Token': token
1394
+ }
1395
+ });
1396
+ };
1397
+
1398
+ _proto.post = function post(api, date) {
1399
+ var token = this.getTokenFromStorage();
1400
+ var apiURL = "" + this._apiUrl + api;
1401
+ return axios.post(apiURL, date, {
1402
+ headers: {
1403
+ 'Content-Type': 'application/json',
1404
+ 'Token': token
1405
+ }
1406
+ });
1407
+ };
1408
+
1409
+ _proto.getTokenFromStorage = function getTokenFromStorage() {
1410
+ return window.localStorage.getItem("token") || '';
1411
+ };
1412
+
1413
+ _proto.ConcatFiltersToURL = function ConcatFiltersToURL(filters, urlparameters) {
1414
+ var mykeys = Object.keys(filters);
1415
+ var addtionalFiltersValues = null;
1416
+
1417
+ for (var i in mykeys) {
1418
+ var propName = mykeys[i];
1419
+ var propValue = filters[propName];
1420
+ var ignoreFilter = propName.indexOf("Operator") > 0 && propValue == "Equals" || propName == "AdditionalFilters";
1421
+
1422
+ if (urlparameters != "?") {
1423
+ urlparameters = urlparameters.concat('&');
1424
+ }
1425
+
1426
+ if (!ignoreFilter) {
1427
+ propValue = propValue ? encodeURIComponent(propValue) : '';
1428
+ urlparameters = urlparameters.concat(propName.concat('=').concat(propValue));
1429
+ }
1430
+
1431
+ if (propName == "AdditionalFilters" && propValue.length > 0) {
1432
+ addtionalFiltersValues = JSON.stringify(propValue);
1433
+ }
1434
+ }
1435
+
1436
+ if (addtionalFiltersValues) {
1437
+ urlparameters = urlparameters.concat("&AdditionalFilters=").concat(addtionalFiltersValues);
1438
+ }
1439
+
1440
+ return urlparameters;
1441
+ };
1442
+
1443
+ return ApiServices;
1444
+ }();
1445
+
1446
+ var DashBoardService = /*#__PURE__*/function () {
1447
+ function DashBoardService() {
1448
+ this.tableName = 'DashBoard';
1449
+ this._ApiServices = new ApiServices();
1450
+ }
1451
+
1452
+ var _proto = DashBoardService.prototype;
1453
+
1454
+ _proto.getDataByFilters = function getDataByFilters(filters) {
1455
+ return this._ApiServices.getByFilters("/api/" + this.tableName + "Views/getbyfilters?", filters);
1456
+ };
1457
+
1458
+ _proto.add = function add(data) {
1459
+ return this._ApiServices.post("/api/DashBoards", data);
1460
+ };
1461
+
1462
+ return DashBoardService;
1463
+ }();
1464
+
1465
+ var Session = function Session() {};
1466
+
1467
+ var DashboardDialogComponent = function DashboardDialogComponent(props) {
1468
+ var _useState = React.useState(''),
1469
+ name = _useState[0],
1470
+ setName = _useState[1];
1471
+
1472
+ var _useState2 = React.useState(''),
1473
+ description = _useState2[0],
1474
+ setDescription = _useState2[1];
1475
+
1476
+ var _useState3 = React.useState(props.display),
1477
+ displayAddDashboard = _useState3[0],
1478
+ setDisplayAddDashboard = _useState3[1];
1479
+
1480
+ var _useState4 = React.useState({}),
1481
+ validation = _useState4[0],
1482
+ setValidation = _useState4[1];
1483
+
1484
+ React.useEffect(function () {
1485
+ setDisplayAddDashboard(props.display);
1486
+ }, [props.display]);
1487
+
1488
+ var onSave = function onSave() {
1489
+ if (!checkFormValidation()) return;
1490
+ var dashBoardService = new DashBoardService();
1491
+ var dasboard = {
1492
+ Name: name,
1493
+ Description: description,
1494
+ Tenant: Session.Tenant,
1495
+ UpdatedByUserId: Session.CurrentUserId,
1496
+ CreatedByUserId: Session.CurrentUserId
1497
+ };
1498
+ dashBoardService.add(dasboard).then(function (e) {
1499
+ onCancel();
1500
+ });
1501
+ };
1502
+
1503
+ var checkFormValidation = function checkFormValidation() {
1504
+ var isValid = true;
1505
+ var formValidation = {};
1506
+
1507
+ if ((name === null || name === void 0 ? void 0 : name.length) == 0) {
1508
+ formValidation['name'] = true;
1509
+ isValid = false;
1510
+ } else {
1511
+ formValidation['name'] = false;
1512
+ }
1513
+
1514
+ console.log(formValidation['name']);
1515
+ setValidation(formValidation);
1516
+ return isValid;
1517
+ };
1518
+
1519
+ var onCancel = function onCancel() {
1520
+ setDisplayAddDashboard(false);
1521
+ props.onClose();
1522
+ clear();
1523
+ };
1524
+
1525
+ var clear = function clear() {
1526
+ setDescription('');
1527
+ setName('');
1528
+ };
1529
+
1530
+ return React__default.createElement(dialog.Dialog, {
1531
+ header: "New Dashboard",
1532
+ visible: displayAddDashboard,
1533
+ style: {
1534
+ width: 'auto'
1535
+ },
1536
+ onHide: onCancel
1537
+ }, React__default.createElement("form", {
1538
+ id: "dashboard-crd",
1539
+ name: "dashboard-crd"
1540
+ }, React__default.createElement("div", {
1541
+ className: "form"
1542
+ }, React__default.createElement("div", {
1543
+ className: "form-field"
1544
+ }, React__default.createElement("label", {
1545
+ htmlFor: "dashboard-name"
1546
+ }, "Name"), React__default.createElement(inputtext.InputText, {
1547
+ id: "dashboard-name",
1548
+ className: "p-inputtext-sm " + (validation['name'] ? 'p-invalid' : ''),
1549
+ value: name,
1550
+ required: true,
1551
+ onChange: function onChange(e) {
1552
+ setName(e.target.value);
1553
+ }
1554
+ })), React__default.createElement("div", {
1555
+ className: "form-field"
1556
+ }, React__default.createElement("label", {
1557
+ htmlFor: "dashboard-description"
1558
+ }, "Description"), React__default.createElement(inputtextarea.InputTextarea, {
1559
+ id: "dashboard-description",
1560
+ className: "p-inputtext-sm",
1561
+ value: description,
1562
+ onChange: function onChange(e) {
1563
+ setDescription(e.target.value);
1564
+ }
1565
+ }))), React__default.createElement("div", {
1566
+ className: "dialog-footer dl-m-t-s"
1567
+ }, React__default.createElement(button.Button, {
1568
+ label: "Cancel",
1569
+ className: "p-button-text",
1570
+ onClick: onCancel
1571
+ }), React__default.createElement(button.Button, {
1572
+ label: "Ok",
1573
+ form: "frm",
1574
+ onClick: onSave,
1575
+ autoFocus: true
1576
+ }))));
1577
+ };
1578
+
1380
1579
  var Dashboard = function Dashboard(props) {
1381
- localStorage.setItem("token", props === null || props === void 0 ? void 0 : props.token);
1382
- return React.createElement("div", {
1580
+ var _props$token;
1581
+
1582
+ var _useState = React.useState([]),
1583
+ dashbords = _useState[0],
1584
+ setDashbords = _useState[1];
1585
+
1586
+ var _useState2 = React.useState(false),
1587
+ displayAddDashboard = _useState2[0],
1588
+ setDisplayAddDashboard = _useState2[1];
1589
+
1590
+ var dashboardService = new DashBoardService();
1591
+ React.useEffect(function () {
1592
+ getDashboards();
1593
+ }, []);
1594
+ Session.CurrentUserId = props.userId;
1595
+ Session.Tenant = props.tenant;
1596
+ Session.Token = props.token;
1597
+ 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);
1598
+
1599
+ var onDashboardDialogClose = function onDashboardDialogClose() {
1600
+ getDashboards();
1601
+ setDisplayAddDashboard(false);
1602
+ };
1603
+
1604
+ var getDashboards = function getDashboards() {
1605
+ dashboardService.getDataByFilters(new ApiQueryFilters()).then(function (data) {
1606
+ console.log(data);
1607
+ setDashbords(data.data.Result);
1608
+ });
1609
+ };
1610
+
1611
+ return React.createElement("div", null, React.createElement("div", {
1612
+ className: 'dl-dashboard-header dl-card'
1613
+ }, React.createElement("div", null, React.createElement(button.Button, {
1614
+ icon: "pi pi-plus",
1615
+ onClick: function onClick() {
1616
+ return setDisplayAddDashboard(true);
1617
+ },
1618
+ className: "dl-dashboard-add p-button-rounded p-button-success",
1619
+ "aria-label": "Search"
1620
+ })), React.createElement(DashboardDialogComponent, {
1621
+ display: displayAddDashboard,
1622
+ onClose: onDashboardDialogClose
1623
+ }), React.createElement("div", {
1624
+ style: {
1625
+ width: "210px"
1626
+ }
1627
+ }, React.createElement(dropdown.Dropdown, {
1628
+ value: [],
1629
+ options: dashbords,
1630
+ optionValue: "Id",
1631
+ optionLabel: "Name",
1632
+ onChange: function onChange(e) {},
1633
+ placeholder: "Choose Dashboard",
1634
+ optionDisabled: function optionDisabled(option) {
1635
+ return option === null || option === void 0 ? void 0 : option.Disabled;
1636
+ },
1637
+ scrollHeight: "300px"
1638
+ }))), React.createElement("div", {
1383
1639
  className: 'dl-dashboard-body'
1384
- }, React.createElement(DashboardDesigner, null));
1640
+ }, React.createElement(DashboardDesigner, null)));
1385
1641
  };
1386
1642
 
1387
1643
  module.exports = Dashboard;