@ezeep/ezeep-js 1.0.150 → 1.0.156

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 (55) hide show
  1. package/dist/cjs/ezeep.cjs.js +3 -3
  2. package/dist/cjs/ezp-auth_14.cjs.entry.js +118 -67
  3. package/dist/cjs/{index-62fc857c.js → index-d547be4e.js} +23 -0
  4. package/dist/cjs/loader.cjs.js +3 -3
  5. package/dist/collection/collection-manifest.json +2 -2
  6. package/dist/collection/components/ezp-auth/ezp-auth.js +1 -3
  7. package/dist/collection/components/ezp-dialog/ezp-dialog.js +0 -2
  8. package/dist/collection/components/ezp-printer-selection/ezp-printer-selection.js +87 -52
  9. package/dist/collection/components/ezp-printing/ezp-printing.js +24 -3
  10. package/dist/collection/components/ezp-status/ezp-status.js +0 -2
  11. package/dist/collection/components/ezp-upload/ezp-upload.js +0 -2
  12. package/dist/collection/components/ezp-user-menu/ezp-user-menu.js +0 -2
  13. package/dist/collection/services/auth.js +2 -0
  14. package/dist/collection/utils/utils.js +20 -8
  15. package/dist/custom-elements/index.js +119 -68
  16. package/dist/directives/proxies.ts +2 -2
  17. package/dist/esm/ezeep.js +3 -3
  18. package/dist/esm/ezp-auth_14.entry.js +118 -67
  19. package/dist/esm/{index-265d8cca.js → index-485041ac.js} +23 -0
  20. package/dist/esm/loader.js +3 -3
  21. package/dist/esm/polyfills/css-shim.js +1 -1
  22. package/dist/esm-es5/ezeep.js +1 -1
  23. package/dist/esm-es5/ezp-auth_14.entry.js +3 -3
  24. package/dist/esm-es5/index-485041ac.js +1 -0
  25. package/dist/esm-es5/loader.js +1 -1
  26. package/dist/ezeep/ezeep.esm.js +1 -1
  27. package/dist/ezeep/ezeep.js +1 -1
  28. package/dist/ezeep/p-0b51d725.system.entry.js +21 -0
  29. package/dist/ezeep/{p-a7b7b386.entry.js → p-b6ec69dc.entry.js} +2 -2
  30. package/dist/ezeep/p-cc2bb341.system.js +1 -0
  31. package/dist/ezeep/p-d4dae139.system.js +1 -0
  32. package/dist/ezeep/{p-f3065800.js → p-fa808a39.js} +0 -0
  33. package/dist/types/components/ezp-printer-selection/ezp-printer-selection.d.ts +1 -1
  34. package/dist/types/components/ezp-printing/ezp-printing.d.ts +1 -0
  35. package/dist/types/components.d.ts +2 -0
  36. package/dist/types/stencil-public-runtime.d.ts +6 -4
  37. package/dist/types/utils/utils.d.ts +1 -1
  38. package/package.json +2 -2
  39. package/readme.md +3 -1
  40. package/www/build/ezeep.esm.js +1 -1
  41. package/www/build/ezeep.js +1 -1
  42. package/www/build/p-0b51d725.system.entry.js +21 -0
  43. package/www/build/{p-a7b7b386.entry.js → p-b6ec69dc.entry.js} +2 -2
  44. package/www/build/p-cc2bb341.system.js +1 -0
  45. package/www/build/p-d4dae139.system.js +1 -0
  46. package/www/build/{p-f3065800.js → p-fa808a39.js} +0 -0
  47. package/www/data/locales/en.json +6 -1
  48. package/www/index.html +1 -1
  49. package/dist/esm-es5/index-265d8cca.js +0 -1
  50. package/dist/ezeep/p-98ec6965.system.js +0 -1
  51. package/dist/ezeep/p-a1b0d17a.system.entry.js +0 -21
  52. package/dist/ezeep/p-f89804ee.system.js +0 -1
  53. package/www/build/p-98ec6965.system.js +0 -1
  54. package/www/build/p-a1b0d17a.system.entry.js +0 -21
  55. package/www/build/p-f89804ee.system.js +0 -1
