@techextensor/tab-sdk 0.0.3 → 0.0.4
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/esm2022/lib/auth/auth.service.mjs +95 -0
- package/esm2022/lib/enums/ui.enum.mjs +16 -0
- package/esm2022/lib/interfaces/ui.interface.mjs +2 -0
- package/esm2022/lib/tab-sdk.service.mjs +5 -19
- package/esm2022/lib/ui/ui.service.mjs +140 -2
- package/fesm2022/techextensor-tab-sdk.mjs +186 -329
- package/fesm2022/techextensor-tab-sdk.mjs.map +1 -1
- package/lib/auth/auth.service.d.ts +58 -0
- package/lib/enums/ui.enum.d.ts +13 -0
- package/lib/interfaces/ui.interface.d.ts +56 -0
- package/lib/tab-sdk.service.d.ts +3 -9
- package/lib/ui/ui.service.d.ts +80 -0
- package/package.json +2 -2
- package/esm2022/lib/common/utils.service.mjs +0 -163
- package/esm2022/lib/core/auth.service.mjs +0 -48
- package/esm2022/lib/data/data.service.mjs +0 -81
- package/esm2022/lib/ui/form.service.mjs +0 -97
- package/lib/common/utils.service.d.ts +0 -58
- package/lib/core/auth.service.d.ts +0 -28
- package/lib/data/data.service.d.ts +0 -36
- package/lib/ui/form.service.d.ts +0 -56
|
@@ -1,388 +1,256 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { Injectable, inject } from '@angular/core';
|
|
3
|
+
import { AuthService, MetadataHelper } from '@techextensor/tab-core-utility';
|
|
4
|
+
import { firstValueFrom } from 'rxjs';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
var ScreenDisplayMode;
|
|
7
|
+
(function (ScreenDisplayMode) {
|
|
8
|
+
ScreenDisplayMode["Sidebar"] = "sidebar";
|
|
9
|
+
ScreenDisplayMode["Popup"] = "popup";
|
|
10
|
+
ScreenDisplayMode["SameTab"] = "sameTab";
|
|
11
|
+
ScreenDisplayMode["NewTab"] = "newTab";
|
|
12
|
+
ScreenDisplayMode["NavigationInSameTab"] = "navigationInSameTab";
|
|
13
|
+
ScreenDisplayMode["NavigationInNewTab"] = "navigationInNewTab";
|
|
14
|
+
})(ScreenDisplayMode || (ScreenDisplayMode = {}));
|
|
15
|
+
var NotificationType;
|
|
16
|
+
(function (NotificationType) {
|
|
17
|
+
NotificationType["Success"] = "success";
|
|
18
|
+
NotificationType["Warning"] = "warning";
|
|
19
|
+
NotificationType["Error"] = "error";
|
|
20
|
+
})(NotificationType || (NotificationType = {}));
|
|
21
|
+
|
|
22
|
+
class UiService {
|
|
23
|
+
_eventActionService = TabSdk.context?.EventActionService;
|
|
24
|
+
_tabUtilsService = TabSdk.context?.TabUtilsService;
|
|
25
|
+
_confirmationDialogService = TabSdk.context?.ConfirmationDialogService;
|
|
9
26
|
/**
|
|
10
|
-
*
|
|
27
|
+
* Open a screen with the given options. The mode determines how the screen is
|
|
28
|
+
* displayed.
|
|
11
29
|
*
|
|
12
|
-
* @
|
|
13
|
-
* const newRecord = await sdk.data.insert('123456', {
|
|
14
|
-
* name: 'ACME Corp',
|
|
15
|
-
* email: 'contact@acme.com'
|
|
16
|
-
* });
|
|
30
|
+
* @param options The options for opening the screen.
|
|
17
31
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
32
|
+
openScreen(options) {
|
|
33
|
+
const { mode, screenId, reqtokens, submission, title, width, height, customClass } = options;
|
|
34
|
+
switch (mode) {
|
|
35
|
+
case ScreenDisplayMode.Sidebar:
|
|
36
|
+
this.showSidebar({ screenId, reqtokens, submission, title, width, height, customClass });
|
|
37
|
+
break;
|
|
38
|
+
case ScreenDisplayMode.Popup:
|
|
39
|
+
this.showDialog({ screenId, reqtokens, submission, title, width, height, customClass });
|
|
40
|
+
break;
|
|
41
|
+
case ScreenDisplayMode.SameTab:
|
|
42
|
+
case ScreenDisplayMode.NavigationInSameTab:
|
|
43
|
+
this.navigateTo({ screenId, reqtokens });
|
|
44
|
+
break;
|
|
45
|
+
case ScreenDisplayMode.NewTab:
|
|
46
|
+
case ScreenDisplayMode.NavigationInNewTab:
|
|
47
|
+
this.openInNewTab({ screenId, reqtokens });
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
30
50
|
}
|
|
31
51
|
/**
|
|
32
|
-
*
|
|
52
|
+
* Opens a screen in a sidebar.
|
|
33
53
|
*
|
|
34
|
-
* @
|
|
35
|
-
* await sdk.data.update('12345', {
|
|
36
|
-
* Id: '12345',
|
|
37
|
-
* name: 'ACME Corporation',
|
|
38
|
-
* status: 'active'
|
|
39
|
-
* });
|
|
54
|
+
* @param options The options for opening the sidebar.
|
|
40
55
|
*/
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
reject(new Error('Failed to update record'));
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
});
|
|
56
|
+
showSidebar(options) {
|
|
57
|
+
const otherConfiguration = {
|
|
58
|
+
...(options.title && { title: options.title }),
|
|
59
|
+
...(options.width && { width: options.width }),
|
|
60
|
+
...(options.height && { height: options.height }),
|
|
61
|
+
...(options.customClass && { customClass: options.customClass })
|
|
62
|
+
};
|
|
63
|
+
this._eventActionService.openScreen(ScreenDisplayMode.Sidebar, options.screenId, options.reqtokens || undefined, options.submission || undefined, Object.keys(otherConfiguration).length > 0 ? otherConfiguration : undefined);
|
|
53
64
|
}
|
|
54
65
|
/**
|
|
55
|
-
*
|
|
66
|
+
* Opens a screen in a popup dialog.
|
|
56
67
|
*
|
|
57
|
-
* @
|
|
58
|
-
* await sdk.data.delete('12345', {Id: '12345'});
|
|
68
|
+
* @param options The options for opening the dialog.
|
|
59
69
|
*/
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
reject(new Error('Failed to delete record'));
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
});
|
|
70
|
+
showDialog(options) {
|
|
71
|
+
const otherConfiguration = {
|
|
72
|
+
...(options.title && { title: options.title }),
|
|
73
|
+
...(options.width && { width: options.width }),
|
|
74
|
+
...(options.height && { height: options.height }),
|
|
75
|
+
...(options.customClass && { customClass: options.customClass })
|
|
76
|
+
};
|
|
77
|
+
this._eventActionService.openScreen(ScreenDisplayMode.Popup, options.screenId, options.reqtokens || undefined, options.submission || undefined, Object.keys(otherConfiguration).length > 0 ? otherConfiguration : undefined);
|
|
72
78
|
}
|
|
73
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: DataService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
74
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: DataService, providedIn: 'root' });
|
|
75
|
-
}
|
|
76
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: DataService, decorators: [{
|
|
77
|
-
type: Injectable,
|
|
78
|
-
args: [{
|
|
79
|
-
providedIn: 'root'
|
|
80
|
-
}]
|
|
81
|
-
}] });
|
|
82
|
-
|
|
83
|
-
class UiService {
|
|
84
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: UiService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
85
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: UiService, providedIn: 'root' });
|
|
86
|
-
}
|
|
87
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: UiService, decorators: [{
|
|
88
|
-
type: Injectable,
|
|
89
|
-
args: [{
|
|
90
|
-
providedIn: 'root'
|
|
91
|
-
}]
|
|
92
|
-
}] });
|
|
93
|
-
|
|
94
|
-
class FormService {
|
|
95
|
-
_helperFunctionService = TabSdk.context?.HelperFunctionService;
|
|
96
79
|
/**
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
* [
|
|
104
|
-
* {
|
|
105
|
-
* keys: 'documentDetails', // Single key
|
|
106
|
-
* action: (component) => component.hidden = true,
|
|
107
|
-
* type: 'columns' // Optional type filter
|
|
108
|
-
* },
|
|
109
|
-
* {
|
|
110
|
-
* keys: 'documentPreview,documentComments', // Multiple keys as comma-separated string
|
|
111
|
-
* action: (component) => component.hidden = false
|
|
112
|
-
* }
|
|
113
|
-
* ]
|
|
114
|
-
* );
|
|
115
|
-
*/
|
|
116
|
-
processComponents(components, processors) {
|
|
117
|
-
if (!components || !Array.isArray(components) || !processors?.length) {
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
this._helperFunctionService?.eachComponent(components, (component) => {
|
|
121
|
-
processors.forEach(processor => {
|
|
122
|
-
// Split the keys string into an array
|
|
123
|
-
const keyList = processor.keys.split(',').map(k => k.trim());
|
|
124
|
-
// Check if component key is in the list of keys to process
|
|
125
|
-
if (!keyList.includes(component.key))
|
|
126
|
-
return;
|
|
127
|
-
// Check type match if specified
|
|
128
|
-
if (processor.type && component.type !== processor.type)
|
|
129
|
-
return;
|
|
130
|
-
// All criteria matched, execute the action
|
|
131
|
-
processor.action(component);
|
|
132
|
-
});
|
|
133
|
-
});
|
|
80
|
+
* Navigates to a screen within the same tab.
|
|
81
|
+
*
|
|
82
|
+
* @param options - The options for navigation, including screenId and optional reqtokens.
|
|
83
|
+
*/
|
|
84
|
+
navigateTo(options) {
|
|
85
|
+
this._eventActionService.openScreen(ScreenDisplayMode.NavigationInSameTab, options.screenId, options.reqtokens || undefined);
|
|
134
86
|
}
|
|
135
87
|
/**
|
|
136
|
-
*
|
|
88
|
+
* Navigates to a screen in a new tab.
|
|
137
89
|
*
|
|
138
|
-
* @
|
|
139
|
-
* sdk.form.setComponentsVisibility(
|
|
140
|
-
* screenParameters.rendererInstance.form.components,
|
|
141
|
-
* {
|
|
142
|
-
* 'documentDetails': false,
|
|
143
|
-
* 'documentComments': true
|
|
144
|
-
* }
|
|
145
|
-
* );
|
|
90
|
+
* @param options The options for navigation, including screenId and optional reqtokens.
|
|
146
91
|
*/
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
this.processComponents(components, keys.map(key => ({
|
|
150
|
-
keys: key,
|
|
151
|
-
action: (component) => {
|
|
152
|
-
component.hidden = visibilityMap[key];
|
|
153
|
-
}
|
|
154
|
-
})));
|
|
92
|
+
openInNewTab(options) {
|
|
93
|
+
this._eventActionService.openScreen(ScreenDisplayMode.NavigationInNewTab, options.screenId, options.reqtokens || undefined);
|
|
155
94
|
}
|
|
156
95
|
/**
|
|
157
|
-
*
|
|
96
|
+
* Navigates to the specified URL.
|
|
158
97
|
*
|
|
159
|
-
* @
|
|
160
|
-
* const components = sdk.form.findComponentsByKeys(
|
|
161
|
-
* form.components,
|
|
162
|
-
* ['documentDetails', 'documentPreview', 'documentComments']
|
|
163
|
-
* );
|
|
98
|
+
* @param url - The URL to navigate to.
|
|
164
99
|
*/
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
if (!components || !Array.isArray(components) || !keys?.length) {
|
|
168
|
-
return result;
|
|
169
|
-
}
|
|
170
|
-
// Use the existing eachComponent helper
|
|
171
|
-
this._helperFunctionService.eachComponent(components, (component) => {
|
|
172
|
-
if (!options?.type || component.type === options.type) {
|
|
173
|
-
result[component.key] = component;
|
|
174
|
-
}
|
|
175
|
-
}, keys);
|
|
176
|
-
return result;
|
|
100
|
+
navigateToUrl(url) {
|
|
101
|
+
this._tabUtilsService.navigateToUrl({ Url: url });
|
|
177
102
|
}
|
|
178
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: FormService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
179
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: FormService, providedIn: 'root' });
|
|
180
|
-
}
|
|
181
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: FormService, decorators: [{
|
|
182
|
-
type: Injectable,
|
|
183
|
-
args: [{
|
|
184
|
-
providedIn: 'root'
|
|
185
|
-
}]
|
|
186
|
-
}] });
|
|
187
|
-
|
|
188
|
-
class AuthService {
|
|
189
|
-
_sessionStorageService = inject(SessionStorageService);
|
|
190
|
-
_localStorageService = inject(LocalStorageService);
|
|
191
103
|
/**
|
|
192
|
-
*
|
|
104
|
+
* Navigates to a specified subdomain using the provided options.
|
|
193
105
|
*
|
|
194
|
-
* @
|
|
195
|
-
* const appCode = sdk.config.getAppCode();
|
|
106
|
+
* @param options - The options for navigation, including subDomain, appCode, and url.
|
|
196
107
|
*/
|
|
197
|
-
|
|
198
|
-
|
|
108
|
+
navigateToSubdomain(options) {
|
|
109
|
+
this._tabUtilsService.navigateToUrlWithSubdomain(options);
|
|
199
110
|
}
|
|
200
111
|
/**
|
|
201
|
-
*
|
|
112
|
+
* Show a notification to the user.
|
|
202
113
|
*
|
|
203
|
-
* @
|
|
204
|
-
* const userId = sdk.auth.getCurrentUserId();
|
|
114
|
+
* @param options The options for the notification.
|
|
205
115
|
*/
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
return userInfo?.user?.Id ?? '';
|
|
116
|
+
notify(options) {
|
|
117
|
+
this._tabUtilsService.notify(options);
|
|
209
118
|
}
|
|
210
119
|
/**
|
|
211
|
-
*
|
|
120
|
+
* Displays a success notification to the user.
|
|
212
121
|
*
|
|
213
|
-
* @
|
|
214
|
-
* const user = sdk.auth.getCurrentUser();
|
|
122
|
+
* @param options - The options for the notification, including message, title, and configuration.
|
|
215
123
|
*/
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
124
|
+
showSuccess(options) {
|
|
125
|
+
this.notify({ ...options, type: NotificationType.Success });
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Displays a warning notification to the user.
|
|
129
|
+
*
|
|
130
|
+
* @param options - The options for the notification, including message, title, and configuration.
|
|
131
|
+
*/
|
|
132
|
+
showWarning(options) {
|
|
133
|
+
this.notify({ ...options, type: NotificationType.Warning });
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Displays an error notification to the user.
|
|
137
|
+
*
|
|
138
|
+
* @param options - The options for the notification, including message, title, and configuration.
|
|
139
|
+
*/
|
|
140
|
+
showError(options) {
|
|
141
|
+
this.notify({ ...options, type: NotificationType.Error });
|
|
222
142
|
}
|
|
223
|
-
|
|
224
|
-
|
|
143
|
+
/**
|
|
144
|
+
* Displays a confirmation dialog to the user and returns a promise that resolves
|
|
145
|
+
* to a boolean indicating whether the user confirmed the action.
|
|
146
|
+
*
|
|
147
|
+
* @param options - The options for the confirmation dialog, including title, message,
|
|
148
|
+
* confirmText, cancelText, and visibility of buttons.
|
|
149
|
+
* @returns A promise that resolves to true if the user confirms, false otherwise.
|
|
150
|
+
*/
|
|
151
|
+
confirm(options) {
|
|
152
|
+
return new Promise((resolve) => {
|
|
153
|
+
this._confirmationDialogService.confirm(options)
|
|
154
|
+
?.subscribe((isConfirmed) => {
|
|
155
|
+
resolve(isConfirmed);
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: UiService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
160
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: UiService, providedIn: 'root' });
|
|
225
161
|
}
|
|
226
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type:
|
|
162
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: UiService, decorators: [{
|
|
227
163
|
type: Injectable,
|
|
228
164
|
args: [{
|
|
229
165
|
providedIn: 'root'
|
|
230
166
|
}]
|
|
231
167
|
}] });
|
|
232
168
|
|
|
233
|
-
class
|
|
169
|
+
class AuthUtilService {
|
|
234
170
|
_authService = inject(AuthService);
|
|
235
|
-
_helperFunctionService = TabSdk.context?.HelperFunctionService;
|
|
236
171
|
/**
|
|
237
|
-
*
|
|
172
|
+
* Authenticates a user based on the provided login credentials.
|
|
238
173
|
*
|
|
239
|
-
* @
|
|
240
|
-
*
|
|
241
|
-
* if (eventName === 'deleteDocument') {
|
|
242
|
-
* // Handle delete document event
|
|
243
|
-
* }
|
|
174
|
+
* @param credentials The login credentials.
|
|
175
|
+
* @returns The response from the server.
|
|
244
176
|
*/
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
return event.event?.component?.configuration?.configScreen?.componentValue?.eventName ??
|
|
250
|
-
event.detail?.type ??
|
|
251
|
-
event.type ??
|
|
252
|
-
event.name ??
|
|
253
|
-
'';
|
|
177
|
+
async login(credentials) {
|
|
178
|
+
// Use the firstValueFrom RxJs operator to wait for the observable to complete
|
|
179
|
+
const response = await firstValueFrom(this._authService.signIn(credentials));
|
|
180
|
+
return response;
|
|
254
181
|
}
|
|
255
182
|
/**
|
|
256
|
-
*
|
|
183
|
+
* Registers a new tenant based on the provided details.
|
|
257
184
|
*
|
|
258
|
-
* @
|
|
259
|
-
*
|
|
260
|
-
* const fullUrl = sdk.utils.buildAppUrl('screen/12345', { id: '12345' });
|
|
185
|
+
* @param tenantDetails The tenant details.
|
|
186
|
+
* @returns The response from the server.
|
|
261
187
|
*/
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
const
|
|
265
|
-
|
|
266
|
-
if (parameters) {
|
|
267
|
-
Object.entries(parameters).forEach(([key, value]) => {
|
|
268
|
-
if (value !== undefined && value !== null) {
|
|
269
|
-
params.append(key, String(value));
|
|
270
|
-
}
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
// Build query string
|
|
274
|
-
const queryString = params.toString() ? `?${params.toString()}` : '';
|
|
275
|
-
// Build URL
|
|
276
|
-
if (includeProtocol) {
|
|
277
|
-
const host = window.location.host;
|
|
278
|
-
return `http://${host}/${appCode}/${path}${queryString}`;
|
|
279
|
-
}
|
|
280
|
-
else {
|
|
281
|
-
return `/${appCode}/${path}${queryString}`;
|
|
282
|
-
}
|
|
188
|
+
async registerTenant(tenantDetails) {
|
|
189
|
+
// Use the firstValueFrom RxJs operator to wait for the observable to complete
|
|
190
|
+
const response = await firstValueFrom(this._authService.registerTenant(tenantDetails));
|
|
191
|
+
return response;
|
|
283
192
|
}
|
|
284
193
|
/**
|
|
285
|
-
*
|
|
194
|
+
* Registers a new user based on the provided user details.
|
|
286
195
|
*
|
|
287
|
-
* @
|
|
288
|
-
*
|
|
289
|
-
*
|
|
196
|
+
* @param userDetails The user details.
|
|
197
|
+
* @param headers Optional headers to pass to the server.
|
|
198
|
+
* @returns The response from the server.
|
|
290
199
|
*/
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
200
|
+
async registerUser(userDetails, headers) {
|
|
201
|
+
// Use the firstValueFrom RxJs operator to wait for the observable to complete
|
|
202
|
+
const response = await firstValueFrom(this._authService.register(userDetails, headers));
|
|
203
|
+
return response;
|
|
294
204
|
}
|
|
295
205
|
/**
|
|
296
|
-
*
|
|
206
|
+
* Resets a user's password based on the provided reset password credentials.
|
|
297
207
|
*
|
|
298
|
-
* @
|
|
299
|
-
*
|
|
300
|
-
* const pdfBlob = new Blob([pdfContent], { type: 'application/pdf' });
|
|
301
|
-
* sdk.utils.downloadBlob(pdfBlob, 'report.pdf');
|
|
208
|
+
* @param credentials The reset password credentials.
|
|
209
|
+
* @returns The response from the server.
|
|
302
210
|
*/
|
|
303
|
-
|
|
304
|
-
//
|
|
305
|
-
const
|
|
306
|
-
|
|
307
|
-
const downloadLink = document.createElement('a');
|
|
308
|
-
downloadLink.href = url;
|
|
309
|
-
downloadLink.download = filename;
|
|
310
|
-
// Append to body, click, and remove
|
|
311
|
-
document.body.appendChild(downloadLink);
|
|
312
|
-
downloadLink.click();
|
|
313
|
-
document.body.removeChild(downloadLink);
|
|
314
|
-
// Release object URL after a short delay to ensure download starts
|
|
315
|
-
setTimeout(() => URL.revokeObjectURL(url), 100);
|
|
211
|
+
async resetPassword(credentials) {
|
|
212
|
+
// Use the firstValueFrom RxJs operator to wait for the observable to complete
|
|
213
|
+
const response = await firstValueFrom(this._authService.resetPassword(credentials));
|
|
214
|
+
return response;
|
|
316
215
|
}
|
|
317
216
|
/**
|
|
318
|
-
*
|
|
217
|
+
* Changes a user's password based on the provided credentials.
|
|
319
218
|
*
|
|
320
|
-
* @
|
|
321
|
-
*
|
|
322
|
-
* sdk.utils.exportAsWord(editorContent, 'report');
|
|
219
|
+
* @param credentials The credentials containing the user's current and new password.
|
|
220
|
+
* @returns The response from the server.
|
|
323
221
|
*/
|
|
324
|
-
|
|
325
|
-
//
|
|
326
|
-
const
|
|
327
|
-
|
|
328
|
-
xmlns:w="urn:schemas-microsoft-com:office:word"
|
|
329
|
-
xmlns="http://www.w3.org/TR/REC-html40">
|
|
330
|
-
<head>
|
|
331
|
-
<meta charset="utf-8">
|
|
332
|
-
<title>${filename}</title>
|
|
333
|
-
</head>
|
|
334
|
-
<body>${content}</body>
|
|
335
|
-
</html>`;
|
|
336
|
-
// Create blob with BOM for Word compatibility
|
|
337
|
-
const blob = new Blob(['\ufeff', docContent], {
|
|
338
|
-
type: 'application/msword'
|
|
339
|
-
});
|
|
340
|
-
// Use the downloadBlob utility
|
|
341
|
-
this.downloadBlob(blob, `${filename}.doc`);
|
|
222
|
+
async changePassword(credentials) {
|
|
223
|
+
// Use the firstValueFrom RxJs operator to wait for the observable to complete
|
|
224
|
+
const response = await firstValueFrom(this._authService.changePassword(credentials));
|
|
225
|
+
return response;
|
|
342
226
|
}
|
|
343
227
|
/**
|
|
344
|
-
*
|
|
228
|
+
* Refreshes a user's token based on the provided refresh token details.
|
|
345
229
|
*
|
|
346
|
-
* @
|
|
347
|
-
*
|
|
348
|
-
* sdk.utils.exportAsPdf(documentContent, 'Invoice');
|
|
230
|
+
* @param tokenDetails The refresh token details.
|
|
231
|
+
* @returns The response from the server.
|
|
349
232
|
*/
|
|
350
|
-
|
|
351
|
-
//
|
|
352
|
-
const
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
${content}
|
|
367
|
-
</body>
|
|
368
|
-
</html>
|
|
369
|
-
`);
|
|
370
|
-
// Prepare for printing
|
|
371
|
-
printWindow.document.close();
|
|
372
|
-
printWindow.focus();
|
|
373
|
-
// Use timeout to ensure content is rendered before printing
|
|
374
|
-
setTimeout(() => {
|
|
375
|
-
printWindow.print();
|
|
376
|
-
// Close window after print dialog is closed or printing is complete
|
|
377
|
-
printWindow.addEventListener('afterprint', () => {
|
|
378
|
-
printWindow.close();
|
|
379
|
-
});
|
|
380
|
-
}, 300);
|
|
233
|
+
async refreshToken(tokenDetails) {
|
|
234
|
+
// Use the firstValueFrom RxJs operator to wait for the observable to complete
|
|
235
|
+
const response = await firstValueFrom(this._authService.refreshToken(tokenDetails));
|
|
236
|
+
return response;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Gets the user details for the provided user details request.
|
|
240
|
+
*
|
|
241
|
+
* @param userDetailsRequest The user details request.
|
|
242
|
+
* @param headers Optional headers to pass to the server.
|
|
243
|
+
* @returns The response from the server.
|
|
244
|
+
*/
|
|
245
|
+
async getUserDetails(userDetailsRequest, headers) {
|
|
246
|
+
// Use the firstValueFrom RxJs operator to wait for the observable to complete
|
|
247
|
+
const response = await firstValueFrom(this._authService.getUserDetails(userDetailsRequest, headers));
|
|
248
|
+
return response;
|
|
381
249
|
}
|
|
382
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type:
|
|
383
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type:
|
|
250
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: AuthUtilService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
251
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: AuthUtilService, providedIn: 'root' });
|
|
384
252
|
}
|
|
385
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type:
|
|
253
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: AuthUtilService, decorators: [{
|
|
386
254
|
type: Injectable,
|
|
387
255
|
args: [{
|
|
388
256
|
providedIn: 'root'
|
|
@@ -390,11 +258,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
|
|
|
390
258
|
}] });
|
|
391
259
|
|
|
392
260
|
class TabSdk {
|
|
393
|
-
static data;
|
|
394
|
-
static ui;
|
|
395
|
-
static form;
|
|
396
261
|
static auth;
|
|
397
|
-
static
|
|
262
|
+
static ui;
|
|
398
263
|
static metadataUtils;
|
|
399
264
|
static context;
|
|
400
265
|
/**
|
|
@@ -406,20 +271,12 @@ class TabSdk {
|
|
|
406
271
|
// external services
|
|
407
272
|
this.context = context;
|
|
408
273
|
// Initialize services
|
|
409
|
-
this.
|
|
274
|
+
this.auth = injector.get(AuthUtilService);
|
|
410
275
|
this.ui = injector.get(UiService);
|
|
411
|
-
this.form = injector.get(FormService);
|
|
412
|
-
this.auth = injector.get(AuthService);
|
|
413
|
-
this.utils = injector.get(UtilsService);
|
|
414
276
|
this.metadataUtils = injector.get(MetadataHelper);
|
|
415
277
|
// Freeze the global object to prevent modifications
|
|
416
278
|
Object.freeze(this);
|
|
417
279
|
Object.freeze(this.context);
|
|
418
|
-
Object.freeze(this.data);
|
|
419
|
-
Object.freeze(this.ui);
|
|
420
|
-
Object.freeze(this.form);
|
|
421
|
-
Object.freeze(this.auth);
|
|
422
|
-
Object.freeze(this.utils);
|
|
423
280
|
}
|
|
424
281
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TabSdk, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
425
282
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TabSdk, providedIn: 'root' });
|