ui-soxo-bootstrap-core 2.6.1-dev.10 → 2.6.1-dev.12

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,4 +1,4 @@
1
- import React, { useState, useEffect, useContext } from 'react';
1
+ import React, { useState, useEffect, useContext, useRef } from 'react';
2
2
 
3
3
  import { Route, Switch } from 'react-router-dom';
4
4
 
@@ -18,13 +18,33 @@ import PropTypes from 'prop-types';
18
18
 
19
19
  import { MenusAPI, CoreScripts } from '../../models';
20
20
 
21
+ const motivatingMessages = [
22
+ 'Setting things up for a great start...',
23
+ 'Good things are loading. Stay with us.',
24
+ 'Almost there. Preparing your workspace.',
25
+ 'You are one moment away from your dashboard.',
26
+ 'Getting everything ready for you.',
27
+ 'Great care takes a second. Loading now.',
28
+ ];
29
+
30
+ function getRandomMessage(previousMessage = '') {
31
+ const options = motivatingMessages.filter((message) => message !== previousMessage);
32
+
33
+ if (!options.length) {
34
+ return motivatingMessages[0];
35
+ }
36
+
37
+ const randomIndex = Math.floor(Math.random() * options.length);
38
+ return options[randomIndex];
39
+ }
40
+
21
41
  /**
22
42
  * Landing API
23
43
  *
24
44
  * @param {*} param0
25
45
  * @returns
26
46
  */