@@ -3,7 +3,7 @@ import i18next from 'i18next';
3
3
  import authStore from '../../services/auth';
4
4
  import printStore, { EzpPrintService } from '../../services/print';
5
5
  import userStore, { EzpUserService } from '../../services/user';
6
- import { initi18n, poll, removeEmptyStrings } from '../../utils/utils';
6
+ import { poll, removeEmptyStrings } from '../../utils/utils';
7
7
  import options from '../../data/options.json';
8
8
  export class EzpPrinterSelection {
9
9
  constructor() {
@@ -12,15 +12,15 @@ export class EzpPrinterSelection {
12
12
  this.duplexOptions = [
13
13
  {
14
14
  id: 1,
15
- title: 'None',
15
+ title: i18next.t('printer_selection.duplex_none'),
16
16
  },
17
17
  {
18
18
  id: 2,
19
- title: 'Long edge binding',
19
+ title: i18next.t('printer_selection.duplex_long'),
20
20
  },
21
21
  {
22
22
  id: 3,
23
- title: 'Short edge binding',
23
+ title: i18next.t('printer_selection.duplex_short'),
24
24
  },
25
25
  ];
26
26
  this.hidemenu = false;
@@ -58,16 +58,6 @@ export class EzpPrinterSelection {
58
58
  copies: '',
59
59
  resolution: '',
60
60
  };
61
- this.previouslySelectedProperties = {
62
- paper: '',
63
- paperid: '',
64
- color: false,
65
- duplex: false,
66
- duplexmode: '',
67
- orientation: '',
68
- copies: '',
69
- resolution: '',
70
- };
71
61
  /**
72
62
  *
73
63
  * Private methods
@@ -112,6 +102,10 @@ export class EzpPrinterSelection {
112
102
  }
113
103
  })
114
104
  .then((data) => {
105
+ if (data.code === 804) {
106
+ this.printFailed = true;
107
+ this.printProcessing = false;
108
+ }
115
109
  if (data.jobid) {
116
110
  printStore.state.jobID = data.jobid;
117
111
  poll({
@@ -121,15 +115,19 @@ export class EzpPrinterSelection {
121
115
  maxAttempts: 10,
122
116
  }).catch((err) => {
123
117
  console.warn(err);
118
+ this.printFailed = true;
119
+ this.printProcessing = false;
124
120
  });
125
121
  }
126
122
  else {
127
123
  this.printFailed = true;
124
+ this.printProcessing = false;
128
125
  }
129
126
  })
130
127
  .catch((error) => {
131
128
  console.log(error);
132
129
  this.printFailed = true;
130
+ this.printProcessing = false;
133
131
  });
134
132
  }
135
133
  if (this.file) {
@@ -137,7 +135,6 @@ export class EzpPrinterSelection {
137
135
  }
138
136
  localStorage.setItem('properties', JSON.stringify(this.selectedProperties));
139
137
  localStorage.setItem('printer', JSON.stringify(this.selectedPrinter));
140
- localStorage.setItem('previouslySelectedProperties', JSON.stringify(this.previouslySelectedProperties));
141
138
  this.printStopped = false;
142
139
  };
143
140
  this.handleUserMenu = () => {
@@ -209,9 +206,6 @@ export class EzpPrinterSelection {
209
206
  else {
210
207
  this.selectedPrinter = { id: '', location: '', name: '' };
211
208
  }
212
- if (localStorage.getItem('previouslySelectedProperties')) {
213
- this.previouslySelectedProperties = JSON.parse(localStorage.getItem('previouslySelectedProperties'));
214
- }
215
209
  }
216
210
  getUserInfo() {
217
211
  const userService = new EzpUserService();
@@ -228,24 +222,20 @@ export class EzpPrinterSelection {
228
222
  await this.printService
229
223
  .getPrinterProperties(authStore.state.accessToken, this.selectedPrinter.id)
230
224
  .then((data) => (this.selectedPrinterConfig = data[0]));
225
+ this.setDefaultPaperFormat();
231
226
  break;
232
227
  case 'color':
233
228
  this.selectedProperties.color = !!eventDetails.id;
234
- this.previouslySelectedProperties.color = eventDetails.title;
235
229
  break;
236
230
  case 'orientation':
237
231
  this.selectedProperties.orientation = eventDetails.id;
238
- this.previouslySelectedProperties.orientation = eventDetails.title;
239
232
  break;
240
233
  case 'format':
241
234
  this.selectedProperties.paper = eventDetails.title;
242
235
  this.selectedProperties.paperid = eventDetails.id;
243
- this.previouslySelectedProperties.paper = eventDetails.title;
244
- this.previouslySelectedProperties.paperid = eventDetails.id;
245
236
  break;
246
237
  case 'quality':
247
238
  this.selectedProperties.resolution = eventDetails.title;
248
- this.previouslySelectedProperties.resolution = eventDetails.title;
249
239
  break;
250
240
  case 'duplex':
251
241
  if (eventDetails.title === 'None') {
@@ -255,7 +245,6 @@ export class EzpPrinterSelection {
255
245
  this.selectedProperties.duplex = true;
256
246
  }
257
247
  this.selectedProperties.duplexmode = eventDetails.id;
258
- this.previouslySelectedProperties.duplexmode = eventDetails.id;
259
248
  break;
260
249
  default:
261
250
  break;
@@ -282,6 +271,10 @@ export class EzpPrinterSelection {
282
271
  this.printService
283
272
  .printByFileID(authStore.state.accessToken, this.fileid, this.filetype, this.selectedPrinter.id, this.selectedProperties, this.filename)
284
273
  .then((data) => {
274
+ if (data.code === 804) {
275
+ this.printFailed = true;
276
+ this.printProcessing = false;
277
+ }
285
278
  if (data.jobid) {
286
279
  printStore.state.jobID = data.jobid;
287
280
  poll({
@@ -292,20 +285,39 @@ export class EzpPrinterSelection {
292
285
  }).catch((err) => {
293
286
  console.log(err);
294
287
  this.printFailed = true;
288
+ this.printProcessing = false;
295
289
  });
296
290
  }
297
291
  else {
298
292
  this.printFailed = true;
293
+ this.printProcessing = false;
299
294
  }
300
295
  })
301
296
  .catch((error) => {
302
297
  console.log(error);
303
298
  this.printFailed = true;
299
+ this.printProcessing = false;
304
300
  });
305
301
  }
306
302
  else {
307
303
  this.printFailed = true;
304
+ this.printProcessing = false;
305
+ }
306
+ }
307
+ setDefaultPaperFormat() {
308
+ let format;
309
+ const language = navigator.language;
310
+ if (language === 'en-US') {
311
+ format = 'Letter';
312
+ }
313
+ else if (language === 'my') {
314
+ format = 'Letter';
308
315
  }
316
+ else {
317
+ format = 'A4';
318
+ }
319
+ this.selectedProperties.paper = this.selectedPrinterConfig.PaperFormats.find((el) => el.Name === format).Name;
320
+ this.selectedProperties.paperid = this.selectedPrinterConfig.PaperFormats.find((el) => el.Name === format).Id;
309
321
  }
310
322
  /**
311
323
  *
@@ -314,11 +326,19 @@ export class EzpPrinterSelection {
314
326
  */
315
327
  /** Description... */
316
328
  async componentWillLoad() {
317
- initi18n();
318
329
  this.loading = true;
319
330
  this.getPropertiesFromLocalStorage();
320
331
  this.getUserInfo();
321
332
  this.printService = new EzpPrintService(this.redirectURI, this.clientID);
333
+ // if printer is stored from previous print, get the config to enable property selection
334
+ if (this.selectedPrinter.id != '') {
335
+ await this.printService
336
+ .getPrinterProperties(authStore.state.accessToken, this.selectedPrinter.id)
337
+ .then((data) => (this.selectedPrinterConfig = data[0]));
338
+ if (this.selectedProperties.paper === '') {
339
+ this.setDefaultPaperFormat();
340
+ }
341
+ }
322
342
  await (await this.printService.getConfig(authStore.state.accessToken))
323
343
  .json()
324
344
  .then((response) => {
@@ -372,7 +392,9 @@ export class EzpPrinterSelection {
372
392
  ? printer.location
373
393
  : i18next.t('printer_selection.unknown_location'),
374
394
  type: 'printer',
375
- })), preSelected: this.selectedPrinter ? this.selectedPrinter.name : null, disabled: !(this.printers.length > 0) })),
395
+ })),
396
+ // preSelected={this.selectedPrinter ? this.selectedPrinter.name : null}
397
+ disabled: !(this.printers.length > 0) })),
376
398
  h("div", { id: "options" },
377
399
  h("ezp-select", { label: i18next.t('printer_selection.color'), icon: "color", placeholder: i18next.t('printer_selection.select_color'), toggleFlow: "horizontal", options: this.selectedPrinterConfig.Color
378
400
  ? [
@@ -398,11 +420,25 @@ export class EzpPrinterSelection {
398
420
  },
399
421
  ],
400
422
  // preSelected={
401
- // this.previouslySelectedProperties.color
402
- // ? this.previouslySelectedProperties.color
403
- // : this.selectedPrinterConfig.Color
404
- // ? i18next.t('printer_selection.color_grayscale')
405
- // : null
423
+ // this.selectedProperties.color ?
424
+ // [
425
+ // {
426
+ // id: 1,
427
+ // title: i18next.t('printer_selection.color'),
428
+ // meta: '',
429
+ // type: 'color',
430
+ // },
431
+ // ]
432
+ // : !this.selectedProperties.color ?
433
+ // [
434
+ // {
435
+ // id: 0,
436
+ // title: i18next.t('printer_selection.color_grayscale'),
437
+ // meta: '',
438
+ // type: 'color',
439
+ // },
440
+ // ]
441
+ // : null
406
442
  // }
407
443
  disabled: !this.selectedPrinterConfig.Color }),
408
444
  h("ezp-select", { label: i18next.t('printer_selection.duplex'), icon: "duplex", placeholder: i18next.t('printer_selection.select_duplex'), toggleFlow: "horizontal", options: this.duplexOptions.map((option) => ({
@@ -412,10 +448,10 @@ export class EzpPrinterSelection {
412
448
  type: 'duplex',
413
449
  })),
414
450
  // preSelected={
415
- // this.previouslySelectedProperties.duplex
416
- // ? this.previouslySelectedProperties.duplex
417
- // : this.selectedPrinterConfig.DuplexSupported
418
- // ? 'None'
451
+ // this.selectedProperties.duplex
452
+ // ? this.selectedProperties.duplex
453
+ // // : this.selectedPrinterConfig.DuplexSupported
454
+ // // ? 'None'
419
455
  // : null
420
456
  // }
421
457
  disabled: !this.selectedPrinterConfig.DuplexSupported }),
@@ -426,10 +462,10 @@ export class EzpPrinterSelection {
426
462
  type: 'format',
427
463
  })),
