@everymatrix/user-action-controller 1.61.1 → 1.62.1

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.
@@ -1,6 +1,7 @@
1
1
  import { h } from "@stencil/core";
2
2
  import { getTranslations, translate } from "../../utils/locale.utils";
3
3
  import { setClientStyling, setClientStylingURL, setStreamStyling } from "../../../../../../../../libs/common/src/styling/index";
4
+ import { dispatchCustomEvent } from "../../../../../../../../libs/custom-events/src/index";
4
5
  import "../../../../../player-user-consents/dist/types/index";
5
6
  export class UserActionController {
6
7
  constructor() {
@@ -13,11 +14,30 @@ export class UserActionController {
13
14
  emailmarketing: translate('emailMarketingTitle', this.lang),
14
15
  privacypolicy: translate('privacyPolicyTitle', this.lang)
15
16
  };
17
+ this.handleApplyClick = () => {
18
+ this.queryFired = true;
19
+ };
20
+ this.handleReject = () => {
21
+ const headers = new Headers();
22
+ headers.append('Content-type', 'application/json');
23
+ headers.append('X-SessionID', this.userSession);
24
+ const options = {
25
+ method: 'DELETE',
26
+ headers: headers
27
+ };
28
+ fetch(`${this.endpoint}/v1/player/session/player`, options)
29
+ .then(() => {
30
+ window.postMessage({ type: 'LogoutSuccessfull' }, window.location.href);
31
+ dispatchCustomEvent('logged_out', {});
32
+ });
33
+ };
16
34
  this.endpoint = undefined;
17
35
  this.userSession = undefined;
18
36
  this.userId = undefined;
19
37
  this.lang = 'en';
20
38
  this.includeSubmitButton = undefined;
39
+ this.includeRejectButton = undefined;
40
+ this.includeRejectText = undefined;
21
41
  this.gmVersion = '';
22
42
  this.translationUrl = '';
23
43
  this.clientStyling = '';
@@ -73,54 +93,52 @@ export class UserActionController {
73
93
  const url = new URL(`${this.endpoint}/v1/player/${this.userId}/consent`);
74
94
  const headers = new Headers();
75
95
  headers.append('X-SessionId', this.userSession);
76
- let requestOptions = {
96
+ const options = {
77
97
  method: 'GET',
78
98
  headers
79
99
  };
80
- return fetch(url.href, requestOptions)
100
+ fetch(url.href, options)
81
101
  .then(res => res.json())
82
102
  .then(data => {
83
- const actionItems = data.items;
84
- actionItems.forEach(element => {
103
+ data.items.forEach(element => {
85
104
  if (element.status === 'Expired') {
86
105
  this.activeUserActions.push(element.tagCode);
87
106
  }
88
107
  });
89
- this.isLoading = false;
90
108
  })
91
109
  .catch(error => {
92
110
  console.error('Error fetching data:', error);
93
- this.isLoading = false;
94
- }).finally(() => {
111
+ })
112
+ .finally(() => {
95
113
  this.calcMandatoryActions();
96
- window.postMessage({ type: 'UserActionsExists', displayUserActions: this.mandatoryItems > 0 ? true : false }, window.location.href);
114
+ window.postMessage({ type: 'UserActionsExists', displayUserActions: this.mandatoryItems > 0 }, window.location.href);
115
+ this.isLoading = false;
97
116
  });
98
117
  }
99
118
  determineUserActions16() {
100
119
  const url = new URL(`${this.endpoint}/v1/player/${this.userId}/legislation/consents`);
101
120
  const headers = new Headers();
102
121
  headers.append('X-SessionId', this.userSession);
103
- let requestOptions = {
122
+ const options = {
104
123
  method: 'GET',
105
124
  headers
106
125
  };
107
- return fetch(url.href, requestOptions)
126
+ fetch(url.href, options)
108
127
  .then(res => res.json())
109
128
  .then(data => {
110
- const actionItems = data.consents;
111
- actionItems.forEach(element => {
129
+ data.consents.forEach(element => {
112
130
  if (element.status === 2 && element.tagCode !== 'pepconsent') {
113
131
  this.activeUserActions.push(element.tagCode);
114
132
  }
115
133
  });
116
- this.isLoading = false;
117
134
  })
118
135
  .catch(error => {
119
136
  console.error('Error fetching data:', error);
120
- this.isLoading = false;
121
- }).finally(() => {
137
+ })
138
+ .finally(() => {
122
139
  this.calcMandatoryActions();
123
- window.postMessage({ type: 'UserActionsExists', displayUserActions: this.mandatoryItems > 0 ? true : false }, window.location.href);
140
+ window.postMessage({ type: 'UserActionsExists', displayUserActions: this.mandatoryItems > 0 }, window.location.href);
141
+ this.isLoading = false;
124
142
  });
125
143
  }
126
144
  updateUserConsents() {
@@ -130,7 +148,7 @@ export class UserActionController {
130
148
  const body = {
131
149
  consents: this.userActions
132
150
  };
133
- let requestOptions = {
151
+ let options = {
134
152
  method: 'POST',
135
153
  headers: {
136
154
  'Content-Type': 'application/json',
@@ -139,7 +157,7 @@ export class UserActionController {
139
157
  },
140
158
  body: JSON.stringify(body)
141
159
  };
142
- fetch(url.href, requestOptions)
160
+ fetch(url.href, options)
143
161
  .then(res => res.json())
144
162
  .then(() => {
145
163
  window.postMessage({
@@ -164,15 +182,14 @@ export class UserActionController {
164
182
  window.postMessage({ type: 'UserActionsCompleted' }, window.location.href);
165
183
  });
166
184
  }
167
- handleApplyClick() {
168
- this.queryFired = true;
169
- }
170
185
  async componentWillLoad() {
171
- if (this.gmVersion === 'gmcore') {
172
- this.determineUserActionsCore();
173
- }
174
- if (this.gmVersion === 'gm16') {
175
- this.determineUserActions16();
186
+ switch (this.gmVersion) {
187
+ case 'gmcore':
188
+ this.determineUserActionsCore();
189
+ break;
190
+ case 'gm16':
191
+ this.determineUserActions16();
192
+ break;
176
193
  }
177
194
  if (this.translationUrl.length > 2) {
178
195
  await getTranslations(this.translationUrl);
@@ -197,24 +214,16 @@ export class UserActionController {
197
214
  }
198
215
  calcMandatoryActions() {
199
216
  this.mandatoryItems = 0;
200
- this.mandatoryActions.map(action => {
201
- const isPresent = this.activeUserActions.includes(action);
202
- if (isPresent) {
203
- this.mandatoryItems++;
204
- }
205
- });
217
+ this.mandatoryActions.forEach(action => this.activeUserActions.includes(action) && this.mandatoryItems++);
206
218
  }
207
219
  render() {
208
- if (this.mandatoryItems > 0) {
209
- this.userActionsValidated = this.mandatoryActionsChecked === this.mandatoryItems;
210
- return (h("div", { class: "QueryReferenceContainer", ref: el => this.stylingContainer = el }, this.isLoading ? (h("slot", { name: 'spinner' })
211
- &&
212
- h("svg", { class: "spinner", viewBox: "0 0 50 50" }, h("circle", { class: "path", cx: "25", cy: "25", r: "20", fill: "none", "stroke-width": "5" }))) : (h("div", { class: "UserActionController" }, h("h2", { class: "UserConsentNotice" }, translate('userNoticeText', this.lang)), h("div", { class: "PlayerLegislationWrapper" }, this.activeUserActions.map(action => (h("slot", { name: action }, h("player-user-consents", { lang: this.lang, "gm-version": this.gmVersion, "translation-url": this.translationUrl, consentType: action, consentTitle: this.consentTitles[action], queried: this.queryFired, mandatory: this.mandatoryActions.includes(action), "client-styling-url": this.clientStylingUrl, "mb-source": this.mbSource, "client-styling": this.clientStyling }))))), this.includeSubmitButton &&
213
- h("button", { class: "ConsentSubmitButton", disabled: !this.userActionsValidated, onClick: () => this.handleApplyClick() }, translate('submitButtonText', this.lang))))));
214
- }
215
- else {
220
+ if (this.mandatoryItems === 0) {
216
221
  return;
217
222
  }
223
+ this.userActionsValidated = this.mandatoryActionsChecked === this.mandatoryItems;
224
+ return (h("div", { class: "QueryReferenceContainer", ref: el => this.stylingContainer = el }, this.isLoading ? (h("div", null, h("slot", { name: 'spinner' }), h("svg", { class: "spinner", viewBox: "0 0 50 50" }, h("circle", { class: "path", cx: "25", cy: "25", r: "20", fill: "none", "stroke-width": "5" })))) : (h("div", { class: "UserActionController" }, h("h2", { class: "UserConsentNotice" }, translate('userNoticeText', this.lang)), h("div", { class: "PlayerLegislationWrapper" }, this.activeUserActions.map(action => (h("slot", { name: action }, h("player-user-consents", { lang: this.lang, "gm-version": this.gmVersion, "translation-url": this.translationUrl, consentType: action, consentTitle: this.consentTitles[action], queried: this.queryFired, mandatory: this.mandatoryActions.includes(action), "client-styling-url": this.clientStylingUrl, "mb-source": this.mbSource, "client-styling": this.clientStyling }))))), h("div", { class: "ButtonsWrapper" }, this.includeRejectButton &&
225
+ h("button", { class: "ConsentRejectButton", onClick: this.handleReject }, translate('rejectButtonText', this.lang)), this.includeSubmitButton &&
226
+ h("button", { class: "ConsentSubmitButton", disabled: !this.userActionsValidated, onClick: this.handleApplyClick }, translate('submitButtonText', this.lang))), this.includeRejectText && h("p", { class: "RejectText" }, translate('rejectText', this.lang))))));
218
227
  }
219
228
  static get is() { return "user-action-controller"; }
220
229
  static get encapsulation() { return "shadow"; }
@@ -316,6 +325,40 @@ export class UserActionController {
316
325
  "attribute": "include-submit-button",
317
326
  "reflect": true
318
327
  },
328
+ "includeRejectButton": {
329
+ "type": "boolean",
330
+ "mutable": false,
331
+ "complexType": {
332
+ "original": "boolean",
333
+ "resolved": "boolean",
334
+ "references": {}
335
+ },
336
+ "required": true,
337
+ "optional": false,
338
+ "docs": {
339
+ "tags": [],
340
+ "text": "whether or not to include the reject button"
341
+ },
342
+ "attribute": "include-reject-button",
343
+ "reflect": true
344
+ },
345
+ "includeRejectText": {
346
+ "type": "boolean",
347
+ "mutable": false,
348
+ "complexType": {
349
+ "original": "boolean",
350
+ "resolved": "boolean",
351
+ "references": {}
352
+ },
353
+ "required": true,
354
+ "optional": false,
355
+ "docs": {
356
+ "tags": [],
357
+ "text": "whether or not to include the reject desctiption text"
358
+ },
359
+ "attribute": "include-reject-text",
360
+ "reflect": true
361
+ },
319
362
  "gmVersion": {
320
363
  "type": "string",
321
364
  "mutable": false,
@@ -331,7 +374,7 @@ export class UserActionController {
331
374
  "text": "Select GM version"
332
375
  },
333
376
  "attribute": "gm-version",
334
- "reflect": false,
377
+ "reflect": true,
335
378
  "defaultValue": "''"
336
379
  },
337
380
  "translationUrl": {
@@ -6,7 +6,9 @@ const TRANSLATIONS = {
6
6
  emailMarketingTitle: 'Email marketing',
7
7
  privacyPolicyTitle: 'Privacy Policy',
8
8
  userNoticeText: 'Before you can proceed you must consent to the following',
9
- submitButtonText: 'Submit'
9
+ submitButtonText: 'Submit',
10
+ rejectButtonText: 'Reject',
11
+ rejectText: 'Rejecting new consents will result in the inability to continue the login process and you will be logged out.'
10
12
  },
11
13
  'en-us': {
12
14
  termsAndConditionsTitle: 'Terms and Conditions',
@@ -14,7 +16,9 @@ const TRANSLATIONS = {
14
16
  emailMarketingTitle: 'Email marketing',
15
17
  privacyPolicyTitle: 'Privacy Policy',
16
18
  userNoticeText: 'Before you can proceed you must consent to the following',
17
- submitButtonText: 'Submit'
19
+ submitButtonText: 'Submit',
20
+ rejectButtonText: 'Reject',
21
+ rejectText: 'Rejecting new consents will result in the inability to continue the login process and you will be logged out.'
18
22
  },
19
23
  ro: {
20
24
  termsAndConditionsTitle: 'Termeni și Condiții',
@@ -22,7 +26,9 @@ const TRANSLATIONS = {
22
26
  emailMarketingTitle: 'Marketing prin Email',
23
27
  privacyPolicyTitle: 'Politica de Confidențialitate',
24
28
  userNoticeText: 'Înainte de a continua, trebuie să vă dați consimțământul pentru următoarele',
25
- submitButtonText: 'Trimite'
29
+ submitButtonText: 'Trimite',
30
+ rejectButtonText: 'Respinge',
31
+ rejectText: 'Respingerea noilor consimțăminte va duce la imposibilitatea de a continua procesul de autentificare și veți fi deconectat.'
26
32
  },
27
33
  hr: {
28
34
  termsAndConditionsTitle: 'Opći uvjeti i odredbe',
@@ -30,7 +36,9 @@ const TRANSLATIONS = {
30
36
  emailMarketingTitle: 'E-mail makretinški sadržaj',
31
37
  privacyPolicyTitle: 'Politika Privatnosti',
32
38
  userNoticeText: 'Prije nego što možete nastaviti, morate pristati na sljedeće',
33
- submitButtonText: 'Pošalji'
39
+ submitButtonText: 'Pošalji',
40
+ rejectButtonText: 'Odbij',
41
+ rejectText: 'Odbijanje novih pristanka rezultirat će nemogućnošću nastavka procesa prijave i bit ćete odjavljeni.'
34
42
  },
35
43
  fr: {
36
44
  termsAndConditionsTitle: 'Termes et Conditions',
@@ -38,15 +46,19 @@ const TRANSLATIONS = {
38
46
  emailMarketingTitle: 'Marketing par Email',
39
47
  privacyPolicyTitle: 'Politique de Confidentialité',
40
48
  userNoticeText: 'Avant de continuer, vous devez consentir aux éléments suivants',
41
- submitButtonText: 'Soumettre'
49
+ submitButtonText: 'Soumettre',
50
+ rejectButtonText: 'Rejeter',
51
+ rejectText: 'Le rejet des nouveaux consentements entraînera l\'impossibilité de continuer le processus de connexion et vous serez déconnecté.'
42
52
  },
43
53
  cs: {
44
- termsAndConditionsTitle: 'Terms and Conditions',
54
+ termsAndConditionsTitle: 'Podmínky a ujednání',
45
55
  smsTitle: 'SMS marketing',
46
- emailMarketingTitle: 'Email marketing',
47
- privacyPolicyTitle: 'Privacy Policy',
48
- userNoticeText: 'Before you can proceed you must consent to the following',
49
- submitButtonText: 'Submit'
56
+ emailMarketingTitle: 'Emailový marketing',
57
+ privacyPolicyTitle: 'Zásady ochrany osobních údajů',
58
+ userNoticeText: 'Než budete moci pokračovat, musíte souhlasit s následujícím',
59
+ submitButtonText: 'Odeslat',
60
+ rejectButtonText: 'Odmítnout',
61
+ rejectText: 'Odmítnutí nových souhlasů povede k nemožnosti pokračovat v procesu přihlášení a budete odhlášeni.'
50
62
  },
51
63
  de: {
52
64
  termsAndConditionsTitle: 'Allgemeine Geschäftsbedingungen',
@@ -54,7 +66,9 @@ const TRANSLATIONS = {
54
66
  emailMarketingTitle: 'E-Mail-Marketing',
55
67
  privacyPolicyTitle: 'Datenschutzrichtlinie',
56
68
  userNoticeText: 'Bevor Sie fortfahren können, müssen Sie den folgenden Punkten zustimmen',
57
- submitButtonText: 'Absenden'
69
+ submitButtonText: 'Absenden',
70
+ rejectButtonText: 'Ablehnen',
71
+ rejectText: 'Das Ablehnen neuer Zustimmungen führt dazu, dass der Anmeldevorgang nicht fortgesetzt werden kann und Sie abgemeldet werden.'
58
72
  },
59
73
  es: {
60
74
  termsAndConditionsTitle: 'Términos y Condiciones',
@@ -62,7 +76,9 @@ const TRANSLATIONS = {
62
76
  emailMarketingTitle: 'Marketing por Email',
63
77
  privacyPolicyTitle: 'Política de Privacidad',
64
78
  userNoticeText: 'Antes de continuar, debe dar su consentimiento a lo siguiente',
65
- submitButtonText: 'Enviar'
79
+ submitButtonText: 'Enviar',
80
+ rejectButtonText: 'Rechazar',
81
+ rejectText: 'Rechazar nuevos consentimientos resultará en la imposibilidad de continuar el proceso de inicio de sesión y se cerrará la sesión.'
66
82
  },
67
83
  pt: {
68
84
  termsAndConditionsTitle: 'Termos e Condições',
@@ -70,7 +86,9 @@ const TRANSLATIONS = {
70
86
  emailMarketingTitle: 'Marketing por Email',
71
87
  privacyPolicyTitle: 'Política de Privacidade',
72
88
  userNoticeText: 'Antes de continuar, você deve consentir com o seguinte',
73
- submitButtonText: 'Enviar'
89
+ submitButtonText: 'Enviar',
90
+ rejectButtonText: 'Rejeitar',
91
+ rejectText: 'Rejeitar novos consentimentos resultará na impossibilidade de continuar o processo de login e você será desconectado.'
74
92
  },
75
93
  'es-mx': {
76
94
  termsAndConditionsTitle: 'Términos y Condiciones',
@@ -78,7 +96,9 @@ const TRANSLATIONS = {
78
96
  emailMarketingTitle: 'Marketing por Email',
79
97
  privacyPolicyTitle: 'Política de Privacidad',
80
98
  userNoticeText: 'Antes de continuar, debe dar su consentimiento a lo siguiente',
81
- submitButtonText: 'Enviar'
99
+ submitButtonText: 'Enviar',
100
+ rejectButtonText: 'Rechazar',
101
+ rejectText: 'Rechazar nuevos consentimientos resultará en la imposibilidad de continuar el proceso de inicio de sesión y se cerrará la sesión.'
82
102
  },
83
103
  'pt-br': {
84
104
  termsAndConditionsTitle: 'Termos e Condições',
@@ -86,7 +106,9 @@ const TRANSLATIONS = {
86
106
  emailMarketingTitle: 'Marketing por Email',
87
107
  privacyPolicyTitle: 'Política de Privacidade',
88
108
  userNoticeText: 'Antes de continuar, você deve consentir com o seguinte',
89
- submitButtonText: 'Enviar'
109
+ submitButtonText: 'Enviar',
110
+ rejectButtonText: 'Rejeitar',
111
+ rejectText: 'Rejeitar novos consentimentos resultará na impossibilidade de continuar o processo de login e você será desconectado.'
90
112
  }
91
113
  };
92
114
  export const getTranslations = (url) => {
@@ -5,7 +5,7 @@ import { g as globalScripts } from './app-globals-0f993ce5.js';
5
5
  const defineCustomElements = async (win, options) => {
6
6
  if (typeof window === 'undefined') return undefined;
7
7
  await globalScripts();
8
- return bootstrapLazy([["player-user-consents_2",[[1,"user-action-controller",{"endpoint":[513],"userSession":[513,"user-session"],"userId":[513,"user-id"],"lang":[1537],"includeSubmitButton":[516,"include-submit-button"],"gmVersion":[1,"gm-version"],"translationUrl":[513,"translation-url"],"clientStyling":[1537,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"mbSource":[513,"mb-source"],"queryFired":[32],"readyActionsCount":[32],"activeUserActions":[32],"userActionsValidated":[32],"receivedQueryResponses":[32],"isLoading":[32],"mandatoryActionsChecked":[32],"mandatoryItems":[32]},[[0,"userLegislationConsent","userLegislationConsentHandler"]],{"translationUrl":["handleNewTranslations"],"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingUrlChange"],"receivedQueryResponses":["handleQueryResponse"]}],[1,"player-user-consents",{"lang":[1537],"queried":[516],"consentType":[513,"consent-type"],"mandatory":[516],"gmVersion":[1,"gm-version"],"consentTitle":[513,"consent-title"],"clientStyling":[1,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"translationUrl":[513,"translation-url"],"mbSource":[513,"mb-source"],"textContent":[32]},null,{"translationUrl":["handleNewTranslations"],"clientStylingUrl":["handleStylingUrlChange"]}]]]], options);
8
+ return bootstrapLazy([["player-user-consents_2",[[1,"user-action-controller",{"endpoint":[513],"userSession":[513,"user-session"],"userId":[513,"user-id"],"lang":[1537],"includeSubmitButton":[516,"include-submit-button"],"includeRejectButton":[516,"include-reject-button"],"includeRejectText":[516,"include-reject-text"],"gmVersion":[513,"gm-version"],"translationUrl":[513,"translation-url"],"clientStyling":[1537,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"mbSource":[513,"mb-source"],"queryFired":[32],"readyActionsCount":[32],"activeUserActions":[32],"userActionsValidated":[32],"receivedQueryResponses":[32],"isLoading":[32],"mandatoryActionsChecked":[32],"mandatoryItems":[32]},[[0,"userLegislationConsent","userLegislationConsentHandler"]],{"translationUrl":["handleNewTranslations"],"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingUrlChange"],"receivedQueryResponses":["handleQueryResponse"]}],[1,"player-user-consents",{"lang":[1537],"queried":[516],"consentType":[513,"consent-type"],"mandatory":[516],"gmVersion":[1,"gm-version"],"consentTitle":[513,"consent-title"],"clientStyling":[1,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"translationUrl":[513,"translation-url"],"mbSource":[513,"mb-source"],"textContent":[32]},null,{"translationUrl":["handleNewTranslations"],"clientStylingUrl":["handleStylingUrlChange"]}]]]], options);
9
9
  };
10
10
 
11
11
  export { defineCustomElements };