versacall-core-library-react 2.0.70 → 2.0.71
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/components/CoreAlert/CoreAlert.js +85 -0
- package/dist/components/CoreAlert/index.js +13 -0
- package/dist/components/CoreAlert/readme.md +21 -0
- package/dist/components/CoreAppBar/CoreAppBar.js +364 -0
- package/dist/components/CoreAppBar/CoreAppBarDrawer.js +134 -0
- package/dist/components/CoreAppBar/README.md +27 -0
- package/dist/components/CoreAppBar/index.js +13 -0
- package/dist/components/CoreAppBar/screenshot.png +0 -0
- package/dist/components/CoreAppSelector/AppLink.js +101 -0
- package/dist/components/CoreAppSelector/CoreAppSelector.js +155 -0
- package/dist/components/CoreAppSelector/index.js +13 -0
- package/dist/components/CoreDialogueToolBar/CoreDialogueToolBar.js +123 -0
- package/dist/components/CoreDialogueToolBar/index.js +13 -0
- package/dist/components/CoreDrawer/CoreDrawer.js +236 -0
- package/dist/components/CoreDrawer/README.md +36 -0
- package/dist/components/CoreDrawer/index.js +13 -0
- package/dist/components/CoreDrawer/screenshot_collapsed.png +0 -0
- package/dist/components/CoreDrawer/screenshot_expanded.png +0 -0
- package/dist/components/CoreDropDownTextfield/CoreDropDownTextfield.js +85 -0
- package/dist/components/CoreDropDownTextfield/index.js +13 -0
- package/dist/components/CoreElapsedTime/CoreElapsedTime.js +57 -0
- package/dist/components/CoreElapsedTime/index.js +13 -0
- package/dist/components/CoreFrame/CoreFrame.js +64 -0
- package/dist/components/CoreFrame/index.js +13 -0
- package/dist/components/CoreImportDialog/CoreImportDialog.js +350 -0
- package/dist/components/CoreImportDialog/index.js +13 -0
- package/dist/components/CoreImportResultsDialog/CoreImportResultsDialog.js +103 -0
- package/dist/components/CoreImportResultsDialog/index.js +13 -0
- package/dist/components/CoreImporting/CoreImporting.js +60 -0
- package/dist/components/CoreImporting/index.js +13 -0
- package/dist/components/CorePlugin/CorePlugin.js +134 -0
- package/dist/components/CorePlugin/OldCorePlugin.js +124 -0
- package/dist/components/CorePlugin/index.js +13 -0
- package/dist/components/CoreSaveChangesDialog/CoreSaveChangesDialog.js +62 -0
- package/dist/components/CoreSaveChangesDialog/index.js +13 -0
- package/dist/components/CoreShiftTagFilter/CoreShiftTagFilter.js +350 -0
- package/dist/components/CoreShiftTagFilter/OldCoreShiftTagFilter.js +208 -0
- package/dist/components/CoreShiftTagFilter/index.js +13 -0
- package/dist/components/CoreSideBar/CoreSideBar.js +737 -0
- package/dist/components/CoreSideBar/CoreSideBarDrawer.js +172 -0
- package/dist/components/CoreSideBar/index.js +13 -0
- package/dist/components/CoreSnackBar/CoreSnackBar.js +116 -0
- package/dist/components/CoreSnackBar/index.js +13 -0
- package/dist/components/CoreSnackBar/readme.md +23 -0
- package/dist/components/CoreTable/CoreTable.js +315 -0
- package/dist/components/CoreTable/CoreTableChips.js +50 -0
- package/dist/components/CoreTable/CoreTableHead.js +175 -0
- package/dist/components/CoreTable/CoreTableToolbar.js +108 -0
- package/dist/components/CoreTable/index.js +13 -0
- package/dist/components/CoreTable/readMe.md +79 -0
- package/dist/components/CoreTagFilter/CoreTagFilter.js +275 -0
- package/dist/components/CoreTagFilter/OldCoreTagFilter.js +341 -0
- package/dist/components/CoreTagFilter/OldTagChip.js +44 -0
- package/dist/components/CoreTagFilter/OldTagFilterSelector.js +105 -0
- package/dist/components/CoreTagFilter/OldTagOption.js +53 -0
- package/dist/components/CoreTagFilter/TagFilterBuilder.js +487 -0
- package/dist/components/CoreTagFilter/index.js +13 -0
- package/dist/components/CoreTextField/CoreTextField.js +109 -0
- package/dist/components/CoreTextField/index.js +13 -0
- package/dist/components/CoreTheme/CoreTheme.css +9 -0
- package/dist/components/CoreTheme/CoreTheme.js +51 -0
- package/dist/components/CoreTheme/README.md +3 -0
- package/dist/components/CoreTheme/index.js +13 -0
- package/dist/components/CoreTile/CoreTile.js +62 -0
- package/dist/components/CoreTile/CoreTileToolbar.js +62 -0
- package/dist/components/CoreTile/index.js +13 -0
- package/dist/components/CoreTimerInput/CoreTimerInput.js +203 -0
- package/dist/components/CoreTimerInput/CoreTimerInputOld.js +146 -0
- package/dist/components/CoreTimerInput/index.js +13 -0
- package/dist/components/CoreToolbar/CoreToolbar.js +205 -0
- package/dist/components/CoreToolbar/index.js +13 -0
- package/dist/components/CoreTracker/CoreTracker.js +52 -0
- package/dist/components/CoreTracker/index.js +13 -0
- package/dist/components/CoreTranslate/CoreTranslate.js +62 -0
- package/dist/components/CoreTranslate/README.md +5 -0
- package/dist/components/CoreTranslate/index.js +13 -0
- package/dist/components/CoreTranslate/translations/en.json +451 -0
- package/dist/components/CoreTranslate/translations/es.json +433 -0
- package/dist/components/CoreTranslateWrapper/CoreTranslateWrapper.js +36 -0
- package/dist/components/CoreTranslateWrapper/index.js +13 -0
- package/dist/components/CoreWidget/CoreWidget.js +120 -0
- package/dist/components/CoreWidget/index.js +13 -0
- package/dist/components/CoreWrapper/CoreWrapper.js +51 -0
- package/dist/components/CoreWrapper/README.md +41 -0
- package/dist/components/CoreWrapper/index.js +13 -0
- package/dist/components/index.js +202 -0
- package/dist/constants/index.js +20 -0
- package/dist/constants/testOrganization.js +31 -0
- package/dist/constants/testToken.js +33 -0
- package/dist/context/Authentication/AuthenticationContext.js +10 -0
- package/dist/context/Authentication/AuthenticationProvider.js +225 -0
- package/dist/context/Authentication/README.md +47 -0
- package/dist/context/Authentication/index.js +27 -0
- package/dist/context/Authentication/withAuthentication.js +15 -0
- package/dist/context/Channels/ChannelsConsumer.js +42 -0
- package/dist/context/Channels/ChannelsContext.js +10 -0
- package/dist/context/Channels/ChannelsProvider.js +258 -0
- package/dist/context/Channels/DataChannel.js +68 -0
- package/dist/context/Channels/EntityChannel.js +69 -0
- package/dist/context/Channels/EveryoneChannel.js +55 -0
- package/dist/context/Channels/OrganizationChannel.js +69 -0
- package/dist/context/Channels/README.md +52 -0
- package/dist/context/Channels/UserChannel.js +60 -0
- package/dist/context/Channels/index.js +69 -0
- package/dist/context/Channels/withChannels.js +15 -0
- package/dist/context/Core/CoreContext.js +10 -0
- package/dist/context/Core/CoreProvider.js +107 -0
- package/dist/context/Core/README.md +43 -0
- package/dist/context/Core/index.js +27 -0
- package/dist/context/Core/withCore.js +15 -0
- package/dist/context/Organization/OrganizationContext.js +10 -0
- package/dist/context/Organization/OrganizationProvider.js +108 -0
- package/dist/context/Organization/README.md +82 -0
- package/dist/context/Organization/index.js +27 -0
- package/dist/context/Organization/withOrganization.js +15 -0
- package/dist/context/Plugin/PluginContext.js +10 -0
- package/dist/context/Plugin/PluginProvider.js +78 -0
- package/dist/context/Plugin/index.js +27 -0
- package/dist/context/Plugin/withPlugin.js +15 -0
- package/dist/context/index.js +60 -0
- package/dist/css/index.js +20 -0
- package/dist/css/junk.module.css +3 -0
- package/dist/css/scrollbar.css +35 -0
- package/dist/css/scrollbar.module.css +37 -0
- package/dist/functions/TagEvaluator.js +165 -0
- package/dist/functions/compareObjects.js +27 -0
- package/dist/functions/formatElapsedTime.js +18 -0
- package/dist/functions/formatNameFileSafe.js +16 -0
- package/dist/functions/getIconUrl.js +15 -0
- package/dist/functions/getParameterByName.js +34 -0
- package/dist/functions/getProperty.js +17 -0
- package/dist/functions/getUrl.js +15 -0
- package/dist/functions/index.js +62 -0
- package/dist/icons/CopyIcon.js +42 -0
- package/dist/icons/DeleteIcon.js +42 -0
- package/dist/icons/DuplicateIcon.js +42 -0
- package/dist/icons/EditIcon.js +42 -0
- package/dist/icons/FabAddIcon.js +78 -0
- package/dist/icons/PasteIcon.js +42 -0
- package/dist/icons/index.js +48 -0
- package/dist/index.js +71 -0
- package/package.json +2 -2
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _OrganizationChannel = _interopRequireDefault(require("./OrganizationChannel"));
|
|
10
|
+
var _EveryoneChannel = _interopRequireDefault(require("./EveryoneChannel"));
|
|
11
|
+
var _EntityChannel = _interopRequireDefault(require("./EntityChannel"));
|
|
12
|
+
var _withChannels = _interopRequireDefault(require("./withChannels"));
|
|
13
|
+
var _UserChannel = _interopRequireDefault(require("./UserChannel"));
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
16
|
+
class ChannelsConsumer extends _react.Component {
|
|
17
|
+
componentDidMount() {
|
|
18
|
+
this.props.channels.registerHandlers(this.props.id, this.props.handler, this.props.connectionChanged, this.props.subscribing);
|
|
19
|
+
}
|
|
20
|
+
componentWillUnmount() {
|
|
21
|
+
this.props.channels.unregisterHandlers(this.props.id);
|
|
22
|
+
}
|
|
23
|
+
render() {
|
|
24
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, this.props.addDefaultChannels && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_EveryoneChannel.default, null), /*#__PURE__*/_react.default.createElement(_UserChannel.default, null), /*#__PURE__*/_react.default.createElement(_OrganizationChannel.default, null), /*#__PURE__*/_react.default.createElement(_EntityChannel.default, null)), this.props.children);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
ChannelsConsumer.propTypes = {
|
|
28
|
+
children: _propTypes.default.node,
|
|
29
|
+
id: _propTypes.default.string.isRequired,
|
|
30
|
+
handler: _propTypes.default.func.isRequired,
|
|
31
|
+
connectionChanged: _propTypes.default.func,
|
|
32
|
+
subscribing: _propTypes.default.func,
|
|
33
|
+
addDefaultChannels: _propTypes.default.bool,
|
|
34
|
+
channels: _propTypes.default.objectOf(_propTypes.default.func).isRequired
|
|
35
|
+
};
|
|
36
|
+
ChannelsConsumer.defaultProps = {
|
|
37
|
+
connectionChanged: null,
|
|
38
|
+
subscribing: null,
|
|
39
|
+
addDefaultChannels: true,
|
|
40
|
+
children: null
|
|
41
|
+
};
|
|
42
|
+
var _default = exports.default = (0, _withChannels.default)(ChannelsConsumer);
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
const ChannelsContext = /*#__PURE__*/_react.default.createContext();
|
|
10
|
+
var _default = exports.default = ChannelsContext;
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _ChannelsContext = _interopRequireDefault(require("./ChannelsContext"));
|
|
10
|
+
var _withCore = _interopRequireDefault(require("../Core/withCore"));
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
13
|
+
const namespace = 'ChannelsProvider';
|
|
14
|
+
const emitter = require('emitter-io');
|
|
15
|
+
const channelTimeoutHandlers = [];
|
|
16
|
+
const channelInformation = [];
|
|
17
|
+
const channelFunctions = [];
|
|
18
|
+
const handlers = [];
|
|
19
|
+
const connectionChangedHandlers = [];
|
|
20
|
+
const subscribingHandlers = [];
|
|
21
|
+
let client;
|
|
22
|
+
function compareChannelInfo(ci1, ci2) {
|
|
23
|
+
if (ci1 !== null) {
|
|
24
|
+
if (ci2 !== null) {
|
|
25
|
+
if (ci1.channelKey === ci2.channelKey) {
|
|
26
|
+
if (ci1.channelName === ci2.channelName) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
if (ci2 !== null) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
const registerHandlers = (id, handler, connectionChanged, subscribing) => {
|
|
41
|
+
const existing = handlers.find(x => x.id === id);
|
|
42
|
+
if (existing !== undefined) {
|
|
43
|
+
existing.handler = handler;
|
|
44
|
+
} else {
|
|
45
|
+
handlers.push({
|
|
46
|
+
id: id,
|
|
47
|
+
handler: handler
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
if (connectionChanged) {
|
|
51
|
+
const existingConnectionChanged = connectionChangedHandlers.find(x => x.id === id);
|
|
52
|
+
if (existingConnectionChanged !== undefined) {
|
|
53
|
+
existingConnectionChanged.handler = connectionChanged;
|
|
54
|
+
} else {
|
|
55
|
+
connectionChangedHandlers.push({
|
|
56
|
+
id: id,
|
|
57
|
+
handler: connectionChanged
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (subscribing) {
|
|
62
|
+
const existingSubscribing = subscribingHandlers.find(x => x.id === id);
|
|
63
|
+
if (existingSubscribing !== undefined) {
|
|
64
|
+
existingSubscribing.handler = subscribing;
|
|
65
|
+
} else {
|
|
66
|
+
subscribingHandlers.push({
|
|
67
|
+
id: id,
|
|
68
|
+
handler: subscribing
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
const unregisterHandlers = id => {
|
|
74
|
+
const existing = handlers.find(x => x.id === id);
|
|
75
|
+
if (existing !== undefined) {
|
|
76
|
+
handlers.splice(handlers.indexOf(existing), 1);
|
|
77
|
+
}
|
|
78
|
+
const existingConnectionChanged = connectionChangedHandlers.find(x => x.id === id);
|
|
79
|
+
if (existingConnectionChanged !== undefined) {
|
|
80
|
+
connectionChangedHandlers.splice(connectionChangedHandlers.indexOf(existingConnectionChanged), 1);
|
|
81
|
+
}
|
|
82
|
+
const existingSubscribing = subscribingHandlers.find(x => x.id === id);
|
|
83
|
+
if (existingSubscribing !== undefined) {
|
|
84
|
+
subscribingHandlers.splice(subscribingHandlers.indexOf(existingSubscribing), 1);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
const registerChannel = (id, channelFunction) => {
|
|
88
|
+
const existing = channelFunctions.find(x => x.id === id);
|
|
89
|
+
if (existing !== undefined) {
|
|
90
|
+
existing.channelFunction = data => channelFunction(data);
|
|
91
|
+
} else {
|
|
92
|
+
channelFunctions.push({
|
|
93
|
+
id: id,
|
|
94
|
+
channelFunction: data => channelFunction(data)
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
const isChannelRegistered = id => {
|
|
99
|
+
const existing = channelFunctions.find(x => x.id === id);
|
|
100
|
+
return existing !== undefined;
|
|
101
|
+
};
|
|
102
|
+
const clearTimeoutHandler = id => {
|
|
103
|
+
const existing = channelTimeoutHandlers.find(x => x.id === id);
|
|
104
|
+
if (existing !== undefined) {
|
|
105
|
+
clearTimeout(existing.handler);
|
|
106
|
+
channelTimeoutHandlers.splice(channelTimeoutHandlers.indexOf(existing), 1);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
const processMessage = (channel, obj) => {
|
|
110
|
+
handlers.forEach(x => {
|
|
111
|
+
x.handler(channel, obj);
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
const notifyConnectionChanged = connected => {
|
|
115
|
+
connectionChangedHandlers.forEach(x => {
|
|
116
|
+
x.handler(connected);
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
const notifySubscribing = channel => {
|
|
120
|
+
subscribingHandlers.forEach(x => {
|
|
121
|
+
x.handler(channel);
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
class ChannelsProvider extends _react.Component {
|
|
125
|
+
constructor(props) {
|
|
126
|
+
const methodName = 'constructor()';
|
|
127
|
+
super(props);
|
|
128
|
+
this.state = {
|
|
129
|
+
connected: true
|
|
130
|
+
};
|
|
131
|
+
const urlArray = props.core.baseUrl.split('://');
|
|
132
|
+
const modifiedUrl = urlArray[urlArray.length - 1];
|
|
133
|
+
client = emitter.connect({
|
|
134
|
+
host: modifiedUrl,
|
|
135
|
+
port: 9090,
|
|
136
|
+
secure: true
|
|
137
|
+
});
|
|
138
|
+
client.on('connect', conack => {
|
|
139
|
+
this.props.core.log('system', namespace, methodName, 'Emitter Connect', conack);
|
|
140
|
+
if (this.state.connected === false) {
|
|
141
|
+
this.resubscribeToChannels();
|
|
142
|
+
this.setState({
|
|
143
|
+
connected: true
|
|
144
|
+
});
|
|
145
|
+
notifyConnectionChanged(true);
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
client.on('disconnect', () => {
|
|
149
|
+
this.props.core.log('system', namespace, methodName, 'Emitter Disconnect');
|
|
150
|
+
if (this.state.connected === true) {
|
|
151
|
+
this.setState({
|
|
152
|
+
connected: false
|
|
153
|
+
});
|
|
154
|
+
notifyConnectionChanged(false);
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
client.on('offline', () => {
|
|
158
|
+
this.props.core.log('system', namespace, methodName, 'Emitter Offline');
|
|
159
|
+
if (this.state.connected === true) {
|
|
160
|
+
this.setState({
|
|
161
|
+
connected: false
|
|
162
|
+
});
|
|
163
|
+
notifyConnectionChanged(false);
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
client.on('message', msg => {
|
|
167
|
+
processMessage(msg.channel, JSON.parse(msg.asString()));
|
|
168
|
+
});
|
|
169
|
+
client.on('error', error => {
|
|
170
|
+
this.props.core.log('error', namespace, methodName, error);
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
updateChannel(id, data) {
|
|
174
|
+
const existing = channelTimeoutHandlers.find(x => x.id === id);
|
|
175
|
+
if (existing !== undefined) {
|
|
176
|
+
clearTimeout(existing.handler);
|
|
177
|
+
existing.handler = setTimeout(() => {
|
|
178
|
+
this.callChannelFunction(id, data);
|
|
179
|
+
}, 500);
|
|
180
|
+
} else {
|
|
181
|
+
channelTimeoutHandlers.push({
|
|
182
|
+
id: id,
|
|
183
|
+
handler: setTimeout(() => {
|
|
184
|
+
this.callChannelFunction(id, data);
|
|
185
|
+
}, 500)
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
callChannelFunction(id, data) {
|
|
190
|
+
const methodName = 'callChannelFunction()';
|
|
191
|
+
clearTimeoutHandler(id);
|
|
192
|
+
const existingFunction = channelFunctions.find(x => x.id === id);
|
|
193
|
+
if (existingFunction !== undefined) {
|
|
194
|
+
existingFunction.channelFunction(data).then(channelInfo => {
|
|
195
|
+
if (channelInfo != null) {
|
|
196
|
+
let channelInfoChanged = true;
|
|
197
|
+
const existingChannelInfo = channelInformation.find(x => x.id === id);
|
|
198
|
+
if (existingChannelInfo !== undefined) {
|
|
199
|
+
if (!compareChannelInfo(channelInfo, existingChannelInfo.channelInfo)) {
|
|
200
|
+
this.unsubscribe(existingChannelInfo.channelInfo);
|
|
201
|
+
existingChannelInfo.channelInfo = channelInfo;
|
|
202
|
+
} else {
|
|
203
|
+
channelInfoChanged = false;
|
|
204
|
+
}
|
|
205
|
+
} else {
|
|
206
|
+
channelInformation.push({
|
|
207
|
+
id: id,
|
|
208
|
+
channelInfo: channelInfo
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
if (channelInfoChanged) {
|
|
212
|
+
this.subscribe(channelInfo);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}).catch(error => {
|
|
216
|
+
this.props.core.log('error', namespace, methodName, error);
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
subscribe(channelInfo) {
|
|
221
|
+
const methodName = 'subscribe()';
|
|
222
|
+
this.props.core.log('system', namespace, methodName, "Subscribing to ".concat(channelInfo.channelName));
|
|
223
|
+
client.subscribe({
|
|
224
|
+
key: channelInfo.channelKey,
|
|
225
|
+
channel: channelInfo.channelName
|
|
226
|
+
});
|
|
227
|
+
notifySubscribing(channelInfo.channelName);
|
|
228
|
+
}
|
|
229
|
+
unsubscribe(channelInfo) {
|
|
230
|
+
const methodName = 'unsubscribe()';
|
|
231
|
+
this.props.core.log('system', namespace, methodName, "Unsubscribing from ".concat(channelInfo.channelName));
|
|
232
|
+
client.unsubscribe({
|
|
233
|
+
key: channelInfo.channelKey,
|
|
234
|
+
channel: channelInfo.channelName
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
resubscribeToChannels() {
|
|
238
|
+
channelInformation.forEach((item, i) => {
|
|
239
|
+
this.subscribe(item.channelInfo);
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
render() {
|
|
243
|
+
return /*#__PURE__*/_react.default.createElement(_ChannelsContext.default.Provider, {
|
|
244
|
+
value: {
|
|
245
|
+
unregisterHandlers: id => unregisterHandlers(id),
|
|
246
|
+
isChannelRegistered: id => isChannelRegistered(id),
|
|
247
|
+
updateChannel: (id, data) => this.updateChannel(id, data),
|
|
248
|
+
registerHandlers: (id, handler, connectionChanged, subscribing) => registerHandlers(id, handler, connectionChanged, subscribing),
|
|
249
|
+
registerChannel: (id, channelFunction) => registerChannel(id, channelFunction)
|
|
250
|
+
}
|
|
251
|
+
}, this.props.children);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
ChannelsProvider.propTypes = {
|
|
255
|
+
children: _propTypes.default.node.isRequired,
|
|
256
|
+
core: _propTypes.default.shape().isRequired
|
|
257
|
+
};
|
|
258
|
+
var _default = exports.default = (0, _withCore.default)(ChannelsProvider);
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _withAuthentication = _interopRequireDefault(require("../Authentication/withAuthentication"));
|
|
10
|
+
var _withOrganization = _interopRequireDefault(require("../Organization/withOrganization"));
|
|
11
|
+
var _withChannels = _interopRequireDefault(require("./withChannels"));
|
|
12
|
+
var _withCore = _interopRequireDefault(require("../Core/withCore"));
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
const namespace = 'DataChannel';
|
|
15
|
+
const channelId = 'data';
|
|
16
|
+
class DataChannel extends _react.Component {
|
|
17
|
+
componentDidMount() {
|
|
18
|
+
if (!this.props.channels.isChannelRegistered(channelId)) {
|
|
19
|
+
this.props.channels.registerChannel(channelId, data => this.channelFunction(data));
|
|
20
|
+
if (this.props.organization.entity !== null) {
|
|
21
|
+
this.props.channels.updateChannel(channelId, {
|
|
22
|
+
entityId: this.props.organization.entity.id
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
componentDidUpdate(prevProps) {
|
|
28
|
+
if (this.props.organization.entity !== prevProps.organization.entity) {
|
|
29
|
+
this.props.channels.updateChannel(channelId, {
|
|
30
|
+
entityId: this.props.organization.entity.id
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
channelFunction(data) {
|
|
35
|
+
const methodName = 'channelFunction()';
|
|
36
|
+
return new Promise((resolve, reject) => {
|
|
37
|
+
if (this.props.authentication.authenticated) {
|
|
38
|
+
this.props.authentication.http({
|
|
39
|
+
method: 'get',
|
|
40
|
+
url: "".concat(this.props.core.baseUrl, "/api/data/subscribe/").concat(data.entityId)
|
|
41
|
+
}).then(results => {
|
|
42
|
+
resolve(results.data);
|
|
43
|
+
}).catch(error => {
|
|
44
|
+
this.props.core.log('error', namespace, methodName, error);
|
|
45
|
+
reject(error);
|
|
46
|
+
});
|
|
47
|
+
} else {
|
|
48
|
+
reject(new Error({
|
|
49
|
+
message: 'Not Authenticated'
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
render() {
|
|
55
|
+
return '';
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
DataChannel.propTypes = {
|
|
59
|
+
core: _propTypes.default.shape().isRequired,
|
|
60
|
+
organization: _propTypes.default.shape().isRequired,
|
|
61
|
+
authentication: _propTypes.default.shape().isRequired,
|
|
62
|
+
channels: _propTypes.default.shape({
|
|
63
|
+
updateChannel: _propTypes.default.func,
|
|
64
|
+
registerChannel: _propTypes.default.func,
|
|
65
|
+
isChannelRegistered: _propTypes.default.func
|
|
66
|
+
}).isRequired
|
|
67
|
+
};
|
|
68
|
+
var _default = exports.default = (0, _withChannels.default)((0, _withCore.default)((0, _withAuthentication.default)((0, _withOrganization.default)(DataChannel))));
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _withAuthentication = _interopRequireDefault(require("../Authentication/withAuthentication"));
|
|
10
|
+
var _withOrganization = _interopRequireDefault(require("../Organization/withOrganization"));
|
|
11
|
+
var _withChannels = _interopRequireDefault(require("./withChannels"));
|
|
12
|
+
var _withCore = _interopRequireDefault(require("../Core/withCore"));
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
const namespace = 'EntityChannel';
|
|
15
|
+
const channelId = 'entity';
|
|
16
|
+
class EntityChannel extends _react.Component {
|
|
17
|
+
componentDidMount() {
|
|
18
|
+
if (!this.props.channels.isChannelRegistered(channelId)) {
|
|
19
|
+
this.props.channels.registerChannel(channelId, data => this.channelFunction(data));
|
|
20
|
+
if (this.props.organization.entity !== null) {
|
|
21
|
+
this.props.channels.updateChannel(channelId, {
|
|
22
|
+
entityId: this.props.organization.entity.id
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
componentDidUpdate(prevProps) {
|
|
28
|
+
if (this.props.organization.entity !== prevProps.organization.entity) {
|
|
29
|
+
this.props.channels.updateChannel(channelId, {
|
|
30
|
+
entityId: this.props.organization.entity.id
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
channelFunction(data) {
|
|
35
|
+
const methodName = 'channelFunction()';
|
|
36
|
+
return new Promise((resolve, reject) => {
|
|
37
|
+
if (this.props.authentication.authenticated) {
|
|
38
|
+
this.props.authentication.http({
|
|
39
|
+
method: 'get',
|
|
40
|
+
url: "".concat(this.props.core.baseUrl, "/api/administration/entities/subscribe"),
|
|
41
|
+
params: data
|
|
42
|
+
}).then(results => {
|
|
43
|
+
resolve(results.data);
|
|
44
|
+
}).catch(error => {
|
|
45
|
+
this.props.core.log('error', namespace, methodName, error);
|
|
46
|
+
reject(error);
|
|
47
|
+
});
|
|
48
|
+
} else {
|
|
49
|
+
reject(new Error({
|
|
50
|
+
message: 'Not Authenticated'
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
render() {
|
|
56
|
+
return '';
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
EntityChannel.propTypes = {
|
|
60
|
+
core: _propTypes.default.shape().isRequired,
|
|
61
|
+
organization: _propTypes.default.shape().isRequired,
|
|
62
|
+
authentication: _propTypes.default.shape().isRequired,
|
|
63
|
+
channels: _propTypes.default.shape({
|
|
64
|
+
updateChannel: _propTypes.default.func,
|
|
65
|
+
registerChannel: _propTypes.default.func,
|
|
66
|
+
isChannelRegistered: _propTypes.default.func
|
|
67
|
+
}).isRequired
|
|
68
|
+
};
|
|
69
|
+
var _default = exports.default = (0, _withChannels.default)((0, _withCore.default)((0, _withAuthentication.default)((0, _withOrganization.default)(EntityChannel))));
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _withAuthentication = _interopRequireDefault(require("../Authentication/withAuthentication"));
|
|
10
|
+
var _withChannels = _interopRequireDefault(require("./withChannels"));
|
|
11
|
+
var _withCore = _interopRequireDefault(require("../Core/withCore"));
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
const namespace = 'EveryoneChannel';
|
|
14
|
+
const channelId = 'everyone';
|
|
15
|
+
class EveryoneChannel extends _react.Component {
|
|
16
|
+
componentDidMount() {
|
|
17
|
+
if (!this.props.channels.isChannelRegistered(channelId)) {
|
|
18
|
+
this.props.channels.registerChannel(channelId, data => this.channelFunction(data));
|
|
19
|
+
this.props.channels.updateChannel(channelId, null);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
channelFunction() {
|
|
23
|
+
const methodName = 'channelFunction()';
|
|
24
|
+
return new Promise((resolve, reject) => {
|
|
25
|
+
if (this.props.authentication.authenticated) {
|
|
26
|
+
this.props.authentication.http({
|
|
27
|
+
method: 'get',
|
|
28
|
+
url: "".concat(this.props.core.baseUrl, "/api/administration/everyone/subscribe")
|
|
29
|
+
}).then(results => {
|
|
30
|
+
resolve(results.data);
|
|
31
|
+
}).catch(error => {
|
|
32
|
+
this.props.core.log('error', namespace, methodName, error);
|
|
33
|
+
reject(error);
|
|
34
|
+
});
|
|
35
|
+
} else {
|
|
36
|
+
reject(new Error({
|
|
37
|
+
message: 'Not Authenticated'
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
render() {
|
|
43
|
+
return '';
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
EveryoneChannel.propTypes = {
|
|
47
|
+
core: _propTypes.default.shape().isRequired,
|
|
48
|
+
authentication: _propTypes.default.shape().isRequired,
|
|
49
|
+
channels: _propTypes.default.shape({
|
|
50
|
+
updateChannel: _propTypes.default.func,
|
|
51
|
+
registerChannel: _propTypes.default.func,
|
|
52
|
+
isChannelRegistered: _propTypes.default.func
|
|
53
|
+
}).isRequired
|
|
54
|
+
};
|
|
55
|
+
var _default = exports.default = (0, _withChannels.default)((0, _withAuthentication.default)((0, _withCore.default)(EveryoneChannel)));
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _withAuthentication = _interopRequireDefault(require("../Authentication/withAuthentication"));
|
|
10
|
+
var _withOrganization = _interopRequireDefault(require("../Organization/withOrganization"));
|
|
11
|
+
var _withChannels = _interopRequireDefault(require("./withChannels"));
|
|
12
|
+
var _withCore = _interopRequireDefault(require("../Core/withCore"));
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
const namespace = 'OrganizationChannel';
|
|
15
|
+
const channelId = 'organization';
|
|
16
|
+
class OrganizationChannel extends _react.Component {
|
|
17
|
+
componentDidMount() {
|
|
18
|
+
if (!this.props.channels.isChannelRegistered(channelId)) {
|
|
19
|
+
this.props.channels.registerChannel(channelId, data => this.channelFunction(data));
|
|
20
|
+
if (this.props.organization.organization !== null) {
|
|
21
|
+
this.props.channels.updateChannel(channelId, {
|
|
22
|
+
organizationId: this.props.organization.organization.id
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
componentDidUpdate(prevProps) {
|
|
28
|
+
if (this.props.organization.organization !== prevProps.organization.organization) {
|
|
29
|
+
this.props.channels.updateChannel(channelId, {
|
|
30
|
+
organizationId: this.props.organization.organization.id
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
channelFunction(data) {
|
|
35
|
+
const methodName = 'channelFunction()';
|
|
36
|
+
return new Promise((resolve, reject) => {
|
|
37
|
+
if (this.props.authentication.authenticated) {
|
|
38
|
+
this.props.authentication.http({
|
|
39
|
+
method: 'get',
|
|
40
|
+
url: "".concat(this.props.core.baseUrl, "/api/administration/organizations/subscribe"),
|
|
41
|
+
params: data
|
|
42
|
+
}).then(results => {
|
|
43
|
+
resolve(results.data);
|
|
44
|
+
}).catch(error => {
|
|
45
|
+
this.props.core.log('error', namespace, methodName, error);
|
|
46
|
+
reject(error);
|
|
47
|
+
});
|
|
48
|
+
} else {
|
|
49
|
+
reject(new Error({
|
|
50
|
+
message: 'Not Authenticated'
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
render() {
|
|
56
|
+
return '';
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
OrganizationChannel.propTypes = {
|
|
60
|
+
core: _propTypes.default.shape().isRequired,
|
|
61
|
+
organization: _propTypes.default.shape().isRequired,
|
|
62
|
+
authentication: _propTypes.default.shape().isRequired,
|
|
63
|
+
channels: _propTypes.default.shape({
|
|
64
|
+
updateChannel: _propTypes.default.func,
|
|
65
|
+
registerChannel: _propTypes.default.func,
|
|
66
|
+
isChannelRegistered: _propTypes.default.func
|
|
67
|
+
}).isRequired
|
|
68
|
+
};
|
|
69
|
+
var _default = exports.default = (0, _withChannels.default)((0, _withCore.default)((0, _withAuthentication.default)((0, _withOrganization.default)(OrganizationChannel))));
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Channels Context
|
|
2
|
+
|
|
3
|
+
This adds the capability to communicate with emitter channels. Typically implemented by adding [CoreWrapper](../../components/CoreWrapper) though it can be added by adding ChannelsProvider directly.
|
|
4
|
+
|
|
5
|
+
To utilize this you need to add ChannelsConsumer to your component:
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
processMessage(channel, obj) {
|
|
9
|
+
if (obj.what !== undefined) {
|
|
10
|
+
if (obj.what === 'package_enabled') {
|
|
11
|
+
this.refreshPackages();
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
connectionChanged(connected) {
|
|
17
|
+
if (connected) {
|
|
18
|
+
console.log('We are connected');
|
|
19
|
+
} else {
|
|
20
|
+
console.log('We are disconnected');
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
render() {
|
|
25
|
+
return (
|
|
26
|
+
<div>
|
|
27
|
+
<ChannelsConsumer
|
|
28
|
+
id="mycomponent"
|
|
29
|
+
handler={(channel, obj) => this.processMessage(channel, obj)}
|
|
30
|
+
connectionChanged={connected => this.connectionChanged(connected)}
|
|
31
|
+
addDefaultChannels
|
|
32
|
+
/>
|
|
33
|
+
</div>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## ChannelConsumer Props
|
|
39
|
+
- id : This is a unique id inside your application to represent your component. It is used to map handlers.
|
|
40
|
+
- handler : This is function that is called when something is received on a channel.
|
|
41
|
+
- connectionChanged : This is a function that is called when the connection changed. NOTE: It is not called initially. Assume that we started connected. It will notify when the connection is dropped and re-connected.
|
|
42
|
+
- addDefaultChannels : If true (default), adds the default channels: EveryoneChannel, UserChannel, OrganizationChannel, EntityChannel
|
|
43
|
+
|
|
44
|
+
## Available functions
|
|
45
|
+
These are functions available once adding HOC withChannels to your application. These are typically only used inside a Channel component. Most application components should be using a Channel component to speak to a channel.
|
|
46
|
+
|
|
47
|
+
### registerHandlers(id, handler, connectionChanged)
|
|
48
|
+
### unregisterHandlers(id)
|
|
49
|
+
### registerChannel(id, channelFunction)
|
|
50
|
+
### updateChannel(id, data)
|
|
51
|
+
### isChannelRegistered(id)
|
|
52
|
+
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _withAuthentication = _interopRequireDefault(require("../Authentication/withAuthentication"));
|
|
10
|
+
var _withChannels = _interopRequireDefault(require("./withChannels"));
|
|
11
|
+
var _withCore = _interopRequireDefault(require("../Core/withCore"));
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
const namespace = 'UserChannel';
|
|
14
|
+
const channelId = 'user';
|
|
15
|
+
class UserChannel extends _react.Component {
|
|
16
|
+
componentDidMount() {
|
|
17
|
+
if (!this.props.channels.isChannelRegistered(channelId)) {
|
|
18
|
+
this.props.channels.registerChannel(channelId, data => this.channelFunction(data));
|
|
19
|
+
this.props.channels.updateChannel(channelId, null);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
componentDidUpdate(prevProps) {
|
|
23
|
+
if (this.props.authentication.didChange(prevProps.authentication)) {
|
|
24
|
+
this.props.channels.updateChannel(channelId, null);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
channelFunction() {
|
|
28
|
+
const methodName = 'channelFunction()';
|
|
29
|
+
return new Promise((resolve, reject) => {
|
|
30
|
+
if (this.props.authentication.authenticated) {
|
|
31
|
+
this.props.authentication.http({
|
|
32
|
+
method: 'get',
|
|
33
|
+
url: "".concat(this.props.core.baseUrl, "/api/administration/users/subscribe")
|
|
34
|
+
}).then(results => {
|
|
35
|
+
resolve(results.data);
|
|
36
|
+
}).catch(error => {
|
|
37
|
+
this.props.core.log('error', namespace, methodName, error);
|
|
38
|
+
reject(error);
|
|
39
|
+
});
|
|
40
|
+
} else {
|
|
41
|
+
reject(new Error({
|
|
42
|
+
message: 'Not Authenticated'
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
render() {
|
|
48
|
+
return '';
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
UserChannel.propTypes = {
|
|
52
|
+
core: _propTypes.default.shape().isRequired,
|
|
53
|
+
authentication: _propTypes.default.shape().isRequired,
|
|
54
|
+
channels: _propTypes.default.shape({
|
|
55
|
+
updateChannel: _propTypes.default.func,
|
|
56
|
+
registerChannel: _propTypes.default.func,
|
|
57
|
+
isChannelRegistered: _propTypes.default.func
|
|
58
|
+
}).isRequired
|
|
59
|
+
};
|
|
60
|
+
var _default = exports.default = (0, _withChannels.default)((0, _withCore.default)((0, _withAuthentication.default)(UserChannel)));
|