428
464
  // preSelected={
429
- // this.previouslySelectedProperties.paper
430
- // ? this.previouslySelectedProperties.paper
431
- // : this.selectedPrinterConfig.PaperFormats.length > 0
432
- // ? this.selectedPrinterConfig.PaperFormats[0].Name
465
+ // this.selectedProperties.paper
466
+ // ? this.selectedProperties.paper
467
+ // // : this.selectedPrinterConfig.PaperFormats.length > 0
468
+ // // ? this.selectedPrinterConfig.PaperFormats[0].Name
433
469
  // : null
434
470
  // }
435
471
  disabled: !(this.selectedPrinterConfig.PaperFormats.length > 0) }),
@@ -440,12 +476,12 @@ export class EzpPrinterSelection {
440
476
  type: 'orientation',
441
477
  })),
442
478
  // preSelected={
443
- // this.previouslySelectedProperties.orientation
444
- // ? this.previouslySelectedProperties.orientation
445
- // : this.selectedPrinterConfig.OrientationsSupported.length > 0
446
- // ? i18next.t(
447
- // `printer_selection.orientation_${this.selectedPrinterConfig.OrientationsSupported[0]}`
448
- // )
479
+ // this.selectedProperties.orientation
480
+ // ? this.selectedProperties.orientation
481
+ // // : this.selectedPrinterConfig.OrientationsSupported.length > 0
482
+ // // ? i18next.t(
483
+ // // `printer_selection.orientation_${this.selectedPrinterConfig.OrientationsSupported[0]}`
484
+ // // )
449
485
  // : null
