@osimatic/helpers-js 1.0.24 → 1.0.27

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/changelog.txt CHANGED
@@ -31,3 +31,7 @@ getDateObjectSelected(lien) -> getSelectedDate(lien.closest('.form-group')
31
31
  selectFormDate(lien) -> setSelectedDate(lien.closest('.form-group')
32
32
  majSelectPeriode() / majSelectCompare() -> updatePeriodSelect(form)
33
33
 
34
+ let URL_REFRESH = ... -> HTTPRequest.setRefreshTokenUrl(URL_REFRESH)
35
+ let _httpHeaders = {...} -> HTTPRequest.setHeader(key, value);
36
+ let httpHeaders = {...} -> HTTPRequest.setHeader(key, value);
37
+ remplacer l'utilisation des variables httpHeaders / _httpHeaders par HTTPRequest.getHeaders()
package/date_time.js CHANGED
@@ -419,128 +419,4 @@ class SqlDateTime {
419
419
  }
420
420
 
421
421
 
422
- class InputPeriod {
423
-
424
- static addLinks(form) {
425
- let divParent = form.find('input[type="date"][data-add_period_select_links]').parent();
426
- if (divParent.hasClass('input-group')) {
427
- divParent = divParent.parent();
428
- }
429
- divParent.append(''
430
- +'<div class="select_period_links">'
431
- +'<a href="#" class="period_select_yesterday">Hier</a> - '
432
- +'<a href="#" class="period_select_current_week">Cette semaine</a> - '
433
- +'<a href="#" class="period_select_last_week">La semaine dernière</a> - '
434
- +'<a href="#" class="period_select_current_month">Ce mois-ci</a> - '
435
- +'<a href="#" class="period_select_last_month">Le mois dernier</a> - '
436
- +'<a href="#" class="period_select_current_year">Cette année</a>'
437
- +'</div>'
438
- );
439
- this.init(form);
440
- }
441
-
442
- static init(form) {
443
- let link;
444
- //console.log(form.find('a.period_select_current_week'));
445
-
446
- if ((link = form.find('a.period_select_today')).length) {
447
- link.click(function() { InputPeriod.selectToday($(this)); return false; });
448
- }
449
- if ((link = form.find('a.period_select_yesterday')).length) {
450
- link.click(function() { InputPeriod.selectPreviousDay($(this), 1); return false; });
451
- }
452
- if ((link = form.find('a.period_select_tomorrow')).length) {
453
- link.click(function() { InputPeriod.selectFollowingDay($(this), 1); return false; });
454
- }
455
- if ((link = form.find('a.period_select_current_week')).length) {
456
- link.click(function() { InputPeriod.selectCurrentWeek($(this)); return false; });
457
- }
458
- if ((link = form.find('a.period_select_last_week')).length) {
459
- link.click(function() { InputPeriod.selectPreviousWeek($(this), 1); return false; });
460
- }
461
- if ((link = form.find('a.period_select_current_month')).length) {
462
- link.click(function() { InputPeriod.selectCurrentMonth($(this)); return false; });
463
- }
464
- if ((link = form.find('a.period_select_last_month')).length) {
465
- link.click(function() { InputPeriod.selectPreviousMonth($(this), 1); return false; });
466
- }
467
- if ((link = form.find('a.period_select_current_year')).length) {
468
- link.click(function() { InputPeriod.selectCurrentYear($(this)); return false; });
469
- }
470
- if ((link = form.find('a.period_select_last_year')).length) {
471
- link.click(function() { InputPeriod.selectCurrentYear($(this), 1); return false; });
472
- }
473
- }
474
-
475
-
476
- static selectToday(link) {
477
- let date = new Date();
478
- this.selectPeriod(link, date, date);
479
- }
480
-
481
- static selectPreviousDay(lien, nbDays) {
482
- this.selectFollowingDay(lien, -nbDays);
483
- }
484
- static selectFollowingDay(lien, nbDays) {
485
- let date = new Date();
486
- date.setDate(date.getDate() + nbDays);
487
- this.selectPeriod(lien, date, date);
488
- }
489
-
490
- static selectCurrentWeek(lien) {
491
- let date = new Date();
492
- this.selectPeriod(lien, DateTime.getFirstDayOfWeek(date), DateTime.getLastDayOfWeek(date));
493
- }
494
- static selectPreviousWeek(lien, nbWeeks) {
495
- this.selectFollowingWeek(lien, -nbWeeks);
496
- }
497
- static selectFollowingWeek(lien, nbWeeks) {
498
- let date = new Date();
499
- date.setDate(date.getDate() + (7*nbWeeks));
500
- this.selectPeriod(lien, DateTime.getFirstDayOfWeek(date), DateTime.getLastDayOfWeek(date));
501
- }
502
-
503
- static selectCurrentMonth(lien) {
504
- let date = new Date();
505
- this.selectPeriod(lien, DateTime.getFirstDayOfMonth(date), DateTime.getLastDayOfMonth(date));
506
- }
507
- static selectPreviousMonth(lien, nbMonths) {
508
- this.selectFollowingMonth(lien, -nbMonths);
509
- }
510
- static selectFollowingMonth(lien, nbMonths) {
511
- let date = new Date();
512
- date.setDate(1);
513
- date.setMonth(date.getMonth() + nbMonths);
514
- this.selectPeriod(lien, DateTime.getFirstDayOfMonth(date), DateTime.getLastDayOfMonth(date));
515
- }
516
-
517
- static selectCurrentYear(lien) {
518
- this.selectFollowingYear(lien, 0);
519
- }
520
- static selectPreviousYear(lien, nbAnneesMoins) {
521
- this.selectFollowingYear(lien, -nbAnneesMoins);
522
- }
523
- static selectFollowingYear(lien, nbAnneesMoins) {
524
- let date = new Date();
525
- date.setFullYear(date.getFullYear() + nbAnneesMoins);
526
- this.selectPeriod(lien, DateTime.getFirstDayOfYear(date), DateTime.getLastDayOfYear(date));
527
- }
528
-
529
-
530
- static selectPeriod(link, startDate, endDate) {
531
- let inputPeriodStart = link.parent().parent().find('input[type="date"]').filter('[name="date_start"], [name="start_date"], [name="start_period"], [name="period_start_date"]');
532
- let inputPeriodEnd = link.parent().parent().find('input[type="date"]').filter('[name="date_end"], [name="end_date"], [name="end_period"], [name="period_end_date"]');
533
- if (inputPeriodStart.length == 0 || inputPeriodEnd.length == 0) {
534
- console.log('no period input found');
535
- return;
536
- }
537
-
538
- //console.log(startDate);
539
- //console.log(endDate);
540
- inputPeriodStart.val(DateTime.getSqlDate(startDate));
541
- inputPeriodEnd.val(DateTime.getSqlDate(endDate));
542
- }
543
-
544
- }
545
-
546
- module.exports = { DateTime, TimestampUnix, SqlDate, SqlTime, SqlDateTime, InputPeriod };
422
+ module.exports = { DateTime, TimestampUnix, SqlDate, SqlTime, SqlDateTime };
package/file.js CHANGED
@@ -12,9 +12,9 @@ class File {
12
12
  }
13
13
  var type = contentType;
14
14
 
15
- var blob = new Blob([data], {
16
- type: type
17
- });
15
+ var blob = new Blob([data], {
16
+ type: type
17
+ });
18
18
 
19
19
  //console.log('disposition: '+disposition+' ; filename: '+filename+' ; type: '+type);
20
20
  //console.log('blob: %o', blob);
@@ -37,30 +37,30 @@ class File {
37
37
  a.click();
38
38
  }
39
39
 
40
- setTimeout(function () {
41
- URL.revokeObjectURL(downloadUrl);
42
- }, 100); // cleanup
40
+ setTimeout(function () {
41
+ URL.revokeObjectURL(downloadUrl);
42
+ }, 100); // cleanup
43
43
  }
44
44
  }
