@memberjunction/ng-explorer-core 0.9.79 → 0.9.96

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 (105) hide show
  1. package/dist/lib/ask-skip/ask-skip.component.d.ts +87 -86
  2. package/dist/lib/ask-skip/ask-skip.component.js +615 -580
  3. package/dist/lib/ask-skip/skip-dynamic-report-wrapper.d.ts +12 -12
  4. package/dist/lib/ask-skip/skip-dynamic-report-wrapper.js +40 -39
  5. package/dist/lib/auth-button/auth-button.component.d.ts +12 -12
  6. package/dist/lib/auth-button/auth-button.component.js +44 -43
  7. package/dist/lib/dashboard-browser-component/dashboard-browser.component.d.ts +18 -18
  8. package/dist/lib/dashboard-browser-component/dashboard-browser.component.js +117 -117
  9. package/dist/lib/data-browser-component/data-browser.component.d.ts +16 -14
  10. package/dist/lib/data-browser-component/data-browser.component.js +96 -91
  11. package/dist/lib/favorites/favorites.component.d.ts +14 -14
  12. package/dist/lib/favorites/favorites.component.js +114 -114
  13. package/dist/lib/generic/base-form-component.d.ts +76 -76
  14. package/dist/lib/generic/base-form-component.js +436 -436
  15. package/dist/lib/generic/base-form-section-component.d.ts +6 -6
  16. package/dist/lib/generic/base-form-section-component.js +9 -9
  17. package/dist/lib/generic/base-record-component.d.ts +6 -6
  18. package/dist/lib/generic/base-record-component.js +15 -15
  19. package/dist/lib/generic/base-resource-component.d.ts +34 -34
  20. package/dist/lib/generic/base-resource-component.js +75 -75
  21. package/dist/lib/generic/dynamic-chart.d.ts +33 -33
  22. package/dist/lib/generic/dynamic-chart.js +236 -235
  23. package/dist/lib/generic/dynamic-grid.d.ts +25 -25
  24. package/dist/lib/generic/dynamic-grid.js +120 -119
  25. package/dist/lib/generic/dynamic-report.d.ts +38 -38
  26. package/dist/lib/generic/dynamic-report.js +353 -347
  27. package/dist/lib/generic/form-toolbar.d.ts +7 -7
  28. package/dist/lib/generic/form-toolbar.js +85 -89
  29. package/dist/lib/generic/resource-container-component.d.ts +25 -25
  30. package/dist/lib/generic/resource-container-component.js +104 -103
  31. package/dist/lib/generic/section-loader-component.d.ts +17 -17
  32. package/dist/lib/generic/section-loader-component.js +66 -65
  33. package/dist/lib/generic-browse-list/generic-browse-list.component.d.ts +26 -24
  34. package/dist/lib/generic-browse-list/generic-browse-list.component.js +145 -143
  35. package/dist/lib/guards/auth-guard.service.d.ts +11 -11
  36. package/dist/lib/guards/auth-guard.service.js +24 -24
  37. package/dist/lib/guards/entities.guard.d.ts +3 -3
  38. package/dist/lib/guards/entities.guard.js +38 -38
  39. package/dist/lib/header/MSFT_UserImageService.d.ts +11 -11
  40. package/dist/lib/header/MSFT_UserImageService.js +23 -23
  41. package/dist/lib/header/header.component.d.ts +51 -51
  42. package/dist/lib/header/header.component.js +220 -208
  43. package/dist/lib/home-component/home.component.d.ts +11 -9
  44. package/dist/lib/home-component/home.component.js +77 -54
  45. package/dist/lib/join-grid/join-grid.component.d.ts +30 -30
  46. package/dist/lib/join-grid/join-grid.component.js +222 -225
  47. package/dist/lib/navigation/navigation.component.d.ts +104 -103
  48. package/dist/lib/navigation/navigation.component.js +1026 -1004
  49. package/dist/lib/query-browser-component/query-browser.component.d.ts +14 -0
  50. package/dist/lib/query-browser-component/query-browser.component.js +55 -0
  51. package/dist/lib/report-browser-component/report-browser.component.d.ts +14 -14
  52. package/dist/lib/report-browser-component/report-browser.component.js +55 -55
  53. package/dist/lib/resource-wrappers/dashboard-resource.component.d.ts +8 -8
  54. package/dist/lib/resource-wrappers/dashboard-resource.component.js +51 -50
  55. package/dist/lib/resource-wrappers/query-resource.component.d.ts +10 -0
  56. package/dist/lib/resource-wrappers/query-resource.component.js +55 -0
  57. package/dist/lib/resource-wrappers/record-resource.component.d.ts +10 -10
  58. package/dist/lib/resource-wrappers/record-resource.component.js +71 -70
  59. package/dist/lib/resource-wrappers/report-resource.component.d.ts +10 -10
  60. package/dist/lib/resource-wrappers/report-resource.component.js +55 -54
  61. package/dist/lib/resource-wrappers/resource-wrappers-loader.d.ts +1 -1
  62. package/dist/lib/resource-wrappers/resource-wrappers-loader.js +14 -12
  63. package/dist/lib/resource-wrappers/search-results-resource.component.d.ts +10 -10
  64. package/dist/lib/resource-wrappers/search-results-resource.component.js +52 -51
  65. package/dist/lib/resource-wrappers/view-resource.component.d.ts +8 -8
  66. package/dist/lib/resource-wrappers/view-resource.component.js +61 -60
  67. package/dist/lib/settings/settings.component.d.ts +5 -5
  68. package/dist/lib/settings/settings.component.js +15 -14
  69. package/dist/lib/single-application/single-application.component.d.ts +20 -20
  70. package/dist/lib/single-application/single-application.component.js +113 -113
  71. package/dist/lib/single-dashboard/Components/add-item/add-item.component.d.ts +28 -28
  72. package/dist/lib/single-dashboard/Components/add-item/add-item.component.js +210 -212
  73. package/dist/lib/single-dashboard/Components/delete-item/delete-item.component.d.ts +13 -13
  74. package/dist/lib/single-dashboard/Components/delete-item/delete-item.component.js +60 -59
  75. package/dist/lib/single-dashboard/Components/edit-dashboard/edit-dashboard.component.d.ts +26 -26
  76. package/dist/lib/single-dashboard/Components/edit-dashboard/edit-dashboard.component.js +170 -169
  77. package/dist/lib/single-dashboard/single-dashboard.component.d.ts +75 -75
  78. package/dist/lib/single-dashboard/single-dashboard.component.js +464 -456
  79. package/dist/lib/single-entity/single-entity.component.d.ts +33 -33
  80. package/dist/lib/single-entity/single-entity.component.js +258 -252
  81. package/dist/lib/single-query/single-query.component.d.ts +16 -0
  82. package/dist/lib/single-query/single-query.component.js +70 -0
  83. package/dist/lib/single-record/single-record.component.d.ts +21 -21
  84. package/dist/lib/single-record/single-record.component.js +95 -95
  85. package/dist/lib/single-report/single-report.component.d.ts +22 -22
  86. package/dist/lib/single-report/single-report.component.js +88 -87
  87. package/dist/lib/single-search-result/single-search-result.component.d.ts +15 -15
  88. package/dist/lib/single-search-result/single-search-result.component.js +61 -60
  89. package/dist/lib/single-view/single-view.component.d.ts +38 -38
  90. package/dist/lib/single-view/single-view.component.js +201 -201
  91. package/dist/lib/user-notifications/user-notifications.component.d.ts +32 -32
  92. package/dist/lib/user-notifications/user-notifications.component.js +282 -282
  93. package/dist/lib/user-profile/user-profile.component.d.ts +10 -10
  94. package/dist/lib/user-profile/user-profile.component.js +42 -41
  95. package/dist/lib/user-view-properties/view-properties-dialog.component.d.ts +71 -71
  96. package/dist/lib/user-view-properties/view-properties-dialog.component.js +591 -581
  97. package/dist/module.d.ts +69 -65
  98. package/dist/module.js +356 -338
  99. package/dist/public-api.d.ts +46 -47
  100. package/dist/public-api.js +49 -50
  101. package/dist/shared/shared.service.d.ts +94 -92
  102. package/dist/shared/shared.service.js +324 -318
  103. package/dist/shared/urlPipe.d.ts +7 -7
  104. package/dist/shared/urlPipe.js +16 -16
  105. package/package.json +23 -15