450
486
  // }
451
487
  disabled: !(this.selectedPrinterConfig.OrientationsSupported.length > 0) }),
@@ -456,14 +492,14 @@ export class EzpPrinterSelection {
456
492
  type: 'quality',
457
493
  })),
458
494
  // preSelected={
459
- // this.previouslySelectedProperties.resolution
460
- // ? this.previouslySelectedProperties.resolution
461
- // : this.selectedPrinterConfig.Resolutions.length > 0
462
- // ? this.selectedPrinterConfig.Resolutions[0]
495
+ // this.selectedProperties.resolution
496
+ // ? this.selectedProperties.resolution
497
+ // // : this.selectedPrinterConfig.Resolutions.length > 0
498
+ // // ? this.selectedPrinterConfig.Resolutions[0]
463
499
  // : null
464
500
  // }
465
501
  disabled: !(this.selectedPrinterConfig.Resolutions.length > 0) })),
466
- h("ezp-stepper", { label: "Copies", max: 10, icon: "copies" })),
502
+ h("ezp-stepper", { label: i18next.t('printer_selection.copies'), max: 10, icon: "copies" })),
467
503
  h("div", { id: "footer" },
468
504
  h("ezp-text-button", { type: "button", level: "secondary", onClick: this.handleCancel, label: i18next.t('button_actions.cancel') }),
469
505
  h("ezp-text-button", { disabled: this.selectedPrinter.id === '', type: "button", onClick: this.handlePrint, label: i18next.t('button_actions.print') })),
