@osimatic/helpers-js 1.0.109 → 1.0.111

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.
@@ -81,7 +81,7 @@ class DetailsSubArray {
81
81
  }
82
82
 
83
83
  //link.attr('disabled', true).button('loading');
84
- HTTPRequest.get(link.data('url_details'), {},
84
+ HTTPClient.request('GET', link.data('url_details'), null,
85
85
  (jsonObj) => {
86
86
  if (jsonObj == null) {
87
87
  if (typeof callbackOnDetailsActionRequestError != 'undefined' && callbackOnDetailsActionRequestError != null) {
@@ -108,7 +108,7 @@ class DetailsSubArray {
108
108
 
109
109
  onComplete();
110
110
  //window.location.replace(decodeURIComponent(urlRetour));
111
- },
111
+ }
112
112
  );
113
113
  }
114
114
 
package/file.js CHANGED
@@ -113,7 +113,7 @@ class Img {
113
113
  $.ajax({
114
114
  type: 'GET',
115
115
  url: url,
116
- headers: HTTPRequest.getHeaders(true),
116
+ headers: HTTPClient.getHeaders(true),
117
117
  cache: false,
118
118
  xhrFields: {responseType: 'blob'},
119
119
  success: (data) => {
@@ -121,7 +121,7 @@ class Img {
121
121
  // $(img).attr('src', urlCreator.createObjectURL(data));
122
122
  Img.setBlobToImg($(img), data);
123
123
  },
124
- error: (jqxhr, status, errorThrown) => HTTPRequest.logJqueryRequestFailure(jqxhr, status, errorThrown),
124
+ error: (jqxhr, status, errorThrown) => HTTPClient.logJqueryRequestFailure(jqxhr, status, errorThrown),
125
125
  });
126
126
  }
127
127
 
package/http_client.js CHANGED
@@ -140,6 +140,9 @@ class HTTPClient {
140
140
  static logRequestFailure(response, json) {
141
141
  console.error('Request failure. Status: '+response.statusText+' ; HTTP Code : '+response.status, json);
142
142
  }
143
+ static logJqueryRequestFailure(jqxhr, status, errorThrown) {
144
+ console.error('Request failure. Status: ' + status + ' ; HTTP Code: ' + jqxhr.status + (null != errorThrown && '' !== errorThrown ? ' ; Error message: ' + errorThrown : ''), jqxhr.responseJSON);
145
+ }
143
146
 
144
147
  static isExpiredToken(response, json) {
145
148
  if (response.status !== 401) {
@@ -176,7 +179,7 @@ class HTTPClient {
176
179
  static async request(method, url, data, successCallback, errorCallback, formErrorCallback) {
177
180
  method = method.toUpperCase();
178
181
 
179
- if ('POST' !== method) {
182
+ if ('GET' === method) {
180
183
  url += (!url.includes('?') ? '?' : '') + HTTPClient.formatQueryString(data);
181
184
  data = null;
182
185
  }
@@ -193,7 +196,7 @@ class HTTPClient {
193
196
  cache: 'no-cache'
194
197
  }
195
198
 
196
- if ('POST' === method) {
199
+ if ('GET' !== method) {
197
200
  requestOptions['body'] = HTTPClient.formatFormData(data);
198
201
  }
199
202
 
@@ -244,7 +247,7 @@ class HTTPClient {
244
247
  static async download(method, url, data, errorCallback, completeCallback) {
245
248
  method = typeof method == 'undefined' || null == method ? 'GET' : method;
246
249
 
247
- if ('POST' !== method) {
250
+ if ('GET' === method) {
248
251
  url += (!url.includes('?') ? '?' : '') + HTTPClient.formatQueryString(data);
249
252
  data = null;
250
253
  }
@@ -260,7 +263,7 @@ class HTTPClient {
260
263
  cache: 'no-cache'
261
264
  }
262
265
 
263
- if ('POST' === method) {
266
+ if ('GET' !== method) {
264
267
  requestOptions['body'] = HTTPClient.formatFormData(data);
265
268
  }
266
269
 
package/media.js CHANGED
@@ -45,7 +45,7 @@ class AudioMedia {
45
45
  let context = new (window.AudioContext || window.webkitAudioContext)();
46
46
  let request = new XMLHttpRequest();
47
47
  request.open("GET", url, true);
48
- Object.entries(HTTPRequest.getHeaders(true)).forEach(([key, value]) => request.setRequestHeader(key, value));
48
+ Object.entries(HTTPClient.getHeaders(true)).forEach(([key, value]) => request.setRequestHeader(key, value));
49
49
  request.responseType = "arraybuffer";
50
50
 
51
51
  request.onload = function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osimatic/helpers-js",
3
- "version": "1.0.109",
3
+ "version": "1.0.111",
4
4
  "main": "main.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"