@ezeep/ezeep-js 1.0.161 → 1.0.163

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 (31) hide show
  1. package/dist/cjs/ezeep.cjs.js +1 -1
  2. package/dist/cjs/ezp-auth_14.cjs.entry.js +58 -136
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/collection/components/ezp-auth/ezp-auth.js +3 -3
  5. package/dist/collection/components/ezp-printer-selection/ezp-printer-selection.js +32 -53
  6. package/dist/collection/components/ezp-printing/ezp-printing.js +33 -1
  7. package/dist/collection/components/ezp-select/ezp-select.js +2 -0
  8. package/dist/collection/services/auth.js +5 -3
  9. package/dist/collection/services/print.js +0 -1
  10. package/dist/custom-elements/index.js +59 -137
  11. package/dist/directives/proxies.ts +1 -1
  12. package/dist/esm/ezeep.js +1 -1
  13. package/dist/esm/ezp-auth_14.entry.js +58 -136
  14. package/dist/esm/loader.js +1 -1
  15. package/dist/esm-es5/ezeep.js +1 -1
  16. package/dist/esm-es5/ezp-auth_14.entry.js +2 -2
  17. package/dist/esm-es5/loader.js +1 -1
  18. package/dist/ezeep/ezeep.esm.js +1 -1
  19. package/dist/ezeep/{p-9ff19f99.entry.js → p-2f6827c6.entry.js} +2 -2
  20. package/dist/ezeep/p-80d5c308.system.js +1 -1
  21. package/dist/ezeep/{p-e762ca0f.system.entry.js → p-9afa0fdb.system.entry.js} +3 -3
  22. package/dist/types/components/ezp-printer-selection/ezp-printer-selection.d.ts +2 -16
  23. package/dist/types/components/ezp-printing/ezp-printing.d.ts +3 -0
  24. package/dist/types/components.d.ts +1 -0
  25. package/dist/types/services/print.d.ts +1 -1
  26. package/package.json +1 -1
  27. package/www/build/ezeep.esm.js +1 -1
  28. package/www/build/{p-9ff19f99.entry.js → p-2f6827c6.entry.js} +2 -2
  29. package/www/build/p-80d5c308.system.js +1 -1
  30. package/www/build/{p-e762ca0f.system.entry.js → p-9afa0fdb.system.entry.js} +3 -3
  31. package/www/index.html +5 -6
@@ -4,7 +4,6 @@ import authStore from '../../services/auth';
4
4
  import printStore, { EzpPrintService } from '../../services/print';
5
5
  import userStore, { EzpUserService } from '../../services/user';
6
6
  import { poll, removeEmptyStrings } from '../../utils/utils';
