ngx-techlify-core 14.13.0 → 14.13.2
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/esm2020/lib/core/error-handler.interceptor.mjs +29 -17
- package/esm2020/lib/entity-files/entity-file-form/entity-file-form.component.mjs +2 -2
- package/esm2020/lib/entity-files/entity-file.service.mjs +3 -1
- package/esm2020/lib/user/current-user.service.mjs +2 -2
- package/fesm2015/ngx-techlify-core.mjs +32 -21
- package/fesm2015/ngx-techlify-core.mjs.map +1 -1
- package/fesm2020/ngx-techlify-core.mjs +32 -20
- package/fesm2020/ngx-techlify-core.mjs.map +1 -1
- package/lib/core/error-handler.interceptor.d.ts +10 -1
- package/package.json +1 -1
|
@@ -30,7 +30,7 @@ import { MatCardModule } from '@angular/material/card';
|
|
|
30
30
|
import * as i1$4 from '@angular/forms';
|
|
31
31
|
import { UntypedFormControl, Validators, ReactiveFormsModule, FormsModule, NG_VALUE_ACCESSOR, FormControl } from '@angular/forms';
|
|
32
32
|
import * as i1$2 from '@angular/common/http';
|
|
33
|
-
import { HttpResponse, HttpClient, HttpClientModule } from '@angular/common/http';
|
|
33
|
+
import { HttpErrorResponse, HttpResponse, HttpClient, HttpClientModule } from '@angular/common/http';
|
|
34
34
|
import { throwError, Observable, Subject, of, BehaviorSubject, map as map$1, from, fromEvent, interval } from 'rxjs';
|
|
35
35
|
import * as i1$1 from '@angular/material/snack-bar';
|
|
36
36
|
import { MAT_SNACK_BAR_DATA, MatSnackBarModule } from '@angular/material/snack-bar';
|
|
@@ -865,41 +865,51 @@ const log$6 = new Logger('ErrorHandlerInterceptor');
|
|
|
865
865
|
* Adds a default error handler to all requests.
|
|
866
866
|
*/
|
|
867
867
|
class ErrorHandlerInterceptor {
|
|
868
|
-
constructor(configService, errorHandler) {
|
|
868
|
+
constructor(configService, errorHandler, alertService) {
|
|
869
869
|
this.configService = configService;
|
|
870
870
|
this.errorHandler = errorHandler;
|
|
871
|
+
this.alertService = alertService;
|
|
871
872
|
}
|
|
872
873
|
intercept(request, next) {
|
|
873
874
|
return next.handle(request).pipe(catchError(error => this.handleError(error)));
|
|
874
875
|
}
|
|
875
876
|
// Customize the default error handler here if needed
|
|
876
877
|
handleError(error) {
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
errorMessage = `Client Error: ${this.configService?.getProjectKey()}: ${error.error.message}`;
|
|
878
|
+
if (this.checkNoNetworkConnection(error)) {
|
|
879
|
+
this.alertService.addAlert('Internet connection not available, try later', 'warning');
|
|
880
|
+
return throwError(error);
|
|
881
881
|
}
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
}
|
|
888
|
-
catch (e) {
|
|
889
|
-
console.log("Unable to handle server error", e);
|
|
890
|
-
}
|
|
882
|
+
try {
|
|
883
|
+
this.errorHandler.handleError(error, 'Unexpected Server Error, try later or contact service team');
|
|
884
|
+
}
|
|
885
|
+
catch (e) {
|
|
886
|
+
console.log("Unable to handle server error", e);
|
|
891
887
|
}
|
|
892
888
|
return throwError(error);
|
|
893
889
|
}
|
|
894
|
-
|
|
895
|
-
|
|
890
|
+
/**
|
|
891
|
+
* Helper function to check if an error is likely due to a network connection issue.
|
|
892
|
+
*
|
|
893
|
+
* @param error The error object to check.
|
|
894
|
+
* @returns `true` if it's likely a network error, `false` otherwise.
|
|
895
|
+
*/
|
|
896
|
+
checkNoNetworkConnection(error) {
|
|
897
|
+
return (error instanceof HttpErrorResponse
|
|
898
|
+
&& !error.headers.keys().length
|
|
899
|
+
&& !error.ok
|
|
900
|
+
&& !error.status
|
|
901
|
+
&& !error.error.loaded
|
|
902
|
+
&& !error.error.total);
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
ErrorHandlerInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.7", ngImport: i0, type: ErrorHandlerInterceptor, deps: [{ token: ConfigService }, { token: ErrorHandlerService }, { token: AlertService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
896
906
|
ErrorHandlerInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.7", ngImport: i0, type: ErrorHandlerInterceptor, providedIn: 'root' });
|
|
897
907
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.7", ngImport: i0, type: ErrorHandlerInterceptor, decorators: [{
|
|
898
908
|
type: Injectable,
|
|
899
909
|
args: [{
|
|
900
910
|
providedIn: 'root'
|
|
901
911
|
}]
|
|
902
|
-
}], ctorParameters: function () { return [{ type: ConfigService }, { type: ErrorHandlerService }]; } });
|
|
912
|
+
}], ctorParameters: function () { return [{ type: ConfigService }, { type: ErrorHandlerService }, { type: AlertService }]; } });
|
|
903
913
|
|
|
904
914
|
const log$5 = new Logger('HttpCacheService');
|
|
905
915
|
/**
|
|
@@ -1291,6 +1301,8 @@ class EntityFileService extends TechlifyServiceBaseClass {
|
|
|
1291
1301
|
formData.append("fileData", file, file.name);
|
|
1292
1302
|
if (params?.entity_id) {
|
|
1293
1303
|
formData.append('entity_id', params.entity_id);
|
|
1304
|
+
}
|
|
1305
|
+
if (params?.entity_type) {
|
|
1294
1306
|
formData.append('entity_type', params.entity_type);
|
|
1295
1307
|
}
|
|
1296
1308
|
params?.disk ? formData.append('disk', params.disk) : null;
|
|
@@ -1815,7 +1827,7 @@ class EntityFileFormComponent {
|
|
|
1815
1827
|
async fileChanged(event) {
|
|
1816
1828
|
this.fileList = event;
|
|
1817
1829
|
if (this.fileList.length > 0) {
|
|
1818
|
-
const result = await this.entityFileService.uploadEntityFile(this.fileList[0]);
|
|
1830
|
+
const result = await this.entityFileService.uploadEntityFile(this.fileList[0], { entity_type: this.entityFileGroup.get('entity_type').value });
|
|
1819
1831
|
this.entityFileGroup.patchValue(result.item);
|
|
1820
1832
|
;
|
|
1821
1833
|
this.fileList = [];
|
|
@@ -2327,7 +2339,7 @@ class CurrentUserService {
|
|
|
2327
2339
|
if (!this.user) {
|
|
2328
2340
|
return false;
|
|
2329
2341
|
}
|
|
2330
|
-
if (this.user.user_type_id == 1
|
|
2342
|
+
if (this.user.user_type_id == 1) {
|
|
2331
2343
|
return true;
|
|
2332
2344
|
}
|
|
2333
2345
|
else {
|