eiam-user-preference 0.0.13

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 (83) hide show
  1. package/LICENSE +22 -0
  2. package/dist/cjs/app-globals-V2Kpy_OQ.js +8 -0
  3. package/dist/cjs/app-globals-V2Kpy_OQ.js.map +1 -0
  4. package/dist/cjs/eiam-user-preference.cjs.entry.js +380 -0
  5. package/dist/cjs/eiam-user-preference.cjs.entry.js.map +1 -0
  6. package/dist/cjs/eiam-user-preference.cjs.js +28 -0
  7. package/dist/cjs/eiam-user-preference.cjs.js.map +1 -0
  8. package/dist/cjs/eiam-user-preference.entry.cjs.js.map +1 -0
  9. package/dist/cjs/index-CpBvGZoy.js +1355 -0
  10. package/dist/cjs/index-CpBvGZoy.js.map +1 -0
  11. package/dist/cjs/index.cjs.js +10 -0
  12. package/dist/cjs/index.cjs.js.map +1 -0
  13. package/dist/cjs/loader.cjs.js +16 -0
  14. package/dist/cjs/loader.cjs.js.map +1 -0
  15. package/dist/cjs/my-component.cjs.entry.js +36 -0
  16. package/dist/cjs/my-component.cjs.entry.js.map +1 -0
  17. package/dist/cjs/my-component.entry.cjs.js.map +1 -0
  18. package/dist/collection/collection-manifest.json +13 -0
  19. package/dist/collection/components/eiam-user-preference/eiam-user-preference.css +34 -0
  20. package/dist/collection/components/eiam-user-preference/eiam-user-preference.js +446 -0
  21. package/dist/collection/components/eiam-user-preference/eiam-user-preference.js.map +1 -0
  22. package/dist/collection/components/my-component/my-component.css +3 -0
  23. package/dist/collection/components/my-component/my-component.js +96 -0
  24. package/dist/collection/components/my-component/my-component.js.map +1 -0
  25. package/dist/collection/index.js +11 -0
  26. package/dist/collection/index.js.map +1 -0
  27. package/dist/collection/utils/utils.js +4 -0
  28. package/dist/collection/utils/utils.js.map +1 -0
  29. package/dist/components/eiam-user-preference.d.ts +11 -0
  30. package/dist/components/eiam-user-preference.js +418 -0
  31. package/dist/components/eiam-user-preference.js.map +1 -0
  32. package/dist/components/index.d.ts +33 -0
  33. package/dist/components/index.js +10 -0
  34. package/dist/components/index.js.map +1 -0
  35. package/dist/components/my-component.d.ts +11 -0
  36. package/dist/components/my-component.js +57 -0
  37. package/dist/components/my-component.js.map +1 -0
  38. package/dist/components/p-CkpXNKI5.js +1150 -0
  39. package/dist/components/p-CkpXNKI5.js.map +1 -0
  40. package/dist/eiam-user-preference/eiam-user-preference.entry.esm.js.map +1 -0
  41. package/dist/eiam-user-preference/eiam-user-preference.esm.js +2 -0
  42. package/dist/eiam-user-preference/eiam-user-preference.esm.js.map +1 -0
  43. package/dist/eiam-user-preference/index.esm.js +2 -0
  44. package/dist/eiam-user-preference/index.esm.js.map +1 -0
  45. package/dist/eiam-user-preference/loader.esm.js.map +1 -0
  46. package/dist/eiam-user-preference/my-component.entry.esm.js.map +1 -0
  47. package/dist/eiam-user-preference/p-92b5e823.entry.js +2 -0
  48. package/dist/eiam-user-preference/p-92b5e823.entry.js.map +1 -0
  49. package/dist/eiam-user-preference/p-Chl3oIcU.js +3 -0
  50. package/dist/eiam-user-preference/p-Chl3oIcU.js.map +1 -0
  51. package/dist/eiam-user-preference/p-DQuL1Twl.js +2 -0
  52. package/dist/eiam-user-preference/p-DQuL1Twl.js.map +1 -0
  53. package/dist/eiam-user-preference/p-d0510b8c.entry.js +2 -0
  54. package/dist/eiam-user-preference/p-d0510b8c.entry.js.map +1 -0
  55. package/dist/esm/app-globals-DQuL1Twl.js +6 -0
  56. package/dist/esm/app-globals-DQuL1Twl.js.map +1 -0
  57. package/dist/esm/eiam-user-preference.entry.js +378 -0
  58. package/dist/esm/eiam-user-preference.entry.js.map +1 -0
  59. package/dist/esm/eiam-user-preference.js +24 -0
  60. package/dist/esm/eiam-user-preference.js.map +1 -0
  61. package/dist/esm/index-Chl3oIcU.js +1347 -0
  62. package/dist/esm/index-Chl3oIcU.js.map +1 -0
  63. package/dist/esm/index.js +8 -0
  64. package/dist/esm/index.js.map +1 -0
  65. package/dist/esm/loader.js +14 -0
  66. package/dist/esm/loader.js.map +1 -0
  67. package/dist/esm/my-component.entry.js +34 -0
  68. package/dist/esm/my-component.entry.js.map +1 -0
  69. package/dist/index.cjs.js +1 -0
  70. package/dist/index.js +1 -0
  71. package/dist/types/components/eiam-user-preference/eiam-user-preference.d.ts +68 -0
  72. package/dist/types/components/my-component/my-component.d.ts +16 -0
  73. package/dist/types/components.d.ts +78 -0
  74. package/dist/types/index.d.ts +11 -0
  75. package/dist/types/stencil-public-runtime.d.ts +1683 -0
  76. package/dist/types/utils/utils.d.ts +1 -0
  77. package/loader/cdn.js +1 -0
  78. package/loader/index.cjs.js +1 -0
  79. package/loader/index.d.ts +24 -0
  80. package/loader/index.es2017.js +1 -0
  81. package/loader/index.js +2 -0
  82. package/package.json +53 -0
  83. package/readme.md +111 -0
