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.
Files changed (142) hide show
  1. package/dist/components/CoreAlert/CoreAlert.js +85 -0
  2. package/dist/components/CoreAlert/index.js +13 -0
  3. package/dist/components/CoreAlert/readme.md +21 -0
  4. package/dist/components/CoreAppBar/CoreAppBar.js +364 -0
  5. package/dist/components/CoreAppBar/CoreAppBarDrawer.js +134 -0
  6. package/dist/components/CoreAppBar/README.md +27 -0
  7. package/dist/components/CoreAppBar/index.js +13 -0
  8. package/dist/components/CoreAppBar/screenshot.png +0 -0
  9. package/dist/components/CoreAppSelector/AppLink.js +101 -0
  10. package/dist/components/CoreAppSelector/CoreAppSelector.js +155 -0
  11. package/dist/components/CoreAppSelector/index.js +13 -0
  12. package/dist/components/CoreDialogueToolBar/CoreDialogueToolBar.js +123 -0
  13. package/dist/components/CoreDialogueToolBar/index.js +13 -0
  14. package/dist/components/CoreDrawer/CoreDrawer.js +236 -0
  15. package/dist/components/CoreDrawer/README.md +36 -0
  16. package/dist/components/CoreDrawer/index.js +13 -0
  17. package/dist/components/CoreDrawer/screenshot_collapsed.png +0 -0
  18. package/dist/components/CoreDrawer/screenshot_expanded.png +0 -0
  19. package/dist/components/CoreDropDownTextfield/CoreDropDownTextfield.js +85 -0
  20. package/dist/components/CoreDropDownTextfield/index.js +13 -0
  21. package/dist/components/CoreElapsedTime/CoreElapsedTime.js +57 -0
  22. package/dist/components/CoreElapsedTime/index.js +13 -0
  23. package/dist/components/CoreFrame/CoreFrame.js +64 -0
  24. package/dist/components/CoreFrame/index.js +13 -0
  25. package/dist/components/CoreImportDialog/CoreImportDialog.js +350 -0
  26. package/dist/components/CoreImportDialog/index.js +13 -0
  27. package/dist/components/CoreImportResultsDialog/CoreImportResultsDialog.js +103 -0
  28. package/dist/components/CoreImportResultsDialog/index.js +13 -0
  29. package/dist/components/CoreImporting/CoreImporting.js +60 -0
  30. package/dist/components/CoreImporting/index.js +13 -0
  31. package/dist/components/CorePlugin/CorePlugin.js +134 -0
  32. package/dist/components/CorePlugin/OldCorePlugin.js +124 -0
  33. package/dist/components/CorePlugin/index.js +13 -0
  34. package/dist/components/CoreSaveChangesDialog/CoreSaveChangesDialog.js +62 -0
  35. package/dist/components/CoreSaveChangesDialog/index.js +13 -0
  36. package/dist/components/CoreShiftTagFilter/CoreShiftTagFilter.js +350 -0
  37. package/dist/components/CoreShiftTagFilter/OldCoreShiftTagFilter.js +208 -0
  38. package/dist/components/CoreShiftTagFilter/index.js +13 -0
  39. package/dist/components/CoreSideBar/CoreSideBar.js +737 -0
  40. package/dist/components/CoreSideBar/CoreSideBarDrawer.js +172 -0
  41. package/dist/components/CoreSideBar/index.js +13 -0
  42. package/dist/components/CoreSnackBar/CoreSnackBar.js +116 -0
  43. package/dist/components/CoreSnackBar/index.js +13 -0
  44. package/dist/components/CoreSnackBar/readme.md +23 -0
  45. package/dist/components/CoreTable/CoreTable.js +315 -0
  46. package/dist/components/CoreTable/CoreTableChips.js +50 -0
  47. package/dist/components/CoreTable/CoreTableHead.js +175 -0
  48. package/dist/components/CoreTable/CoreTableToolbar.js +108 -0
  49. package/dist/components/CoreTable/index.js +13 -0
  50. package/dist/components/CoreTable/readMe.md +79 -0
  51. package/dist/components/CoreTagFilter/CoreTagFilter.js +275 -0
  52. package/dist/components/CoreTagFilter/OldCoreTagFilter.js +341 -0
  53. package/dist/components/CoreTagFilter/OldTagChip.js +44 -0
  54. package/dist/components/CoreTagFilter/OldTagFilterSelector.js +105 -0
  55. package/dist/components/CoreTagFilter/OldTagOption.js +53 -0
  56. package/dist/components/CoreTagFilter/TagFilterBuilder.js +487 -0
  57. package/dist/components/CoreTagFilter/index.js +13 -0
  58. package/dist/components/CoreTextField/CoreTextField.js +109 -0
  59. package/dist/components/CoreTextField/index.js +13 -0
  60. package/dist/components/CoreTheme/CoreTheme.css +9 -0
  61. package/dist/components/CoreTheme/CoreTheme.js +51 -0
  62. package/dist/components/CoreTheme/README.md +3 -0
  63. package/dist/components/CoreTheme/index.js +13 -0
  64. package/dist/components/CoreTile/CoreTile.js +62 -0
  65. package/dist/components/CoreTile/CoreTileToolbar.js +62 -0
  66. package/dist/components/CoreTile/index.js +13 -0
  67. package/dist/components/CoreTimerInput/CoreTimerInput.js +203 -0
  68. package/dist/components/CoreTimerInput/CoreTimerInputOld.js +146 -0
  69. package/dist/components/CoreTimerInput/index.js +13 -0
  70. package/dist/components/CoreToolbar/CoreToolbar.js +205 -0
  71. package/dist/components/CoreToolbar/index.js +13 -0
  72. package/dist/components/CoreTracker/CoreTracker.js +52 -0
  73. package/dist/components/CoreTracker/index.js +13 -0
  74. package/dist/components/CoreTranslate/CoreTranslate.js +62 -0
  75. package/dist/components/CoreTranslate/README.md +5 -0
  76. package/dist/components/CoreTranslate/index.js +13 -0
  77. package/dist/components/CoreTranslate/translations/en.json +451 -0
  78. package/dist/components/CoreTranslate/translations/es.json +433 -0
  79. package/dist/components/CoreTranslateWrapper/CoreTranslateWrapper.js +36 -0
  80. package/dist/components/CoreTranslateWrapper/index.js +13 -0
  81. package/dist/components/CoreWidget/CoreWidget.js +120 -0
  82. package/dist/components/CoreWidget/index.js +13 -0
  83. package/dist/components/CoreWrapper/CoreWrapper.js +51 -0
  84. package/dist/components/CoreWrapper/README.md +41 -0
  85. package/dist/components/CoreWrapper/index.js +13 -0
  86. package/dist/components/index.js +202 -0
  87. package/dist/constants/index.js +20 -0
  88. package/dist/constants/testOrganization.js +31 -0
  89. package/dist/constants/testToken.js +33 -0
  90. package/dist/context/Authentication/AuthenticationContext.js +10 -0
  91. package/dist/context/Authentication/AuthenticationProvider.js +225 -0
  92. package/dist/context/Authentication/README.md +47 -0
  93. package/dist/context/Authentication/index.js +27 -0
  94. package/dist/context/Authentication/withAuthentication.js +15 -0
  95. package/dist/context/Channels/ChannelsConsumer.js +42 -0
  96. package/dist/context/Channels/ChannelsContext.js +10 -0
  97. package/dist/context/Channels/ChannelsProvider.js +258 -0
  98. package/dist/context/Channels/DataChannel.js +68 -0
  99. package/dist/context/Channels/EntityChannel.js +69 -0
  100. package/dist/context/Channels/EveryoneChannel.js +55 -0
  101. package/dist/context/Channels/OrganizationChannel.js +69 -0
  102. package/dist/context/Channels/README.md +52 -0
  103. package/dist/context/Channels/UserChannel.js +60 -0
  104. package/dist/context/Channels/index.js +69 -0
  105. package/dist/context/Channels/withChannels.js +15 -0
  106. package/dist/context/Core/CoreContext.js +10 -0
  107. package/dist/context/Core/CoreProvider.js +107 -0
  108. package/dist/context/Core/README.md +43 -0
  109. package/dist/context/Core/index.js +27 -0
  110. package/dist/context/Core/withCore.js +15 -0
  111. package/dist/context/Organization/OrganizationContext.js +10 -0
  112. package/dist/context/Organization/OrganizationProvider.js +108 -0
  113. package/dist/context/Organization/README.md +82 -0
  114. package/dist/context/Organization/index.js +27 -0
  115. package/dist/context/Organization/withOrganization.js +15 -0
  116. package/dist/context/Plugin/PluginContext.js +10 -0
  117. package/dist/context/Plugin/PluginProvider.js +78 -0
  118. package/dist/context/Plugin/index.js +27 -0
  119. package/dist/context/Plugin/withPlugin.js +15 -0
  120. package/dist/context/index.js +60 -0
  121. package/dist/css/index.js +20 -0
  122. package/dist/css/junk.module.css +3 -0
  123. package/dist/css/scrollbar.css +35 -0
  124. package/dist/css/scrollbar.module.css +37 -0
  125. package/dist/functions/TagEvaluator.js +165 -0
  126. package/dist/functions/compareObjects.js +27 -0
  127. package/dist/functions/formatElapsedTime.js +18 -0
  128. package/dist/functions/formatNameFileSafe.js +16 -0
  129. package/dist/functions/getIconUrl.js +15 -0
  130. package/dist/functions/getParameterByName.js +34 -0
  131. package/dist/functions/getProperty.js +17 -0
  132. package/dist/functions/getUrl.js +15 -0
  133. package/dist/functions/index.js +62 -0
  134. package/dist/icons/CopyIcon.js +42 -0
  135. package/dist/icons/DeleteIcon.js +42 -0
  136. package/dist/icons/DuplicateIcon.js +42 -0
  137. package/dist/icons/EditIcon.js +42 -0
  138. package/dist/icons/FabAddIcon.js +78 -0
  139. package/dist/icons/PasteIcon.js +42 -0
  140. package/dist/icons/index.js +48 -0
  141. package/dist/index.js +71 -0
  142. package/package.json +2 -2