7
- import options from '../../data/options.json';
8
7
  export class EzpPrinterSelection {
9
8
  constructor() {
10
9
  this.sasUri = '';
@@ -30,7 +29,6 @@ export class EzpPrinterSelection {
30
29
  *
31
30
  */
32
31
  this.loading = true;
33
- this.options = options;
34
32
  this.printProcessing = false;
35
33
  this.uploading = false;
36
34
  this.preparingUpload = false;
@@ -76,12 +74,13 @@ export class EzpPrinterSelection {
76
74
  return false;
77
75
  };
78
76
  this.POLL_INTERVAL = 2000;
77
+ this.MAX_POLL_ATTEMPTS = 1000;
79
78
  /** Description... */
80
79
  this.handlePrint = async () => {
81
80
  this.printProcessing = true;
82
81
  // we have to initialse this obj with empty strings to display the select component
83
82
  // but don't want to send any attributes with empty strings to the API
84
- this.selectedProperties = removeEmptyStrings(this.selectedProperties);
83
+ const cleanPrintProperties = removeEmptyStrings(this.selectedProperties);
85
84
  // put it in store for further use
86
85
  printStore.state.fileUrl = this.fileurl;
87
86
  printStore.state.fileID = this.fileid;
@@ -91,11 +90,11 @@ export class EzpPrinterSelection {
91
90
  printStore.state.fileName = this.filename;
92
91
  if (this.fileurl) {
93
92
  this.printService
94
- .printFileByUrl(authStore.state.accessToken, this.fileurl, this.filetype, this.selectedPrinter.id, this.selectedProperties, this.filename)
93
+ .printFileByUrl(authStore.state.accessToken, this.fileurl, this.filetype, this.selectedPrinter.id, cleanPrintProperties, this.filename)
95
94
  .then((response) => {
96
95
  if (response.status === 412) {
97
96
  response.json().then((data) => (this.fileid = data.fileid));
98
- this.printService.printByFileID(authStore.state.accessToken, this.fileid, this.filetype, this.selectedPrinter.id, this.selectedProperties, this.filename);
97
+ this.printService.printByFileID(authStore.state.accessToken, this.fileid, this.filetype, this.selectedPrinter.id, cleanPrintProperties, this.filename);
99
98
  }
100
99
  else {
101
100
  return response.json();
@@ -112,7 +111,7 @@ export class EzpPrinterSelection {
112
111
  fn: this.printService.getPrintStatus,
113
112
  validate: this.validateData,
114
113
  interval: this.POLL_INTERVAL,
115
- maxAttempts: 30,
114
+ maxAttempts: this.MAX_POLL_ATTEMPTS,
116
115
  }).catch((err) => {
117
116
  console.warn(err);
118
117
  this.printFailed = true;
@@ -131,7 +130,7 @@ export class EzpPrinterSelection {
131
130
  });
132
131
  }
133
132
  if (this.file) {
134
- await this.handleFiles(this.file);
133
+ await this.handleFiles(this.file, cleanPrintProperties);
135
134
  }
136
135
  localStorage.setItem('properties', JSON.stringify(this.selectedProperties));
137
136
  localStorage.setItem('printer', JSON.stringify(this.selectedPrinter));
@@ -226,16 +225,24 @@ export class EzpPrinterSelection {
226
225
  break;
227
226
  case 'color':
228
227
  this.selectedProperties.color = !!eventDetails.id;
228
+ // console.log('color selected:')
229
+ // console.log(this.selectedProperties.color)
229
230
  break;
230
231
  case 'orientation':
231
232
  this.selectedProperties.orientation = eventDetails.id;
233
+ // console.log('orientation selected:')
234
+ // console.log(this.selectedProperties.orientation)
232
235
  break;
233
236
  case 'format':
234
237
  this.selectedProperties.paper = eventDetails.title;
235
238
  this.selectedProperties.paperid = eventDetails.id;
239
+ // console.log('paper selected:')
240
+ // console.log(this.selectedProperties.paper)
236
241
  break;
237
242
  case 'quality':
238
243
  this.selectedProperties.resolution = eventDetails.title;
244
+ // console.log('quality selected:')
245
+ // console.log(this.selectedProperties.resolution)
239
246
  break;
240
247
  case 'duplex':
241
248
  if (eventDetails.title === 'None') {
@@ -245,12 +252,14 @@ export class EzpPrinterSelection {
245
252
  this.selectedProperties.duplex = true;
246
253
  }
247
254
  this.selectedProperties.duplexmode = eventDetails.id;
255
+ // console.log('duplex selected:')
256
+ // console.log(this.selectedProperties.duplexmode)
248
257
  break;
249
258
  default:
250
259
  break;
251
260
  }
252
261
  }
253
- async handleFiles(file) {
262
+ async handleFiles(file, printPorperties) {
254
263
  this.preparingUpload = true;
255
264
  const response = await this.printService.prepareFileUpload(authStore.state.accessToken);
256
265
  this.preparingUpload = false;
@@ -269,7 +278,7 @@ export class EzpPrinterSelection {
269
278
  this.uploading = false;
270
279
  if (res._response.status === 201) {
271
280
  this.printService
272
- .printByFileID(authStore.state.accessToken, this.fileid, this.filetype, this.selectedPrinter.id, this.selectedProperties, this.filename)
281
+ .printByFileID(authStore.state.accessToken, this.fileid, this.filetype, this.selectedPrinter.id, printPorperties, this.filename)
273
282
  .then((data) => {
274
283
  if (data.code === 804) {
275
284
  this.printFailed = true;
@@ -281,7 +290,7 @@ export class EzpPrinterSelection {
281
290
  fn: this.printService.getPrintStatus,
282
291
  validate: this.validateData,
283
292
  interval: this.POLL_INTERVAL,
284
- maxAttempts: 30,
293
+ maxAttempts: this.MAX_POLL_ATTEMPTS,
285
294
  }).catch((err) => {
286
295
  console.log(err);
287
296
  this.printFailed = true;
@@ -327,8 +336,9 @@ export class EzpPrinterSelection {
327
336
  /** Description... */
328
337
  async connectedCallback() {
329
338
  this.getPropertiesFromLocalStorage();
330
- this.getUserInfo();
331
339
  this.printService = new EzpPrintService(this.redirectURI, this.clientID);
340
+ this.printService.registerFetchInterceptor();
341
+ await this.getUserInfo();
332
342
  // if printer is stored from previous print, get the config to enable property selection
333
343
  if (this.selectedPrinter.id != '') {
334
344
  await this.printService
@@ -419,25 +429,9 @@ export class EzpPrinterSelection {
419
429
  },
420
430
  ],
421
431
  // preSelected={
422
- // this.selectedProperties.color ?
423
- // [
424
- // {
425
- // id: 1,
426
- // title: i18next.t('printer_selection.color'),
427
- // meta: '',
428
- // type: 'color',
429
- // },
430
- // ]
431
- // : !this.selectedProperties.color ?
432
- // [
433
- // {
434
- // id: 0,
435
- // title: i18next.t('printer_selection.color_grayscale'),
436
- // meta: '',
437
- // type: 'color',
438
- // },
439
- // ]
440
- // : null
432
+ // this.selectedProperties.color
433
+ // ? i18next.t('printer_selection.color_color')
434
+ // : i18next.t('printer_selection.color_grayscale')
441
435
  // }
442
436
  disabled: !this.selectedPrinterConfig.Color }),
443
437
  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) => ({
@@ -448,9 +442,9 @@ export class EzpPrinterSelection {
448
442
  })),
449
443
  // preSelected={
450
444
  // this.selectedProperties.duplex
451
- // ? this.selectedProperties.duplex
452
- // // : this.selectedPrinterConfig.DuplexSupported
453
- // // ? 'None'
445
+ // ? this.duplexOptions.find(
446
+ // (option) => option.id === this.selectedProperties.duplexmode
447
+ // ).id
454
448
  // : null
455
449
  // }
456
450
  disabled: !this.selectedPrinterConfig.DuplexSupported }),
@@ -460,28 +454,18 @@ export class EzpPrinterSelection {
460
454
  meta: `${format.XRes} x ${format.YRes}`,
461
455
  type: 'format',
462
456
  })),
463
- // preSelected={
464
- // this.selectedProperties.paper
465
- // ? this.selectedProperties.paper
466
- // // : this.selectedPrinterConfig.PaperFormats.length > 0
467
- // // ? this.selectedPrinterConfig.PaperFormats[0].Name
468
- // : null
469
- // }
457
+ // preSelected={this.selectedProperties.paper ? this.selectedProperties.paper : null}
470
458
  disabled: !(this.selectedPrinterConfig.PaperFormats.length > 0) }),
471
459
  h("ezp-select", { label: i18next.t('printer_selection.orientation'), icon: "orientation", placeholder: i18next.t('printer_selection.select_orientation'), toggleFlow: "horizontal", options: this.selectedPrinterConfig.OrientationsSupported.map((orientation, index) => ({
472
- id: index,
460
+ id: index + 1,
473
461
  title: i18next.t(`printer_selection.orientation_${orientation}`),
474
462
  meta: '',
475
463
  type: 'orientation',
476
464
  })),
477
465
  // preSelected={
478
466
  // this.selectedProperties.orientation
479
- // ? this.selectedProperties.orientation
480
- // // : this.selectedPrinterConfig.OrientationsSupported.length > 0
481
- // // ? i18next.t(
482
- // // `printer_selection.orientation_${this.selectedPrinterConfig.OrientationsSupported[0]}`
483
- // // )
484
- // : null
467
+ // ? this.selectedProperties.orientation
468
+ // : null
485
469
  // }
486
470
  disabled: !(this.selectedPrinterConfig.OrientationsSupported.length > 0) }),
487
471
  h("ezp-select", { label: i18next.t('printer_selection.quality'), icon: "quality", placeholder: i18next.t('printer_selection.select_quality'), toggleFlow: "horizontal", options: this.selectedPrinterConfig.Resolutions.map((option, index) => ({
@@ -491,11 +475,7 @@ export class EzpPrinterSelection {
491
475
  type: 'quality',
492
476
  })),
493
477
  // preSelected={
494
- // this.selectedProperties.resolution
495
- // ? this.selectedProperties.resolution
496
- // // : this.selectedPrinterConfig.Resolutions.length > 0
497
- // // ? this.selectedPrinterConfig.Resolutions[0]
498
- // : null
478
+ // this.selectedProperties.resolution ? this.selectedProperties.resolution : null
499
479
  // }
500
480
  disabled: !(this.selectedPrinterConfig.Resolutions.length > 0) })),
501
481
  h("ezp-stepper", { label: i18next.t('printer_selection.copies'), max: 10, icon: "copies" })),
@@ -655,7 +635,6 @@ export class EzpPrinterSelection {
655
635
  }; }
656
636
  static get states() { return {
657
637
  "loading": {},
658
- "options": {},
659
638
  "printProcessing": {},
660
639
  "uploading": {},
661
640
  "preparingUpload": {},
@@ -1,5 +1,5 @@
1
1
  import { Component, Host, State, Listen, Method, h, Prop } from '@stencil/core';
2
- import authStore, { sendCodeToParentWindow } from '../../services/auth';
2
+ import authStore, { EzpAuthorizationService, sendCodeToParentWindow } from '../../services/auth';
3
3
  import printStore, { EzpPrintService } from '../../services/print';
4
4
  import userStore from '../../services/user';
5
5
  import config from '../../shared/config.json';
@@ -88,6 +88,13 @@ export class EzpPrinting {
88
88
  localStorage.removeItem('isAuthorized');
89
89
  this.printOpen = false;
90
90
  }
91
+ async getSasUri() {
92
+ const printService = new EzpPrintService(this.redirecturi, this.clientid);
93
+ const response = await printService.prepareFileUpload(authStore.state.accessToken)
94
+ .catch(() => this.open());
95
+ const sasUri = response.sasUri;
96
+ return sasUri;
97
+ }
91
98
  checkAuth() {
92
99
  const printService = new EzpPrintService(this.redirecturi, this.clientid);
93
100
  let accessToken = authStore.state.accessToken;
@@ -113,6 +120,12 @@ export class EzpPrinting {
113
120
  authStore.state.isAuthorized = false;
114
121
  });
115
122
  }
123
+ refreshTokensPeriodically(seconds) {
124
+ const authService = new EzpAuthorizationService(this.redirecturi, this.clientid);
125
+ setInterval(() => {
126
+ authService.refreshTokens();
127
+ }, seconds * 1000);
128
+ }
116
129
  componentWillLoad() {
117
130
  const systemAppearanceDark = window.matchMedia('(prefers-color-scheme: dark)');
118
131
  this.systemAppearance = systemAppearanceDark.matches ? 'dark' : 'light';
@@ -138,6 +151,9 @@ export class EzpPrinting {
138
151
  sendCodeToParentWindow();
139
152
  this.checkAuth();
140
153
  }
154
+ componentDidLoad() {
155
+ this.refreshTokensPeriodically(1800);
156
+ }
141
157
  /**
142
158
  *
143
159
  * Render method
@@ -471,6 +487,22 @@ export class EzpPrinting {
471
487
  "text": "",
472
488
  "tags": []
473
489
  }
490
+ },
491
+ "getSasUri": {
492
+ "complexType": {
493
+ "signature": "() => Promise<string>",
494
+ "parameters": [],
495
+ "references": {
496
+ "Promise": {
497
+ "location": "global"
498
+ }
499
+ },
500
+ "return": "Promise<string>"
501
+ },
502
+ "docs": {
503
+ "text": "",
504
+ "tags": []
505
+ }
474
506
  }
475
507
  }; }
476
508
  static get listeners() { return [{
@@ -49,6 +49,8 @@ export class EzpSelect {
49
49
  const delay = this.selected.id === id ? 0 : this.duration * 1000;
50
50
  this.selected = this.options.find((option) => option.id === id);
51
51
  this.selectSelection.emit(this.selected);
52
+ // console.log('ezp-select:')
53
+ // console.log(this.selected)
52
54
  window.setTimeout(() => {
53
55
  this.toggle();
54
56
  }, delay);
@@ -114,8 +114,10 @@ export function sendCodeToParentWindow() {
114
114
  const params = new URLSearchParams(window.location.search);
115
115
  const code = params.get('code');
116
116
  if (window.opener) {
117
- // send them to the opening window
118
- window.opener.postMessage(code, authStore.state.redirectUri);
119
- window.close();
117
+ if (code) {
118
+ // send them to the opening window
119
+ window.opener.postMessage(code, authStore.state.redirectUri);
120
+ window.close();
121
+ }
120
122
  }
121
123
  }
@@ -15,7 +15,6 @@ export class EzpPrintService {
15
15
  this.clientID = clientID;
16
16
  this.printingApi = printStore.state.printApiHostUrl;
17
17
  this.checkStoredRefreshToken();
18
- this.registerFetchInterceptor();
19
18
  }
20
19
  checkStoredRefreshToken() {
21
20
  if (authStore.state.refreshToken !== '') {