@eurosat/http 8.0.0 → 12.0.0

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,13 +1,9 @@
1
1
  (function (global, factory) {
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common/http'), require('@angular/material/snack-bar'), require('rxjs'), require('rxjs/operators')) :
3
3
  typeof define === 'function' && define.amd ? define('@eurosat/http', ['exports', '@angular/core', '@angular/common/http', '@angular/material/snack-bar', 'rxjs', 'rxjs/operators'], factory) :
4
- (global = global || self, factory((global.eurosat = global.eurosat || {}, global.eurosat.http = {}), global.ng.core, global.ng.common.http, global.ng.material['snack-bar'], global.rxjs, global.rxjs.operators));
5
- }(this, function (exports, core, http, snackBar, rxjs, operators) { 'use strict';
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.eurosat = global.eurosat || {}, global.eurosat.http = {}), global.ng.core, global.ng.common.http, global.ng.material.snackBar, global.rxjs, global.rxjs.operators));
5
+ }(this, (function (exports, i0, i1, i2, rxjs, operators) { 'use strict';
6
6
 
7
- /**
8
- * @fileoverview added by tsickle
9
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
10
- */
11
7
  // @dynamic --> NEMAZAT https://github.com/dherges/ng-packagr/issues/641
12
8
  var HttpService = /** @class */ (function () {
13
9
  function HttpService(http, snackBar) {
@@ -17,23 +13,12 @@
17
13
  HttpService.instance = this;
18
14
  }
19
15
  }
20
- /**
21
- * @param {?} error
22
- * @return {?}
23
- */
24
- HttpService.handleError = /**
25
- * @param {?} error
26
- * @return {?}
27
- */
28
- function (error) {
16
+ HttpService.handleError = function (error) {
29
17
  HttpService.errorStatus(error);
30
18
  // Todo: In a real world app, you might use a remote logging infrastructure
31
- /** @type {?} */
32
19
  var errMsg;
33
- if (error instanceof http.HttpResponse) {
34
- /** @type {?} */
20
+ if (error instanceof i1.HttpResponse) {
35
21
  var body = error.body || '';
36
- /** @type {?} */
37
22
  var err = body.error || JSON.stringify(body);
38
23
  errMsg = error.status + " - " + (error.statusText || '') + " " + err;
39
24
  }
@@ -43,17 +28,7 @@
43
28
  console.error(errMsg);
44
29
  return rxjs.throwError(errMsg);
45
30
  };
46
- /**
47
- * @private
48
- * @param {?} err
49
- * @return {?}
50
- */
51
- HttpService.errorStatus = /**
52
- * @private
53
- * @param {?} err
54
- * @return {?}
55
- */
56
- function (err) {
31
+ HttpService.errorStatus = function (err) {
57
32
  switch (err.status) {
58
33
  case 300:
59
34
  case 301:
@@ -78,30 +53,9 @@
78
53
  // const error = res['error'];
79
54
  //
80
55
  // }
81
- // private static handleLoginRedirect(res: HttpResponse<any>) {
82
- // const error = res['error'];
83
- //
84
- // }
85
- /**
86
- * @private
87
- * @param {?} res
88
- * @return {?}
89
- */
90
- HttpService.handleRedirect =
91
- // private static handleLoginRedirect(res: HttpResponse<any>) {
92
- // const error = res['error'];
93
- //
94
- // }
95
- /**
96
- * @private
97
- * @param {?} res
98
- * @return {?}
99
- */
100
- function (res) {
101
- /** @type {?} */
56
+ HttpService.handleRedirect = function (res) {
102
57
  var error = res['error'];
103
58
  if (error.login) {
104
- /** @type {?} */
105
59
  var path = window.location.pathname;
106
60
  path = path[0] === '/' ? path.substr(1) : path; // '/front/' => 'front/'
107
61
  // console.log('Redirect ' + `${error.url}?r=${path}`);
@@ -111,91 +65,42 @@
111
65
  window.location.href = "" + error.url;
112
66
  }
113
67
  };
114
- /**
115
- * @private
116
- * @param {?} res
117
- * @return {?}
118
- */
119
- HttpService.handleErrorMessage = /**
120
- * @private
121
- * @param {?} res
122
- * @return {?}
123
- */
124
- function (res) {
125
- /** @type {?} */
68
+ HttpService.handleErrorMessage = function (res) {
126
69
  var message = res['error'];
127
70
  if (res['error'] instanceof Blob) {
128
- /** @type {?} */
129
71
  var reader = new FileReader();
130
- reader.addEventListener('loadend', (/**
131
- * @param {?} e
132
- * @return {?}
133
- */
134
- function (e) {
72
+ reader.addEventListener('loadend', function (e) {
135
73
  HttpService.createSnackBar(e.srcElement['result']);
136
- }));
74
+ });
137
75
  reader.readAsText(res['error']);
138
76
  }
139
77
  else {
140
78
  HttpService.createSnackBar(message);
141
79
  }
142
80
  };
143
- /**
144
- * @private
145
- * @param {?} message
146
- * @return {?}
147
- */
148
- HttpService.createSnackBar = /**
149
- * @private
150
- * @param {?} message
151
- * @return {?}
152
- */
153
- function (message) {
154
- /** @type {?} */
155
- var config = new snackBar.MatSnackBarConfig();
81
+ HttpService.createSnackBar = function (message) {
82
+ var config = new i2.MatSnackBarConfig();
156
83
  config.duration = 2000;
157
84
  config.panelClass = 'es-snackbar-alert-danger'; // AppSnackbarPanelClass.DANGER;
158
85
  HttpService.instance.snackBar.open(message, null, config);
159
86
  };
160
- /**
161
- * @param {?} url
162
- * @param {?=} options
163
- * @return {?}
164
- */
165
- HttpService.prototype.get = /**
166
- * @param {?} url
167
- * @param {?=} options
168
- * @return {?}
169
- */
170
- function (url, options) {
87
+ HttpService.prototype.get = function (url, options) {
171
88
  if (!options) {
172
89
  options = {};
173
90
  }
174
91
  if (!options.params) {
175
- options.params = new http.HttpParams();
92
+ options.params = new i1.HttpParams();
176
93
  }
177
94
  options.params = options.params.set('_req_s', HttpService.ANGULAR_REQUEST_CONST); // pridava se nejakej param na formy pro angular
178
95
  return this.http.get(url, options)
179
96
  .pipe(operators.catchError(HttpService.handleError));
180
97
  };
181
- /**
182
- * @param {?} url
183
- * @param {?} body
184
- * @param {?=} options
185
- * @return {?}
186
- */
187
- HttpService.prototype.post = /**
188
- * @param {?} url
189
- * @param {?} body
190
- * @param {?=} options
191
- * @return {?}
192
- */
193
- function (url, body, options) {
98
+ HttpService.prototype.post = function (url, body, options) {
194
99
  if (!options) {
195
100
  options = {};
196
101
  }
197
102
  if (!options.params) {
198
- options.params = new http.HttpParams();
103
+ options.params = new i1.HttpParams();
199
104
  }
200
105
  options.params = options.params.set('_req_s', HttpService.ANGULAR_REQUEST_CONST);
201
106
  return this.http.post(url, body, options)
@@ -204,115 +109,79 @@
204
109
  // upload file s vypnutym service workerem -> header{disable-ngsw: true}
205
110
  // v ekj projektu fix-ngsw.sh
206
111
  // sed -i '/onFetch(event) {/,/const req = event.request;/c onFetch(event){const req=event.request;if(req.headers.get('disable-ngsw')==="true")return;' ./front/ngsw-worker.js
207
- // upload file s vypnutym service workerem -> header{disable-ngsw: true}
208
- // v ekj projektu fix-ngsw.sh
209
- // sed -i '/onFetch(event) {/,/const req = event.request;/c onFetch(event){const req=event.request;if(req.headers.get('disable-ngsw')==="true")return;' ./front/ngsw-worker.js
210
- /**
211
- * @param {?} url
212
- * @param {?} body
213
- * @param {?=} options
214
- * @return {?}
215
- */
216
- HttpService.prototype.postFiles =
217
- // upload file s vypnutym service workerem -> header{disable-ngsw: true}
218
- // v ekj projektu fix-ngsw.sh
219
- // sed -i '/onFetch(event) {/,/const req = event.request;/c onFetch(event){const req=event.request;if(req.headers.get('disable-ngsw')==="true")return;' ./front/ngsw-worker.js
220
- /**
221
- * @param {?} url
222
- * @param {?} body
223
- * @param {?=} options
224
- * @return {?}
225
- */
226
- function (url, body, options) {
112
+ HttpService.prototype.postFiles = function (url, body, options) {
227
113
  if (!options) {
228
114
  options = {};
229
115
  }
230
116
  if (!options.params) {
231
- options.params = new http.HttpParams();
117
+ options.params = new i1.HttpParams();
232
118
  }
233
119
  options.params = options.params.set('_req_s', HttpService.ANGULAR_REQUEST_CONST);
234
- /** @type {?} */
235
- var headers = new http.HttpHeaders();
120
+ var headers = new i1.HttpHeaders();
236
121
  options['headers'] = headers.set('disable-ngsw', 'true');
237
122
  return this.http.post(url, body, options)
238
123
  .pipe(operators.catchError(HttpService.handleError));
239
124
  };
240
- /**
241
- * @param {?} url
242
- * @param {?=} options
243
- * @return {?}
244
- */
245
- HttpService.prototype.delete = /**
246
- * @param {?} url
247
- * @param {?=} options
248
- * @return {?}
249
- */
250
- function (url, options) {
125
+ HttpService.prototype.delete = function (url, options) {
251
126
  return this.http.delete(url, options)
252
127
  .pipe(operators.catchError(HttpService.handleError));
253
128
  };
254
- HttpService.ANGULAR_REQUEST_CONST = '2';
255
- HttpService.decorators = [
256
- { type: core.Injectable, args: [{
257
- providedIn: 'root'
258
- },] }
259
- ];
260
- /** @nocollapse */
261
- HttpService.ctorParameters = function () { return [
262
- { type: http.HttpClient },
263
- { type: snackBar.MatSnackBar }
264
- ]; };
265
- /** @nocollapse */ HttpService.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function HttpService_Factory() { return new HttpService(core.ɵɵinject(http.HttpClient), core.ɵɵinject(snackBar.MatSnackBar)); }, token: HttpService, providedIn: "root" });
266
129
  return HttpService;
267
130
  }());
131
+ HttpService.ANGULAR_REQUEST_CONST = '2';
132
+ /** @nocollapse */ HttpService.ɵprov = i0.ɵɵdefineInjectable({ factory: function HttpService_Factory() { return new HttpService(i0.ɵɵinject(i1.HttpClient), i0.ɵɵinject(i2.MatSnackBar)); }, token: HttpService, providedIn: "root" });
133
+ HttpService.decorators = [
134
+ { type: i0.Injectable, args: [{
135
+ providedIn: 'root'
136
+ },] }
137
+ ];
138
+ /** @nocollapse */
139
+ HttpService.ctorParameters = function () { return [
140
+ { type: i1.HttpClient },
141
+ { type: i2.MatSnackBar }
142
+ ]; };
268
143
 
269
- /**
270
- * @fileoverview added by tsickle
271
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
272
- */
273
144
  var HttpComponent = /** @class */ (function () {
274
145
  function HttpComponent() {
275
146
  }
276
- /**
277
- * @return {?}
278
- */
279
- HttpComponent.prototype.ngOnInit = /**
280
- * @return {?}
281
- */
282
- function () {
147
+ HttpComponent.prototype.ngOnInit = function () {
283
148
  };
284
- HttpComponent.decorators = [
285
- { type: core.Component, args: [{
286
- selector: 'es-http',
287
- template: "\n <p>\n http works!\n </p>\n "
288
- }] }
289
- ];
290
- /** @nocollapse */
291
- HttpComponent.ctorParameters = function () { return []; };
292
149
  return HttpComponent;
293
150
  }());
151
+ HttpComponent.decorators = [
152
+ { type: i0.Component, args: [{
153
+ selector: 'es-http',
154
+ template: "\n <p>\n http works!\n </p>\n "
155
+ },] }
156
+ ];
157
+ /** @nocollapse */
158
+ HttpComponent.ctorParameters = function () { return []; };
294
159
 
295
- /**
296
- * @fileoverview added by tsickle
297
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
298
- */
299
160
  var HttpModule = /** @class */ (function () {
300
161
  function HttpModule() {
301
162
  }
302
- HttpModule.decorators = [
303
- { type: core.NgModule, args: [{
304
- imports: [
305
- http.HttpClientModule
306
- ],
307
- declarations: [HttpComponent],
308
- providers: [
309
- HttpService
310
- ],
311
- exports: [],
312
- },] }
313
- ];
314
163
  return HttpModule;
315
164
  }());
165
+ HttpModule.decorators = [
166
+ { type: i0.NgModule, args: [{
167
+ imports: [
168
+ i1.HttpClientModule
169
+ ],
170
+ declarations: [HttpComponent],
171
+ providers: [
172
+ HttpService
173
+ ],
174
+ exports: [],
175
+ },] }
176
+ ];
177
+
178
+ /*
179
+ * Public API Surface of http
180
+ */
181
+
182
+ /**
183
+ * Generated bundle index. Do not edit.
184
+ */
316
185
 
317
186
  exports.HttpComponent = HttpComponent;
318
187
  exports.HttpModule = HttpModule;
@@ -320,5 +189,5 @@
320
189
 
321
190
  Object.defineProperty(exports, '__esModule', { value: true });
322
191
 
323
- }));
192
+ })));
324
193
  //# sourceMappingURL=eurosat-http.umd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"eurosat-http.umd.js","sources":["ng://@eurosat/http/lib/http.service.ts","ng://@eurosat/http/lib/http.component.ts","ng://@eurosat/http/lib/http.module.ts"],"sourcesContent":["import {Injectable} from '@angular/core';\nimport {HttpClient, HttpHeaders, HttpParams, HttpResponse} from '@angular/common/http';\nimport {MatSnackBar, MatSnackBarConfig} from '@angular/material/snack-bar';\nimport {Observable, throwError} from 'rxjs';\nimport {catchError} from 'rxjs/operators';\n// @dynamic --> NEMAZAT https://github.com/dherges/ng-packagr/issues/641\n@Injectable({\n providedIn: 'root'\n})\nexport class HttpService {\n\n public static ANGULAR_REQUEST_CONST = '2';\n\n private static instance: HttpService; // není to prasárna?\n\n constructor(\n private http: HttpClient,\n private snackBar: MatSnackBar,\n ) {\n if (!HttpService.instance) { // není to prasárna?\n HttpService.instance = this;\n }\n }\n\n public static handleError (error: HttpResponse<any> | any) {\n HttpService.errorStatus(error);\n\n // Todo: In a real world app, you might use a remote logging infrastructure\n let errMsg: string;\n if (error instanceof HttpResponse) {\n const body = error.body || '';\n const err = body.error || JSON.stringify(body);\n errMsg = `${error.status} - ${error.statusText || ''} ${err}`;\n } else {\n errMsg = error.message ? error.message : error.toString();\n }\n console.error(errMsg);\n return throwError(errMsg);\n }\n\n private static errorStatus(err: HttpResponse<any>) {\n switch (err.status) {\n case 300:\n case 301:\n HttpService.handleRedirect(err);\n break;\n // case 302:\n // HttpService.handleRedirect(err);\n // break;\n case 403:\n HttpService.handleErrorMessage(err);\n break;\n case 503:\n HttpService.handleErrorMessage(err);\n break;\n case 601:\n HttpService.handleRedirect(err);\n break;\n }\n\n // todo 413 Request Entity Too Large - upload file z formu\n }\n\n // private static handleLoginRedirect(res: HttpResponse<any>) {\n // const error = res['error'];\n //\n // }\n\n private static handleRedirect(res: HttpResponse<any>) {\n const error = res['error'];\n if (error.login) {\n let path = window.location.pathname;\n path = path[0] === '/' ? path.substr(1) : path; // '/front/' => 'front/'\n // console.log('Redirect ' + `${error.url}?r=${path}`);\n window.location.href = `${error.url}?r=${path}`;\n } else {\n window.location.href = `${error.url}`;\n }\n }\n\n private static handleErrorMessage(res: HttpResponse<any>) {\n const message = res['error'];\n if (res['error'] instanceof Blob) {\n const reader = new FileReader();\n\n reader.addEventListener('loadend', (e) => {\n HttpService.createSnackBar(e.srcElement['result']);\n });\n\n reader.readAsText(res['error']);\n } else {\n HttpService.createSnackBar(message);\n }\n }\n\n private static createSnackBar(message) {\n const config = new MatSnackBarConfig();\n config.duration = 2000;\n config.panelClass = 'es-snackbar-alert-danger'; // AppSnackbarPanelClass.DANGER;\n HttpService.instance.snackBar.open(message, null, config);\n }\n\n get(url: string, options?: {params?: HttpParams, responseType?, observe?}): Observable<any> {\n if (!options) { options = {}; }\n if (!options.params) {\n options.params = new HttpParams();\n }\n options.params = options.params.set('_req_s', HttpService.ANGULAR_REQUEST_CONST); // pridava se nejakej param na formy pro angular\n return this.http.get(url, options)\n .pipe(catchError(HttpService.handleError));\n }\n\n post(url: string, body: any | null, options?: {params?: HttpParams, responseType?, reportProgress?: boolean, observe?: any}): Observable<any> {\n if (!options) { options = {}; }\n if (!options.params) {\n options.params = new HttpParams();\n }\n options.params = options.params.set('_req_s', HttpService.ANGULAR_REQUEST_CONST);\n\n return this.http.post(url, body, options)\n .pipe(catchError(HttpService.handleError));\n }\n\n // upload file s vypnutym service workerem -> header{disable-ngsw: true}\n // v ekj projektu fix-ngsw.sh\n // sed -i '/onFetch(event) {/,/const req = event.request;/c onFetch(event){const req=event.request;if(req.headers.get('disable-ngsw')===\"true\")return;' ./front/ngsw-worker.js\n postFiles(url: string, body: any | null, options?: {params?: HttpParams, responseType?, reportProgress?: boolean, observe?: any}): Observable<any> {\n if (!options) { options = {}; }\n if (!options.params) {\n options.params = new HttpParams();\n }\n options.params = options.params.set('_req_s', HttpService.ANGULAR_REQUEST_CONST);\n const headers = new HttpHeaders();\n options['headers'] = headers.set('disable-ngsw', 'true');\n return this.http.post(url, body, options)\n .pipe(catchError(HttpService.handleError));\n }\n\n delete(url: string, options?: {}): Observable<Object> {\n return this.http.delete(url, options)\n .pipe(catchError(HttpService.handleError));\n }\n\n\n // private extractMsgpack(res: Response) {\n //\n // let buffer = res.arrayBuffer();\n // // console.log(buffer);\n //\n // let array = new Uint8Array(buffer);\n // // console.log(array);\n // // console.log('Decode ' + msgpack.decode(array));\n //\n // return msgpack.decode(array);\n // }\n\n\n\n}\n","import { Component, OnInit } from '@angular/core';\n\n@Component({\n selector: 'es-http',\n template: `\n <p>\n http works!\n </p>\n `,\n styles: []\n})\nexport class HttpComponent implements OnInit {\n\n constructor() { }\n\n ngOnInit() {\n }\n\n}\n","import {NgModule} from '@angular/core';\nimport {HttpComponent} from './http.component';\nimport {HttpClientModule} from '@angular/common/http';\nimport {HttpService} from './http.service';\n\n@NgModule({\n imports: [\n HttpClientModule\n ],\n declarations: [HttpComponent],\n providers: [\n HttpService\n ],\n exports: [],\n})\nexport class HttpModule { }\n"],"names":["HttpResponse","throwError","MatSnackBarConfig","HttpParams","catchError","HttpHeaders","Injectable","HttpClient","MatSnackBar","Component","NgModule","HttpClientModule"],"mappings":";;;;;;;;;;IAAA;AAMA;QASI,qBACY,IAAgB,EAChB,QAAqB;YADrB,SAAI,GAAJ,IAAI,CAAY;YAChB,aAAQ,GAAR,QAAQ,CAAa;YAE7B,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE;gBACvB,WAAW,CAAC,QAAQ,GAAG,IAAI,CAAC;aAC/B;SACJ;;;;;QAEa,uBAAW;;;;QAAzB,UAA2B,KAA8B;YACrD,WAAW,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;;;gBAG3B,MAAc;YAClB,IAAI,KAAK,YAAYA,iBAAY,EAAE;;oBACzB,IAAI,GAAG,KAAK,CAAC,IAAI,IAAI,EAAE;;oBACvB,GAAG,GAAG,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;gBAC9C,MAAM,GAAM,KAAK,CAAC,MAAM,YAAM,KAAK,CAAC,UAAU,IAAI,EAAE,UAAI,GAAK,CAAC;aACjE;iBAAM;gBACH,MAAM,GAAG,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC;aAC7D;YACD,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YACtB,OAAOC,eAAU,CAAC,MAAM,CAAC,CAAC;S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AW;;;0BAFnB;KAMA;;;;;;ACNA;QAaE;SAAiB;;;;QAEjB,gCAAQ;;;QAAR;SACC;;oBAdFC,cAAS,SAAC;wBACT,QAAQ,EAAE,SAAS;wBACnB,QAAQ,EAAE,4CAIT;qBAEF;;;;QAQD,oBAAC;KAhBD;;;;;;ACFA;QAKA;SAU2B;;oBAV1BC,aAAQ,SAAC;wBACN,OAAO,EAAE;4BACLC,qBAAgB;yBACnB;wBACD,YAAY,EAAE,CAAC,aAAa,CAAC;wBAC7B,SAAS,EAAE;4BACP,WAAW;yBACd;wBACD,OAAO,EAAE,EAAE;qBACd;;QACyB,iBAAC;KAV3B;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"eurosat-http.umd.js","sources":["../../../projects/http/src/lib/http.service.ts","../../../projects/http/src/lib/http.component.ts","../../../projects/http/src/lib/http.module.ts","../../../projects/http/src/public_api.ts","../../../projects/http/src/eurosat-http.ts"],"sourcesContent":["import {Injectable} from '@angular/core';\nimport {HttpClient, HttpHeaders, HttpParams, HttpResponse} from '@angular/common/http';\nimport {MatSnackBar, MatSnackBarConfig} from '@angular/material/snack-bar';\nimport {Observable, throwError} from 'rxjs';\nimport {catchError} from 'rxjs/operators';\n// @dynamic --> NEMAZAT https://github.com/dherges/ng-packagr/issues/641\n@Injectable({\n providedIn: 'root'\n})\nexport class HttpService {\n\n public static ANGULAR_REQUEST_CONST = '2';\n\n private static instance: HttpService; // není to prasárna?\n\n constructor(\n private http: HttpClient,\n private snackBar: MatSnackBar,\n ) {\n if (!HttpService.instance) { // není to prasárna?\n HttpService.instance = this;\n }\n }\n\n public static handleError (error: HttpResponse<any> | any) {\n HttpService.errorStatus(error);\n\n // Todo: In a real world app, you might use a remote logging infrastructure\n let errMsg: string;\n if (error instanceof HttpResponse) {\n const body = error.body || '';\n const err = body.error || JSON.stringify(body);\n errMsg = `${error.status} - ${error.statusText || ''} ${err}`;\n } else {\n errMsg = error.message ? error.message : error.toString();\n }\n console.error(errMsg);\n return throwError(errMsg);\n }\n\n private static errorStatus(err: HttpResponse<any>) {\n switch (err.status) {\n case 300:\n case 301:\n HttpService.handleRedirect(err);\n break;\n // case 302:\n // HttpService.handleRedirect(err);\n // break;\n case 403:\n HttpService.handleErrorMessage(err);\n break;\n case 503:\n HttpService.handleErrorMessage(err);\n break;\n case 601:\n HttpService.handleRedirect(err);\n break;\n }\n\n // todo 413 Request Entity Too Large - upload file z formu\n }\n\n // private static handleLoginRedirect(res: HttpResponse<any>) {\n // const error = res['error'];\n //\n // }\n\n private static handleRedirect(res: HttpResponse<any>) {\n const error = res['error'];\n if (error.login) {\n let path = window.location.pathname;\n path = path[0] === '/' ? path.substr(1) : path; // '/front/' => 'front/'\n // console.log('Redirect ' + `${error.url}?r=${path}`);\n window.location.href = `${error.url}?r=${path}`;\n } else {\n window.location.href = `${error.url}`;\n }\n }\n\n private static handleErrorMessage(res: HttpResponse<any>) {\n const message = res['error'];\n if (res['error'] instanceof Blob) {\n const reader = new FileReader();\n\n reader.addEventListener('loadend', (e) => {\n HttpService.createSnackBar(e.srcElement['result']);\n });\n\n reader.readAsText(res['error']);\n } else {\n HttpService.createSnackBar(message);\n }\n }\n\n private static createSnackBar(message) {\n const config = new MatSnackBarConfig();\n config.duration = 2000;\n config.panelClass = 'es-snackbar-alert-danger'; // AppSnackbarPanelClass.DANGER;\n HttpService.instance.snackBar.open(message, null, config);\n }\n\n get(url: string, options?: {params?: HttpParams, responseType?, observe?}): Observable<any> {\n if (!options) { options = {}; }\n if (!options.params) {\n options.params = new HttpParams();\n }\n options.params = options.params.set('_req_s', HttpService.ANGULAR_REQUEST_CONST); // pridava se nejakej param na formy pro angular\n return this.http.get(url, options)\n .pipe(catchError(HttpService.handleError));\n }\n\n post(url: string, body: any | null, options?: {params?: HttpParams, responseType?, reportProgress?: boolean, observe?: any}): Observable<any> {\n if (!options) { options = {}; }\n if (!options.params) {\n options.params = new HttpParams();\n }\n options.params = options.params.set('_req_s', HttpService.ANGULAR_REQUEST_CONST);\n\n return this.http.post(url, body, options)\n .pipe(catchError(HttpService.handleError));\n }\n\n // upload file s vypnutym service workerem -> header{disable-ngsw: true}\n // v ekj projektu fix-ngsw.sh\n // sed -i '/onFetch(event) {/,/const req = event.request;/c onFetch(event){const req=event.request;if(req.headers.get('disable-ngsw')===\"true\")return;' ./front/ngsw-worker.js\n postFiles(url: string, body: any | null, options?: {params?: HttpParams, responseType?, reportProgress?: boolean, observe?: any}): Observable<any> {\n if (!options) { options = {}; }\n if (!options.params) {\n options.params = new HttpParams();\n }\n options.params = options.params.set('_req_s', HttpService.ANGULAR_REQUEST_CONST);\n const headers = new HttpHeaders();\n options['headers'] = headers.set('disable-ngsw', 'true');\n return this.http.post(url, body, options)\n .pipe(catchError(HttpService.handleError));\n }\n\n delete(url: string, options?: {}): Observable<Object> {\n return this.http.delete(url, options)\n .pipe(catchError(HttpService.handleError));\n }\n\n\n // private extractMsgpack(res: Response) {\n //\n // let buffer = res.arrayBuffer();\n // // console.log(buffer);\n //\n // let array = new Uint8Array(buffer);\n // // console.log(array);\n // // console.log('Decode ' + msgpack.decode(array));\n //\n // return msgpack.decode(array);\n // }\n\n\n\n}\n","import { Component, OnInit } from '@angular/core';\n\n@Component({\n selector: 'es-http',\n template: `\n <p>\n http works!\n </p>\n `,\n styles: []\n})\nexport class HttpComponent implements OnInit {\n\n constructor() { }\n\n ngOnInit() {\n }\n\n}\n","import {NgModule} from '@angular/core';\nimport {HttpComponent} from './http.component';\nimport {HttpClientModule} from '@angular/common/http';\nimport {HttpService} from './http.service';\n\n@NgModule({\n imports: [\n HttpClientModule\n ],\n declarations: [HttpComponent],\n providers: [\n HttpService\n ],\n exports: [],\n})\nexport class HttpModule { }\n","/*\n * Public API Surface of http\n */\n\nexport * from './lib/http.service';\nexport * from './lib/http.component';\nexport * from './lib/http.module';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":["HttpResponse","throwError","MatSnackBarConfig","HttpParams","catchError","HttpHeaders","Injectable","Htt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ular/common/http"),require("@angular/material/snack-bar"),require("rxjs"),require("rxjs/operators")):"function"==typeof define&&define.amd?define("@eurosat/http",["exports","@angular/core","@angular/common/http","@angular/material/snack-bar","rxjs","rxjs/operators"],e):e(((r=r||self).eurosat=r.eurosat||{},r.eurosat.http={}),r.ng.core,r.ng.common.http,r.ng.material["snack-bar"],r.rxjs,r.rxjs.operators)}(this,function(r,e,t,a,n,o){"use strict";var s=function(){function r(e,t){this.http=e,this.snackBar=t,r.instance||(r.instance=this)}return r.handleError=function(e){var a;if(r.errorStatus(e),e instanceof t.HttpResponse){var o=e.body||"",s=o.error||JSON.stringify(o);a=e.status+" - "+(e.statusText||"")+" "+s}else a=e.message?e.message:e.toString();return console.error(a),n.throwError(a)},r.errorStatus=function(e){switch(e.status){case 300:case 301:r.handleRedirect(e);break;case 403:case 503:r.handleErrorMessage(e);break;case 601:r.handleRedirect(e)}},r.handleRedirect=function(r){var e=r.error;if(e.login){var t=window.location.pathname;t="/"===t[0]?t.substr(1):t,window.location.href=e.url+"?r="+t}else window.location.href=""+e.url},r.handleErrorMessage=function(e){var t=e.error;if(e.error instanceof Blob){var a=new FileReader;a.addEventListener("loadend",function(e){r.createSnackBar(e.srcElement.result)}),a.readAsText(e.error)}else r.createSnackBar(t)},r.createSnackBar=function(e){var t=new a.MatSnackBarConfig;t.duration=2e3,t.panelClass="es-snackbar-alert-danger",r.instance.snackBar.open(e,null,t)},r.prototype.get=function(e,a){return a||(a={}),a.params||(a.params=new t.HttpParams),a.params=a.params.set("_req_s",r.ANGULAR_REQUEST_CONST),this.http.get(e,a).pipe(o.catchError(r.handleError))},r.prototype.post=function(e,a,n){return n||(n={}),n.params||(n.params=new t.HttpParams),n.params=n.params.set("_req_s",r.ANGULAR_REQUEST_CONST),this.http.post(e,a,n).pipe(o.catchError(r.handleError))},r.prototype.postFiles=function(e,a,n){n||(n={}),n.params||(n.params=new t.HttpParams),n.params=n.params.set("_req_s",r.ANGULAR_REQUEST_CONST);var s=new t.HttpHeaders;return n.headers=s.set("disable-ngsw","true"),this.http.post(e,a,n).pipe(o.catchError(r.handleError))},r.prototype.delete=function(e,t){return this.http.delete(e,t).pipe(o.catchError(r.handleError))},r.ANGULAR_REQUEST_CONST="2",r.decorators=[{type:e.Injectable,args:[{providedIn:"root"}]}],r.ctorParameters=function(){return[{type:t.HttpClient},{type:a.MatSnackBar}]},r.ngInjectableDef=e.ɵɵdefineInjectable({factory:function(){return new r(e.ɵɵinject(t.HttpClient),e.ɵɵinject(a.MatSnackBar))},token:r,providedIn:"root"}),r}(),i=function(){function r(){}return r.prototype.ngOnInit=function(){},r.decorators=[{type:e.Component,args:[{selector:"es-http",template:"\n <p>\n http works!\n </p>\n "}]}],r.ctorParameters=function(){return[]},r}(),c=function(){function r(){}return r.decorators=[{type:e.NgModule,args:[{imports:[t.HttpClientModule],declarations:[i],providers:[s],exports:[]}]}],r}();r.HttpComponent=i,r.HttpModule=c,r.HttpService=s,Object.defineProperty(r,"__esModule",{value:!0})});
1
+ !function(r,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/common/http"),require("@angular/material/snack-bar"),require("rxjs"),require("rxjs/operators")):"function"==typeof define&&define.amd?define("@eurosat/http",["exports","@angular/core","@angular/common/http","@angular/material/snack-bar","rxjs","rxjs/operators"],e):e(((r="undefined"!=typeof globalThis?globalThis:r||self).eurosat=r.eurosat||{},r.eurosat.http={}),r.ng.core,r.ng.common.http,r.ng.material.snackBar,r.rxjs,r.rxjs.operators)}(this,(function(r,e,t,a,n,o){"use strict";var s=function(){function r(e,t){this.http=e,this.snackBar=t,r.instance||(r.instance=this)}return r.handleError=function(e){var a;if(r.errorStatus(e),e instanceof t.HttpResponse){var o=e.body||"",s=o.error||JSON.stringify(o);a=e.status+" - "+(e.statusText||"")+" "+s}else a=e.message?e.message:e.toString();return console.error(a),n.throwError(a)},r.errorStatus=function(e){switch(e.status){case 300:case 301:r.handleRedirect(e);break;case 403:case 503:r.handleErrorMessage(e);break;case 601:r.handleRedirect(e)}},r.handleRedirect=function(r){var e=r.error;if(e.login){var t=window.location.pathname;t="/"===t[0]?t.substr(1):t,window.location.href=e.url+"?r="+t}else window.location.href=""+e.url},r.handleErrorMessage=function(e){var t=e.error;if(e.error instanceof Blob){var a=new FileReader;a.addEventListener("loadend",(function(e){r.createSnackBar(e.srcElement.result)})),a.readAsText(e.error)}else r.createSnackBar(t)},r.createSnackBar=function(e){var t=new a.MatSnackBarConfig;t.duration=2e3,t.panelClass="es-snackbar-alert-danger",r.instance.snackBar.open(e,null,t)},r.prototype.get=function(e,a){return a||(a={}),a.params||(a.params=new t.HttpParams),a.params=a.params.set("_req_s",r.ANGULAR_REQUEST_CONST),this.http.get(e,a).pipe(o.catchError(r.handleError))},r.prototype.post=function(e,a,n){return n||(n={}),n.params||(n.params=new t.HttpParams),n.params=n.params.set("_req_s",r.ANGULAR_REQUEST_CONST),this.http.post(e,a,n).pipe(o.catchError(r.handleError))},r.prototype.postFiles=function(e,a,n){n||(n={}),n.params||(n.params=new t.HttpParams),n.params=n.params.set("_req_s",r.ANGULAR_REQUEST_CONST);var s=new t.HttpHeaders;return n.headers=s.set("disable-ngsw","true"),this.http.post(e,a,n).pipe(o.catchError(r.handleError))},r.prototype.delete=function(e,t){return this.http.delete(e,t).pipe(o.catchError(r.handleError))},r}();s.ANGULAR_REQUEST_CONST="2",s.ɵprov=e.ɵɵdefineInjectable({factory:function(){return new s(e.ɵɵinject(t.HttpClient),e.ɵɵinject(a.MatSnackBar))},token:s,providedIn:"root"}),s.decorators=[{type:e.Injectable,args:[{providedIn:"root"}]}],s.ctorParameters=function(){return[{type:t.HttpClient},{type:a.MatSnackBar}]};var i=function(){function r(){}return r.prototype.ngOnInit=function(){},r}();i.decorators=[{type:e.Component,args:[{selector:"es-http",template:"\n <p>\n http works!\n </p>\n "}]}],i.ctorParameters=function(){return[]};var p=function(){};p.decorators=[{type:e.NgModule,args:[{imports:[t.HttpClientModule],declarations:[i],providers:[s],exports:[]}]}],r.HttpComponent=i,r.HttpModule=p,r.HttpService=s,Object.defineProperty(r,"__esModule",{value:!0})}));
2
2
  //# sourceMappingURL=eurosat-http.umd.min.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["ng://@eurosat/http/lib/http.service.ts","ng://@eurosat/http/lib/http.component.ts","ng://@eurosat/http/lib/http.module.ts"],"names":["HttpService","http","snackBar","this","instance","handleError","error","errMsg","errorStatus","HttpResponse","body","err","JSON","stringify","status","statusText","message","toString","console","throwError","handleRedirect","handleErrorMessage","res","login","path","window","location","pathname","substr","href","url","Blob","reader","FileReader","addEventListener","e","createSnackBar","srcElement","readAsText","config","MatSnackBarConfig","duration","panelClass","open","prototype","get","options","params","HttpParams","set","ANGULAR_REQUEST_CONST","pipe","catchError","post","postFiles","headers","HttpHeaders","delete","Injectable","args","providedIn","HttpClient","MatSnackBar","HttpComponent","ngOnInit","Component","selector","template","HttpModule","NgModule","imports","HttpClientModule","declarations","providers","exports"],"mappings":"kjBAMA,IAAAA,EAAA,WASI,SAAAA,EACYC,EACAC,GADAC,KAAAF,KAAAA,EACAE,KAAAD,SAAAA,EAEHF,EAAYI,WACbJ,EAAYI,SAAWD,aAIjBH,EAAAK,YAAd,SAA2BC,OAInBC,EACJ,GAJAP,EAAYQ,YAAYF,GAIpBA,aAAiBG,EAAAA,aAAc,KACzBC,EAAOJ,EAAMI,MAAQ,GACrBC,EAAMD,EAAKJ,OAASM,KAAKC,UAAUH,GACzCH,EAAYD,EAAMQ,OAAM,OAAMR,EAAMS,YAAc,IAAE,IAAIJ,OAExDJ,EAASD,EAAMU,QAAUV,EAAMU,QAAUV,EAAMW,WAGnD,OADAC,QAAQZ,MAAMC,GACPY,EAAAA,WAAWZ,IAGPP,EAAAQ,YAAf,SAA2BG,GACvB,OAAQA,EAAIG,QACR,KAAK,IACL,KAAK,IACDd,EAAYoB,eAAeT,GAC3B,MAIJ,KAAK,IAGL,KAAK,IACDX,EAAYqB,mBAAmBV,GAC/B,MACJ,KAAK,IAC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,UAAAU,UAAA,SAAUxB,EAAapB,EAAkBoC,GAChCA,IAAWA,EAAU,IACrBA,EAAQC,SACTD,EAAQC,OAAS,IAAIC,EAAAA,YAEzBF,EAAQC,OAASD,EAAQC,OAAOE,IAAI,SAAUjD,EAAYkD,2BACpDK,EAAU,IAAIC,EAAAA,YAEpB,OADAV,EAAiB,QAAIS,EAAQN,IAAI,eAAgB,QAC1C9C,KAAKF,KAAKoD,KAAKvB,EAAKpB,EAAMoC,GAC5BK,KAAKC,EAAAA,WAAWpD,EAAYK,eAGrCL,EAAA4C,UAAAa,OAAA,SAAO3B,EAAagB,GAChB,OAAO3C,KAAKF,KAAKwD,OAAO3B,EAAKgB,GACxBK,KAAKC,EAAAA,WAAWpD,EAAYK,eAjIvBL,EAAAkD,sBAAwB,wBALzCQ,EAAAA,WAAUC,KAAA,CAAC,CACRC,WAAY,oDANRC,EAAAA,kBACAC,EAAAA,0KAIR,GCNAC,EAAA,WAaE,SAAAA,KAKF,OAHEA,EAAAnB,UAAAoB,SAAA,iCAbDC,EAAAA,UAASN,KAAA,CAAC,CACTO,SAAU,UACVC,SAAU,uFAcZJ,EAlBA,GCAAK,EAAA,WAKA,SAAAA,KAU0B,2BAVzBC,EAAAA,SAAQV,KAAA,CAAC,CACNW,QAAS,CACLC,EAAAA,kBAEJC,aAAc,CAACT,GACfU,UAAW,CACPzE,GAEJ0E,QAAS,OAEaN,EAf1B","sourcesContent":["import {Injectable} from '@angular/core';\nimport {HttpClient, HttpHeaders, HttpParams, HttpResponse} from '@angular/common/http';\nimport {MatSnackBar, MatSnackBarConfig} from '@angular/material/snack-bar';\nimport {Observable, throwError} from 'rxjs';\nimport {catchError} from 'rxjs/operators';\n// @dynamic --> NEMAZAT https://github.com/dherges/ng-packagr/issues/641\n@Injectable({\n providedIn: 'root'\n})\nexport class HttpService {\n\n public static ANGULAR_REQUEST_CONST = '2';\n\n private static instance: HttpService; // není to prasárna?\n\n constructor(\n private http: HttpClient,\n private snackBar: MatSnackBar,\n ) {\n if (!HttpService.instance) { // není to prasárna?\n HttpService.instance = this;\n }\n }\n\n public static handleError (error: HttpResponse<any> | any) {\n HttpService.errorStatus(error);\n\n // Todo: In a real world app, you might use a remote logging infrastructure\n let errMsg: string;\n if (error instanceof HttpResponse) {\n const body = error.body || '';\n const err = body.error || JSON.stringify(body);\n errMsg = `${error.status} - ${error.statusText || ''} ${err}`;\n } else {\n errMsg = error.message ? error.message : error.toString();\n }\n console.error(errMsg);\n return throwError(errMsg);\n }\n\n private static errorStatus(err: HttpResponse<any>) {\n switch (err.status) {\n case 300:\n case 301:\n HttpService.handleRedirect(err);\n break;\n // case 302:\n // HttpService.handleRedirect(err);\n // break;\n case 403:\n HttpService.handleErrorMessage(err);\n break;\n case 503:\n HttpService.handleErrorMessage(err);\n break;\n case 601:\n HttpService.handleRedirect(err);\n break;\n }\n\n // todo 413 Request Entity Too Large - upload file z formu\n }\n\n // private static handleLoginRedirect(res: HttpResponse<any>) {\n // const error = res['error'];\n //\n // }\n\n private static handleRedirect(res: HttpResponse<any>) {\n const error = res['error'];\n if (error.login) {\n let path = window.location.pathname;\n path = path[0] === '/' ? path.substr(1) : path; // '/front/' => 'front/'\n // console.log('Redirect ' + `${error.url}?r=${path}`);\n window.location.href = `${error.url}?r=${path}`;\n } else {\n window.location.href = `${error.url}`;\n }\n }\n\n private static handleErrorMessage(res: HttpResponse<any>) {\n const message = res['error'];\n if (res['error'] instanceof Blob) {\n const reader = new FileReader();\n\n reader.addEventListener('loadend', (e) => {\n HttpService.createSnackBar(e.srcElement['result']);\n });\n\n reader.readAsText(res['error']);\n } else {\n HttpService.createSnackBar(message);\n }\n }\n\n private static createSnackBar(message) {\n const config = new MatSnackBarConfig();\n config.duration = 2000;\n config.panelClass = 'es-snackbar-alert-danger'; // AppSnackbarPanelClass.DANGER;\n HttpService.instance.snackBar.open(message, null, config);\n }\n\n get(url: string, options?: {params?: HttpParams, responseType?, observe?}): Observable<any> {\n if (!options) { options = {}; }\n if (!options.params) {\n options.params = new HttpParams();\n }\n options.params = options.params.set('_req_s', HttpService.ANGULAR_REQUEST_CONST); // pridava se nejakej param na formy pro angular\n return this.http.get(url, options)\n .pipe(catchError(HttpService.handleError));\n }\n\n post(url: string, body: any | null, options?: {params?: HttpParams, responseType?, reportProgress?: boolean, observe?: any}): Observable<any> {\n if (!options) { options = {}; }\n if (!options.params) {\n options.params = new HttpParams();\n }\n options.params = options.params.set('_req_s', HttpService.ANGULAR_REQUEST_CONST);\n\n return this.http.post(url, body, options)\n .pipe(catchError(HttpService.handleError));\n }\n\n // upload file s vypnutym service workerem -> header{disable-ngsw: true}\n // v ekj projektu fix-ngsw.sh\n // sed -i '/onFetch(event) {/,/const req = event.request;/c onFetch(event){const req=event.request;if(req.headers.get('disable-ngsw')===\"true\")return;' ./front/ngsw-worker.js\n postFiles(url: string, body: any | null, options?: {params?: HttpParams, responseType?, reportProgress?: boolean, observe?: any}): Observable<any> {\n if (!options) { options = {}; }\n if (!options.params) {\n options.params = new HttpParams();\n }\n options.params = options.params.set('_req_s', HttpService.ANGULAR_REQUEST_CONST);\n const headers = new HttpHeaders();\n options['headers'] = headers.set('disable-ngsw', 'true');\n return this.http.post(url, body, options)\n .pipe(catchError(HttpService.handleError));\n }\n\n delete(url: string, options?: {}): Observable<Object> {\n return this.http.delete(url, options)\n .pipe(catchError(HttpService.handleError));\n }\n\n\n // private extractMsgpack(res: Response) {\n //\n // let buffer = res.arrayBuffer();\n // // console.log(buffer);\n //\n // let array = new Uint8Array(buffer);\n // // console.log(array);\n // // console.log('Decode ' + msgpack.decode(array));\n //\n // return msgpack.decode(array);\n // }\n\n\n\n}\n","import { Component, OnInit } from '@angular/core';\n\n@Component({\n selector: 'es-http',\n template: `\n <p>\n http works!\n </p>\n `,\n styles: []\n})\nexport class HttpComponent implements OnInit {\n\n constructor() { }\n\n ngOnInit() {\n }\n\n}\n","import {NgModule} from '@angular/core';\nimport {HttpComponent} from './http.component';\nimport {HttpClientModule} from '@angular/common/http';\nimport {HttpService} from './http.service';\n\n@NgModule({\n imports: [\n HttpClientModule\n ],\n declarations: [HttpComponent],\n providers: [\n HttpService\n ],\n exports: [],\n})\nexport class HttpModule { }\n"]}
1
+ {"version":3,"sources":["../../../projects/http/src/lib/http.service.ts","../../../projects/http/src/lib/http.component.ts","../../../projects/http/src/lib/http.module.ts"],"names":["HttpService","http","snackBar","this","instance","handleError","error","errMsg","errorStatus","HttpResponse","body","err","JSON","stringify","status","statusText","message","toString","console","throwError","handleRedirect","handleErrorMessage","res","login","path","window","location","pathname","substr","href","url","Blob","reader","FileReader","addEventListener","e","createSnackBar","srcElement","readAsText","config","MatSnackBarConfig","duration","panelClass","open","prototype","get","options","params","HttpParams","set","ANGULAR_REQUEST_CONST","pipe","catchError","post","postFiles","headers","HttpHeaders","delete","Injectable","args","providedIn","HttpClient","MatSnackBar","HttpComponent","ngOnInit","Component","selector","template","NgModule","imports","HttpClientModule","declarations","providers","exports"],"mappings":"0mBAeI,SAAAA,EACYC,EACAC,GADAC,KAAAF,KAAAA,EACAE,KAAAD,SAAAA,EAEHF,EAAYI,WACbJ,EAAYI,SAAWD,aAIjBH,EAAAK,YAAP,SAAoBC,GAIvB,IAAIC,EACJ,GAJAP,EAAYQ,YAAYF,GAIpBA,aAAiBG,EAAAA,aAAc,CAC/B,IAAMC,EAAOJ,EAAMI,MAAQ,GACrBC,EAAMD,EAAKJ,OAASM,KAAKC,UAAUH,GACzCH,EAAYD,EAAMQ,OAAM,OAAMR,EAAMS,YAAc,IAAE,IAAIJ,OAExDJ,EAASD,EAAMU,QAAUV,EAAMU,QAAUV,EAAMW,WAGnD,OADAC,QAAQZ,MAAMC,GACPY,EAAAA,WAAWZ,IAGPP,EAAAQ,YAAP,SAAmBG,GACvB,OAAQA,EAAIG,QACR,KAAK,IACL,KAAK,IACDd,EAAYoB,eAAeT,GAC3B,MAIJ,KAAK,IAGL,KAAK,IACDX,EAAYqB,mBAAmBV,GAC/B,MACJ,KAAK,IACDX,EAAYoB,eA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YK,eAMrCL,EAAA4C,UAAAU,UAAA,SAAUxB,EAAapB,EAAkBoC,GAChCA,IAAWA,EAAU,IACrBA,EAAQC,SACTD,EAAQC,OAAS,IAAIC,EAAAA,YAEzBF,EAAQC,OAASD,EAAQC,OAAOE,IAAI,SAAUjD,EAAYkD,uBAC1D,IAAMK,EAAU,IAAIC,EAAAA,YAEpB,OADAV,EAAiB,QAAIS,EAAQN,IAAI,eAAgB,QAC1C9C,KAAKF,KAAKoD,KAAKvB,EAAKpB,EAAMoC,GAC5BK,KAAKC,EAAAA,WAAWpD,EAAYK,eAGrCL,EAAA4C,UAAAa,OAAA,SAAO3B,EAAagB,GAChB,OAAO3C,KAAKF,KAAKwD,OAAO3B,EAAKgB,GACxBK,KAAKC,EAAAA,WAAWpD,EAAYK,oBAjIvBL,EAAAkD,sBAAwB,uKALzCQ,EAAAA,WAAUC,KAAA,CAAC,CACRC,WAAY,oDANRC,EAAAA,kBACAC,EAAAA,gCCWN,SAAAC,YAEAA,EAAAnB,UAAAoB,SAAA,sCAbDC,EAAAA,UAASN,KAAA,CAAC,CACTO,SAAU,UACVC,SAAU,6FCWZ,iCAVCC,EAAAA,SAAQT,KAAA,CAAC,CACNU,QAAS,CACLC,EAAAA,kBAEJC,aAAc,CAACR,GACfS,UAAW,CACPxE,GAEJyE,QAAS","sourcesContent":["import {Injectable} from '@angular/core';\nimport {HttpClient, HttpHeaders, HttpParams, HttpResponse} from '@angular/common/http';\nimport {MatSnackBar, MatSnackBarConfig} from '@angular/material/snack-bar';\nimport {Observable, throwError} from 'rxjs';\nimport {catchError} from 'rxjs/operators';\n// @dynamic --> NEMAZAT https://github.com/dherges/ng-packagr/issues/641\n@Injectable({\n providedIn: 'root'\n})\nexport class HttpService {\n\n public static ANGULAR_REQUEST_CONST = '2';\n\n private static instance: HttpService; // není to prasárna?\n\n constructor(\n private http: HttpClient,\n private snackBar: MatSnackBar,\n ) {\n if (!HttpService.instance) { // není to prasárna?\n HttpService.instance = this;\n }\n }\n\n public static handleError (error: HttpResponse<any> | any) {\n HttpService.errorStatus(error);\n\n // Todo: In a real world app, you might use a remote logging infrastructure\n let errMsg: string;\n if (error instanceof HttpResponse) {\n const body = error.body || '';\n const err = body.error || JSON.stringify(body);\n errMsg = `${error.status} - ${error.statusText || ''} ${err}`;\n } else {\n errMsg = error.message ? error.message : error.toString();\n }\n console.error(errMsg);\n return throwError(errMsg);\n }\n\n private static errorStatus(err: HttpResponse<any>) {\n switch (err.status) {\n case 300:\n case 301:\n HttpService.handleRedirect(err);\n break;\n // case 302:\n // HttpService.handleRedirect(err);\n // break;\n case 403:\n HttpService.handleErrorMessage(err);\n break;\n case 503:\n HttpService.handleErrorMessage(err);\n break;\n case 601:\n HttpService.handleRedirect(err);\n break;\n }\n\n // todo 413 Request Entity Too Large - upload file z formu\n }\n\n // private static handleLoginRedirect(res: HttpResponse<any>) {\n // const error = res['error'];\n //\n // }\n\n private static handleRedirect(res: HttpResponse<any>) {\n const error = res['error'];\n if (error.login) {\n let path = window.location.pathname;\n path = path[0] === '/' ? path.substr(1) : path; // '/front/' => 'front/'\n // console.log('Redirect ' + `${error.url}?r=${path}`);\n window.location.href = `${error.url}?r=${path}`;\n } else {\n window.location.href = `${error.url}`;\n }\n }\n\n private static handleErrorMessage(res: HttpResponse<any>) {\n const message = res['error'];\n if (res['error'] instanceof Blob) {\n const reader = new FileReader();\n\n reader.addEventListener('loadend', (e) => {\n HttpService.createSnackBar(e.srcElement['result']);\n });\n\n reader.readAsText(res['error']);\n } else {\n HttpService.createSnackBar(message);\n }\n }\n\n private static createSnackBar(message) {\n const config = new MatSnackBarConfig();\n config.duration = 2000;\n config.panelClass = 'es-snackbar-alert-danger'; // AppSnackbarPanelClass.DANGER;\n HttpService.instance.snackBar.open(message, null, config);\n }\n\n get(url: string, options?: {params?: HttpParams, responseType?, observe?}): Observable<any> {\n if (!options) { options = {}; }\n if (!options.params) {\n options.params = new HttpParams();\n }\n options.params = options.params.set('_req_s', HttpService.ANGULAR_REQUEST_CONST); // pridava se nejakej param na formy pro angular\n return this.http.get(url, options)\n .pipe(catchError(HttpService.handleError));\n }\n\n post(url: string, body: any | null, options?: {params?: HttpParams, responseType?, reportProgress?: boolean, observe?: any}): Observable<any> {\n if (!options) { options = {}; }\n if (!options.params) {\n options.params = new HttpParams();\n }\n options.params = options.params.set('_req_s', HttpService.ANGULAR_REQUEST_CONST);\n\n return this.http.post(url, body, options)\n .pipe(catchError(HttpService.handleError));\n }\n\n // upload file s vypnutym service workerem -> header{disable-ngsw: true}\n // v ekj projektu fix-ngsw.sh\n // sed -i '/onFetch(event) {/,/const req = event.request;/c onFetch(event){const req=event.request;if(req.headers.get('disable-ngsw')===\"true\")return;' ./front/ngsw-worker.js\n postFiles(url: string, body: any | null, options?: {params?: HttpParams, responseType?, reportProgress?: boolean, observe?: any}): Observable<any> {\n if (!options) { options = {}; }\n if (!options.params) {\n options.params = new HttpParams();\n }\n options.params = options.params.set('_req_s', HttpService.ANGULAR_REQUEST_CONST);\n const headers = new HttpHeaders();\n options['headers'] = headers.set('disable-ngsw', 'true');\n return this.http.post(url, body, options)\n .pipe(catchError(HttpService.handleError));\n }\n\n delete(url: string, options?: {}): Observable<Object> {\n return this.http.delete(url, options)\n .pipe(catchError(HttpService.handleError));\n }\n\n\n // private extractMsgpack(res: Response) {\n //\n // let buffer = res.arrayBuffer();\n // // console.log(buffer);\n //\n // let array = new Uint8Array(buffer);\n // // console.log(array);\n // // console.log('Decode ' + msgpack.decode(array));\n //\n // return msgpack.decode(array);\n // }\n\n\n\n}\n","import { Component, OnInit } from '@angular/core';\n\n@Component({\n selector: 'es-http',\n template: `\n <p>\n http works!\n </p>\n `,\n styles: []\n})\nexport class HttpComponent implements OnInit {\n\n constructor() { }\n\n ngOnInit() {\n }\n\n}\n","import {NgModule} from '@angular/core';\nimport {HttpComponent} from './http.component';\nimport {HttpClientModule} from '@angular/common/http';\nimport {HttpService} from './http.service';\n\n@NgModule({\n imports: [\n HttpClientModule\n ],\n declarations: [HttpComponent],\n providers: [\n HttpService\n ],\n exports: [],\n})\nexport class HttpModule { }\n"]}
@@ -1,9 +1,5 @@
1
- /**
2
- * @fileoverview added by tsickle
3
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4
- */
5
1
  /**
6
2
  * Generated bundle index. Do not edit.
7
3
  */
8
- export { HttpService, HttpComponent, HttpModule } from './public_api';
9
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXVyb3NhdC1odHRwLmpzIiwic291cmNlUm9vdCI6Im5nOi8vQGV1cm9zYXQvaHR0cC8iLCJzb3VyY2VzIjpbImV1cm9zYXQtaHR0cC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7O0FBSUEsdURBQWMsY0FBYyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBHZW5lcmF0ZWQgYnVuZGxlIGluZGV4LiBEbyBub3QgZWRpdC5cbiAqL1xuXG5leHBvcnQgKiBmcm9tICcuL3B1YmxpY19hcGknO1xuIl19
4
+ export * from './public_api';
5
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXVyb3NhdC1odHRwLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vcHJvamVjdHMvaHR0cC9zcmMvZXVyb3NhdC1odHRwLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBRUgsY0FBYyxjQUFjLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIEdlbmVyYXRlZCBidW5kbGUgaW5kZXguIERvIG5vdCBlZGl0LlxuICovXG5cbmV4cG9ydCAqIGZyb20gJy4vcHVibGljX2FwaSc7XG4iXX0=
@@ -1,13 +1,6 @@
1
- /**
2
- * @fileoverview added by tsickle
3
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4
- */
5
1
  import { Component } from '@angular/core';
6
2
  export class HttpComponent {
7
3
  constructor() { }
8
- /**
9
- * @return {?}
10
- */
11
4
  ngOnInit() {
12
5
  }
13
6
  }
@@ -19,8 +12,8 @@ HttpComponent.decorators = [
19
12
  http works!
20
13
  </p>
21
14
  `
22
- }] }
15
+ },] }
23
16
  ];
24
17
  /** @nocollapse */
25
18
  HttpComponent.ctorParameters = () => [];
26
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaHR0cC5jb21wb25lbnQuanMiLCJzb3VyY2VSb290Ijoibmc6Ly9AZXVyb3NhdC9odHRwLyIsInNvdXJjZXMiOlsibGliL2h0dHAuY29tcG9uZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7QUFBQSxPQUFPLEVBQUUsU0FBUyxFQUFVLE1BQU0sZUFBZSxDQUFDO0FBV2xELE1BQU0sT0FBTyxhQUFhO0lBRXhCLGdCQUFnQixDQUFDOzs7O0lBRWpCLFFBQVE7SUFDUixDQUFDOzs7WUFkRixTQUFTLFNBQUM7Z0JBQ1QsUUFBUSxFQUFFLFNBQVM7Z0JBQ25CLFFBQVEsRUFBRTs7OztHQUlUO2FBRUYiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBDb21wb25lbnQsIE9uSW5pdCB9IGZyb20gJ0Bhbmd1bGFyL2NvcmUnO1xuXG5AQ29tcG9uZW50KHtcbiAgc2VsZWN0b3I6ICdlcy1odHRwJyxcbiAgdGVtcGxhdGU6IGBcbiAgICA8cD5cbiAgICAgIGh0dHAgd29ya3MhXG4gICAgPC9wPlxuICBgLFxuICBzdHlsZXM6IFtdXG59KVxuZXhwb3J0IGNsYXNzIEh0dHBDb21wb25lbnQgaW1wbGVtZW50cyBPbkluaXQge1xuXG4gIGNvbnN0cnVjdG9yKCkgeyB9XG5cbiAgbmdPbkluaXQoKSB7XG4gIH1cblxufVxuIl19
19
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaHR0cC5jb21wb25lbnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9wcm9qZWN0cy9odHRwL3NyYy9saWIvaHR0cC5jb21wb25lbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFNBQVMsRUFBVSxNQUFNLGVBQWUsQ0FBQztBQVdsRCxNQUFNLE9BQU8sYUFBYTtJQUV4QixnQkFBZ0IsQ0FBQztJQUVqQixRQUFRO0lBQ1IsQ0FBQzs7O1lBZEYsU0FBUyxTQUFDO2dCQUNULFFBQVEsRUFBRSxTQUFTO2dCQUNuQixRQUFRLEVBQUU7Ozs7R0FJVDthQUVGIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgQ29tcG9uZW50LCBPbkluaXQgfSBmcm9tICdAYW5ndWxhci9jb3JlJztcblxuQENvbXBvbmVudCh7XG4gIHNlbGVjdG9yOiAnZXMtaHR0cCcsXG4gIHRlbXBsYXRlOiBgXG4gICAgPHA+XG4gICAgICBodHRwIHdvcmtzIVxuICAgIDwvcD5cbiAgYCxcbiAgc3R5bGVzOiBbXVxufSlcbmV4cG9ydCBjbGFzcyBIdHRwQ29tcG9uZW50IGltcGxlbWVudHMgT25Jbml0IHtcblxuICBjb25zdHJ1Y3RvcigpIHsgfVxuXG4gIG5nT25Jbml0KCkge1xuICB9XG5cbn1cbiJdfQ==
@@ -1,7 +1,3 @@
1
- /**
2
- * @fileoverview added by tsickle
3
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4
- */
5
1
  import { NgModule } from '@angular/core';
6
2
  import { HttpComponent } from './http.component';
7
3
  import { HttpClientModule } from '@angular/common/http';
@@ -20,4 +16,4 @@ HttpModule.decorators = [
20
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