@@ -0,0 +1,737 @@
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 _styles = require("@material-ui/core/styles");
10
+ var _Avatar = _interopRequireDefault(require("@material-ui/core/Avatar"));
11
+ var _Badge = _interopRequireDefault(require("@material-ui/core/Badge"));
12
+ var _Button = _interopRequireDefault(require("@material-ui/core/Button"));
13
+ var _Divider = _interopRequireDefault(require("@material-ui/core/Divider"));
14
+ var _Drawer = _interopRequireDefault(require("@material-ui/core/Drawer"));
15
+ var _IconButton = _interopRequireDefault(require("@material-ui/core/IconButton"));
16
+ var _ListItem = _interopRequireDefault(require("@material-ui/core/ListItem"));
17
+ var _ListItemIcon = _interopRequireDefault(require("@material-ui/core/ListItemIcon"));
18
+ var _ListItemText = _interopRequireDefault(require("@material-ui/core/ListItemText"));
19
+ var _Menu = _interopRequireDefault(require("@material-ui/core/Menu"));
20
+ var _MenuItem = _interopRequireDefault(require("@material-ui/core/MenuItem"));
21
+ var _Tooltip = _interopRequireDefault(require("@material-ui/core/Tooltip"));
22
+ var _Typography = _interopRequireDefault(require("@material-ui/core/Typography"));
23
+ var _AccountCircle = _interopRequireDefault(require("@material-ui/icons/AccountCircle"));
24
+ var _Delete = _interopRequireDefault(require("@material-ui/icons/Delete"));
25
+ var _LocationCity = _interopRequireDefault(require("@material-ui/icons/LocationCity"));
26
+ var _Menu2 = _interopRequireDefault(require("@material-ui/icons/Menu"));
27
+ var _ExitToApp = _interopRequireDefault(require("@material-ui/icons/ExitToApp"));
28
+ var _Notifications = _interopRequireDefault(require("@material-ui/icons/Notifications"));
29
+ var _Error = _interopRequireDefault(require("@material-ui/icons/Error"));
30
+ var _Info = _interopRequireDefault(require("@material-ui/icons/Info"));
31
+ var _Warning = _interopRequireDefault(require("@material-ui/icons/Warning"));
32
+ var _StarBorder = _interopRequireDefault(require("@material-ui/icons/StarBorder"));
33
+ var _Star = _interopRequireDefault(require("@material-ui/icons/Star"));
34
+ var _reactIntl = require("react-intl");
35
+ var _context = require("../../context");
36
+ var _CoreSideBarDrawer = _interopRequireDefault(require("./CoreSideBarDrawer"));
37
+ var _scrollbarModule = _interopRequireDefault(require("../../css/scrollbar.module.css"));
38
+ require("../../css/scrollbar.css");
39
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
40
+ 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); }
41
+ // import ListItemAvatar from '@material-ui/core/ListItemAvatar';
42
+
43
+ // import Toolbar from '@material-ui/core/Toolbar';
44
+
45
+ // import SettingsIcon from '@material-ui/icons/Settings';
46
+
47
+ // import SubscriptionActiveIcon from '@material-ui/icons/CheckCircleOutline';
48
+ // import SubscriptionInactiveIcon from '@material-ui/icons/ErrorOutline';
49
+
50
+ const namespace = 'CoreSideBar';
51
+ const styles = theme => ({
52
+ root: {
53
+ display: 'flex',
54
+ height: '100vh',
55
+ overflow: 'hidden'
56
+ },
57
+ content: {
58
+ position: 'relative',
59
+ width: '100%'
60
+ },
61
+ topPadding: {
62
+ minHeight: 56,
63
+ '@media (min-width:600px)': {
64
+ minHeight: 64
65
+ }
66
+ },
67
+ drawerPaper: {
68
+ position: 'relative',
69
+ whiteSpace: 'nowrap',
70
+ backgroundColor: '#496b78',
71
+ color: '#ffffff',
72
+ display: 'flex',
73
+ flexDirection: 'column'
74
+ },
75
+ listItemRoot: {
76
+ color: '#ffffff'
77
+ },
78
+ menuPaper: {
79
+ backgroundColor: '#3f5c67'
80
+ },
81
+ menuItemRoot: {
82
+ color: '#ffffff'
83
+ },
84
+ icon: {
85
+ verticalAlign: 'middle',
86
+ height: 24,
87
+ width: 24
88
+ },
89
+ svgIcon: {
90
+ verticalAlign: 'middle',
91
+ height: 24,
92
+ width: 24,
93
+ filter: 'invert(1)'
94
+ },
95
+ inline: {
96
+ display: 'inline',
97
+ color: '#cccccc'
98
+ },
99
+ notificationRoot: {
100
+ width: 200
101
+ },
102
+ badgeError: {
103
+ backgroundColor: theme.palette.error.light,
104
+ color: theme.palette.error.contrastText
105
+ },
106
+ badgeWarning: {
107
+ backgroundColor: theme.palette.warning.light,
108
+ color: theme.palette.warning.contrastText
109
+ },
110
+ badgeInfo: {
111
+ backgroundColor: theme.palette.info.light,
112
+ color: theme.palette.info.contrastText
113
+ },
114
+ menuIconButton: {
115
+ // background: '#3f5c67',
116
+ // borderRadius: 10,
117
+ // marginRight: 10,
118
+ }
119
+ });
120
+ const style = {
121
+ title: {
122
+ // flexGrow: 1,
123
+ textAlign: 'center',
124
+ marginTop: 10,
125
+ marginBottom: 10
126
+ },
127
+ orgEntity: {
128
+ flexGrow: 1,
129
+ textAlign: 'center'
130
+ },
131
+ flex: {
132
+ // flexGrow: 1,
133
+ textAlign: 'center'
134
+ },
135
+ titleButton: {
136
+ textTransform: 'none',
137
+ borderColor: 'white'
138
+ },
139
+ menuButton: {
140
+ marginLeft: -12,
141
+ marginRight: 12,
142
+ backgroundColor: '#496b78'
143
+ },
144
+ navLink: {
145
+ textDecoration: 'none',
146
+ color: '#ffffff'
147
+ },
148
+ // NOTE: activeStyle doesn't really seem to stay applied. Believe this might be because HashRouter/Router is on a different component
149
+ activeStyle: {
150
+ backgroundColor: '#3f5c67',
151
+ color: '#55b7dc',
152
+ pointerEvents: 'none'
153
+ }
154
+ };
155
+
156
+ /* const getNotificationsBadgeColor = notifications => {
157
+ return 'warning';
158
+ let hasError = false;
159
+ let hasWarning = false;
160
+ notifications.forEach(notification => {
161
+ if (notification.type === 'error') {
162
+ hasError = true;
163
+ } if (notification.type === 'warning') {
164
+ hasWarning = true;
165
+ }
166
+ });
167
+ if (hasError) {
168
+ return 'error';
169
+ } if (hasWarning) {
170
+ return 'warning';
171
+ }
172
+ return 'primary';
173
+ }; */
174
+
175
+ class CoreSideBar extends _react.Component {
176
+ constructor() {
177
+ super();
178
+ this.state = {
179
+ drawer: false,
180
+ organizationAnchorEl: null,
181
+ entityAnchorEl: null,
182
+ authenticationAnchorEl: null,
183
+ notificationsAnchorEl: null,
184
+ apps: [],
185
+ organizations: [],
186
+ entities: [],
187
+ favorites: [],
188
+ // subscription: null,
189
+ notifications: []
190
+ };
191
+ }
192
+ componentDidMount() {
193
+ this.getOrganizations();
194
+ // this.getSubscription();
195
+ this.getNotifications();
196
+ }
197
+ componentDidUpdate(prevProps) {
198
+ if (this.props.authentication.didChange(prevProps.authentication)) {
199
+ this.getOrganizations();
200
+ }
201
+ if (this.props.organization.didOrganizationChange(prevProps.organization.organization)) {
202
+ this.getEntities();
203
+ }
204
+ if (this.props.authentication.didChange(prevProps.authentication) || this.props.organization.didChange(prevProps.organization)) {
205
+ this.getApps();
206
+ this.getFavorites();
207
+ // this.getSubscription();
208
+ this.getNotifications();
209
+ }
210
+ }
211
+ getOrganizations() {
212
+ const methodName = 'getOrganizations()';
213
+ this.props.authentication.http({
214
+ method: 'get',
215
+ url: "".concat(this.props.core.baseUrl, "/api/administration/organizations")
216
+ }).then(res => {
217
+ if (res.data.length > 0 && typeof res.data[0] === 'object') {
218
+ this.setState({
219
+ organizations: res.data
220
+ });
221
+ if (this.props.organization.organization === null || res.data.find(x => x.id === this.props.organization.organization.id) === undefined) {
222
+ this.props.organization.setOrganization(res.data[0]);
223
+ }
224
+ }
225
+ }).catch(error => {
226
+ this.props.core.log('error', namespace, methodName, error);
227
+ });
228
+ }
229
+ getEntities() {
230
+ const methodName = 'getEntities()';
231
+ if (this.props.organization.organization !== null) {
232
+ this.props.authentication.http({
233
+ method: 'get',
234
+ url: "".concat(this.props.core.baseUrl, "/api/administration/entities/organization/").concat(this.props.organization.organization.key)
235
+ }).then(res => {
236
+ if (res.data.length > 0 && typeof res.data[0] === 'object') {
237
+ this.setState({
238
+ entities: res.data
239
+ });
240
+ if (this.props.organization.entity === null || res.data.find(x => x.id === this.props.organization.entity.id) === undefined) {
241
+ this.props.organization.setEntity(res.data[0]);
242
+ }
243
+ }
244
+ }).catch(error => {
245
+ this.props.core.log('error', namespace, methodName, error);
246
+ });
247
+ }
248
+ }
249
+ getApps() {
250
+ const methodName = 'getApps()';
251
+ if (this.props.organization.organization !== null && this.props.organization.entity !== null) {
252
+ this.props.authentication.http({
253
+ method: 'get',
254
+ url: "".concat(this.props.core.baseUrl, "/api/components/tiered"),
255
+ params: {
256
+ type: 'UI',
257
+ organizationId: this.props.organization.organization.id,
258
+ entityId: this.props.organization.entity.id
259
+ }
260
+ }).then(res => {
261
+ if (res.data.length > 0 && typeof res.data[0] === 'object') {
262
+ this.setState({
263
+ apps: res.data
264
+ });
265
+ }
266
+ }).catch(error => {
267
+ this.props.core.log('error', namespace, methodName, error);
268
+ });
269
+ }
270
+ }
271
+ getFavorites() {
272
+ const methodName = 'getFavorites()';
273
+ if (this.props.organization.organization !== null && this.props.organization.entity !== null) {
274
+ this.props.authentication.http({
275
+ method: 'get',
276
+ url: "".concat(this.props.core.baseUrl, "/api/user/activity/favorites"),
277
+ params: {
278
+ type: 'App'
279
+ }
280
+ }).then(res => {
281
+ this.setState({
282
+ favorites: res.data
283
+ });
284
+ }).catch(error => {
285
+ this.props.core.log('error', namespace, methodName, error);
286
+ });
287
+ }
288
+ }
289
+ getNotifications() {
290
+ const methodName = 'getNotifications()';
291
+ const {
292
+ authentication,
293
+ core,
294
+ organization
295
+ } = this.props;
296
+ if (organization.organization !== null && organization.entity !== null) {
297
+ authentication.http({
298
+ method: 'get',
299
+ url: "".concat(core.baseUrl, "/api/user/activity/notifications"),
300
+ params: {
301
+ organizationId: organization.organization.id,
302
+ entityId: organization.entity.id
303
+ }
304
+ }).then(res => {
305
+ this.setState({
306
+ notifications: res.data
307
+ });
308
+ }).catch(error => {
309
+ core.log('error', namespace, methodName, error);
310
+ });
311
+ }
312
+ }
313
+
314
+ /* getSubscription() {
315
+ const methodName = 'getSubscription()';
316
+ const { authentication, core, organization } = this.props;
317
+ if (organization.organization !== null && organization.entity !== null) {
318
+ authentication.http({
319
+ method: 'get',
320
+ url: `${core.baseUrl}/api/subscriptions/primary`,
321
+ params: {
322
+ organizationId: organization.organization.id,
323
+ entityId: organization.entity.id,
324
+ },
325
+ }).then(res => {
326
+ this.setState({ subscription: res.data });
327
+ }).catch(error => {
328
+ core.log('error', namespace, methodName, error);
329
+ });
330
+ }
331
+ } */
332
+
333
+ getUsersInitials() {
334
+ const {
335
+ authentication
336
+ } = this.props;
337
+ let initials = '';
338
+ if (authentication.token && authentication.token.userInfo) {
339
+ if (authentication.token.userInfo.firstName.length > 0) {
340
+ initials += authentication.token.userInfo.firstName[0].toUpperCase();
341
+ }
342
+ if (authentication.token.userInfo.lastName.length > 0) {
343
+ initials += authentication.token.userInfo.lastName[0].toUpperCase();
344
+ }
345
+ }
346
+ return initials;
347
+ }
348
+ getNotificationBadgeClass() {
349
+ const {
350
+ notifications
351
+ } = this.state;
352
+ const {
353
+ classes
354
+ } = this.props;
355
+ let hasError = false;
356
+ let hasWarning = false;
357
+ notifications.forEach(notification => {
358
+ if (notification.type === 'error') {
359
+ hasError = true;
360
+ }
361
+ if (notification.type === 'warning') {
362
+ hasWarning = true;
363
+ }
364
+ });
365
+ if (hasError) {
366
+ return classes.badgeError;
367
+ }
368
+ if (hasWarning) {
369
+ return classes.badgeWarning;
370
+ }
371
+ return classes.badgeInfo;
372
+ }
373
+ getNotificationIcon(type) {
374
+ const {
375
+ theme
376
+ } = this.props;
377
+ switch (type.toLowerCase()) {
378
+ case 'error':
379
+ // '#ff6666'
380
+ return /*#__PURE__*/_react.default.createElement(_Error.default, {
381
+ style: {
382
+ color: theme.palette.error.light
383
+ }
384
+ });
385
+ case 'warning':
386
+ // 'yellow'
387
+ return /*#__PURE__*/_react.default.createElement(_Warning.default, {
388
+ style: {
389
+ color: theme.palette.warning.light
390
+ }
391
+ });
392
+ default:
393
+ // 'lightblue'
394
+ return /*#__PURE__*/_react.default.createElement(_Info.default, {
395
+ style: {
396
+ color: theme.palette.info.light
397
+ }
398
+ });
399
+ }
400
+ }
401
+ favoriteApp() {
402
+ const methodName = 'favoriteApp()';
403
+ if (this.props.organization.organization !== null && this.props.organization.entity !== null) {
404
+ this.props.authentication.http({
405
+ method: 'post',
406
+ url: "".concat(this.props.core.baseUrl, "/api/user/activity/favorite"),
407
+ params: {
408
+ type: 'App',
409
+ itemId: this.props.componentID,
410
+ favorite: !this.state.favorites.includes(this.props.componentID)
411
+ }
412
+ }).then(() => {
413
+ this.getFavorites();
414
+ }).catch(error => {
415
+ this.props.core.log('error', namespace, methodName, error);
416
+ });
417
+ }
418
+ }
419
+ dismissNotification(id) {
420
+ const methodName = "dismissNotification(".concat(id, ")");
421
+ const {
422
+ authentication,
423
+ core
424
+ } = this.props;
425
+ authentication.http({
426
+ method: 'delete',
427
+ url: "".concat(core.baseUrl, "/api/user/activity/notifications/").concat(id)
428
+ }).catch(error => {
429
+ core.log('error', namespace, methodName, error);
430
+ });
431
+ }
432
+ handleMessage(channel, obj) {
433
+ switch (obj.what) {
434
+ case 'notifications_changed':
435
+ this.getNotifications();
436
+ break;
437
+ case 'package_enabled':
438
+ case 'package_disabled':
439
+ case 'package_added':
440
+ case 'package_updated':
441
+ case 'package_deleted':
442
+ this.getApps();
443
+ break;
444
+ case 'entities_added':
445
+ case 'entities_updated':
446
+ case 'entities_deleted':
447
+ this.getEntities();
448
+ break;
449
+ default:
450
+ break;
451
+ }
452
+ }
453
+ render() {
454
+ const {
455
+ title,
456
+ componentID,
457
+ authentication,
458
+ organization,
459
+ classes
460
+ } = this.props;
461
+ const {
462
+ notificationsAnchorEl,
463
+ notifications
464
+ } = this.state;
465
+ return /*#__PURE__*/_react.default.createElement("div", {
466
+ className: classes.root
467
+ }, /*#__PURE__*/_react.default.createElement(_context.ChannelsConsumer, {
468
+ id: "coreappbar",
469
+ handler: (channel, obj) => this.handleMessage(channel, obj)
470
+ }), /*#__PURE__*/_react.default.createElement(_Drawer.default, {
471
+ variant: "permanent",
472
+ classes: {
473
+ paper: classes.drawerPaper
474
+ }
475
+ }, /*#__PURE__*/_react.default.createElement("div", {
476
+ style: {
477
+ display: 'flex',
478
+ flexDirection: ' row',
479
+ backgroundColor: '#3f5c67'
480
+ }
481
+ }, /*#__PURE__*/_react.default.createElement("div", {
482
+ style: {
483
+ backgroundColor: '#496b78',
484
+ alignItems: 'center',
485
+ justifyContent: 'center'
486
+ }
487
+ }, /*#__PURE__*/_react.default.createElement(_IconButton.default, {
488
+ style: {
489
+ margin: 8
490
+ },
491
+ color: "inherit",
492
+ onClick: () => this.setState({
493
+ drawer: true
494
+ })
495
+ }, /*#__PURE__*/_react.default.createElement(_Menu2.default, null))), /*#__PURE__*/_react.default.createElement("div", {
496
+ style: style.orgEntity
497
+ }, /*#__PURE__*/_react.default.createElement(_Button.default, {
498
+ color: "inherit",
499
+ style: style.titleButton,
500
+ variant: "text",
501
+ onClick: this.state.entities.length > 1 ? e => this.setState({
502
+ entityAnchorEl: e.currentTarget
503
+ }) : null
504
+ }, /*#__PURE__*/_react.default.createElement("div", null, organization.organization ? organization.organization.name : null, this.props.showEntity && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("br", null), organization.entity ? organization.entity.name : null))))), /*#__PURE__*/_react.default.createElement(_Typography.default, {
505
+ style: style.title,
506
+ variant: "h6",
507
+ color: "inherit"
508
+ }, title), /*#__PURE__*/_react.default.createElement(_Divider.default, null), /*#__PURE__*/_react.default.createElement("div", {
509
+ className: "".concat(_scrollbarModule.default.scroll, " ").concat(_scrollbarModule.default.white),
510
+ style: {
511
+ flexGrow: 1,
512
+ minHeight: 0,
513
+ overflow: 'auto'
514
+ }
515
+ }, this.props.content), /*#__PURE__*/_react.default.createElement(_Divider.default, null), /*#__PURE__*/_react.default.createElement("div", {
516
+ style: {
517
+ padding: 5
518
+ }
519
+ }, /*#__PURE__*/_react.default.createElement(_Tooltip.default, {
520
+ title: "".concat(this.props.authentication.token.userInfo.firstName, " ").concat(this.props.authentication.token.userInfo.lastName)
521
+ }, /*#__PURE__*/_react.default.createElement(_IconButton.default, {
522
+ color: "inherit",
523
+ onClick: e => this.setState({
524
+ authenticationAnchorEl: e.currentTarget
525
+ }),
526
+ className: classes.menuIconButton
527
+ }, /*#__PURE__*/_react.default.createElement(_AccountCircle.default, null))), /*#__PURE__*/_react.default.createElement(_Tooltip.default, {
528
+ title: notifications.length > 0 ? "You have ".concat(notifications.length, " notification").concat(notifications.length > 0 ? 's' : '') : 'There are no notifications'
529
+ }, /*#__PURE__*/_react.default.createElement(_IconButton.default, {
530
+ color: "inherit",
531
+ onClick: notifications.length > 0 ? e => this.setState({
532
+ notificationsAnchorEl: e.currentTarget
533
+ }) : null,
534
+ className: classes.menuIconButton
535
+ }, /*#__PURE__*/_react.default.createElement(_Badge.default, {
536
+ badgeContent: notifications.length,
537
+ classes: {
538
+ badge: this.getNotificationBadgeClass()
539
+ },
540
+ showZero: false
541
+ }, /*#__PURE__*/_react.default.createElement(_Notifications.default, null)))), componentID.length > 0 && /*#__PURE__*/_react.default.createElement(_Tooltip.default, {
542
+ title: this.state.favorites.includes(componentID) ? /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
543
+ id: "__favorite"
544
+ }) : /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
545
+ id: "__click_to_favorite"
546
+ })
547
+ }, /*#__PURE__*/_react.default.createElement(_IconButton.default, {
548
+ color: "inherit",
549
+ onClick: () => this.favoriteApp(),
550
+ className: classes.menuIconButton
551
+ }, this.state.favorites.includes(componentID) ? /*#__PURE__*/_react.default.createElement(_Star.default, {
552
+ color: "inherit"
553
+ }) : /*#__PURE__*/_react.default.createElement(_StarBorder.default, {
554
+ color: "inherit"
555
+ }))))), /*#__PURE__*/_react.default.createElement("div", {
556
+ className: classes.content
557
+ }, this.props.children), /*#__PURE__*/_react.default.createElement(_CoreSideBarDrawer.default, {
558
+ open: this.state.drawer,
559
+ onClose: () => this.setState({
560
+ drawer: false
561
+ }),
562
+ apps: this.state.apps
563
+ }), /*#__PURE__*/_react.default.createElement(_Menu.default, {
564
+ open: !!this.state.organizationAnchorEl,
565
+ anchorEl: this.state.organizationAnchorEl,
566
+ anchorOrigin: {
567
+ vertical: 'top',
568
+ horizontal: 'center'
569
+ },
570
+ transformOrigin: {
571
+ vertical: 'top',
572
+ horizontal: 'center'
573
+ },
574
+ onClose: () => this.setState({
575
+ organizationAnchorEl: null
576
+ })
577
+ }, this.state.organizations.map(org => /*#__PURE__*/_react.default.createElement(_MenuItem.default, {
578
+ key: org.id,
579
+ onClick: () => {
580
+ organization.setOrganization(org);
581
+ this.setState({
582
+ organizationAnchorEl: null
583
+ });
584
+ }
585
+ }, /*#__PURE__*/_react.default.createElement(_ListItemIcon.default, null, /*#__PURE__*/_react.default.createElement(_LocationCity.default, null)), /*#__PURE__*/_react.default.createElement(_ListItemText.default, {
586
+ primary: org.name,
587
+ inset: true
588
+ })))), /*#__PURE__*/_react.default.createElement(_Menu.default, {
589
+ classes: {
590
+ paper: classes.menuPaper
591
+ },
592
+ anchorEl: this.state.entityAnchorEl,
593
+ anchorOrigin: {
594
+ vertical: 'top',
595
+ horizontal: 'center'
596
+ },
597
+ transformOrigin: {
598
+ vertical: 'top',
599
+ horizontal: 'center'
600
+ },
601
+ open: !!this.state.entityAnchorEl,
602
+ onClose: () => this.setState({
603
+ entityAnchorEl: null
604
+ })
605
+ }, this.state.entities.map(entity => /*#__PURE__*/_react.default.createElement(_MenuItem.default, {
606
+ classes: {
607
+ root: classes.menuItemRoot
608
+ },
609
+ key: entity.key,
610
+ onClick: () => {
611
+ organization.setEntity(entity);
612
+ this.setState({
613
+ entityAnchorEl: null
614
+ });
615
+ }
616
+ }, /*#__PURE__*/_react.default.createElement(_ListItemIcon.default, {
617
+ classes: {
618
+ root: classes.listItemRoot
619
+ }
620
+ }, /*#__PURE__*/_react.default.createElement(_LocationCity.default, null)), /*#__PURE__*/_react.default.createElement(_ListItemText.default, {
621
+ classes: {
622
+ primary: classes.listItemRoot
623
+ },
624
+ primary: entity.name,
625
+ inset: true
626
+ })))), /*#__PURE__*/_react.default.createElement(_Menu.default, {
627
+ classes: {
628
+ paper: classes.menuPaper
629
+ },
630
+ open: !!this.state.authenticationAnchorEl,
631
+ anchorEl: this.state.authenticationAnchorEl,
632
+ onClose: () => this.setState({
633
+ authenticationAnchorEl: null
634
+ })
635
+ }, /*#__PURE__*/_react.default.createElement(_ListItem.default, {
636
+ classes: {
637
+ root: classes.menuItemRoot
638
+ },
639
+ style: {
640
+ outline: 0
641
+ }
642
+ }, /*#__PURE__*/_react.default.createElement(_Avatar.default, {
643
+ style: {
644
+ marginRight: 10
645
+ }
646
+ }, this.getUsersInitials()), /*#__PURE__*/_react.default.createElement(_ListItemText.default, {
647
+ classes: {
648
+ primary: classes.menuItemRoot,
649
+ secondary: classes.menuItemRoot
650
+ },
651
+ primary: "".concat(this.props.authentication.token.userInfo.firstName, " ").concat(this.props.authentication.token.userInfo.lastName),
652
+ secondary: this.props.authentication.token.userInfo.emailAddress
653
+ })), /*#__PURE__*/_react.default.createElement(_Divider.default, null), /*#__PURE__*/_react.default.createElement("a", {
654
+ href: this.props.core.formatUrl('/profile'),
655
+ style: {
656
+ all: 'unset'
657
+ }
658
+ }, /*#__PURE__*/_react.default.createElement(_MenuItem.default, {
659
+ classes: {
660
+ root: classes.menuItemRoot
661
+ }
662
+ }, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
663
+ id: "__my_profile"
664
+ }))), /*#__PURE__*/_react.default.createElement(_Divider.default, null), /*#__PURE__*/_react.default.createElement(_MenuItem.default, {
665
+ classes: {
666
+ root: classes.menuItemRoot
667
+ },
668
+ onClick: () => authentication.logout()
669
+ }, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
670
+ id: "__log_out"
671
+ }))), /*#__PURE__*/_react.default.createElement(_Menu.default, {
672
+ classes: {
673
+ paper: classes.menuPaper,
674
+ root: classes.notificationRoot
675
+ },
676
+ open: !!notificationsAnchorEl,
677
+ anchorEl: notificationsAnchorEl,
678
+ onClose: () => this.setState({
679
+ notificationsAnchorEl: null
680
+ })
681
+ }, notifications.map(notification => /*#__PURE__*/_react.default.createElement(_ListItem.default, {
682
+ key: notification.id,
683
+ classes: {
684
+ root: classes.menuItemRoot
685
+ }
686
+ }, /*#__PURE__*/_react.default.createElement(_ListItemIcon.default, null, this.getNotificationIcon(notification.type)), /*#__PURE__*/_react.default.createElement(_ListItemText.default, {
687
+ primary: notification.title,
688
+ secondary: /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Typography.default, {
689
+ component: "span",
690
+ variant: "body2",
691
+ className: classes.inline,
692
+ color: "inherit"
693
+ }, notification.description))
694
+ }), notification.url && notification.url.length > 0 && /*#__PURE__*/_react.default.createElement(_IconButton.default, {
695
+ style: {
696
+ marginLeft: 5
697
+ },
698
+ "aria-label": "navigate",
699
+ onClick: () => window.open(notification.url, '__BLANK')
700
+ }, /*#__PURE__*/_react.default.createElement(_ExitToApp.default, {
701
+ style: {
702
+ color: '#ffffff'
703
+ }
704
+ })), notification.isDismissable && /*#__PURE__*/_react.default.createElement(_IconButton.default, {
705
+ style: {
706
+ marginLeft: 5
707
+ },
708
+ "aria-label": "delete",
709
+ onClick: () => this.dismissNotification(notification.id)
710
+ }, /*#__PURE__*/_react.default.createElement(_Delete.default, {
711
+ style: {
712
+ color: '#ffffff'
713
+ }
714
+ }))))));
715
+ }
716
+ }
717
+ CoreSideBar.propTypes = {
718
+ title: _propTypes.default.string,
719
+ showEntity: _propTypes.default.bool,
720
+ componentID: _propTypes.default.string,
721
+ core: _propTypes.default.shape().isRequired,
722
+ authentication: _propTypes.default.shape().isRequired,
723
+ // intl: PropTypes.shape().isRequired,
724
+ organization: _propTypes.default.shape().isRequired,
725
+ classes: _propTypes.default.shape().isRequired,
726
+ theme: _propTypes.default.shape().isRequired,
727
+ children: _propTypes.default.node,
728
+ content: _propTypes.default.node
729
+ };
730
+ CoreSideBar.defaultProps = {
731
+ showEntity: false,
732
+ title: '',
733
+ componentID: '',
734
+ children: null,
735
+ content: null
736
+ };
737
+ var _default = exports.default = (0, _reactIntl.injectIntl)((0, _context.withCore)((0, _context.withAuthentication)((0, _context.withOrganization)((0, _styles.withTheme)((0, _styles.withStyles)(styles)(CoreSideBar))))));