@@ -635,8 +671,7 @@ export class EzpPrinterSelection {
635
671
  "selectedPrinter": {},
636
672
  "printerConfig": {},
637
673
  "selectedPrinterConfig": {},
638
- "selectedProperties": {},
639
- "previouslySelectedProperties": {}
674
+ "selectedProperties": {}
640
675
  }; }
641
676
  static get events() { return [{
642
677
  "method": "printCancel",
@@ -7,9 +7,11 @@ import i18next from 'i18next';
7
7
  import { initi18n } from '../../utils/utils';
8
8
  export class EzpPrinting {
9
9
  constructor() {
10
+ this.filename = '';
10
11
  this.hidemenu = false;
11
12
  this.theme = 'cyan';
12
13
  this.appearance = 'system';
14
+ this.language = '';
13
15
  /**
14
16
  *
15
17
  * States
@@ -38,7 +40,7 @@ export class EzpPrinting {
38
40
  this.authOpen = false;
39
41
  }
40
42
  listenAuthSuccess() {
41
- if (this.filename) {
43
+ if (this.filename != '') {
42
44
  this.printOpen = true;
43
45
  }
44
46
  else {
@@ -124,7 +126,7 @@ export class EzpPrinting {
124
126
  else {
125
127
  printStore.state.printApiHostUrl = config.printingApiHostUrl;
126
128
  }
127
- initi18n();
129
+ initi18n(this.language);
128
130
  sendCodeToParentWindow();
129
131
  this.checkAuth();
130
132
  }
@@ -196,7 +198,8 @@ export class EzpPrinting {
196
198
  "text": ""
197
199
  },
198
200
  "attribute": "filename",
199
- "reflect": false
201
+ "reflect": false,
202
+ "defaultValue": "''"
200
203
  },
201
204
  "fileurl": {
202
205
  "type": "string",
@@ -402,6 +405,24 @@ export class EzpPrinting {
402
405
  },
403
406
  "attribute": "trigger",
404
407
  "reflect": false
408
+ },
409
+ "language": {
410
+ "type": "string",
411
+ "mutable": false,
412
+ "complexType": {
413
+ "original": "string",
414
+ "resolved": "string",
415
+ "references": {}
416
+ },
417
+ "required": false,
418
+ "optional": false,
419
+ "docs": {
420
+ "tags": [],
421
+ "text": ""
422
+ },
423
+ "attribute": "language",
424
+ "reflect": false,
425
+ "defaultValue": "''"
405
426
  }
406
427
  }; }
407
428
  static get states() { return {
@@ -1,5 +1,4 @@
1
1
  import { Component, Host, Prop, Event, h } from '@stencil/core';
2
- import { initi18n } from '../../utils/utils';
3
2
  import i18next from 'i18next';
4
3
  export class EzpStatus {
5
4
  constructor() {
@@ -31,7 +30,6 @@ export class EzpStatus {
31
30
  *
32
31
  */
33
32
  componentWillLoad() {
34
- initi18n();
35
33
  }
36
34
  /**
37
35
  *
@@ -1,5 +1,4 @@
1
1
  import { Component, Host, Listen, Event, State, h } from '@stencil/core';
2
- import { initi18n } from '../../utils/utils';
3
2
  import i18next from 'i18next';
4
3
  export class EzpUpload {
5
4
  constructor() {
@@ -46,7 +45,6 @@ export class EzpUpload {
46
45
  *
47
46
  */
48
47
  componentWillLoad() {
49
- initi18n();
50
48
  }
51
49
  /**
52
50
  *
@@ -1,7 +1,6 @@
1
1
  import { Component, Host, Prop, Event, Element, Watch, h } from '@stencil/core';
2
2
  import authStore from '../../services/auth';
3
3
  import userStore from '../../services/user';
4
- import { initi18n } from '../../utils/utils';
5
4
  import i18next from 'i18next';
6
5
  export class EzpUserMenu {
7
6
  constructor() {
@@ -67,7 +66,6 @@ export class EzpUserMenu {
67
66
  *
68
67
  */
69
68
  componentWillLoad() {
70
- initi18n();
71
69
  this.container = this.component.closest('[data-backdrop-surface]');
72
70
  this.backdrop.addEventListener('backdropHideStart', () => {
73
71
  this.open = false;
@@ -39,6 +39,7 @@ export class EzpAuthorizationService {
39
39
  }
40
40
  getAccessToken() {
41
41
  return fetch(this.accessTokenURL, {
42
+ credentials: 'include',
42
43
  headers: {
43
44
  Authorization: 'Basic ' + btoa(this.clientID + ':'),
44
45
  'Content-Type': 'application/x-www-form-urlencoded',
@@ -72,6 +73,7 @@ export class EzpAuthorizationService {
72
73
  }
73
74
  refreshTokens() {
74
75
  fetch(this.accessTokenURL, {
76
+ credentials: 'include',
75
77
  headers: {
76
78
  Authorization: 'Basic ' + btoa(this.clientID + ':'),
77
79
  'Content-Type': 'application/x-www-form-urlencoded',
@@ -9,7 +9,7 @@ export function encodeFormData(data) {
9
9
  export function capitalize(string) {
10
10
  return string.charAt(0).toUpperCase() + string.slice(1);
11
11
  }
12
- export function initi18n() {
12
+ export function initi18n(language) {
13
13
  const resources = {
14
14
  en: {
15
15
  translation: translationsEN,
@@ -18,13 +18,25 @@ export function initi18n() {
18
18
  translation: translationsDE,
19
19
  },
20
20
  };
21
- i18next.init({
22
- resources,
23
- lng: navigator.language,
24
- // allow keys to be phrases having `:`, `.`
25
- nsSeparator: false,
26
- fallbackLng: 'en',
27
- });
21
+ // override browserlanguage if language is provided
22
+ if (language != '') {
23
+ i18next.init({
24
+ resources,
25
+ lng: language,
26
+ // allow keys to be phrases having `:`, `.`
27
+ nsSeparator: false,
28
+ fallbackLng: 'en',
29
+ });
30
+ }
31
+ else {
32
+ i18next.init({
33
+ resources,
34
+ lng: navigator.language,
35
+ // allow keys to be phrases having `:`, `.`
36
+ nsSeparator: false,
37
+ fallbackLng: 'en',
38
+ });
39
+ }
28
40
  }
29
41
  export const poll = async ({ fn, validate, interval, maxAttempts }) => {
30
42
  let attempts = 0;