@agilemotion/oui-react-js 1.8.24 → 1.8.27
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.
|
@@ -24,6 +24,7 @@ class ApplicationManager {
|
|
|
24
24
|
constructor() {
|
|
25
25
|
if (!ApplicationManager.instance) {
|
|
26
26
|
this.views = [];
|
|
27
|
+
this.dashboardViews = [];
|
|
27
28
|
this.props = {};
|
|
28
29
|
this.listeners = [];
|
|
29
30
|
this.libs = {};
|
|
@@ -355,6 +356,26 @@ class ApplicationManager {
|
|
|
355
356
|
applicationContext[key] = values[key];
|
|
356
357
|
});
|
|
357
358
|
};
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* add view configuration
|
|
362
|
+
*
|
|
363
|
+
* @param view the listener to be added
|
|
364
|
+
* @param path
|
|
365
|
+
* @param forward
|
|
366
|
+
*/
|
|
367
|
+
addDashboardView = (view, path) => {
|
|
368
|
+
this.dashboardViews.push(view);
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* clear dashboard view configuration
|
|
373
|
+
*
|
|
374
|
+
*/
|
|
375
|
+
clearDashboardViews = () => {
|
|
376
|
+
this.dashboardViews.splice(0, this.dashboardViews.length);
|
|
377
|
+
};
|
|
378
|
+
|
|
358
379
|
/**
|
|
359
380
|
* add view configuration
|
|
360
381
|
*
|
|
@@ -493,7 +514,7 @@ class ApplicationManager {
|
|
|
493
514
|
return view;
|
|
494
515
|
}
|
|
495
516
|
}
|
|
496
|
-
return
|
|
517
|
+
return this.dashboardViews.find(v => v.config.id === id);
|
|
497
518
|
};
|
|
498
519
|
getViewComponent = (view, id) => {
|
|
499
520
|
if (!_Utils.default.isNull(view) && !_Utils.default.isNull(view.handle) && !_Utils.default.isNull(view.handle.api)) {
|
|
@@ -523,6 +544,12 @@ class ApplicationManager {
|
|
|
523
544
|
return graph;
|
|
524
545
|
}
|
|
525
546
|
}
|
|
547
|
+
for (const view of this.dashboardViews) {
|
|
548
|
+
let component = this.getViewComponent(view, id);
|
|
549
|
+
if (component) {
|
|
550
|
+
return component;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
526
553
|
if (this.views.length === 0) {
|
|
527
554
|
return this.getViewComponent(this.props.dashboardView, id);
|
|
528
555
|
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _Utils = _interopRequireDefault(require("../Utils"));
|
|
9
|
+
var _reactHtmlRenderer = _interopRequireDefault(require("react-html-renderer"));
|
|
10
|
+
var _Observable = _interopRequireDefault(require("../event/Observable"));
|
|
11
|
+
var _ApplicationManager = _interopRequireDefault(require("../ApplicationManager"));
|
|
12
|
+
var _reactPromiseTracker = require("react-promise-tracker");
|
|
13
|
+
var _Event = _interopRequireDefault(require("../event/Event"));
|
|
14
|
+
var _EventType = _interopRequireDefault(require("../event/EventType"));
|
|
15
|
+
var _RestUtils = require("../RestUtils");
|
|
16
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
|
+
const location = window.location.protocol + '//' + window.location.hostname;
|
|
18
|
+
const Chart = /*#__PURE__*/_react.default.memo(/*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
19
|
+
const [path, setPath] = _react.default.useState(null);
|
|
20
|
+
const [displayType, setDisplayType] = _react.default.useState(props.config.defaultDisplayType);
|
|
21
|
+
const [visible, setVisible] = _react.default.useState(false);
|
|
22
|
+
_react.default.useEffect(() => {
|
|
23
|
+
props.handle.api = api();
|
|
24
|
+
});
|
|
25
|
+
_react.default.useEffect(() => {
|
|
26
|
+
let parsedConfig = _Utils.default.parseConfig(props.config, props.viewId);
|
|
27
|
+
_Observable.default.addSubscriptions(parsedConfig.eventHandlingConfig, props.handle, props.viewId);
|
|
28
|
+
_Observable.default.addSystemSubscriptions(props.viewId, parsedConfig);
|
|
29
|
+
let event = new _Event.default(props.handle, props.viewId, null);
|
|
30
|
+
_Observable.default.fireEvent(_EventType.default.COMPONENT_LOAD, event);
|
|
31
|
+
return () => {
|
|
32
|
+
_Observable.default.clearComponentEventListeners(props.handle);
|
|
33
|
+
};
|
|
34
|
+
}, []);
|
|
35
|
+
function load(parameters) {
|
|
36
|
+
const accessToken = sessionStorage.getItem('accessToken');
|
|
37
|
+
const idToken = sessionStorage.getItem('idToken');
|
|
38
|
+
let path = location + _ApplicationManager.default.getContextRoot() + _ApplicationManager.default.getUIConfigPath() + '/html/get?version=1.0&id=' + props.config.contentPath + `-${displayType.toLowerCase()}.html&access_token=${accessToken}&idToken=${idToken}`;
|
|
39
|
+
for (const parameter of parameters) {
|
|
40
|
+
path += '&' + parameter.name + '=' + parameter.value;
|
|
41
|
+
}
|
|
42
|
+
setPath(path);
|
|
43
|
+
}
|
|
44
|
+
const api = () => {
|
|
45
|
+
return {
|
|
46
|
+
get id() {
|
|
47
|
+
return props.config.id;
|
|
48
|
+
},
|
|
49
|
+
loadData: actionConfig => {
|
|
50
|
+
let parameters = [];
|
|
51
|
+
if (props.config.chartDataServiceParameters) {
|
|
52
|
+
for (const chartDataServiceParameter of props.config.chartDataServiceParameters) {
|
|
53
|
+
let value = _ApplicationManager.default.resolveParameterValue(chartDataServiceParameter, null);
|
|
54
|
+
if (value) {
|
|
55
|
+
let parameter = {};
|
|
56
|
+
parameter.name = chartDataServiceParameter.name;
|
|
57
|
+
parameter.value = typeof value === 'object' ? value.value : value;
|
|
58
|
+
parameters.push(parameter);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
load(parameters);
|
|
63
|
+
},
|
|
64
|
+
refresh() {
|
|
65
|
+
let parsedConfig = _Utils.default.parseConfig(props.config, props.viewId);
|
|
66
|
+
if (!_Utils.default.isNull(props.config) && !_Utils.default.isNull(parsedConfig.visible)) {
|
|
67
|
+
setVisible(_Utils.default.evaluateBooleanExpression(parsedConfig.visible, parsedConfig.id));
|
|
68
|
+
} else {
|
|
69
|
+
setVisible(true);
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
getChildren: () => {
|
|
73
|
+
return [];
|
|
74
|
+
},
|
|
75
|
+
set visible(visible) {
|
|
76
|
+
setVisible(visible);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
return visible && path && /*#__PURE__*/_react.default.createElement("div", {
|
|
81
|
+
style: _Utils.default.mergeStyles({
|
|
82
|
+
height: '100%'
|
|
83
|
+
}, props.config)
|
|
84
|
+
}, !_Utils.default.isNull(path) && !_Utils.default.isNull(displayType) && displayType !== 'VIEW' && /*#__PURE__*/_react.default.createElement("object", {
|
|
85
|
+
data: path,
|
|
86
|
+
type: "text/html",
|
|
87
|
+
style: {
|
|
88
|
+
width: '100%',
|
|
89
|
+
height: '100%'
|
|
90
|
+
}
|
|
91
|
+
}));
|
|
92
|
+
}));
|
|
93
|
+
var _default = exports.default = Chart;
|
|
@@ -29,6 +29,7 @@ var _TabPanel = _interopRequireDefault(require("../TabPanel"));
|
|
|
29
29
|
var _DocumentTemplateDesigner = _interopRequireDefault(require("../DocumentTemplateDesigner"));
|
|
30
30
|
var _ChatRoomWrapper = _interopRequireDefault(require("../media/chat/ChatRoomWrapper"));
|
|
31
31
|
var _ProgressTracker = _interopRequireDefault(require("../ProgressTracker"));
|
|
32
|
+
var _Chart = _interopRequireDefault(require("../Chart"));
|
|
32
33
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
33
34
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
34
35
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -250,6 +251,13 @@ const Layout = props => {
|
|
|
250
251
|
key: index,
|
|
251
252
|
viewId: props.viewId
|
|
252
253
|
});
|
|
254
|
+
case 'chart':
|
|
255
|
+
return /*#__PURE__*/_react.default.createElement(_Chart.default, {
|
|
256
|
+
config: component,
|
|
257
|
+
handle: createComponentHandle(component),
|
|
258
|
+
key: index,
|
|
259
|
+
viewId: props.viewId
|
|
260
|
+
});
|
|
253
261
|
default:
|
|
254
262
|
return /*#__PURE__*/_react.default.createElement("div", null, 'Unsupported component type ' + component.type);
|
|
255
263
|
}
|
package/dist/view/Dashboard.js
CHANGED
|
@@ -27,6 +27,7 @@ const location = window.location.protocol + '//' + window.location.hostname;
|
|
|
27
27
|
const text = response => {
|
|
28
28
|
return response.text();
|
|
29
29
|
};
|
|
30
|
+
let keyCounter = 0;
|
|
30
31
|
const alertBarHandle = {};
|
|
31
32
|
const DashboardCard = props => {
|
|
32
33
|
const [path, setPath] = _react.default.useState(null);
|
|
@@ -39,7 +40,6 @@ const DashboardCard = props => {
|
|
|
39
40
|
const [id, setId] = _react.default.useState(props.settings.id);
|
|
40
41
|
const [content, setContent] = _react.default.useState(null);
|
|
41
42
|
const [ref] = _react.default.useState(/*#__PURE__*/_react.default.createRef());
|
|
42
|
-
const keyCounter = (0, _react.useRef)(0);
|
|
43
43
|
_react.default.useEffect(() => {
|
|
44
44
|
const accessToken = sessionStorage.getItem('accessToken');
|
|
45
45
|
const idToken = sessionStorage.getItem('idToken');
|
|
@@ -56,6 +56,7 @@ const DashboardCard = props => {
|
|
|
56
56
|
if (path && displayType) {
|
|
57
57
|
if (displayType === 'VIEW') {
|
|
58
58
|
(0, _RestUtils.sendRequest)(path, data => {
|
|
59
|
+
data.id = data.id + "-" + keyCounter++;
|
|
59
60
|
let dashboardView = {};
|
|
60
61
|
let defaultModel = {};
|
|
61
62
|
dashboardView.config = data;
|
|
@@ -73,9 +74,9 @@ const DashboardCard = props => {
|
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
76
|
};
|
|
76
|
-
_ApplicationManager.default.
|
|
77
|
+
_ApplicationManager.default.addDashboardView(dashboardView, path);
|
|
77
78
|
let element = /*#__PURE__*/_react.default.createElement(_View.View, {
|
|
78
|
-
key: data.id
|
|
79
|
+
key: data.id,
|
|
79
80
|
config: data,
|
|
80
81
|
parameters: [],
|
|
81
82
|
handle: dashboardView.handle
|
|
@@ -93,14 +94,16 @@ const DashboardCard = props => {
|
|
|
93
94
|
}
|
|
94
95
|
};
|
|
95
96
|
(0, _reactPromiseTracker.trackPromise)(fetch(encodeURI(path), fetchConfig).then(text).then(data => {
|
|
97
|
+
console.log("CONTENT : ", data);
|
|
96
98
|
setContent(data);
|
|
97
99
|
}).catch(e => {
|
|
100
|
+
alert(e.message);
|
|
98
101
|
console.error(e);
|
|
99
102
|
}));
|
|
100
103
|
}
|
|
101
104
|
}
|
|
102
105
|
}, [path, displayType]);
|
|
103
|
-
|
|
106
|
+
function load() {
|
|
104
107
|
if (!path) {
|
|
105
108
|
// TODO: Make the base URL dynamic
|
|
106
109
|
let url = location + _ApplicationManager.default.getContextRoot() + _ApplicationManager.default.getUIConfigPath() + '/dashboard/get?version=1.0&id=' + settings.path;
|
|
@@ -130,6 +133,9 @@ const DashboardCard = props => {
|
|
|
130
133
|
console.error(e);
|
|
131
134
|
});
|
|
132
135
|
}
|
|
136
|
+
}
|
|
137
|
+
_react.default.useEffect(() => {
|
|
138
|
+
load();
|
|
133
139
|
}, []);
|
|
134
140
|
const saveDashboard = () => {
|
|
135
141
|
settings.parameters.displayType = displayType;
|
|
@@ -459,6 +465,9 @@ const Dashboard = /*#__PURE__*/_react.default.memo(/*#__PURE__*/_react.default.f
|
|
|
459
465
|
_ApplicationManager.default.setDashboardView({
|
|
460
466
|
handle: handle
|
|
461
467
|
});
|
|
468
|
+
return () => {
|
|
469
|
+
_ApplicationManager.default.clearDashboardViews();
|
|
470
|
+
};
|
|
462
471
|
}, []);
|
|
463
472
|
const addDashboardCard = item => {
|
|
464
473
|
let path = item.eventHandlingConfig.subscriptions[0].actions[0].path;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agilemotion/oui-react-js",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.27",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist"
|
|
6
6
|
],
|
|
@@ -135,7 +135,7 @@
|
|
|
135
135
|
"eslint-plugin-flowtype": "3.13.0",
|
|
136
136
|
"typescript": "3.8.3"
|
|
137
137
|
},
|
|
138
|
-
"description": "
|
|
138
|
+
"description": "AgileMotion React UI Component Library - A comprehensive collection of dashboard components, forms, media controls, and more",
|
|
139
139
|
"main": "gulpfile.js",
|
|
140
140
|
"author": "",
|
|
141
141
|
"license": "ISC",
|