@@ -1,318 +1,324 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { Injectable } from '@angular/core';
11
- import { LogError, Metadata, RunView } from '@memberjunction/core';
12
- import { MJEventType, MJGlobal } from '@memberjunction/global';
13
- import { Subject } from 'rxjs';
14
- import * as i0 from "@angular/core";
15
- import * as i1 from "@progress/kendo-angular-notification";
16
- export class SharedService {
17
- constructor(notificationService) {
18
- this.notificationService = notificationService;
19
- this.tabChange = new Subject();
20
- this.tabChange$ = this.tabChange.asObservable();
21
- this._currentUserImage = '/assets/user.png';
22
- this._resourceTypeMap = [
23
- { routeSegment: 'record', name: 'records' },
24
- { routeSegment: 'view', name: 'user views' },
25
- { routeSegment: 'search', name: 'search results' },
26
- { routeSegment: 'report', name: 'reports' },
27
- { routeSegment: 'dashboard', name: 'dashboards' }
28
- ];
29
- if (SharedService._instance) {
30
- // return existing instance which will short circuit the creation of a new instance
31
- return SharedService._instance;
32
- }
33
- // first time this has been called, so return ourselves since we're in the constructor
34
- SharedService._instance = this;
35
- MJGlobal.Instance.GetEventListener(true).subscribe((event) => {
36
- switch (event.event) {
37
- case MJEventType.DisplaySimpleNotificationRequest:
38
- // received the message to display a notification to the user, so do that...
39
- const messageData = event.args;
40
- this.CreateSimpleNotification(messageData.message, messageData.style, messageData.DisplayDuration);
41
- break;
42
- case MJEventType.ComponentEvent:
43
- if (event.eventCode === EventCodes.UserNotificationsUpdated) {
44
- // refresh the user notifications
45
- SharedService.RefreshUserNotifications();
46
- }
47
- break;
48
- case MJEventType.LoggedIn:
49
- if (SharedService._loaded === false)
50
- SharedService.RefreshData();
51
- // got the login, now subscribe to push status updates here so we can then raise them as events in MJ Global locally
52
- this.PushStatusUpdates().subscribe((status) => {
53
- var _a, _b;
54
- const statusObj = JSON.parse(status.message);
55
- // pass along as an event so anyone else who wants to know about the push status update can do stuff
56
- MJGlobal.Instance.RaiseEvent({
57
- event: MJEventType.ComponentEvent,
58
- eventCode: EventCodes.PushStatusUpdates,
59
- args: statusObj,
60
- component: this
61
- });
62
- if (((_a = statusObj.type) === null || _a === void 0 ? void 0 : _a.trim().toLowerCase()) === 'usernotifications') {
63
- if (statusObj.details && ((_b = statusObj.details.action) === null || _b === void 0 ? void 0 : _b.trim().toLowerCase()) === 'create') {
64
- // we have changes to user notifications, so refresh them
65
- this.CreateSimpleNotification('New Notification Available', "success", 2000);
66
- SharedService.RefreshUserNotifications();
67
- }
68
- }
69
- else {
70
- // otherwise just post it as a simple notification
71
- this.CreateSimpleNotification(statusObj.message, "success", 2500);
72
- }
73
- });
74
- break;
75
- }
76
- });
77
- }
78
- static get Instance() {
79
- return SharedService._instance;
80
- }
81
- /**
82
- * Returns the current session ID, which is automatically created when the service is instantiated.
83
- */
84
- get SessionId() {
85
- return Metadata.Provider.sessionId;
86
- }
87
- get ResourceTypes() {
88
- return SharedService._resourceTypes;
89
- }
90
- get ViewResourceType() {
91
- return SharedService._resourceTypes.find(rt => rt.Name.trim().toLowerCase() === 'user views');
92
- }
93
- get RecordResourceType() {
94
- return SharedService._resourceTypes.find(rt => rt.Name.trim().toLowerCase() === 'records');
95
- }
96
- get DashboardResourceType() {
97
- return SharedService._resourceTypes.find(rt => rt.Name.trim().toLowerCase() === 'dashboards');
98
- }
99
- get ReportResourceType() {
100
- return SharedService._resourceTypes.find(rt => rt.Name.trim().toLowerCase() === 'reports');
101
- }
102
- get SearchResultsResourceType() {
103
- return SharedService._resourceTypes.find(rt => rt.Name.trim().toLowerCase() === 'search results');
104
- }
105
- ResourceTypeByID(id) {
106
- return SharedService._resourceTypes.find(rt => rt.ID === id);
107
- }
108
- ResourceTypeByName(name) {
109
- return SharedService._resourceTypes.find(rt => rt.Name.trim().toLowerCase() === name.trim().toLowerCase());
110
- }
111
- static RefreshData() {
112
- return __awaiter(this, void 0, void 0, function* () {
113
- // if we have a provider, then we can load the data, otherwise load isn't done yet
114
- const md = new Metadata();
115
- const rtResult = yield md.GetAndCacheDatasetByName('ResourceTypes');
116
- if (rtResult && rtResult.Success) {
117
- const data = rtResult.Results.find(r => r.EntityName === 'Resource Types');
118
- if (data) {
119
- SharedService._resourceTypes = data.Results;
120
- SharedService._loaded = true;
121
- }
122
- }
123
- SharedService.RefreshUserNotifications(); // also call this initially when refreshing the dataset...
124
- });
125
- }
126
- static GeneratePrimaryKeyValueString(pkVals) {
127
- return pkVals.map(pk => pk.FieldName + '|' + pk.Value).join('||');
128
- }
129
- static ParsePrimaryKeys(entity, routeSegment) {
130
- if (!routeSegment.includes('|')) {
131
- // If not, return a single element array with a default field name
132
- return [{ FieldName: entity.PrimaryKey.Name, Value: routeSegment }];
133
- }
134
- else {
135
- const parts = routeSegment.split('||');
136
- const pkVals = [];
137
- for (let p of parts) {
138
- const kv = p.split('|');
139
- pkVals.push({ FieldName: kv[0], Value: kv[1] });
140
- }
141
- return pkVals;
142
- }
143
- }
144
- FormatColumnValue(col, value, maxLength = 0, trailingChars = "...") {
145
- if (value === null || value === undefined)
146
- return value;
147
- try {
148
- const retVal = col.EntityField.FormatValue(value, 0);
149
- if (maxLength > 0 && retVal && retVal.length > maxLength)
150
- return retVal.substring(0, maxLength) + trailingChars;
151
- else
152
- return retVal;
153
- }
154
- catch (e) {
155
- LogError(e);
156
- return value;
157
- }
158
- }
159
- ConvertMarkdownStringToHtmlList(listType, text) {
160
- const listTag = listType === HtmlListType.Unordered ? 'ul' : 'ol';
161
- if (!text.includes('\n')) {
162
- return text;
163
- }
164
- const listItems = text.split('\n').map(line => `<li>${line.trim().replace(/^-\s*/, '')}</li>`).join('');
165
- return `<${listTag}>${listItems}</${listTag}>`;
166
- }
167
- InvokeManualResize(delay = 50) {
168
- setTimeout(() => {
169
- MJGlobal.Instance.RaiseEvent({
170
- event: MJEventType.ManualResizeRequest,
171
- eventCode: '',
172
- args: null,
173
- component: this
174
- });
175
- }, delay); // give the tabstrip time to render
176
- }
177
- PushStatusUpdates() {
178
- const gp = Metadata.Provider;
179
- return gp.PushStatusUpdates();
180
- }
181
- get CurrentUserImage() {
182
- return this._currentUserImage;
183
- }
184
- set CurrentUserImage(value) {
185
- this._currentUserImage = value;
186
- }
187
- static get UserNotifications() {
188
- return SharedService._userNotifications;
189
- }
190
- static get UnreadUserNotifications() {
191
- return SharedService._userNotifications.filter(n => n.Unread);
192
- }
193
- static get UnreadUserNotificationCount() {
194
- return SharedService.UnreadUserNotifications.length;
195
- }
196
- /**
197
- * Creates a notification in the database and refreshes the UI. Returns the notification object.
198
- * @param title
199
- * @param message
200
- * @param resourceTypeId
201
- * @param resourceRecordId
202
- * @param resourceConfiguration Any object, it is converted to a string by JSON.stringify and stored in the database
203
- * @returns
204
- */
205
- CreateNotification(title, message, resourceTypeId, resourceRecordId, resourceConfiguration) {
206
- return __awaiter(this, void 0, void 0, function* () {
207
- const md = new Metadata();
208
- const notification = yield md.GetEntityObject('User Notifications');
209
- notification.Title = title;
210
- notification.Message = message;
211
- if (resourceTypeId)
212
- notification.ResourceTypeID = resourceTypeId;
213
- if (resourceRecordId)
214
- notification.ResourceRecordID = resourceRecordId;
215
- if (resourceConfiguration)
216
- notification.ResourceConfiguration = JSON.stringify(resourceConfiguration);
217
- notification.UserID = md.CurrentUser.ID;
218
- notification.Unread = true;
219
- const result = yield notification.Save();
220
- if (result) {
221
- SharedService.RefreshUserNotifications();
222
- }
223
- // test
224
- this.CreateSimpleNotification(notification.Message, "success", 2500);
225
- return notification;
226
- });
227
- }
228
- static RefreshUserNotifications() {
229
- return __awaiter(this, void 0, void 0, function* () {
230
- try {
231
- const rv = new RunView();
232
- const md = new Metadata();
233
- const result = yield rv.RunView({
234
- EntityName: 'User Notifications',
235
- ExtraFilter: 'UserID=' + md.CurrentUser.ID,
236
- OrderBy: 'CreatedAt DESC'
237
- });
238
- if (result && result.Success) {
239
- SharedService._userNotifications = result.Results;
240
- }
241
- }
242
- catch (e) {
243
- LogError(e);
244
- }
245
- });
246
- }
247
- /**
248
- * Creates a message that is not saved to the User Notifications table, but is displayed to the user.
249
- * @param message - text to display
250
- * @param style - display styling
251
- * @param hideAfter - option to auto hide after the specified delay in milliseconds
252
- */
253
- CreateSimpleNotification(message, style = "success", hideAfter) {
254
- const props = {
255
- content: message,
256
- cssClass: "button-notification",
257
- animation: { type: "slide", duration: 400 },
258
- position: { horizontal: "center", vertical: "top" },
259
- type: { style: style, icon: true }
260
- };
261
- if (hideAfter)
262
- props.hideAfter = hideAfter;
263
- else
264
- props.closable = true;
265
- this.notificationService.show(props);
266
- }
267
- /**
268
- * Maps a Resource Type record Name column to the corresponding route segment
269
- * @param resourceTypeName
270
- * @returns
271
- */
272
- mapResourceTypeNameToRouteSegment(resourceTypeName) {
273
- const item = this._resourceTypeMap.find(rt => rt.name.trim().toLowerCase() === resourceTypeName.trim().toLowerCase());
274
- if (item)
275
- return item.routeSegment;
276
- else
277
- return null;
278
- }
279
- /**
280
- * Maps a route segment to the corresponding Resource Type record Name column
281
- * @param resourceRouteSegment
282
- * @returns
283
- */
284
- mapResourceTypeRouteSegmentToName(resourceRouteSegment) {
285
- const item = this._resourceTypeMap.find(rt => rt.routeSegment.trim().toLowerCase() === resourceRouteSegment.trim().toLowerCase());
286
- if (item)
287
- return item.name;
288
- else
289
- return null;
290
- }
291
- }
292
- SharedService._loaded = false;
293
- SharedService._resourceTypes = [];
294
- SharedService._userNotifications = [];
295
- SharedService.ɵfac = function SharedService_Factory(t) { return new (t || SharedService)(i0.ɵɵinject(i1.NotificationService)); };
296
- SharedService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SharedService, factory: SharedService.ɵfac, providedIn: 'root' });
297
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SharedService, [{
298
- type: Injectable,
299
- args: [{
300
- providedIn: 'root'
301
- }]
302
- }], function () { return [{ type: i1.NotificationService }]; }, null); })();
303
- export const HtmlListType = {
304
- Unordered: 'Unordered',
305
- Ordered: 'Ordered',
306
- };
307
- export const EventCodes = {
308
- ViewClicked: "ViewClicked",
309
- EntityRecordClicked: "EntityRecordClicked",
310
- AddDashboard: "AddDashboard",
311
- AddReport: "AddReport",
312
- ViewCreated: "ViewCreated",
313
- ViewUpdated: "ViewUpdated",
314
- RunSearch: "RunSearch",
315
- ViewNotifications: "ViewNotifications",
316
- PushStatusUpdates: "PushStatusUpdates",
317
- UserNotificationsUpdated: "UserNotificationsUpdated"
318
- };
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { Injectable } from '@angular/core';
11
+ import { LogError, Metadata, RunView } from '@memberjunction/core';
12
+ import { MJEventType, MJGlobal } from '@memberjunction/global';
13
+ import { Subject } from 'rxjs';
14
+ import { kendoSVGIcon } from '@memberjunction/ng-shared';
15
+ import * as i0 from "@angular/core";
16
+ import * as i1 from "@progress/kendo-angular-notification";
17
+ export class SharedService {
18
+ constructor(notificationService) {
19
+ this.notificationService = notificationService;
20
+ this.tabChange = new Subject();
21
+ this.tabChange$ = this.tabChange.asObservable();
22
+ this._currentUserImage = '/assets/user.png';
23
+ this._resourceTypeMap = [
24
+ { routeSegment: 'record', name: 'records' },
25
+ { routeSegment: 'view', name: 'user views' },
26
+ { routeSegment: 'search', name: 'search results' },
27
+ { routeSegment: 'report', name: 'reports' },
28
+ { routeSegment: 'query', name: 'queries' },
29
+ { routeSegment: 'dashboard', name: 'dashboards' }
30
+ ];
31
+ if (SharedService._instance) {
32
+ // return existing instance which will short circuit the creation of a new instance
33
+ return SharedService._instance;
34
+ }
35
+ // first time this has been called, so return ourselves since we're in the constructor
36
+ SharedService._instance = this;
37
+ MJGlobal.Instance.GetEventListener(true).subscribe((event) => {
38
+ switch (event.event) {
39
+ case MJEventType.DisplaySimpleNotificationRequest:
40
+ // received the message to display a notification to the user, so do that...
41
+ const messageData = event.args;
42
+ this.CreateSimpleNotification(messageData.message, messageData.style, messageData.DisplayDuration);
43
+ break;
44
+ case MJEventType.ComponentEvent:
45
+ if (event.eventCode === EventCodes.UserNotificationsUpdated) {
46
+ // refresh the user notifications
47
+ SharedService.RefreshUserNotifications();
48
+ }
49
+ break;
50
+ case MJEventType.LoggedIn:
51
+ if (SharedService._loaded === false)
52
+ SharedService.RefreshData();
53
+ // got the login, now subscribe to push status updates here so we can then raise them as events in MJ Global locally
54
+ this.PushStatusUpdates().subscribe((status) => {
55
+ var _a, _b;
56
+ const statusObj = JSON.parse(status.message);
57
+ // pass along as an event so anyone else who wants to know about the push status update can do stuff
58
+ MJGlobal.Instance.RaiseEvent({
59
+ event: MJEventType.ComponentEvent,
60
+ eventCode: EventCodes.PushStatusUpdates,
61
+ args: statusObj,
62
+ component: this
63
+ });
64
+ if (((_a = statusObj.type) === null || _a === void 0 ? void 0 : _a.trim().toLowerCase()) === 'usernotifications') {
65
+ if (statusObj.details && ((_b = statusObj.details.action) === null || _b === void 0 ? void 0 : _b.trim().toLowerCase()) === 'create') {
66
+ // we have changes to user notifications, so refresh them
67
+ this.CreateSimpleNotification('New Notification Available', "success", 2000);
68
+ SharedService.RefreshUserNotifications();
69
+ }
70
+ }
71
+ else {
72
+ // otherwise just post it as a simple notification
73
+ this.CreateSimpleNotification(statusObj.message, "success", 2500);
74
+ }
75
+ });
76
+ break;
77
+ }
78
+ });
79
+ }
80
+ static get Instance() {
81
+ return SharedService._instance;
82
+ }
83
+ /**
84
+ * Returns the current session ID, which is automatically created when the service is instantiated.
85
+ */
86
+ get SessionId() {
87
+ return Metadata.Provider.sessionId;
88
+ }
89
+ get ResourceTypes() {
90
+ return SharedService._resourceTypes;
91
+ }
92
+ get ViewResourceType() {
93
+ return SharedService._resourceTypes.find(rt => rt.Name.trim().toLowerCase() === 'user views');
94
+ }
95
+ get RecordResourceType() {
96
+ return SharedService._resourceTypes.find(rt => rt.Name.trim().toLowerCase() === 'records');
97
+ }
98
+ get DashboardResourceType() {
99
+ return SharedService._resourceTypes.find(rt => rt.Name.trim().toLowerCase() === 'dashboards');
100
+ }
101
+ get ReportResourceType() {
102
+ return SharedService._resourceTypes.find(rt => rt.Name.trim().toLowerCase() === 'reports');
103
+ }
104
+ get SearchResultsResourceType() {
105
+ return SharedService._resourceTypes.find(rt => rt.Name.trim().toLowerCase() === 'search results');
106
+ }
107
+ ResourceTypeByID(id) {
108
+ return SharedService._resourceTypes.find(rt => rt.ID === id);
109
+ }
110
+ ResourceTypeByName(name) {
111
+ return SharedService._resourceTypes.find(rt => rt.Name.trim().toLowerCase() === name.trim().toLowerCase());
112
+ }
113
+ static RefreshData() {
114
+ return __awaiter(this, void 0, void 0, function* () {
115
+ // if we have a provider, then we can load the data, otherwise load isn't done yet
116
+ const md = new Metadata();
117
+ const rtResult = yield md.GetAndCacheDatasetByName('ResourceTypes');
118
+ if (rtResult && rtResult.Success) {
119
+ const data = rtResult.Results.find(r => r.EntityName === 'Resource Types');
120
+ if (data) {
121
+ SharedService._resourceTypes = data.Results;
122
+ SharedService._loaded = true;
123
+ }
124
+ }
125
+ SharedService.RefreshUserNotifications(); // also call this initially when refreshing the dataset...
126
+ });
127
+ }
128
+ static GeneratePrimaryKeyValueString(pkVals) {
129
+ return pkVals.map(pk => pk.FieldName + '|' + pk.Value).join('||');
130
+ }
131
+ static ParsePrimaryKeys(entity, routeSegment) {
132
+ if (!routeSegment.includes('|')) {
133
+ // If not, return a single element array with a default field name
134
+ return [{ FieldName: entity.PrimaryKey.Name, Value: routeSegment }];
135
+ }
136
+ else {
137
+ const parts = routeSegment.split('||');
138
+ const pkVals = [];
139
+ for (let p of parts) {
140
+ const kv = p.split('|');
141
+ pkVals.push({ FieldName: kv[0], Value: kv[1] });
142
+ }
143
+ return pkVals;
144
+ }
145
+ }
146
+ FormatColumnValue(col, value, maxLength = 0, trailingChars = "...") {
147
+ if (value === null || value === undefined)
148
+ return value;
149
+ try {
150
+ const retVal = col.EntityField.FormatValue(value, 0);
151
+ if (maxLength > 0 && retVal && retVal.length > maxLength)
152
+ return retVal.substring(0, maxLength) + trailingChars;
153
+ else
154
+ return retVal;
155
+ }
156
+ catch (e) {
157
+ LogError(e);
158
+ return value;
159
+ }
160
+ }
161
+ ConvertMarkdownStringToHtmlList(listType, text) {
162
+ const listTag = listType === HtmlListType.Unordered ? 'ul' : 'ol';
163
+ if (!text.includes('\n')) {
164
+ return text;
165
+ }
166
+ const listItems = text.split('\n').map(line => `<li>${line.trim().replace(/^-\s*/, '')}</li>`).join('');
167
+ return `<${listTag}>${listItems}</${listTag}>`;
168
+ }
169
+ InvokeManualResize(delay = 50) {
170
+ setTimeout(() => {
171
+ MJGlobal.Instance.RaiseEvent({
172
+ event: MJEventType.ManualResizeRequest,
173
+ eventCode: '',
174
+ args: null,
175
+ component: this
176
+ });
177
+ }, delay); // give the tabstrip time to render
178
+ }
179
+ PushStatusUpdates() {
180
+ const gp = Metadata.Provider;
181
+ return gp.PushStatusUpdates();
182
+ }
183
+ get CurrentUserImage() {
184
+ return this._currentUserImage;
185
+ }
186
+ set CurrentUserImage(value) {
187
+ this._currentUserImage = value;
188
+ }
189
+ static get UserNotifications() {
190
+ return SharedService._userNotifications;
191
+ }
192
+ static get UnreadUserNotifications() {
193
+ return SharedService._userNotifications.filter(n => n.Unread);
194
+ }
195
+ static get UnreadUserNotificationCount() {
196
+ return SharedService.UnreadUserNotifications.length;
197
+ }
198
+ /**
199
+ * Creates a notification in the database and refreshes the UI. Returns the notification object.
200
+ * @param title
201
+ * @param message
202
+ * @param resourceTypeId
203
+ * @param resourceRecordId
204
+ * @param resourceConfiguration Any object, it is converted to a string by JSON.stringify and stored in the database
205
+ * @returns
206
+ */
207
+ CreateNotification(title, message, resourceTypeId, resourceRecordId, resourceConfiguration) {
208
+ return __awaiter(this, void 0, void 0, function* () {
209
+ const md = new Metadata();
210
+ const notification = yield md.GetEntityObject('User Notifications');
211
+ notification.Title = title;
212
+ notification.Message = message;
213
+ if (resourceTypeId)
214
+ notification.ResourceTypeID = resourceTypeId;
215
+ if (resourceRecordId)
216
+ notification.ResourceRecordID = resourceRecordId;
217
+ if (resourceConfiguration)
218
+ notification.ResourceConfiguration = JSON.stringify(resourceConfiguration);
219
+ notification.UserID = md.CurrentUser.ID;
220
+ notification.Unread = true;
221
+ const result = yield notification.Save();
222
+ if (result) {
223
+ SharedService.RefreshUserNotifications();
224
+ }
225
+ // test
226
+ this.CreateSimpleNotification(notification.Message, "success", 2500);
227
+ return notification;
228
+ });
229
+ }
230
+ static RefreshUserNotifications() {
231
+ return __awaiter(this, void 0, void 0, function* () {
232
+ try {
233
+ const rv = new RunView();
234
+ const md = new Metadata();
235
+ const result = yield rv.RunView({
236
+ EntityName: 'User Notifications',
237
+ ExtraFilter: 'UserID=' + md.CurrentUser.ID,
238
+ OrderBy: 'CreatedAt DESC'
239
+ });
240
+ if (result && result.Success) {
241
+ SharedService._userNotifications = result.Results;
242
+ }
243
+ }
244
+ catch (e) {
245
+ LogError(e);
246
+ }
247
+ });
248
+ }
249
+ /**
250
+ * Creates a message that is not saved to the User Notifications table, but is displayed to the user.
251
+ * @param message - text to display
252
+ * @param style - display styling
253
+ * @param hideAfter - option to auto hide after the specified delay in milliseconds
254
+ */
255
+ CreateSimpleNotification(message, style = "success", hideAfter) {
256
+ const props = {
257
+ content: message,
258
+ cssClass: "button-notification",
259
+ animation: { type: "slide", duration: 400 },
260
+ position: { horizontal: "center", vertical: "top" },
261
+ type: { style: style, icon: true }
262
+ };
263
+ if (hideAfter)
264
+ props.hideAfter = hideAfter;
265
+ else
266
+ props.closable = true;
267
+ this.notificationService.show(props);
268
+ }
269
+ /**
270
+ * Maps a Resource Type record Name column to the corresponding route segment
271
+ * @param resourceTypeName
272
+ * @returns
273
+ */
274
+ mapResourceTypeNameToRouteSegment(resourceTypeName) {
275
+ const item = this._resourceTypeMap.find(rt => rt.name.trim().toLowerCase() === resourceTypeName.trim().toLowerCase());
276
+ if (item)
277
+ return item.routeSegment;
278
+ else
279
+ return null;
280
+ }
281
+ /**
282
+ * Maps a route segment to the corresponding Resource Type record Name column
283
+ * @param resourceRouteSegment
284
+ * @returns
285
+ */
286
+ mapResourceTypeRouteSegmentToName(resourceRouteSegment) {
287
+ const item = this._resourceTypeMap.find(rt => rt.routeSegment.trim().toLowerCase() === resourceRouteSegment.trim().toLowerCase());
288
+ if (item)
289
+ return item.name;
290
+ else
291
+ return null;
292
+ }
293
+ kendoSVGIcon(iconName) {
294
+ return kendoSVGIcon(iconName);
295
+ }
296
+ }
297
+ SharedService._loaded = false;
298
+ SharedService._resourceTypes = [];
299
+ SharedService._userNotifications = [];
300
+ SharedService.ɵfac = function SharedService_Factory(t) { return new (t || SharedService)(i0.ɵɵinject(i1.NotificationService)); };
301
+ SharedService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SharedService, factory: SharedService.ɵfac, providedIn: 'root' });
302
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SharedService, [{
303
+ type: Injectable,
304
+ args: [{
305
+ providedIn: 'root'
306
+ }]
307
+ }], () => [{ type: i1.NotificationService }], null); })();
308
+ export const HtmlListType = {
309
+ Unordered: 'Unordered',
310
+ Ordered: 'Ordered',
311
+ };
312
+ export const EventCodes = {
313
+ ViewClicked: "ViewClicked",
314
+ EntityRecordClicked: "EntityRecordClicked",
315
+ AddDashboard: "AddDashboard",
316
+ AddReport: "AddReport",
317
+ AddQuery: "AddQuery",
318
+ ViewCreated: "ViewCreated",
319
+ ViewUpdated: "ViewUpdated",
320
+ RunSearch: "RunSearch",
321
+ ViewNotifications: "ViewNotifications",
322
+ PushStatusUpdates: "PushStatusUpdates",
323
+ UserNotificationsUpdated: "UserNotificationsUpdated"
324
+ };