45
45
 
46
- static formatFileSize(fileSizeInBytes, fractionDigits, locale) {
47
- fractionDigits = (typeof fractionDigits != 'undefined' ? fractionDigits : 2);
48
- var i = -1;
49
- var byteUnits = ['kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
50
- if (fileSizeInBytes === 0) {
51
- return '0 ' + byteUnits[0];
52
- }
53
- do {
54
- fileSizeInBytes = fileSizeInBytes / 1024;
55
- i++;
56
- }
57
- while (fileSizeInBytes > 1024);
58
- //var size = Math.max(fileSizeInBytes, 0.1).toFixed(fractionDigits);
59
- var size = Math.max(fileSizeInBytes, 0.1);
60
- return (new Intl.NumberFormat(locale, {
61
- maximumFractionDigits: fractionDigits
62
- }).format(size)) + ' ' + byteUnits[i];
63
- }
46
+ static formatFileSize(fileSizeInBytes, fractionDigits, locale) {
47
+ fractionDigits = (typeof fractionDigits != 'undefined' ? fractionDigits : 2);
48
+ var i = -1;
49
+ var byteUnits = ['kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
50
+ if (fileSizeInBytes === 0) {
51
+ return '0 ' + byteUnits[0];
52
+ }
53
+ do {
54
+ fileSizeInBytes = fileSizeInBytes / 1024;
55
+ i++;
56
+ }
57
+ while (fileSizeInBytes > 1024);
58
+ //var size = Math.max(fileSizeInBytes, 0.1).toFixed(fractionDigits);
59
+ var size = Math.max(fileSizeInBytes, 0.1);
60
+ return (new Intl.NumberFormat(locale, {
61
+ maximumFractionDigits: fractionDigits
62
+ }).format(size)) + ' ' + byteUnits[i];
63
+ }
64
64
  }
65
65
 
66
66
  const CSV_FILE_EXTENSION = "csv";
package/form_date.js CHANGED
@@ -1,17 +1,214 @@
1
- const {Object} = require('./index');
1
+ // input period de type : Du <input type="date" name="start_date" /> au <input type="date" name="end_date" />
2
+ class InputPeriod {
2
3
 
4
+ static addLinks(form) {
5
+ let divParent = form.find('input[type="date"][data-add_period_select_links]').parent();
6
+ if (divParent.hasClass('input-group')) {
7
+ divParent = divParent.parent();
8
+ }
9
+ divParent.append(''
10
+ +'<div class="select_period_links">'
11
+ +'<a href="#" class="period_select_yesterday">Hier</a> - '
12
+ +'<a href="#" class="period_select_current_week">Cette semaine</a> - '
13
+ +'<a href="#" class="period_select_last_week">La semaine dernière</a> - '
14
+ +'<a href="#" class="period_select_current_month">Ce mois-ci</a> - '
15
+ +'<a href="#" class="period_select_last_month">Le mois dernier</a> - '
16
+ +'<a href="#" class="period_select_current_year">Cette année</a>'
17
+ +'</div>'
18
+ );
19
+ this.init(form);
20
+ }
21
+
22
+ static init(form) {
23
+ let link;
24
+ //console.log(form.find('a.period_select_current_week'));
25
+
26
+ if ((link = form.find('a.period_select_today')).length) {
27
+ link.click(function() { InputPeriod.selectToday($(this)); return false; });
28
+ }
29
+ if ((link = form.find('a.period_select_yesterday')).length) {
30
+ link.click(function() { InputPeriod.selectPreviousDay($(this), 1); return false; });
31
+ }
32
+ if ((link = form.find('a.period_select_tomorrow')).length) {
33
+ link.click(function() { InputPeriod.selectFollowingDay($(this), 1); return false; });
34
+ }
35
+ if ((link = form.find('a.period_select_current_week')).length) {
36
+ link.click(function() { InputPeriod.selectCurrentWeek($(this)); return false; });
37
+ }
38
+ if ((link = form.find('a.period_select_last_week')).length) {
39
+ link.click(function() { InputPeriod.selectPreviousWeek($(this), 1); return false; });
40
+ }
41
+ if ((link = form.find('a.period_select_current_month')).length) {
42
+ link.click(function() { InputPeriod.selectCurrentMonth($(this)); return false; });
43
+ }
44
+ if ((link = form.find('a.period_select_last_month')).length) {
45
+ link.click(function() { InputPeriod.selectPreviousMonth($(this), 1); return false; });
46
+ }
47
+ if ((link = form.find('a.period_select_current_year')).length) {
48
+ link.click(function() { InputPeriod.selectCurrentYear($(this)); return false; });
49
+ }
50
+ if ((link = form.find('a.period_select_last_year')).length) {
51
+ link.click(function() { InputPeriod.selectCurrentYear($(this), 1); return false; });
52
+ }
53
+ }
54
+
55
+
56
+ static selectToday(link) {
57
+ let date = new Date();
58
+ this.selectPeriod(link, date, date);
59
+ }
60
+
61
+ static selectPreviousDay(lien, nbDays) {
62
+ this.selectFollowingDay(lien, -nbDays);
63
+ }
64
+ static selectFollowingDay(lien, nbDays) {
65
+ let date = new Date();
66
+ date.setDate(date.getDate() + nbDays);
67
+ this.selectPeriod(lien, date, date);
68
+ }
69
+
70
+ static selectCurrentWeek(lien) {
71
+ let date = new Date();
72
+ this.selectPeriod(lien, DateTime.getFirstDayOfWeek(date), DateTime.getLastDayOfWeek(date));
73
+ }
74
+ static selectPreviousWeek(lien, nbWeeks) {
75
+ this.selectFollowingWeek(lien, -nbWeeks);
76
+ }
77
+ static selectFollowingWeek(lien, nbWeeks) {
78
+ let date = new Date();
79
+ date.setDate(date.getDate() + (7*nbWeeks));
80
+ this.selectPeriod(lien, DateTime.getFirstDayOfWeek(date), DateTime.getLastDayOfWeek(date));
81
+ }
82
+
83
+ static selectCurrentMonth(lien) {
84
+ let date = new Date();
85
+ this.selectPeriod(lien, DateTime.getFirstDayOfMonth(date), DateTime.getLastDayOfMonth(date));
86
+ }
87
+ static selectPreviousMonth(lien, nbMonths) {
88
+ this.selectFollowingMonth(lien, -nbMonths);
89
+ }
90
+ static selectFollowingMonth(lien, nbMonths) {
91
+ let date = new Date();
92
+ date.setDate(1);
93
+ date.setMonth(date.getMonth() + nbMonths);
94
+ this.selectPeriod(lien, DateTime.getFirstDayOfMonth(date), DateTime.getLastDayOfMonth(date));
95
+ }
96
+
97
+ static selectCurrentYear(lien) {
98
+ this.selectFollowingYear(lien, 0);
99
+ }
100
+ static selectPreviousYear(lien, nbAnneesMoins) {
101
+ this.selectFollowingYear(lien, -nbAnneesMoins);
102
+ }
103
+ static selectFollowingYear(lien, nbAnneesMoins) {
104
+ let date = new Date();
105
+ date.setFullYear(date.getFullYear() + nbAnneesMoins);
106
+ this.selectPeriod(lien, DateTime.getFirstDayOfYear(date), DateTime.getLastDayOfYear(date));
107
+ }
108
+
109
+
110
+ static selectPeriod(link, startDate, endDate) {
111
+ let inputPeriodStart = link.parent().parent().find('input[type="date"]').filter('[name="date_start"], [name="start_date"], [name="start_period"], [name="period_start_date"]');
112
+ let inputPeriodEnd = link.parent().parent().find('input[type="date"]').filter('[name="date_end"], [name="end_date"], [name="end_period"], [name="period_end_date"]');
113
+ if (inputPeriodStart.length == 0 || inputPeriodEnd.length == 0) {
114
+ console.log('no period input found');
115
+ return;
116
+ }
117
+
118
+ //console.log(startDate);
119
+ //console.log(endDate);
120
+ inputPeriodStart.val(DateTime.getSqlDate(startDate));
121
+ inputPeriodEnd.val(DateTime.getSqlDate(endDate));
122
+ }
123
+
124
+ }
125
+
126
+ // input period de type : <select class="period">Aujourd'hui / Ce mois-ci / etc. / Personnalisé</select>
3
127
  class FormDate {
4
128
  static initForm(form) {
129
+
130
+ function fillPeriodSelect(select) {
131
+ Object.entries(FormDate.getPeriodList()).forEach(([idx, tabListPeriode]) => {
132
+ let html = '<optgroup label="'+tabListPeriode['label']+'">';
133
+ Object.entries(tabListPeriode['list']).forEach(([key, label]) => {
134
+ html += '<option value="'+key+'">'+label+'</option>';
135
+ });
136
+ html += '</optgroup>';
137
+ select.append(html);
138
+ });
139
+ if (select.data('default_value')) {
140
+ select.val(select.data('default_value'));
141
+ }
142
+ }
143
+
144
+ function updatePeriodSelect(select) {
145
+ if (select.val() === 'perso') {
146
+ select.closest('.form-group').next().removeClass('hide');
147
+ }
148
+ else {
149
+ select.closest('.form-group').next().addClass('hide');
150
+ }
151
+ }
152
+
153
+ function updateForm(form) {
154
+ let periodSelect = form.find('select.periode');
155
+ if (periodSelect.length === 0) {
156
+ return;
157
+ }
158
+
159
+ updatePeriodSelect(periodSelect);
160
+
161
+ let comparedPeriodSelect = form.find('select.periodeCompare');
162
+ if (comparedPeriodSelect.length === 0) {
163
+ return;
164
+ }
165
+
166
+ let listValues = [];
167
+ let valueDefault = null;
168
+
169
+ comparedPeriodSelect.find('option').attr('disabled', false);
170
+
171
+ Object.entries(FormDate.getPeriodList()).forEach(([idx, tabListPeriode]) => {
172
+ if (idx != 0) {
173
+ let listKeyPeriode = Object.entries(tabListPeriode['list']).map(([key, value]) => key);
174
+ if (listKeyPeriode.indexOf(periodSelect.val()) !== -1) {
175
+ listValues = listKeyPeriode;
176
+ valueDefault = listKeyPeriode[1];
177
+ }
178
+ else {
179
+ comparedPeriodSelect.find('option[value="' + listKeyPeriode[0] + '"]').parent().children().attr('disabled', true);
180
+ }
181
+ }
182
+ });
183
+
184
+ if (periodSelect.val() === 'perso') {
185
+ valueDefault = 'perso';
186
+ }
187
+ else if (comparedPeriodSelect.val() !== 'perso' && listValues.indexOf(comparedPeriodSelect.val()) !== -1) {
188
+ valueDefault = comparedPeriodSelect.val();
189
+ }
190
+ comparedPeriodSelect.val(valueDefault);
191
+
192
+ updatePeriodSelect(comparedPeriodSelect);
193
+ }
194
+
5
195
  // ---------- Choix période (new) ----------
6
196
 
7
- // Formulaire de sélection de période
8
197
  if (form.find('select.periode').length > 0) {
198
+ fillPeriodSelect(form.find('select.periode'));
9
199
  form.find('select.periode').change(function() {
10
- FormDate.updatePeriodSelect($(this).closest('form'));
200
+ updateForm($(this).closest('form'));
11
201
  });
12
- FormDate.updatePeriodSelect($(this).closest('form'));
13
202
  }
14
203
 
204
+ if (form.find('select.periodeCompare').length > 0) {
205
+ fillPeriodSelect(form.find('select.periodeCompare'));
206
+ form.find('select.periodeCompare').change(function() {
207
+ updateForm($(this).closest('form'));
208
+ });
209
+ }
210
+
211
+ updateForm(form);
15
212
 
16
213
  // ---------- Choix période (old) ----------
17
214
 
@@ -51,7 +248,7 @@ class FormDate {
51
248
  ' <a href="#" class="lien_form_day_moins_8">J-8</a> - '+
52
249
  ' <a href="#" class="lien_form_last_month">Le mois dernier</a> - '+
53
250
  ' <a href="#" class="lien_form_month_moins_2">Mois M-2</a> - '+
54
- ' <a href="#" class="lien_form_last_year">L\'année dernière</a>'+
251
+ ' <a href="#" class="lien_form_last_year">Lannée dernière</a>'+
55
252
  '</p>'
56
253
  );
57
254
  }
@@ -141,58 +338,99 @@ class FormDate {
141
338
  //}
142
339
  }
143
340
 
144
- static updatePeriodSelect(form) {
145
- function updateSelect(select) {
146
- if (select.val() === 'perso') {
147
- select.parent().parent().next().removeClass('hide');
148
- }
149
- else {
150
- select.parent().parent().next().addClass('hide');
151
- }
152
- }
153
-
154
- let periodSelect = form.find('select.period');
155
- if (periodSelect.length === 0) {
156
- return;
157
- }
158
-
159
- updateSelect(periodSelect);
160
-
161
- let comparedPeriodSelect = form.find('select.compared_period');
162
- if (comparedPeriodSelect.length === 0) {
163
- return;
164
- }
165
-
166
- let listValues = [];
167
- let valueDefault = null;
168
-
169
- comparedPeriodSelect.find('option').attr('disabled', false);
170
-
171
- let listePeriodeCompare = typeof listePeriodeCompare != 'undefined' ? listePeriodeCompare : {};
172
- listePeriodeCompare.forEach(([idx, tabListPeriode]) => {
173
- if (idx != 0) {
174
- let listKeyPeriode = Object.entries(tabListPeriode['list']).map(([key, value]) => key);
175
- if (listKeyPeriode.indexOf(periodSelect.val()) !== -1) {
176
- listValues = listKeyPeriode;
177
- valueDefault = listKeyPeriode[1];
178
- }
179
- else {
180
- comparedPeriodSelect.find('option[value="' + listKeyPeriode[0] + '"]').parent().children().attr('disabled', true);
181
- }
182
- }
183
- });
184
-
185
- if (periodSelect.val() === 'perso') {
186
- valueDefault = 'perso';
187
- }
188
- else if (comparedPeriodSelect.val() !== 'perso' && listValues.indexOf(comparedPeriodSelect.val()) !== -1) {
189
- valueDefault = comparedPeriodSelect.val();
190
- }
191
- comparedPeriodSelect.val(valueDefault);
192
-
193
- updateSelect(comparedPeriodSelect);
341
+ static getPeriodList() {
342
+ return {
343
+ other: {label: 'Autre', list: {
344
+ perso: 'Personnalisé',
345
+ }},
346
+ '1d': {label: 'Un jour', list: { // 1 jour
347
+ 'ajd': 'Aujourd’hui',
348
+ 'hier': 'Hier',
349
+ 'jourMoins2': 'Avant-hier',
350
+ 'jourMoins3': 'J-3',
351
+ 'jourMoins7': 'J-7',
352
+ 'jourMoins8': 'J-8',
353
+ 'same_day_last_year': 'Même jour l’année dernière',
354
+ 'same_day_least_2_years': 'Même jour l’année A-2',
355
+ 'same_day_as_yesterday_last_year': 'Même jour qu’hier l’année dernière',
356
+ 'same_day_as_yesterday_least_2_years': 'Même jour qu’hier l’année A-2'
357
+ }},
358
+ '1w': {label: 'Une semaine', list: { // 1 semaine
359
+ 'curr_week': 'Cette semaine',
360
+ 'last_week': 'La semaine dernière',
361
+ 'weekMoins2': 'Semaine S-2',
362
+ 'weekMoins3': 'Semaine S-3',
363
+ 'weekMoins4': 'Semaine S-4',
364
+ }},
365
+ '7d': {label: '7 jours', list: { // 7 jours
366
+ 'last_7_days': 'Les 7 derniers jours',
367
+ 'last_7_days_before': 'Les 7 jours avant',
368
+ 'last_7_days_least_1_year': 'Les mêmes 7 jours l’année dernière',
369
+ 'last_7_days_least_2_years': 'Les mêmes 7 jours l’année A-2',
370
+ }},
371
+ '14d': {label: '14 jours', list: { // 14 jours
372
+ 'last_14_days': 'Les 14 derniers jours',
373
+ 'last_14_days_before': 'Les 14 jours avant',
374
+ 'last_14_days_least_1_year': 'Les mêmes 14 jours l’année dernière',
375
+ 'last_14_days_least_2_years': 'Les mêmes 14 jours l’année A-2',
376
+ }},
377
+ // 30 jours
378
+ '30d': {label: '30 jours', list: {
379
+ 'last_30_days': 'Les 30 derniers jours',
380
+ 'last_30_days_before': 'Les 30 jours avant',
381
+ 'last_30_days_least_1_year': 'Les mêmes 30 jours l’année dernière',
382
+ 'last_30_days_least_2_years': 'Les mêmes 30 jours l’année A-2',
383
+ }},
384
+ '60d': {label: '60 jours', list: { // 60 jours
385
+ 'last_60_days': 'Les 60 derniers jours',
386
+ 'last_60_days_before': 'Les 60 jours avant',
387
+ 'last_60_days_least_1_year': 'Les mêmes 60 jours l’année dernière',
388
+ 'last_60_days_least_2_years': 'Les mêmes 60 jours l’année A-2',
389
+ }},
390
+ '1m': {label: 'Un mois', list: { // 1 mois
391
+ 'curr_month': 'Ce mois-ci',
392
+ 'last_month': 'Le mois dernier',
393
+ 'monthMoins2': 'Mois M-2',
394
+ 'monthMoins3': 'Mois M-3',
395
+ 'monthMoins4': 'Mois M-4',
396
+ 'monthMoins5': 'Mois M-5',
397
+ 'monthMoins6': 'Mois M-6',
398
+ 'same_month_last_year': 'Même mois l’année dernière',
399
+ 'same_month_least_2_years': 'Même mois l’année A-2',
400
+ }},
401
+ '3m': {label: '3 mois', list: { // 3 mois
402
+ 'last_3_month': 'Les 3 derniers mois',
403
+ 'last_3_month_before': 'Les 3 mois avant',
404
+ 'last_3_month_least_1_year': 'Les mêmes 3 mois l’année dernière',
405
+ 'last_3_month_least_2_years': 'Les mêmes 3 mois l’année A-2',
406
+ }},
407
+ '6m': {label: '6 mois', list: { // 6 mois
408
+ 'last_6_month': 'Les 6 derniers mois',
409
+ 'last_6_month_before': 'Les 6 mois avant',
410
+ 'last_6_month_least_1_year': 'Les mêmes 6 mois l’année dernière',
411
+ 'last_6_month_least_2_years': 'Les mêmes 6 mois l’année A-2',
412
+ }},
413
+ '12m': {label: '12 mois', list: { // 12 mois
414
+ 'last_12_month': 'Les 12 derniers mois',
415
+ 'last_12_month_before': 'Les 12 mois avant',
416
+ 'last_12_month_least_1_year': 'Les mêmes 12 mois l’année dernière',
417
+ 'last_12_month_least_2_years': 'Les mêmes 12 mois l’année A-2',
418
+ }},
419
+ '24m': {label: '24 mois', list: { // 24 mois
420
+ 'last_24_month': 'Les 24 derniers mois',
421
+ 'last_24_month_before': 'Les 24 mois avant',
422
+ 'last_24_month_least_1_year': 'Les mêmes 24 mois l’année dernière',
423
+ 'last_24_month_least_2_years': 'Les mêmes 24 mois l’année A-2',
424
+ }},
425
+ '1y': {label: 'Une année', list: { // 1 année
426
+ 'curr_year': 'Cette année',
427
+ 'last_year': 'L’année dernière',
428
+ 'yearMoins2': 'Année A-2',
429
+ 'yearMoins3': 'Année A-3',
430
+ 'yearMoins4': 'Année A-4',
431
+ }},
432
+ };
194
433
  }
195
-
196
434
  static setTodaySelected(periodFormGroup) {
197
435
  let date = new Date();
198
436
  FormDate.setSelectedDate(periodFormGroup, date.getDate(), (date.getMonth() + 1), date.getFullYear());
@@ -241,7 +479,7 @@ class FormDate {
241
479
  }
242
480
  return new Date();
243
481
  }
244
-
482
+
245
483
  static setSelectedDate(periodFormGroup, day, month, year) {
246
484
  periodFormGroup.find('select.day').val(day);
247
485
  periodFormGroup.find('select.month').val(month);
@@ -250,24 +488,9 @@ class FormDate {
250
488
 
251
489
 
252
490
 
253
-
254
-
255
-
256
-
257
-
258
-
259
-
260
-
261
-
262
-
263
-
264
-
265
-
266
-
267
-
491
+ /*
268
492
  // deprecated
269
493
 
270
- /** @deprecated */
271
494
  static majSelectPeriode(select) {
272
495
  if (select.find(':selected').attr('value') === 'perso') {
273
496
  select.parent().parent().next().removeClass('hide');
@@ -277,7 +500,6 @@ class FormDate {
277
500
  }
278
501
  }
279
502
 
280
- /** @deprecated */
281
503
  static majSelectCompare() {
282
504
  if ($('form select#periodeCompare').length === 0) {
283
505
  return;
@@ -315,53 +537,38 @@ class FormDate {
315
537
  FormDate.majSelectPeriode(selectCompare);
316
538
  }
317
539
 
318
- /** @deprecated */
319
540
  static selectFormDateToday(lien) {
320
541
  let date = new Date();
321
542
  FormDate.selectFormDate(lien, date.getDate(), (date.getMonth() + 1), date.getFullYear());
322
543
  }
323
-
324
- /** @deprecated */
325
544
  static selectFormDateDayMoinsNb(lien, nbJoursMoins) {
326
545
  let date = new Date();
327
546
  date.setDate(date.getDate() - nbJoursMoins);
328
547
  FormDate.selectFormDate(lien, date.getDate(), (date.getMonth() + 1), date.getFullYear());
329
548
  }
330
-
331
- /** @deprecated */
332
549
  static selectFormDateCurrentMonth(lien) {
333
550
  let date = new Date();
334
551
  FormDate.selectFormDate(lien, -1, (date.getMonth() + 1), date.getFullYear());
335
552
  }
336
-
337
- /** @deprecated */
338
553
  static selectFormDateMonthMoinsNb(lien, nbMoisMoins) {
339
554
  let date = new Date();
340
555
  date.setDate(1);
341
556
  date.setMonth(date.getMonth() - nbMoisMoins);
342
557
  FormDate.selectFormDate(lien, -1, (date.getMonth() + 1), date.getFullYear());
343
558
  }
344
-
345
- /** @deprecated */
346
559
  static selectFormDateCurrentYear(lien) {
347
560
  let today = new Date();
348
561
  FormDate.selectFormDate(lien, -1, -1, today.getFullYear());
349
562
  }
350
-
351
- /** @deprecated */
352
563
  static selectFormDateYearMoinsNb(lien, nbAnneesMoins) {
353
564
  let today = new Date();
354
565
  FormDate.selectFormDate(lien, -1, -1, today.getFullYear() - nbAnneesMoins);
355
566
  }
356
-
357
- /** @deprecated */
358
567
  static selectFormDateAddDayFromSelectedDay(lien, nbDaysAdded) {
359
568
  let date = FormDate.getDateObjectSelected(lien);
360
569
  date.setDate(date.getDate() + nbDaysAdded);
361
570
  FormDate.selectFormDate(lien, date.getDate(), (date.getMonth() + 1), date.getFullYear());
362
571
  }
363
-
364
- /** @deprecated */
365
572
  static getDateObjectSelected(lien) {
366
573
  let selectorDay = '#' + (lien.parent().prev().prev().prev().prev().attr('id')) + ' option:selected';
367
574
  let selectorMonth = '#' + (lien.parent().prev().prev().prev().attr('id')) + ' option:selected';
@@ -371,8 +578,6 @@ class FormDate {
371
578
  }
372
579
  return new Date();
373
580
  }
374
-
375
- /** @deprecated */
376
581
  static selectFormDate(lien, day, month, year) {
377
582
  let selectorDay = '#' + (lien.parent().prev().prev().prev().prev().attr('id')) + ' option[value=' + day + ']';
378
583
  let selectorMonth = '#' + (lien.parent().prev().prev().prev().attr('id')) + ' option[value=' + month + ']';
@@ -381,7 +586,7 @@ class FormDate {
381
586
  if ($(selectorMonth).length > 0) $(selectorMonth).prop('selected', 'selected');
382
587
  if ($(selectorYear).length > 0) $(selectorYear).prop('selected', 'selected');
383
588
  }
384
-
589
+ */
385
590
  }
386
591
 
387
- module.exports = { FormDate };
592
+ module.exports = { FormDate, InputPeriod };
package/index.js CHANGED
@@ -11,7 +11,7 @@ const { HTTPRequest, Cookie, UrlAndQueryString } = require('./network');
11
11
  const { IBAN, BankCard } = require('./bank');
12
12
  const { AudioMedia, UserMedia } = require('./media');
13
13
  const { PersonName, Email, TelephoneNumber } = require('./contact_details');
14
- const { DateTime, TimestampUnix, SqlDate, SqlTime, SqlDateTime, InputPeriod } = require('./date_time');
14
+ const { DateTime, TimestampUnix, SqlDate, SqlTime, SqlDateTime } = require('./date_time');
15
15
  const { Duration } = require('./duration');
16
16
  const { File, CSV, Img } = require('./file');
17
17
  const { FormHelper } = require('./form_helper');
@@ -19,7 +19,6 @@ const { Country, PostalAddress, Location } = require('./location');
19
19
  const { SocialNetwork } = require('./social_network');
20
20
  const { sleep, refresh } = require('./util');
21
21
  const { chr, ord, trim, empty } = require('./php.min');
22
- const { FormDate } = require('./form_date');
23
22
 
24
23
  // exports plugins "maison"
25
24
  const { DataTable } = require('./data_table');
@@ -27,6 +26,7 @@ const { Pagination, Navigation } = require('./paging');
27
26
  const { DetailsSubArray } = require('./details_sub_array');
28
27
  const { SelectAll } = require('./select_all');
29
28
  const { MultipleActionInTable } = require('./multiple_action_in_table');
29
+ const { FormDate, InputPeriod } = require('./form_date');
30
30
  const { ShoppingCart } = require('./shopping_cart');
31
31
  const { FlashMessage } = require('./flash_message');
32
32
  const { CountDown } = require('./count_down');
@@ -43,9 +43,9 @@ const { OpenStreetMap } = require('./open_street_map');
43
43
  // deprecated
44
44
 
45
45
  module.exports = {
46
- Array, Object, Number, String,
47
- HTTPRequest, Cookie, UrlAndQueryString, IBAN, BankCard, AudioMedia, UserMedia, PersonName, Email, TelephoneNumber, DateTime, TimestampUnix, SqlDate, SqlTime, SqlDateTime, InputPeriod, Duration, File, CSV, Img, FormHelper, Country, PostalAddress, Location, SocialNetwork, FormDate,
48
- DataTable, Pagination, Navigation, DetailsSubArray, SelectAll, MultipleActionInTable, ShoppingCart, FlashMessage, CountDown, ImportFromCsv, JwtToken, JwtSession, ListBox,
49
- sleep, refresh, chr, ord, trim, empty,
50
- GoogleCharts, GoogleRecaptcha, GoogleMap, OpenStreetMap
46
+ Array, Object, Number, String,
47
+ HTTPRequest, Cookie, UrlAndQueryString, IBAN, BankCard, AudioMedia, UserMedia, PersonName, Email, TelephoneNumber, DateTime, TimestampUnix, SqlDate, SqlTime, SqlDateTime, Duration, File, CSV, Img, FormHelper, Country, PostalAddress, Location, SocialNetwork,
48
+ DataTable, Pagination, Navigation, DetailsSubArray, SelectAll, MultipleActionInTable, FormDate, InputPeriod, ShoppingCart, FlashMessage, CountDown, ImportFromCsv, JwtToken, JwtSession, ListBox,
49
+ sleep, refresh, chr, ord, trim, empty,
50
+ GoogleCharts, GoogleRecaptcha, GoogleMap, OpenStreetMap
51
51
  };
package/media.js CHANGED
@@ -81,9 +81,9 @@ class UserMedia {
81
81
  }
82
82
 
83
83
  /** SystemPermissionDenied => (macOS) browser does not have permission to access cam/mic */
84
- /** UserPermissionDenied => user denied permission for site to access cam/mic */
85
- /** CouldNotStartVideoSource = > (Windows) browser does not have permission to access cam/mic OR camera is in use by another application or browser tab */
86
- /** Generic => all other errors */
84
+ /** UserPermissionDenied => user denied permission for site to access cam/mic */
85
+ /** CouldNotStartVideoSource = > (Windows) browser does not have permission to access cam/mic OR camera is in use by another application or browser tab */
86
+ /** Generic => all other errors */
87
87
 
88
88
  static requestMediaPermissions(constraints) {
89
89
  /*try {
@@ -95,7 +95,7 @@ class UserMedia {
95
95
  return new Promise((resolve, reject) => {
96
96
  const bowser = require('bowser');
97
97
  const browser = bowser.getParser(window.navigator.userAgent);
98
- const browserName = browser.getBrowserName();
98
+ const browserName = browser.getBrowserName();
99
99
 
100
100
  navigator.mediaDevices.getUserMedia(constraints !== 'undefined' ? constraints : { audio: true, video: true })
101
101
  .then((stream) => resolve(stream))
package/network.js CHANGED
@@ -1,20 +1,55 @@
1
1
 
2
2
  class HTTPRequest {
3
- static async get(url, data, successCallback, errorCallback) {
3
+ static setRefreshTokenUrl(url) {
4
+ this.refreshTokenUrl = url;
5
+ }
6
+ static setRefreshTokenCallback(callback) {
7
+ this.refreshTokenCallback = callback;
8
+ }
9
+
10
+ static setHeader(key, value) {
11
+ if (typeof this.headers == 'undefined') {
12
+ this.headers = {};
13
+ }
14
+ this.headers[key] = value;
15
+ }
16
+
17
+ static getHeaders() {
18
+ //if (typeof httpHeaders != 'undefined') {
19
+ // return httpHeaders;
20
+ //}
21
+
22
+ if (typeof this.headers == 'undefined') {
23
+ this.headers = {};
24
+ }
25
+
26
+ let httpHeaders = new Headers();
27
+ Object.entries(this.headers).forEach(([key, value]) => {
28
+ httpHeaders.append(key, value);
29
+ });
30
+ return httpHeaders;
31
+ }
32
+
33
+ static formatQueryString(data) {
4
34
  if (data == null) {
5
- data = '';
35
+ return '';
6
36
  }
7
- else if (typeof data == 'object') {
37
+ if (typeof data == 'object') {
8
38
  data = UrlAndQueryString.buildQuery(data);
9
39
  }
10
40
  if (data !== '' && data.substring(0, 1) !== '&') {
11
41
  data = '&' + data;
12
42
  }
43
+ return data;
44
+ }
45
+
46
+ static async get(url, data, successCallback, errorCallback) {
47
+ data = this.formatQueryString(data);
13
48
 
14
49
  if (window.fetch) {
15
50
  let requestInit = {
16
51
  method: 'GET',
17
- headers: _httpHeaders,
52
+ headers: HTTPRequest.getHeaders(),
18
53
  mode: 'cors',
19
54
  cache: 'no-cache'
20
55
  }
@@ -24,9 +59,10 @@ class HTTPRequest {
24
59
  try {
25
60
  jsonData = await response.json();
26
61
  //console.log(url, jsonData);
62
+ //console.log(response.status, response.statusText, jsonData['error']);
27
63
 
28
- if (response.status == 401 && response.statusText == "Expired JWT Token") {
29
- HTTPRequest.refreshToken(URL_REFRESH, () => HTTPRequest.get(url, data, successCallback, errorCallback));
64
+ if (response.status == 401 && (response.statusText === "Expired JWT Token" || typeof jsonData['error'] != 'undefined' && jsonData['error'] === 'expired_token')) {
65
+ HTTPRequest.refreshToken(() => HTTPRequest.get(url, data, successCallback, errorCallback));
30
66
  return;
31
67
  }
32
68
 
@@ -37,10 +73,14 @@ class HTTPRequest {
37
73
  }
38
74
  catch (e) {
39
75
  console.log(e);
40
- errorCallback(response, response.status, e);
76
+ if (typeof errorCallback != 'undefined' && errorCallback != null) {
77
+ errorCallback(response, response.status, e);
78
+ }
41
79
  return;
42
80
  }
43
- errorCallback(response, response.status, null, jsonData);
81
+ if (typeof errorCallback != 'undefined' && errorCallback != null) {
82
+ errorCallback(response, response.status, null, jsonData);
83
+ }
44
84
  return;
45
85
  }
46
86
 
@@ -49,14 +89,16 @@ class HTTPRequest {
49
89
  $.ajax({
50
90
  type: 'GET',
51
91
  url: url + (!url.includes('?') ? '?' : '') + data,
52
- headers: httpHeaders,
92
+ headers: HTTPRequest.getHeaders(),
53
93
  dataType: 'json',
54
94
  cache: false,
55
95
  success: (data) => successCallback(data),
56
96
  error: (jqxhr, status, exception) => {
57
- if (typeof jqxhr.responseJSON != 'undefined' && jqxhr.responseJSON.code == 401 && jqxhr.responseJSON.message == "Expired JWT Token") {
58
- HTTPRequest.refreshToken(URL_REFRESH, () => HTTPRequest.get(url, data, successCallback, errorCallback));
59
- } else {
97
+ if (typeof jqxhr.responseJSON != 'undefined' && jqxhr.responseJSON.code == 401 && (jqxhr.responseJSON.message === "Expired JWT Token" || (typeof jqxhr.responseJSON['error'] != 'undefined' && jqxhr.responseJSON['error'] === 'expired_token' ))) {
98
+ HTTPRequest.refreshToken(() => HTTPRequest.get(url, data, successCallback, errorCallback));
99
+ return;
100
+ }
101
+ if (typeof errorCallback != 'undefined' && errorCallback != null) {
60
102
  errorCallback(jqxhr, status, exception);
61
103
  }
62
104
  }
@@ -64,21 +106,12 @@ class HTTPRequest {
64
106
  }
65
107
 
66
108
  static async download(url, data, errorCallback, completeCallback) {
67
- if (data == null) {
68
- data = '';
69
- }
70
- else if (typeof data == 'object') {
71
- data = UrlAndQueryString.buildQuery(data);
72
- }
73
- if (data !== '' && data.substring(0, 1) !== '&') {
74
- data = '&' + data;
75
- }
76
-
109
+ data = this.formatQueryString(data);
77
110
 
78
111
  if (window.fetch) {
79
112
  let requestInit = {
80
113
  method: 'GET',
81
- headers: _httpHeaders,
114
+ headers: HTTPRequest.getHeaders(),
82
115
  mode: 'cors',
83
116
  cache: 'no-cache'
84
117
  }
@@ -89,8 +122,8 @@ class HTTPRequest {
89
122
  /*console.log(url);
90
123
  console.log(blobData);*/
91
124
 
92
- if (response.status == 401 && response.statusText == "Expired JWT Token") {
93
- HTTPRequest.refreshToken(URL_REFRESH, () => HTTPRequest.download(url, data, errorCallback, completeCallback));
125
+ if (response.status == 401 && response.statusText === "Expired JWT Token") {
126
+ HTTPRequest.refreshToken(() => HTTPRequest.download(url, data, errorCallback, completeCallback));
94
127
  return;
95
128
  }
96
129
 
@@ -118,16 +151,18 @@ class HTTPRequest {
118
151
  $.ajax({
119
152
  type: 'GET',
120
153
  url: url + (!url.includes('?') ? '?' : '') + data,
121
- headers: httpHeaders,
154
+ headers: HTTPRequest.getHeaders(),
122
155
  cache: false,
123
156
  xhrFields: {
124
157
  responseType: 'blob'
125
158
  },
126
159
  success: (data, status, jqxhr) => File.download(data, jqxhr.getResponseHeader('Content-Type'), jqxhr.getResponseHeader('Content-Disposition')),
127
160
  error: (jqxhr, status, exception) => {
128
- if (typeof jqxhr.responseJSON != 'undefined' && jqxhr.responseJSON.code == 401 && jqxhr.responseJSON.message == "Expired JWT Token") {
129
- HTTPRequest.refreshToken(URL_REFRESH, () => HTTPRequest.download(url, data, errorCallback, completeCallback));
130
- } else if (typeof errorCallback != 'undefined' && errorCallback != null) {
161
+ if (typeof jqxhr.responseJSON != 'undefined' && jqxhr.responseJSON.code == 401 && (jqxhr.responseJSON.message === "Expired JWT Token" || (typeof jqxhr.responseJSON['error'] != 'undefined' && jqxhr.responseJSON['error'] === 'expired_token' ))) {
162
+ HTTPRequest.refreshToken(() => HTTPRequest.download(url, data, errorCallback, completeCallback));
163
+ return;
164
+ }
165
+ if (typeof errorCallback != 'undefined' && errorCallback != null) {
131
166
  errorCallback(jqxhr, status, exception);
132
167
  }
133
168
  },
@@ -140,11 +175,17 @@ class HTTPRequest {
140
175
  }
141
176
 
142
177
  static async post(url, formData, successCallback, errorCallback, formErrorCallback) {
178
+ if (!(formData instanceof FormData)) {
179
+ let formDataObject = new FormData();
180
+ Object.entries(formData).forEach(([key, value]) => formDataObject.append(key, value));
181
+ formData = formDataObject;
182
+ }
183
+
143
184
  if (window.fetch && false) {
144
185
  let requestInit = {
145
186
  method: 'POST',
146
187
  body: formData,
147
- headers: _httpHeaders,
188
+ headers: HTTPRequest.getHeaders(),
148
189
  mode: 'cors',
149
190
  cache: 'no-cache'
150
191
  };
@@ -156,8 +197,8 @@ class HTTPRequest {
156
197
  jsonData = await response.json();
157
198
  //console.log(url, jsonData);
158
199
 
159
- if (response.status == 401 && response.statusText == "Expired JWT Token") {
160
- HTTPRequest.refreshToken(URL_REFRESH, () => HTTPRequest.post(url, formData, successCallback, errorCallback, formErrorCallback));
200
+ if (response.status == 401 && (response.statusText === "Expired JWT Token" || (typeof jsonData['error'] != 'undefined' && jsonData['error'] === 'expired_token'))) {
201
+ HTTPRequest.refreshToken(() => HTTPRequest.post(url, formData, successCallback, errorCallback, formErrorCallback));
161
202
  return;
162
203
  }
163
204
 
@@ -173,11 +214,15 @@ class HTTPRequest {
173
214
  }
174
215
  catch (e) {
175
216
  console.log(e);
176
- errorCallback(response, response.status, e);
217
+ if (typeof errorCallback != 'undefined' && errorCallback != null) {
218
+ errorCallback(response, response.status, e);
219
+ }
177
220
  return;
178
221
  }
179
222
 
180
- errorCallback(response, response.status, null, jsonData);
223
+ if (typeof errorCallback != 'undefined' && errorCallback != null) {
224
+ errorCallback(response, response.status, null, jsonData);
225
+ }
181
226
  return;
182
227
  }
183
228
 
@@ -186,7 +231,7 @@ class HTTPRequest {
186
231
  $.ajax({
187
232
  type: 'POST',
188
233
  url: url,
189
- headers: httpHeaders,
234
+ headers: HTTPRequest.getHeaders(),
190
235
  dataType: 'json', // 22/09/2020 : à voir si cette ligne pose pb (utilisé pour requete import et peut être d'autres
191
236
  data: formData,
192
237
  cache: false,
@@ -194,27 +239,42 @@ class HTTPRequest {
194
239
  processData: false,
195
240
  success: (data) => successCallback(data),
196
241
  error: (jqxhr, status, exception) => {
197
- if (typeof jqxhr.responseJSON != 'undefined' && jqxhr.responseJSON.code == 401 && jqxhr.responseJSON.message == "Expired JWT Token") {
198
- HTTPRequest.refreshToken(URL_REFRESH, () => HTTPRequest.post(url, formData, successCallback, errorCallback, formErrorCallback));
199
- } else if (jqxhr.status == 400 && typeof formErrorCallback != 'undefined' && formErrorCallback != null) {
242
+ if (typeof jqxhr.responseJSON != 'undefined' && jqxhr.responseJSON.code == 401 && (jqxhr.responseJSON.message === "Expired JWT Token" || (typeof jqxhr.responseJSON['error'] != 'undefined' && jqxhr.responseJSON['error'] === 'expired_token' ))) {
243
+ HTTPRequest.refreshToken(() => HTTPRequest.post(url, formData, successCallback, errorCallback, formErrorCallback));
244
+ return;
245
+ }
246
+ if (jqxhr.status == 400 && typeof formErrorCallback != 'undefined' && formErrorCallback != null) {
200
247
  formErrorCallback(jqxhr, status, exception);
201
- } else {
248
+ return;
249
+ }
250
+ if (typeof errorCallback != 'undefined' && errorCallback != null) {
202
251
  errorCallback(jqxhr, status, exception);
203
252
  }
204
253
  }
205
254
  });
206
255
  }
207
256
 
208
- static refreshToken(url, onCompleteCallback) {
257
+ static refreshToken(onCompleteCallback) {
258
+ if (typeof this.refreshTokenCallback == 'function') {
259
+ this.refreshTokenCallback(onCompleteCallback);
260
+ return;
261
+ }
262
+
263
+ if (typeof this.refreshTokenUrl == 'undefined') {
264
+ console.error('URL refresh token non définie. Appeler HTTPRequest.setRefreshTokenUrl(url)');
265
+ return;
266
+ }
267
+
209
268
  let payload = new FormData();
210
269
  payload.append('refresh_token', JwtSession.getRefreshToken());
211
270
 
212
- HTTPRequest.post(url, payload,
271
+ HTTPRequest.post(this.refreshTokenUrl, payload,
213
272
  (data) => {
214
273
  JwtSession.setToken(data.token);
215
274
  JwtSession.setRefreshToken(data.refresh_token);
216
275
  onCompleteCallback();
217
- }, (jqxhr, status, exception) => {
276
+ },
277
+ (jqxhr, status, exception) => {
218
278
  console.log(exception);
219
279
  JwtSession.logout();
220
280
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osimatic/helpers-js",
3
- "version": "1.0.24",
3
+ "version": "1.0.27",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"