coer-elements 0.0.20 → 0.0.22
Sign up to get free protection for your applications and to get access to all the features.
- package/components/lib/coer-button/coer-button.component.d.ts +2 -2
- package/components/lib/coer-numberbox/coer-numberbox.component.d.ts +1 -1
- package/components/lib/coer-switch/coer-switch.component.d.ts +1 -1
- package/components/lib/coer-textarea/coer-textarea.component.d.ts +1 -1
- package/components/lib/coer-textbox/coer-textbox.component.d.ts +1 -1
- package/esm2022/pipes/lib/no-image.pipe.mjs +2 -2
- package/esm2022/public_api.mjs +1 -1
- package/esm2022/tools/index.mjs +3 -2
- package/esm2022/tools/lib/service.class.mjs +248 -0
- package/fesm2022/coer-elements.mjs +247 -2
- package/fesm2022/coer-elements.mjs.map +1 -1
- package/package.json +1 -1
- package/styles/angular-material.scss +12 -0
- package/{src/styles → styles}/bootstrap.scss +3 -3
- package/tools/index.d.ts +2 -1
- package/tools/lib/service.class.d.ts +39 -0
- package/src/interfaces/index.ts +0 -49
- package/src/interfaces/lib/app-source.interface.ts +0 -4
- package/src/interfaces/lib/coer-filebox/file-image.interface.ts +0 -14
- package/src/interfaces/lib/coer-filebox/file.interface.ts +0 -5
- package/src/interfaces/lib/coer-grid/grid-button-by-row.interface.ts +0 -7
- package/src/interfaces/lib/coer-grid/grid-checkbox.interface.ts +0 -5
- package/src/interfaces/lib/coer-grid/grid-coer-numberbox.interface.ts +0 -12
- package/src/interfaces/lib/coer-grid/grid-coer-selectbox.interface.ts +0 -9
- package/src/interfaces/lib/coer-grid/grid-coer-switch.interface.ts +0 -6
- package/src/interfaces/lib/coer-grid/grid-coer-textbox.interface.ts +0 -11
- package/src/interfaces/lib/coer-grid/grid-column.interface.ts +0 -23
- package/src/interfaces/lib/coer-grid/grid-data-source.interface.ts +0 -6
- package/src/interfaces/lib/coer-grid/grid-header-button.interface.ts +0 -8
- package/src/interfaces/lib/coer-grid/grid-header-export-button.interface.ts +0 -10
- package/src/interfaces/lib/coer-grid/grid-header.interface.ts +0 -5
- package/src/interfaces/lib/coer-grid/grid-import.interface.ts +0 -4
- package/src/interfaces/lib/coer-grid/grid-input-checkbox.interface.ts +0 -5
- package/src/interfaces/lib/coer-grid/grid-input-switch-change.interface.ts +0 -5
- package/src/interfaces/lib/coer-grid/grid-input-textbox.interface.ts +0 -5
- package/src/interfaces/lib/coer-grid/grid-item.interface.ts +0 -5
- package/src/interfaces/lib/coer-grid/grid-keyup-enter.interface.ts +0 -6
- package/src/interfaces/lib/coer-grid/grid-length.interface.ts +0 -5
- package/src/interfaces/lib/coer-grid/grid-search.interface.ts +0 -4
- package/src/interfaces/lib/coer-grid/grid-sort.interface.ts +0 -5
- package/src/interfaces/lib/coer-menu/menu-option-selected.interface.ts +0 -10
- package/src/interfaces/lib/coer-menu/menu-selected.interface.ts +0 -11
- package/src/interfaces/lib/coer-menu/menu.interface.ts +0 -6
- package/src/interfaces/lib/coer-ref.interface.ts +0 -11
- package/src/interfaces/lib/page-title/breadcrumb.interface.ts +0 -6
- package/src/interfaces/lib/page-title/go-back.interface.ts +0 -6
- package/src/interfaces/lib/screen-size.interface.ts +0 -5
- package/src/interfaces/lib/service/http-request.interface.ts +0 -11
- package/src/interfaces/lib/service/http-response.interface.ts +0 -6
- package/src/interfaces/lib/service/patch.interface.ts +0 -5
- package/src/styles/angular-material.scss +0 -12
- /package/{src/images → images}/no-image.png +0 -0
- /package/{src/images → images}/no-user.png +0 -0
- /package/{src/styles → styles}/colors.scss +0 -0
- /package/{src/styles → styles}/containers.scss +0 -0
- /package/{src/styles → styles}/cursores.scss +0 -0
- /package/{src/styles → styles}/index.scss +0 -0
- /package/{src/styles → styles}/layout.scss +0 -0
- /package/{src/styles → styles}/scroll-bar.scss +0 -0
@@ -25,6 +25,7 @@ import Swal from 'sweetalert2';
|
|
25
25
|
import * as XLSX from 'xlsx';
|
26
26
|
import { Observable } from 'rxjs';
|
27
27
|
import moment from 'moment';
|
28
|
+
import { HttpClient, HttpRequest } from '@angular/common/http';
|
28
29
|
|
29
30
|
class CoerRefDirective {
|
30
31
|
constructor(template) {
|
@@ -335,7 +336,7 @@ const Tools = {
|
|
335
336
|
|
336
337
|
class NoImagePipe {
|
337
338
|
transform(value) {
|
338
|
-
const NO_IMAGE = '
|
339
|
+
const NO_IMAGE = '../../../images/no-image.png';
|
339
340
|
if (Tools.IsOnlyWhiteSpace(value)) {
|
340
341
|
return NO_IMAGE;
|
341
342
|
}
|
@@ -3832,9 +3833,253 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
|
|
3832
3833
|
args: [String]
|
3833
3834
|
}] }] });
|
3834
3835
|
|
3836
|
+
class Service {
|
3837
|
+
constructor() {
|
3838
|
+
//Injections
|
3839
|
+
this.alert = inject(CoerAlert);
|
3840
|
+
this.http = inject(HttpClient);
|
3841
|
+
this.httpCode = {
|
3842
|
+
Ok: 200,
|
3843
|
+
Created: 201,
|
3844
|
+
NoContent: 204,
|
3845
|
+
BadRequest: 400,
|
3846
|
+
Unauthorize: 401,
|
3847
|
+
NotFound: 404,
|
3848
|
+
NotAllowed: 405,
|
3849
|
+
NotAcceptable: 406,
|
3850
|
+
Conflict: 409,
|
3851
|
+
PayloadTooLarge: 413,
|
3852
|
+
InnerError: 500
|
3853
|
+
};
|
3854
|
+
}
|
3855
|
+
/** */
|
3856
|
+
ReleaseSubscription(subscription) {
|
3857
|
+
if (subscription && !subscription.closed)
|
3858
|
+
subscription.unsubscribe();
|
3859
|
+
}
|
3860
|
+
/** HTTP GET */
|
3861
|
+
HTTP_GET(request) {
|
3862
|
+
return new Promise(Resolve => {
|
3863
|
+
this.ReleaseSubscription(this._GET$);
|
3864
|
+
this._GET$ = this.http.request(new HttpRequest("GET", request.url, { params: request.queryParams, headers: request.headers })).subscribe({
|
3865
|
+
next: (response) => {
|
3866
|
+
if (response.type > 0) {
|
3867
|
+
Resolve({
|
3868
|
+
body: Tools.BreakReference(response.body),
|
3869
|
+
status: response.status,
|
3870
|
+
message: response.statusText,
|
3871
|
+
ok: true
|
3872
|
+
});
|
3873
|
+
}
|
3874
|
+
},
|
3875
|
+
error: (httpError) => {
|
3876
|
+
this.ReleaseSubscription(this._GET$);
|
3877
|
+
this.AlertError(httpError, request.alertError);
|
3878
|
+
Resolve({
|
3879
|
+
body: {},
|
3880
|
+
status: httpError.status,
|
3881
|
+
message: httpError.error?.message || httpError.error,
|
3882
|
+
ok: false
|
3883
|
+
});
|
3884
|
+
},
|
3885
|
+
complete: () => {
|
3886
|
+
this.ReleaseSubscription(this._GET$);
|
3887
|
+
if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
|
3888
|
+
this.alert.Success(request.alertSuccess);
|
3889
|
+
}
|
3890
|
+
}
|
3891
|
+
});
|
3892
|
+
});
|
3893
|
+
}
|
3894
|
+
/** HTTP POST */
|
3895
|
+
HTTP_POST(request) {
|
3896
|
+
return new Promise(Resolve => {
|
3897
|
+
this.ReleaseSubscription(this._POST$);
|
3898
|
+
this._POST$ = this.http.request(new HttpRequest("POST", request.url, request.body, { params: request.queryParams, headers: request.headers })).subscribe({
|
3899
|
+
next: (response) => {
|
3900
|
+
if (response.type > 0) {
|
3901
|
+
Resolve({
|
3902
|
+
body: Tools.BreakReference(response.body),
|
3903
|
+
status: response.status,
|
3904
|
+
message: response.statusText,
|
3905
|
+
ok: true
|
3906
|
+
});
|
3907
|
+
}
|
3908
|
+
},
|
3909
|
+
error: (httpError) => {
|
3910
|
+
this.ReleaseSubscription(this._POST$);
|
3911
|
+
this.AlertError(httpError, request.alertError);
|
3912
|
+
Resolve({
|
3913
|
+
body: {},
|
3914
|
+
status: httpError.status,
|
3915
|
+
message: httpError.error?.message || httpError.error,
|
3916
|
+
ok: false
|
3917
|
+
});
|
3918
|
+
},
|
3919
|
+
complete: () => {
|
3920
|
+
this.ReleaseSubscription(this._POST$);
|
3921
|
+
if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
|
3922
|
+
this.alert.Success(request.alertSuccess);
|
3923
|
+
}
|
3924
|
+
}
|
3925
|
+
});
|
3926
|
+
});
|
3927
|
+
}
|
3928
|
+
/** HTTP PUT */
|
3929
|
+
HTTP_PUT(request) {
|
3930
|
+
return new Promise(Resolve => {
|
3931
|
+
this.ReleaseSubscription(this._PUT$);
|
3932
|
+
this._PUT$ = this.http.request(new HttpRequest("PUT", request.url, request.body, { params: request.queryParams, headers: request.headers })).subscribe({
|
3933
|
+
next: (response) => {
|
3934
|
+
if (response.type > 0) {
|
3935
|
+
Resolve({
|
3936
|
+
body: {},
|
3937
|
+
status: response.status,
|
3938
|
+
message: response.statusText,
|
3939
|
+
ok: true
|
3940
|
+
});
|
3941
|
+
}
|
3942
|
+
},
|
3943
|
+
error: (httpError) => {
|
3944
|
+
this.ReleaseSubscription(this._PUT$);
|
3945
|
+
this.AlertError(httpError, request.alertError);
|
3946
|
+
Resolve({
|
3947
|
+
body: {},
|
3948
|
+
status: httpError.status,
|
3949
|
+
message: httpError.error?.message || httpError.error,
|
3950
|
+
ok: false
|
3951
|
+
});
|
3952
|
+
},
|
3953
|
+
complete: () => {
|
3954
|
+
this.ReleaseSubscription(this._PUT$);
|
3955
|
+
if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
|
3956
|
+
this.alert.Success(request.alertSuccess, 'Updated', 'fa-solid fa-arrows-rotate fa-spin');
|
3957
|
+
}
|
3958
|
+
}
|
3959
|
+
});
|
3960
|
+
});
|
3961
|
+
}
|
3962
|
+
/** HTTP PATCH */
|
3963
|
+
HTTP_PATCH(request) {
|
3964
|
+
return new Promise(Resolve => {
|
3965
|
+
this.ReleaseSubscription(this._PATCH$);
|
3966
|
+
this._PATCH$ = this.http.request(new HttpRequest("PATCH", request.url, request.body, { params: request.queryParams, headers: request.headers })).subscribe({
|
3967
|
+
next: (response) => {
|
3968
|
+
if (response.type > 0) {
|
3969
|
+
Resolve({
|
3970
|
+
body: {},
|
3971
|
+
status: response.status,
|
3972
|
+
message: response.statusText,
|
3973
|
+
ok: true
|
3974
|
+
});
|
3975
|
+
}
|
3976
|
+
},
|
3977
|
+
error: (httpError) => {
|
3978
|
+
this.ReleaseSubscription(this._PATCH$);
|
3979
|
+
this.AlertError(httpError, request.alertError);
|
3980
|
+
Resolve({
|
3981
|
+
body: {},
|
3982
|
+
status: httpError.status,
|
3983
|
+
message: httpError.error?.message || httpError.error,
|
3984
|
+
ok: false
|
3985
|
+
});
|
3986
|
+
},
|
3987
|
+
complete: () => {
|
3988
|
+
this.ReleaseSubscription(this._PATCH$);
|
3989
|
+
if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
|
3990
|
+
this.alert.Success(request.alertSuccess, 'Updated', 'fa-solid fa-arrows-rotate fa-spin');
|
3991
|
+
}
|
3992
|
+
}
|
3993
|
+
});
|
3994
|
+
});
|
3995
|
+
}
|
3996
|
+
/** HTTP DELETE */
|
3997
|
+
HTTP_DELETE(request) {
|
3998
|
+
return new Promise(Resolve => {
|
3999
|
+
this.ReleaseSubscription(this._DELETE$);
|
4000
|
+
this._DELETE$ = this.http.request(new HttpRequest("DELETE", request.url, { params: request.queryParams, headers: request.headers })).subscribe({
|
4001
|
+
next: (response) => {
|
4002
|
+
if (response.type > 0) {
|
4003
|
+
Resolve({
|
4004
|
+
body: {},
|
4005
|
+
status: response.status,
|
4006
|
+
message: response.statusText,
|
4007
|
+
ok: true
|
4008
|
+
});
|
4009
|
+
}
|
4010
|
+
},
|
4011
|
+
error: (httpError) => {
|
4012
|
+
this.ReleaseSubscription(this._DELETE$);
|
4013
|
+
this.AlertError(httpError, request.alertError);
|
4014
|
+
Resolve({
|
4015
|
+
body: {},
|
4016
|
+
status: httpError.status,
|
4017
|
+
message: httpError.error?.message || httpError.error,
|
4018
|
+
ok: false
|
4019
|
+
});
|
4020
|
+
},
|
4021
|
+
complete: () => {
|
4022
|
+
this.ReleaseSubscription(this._DELETE$);
|
4023
|
+
if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
|
4024
|
+
this.alert.Success(request.alertSuccess, 'Deleted', 'fa-regular fa-trash-can');
|
4025
|
+
}
|
4026
|
+
}
|
4027
|
+
});
|
4028
|
+
});
|
4029
|
+
}
|
4030
|
+
/** */
|
4031
|
+
AlertError(httpError, message) {
|
4032
|
+
if (httpError.status >= 500) {
|
4033
|
+
if (Tools.IsNotOnlyWhiteSpace(message)) {
|
4034
|
+
this.alert.Error('', message, 'fa-solid fa-bug', null);
|
4035
|
+
}
|
4036
|
+
}
|
4037
|
+
else if (httpError.status < 500) {
|
4038
|
+
switch (httpError.status) {
|
4039
|
+
case 400: {
|
4040
|
+
this.alert.Warning(httpError.error?.message || httpError.error, 'Bad Request', 'fa-regular fa-face-grin-beam-sweat fa-lg');
|
4041
|
+
break;
|
4042
|
+
}
|
4043
|
+
case 401: {
|
4044
|
+
this.alert.Warning(httpError.error?.message || httpError.error, 'Unauthorize', 'fa-regular fa-face-rolling-eyes fa-lg');
|
4045
|
+
break;
|
4046
|
+
}
|
4047
|
+
case 404: {
|
4048
|
+
this.alert.Warning(httpError.error?.message || httpError.error, 'Not Found', 'fa-regular fa-face-meh fa-lg');
|
4049
|
+
break;
|
4050
|
+
}
|
4051
|
+
case 405: {
|
4052
|
+
this.alert.Warning(httpError.error?.message || httpError.error, 'Not Allowed', 'fa-regular fa-face-grimace fa-lg');
|
4053
|
+
break;
|
4054
|
+
}
|
4055
|
+
case 406: {
|
4056
|
+
this.alert.Warning(httpError.error?.message || httpError.error, 'Not Acceptable', 'fa-regular fa-face-frown-open fa-lg');
|
4057
|
+
break;
|
4058
|
+
}
|
4059
|
+
case 409: {
|
4060
|
+
this.alert.Warning(httpError.error?.message || httpError.error, 'Conflict', 'fa-regular fa-face-dizzy fa-lg');
|
4061
|
+
break;
|
4062
|
+
}
|
4063
|
+
case 413: {
|
4064
|
+
this.alert.Warning(httpError.error?.message || httpError.error, 'Too Large', 'fa-regular fa-face-flushed fa-lg');
|
4065
|
+
break;
|
4066
|
+
}
|
4067
|
+
default: {
|
4068
|
+
if (httpError.status <= 0) {
|
4069
|
+
this.alert.Warning('Without Connection', 'WEB API DOWN', 'fa-solid fa-plug-circle-xmark fa-lg', null);
|
4070
|
+
}
|
4071
|
+
else
|
4072
|
+
this.alert.Warning(httpError.error?.message || httpError.error);
|
4073
|
+
break;
|
4074
|
+
}
|
4075
|
+
}
|
4076
|
+
}
|
4077
|
+
}
|
4078
|
+
}
|
4079
|
+
|
3835
4080
|
/**
|
3836
4081
|
* Generated bundle index. Do not edit.
|
3837
4082
|
*/
|
3838
4083
|
|
3839
|
-
export { Breadcrumbs, CONTROL_VALUE, CoerAlert, CoerButton, CoerCheckbox, CoerFilebox, CoerForm, CoerGrid, CoerModal, CoerNumberBox, CoerPageTitle, CoerRefDirective, CoerSelectbox, CoerSwitch, CoerTab, CoerTextBox, CoerTextarea, ComponentsModule, ControlValue, DateTime, DirectivesModule, Files, GridTemplates, HtmlPipe, LifeCycleDirective, Menu, NoImagePipe, NumericFormatPipe, Page, PipesModule, Screen, Source, Tools, breakpointSIGNAL, isLoadingSIGNAL, isMenuOpenSIGNAL, isModalOpenSIGNAL, menuSIGNAL };
|
4084
|
+
export { Breadcrumbs, CONTROL_VALUE, CoerAlert, CoerButton, CoerCheckbox, CoerFilebox, CoerForm, CoerGrid, CoerModal, CoerNumberBox, CoerPageTitle, CoerRefDirective, CoerSelectbox, CoerSwitch, CoerTab, CoerTextBox, CoerTextarea, ComponentsModule, ControlValue, DateTime, DirectivesModule, Files, GridTemplates, HtmlPipe, LifeCycleDirective, Menu, NoImagePipe, NumericFormatPipe, Page, PipesModule, Screen, Service, Source, Tools, breakpointSIGNAL, isLoadingSIGNAL, isMenuOpenSIGNAL, isModalOpenSIGNAL, menuSIGNAL };
|
3840
4085
|
//# sourceMappingURL=coer-elements.mjs.map
|