@@ -0,0 +1,96 @@
1
+ import { h } from "@stencil/core";
2
+ import { format } from "../../utils/utils";
3
+ export class MyComponent {
4
+ /**
5
+ * The first name
6
+ */
7
+ first;
8
+ /**
9
+ * The middle name
10
+ */
11
+ middle;
12
+ /**
13
+ * The last name
14
+ */
15
+ last;
16
+ getText() {
17
+ return format(this.first, this.middle, this.last);
18
+ }
19
+ render() {
20
+ return h("div", { key: '76b1efbfabf4194a3615ca3c9f0af80d326fed1c' }, "Hello, World! I'm ", this.getText());
21
+ }
22
+ static get is() { return "my-component"; }
23
+ static get encapsulation() { return "shadow"; }
24
+ static get originalStyleUrls() {
25
+ return {
26
+ "$": ["my-component.css"]
27
+ };
28
+ }
29
+ static get styleUrls() {
30
+ return {
31
+ "$": ["my-component.css"]
32
+ };
33
+ }
34
+ static get properties() {
35
+ return {
36
+ "first": {
37
+ "type": "string",
38
+ "attribute": "first",
39
+ "mutable": false,
40
+ "complexType": {
41
+ "original": "string",
42
+ "resolved": "string",
43
+ "references": {}
44
+ },
45
+ "required": false,
46
+ "optional": false,
47
+ "docs": {
48
+ "tags": [],
49
+ "text": "The first name"
50
+ },
51
+ "getter": false,
52
+ "setter": false,
53
+ "reflect": false
54
+ },
55
+ "middle": {
56
+ "type": "string",
57
+ "attribute": "middle",
58
+ "mutable": false,
59
+ "complexType": {
60
+ "original": "string",
61
+ "resolved": "string",
62
+ "references": {}
63
+ },
64
+ "required": false,
65
+ "optional": false,
66
+ "docs": {
67
+ "tags": [],
68
+ "text": "The middle name"
69
+ },
70
+ "getter": false,
71
+ "setter": false,
72
+ "reflect": false
73
+ },
74
+ "last": {
75
+ "type": "string",
76
+ "attribute": "last",
77
+ "mutable": false,
78
+ "complexType": {
79
+ "original": "string",
80
+ "resolved": "string",
81
+ "references": {}
82
+ },
83
+ "required": false,
84
+ "optional": false,
85
+ "docs": {
86
+ "tags": [],
87
+ "text": "The last name"
88
+ },
89
+ "getter": false,
90
+ "setter": false,
91
+ "reflect": false
92
+ }
93
+ };
94
+ }
95
+ }
96
+ //# sourceMappingURL=my-component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"my-component.js","sourceRoot":"","sources":["../../../src/components/my-component/my-component.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAO3C,MAAM,OAAO,WAAW;IACtB;;OAEG;IACK,KAAK,CAAS;IAEtB;;OAEG;IACK,MAAM,CAAS;IAEvB;;OAEG;IACK,IAAI,CAAS;IAEb,OAAO;QACb,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC;IAED,MAAM;QACJ,OAAO;;YAAwB,IAAI,CAAC,OAAO,EAAE,CAAO,CAAC;IACvD,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Prop, h } from '@stencil/core';\nimport { format } from '../../utils/utils';\n\n@Component({\n tag: 'my-component',\n styleUrl: 'my-component.css',\n shadow: true,\n})\nexport class MyComponent {\n /**\n * The first name\n */\n @Prop() first: string;\n\n /**\n * The middle name\n */\n @Prop() middle: string;\n\n /**\n * The last name\n */\n @Prop() last: string;\n\n private getText(): string {\n return format(this.first, this.middle, this.last);\n }\n\n render() {\n return <div>Hello, World! I'm {this.getText()}</div>;\n }\n}\n"]}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @fileoverview entry point for your component library
3
+ *
4
+ * This is the entry point for your component library. Use this file to export utilities,
5
+ * constants or data structure that accompany your components.
6
+ *
7
+ * DO NOT use this file to export your components. Instead, use the recommended approaches
8
+ * to consume components of this package as outlined in the `README.md`.
9
+ */
10
+ export { format } from './utils/utils';
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC","sourcesContent":["/**\n * @fileoverview entry point for your component library\n *\n * This is the entry point for your component library. Use this file to export utilities,\n * constants or data structure that accompany your components.\n *\n * DO NOT use this file to export your components. Instead, use the recommended approaches\n * to consume components of this package as outlined in the `README.md`.\n */\n\nexport { format } from './utils/utils';\nexport type * from './components.d.ts';\n"]}
@@ -0,0 +1,4 @@
1
+ export function format(first, middle, last) {
2
+ return (first || '') + (middle ? ` ${middle}` : '') + (last ? ` ${last}` : '');
3
+ }
4
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils/utils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,MAAM,CAAC,KAAc,EAAE,MAAe,EAAE,IAAa;IACnE,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AACjF,CAAC","sourcesContent":["export function format(first?: string, middle?: string, last?: string): string {\n return (first || '') + (middle ? ` ${middle}` : '') + (last ? ` ${last}` : '');\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../types/components";
2
+
3
+ interface EiamUserPreference extends Components.EiamUserPreference, HTMLElement {}
4
+ export const EiamUserPreference: {
5
+ prototype: EiamUserPreference;
6
+ new (): EiamUserPreference;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;
@@ -0,0 +1,418 @@
1
+ import { p as proxyCustomElement, H, h, a as Host } from './p-CkpXNKI5.js';
2
+
3
+ const eiamUserPreferenceCss = ".kt-quick-panel.kt-quick-panel--on{-webkit-transition:left 0.3s ease, right 0.3s ease;transition:left 0.3s ease, right 0.3s ease;right:0;left:auto}.kt-quick-panel-close{width:25px;height:25px;top:1px;z-index:1002;-webkit-transition:left 0.3s ease, right 0.3s ease;transition:left 0.3s ease, right 0.3s ease;position:fixed;border:0;-webkit-box-shadow:none;box-shadow:none;border-radius:3px;cursor:pointer;outline:none !important;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;left:-25px}";
4
+
5
+ const EiamUserPreference$1 = /*@__PURE__*/ proxyCustomElement(class EiamUserPreference extends H {
6
+ constructor() {
7
+ super();
8
+ this.__registerHost();
9
+ this.__attachShadow();
10
+ }
11
+ get host() { return this; }
12
+ apiUrl = window['config']?.apiUrl || 'http://localhost:5000';
13
+ currentRouteSlug;
14
+ payload = {
15
+ pagination: {
16
+ pageIndex: 0,
17
+ pageSize: 1000,
18
+ },
19
+ search: {
20
+ pageName: '',
21
+ },
22
+ };
23
+ userPreferences = {
24
+ dateFormate: 'dd/MM/yyyy',
25
+ timeFormate: '',
26
+ fontSize: null,
27
+ displayFormat: 4,
28
+ defaultLandingPageId: '',
29
+ pageName: '',
30
+ };
31
+ dateFormates = ['dd/MM/yyyy', 'MM/dd/yyyy', 'yyyy-MM-dd'];
32
+ timeFormats = ['h:mm a'];
33
+ fontSizes = [
34
+ { label: 'Small', value: '14' },
35
+ { label: 'Medium', value: '16' },
36
+ { label: 'Large', value: '18' },
37
+ ];
38
+ displayFormats = [];
39
+ userApplications = [];
40
+ pages = [];
41
+ totalPages = 0;
42
+ isModalOpen = false;
43
+ isPageModalOpen = false; // Controls the visibility of the secondary modal
44
+ selectedPage = { id: null, name: '' }; // To store selected page
45
+ pageParams = {
46
+ pageName: '',
47
+ status: 0,
48
+ pageCategory: 0,
49
+ cultureId: 0,
50
+ cultureCode: '',
51
+ pageNumber: 0,
52
+ pageSize: 10,
53
+ applicationId: 0,
54
+ searchText: '',
55
+ };
56
+ pageId;
57
+ cultureCode;
58
+ applicationId;
59
+ async componentWillLoad() {
60
+ await this.getDisplayFormats();
61
+ await this.getUserPreferences();
62
+ await this.getUserApplications();
63
+ }
64
+ componentDidLoad() {
65
+ if (this.host.shadowRoot) {
66
+ const existingLink = this.host.shadowRoot.querySelector('link[rel="stylesheet"]');
67
+ if (!existingLink) {
68
+ const link = document.createElement('link');
69
+ link.rel = 'stylesheet';
70
+ link.href = 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css';
71
+ this.host.shadowRoot.appendChild(link);
72
+ // console.log('FontAwesome added to shadow DOM');
73
+ }
74
+ else {
75
+ console.log('FontAwesome already added to shadow DOM');
76
+ }
77
+ }
78
+ else {
79
+ console.warn('shadowRoot is null');
80
+ }
81
+ }
82
+ async getDisplayFormats() {
83
+ try {
84
+ const headers = {
85
+ 'Content-Type': 'application/json',
86
+ 'IntegrationPermission': '0f5d983d203189bbffc5f686d01f6680bc6a83718a515fe42639347efc92478e',
87
+ 'CultureCode': this.cultureCode,
88
+ 'Source': '2',
89
+ 'applicationId': this.applicationId,
90
+ };
91
+ const response = await fetch(`${this.apiUrl}/api/UserPreferences/DisplayFormats`, {
92
+ method: 'GET', // Specify GET method
93
+ headers: headers,
94
+ credentials: 'include', // Include credentials (cookies) in the request
95
+ });
96
+ const data = await response.json();
97
+ if (Array.isArray(data.content)) {
98
+ this.displayFormats = data.content;
99
+ }
100
+ else {
101
+ console.error('Invalid response structure:', data);
102
+ }
103
+ }
104
+ catch (error) {
105
+ console.error('Error fetching display formats:', error);
106
+ }
107
+ }
108
+ async getUserPreferences() {
109
+ try {
110
+ const headers = {
111
+ 'Content-Type': 'application/json',
112
+ 'IntegrationPermission': '0f5d983d203189bbffc5f686d01f6680bc6a83718a515fe42639347efc92478e',
113
+ 'CultureCode': this.cultureCode,
114
+ 'Source': '2',
115
+ 'applicationId': this.applicationId,
116
+ };
117
+ const response = await fetch(`${this.apiUrl}/api/UserPreferences/GetUserPreferences`, {
118
+ method: 'GET',
119
+ headers: headers,
120
+ credentials: 'include',
121
+ });
122
+ const data = await response.json();
123
+ if (data && typeof data !== 'string') {
124
+ const fontSizeValue = parseFloat(data.fontSize);
125
+ this.userPreferences = {
126
+ ...this.userPreferences,
127
+ dateFormate: data.dateFormate || 'dd/MM/yyyy',
128
+ timeFormate: data.timeFormate || this.timeFormats[0], // fallback!
129
+ fontSize: !isNaN(fontSizeValue) ? fontSizeValue : this.fontSizes[0]?.value,
130
+ displayFormat: data.displayFormat || 1,
131
+ defaultLandingPageId: data.defaultLandingPageId,
132
+ pageName: data?.defaultLandingPageDetails?.name || '',
133
+ };
134
+ }
135
+ }
136
+ catch (error) {
137
+ console.error('Error fetching user preferences:', error);
138
+ }
139
+ }
140
+ async getUserApplications() {
141
+ try {
142
+ const headers = {
143
+ 'Content-Type': 'application/json',
144
+ 'IntegrationPermission': '0f5d983d203189bbffc5f686d01f6680bc6a83718a515fe42639347efc92478e',
145
+ 'CultureCode': this.cultureCode,
146
+ 'Source': '2',
147
+ 'applicationId': this.applicationId,
148
+ };
149
+ const response = await fetch(`${this.apiUrl}/api/OrganizationApplicationsApi/GetAssigndApplicationForUser`, {
150
+ method: 'GET',
151
+ headers: headers,
152
+ credentials: 'include',
153
+ });
154
+ const data = await response.json();
155
+ if (data && Array.isArray(data.content)) {
156
+ this.userApplications = data.content;
157
+ }
158
+ else {
159
+ console.error('Invalid response structure:', data);
160
+ }
161
+ }
162
+ catch (error) {
163
+ console.error('Error fetching applications:', error);
164
+ }
165
+ }
166
+ changeApplication(application) {
167
+ if (application.applicationId) {
168
+ this.pageParams.applicationId = application.applicationId;
169
+ this.getPagesSApplications();
170
+ }
171
+ }
172
+ async getPagesSApplications() {
173
+ const requestBody = {}; // Create the request body (you can modify based on your needs)
174
+ try {
175
+ const response = await fetch(`${this.apiUrl}/api/Pages/GetPages`, {
176
+ method: 'POST',
177
+ headers: {
178
+ 'Content-Type': 'application/json',
179
+ 'IntegrationPermission': '0f5d983d203189bbffc5f686d01f6680bc6a83718a515fe42639347efc92478e',
180
+ 'CultureCode': this.cultureCode,
181
+ 'Source': '2',
182
+ 'applicationId': this.applicationId,
183
+ },
184
+ credentials: 'include',
185
+ body: JSON.stringify(requestBody),
186
+ });
187
+ if (!response.ok) {
188
+ console.error('Failed to fetch pages');
189
+ return;
190
+ }
191
+ const data = await response.json();
192
+ console.log(data, 'data of all pages ');
193
+ }
194
+ catch (error) {
195
+ console.error('Error fetching pages:', error);
196
+ }
197
+ }
198
+ // async submitPreferences() {
199
+ // const fontSize = this.userPreferences.fontSize ? this.userPreferences.fontSize + 'px' : null;
200
+ // const headers = {
201
+ // 'Content-Type': 'application/json',
202
+ // 'IntegrationPermission': '0f5d983d203189bbffc5f686d01f6680bc6a83718a515fe42639347efc92478e',
203
+ // 'CultureCode': this.cultureCode,
204
+ // 'Source': '2',
205
+ // 'applicationId': this.applicationId,
206
+ // };
207
+ // try {
208
+ // const response = await fetch(`${this.apiUrl}/api/UserPreferences/SaveUserPreferences`, {
209
+ // method: 'POST',
210
+ // headers: headers,
211
+ // body: JSON.stringify({ ...this.userPreferences, fontSize }),
212
+ // credentials: 'include',
213
+ // });
214
+ // if (!response.ok) {
215
+ // console.error('Failed to save preferences:', response.statusText);
216
+ // return;
217
+ // }
218
+ // await this.getUserPreferences();
219
+ // } catch (error) {
220
+ // console.error('Error submitting preferences:', error);
221
+ // }
222
+ // }
223
+ async submitPreferences() {
224
+ const fontSizeValue = parseFloat(this.userPreferences.fontSize);
225
+ const fontSize = !isNaN(fontSizeValue) ? `${fontSizeValue}px` : null;
226
+ const headers = {
227
+ 'Content-Type': 'application/json',
228
+ 'IntegrationPermission': '0f5d983d203189bbffc5f686d01f6680bc6a83718a515fe42639347efc92478e',
229
+ 'CultureCode': this.cultureCode,
230
+ 'Source': '2',
231
+ 'applicationId': this.applicationId,
232
+ };
233
+ try {
234
+ const response = await fetch(`${this.apiUrl}/api/UserPreferences/SaveUserPreferences`, {
235
+ method: 'POST',
236
+ headers,
237
+ body: JSON.stringify({ ...this.userPreferences, fontSize }),
238
+ credentials: 'include',
239
+ });
240
+ if (!response.ok) {
241
+ console.error('Failed to save preferences:', response.statusText);
242
+ return;
243
+ }
244
+ // Fetch updated preferences
245
+ const newPrefs = await this.getUserPreferences();
246
+ if (!newPrefs || typeof newPrefs === 'string')
247
+ return;
248
+ // Apply updated preferences like Angular code
249
+ const { displayFormat, fontSize: newFontSize, dateFormate, timeFormate } = newPrefs;
250
+ if (displayFormat) {
251
+ localStorage.setItem('displayFormat', displayFormat);
252
+ // this.emit('displayFormatUpdated', displayFormat);
253
+ }
254
+ if (newFontSize) {
255
+ document.body.setAttribute('style', `font-size: ${newFontSize} !important`);
256
+ }
257
+ localStorage.setItem('dateFormat', dateFormate || 'dd/MM/yyyy');
258
+ localStorage.setItem('timeFormat', timeFormate || '');
259
+ // this.emit('dateFormatUpdated', dateFormate || 'dd/MM/yyyy');
260
+ // this.emit('timeFormatUpdated', timeFormate || '');
261
+ }
262
+ catch (error) {
263
+ console.error('Error submitting preferences:', error);
264
+ }
265
+ }
266
+ async resetPreferences() {
267
+ try {
268
+ await fetch(`${this.apiUrl}/api/UserPreferences/Delete`, {
269
+ method: 'DELETE',
270
+ credentials: 'include',
271
+ });
272
+ this.userPreferences = {
273
+ dateFormate: 'dd/MM/yyyy',
274
+ timeFormate: '',
275
+ fontSize: '',
276
+ displayFormat: 4,
277
+ defaultLandingPageId: '',
278
+ pageName: '',
279
+ };
280
+ localStorage.removeItem('dateFormat');
281
+ localStorage.removeItem('displayFormat');
282
+ localStorage.removeItem('fontSize');
283
+ location.reload(); // If you want to refresh the UI
284
+ }
285
+ catch (error) {
286
+ console.error('Failed to reset preferences', error);
287
+ }
288
+ }
289
+ toggleModal() {
290
+ this.isModalOpen = !this.isModalOpen;
291
+ }
292
+ togglePageModal() {
293
+ this.isPageModalOpen = !this.isPageModalOpen;
294
+ }
295
+ selectPage(page) {
296
+ this.selectedPage = page;
297
+ this.userPreferences.defaultLandingPageId = page.id; // Update default landing page
298
+ this.togglePageModal(); // Close the page selection modal
299
+ }
300
+ // render() {
301
+ // return (
302
+ // <Host>
303
+ // <div>
304
+ // <i class="fas fa-cogs" onClick={() => this.toggleModal()} style={{ cursor: 'pointer', fontSize: '24px' }}></i>
305
+ // {/* Modal */}
306
+ // {this.isModalOpen && (
307
+ // <div class="modal">
308
+ // <div class="modal-content">
309
+ // <span class="close" onClick={() => this.toggleModal()}>
310
+ // &times;
311
+ // </span>
312
+ // <h2>User Preferences</h2>
313
+ // <div>
314
+ // <label>Date Format</label>
315
+ // <select onInput={e => (this.userPreferences.dateFormate = (e.target as HTMLSelectElement).value)}>
316
+ // {this.dateFormates.map(format => (
317
+ // <option value={format} selected={this.userPreferences.dateFormate === format}>
318
+ // {format}
319
+ // </option>
320
+ // ))}
321
+ // </select>
322
+ // <label>Time Format</label>
323
+ // <select onInput={e => (this.userPreferences.timeFormate = (e.target as HTMLSelectElement).value)}>
324
+ // {this.timeFormats.map(format => (
325
+ // <option value={format} selected={this.userPreferences.timeFormate === format}>
326
+ // {format}
327
+ // </option>
328
+ // ))}
329
+ // </select>
330
+ // <label>Font Size</label>
331
+ // <select onInput={e => (this.userPreferences.fontSize = (e.target as HTMLSelectElement).value)}>
332
+ // {this.fontSizes.map(size => (
333
+ // <option value={size.value} selected={this.userPreferences.fontSize === size.value}>
334
+ // {size.label}
335
+ // </option>
336
+ // ))}
337
+ // </select>
338
+ // <label>User Display Format</label>
339
+ // <select onInput={e => (this.userPreferences.displayFormat = parseInt((e.target as HTMLSelectElement).value))}>
340
+ // {this.displayFormats.map(format => (
341
+ // <option value={format.value} selected={this.userPreferences.displayFormat === format.value}>
342
+ // {format.label}
343
+ // </option>
344
+ // ))}
345
+ // </select>
346
+ // <label>Default Landing Page</label>
347
+ // <select onInput={e => (this.userPreferences.defaultLandingPageId = (e.target as HTMLSelectElement).value)}>
348
+ // {this.pages.map(page => (
349
+ // <option value={page.id} selected={this.userPreferences.defaultLandingPageId === page.id}>
350
+ // {page.name}
351
+ // </option>
352
+ // ))}
353
+ // </select>
354
+ // <button onClick={() => this.submitPreferences()}>Save</button>
355
+ // <button onClick={() => this.resetPreferences()}>Reset</button>
356
+ // </div>
357
+ // </div>
358
+ // </div>
359
+ // )}
360
+ // </div>
361
+ // </Host>
362
+ // );
363
+ // }
364
+ render() {
365
+ return (h(Host, { key: '73268d667553094939f061bcb072bda06c14b214' }, h("div", { key: '9eb1fd24078089437f64a4840f738a1f942452b0' }, h("i", { key: '8ad9ea93263a7695eed25fb3fe33893c22e2a989', class: "fas fa-cogs", onClick: () => this.toggleModal(), style: { cursor: 'pointer', fontSize: '24px' } }), this.isModalOpen && (h("div", { key: '988a1a24b362afc61f0e9398a6c401dacfc42837', class: "kt-quick-panel kt-quick-panel--on" }, h("a", { key: 'd969cf578cab9d74ce3bc9203beab91d7d47f1b2', onClick: () => this.toggleModal(), id: "kt_quick_panel_close_btn", class: "kt-quick-panel__close" }, h("i", { key: 'a575b9ee906bd938bfb324835e56b04f9ce256f1', class: "fas fa-times" })), h("div", { key: 'e35452dc147593b9b10707c8efa15e600d8b38c2', class: "kt-quick-panel__nav" }, h("ul", { key: 'b5eb70a8f79b795e53dd364e6c518f623ea0680c', role: "tablist", class: "nav nav-tabs nav-tabs-line nav-tabs-bold nav-tabs-line-3x nav-tabs-line-brand kt-notification-item-padding-x" }, h("li", { key: '2a4efe276341c924f7c3437643c9aa23f2739ca6', class: "nav-item active" }, h("a", { key: 'a301c57cc56e752b21881037f02abbaf5e721060', "data-toggle": "tab", role: "tab", class: "nav-link active" }, "User Preference")))), h("div", { key: '2a2a0a8df42f12ae43290fa82649492faf118a1a', class: "kt-quick-panel__content" }, h("div", { key: 'df7abede8ff8e7c6219939f32bb097e4126b513c', class: "tab-content" }, h("div", { key: 'aef7806fef44acb6179007e5af991ec1a9ef1148', id: "kt_quick_panel_tab_notifications", role: "tabpanel", class: "tab-pane fade show kt-scroll active ps ps--active-y" }, h("div", { key: 'ceb62ff2e5d97947c7746cc3ba8359a903106261', class: "kt-notification" }, h("div", { key: '345c04d2b76a353e6336d87d6cf7fb0ba831183f', class: "kt-portlet__body" }, h("div", { key: 'e8f3b6eaacea413e7f8fa9a05d7e4a1ecd4f3abf', class: "form-group" }, h("label", { key: '7f4f8b89e8bb8fce52da354579c305edfdbfbd7b' }, "Date Format"), h("select", { key: '802e4604185a71450e19fe0ff80091c11aa607aa', onInput: e => (this.userPreferences.dateFormate = e.target.value) }, this.dateFormates.map(format => (h("option", { value: format, selected: this.userPreferences.dateFormate === format }, format))))), h("div", { key: 'da29120fb40a409f143a212b592455ee0a3e9486', class: "form-group" }, h("label", { key: 'db8adfe511a9647822add835b2e79b35551e8ae8' }, "Time Format"), h("select", { key: 'aa335e039c7509388ae5b0ebb95e38a2dd26dd84', onInput: e => (this.userPreferences.timeFormate = e.target.value) }, this.timeFormats.map(format => (h("option", { value: format, selected: this.userPreferences.timeFormate === format }, format))))), h("div", { key: '95591ac88b995c9a2bc9c7e85dc4d86fabd49111', class: "form-group" }, h("label", { key: 'abcc1107a38ab88df414cb6e0b0f89d30db14edb' }, "Font Size"), h("select", { key: '2500ac6ead59cdfd696fb70de46d80395f09b7ba', onInput: e => (this.userPreferences.fontSize = e.target.value) }, this.fontSizes.map(size => (h("option", { value: size.value, selected: this.userPreferences.fontSize === size.value }, size.label))))), h("div", { key: '8e28e4ea701c85a9df01c6e377ff41e0775d217f', class: "form-group" }, h("label", { key: '63a1fca56a0bdae7c4aa91f97e00e764d130b61d' }, "User Display Format"), h("select", { key: 'd637292ae9df0ad9694119d3ed9eb653aa318350', onInput: e => (this.userPreferences.displayFormat = parseInt(e.target.value)) }, this.displayFormats.map(format => (h("option", { value: format.value, selected: this.userPreferences.displayFormat === format.value }, format.label))))), h("div", { key: 'a05f5a4620222485b3d70e662675f79a344cbfc6', class: "form-group" }, h("label", { key: '163feb5c4c8707d3b5de2e7ece82d725de954814' }, "Default Landing Page"), h("div", { key: 'f45690926ace8996450fc90856d725c49ad87efd', class: "input-group", onClick: () => this.togglePageModal() }, h("div", { key: '96be1b6688f8b8d354662e2978d5d767c2d097b5', class: "input-group-prepend" }, h("span", { key: '71f477fe498f90e3b440fdde31fb17e7ffa6743e', class: "input-group-text" }, h("i", { key: '5491f0b4b917a953590e9d3b40ac04fcf767a357', class: "fas fa-link" }))), h("input", { key: '8ab0f12f72e0a2911a8803c79409de0fdbc9a935', type: "text", class: "form-control", readonly: true, value: this.selectedPage.name || 'Select page', placeholder: "Select page" })))), h("div", { key: 'd031e47045efa5108f70e7d1e97700b348c34654', class: "kt-portlet__foot" }, h("div", { key: 'fc41e360f1331381d73bac4f9bb0c6c89ae3262c', class: "kt-form__actions" }, h("button", { key: 'f6e0948a440fbd83885bd20549ddc2bbddf3219c', class: "btn btn-primary", onClick: () => this.submitPreferences() }, "Save"), h("button", { key: 'db3e6b974e20adb93c7dcca03fa52dfdbea57d82', class: "btn btn-secondary", onClick: () => this.resetPreferences() }, "Reset"))))))))), this.isPageModalOpen && (h("div", { key: '36ed3547d24490064ad098ff6893f64abafa612f', class: "modal-dialog modal-md landing-modal" }, h("div", { key: '425a4cdbe00179fb0628ddd46f1ea8699c52aa8b', class: "modal-content landing-page" }, h("div", { key: '0ea6be6c543941262e28a029990bf3d5a3d65f6b', class: "modal-header" }, h("h4", { key: '36644da5cf638a4c24179cc553ec74db1705315e', class: "modal-title pull-left" }, " Default Landing Page "), h("button", { key: 'e59f82a9c151a80ae4300e432172d767e819ba9a', onClick: () => this.togglePageModal(), type: "button", "aria-label": "Close", class: "close pull-right" }, h("span", { key: '6c36480c025d8c7a9ddbee1ca2c3d8c15b01b917' }, h("i", { key: '22e67e915e5dc2cdee997c48b548710c9038941f', class: "fas fa-times" })))), h("div", { key: '5afc1b174e337ac3656d7f2a268d245acb65a8a2', class: "modal-body" }, h("div", { key: '08b55625de4683aad5c3eeede962029701b7d8c6', class: "row" }, h("div", { key: 'f7eebf3e41024676b42c956addef734e18aa2d05', class: "col-12" }, h("div", { key: '2e4bec9be8c15162b43e202623ebf79367783ff0', class: "row" }, h("div", { key: 'd10ec0ce280235ad7bdad74d65f1158e53966519', class: "form-group" }, h("label", { key: 'c67179f8a27436aeec5a209a4b6a169f31bc367b', htmlFor: "" }, " Default Landing Page "), h("select", { key: 'bf0f2664891f7b581ee60cba7c14296e25f2e218', onInput: e => this.changeApplication(e) }, this.userApplications.map(application => (h("option", { value: application.applicationId }, application.applicationName)))))), h("label", { key: '17fa28c79845986510a0d2a538251673cdde4dc6' }, "Select Page"), h("div", { key: 'ceaf84ad32062d5b3a6c125b77f4b8c37c82ca37', style: { maxHeight: '300px', overflowY: 'auto', overflowX: 'hidden' } }, this.pages.map(page => (h("div", { class: "slug-item", onClick: () => this.selectPage(page) }, h("div", { class: "row" }, h("span", { class: "text-brand", style: { fontWeight: '600', lineHeight: '1' } }, page.name), h("small", { class: {
366
+ 'culture-unpublished': page.pageCultureStatus == 1,
367
+ 'culture-published': page.pageCultureStatus == 2,
368
+ } }, "| ", page.cultureCode)))))), h("div", { key: 'fe6fd591d3f70ed1903b49d927b6efd3006d82cf', class: "d-flex justify-content-center mt-2 pagination-class" }))))))))));
369
+ }
370
+ static get watchers() { return {
371
+ "cultureCode": ["componentWillLoad"],
372
+ "applicationId": ["componentWillLoad"]
373
+ }; }
374
+ static get style() { return eiamUserPreferenceCss; }
375
+ }, [1, "eiam-user-preference", {
376
+ "cultureCode": [1, "culture-code"],
377
+ "applicationId": [1, "application-id"],
378
+ "currentRouteSlug": [32],
379
+ "payload": [32],
380
+ "userPreferences": [32],
381
+ "dateFormates": [32],
382
+ "timeFormats": [32],
383
+ "fontSizes": [32],
384
+ "displayFormats": [32],
385
+ "userApplications": [32],
386
+ "pages": [32],
387
+ "totalPages": [32],
388
+ "isModalOpen": [32],
389
+ "isPageModalOpen": [32],
390
+ "selectedPage": [32],
391
+ "pageParams": [32],
392
+ "pageId": [32]
393
+ }, undefined, {
394
+ "cultureCode": ["componentWillLoad"],
395
+ "applicationId": ["componentWillLoad"]
396
+ }]);
397
+ function defineCustomElement$1() {
398
+ if (typeof customElements === "undefined") {
399
+ return;
400
+ }
401
+ const components = ["eiam-user-preference"];
402
+ components.forEach(tagName => { switch (tagName) {
403
+ case "eiam-user-preference":
404
+ if (!customElements.get(tagName)) {
405
+ customElements.define(tagName, EiamUserPreference$1);
406
+ }
407
+ break;
408
+ } });
409
+ }
410
+ defineCustomElement$1();
411
+
412
+ const EiamUserPreference = EiamUserPreference$1;
413
+ const defineCustomElement = defineCustomElement$1;
414
+
415
+ export { EiamUserPreference, defineCustomElement };
416
+ //# sourceMappingURL=eiam-user-preference.js.map
417
+
418
+ //# sourceMappingURL=eiam-user-preference.js.map