27
- export default function LandingApi({ history, CustomComponents, CustomModels, appSettings, ...props }) {
47
+ export default function LandingApi({ history, CustomComponents, CustomModels, appSettings, transitionPending = false, onHomeReady, ...props }) {
28
48
  const [loader, setLoader] = useState(false);
29
49
 
30
50
  // const [modules, setModules] = useState([]);
@@ -34,8 +54,11 @@ export default function LandingApi({ history, CustomComponents, CustomModels, ap
34
54
  const { dispatch, user = {} } = useContext(GlobalContext);
35
55
 
36
56
  const [allModules, setAllModules] = useState();
57
+ const homeReadyNotifiedRef = useRef(false);
58
+ const messageIntervalRef = useRef(null);
37
59
 
38
60
  const [meta, setMeta] = useState({});
61
+ const [loadingMessage, setLoadingMessage] = useState('');
39
62
 
40
63
  // const [reports, setReports] = useState([]);
41
64
 
@@ -70,6 +93,46 @@ export default function LandingApi({ history, CustomComponents, CustomModels, ap
70
93
  initializeUserMenus();
71
94
  }, []);
72
95
 
96
+ useEffect(() => {
97
+ if (!transitionPending) {
98
+ homeReadyNotifiedRef.current = false;
99
+ return;
100
+ }
101
+
102
+ if (!loader && allModules && !homeReadyNotifiedRef.current) {
103
+ homeReadyNotifiedRef.current = true;
104
+ if (typeof onHomeReady === 'function') {
105
+ onHomeReady();
106
+ }
107
+ }
108
+ }, [transitionPending, loader, allModules, onHomeReady]);
109
+
110
+ useEffect(() => {
111
+ if (!loader) {
112
+ setLoadingMessage('');
113
+
114
+ if (messageIntervalRef.current) {
115
+ clearInterval(messageIntervalRef.current);
116
+ messageIntervalRef.current = null;
117
+ }
118
+
119
+ return;
120
+ }
121
+
122
+ setLoadingMessage((previousMessage) => getRandomMessage(previousMessage));
123
+
124
+ messageIntervalRef.current = setInterval(() => {
125
+ setLoadingMessage((previousMessage) => getRandomMessage(previousMessage));
126
+ }, 2200);
127
+
128
+ return () => {
129
+ if (messageIntervalRef.current) {
130
+ clearInterval(messageIntervalRef.current);
131
+ messageIntervalRef.current = null;
132
+ }
133
+ };
134
+ }, [loader]);
135
+
73
136
  /**
74
137
  * Initialize the user menus
75
138
  */
@@ -245,6 +308,7 @@ export default function LandingApi({ history, CustomComponents, CustomModels, ap
245
308
  <Card className="skeleton-card">
246
309
  <div className="skeleton-wrapper">
247
310
  <Skeleton paragraph={{ rows: 4 }} />
311
+ <p className="motivating-text">{loadingMessage}</p>
248
312
  </div>
249
313
  </Card>
250
314
  ) : (
@@ -11,9 +11,31 @@
11
11
  }
12
12
 
13
13
  .skeleton-wrapper {
14
+ .motivating-text {
15
+ margin-top: 14px;
16
+ margin-bottom: 4px;
17
+ font-size: 14px;
18
+ line-height: 20px;
19
+ text-align: center;
20
+ color: #5e6d86;
21
+ font-weight: 500;
22
+ animation: skeletonTextFade 0.4s ease-in-out;
23
+ }
14
24
  }
15
25
 
16
26
  .wrapper-loader {
17
27
  margin: 20px;
18
28
  }
19
29
  }
30
+
31
+ @keyframes skeletonTextFade {
32
+ from {
33
+ opacity: 0;
34
+ transform: translateY(2px);
35
+ }
36
+
37
+ to {
38
+ opacity: 1;
39
+ transform: translateY(0);
40
+ }
41
+ }
@@ -11,7 +11,7 @@
11
11
  position: relative;
12
12
  padding: 8px;
13
13
  border-radius: 4px;
14
- // border: 1px solid #e3e3e3;
14
+ border: 1px solid #e3e3e3;
15
15
  margin-bottom: 3px;
16
16
 
17
17
  .field-customizer {
@@ -9,151 +9,150 @@ import React from 'react';
9
9
 
10
10
  import Base from '../base/base';
11
11
 
12
- import { ApiUtils } from './../../lib/'
13
-
12
+ import { ApiUtils } from './../../lib/';
14
13
 
15
14
  class CoreScript extends Base {
15
+ constructor() {
16
+ super();
16
17
 
17
- constructor() {
18
- super();
19
-
20
- this.fields = [
21
- {
22
- field: 'name',
23
- caption: 'Name'
24
- },
25
- {
26
- field: 'amount',
27
- caption: 'Amount'
28
- }
29
- ];
30
-
31
- // this.columns = ;
32
- }
33
-
34
- get id() {
35
- return 'id';
36
- }
37
-
38
- get getEndpoint() {
39
- return 'core-scripts';
40
- }
41
-
42
-
43
- get modelName() {
44
- return `core-scripts`;
45
- }
46
-
47
- get columns() {
48
- return [
49
- {
50
- caption: 'Staff',
51
- field: 'staff.name',
52
- key: 'staff'
53
- },
54
- {
55
- caption: 'Weight',
56
- field: 'weight',
57
- key: 'weight'
58
- },
59
- {
60
- caption: 'Date',
61
- field: 'created_at',
62
- key: 'created_at'
63
- }
64
- ];
65
- }
66
-
67
-
68
- /**
69
- *Getting core_script data
70
- * @returns
71
- */
72
- getReportingLisitng = (id, formBody, dbPtr = null) => {
73
-
74
- // Settings db pointer
75
- if (!dbPtr) dbPtr = localStorage.db_ptr;
76
- return ApiUtils.post({
77
- url: `core-scripts/dashboardquery/${id}`,
78
- formBody,
79
- headers: {
80
- 'Content-Type': 'application/json',
81
- Authorization: 'Bearer ' + localStorage.access_token,
82
- db_ptr: dbPtr
18
+ this.fields = [
19
+ {
20
+ field: 'name',
21
+ caption: 'Name',
83
22
  },
84
- });
85
- };
86
-
87
-
88
- /**
89
- *Updating user details
90
- * @returns
91
- */
92
- getUserDetailsLisitng = (id, formBody) => {
93
-
94
- return ApiUtils.post({
95
- url: `core-scripts/update-user-deatils/${id}`,
96
- formBody,
97
- });
98
- };
99
-
100
- getQuery = (formBody) => {
101
-
102
- return ApiUtils.post({
103
- url: `core-scripts/execute-script-api`,
104
- formBody,
105
- });
106
- };
107
-
108
-
109
-
110
- /**
111
- *
112
- */
113
- getReportMenu = async ({ id }) => {
114
-
115
- const result = await this.getRecord({ id });
23
+ {
24
+ field: 'amount',
25
+ caption: 'Amount',
26
+ },
27
+ ];
116
28
 
117
- const report = result.result
29
+ // this.columns = ;
30
+ }
118
31
 
119
- return {
120
- ...report,
121
- caption: report.caption,
122
- path: '/reports/' + report.id,
123
- is_visible: true
124
- }
125
- }
32
+ get id() {
33
+ return 'id';
34
+ }
126
35
 
127
- /**
128
- * To get extra script data corresponding to mode
129
- *
130
- * @param {*} mode
131
- * @returns
132
- */
133
- getExtraInfo = (mode) => {
134
- return ApiUtils.get({
135
- url: `core-scripts/get-script-data?mode=${mode}`,
136
- });
137
- };
36
+ get getEndpoint() {
37
+ return 'core-scripts';
38
+ }
138
39
 
40
+ get modelName() {
41
+ return `core-scripts`;
42
+ }
139
43
 
140
- /**
141
- * To get executed data
142
- *
143
- * @param {*} mode
144
- * @returns
145
- */
146
-
147
- getSelectedExtraInfo = (formBody) => {
148
- return ApiUtils.post({
149
- url: `core-scripts/get-selected-script-data`,
150
- formBody,
151
- headers: {
152
- 'Content-Type': 'application/json',
153
- Authorization: 'Bearer ' + localStorage.access_token,
154
- },
155
- });
44
+ get columns() {
45
+ return [
46
+ {
47
+ caption: 'Staff',
48
+ field: 'staff.name',
49
+ key: 'staff',
50
+ },
51
+ {
52
+ caption: 'Weight',
53
+ field: 'weight',
54
+ key: 'weight',
55
+ },
56
+ {
57
+ caption: 'Date',
58
+ field: 'created_at',
59
+ key: 'created_at',
60
+ },
61
+ ];
62
+ }
63
+
64
+ /**
65
+ *Getting core_script data
66
+ * @returns
67
+ */
68
+ getReportingLisitng = (id, formBody, dbPtr = null) => {
69
+ // Settings db pointer
70
+ if (!dbPtr) dbPtr = localStorage.db_ptr;
71
+ return ApiUtils.post({
72
+ // baseUrl: 'http://localhost:8002/dev/',
73
+ url: `core-scripts/dashboardquery/${id}`,
74
+ formBody,
75
+ headers: {
76
+ 'Content-Type': 'application/json',
77
+ Authorization: 'Bearer ' + localStorage.access_token,
78
+ db_ptr: dbPtr,
79
+ },
80
+ });
81
+ };
82
+
83
+ /**
84
+ *Updating user details
85
+ * @returns
86
+ */
87
+ getUserDetailsLisitng = (id, formBody) => {
88
+ return ApiUtils.post({
89
+ url: `core-scripts/update-user-deatils/${id}`,
90
+ formBody,
91
+ });
92
+ };
93
+
94
+ getQuery = (formBody) => {
95
+ return ApiUtils.post({
96
+ url: `core-scripts/execute-script-api`,
97
+ formBody,
98
+ });
99
+ };
100
+ /**
101
+ *
102
+ */
103
+ getQuerySeacch = (formBody) => {
104
+ return ApiUtils.post({
105
+ // baseUrl: 'http://localhost:8002/dev/',
106
+ url: `core-scripts/execute-script-by-search`,
107
+ formBody,
108
+ });
109
+ };
110
+
111
+ /**
112
+ *
113
+ */
114
+ getReportMenu = async ({ id }) => {
115
+ const result = await this.getRecord({ id });
116
+
117
+ const report = result.result;
118
+
119
+ return {
120
+ ...report,
121
+ caption: report.caption,
122
+ path: '/reports/' + report.id,
123
+ is_visible: true,
156
124
  };
125
+ };
126
+
127
+ /**
128
+ * To get extra script data corresponding to mode
129
+ *
130
+ * @param {*} mode
131
+ * @returns
132
+ */
133
+ getExtraInfo = (mode) => {
134
+ return ApiUtils.get({
135
+ url: `core-scripts/get-script-data?mode=${mode}`,
136
+ });
137
+ };
138
+
139
+ /**
140
+ * To get executed data
141
+ *
142
+ * @param {*} mode
143
+ * @returns
144
+ */
145
+
146
+ getSelectedExtraInfo = (formBody) => {
147
+ return ApiUtils.post({
148
+ url: `core-scripts/get-selected-script-data`,
149
+ formBody,
150
+ headers: {
151
+ 'Content-Type': 'application/json',
152
+ Authorization: 'Bearer ' + localStorage.access_token,
153
+ },
154
+ });
155
+ };
157
156
  }
158
157
 
159
158
  export default CoreScript;
@@ -1,5 +1,5 @@
1
1
  import React, { useState, useCallback, useEffect } from 'react';
2
- import { Space, Popconfirm, Input, Drawer, Skeleton, Collapse, message, Tag } from 'antd';
2
+ import { Space, Popconfirm, Input, Drawer, Skeleton, Collapse, message, Tag, Empty } from 'antd';
3
3
  import { ReloadOutlined, DeleteOutlined, EditOutlined, PlusCircleFilled, CopyOutlined } from '@ant-design/icons';
4
4
  import { Button, Card, Switch, DraggableWrapper } from '../../../../lib';
5
5
  // for draggable menu list import { DndProvider } from "react-dnd";
@@ -203,7 +203,7 @@ const MenuLists = ({ model, match, relativeAdd = false, additional_queries = [],
203
203
  model.delete(rec).then(loadMenus);
204
204
  };
205
205
 
206
- const filtered = records.filter((r) => r.name?.toUpperCase().includes(query.toUpperCase()));
206
+ const filtered = records.filter((r) => r.caption?.toUpperCase().includes(query.toUpperCase()));
207
207
 
208
208
  const visibleItems = filtered;
209
209
 
@@ -362,50 +362,53 @@ const MenuLists = ({ model, match, relativeAdd = false, additional_queries = [],
362
362
  <Card>
363
363
  <DndProvider backend={HTML5Backend}>
364
364
  <Collapse accordion>
365
- {visibleItems.map((item, index) => (
366
- <Panel
367
- key={item.id}
368
- header={
369
- <DraggableWrapper
370
- id={item.id}
371
- index={index}
372
- movePanel={movePanel}
373
- item={item}
374
- dragEnabled={dragMode}
375
- level={1}
376
- parentId={null}
377
- onCrossLevelMove={handleCrossLevelMove}
378
- canAcceptChildren={true}
379
- />
380
- }
381
- // only show arrow if sub_menus exist
382
- showArrow={item.sub_menus && item.sub_menus.length > 0}
383
- // disable panel
384
- // collapsible={item.sub_menus && item.sub_menus.length > 0 ? 'header' : 'disabled'}
385
- extra={panelActions(item, model, setSelectedRecord, setDrawerTitle, setDrawerVisible, deleteRecord)}
386
- >
387
- {item.sub_menus && item.sub_menus.length > 0 && (
388
- <NestedMenu
389
- parentId={item.id}
390
- step={item.step + 1}
391
- items={item.sub_menus || []}
392
- model={model}
393
- dragMode={dragMode}
394
- setSelectedRecord={setSelectedRecord}
395
- setDrawerTitle={setDrawerTitle}
396
- setDrawerVisible={setDrawerVisible}
397
- deleteRecord={deleteRecord}
398
- level={2}
399
- onCrossLevelMove={handleCrossLevelMove}
400
- onChange={(subMenus) => {
401
- const updated = records.map((r) => (r.id === item.id ? { ...r, sub_menus: subMenus } : r));
402
- setRecords(updated);
403
- setOrderChanged(true);
404
- }}
405
- />
406
- )}
407
- </Panel>
408
- ))}
365
+ {visibleItems && visibleItems.length > 0 ? (
366
+ visibleItems.map((item, index) => (
367
+ <Panel
368
+ key={item.id}
369
+ header={
370
+ <DraggableWrapper
371
+ id={item.id}
372
+ index={index}
373
+ movePanel={movePanel}
374
+ item={item}
375
+ dragEnabled={dragMode}
376
+ level={1}
377
+ parentId={null}
378
+ onCrossLevelMove={handleCrossLevelMove}
379
+ canAcceptChildren={true}
380
+ />
381
+ }
382
+ showArrow={item.sub_menus && item.sub_menus.length > 0}
383
+ extra={panelActions(item, model, setSelectedRecord, setDrawerTitle, setDrawerVisible, deleteRecord)}
384
+ >
385
+ {item.sub_menus && item.sub_menus.length > 0 && (
386
+ <NestedMenu
387
+ parentId={item.id}
388
+ step={item.step + 1}
389
+ items={item.sub_menus || []}
390
+ model={model}
391
+ dragMode={dragMode}
392
+ setSelectedRecord={setSelectedRecord}
393
+ setDrawerTitle={setDrawerTitle}
394
+ setDrawerVisible={setDrawerVisible}
395
+ deleteRecord={deleteRecord}
396
+ level={2}
397
+ onCrossLevelMove={handleCrossLevelMove}
398
+ onChange={(subMenus) => {
399
+ const updated = records.map((r) => (r.id === item.id ? { ...r, sub_menus: subMenus } : r));
400
+ setRecords(updated);
401
+ setOrderChanged(true);
402
+ }}
403
+ />
404
+ )}
405
+ </Panel>
406
+ ))
407
+ ) : (
408
+ <div style={{ textAlign: 'center', padding: '40px 0' }}>
409
+ <Empty description="No Menu Items" />
410
+ </div>
411
+ )}
409
412
  </Collapse>
410
413
  </DndProvider>
411
414
  </Card>