coer-elements 0.0.23 → 0.0.25
Sign up to get free protection for your applications and to get access to all the features.
- package/components/index.d.ts +5 -0
- package/components/lib/coer-button/coer-button.component.d.ts +44 -0
- package/components/lib/coer-checkbox/coer-checkbox.component.d.ts +28 -0
- package/components/lib/coer-filebox/coer-filebox.component.d.ts +33 -0
- package/components/lib/coer-form/coer-form.component.d.ts +33 -0
- package/components/lib/coer-grid/coer-grid.component.d.ts +53 -0
- package/components/lib/coer-grid/coer-grid.extension.d.ts +103 -0
- package/components/lib/coer-grid/coer-grid.templates.d.ts +9 -0
- package/components/lib/coer-modal/coer-modal.component.d.ts +38 -0
- package/components/lib/coer-numberbox/coer-numberbox.component.d.ts +55 -0
- package/components/lib/coer-page-title/coer-page-title.component.d.ts +12 -0
- package/components/lib/coer-selectbox/coer-selectbox.component.d.ts +75 -0
- package/components/lib/coer-switch/coer-switch.component.d.ts +31 -0
- package/components/lib/coer-tab/coer-tab.component.d.ts +35 -0
- package/components/lib/coer-textarea/coer-textarea.component.d.ts +51 -0
- package/components/lib/coer-textbox/coer-textbox.component.d.ts +57 -0
- package/components/lib/components.module.d.ts +30 -0
- package/components/public-api.d.ts +15 -0
- package/directives/index.d.ts +5 -0
- package/directives/lib/coer-ref.directive.d.ts +14 -0
- package/directives/lib/directives.module.d.ts +8 -0
- package/directives/lib/life-cycle.directive.d.ts +16 -0
- package/directives/public-api.d.ts +3 -0
- package/esm2022/components/coer-elements-components.mjs +5 -0
- package/esm2022/components/lib/coer-button/coer-button.component.mjs +133 -0
- package/esm2022/components/lib/coer-checkbox/coer-checkbox.component.mjs +83 -0
- package/esm2022/components/lib/coer-filebox/coer-filebox.component.mjs +102 -0
- package/esm2022/components/lib/coer-form/coer-form.component.mjs +101 -0
- package/esm2022/components/lib/coer-grid/coer-grid.component.mjs +512 -0
- package/esm2022/components/lib/coer-grid/coer-grid.extension.mjs +408 -0
- package/esm2022/components/lib/coer-grid/coer-grid.templates.mjs +30 -0
- package/esm2022/components/lib/coer-modal/coer-modal.component.mjs +107 -0
- package/esm2022/components/lib/coer-numberbox/coer-numberbox.component.mjs +258 -0
- package/esm2022/components/lib/coer-page-title/coer-page-title.component.mjs +44 -0
- package/esm2022/components/lib/coer-selectbox/coer-selectbox.component.mjs +338 -0
- package/esm2022/components/lib/coer-switch/coer-switch.component.mjs +93 -0
- package/esm2022/components/lib/coer-tab/coer-tab.component.mjs +116 -0
- package/esm2022/components/lib/coer-textarea/coer-textarea.component.mjs +156 -0
- package/esm2022/components/lib/coer-textbox/coer-textbox.component.mjs +195 -0
- package/esm2022/components/lib/components.module.mjs +129 -0
- package/esm2022/components/public-api.mjs +16 -0
- package/esm2022/directives/coer-elements-directives.mjs +5 -0
- package/esm2022/directives/lib/coer-ref.directive.mjs +23 -0
- package/esm2022/directives/lib/directives.module.mjs +25 -0
- package/esm2022/directives/lib/life-cycle.directive.mjs +33 -0
- package/esm2022/directives/public-api.mjs +4 -0
- package/esm2022/interfaces/coer-elements-interfaces.mjs +5 -0
- package/esm2022/interfaces/lib/app-source.interface.mjs +2 -0
- package/esm2022/interfaces/lib/coer-filebox/file-image.interface.mjs +2 -0
- package/esm2022/interfaces/lib/coer-filebox/file.interface.mjs +2 -0
- package/esm2022/interfaces/lib/coer-grid/grid-button-by-row.interface.mjs +2 -0
- package/esm2022/interfaces/lib/coer-grid/grid-checkbox.interface.mjs +2 -0
- package/esm2022/interfaces/lib/coer-grid/grid-coer-numberbox.interface.mjs +2 -0
- package/esm2022/interfaces/lib/coer-grid/grid-coer-selectbox.interface.mjs +2 -0
- package/esm2022/interfaces/lib/coer-grid/grid-coer-switch.interface.mjs +2 -0
- package/esm2022/interfaces/lib/coer-grid/grid-coer-textbox.interface.mjs +2 -0
- package/esm2022/interfaces/lib/coer-grid/grid-column.interface.mjs +2 -0
- package/esm2022/interfaces/lib/coer-grid/grid-data-source.interface.mjs +2 -0
- package/esm2022/interfaces/lib/coer-grid/grid-header-button.interface.mjs +2 -0
- package/esm2022/interfaces/lib/coer-grid/grid-header-export-button.interface.mjs +2 -0
- package/esm2022/interfaces/lib/coer-grid/grid-header.interface.mjs +2 -0
- package/esm2022/interfaces/lib/coer-grid/grid-import.interface.mjs +2 -0
- package/esm2022/interfaces/lib/coer-grid/grid-input-checkbox.interface.mjs +2 -0
- package/esm2022/interfaces/lib/coer-grid/grid-input-switch-change.interface.mjs +2 -0
- package/esm2022/interfaces/lib/coer-grid/grid-input-textbox.interface.mjs +2 -0
- package/esm2022/interfaces/lib/coer-grid/grid-item.interface.mjs +2 -0
- package/esm2022/interfaces/lib/coer-grid/grid-keyup-enter.interface.mjs +2 -0
- package/esm2022/interfaces/lib/coer-grid/grid-length.interface.mjs +2 -0
- package/esm2022/interfaces/lib/coer-grid/grid-search.interface.mjs +2 -0
- package/esm2022/interfaces/lib/coer-grid/grid-sort.interface.mjs +2 -0
- package/esm2022/interfaces/lib/coer-menu/menu-option-selected.interface.mjs +2 -0
- package/esm2022/interfaces/lib/coer-menu/menu-selected.interface.mjs +2 -0
- package/esm2022/interfaces/lib/coer-menu/menu.interface.mjs +2 -0
- package/esm2022/interfaces/lib/coer-ref.interface.mjs +2 -0
- package/esm2022/interfaces/lib/page-title/breadcrumb.interface.mjs +2 -0
- package/esm2022/interfaces/lib/page-title/go-back.interface.mjs +2 -0
- package/esm2022/interfaces/lib/screen-size.interface.mjs +2 -0
- package/esm2022/interfaces/lib/service/http-request.interface.mjs +2 -0
- package/esm2022/interfaces/lib/service/http-response.interface.mjs +2 -0
- package/esm2022/interfaces/lib/service/patch.interface.mjs +2 -0
- package/esm2022/interfaces/public-api.mjs +39 -0
- package/esm2022/pipes/coer-elements-pipes.mjs +5 -0
- package/esm2022/pipes/lib/html.pipe.mjs +18 -0
- package/esm2022/pipes/lib/no-image.pipe.mjs +23 -0
- package/esm2022/pipes/lib/numeric-format.pipe.mjs +15 -0
- package/esm2022/pipes/lib/pipes.module.mjs +31 -0
- package/esm2022/pipes/public-api.mjs +5 -0
- package/esm2022/signals/coer-elements-signals.mjs +5 -0
- package/esm2022/signals/lib/breakpoint.signal.mjs +4 -0
- package/esm2022/signals/lib/is-loading.signal.mjs +3 -0
- package/esm2022/signals/lib/is-menu-open.signal.mjs +3 -0
- package/esm2022/signals/lib/is-modal-open.signal.mjs +3 -0
- package/esm2022/signals/lib/menu.signal.mjs +3 -0
- package/esm2022/signals/public-api.mjs +6 -0
- package/esm2022/tools/coer-elements-tools.mjs +5 -0
- package/esm2022/tools/lib/breadcrumbs.class.mjs +63 -0
- package/esm2022/tools/lib/coer-alert/coer-alert.component.mjs +228 -0
- package/esm2022/tools/lib/control-value.class.mjs +46 -0
- package/esm2022/tools/lib/date-time.class.mjs +29 -0
- package/esm2022/tools/lib/files.class.mjs +91 -0
- package/esm2022/tools/lib/menu.class.mjs +23 -0
- package/esm2022/tools/lib/page.class.mjs +156 -0
- package/esm2022/tools/lib/screen.class.mjs +51 -0
- package/esm2022/tools/lib/service.class.mjs +247 -0
- package/esm2022/tools/lib/source.class.mjs +80 -0
- package/esm2022/tools/lib/tools.mjs +220 -0
- package/esm2022/tools/public-api.mjs +12 -0
- package/fesm2022/coer-elements-components.mjs +2718 -0
- package/fesm2022/coer-elements-components.mjs.map +1 -0
- package/fesm2022/coer-elements-directives.mjs +82 -0
- package/fesm2022/coer-elements-directives.mjs.map +1 -0
- package/fesm2022/coer-elements-interfaces.mjs +6 -0
- package/fesm2022/coer-elements-interfaces.mjs.map +1 -0
- package/fesm2022/coer-elements-pipes.mjs +83 -0
- package/fesm2022/coer-elements-pipes.mjs.map +1 -0
- package/fesm2022/coer-elements-signals.mjs +19 -0
- package/fesm2022/coer-elements-signals.mjs.map +1 -0
- package/fesm2022/coer-elements-tools.mjs +1223 -0
- package/fesm2022/coer-elements-tools.mjs.map +1 -0
- package/interfaces/index.d.ts +5 -0
- package/interfaces/lib/app-source.interface.d.ts +4 -0
- package/interfaces/lib/coer-filebox/file-image.interface.d.ts +14 -0
- package/interfaces/lib/coer-filebox/file.interface.d.ts +5 -0
- package/interfaces/lib/coer-grid/grid-button-by-row.interface.d.ts +6 -0
- package/interfaces/lib/coer-grid/grid-checkbox.interface.d.ts +5 -0
- package/interfaces/lib/coer-grid/grid-coer-numberbox.interface.d.ts +12 -0
- package/interfaces/lib/coer-grid/grid-coer-selectbox.interface.d.ts +9 -0
- package/interfaces/lib/coer-grid/grid-coer-switch.interface.d.ts +6 -0
- package/interfaces/lib/coer-grid/grid-coer-textbox.interface.d.ts +11 -0
- package/interfaces/lib/coer-grid/grid-column.interface.d.ts +22 -0
- package/interfaces/lib/coer-grid/grid-data-source.interface.d.ts +6 -0
- package/interfaces/lib/coer-grid/grid-header-button.interface.d.ts +8 -0
- package/interfaces/lib/coer-grid/grid-header-export-button.interface.d.ts +10 -0
- package/interfaces/lib/coer-grid/grid-header.interface.d.ts +5 -0
- package/interfaces/lib/coer-grid/grid-import.interface.d.ts +4 -0
- package/interfaces/lib/coer-grid/grid-input-checkbox.interface.d.ts +5 -0
- package/interfaces/lib/coer-grid/grid-input-switch-change.interface.d.ts +5 -0
- package/interfaces/lib/coer-grid/grid-input-textbox.interface.d.ts +5 -0
- package/interfaces/lib/coer-grid/grid-item.interface.d.ts +5 -0
- package/interfaces/lib/coer-grid/grid-keyup-enter.interface.d.ts +6 -0
- package/interfaces/lib/coer-grid/grid-length.interface.d.ts +5 -0
- package/interfaces/lib/coer-grid/grid-search.interface.d.ts +4 -0
- package/interfaces/lib/coer-grid/grid-sort.interface.d.ts +5 -0
- package/interfaces/lib/coer-menu/menu-option-selected.interface.d.ts +9 -0
- package/interfaces/lib/coer-menu/menu-selected.interface.d.ts +10 -0
- package/interfaces/lib/coer-menu/menu.interface.d.ts +6 -0
- package/interfaces/lib/coer-ref.interface.d.ts +10 -0
- package/interfaces/lib/page-title/breadcrumb.interface.d.ts +6 -0
- package/interfaces/lib/page-title/go-back.interface.d.ts +6 -0
- package/interfaces/lib/screen-size.interface.d.ts +5 -0
- package/interfaces/lib/service/http-request.interface.d.ts +10 -0
- package/interfaces/lib/service/http-response.interface.d.ts +6 -0
- package/interfaces/lib/service/patch.interface.d.ts +5 -0
- package/interfaces/public-api.d.ts +33 -0
- package/package.json +37 -1
- package/pipes/index.d.ts +5 -0
- package/pipes/lib/html.pipe.d.ts +10 -0
- package/pipes/lib/no-image.pipe.d.ts +7 -0
- package/pipes/lib/numeric-format.pipe.d.ts +7 -0
- package/pipes/lib/pipes.module.d.ts +9 -0
- package/pipes/public-api.d.ts +4 -0
- package/signals/index.d.ts +5 -0
- package/signals/lib/breakpoint.signal.d.ts +1 -0
- package/signals/lib/is-loading.signal.d.ts +1 -0
- package/signals/lib/is-menu-open.signal.d.ts +1 -0
- package/signals/lib/is-modal-open.signal.d.ts +1 -0
- package/signals/lib/menu.signal.d.ts +2 -0
- package/signals/public-api.d.ts +5 -0
- package/tools/index.d.ts +5 -0
- package/tools/lib/breadcrumbs.class.d.ts +18 -0
- package/tools/lib/coer-alert/coer-alert.component.d.ts +23 -0
- package/tools/lib/control-value.class.d.ts +25 -0
- package/tools/lib/date-time.class.d.ts +13 -0
- package/tools/lib/files.class.d.ts +16 -0
- package/tools/lib/menu.class.d.ts +8 -0
- package/tools/lib/page.class.d.ts +60 -0
- package/tools/lib/screen.class.d.ts +13 -0
- package/tools/lib/service.class.d.ts +39 -0
- package/tools/lib/source.class.d.ts +20 -0
- package/tools/lib/tools.d.ts +34 -0
- package/tools/public-api.d.ts +11 -0
@@ -0,0 +1,1223 @@
|
|
1
|
+
import * as i0 from '@angular/core';
|
2
|
+
import { signal, Component, forwardRef, inject, Inject } from '@angular/core';
|
3
|
+
import * as bootstrap from 'bootstrap';
|
4
|
+
import Swal from 'sweetalert2';
|
5
|
+
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
6
|
+
import moment from 'moment';
|
7
|
+
import * as XLSX from 'xlsx';
|
8
|
+
import { Router, ActivatedRoute } from '@angular/router';
|
9
|
+
import { Observable } from 'rxjs';
|
10
|
+
import { HttpClient, HttpRequest } from '@angular/common/http';
|
11
|
+
|
12
|
+
const reference_signal = signal({});
|
13
|
+
const Tools = {
|
14
|
+
/** Generate a Guid */
|
15
|
+
GetGuid: (seed = 'coer-system') => {
|
16
|
+
let time = new Date().getTime();
|
17
|
+
seed = seed.toString().trim();
|
18
|
+
return seed + `-xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g, (c) => {
|
19
|
+
const random = (time + Math.random() * 16) % 16 | 0;
|
20
|
+
time = Math.floor(time / 16);
|
21
|
+
return (c == 'x' ? random : (random & 0x3 | 0x8)).toString(16);
|
22
|
+
});
|
23
|
+
},
|
24
|
+
/** Returns true if the value is null or undefined, false otherwise */
|
25
|
+
IsNull: (value) => {
|
26
|
+
if (value === undefined)
|
27
|
+
return true;
|
28
|
+
if (value === null)
|
29
|
+
return true;
|
30
|
+
return false;
|
31
|
+
},
|
32
|
+
/** Returns true if the value is not null or undefined, false otherwise */
|
33
|
+
IsNotNull: (value) => {
|
34
|
+
if (value === undefined)
|
35
|
+
return false;
|
36
|
+
if (value === null)
|
37
|
+
return false;
|
38
|
+
return true;
|
39
|
+
},
|
40
|
+
/** Returns true if the value is null or undefined or contains only whitespace, false otherwise */
|
41
|
+
IsOnlyWhiteSpace: (value) => {
|
42
|
+
if (value === undefined)
|
43
|
+
return true;
|
44
|
+
if (value === null)
|
45
|
+
return true;
|
46
|
+
if (typeof value === 'string' && value.trim() === '')
|
47
|
+
return true;
|
48
|
+
return false;
|
49
|
+
},
|
50
|
+
/** Returns true if has string value and is not only whitespace, false otherwise */
|
51
|
+
IsNotOnlyWhiteSpace: (value) => {
|
52
|
+
if (value === undefined)
|
53
|
+
return false;
|
54
|
+
if (value === null)
|
55
|
+
return false;
|
56
|
+
if (typeof value === 'string' && value.trim() === '')
|
57
|
+
return false;
|
58
|
+
return true;
|
59
|
+
},
|
60
|
+
/** Break reference of a object or array */
|
61
|
+
BreakReference: (object) => {
|
62
|
+
if (object === null)
|
63
|
+
return object;
|
64
|
+
if (typeof object === 'undefined')
|
65
|
+
return object;
|
66
|
+
if (typeof object === 'string')
|
67
|
+
return object;
|
68
|
+
if (typeof object === 'number')
|
69
|
+
return object;
|
70
|
+
if (typeof object === 'boolean')
|
71
|
+
return object;
|
72
|
+
const OBJECT = JSON.parse(JSON.stringify(object));
|
73
|
+
return (Array.isArray(OBJECT)) ? [...OBJECT] : { ...OBJECT };
|
74
|
+
},
|
75
|
+
/** Clean extra whitespaces */
|
76
|
+
CleanUpBlanks: (text) => {
|
77
|
+
if (Tools.IsNull(text))
|
78
|
+
return '';
|
79
|
+
let worlds = String(text).split(' ');
|
80
|
+
worlds = worlds.filter(x => x.length > 0);
|
81
|
+
return worlds.join(' ');
|
82
|
+
},
|
83
|
+
/** Get properties of an object */
|
84
|
+
GetObjectProperties: (obj) => {
|
85
|
+
const properties = [];
|
86
|
+
if (obj === null)
|
87
|
+
return properties;
|
88
|
+
if (typeof obj === 'undefined')
|
89
|
+
return properties;
|
90
|
+
if (typeof obj === 'string')
|
91
|
+
return properties;
|
92
|
+
if (typeof obj === 'number')
|
93
|
+
return properties;
|
94
|
+
if (typeof obj === 'boolean')
|
95
|
+
return properties;
|
96
|
+
for (const property in obj)
|
97
|
+
properties.push(String(property));
|
98
|
+
return properties;
|
99
|
+
},
|
100
|
+
/**
|
101
|
+
* Set an index and merge more arrays of the same type
|
102
|
+
* */
|
103
|
+
SetIndex: (array, ...args) => {
|
104
|
+
let index = 0;
|
105
|
+
for (const arg of args) {
|
106
|
+
array = Tools.BreakReference(array).concat(Tools.BreakReference(arg));
|
107
|
+
}
|
108
|
+
return Tools.BreakReference(array).map(item => Object.assign({ index: index++ }, item));
|
109
|
+
},
|
110
|
+
/** Set First Char To Lower */
|
111
|
+
FirstCharToLower: (text) => {
|
112
|
+
if (Tools.IsOnlyWhiteSpace(text))
|
113
|
+
return '';
|
114
|
+
const textArray = [];
|
115
|
+
for (let i = 0; i < text.length; i++) {
|
116
|
+
if (i === 0)
|
117
|
+
textArray.push(text[i].toLowerCase());
|
118
|
+
else
|
119
|
+
textArray.push(text[i]);
|
120
|
+
}
|
121
|
+
return textArray.join('');
|
122
|
+
},
|
123
|
+
/** Set First Char To Upper */
|
124
|
+
FirstCharToUpper: (text) => {
|
125
|
+
if (Tools.IsOnlyWhiteSpace(text))
|
126
|
+
return '';
|
127
|
+
const textArray = [];
|
128
|
+
for (let i = 0; i < text.length; i++) {
|
129
|
+
if (i === 0)
|
130
|
+
textArray.push(text[i].toUpperCase());
|
131
|
+
else
|
132
|
+
textArray.push(text[i]);
|
133
|
+
}
|
134
|
+
return textArray.join('');
|
135
|
+
},
|
136
|
+
/** Sort an array in ascending order by property */
|
137
|
+
SortBy: (array, property, propertyType = 'string') => {
|
138
|
+
switch (propertyType) {
|
139
|
+
case 'string': {
|
140
|
+
return array.sort((x, y) => {
|
141
|
+
if (String(x[property]).toUpperCase().trim() < String(y[property]).toUpperCase().trim())
|
142
|
+
return -1;
|
143
|
+
else if (String(x[property]).toUpperCase().trim() > String(y[property]).toUpperCase().trim())
|
144
|
+
return 1;
|
145
|
+
else
|
146
|
+
return 0;
|
147
|
+
});
|
148
|
+
}
|
149
|
+
case 'number': {
|
150
|
+
return array.sort((x, y) => Number(x[property] - Number(y[property])));
|
151
|
+
}
|
152
|
+
}
|
153
|
+
},
|
154
|
+
/** Sort an array in descending order by property */
|
155
|
+
SortByDesc: (array, property, propertyType = 'string') => {
|
156
|
+
switch (propertyType) {
|
157
|
+
case 'string': {
|
158
|
+
return array.sort((x, y) => {
|
159
|
+
if (String(x[property]).toUpperCase().trim() < String(y[property]).toUpperCase().trim())
|
160
|
+
return 1;
|
161
|
+
else if (String(x[property]).toUpperCase().trim() > String(y[property]).toUpperCase().trim())
|
162
|
+
return -1;
|
163
|
+
else
|
164
|
+
return 0;
|
165
|
+
});
|
166
|
+
}
|
167
|
+
case 'number': {
|
168
|
+
return array.sort((x, y) => Number(Number(y[property])) - x[property]);
|
169
|
+
}
|
170
|
+
}
|
171
|
+
},
|
172
|
+
/** Return a string with forman numeric */
|
173
|
+
GetNumericFormat: (value, decimals = 0) => {
|
174
|
+
if (Tools.IsOnlyWhiteSpace(value) || isNaN(Number(value))) {
|
175
|
+
return '0';
|
176
|
+
}
|
177
|
+
let valueInteger = '';
|
178
|
+
let valueDecimal = '';
|
179
|
+
value = value.toString().replaceAll(' ', '');
|
180
|
+
if (value.includes('.') || (decimals > 0)) {
|
181
|
+
valueInteger = value.includes('.') ? value.split('.')[0] : value;
|
182
|
+
if (decimals > 0) {
|
183
|
+
const PADDING = decimals - valueDecimal.length;
|
184
|
+
valueDecimal = value.includes('.') ? value.split('.')[1] : '';
|
185
|
+
for (let i = 0; i < PADDING; i++)
|
186
|
+
valueDecimal += '0';
|
187
|
+
valueDecimal = valueDecimal.substring(0, decimals);
|
188
|
+
valueDecimal = `.${valueDecimal}`;
|
189
|
+
}
|
190
|
+
}
|
191
|
+
else {
|
192
|
+
valueInteger = value;
|
193
|
+
}
|
194
|
+
let counter = 0;
|
195
|
+
const VALUE_INTEGER_ARRAY = [];
|
196
|
+
for (const char of valueInteger.split('').reverse()) {
|
197
|
+
if (counter == 3) {
|
198
|
+
VALUE_INTEGER_ARRAY.push(',');
|
199
|
+
counter = 0;
|
200
|
+
}
|
201
|
+
VALUE_INTEGER_ARRAY.push(char);
|
202
|
+
++counter;
|
203
|
+
}
|
204
|
+
valueInteger = VALUE_INTEGER_ARRAY.reverse().join('');
|
205
|
+
return `${valueInteger}${valueDecimal}`;
|
206
|
+
},
|
207
|
+
/** Wait the time indicated */
|
208
|
+
Sleep: (milliseconds = 0, reference = null) => {
|
209
|
+
if (Tools.IsNull(reference)) {
|
210
|
+
return new Promise(Resolve => setTimeout(Resolve, milliseconds));
|
211
|
+
}
|
212
|
+
else
|
213
|
+
return new Promise(Resolve => {
|
214
|
+
reference = reference.replaceAll(' ', '_').toLowerCase();
|
215
|
+
if (reference_signal().hasOwnProperty(reference)) {
|
216
|
+
clearInterval(reference_signal()[reference]);
|
217
|
+
}
|
218
|
+
reference_signal.set(Object.assign(reference_signal(), {
|
219
|
+
[reference]: setTimeout(() => {
|
220
|
+
Resolve();
|
221
|
+
clearInterval(reference_signal()[reference]);
|
222
|
+
const _reference = { ...reference_signal() };
|
223
|
+
delete _reference[reference];
|
224
|
+
reference_signal.set({ ..._reference });
|
225
|
+
}, milliseconds)
|
226
|
+
}));
|
227
|
+
});
|
228
|
+
}
|
229
|
+
};
|
230
|
+
|
231
|
+
class CoerAlert {
|
232
|
+
/** */
|
233
|
+
Success(message = null, title = null, icon = null, autohide = 3000) {
|
234
|
+
//Title
|
235
|
+
if (Tools.IsOnlyWhiteSpace(title))
|
236
|
+
title = 'Success';
|
237
|
+
const alertSuccessTitle = document.getElementById('alert-success-title');
|
238
|
+
alertSuccessTitle.textContent = title;
|
239
|
+
//Icon
|
240
|
+
icon = this.GetIcon(title, icon, 'bi-check-circle fa-beat');
|
241
|
+
const alertSuccessIcon = document.getElementById('alert-success-icon');
|
242
|
+
this.SetIcon(alertSuccessIcon, icon);
|
243
|
+
//Message
|
244
|
+
if (Tools.IsNull(message))
|
245
|
+
message = '';
|
246
|
+
const alertSuccessMessage = document.getElementById('alert-success-message');
|
247
|
+
alertSuccessMessage.innerHTML = message;
|
248
|
+
//Toast
|
249
|
+
const alertSuccess = document.getElementById('alert-success');
|
250
|
+
this.SetAutoHide(alertSuccess, autohide);
|
251
|
+
const toast = bootstrap.Toast.getOrCreateInstance(alertSuccess);
|
252
|
+
toast.show();
|
253
|
+
}
|
254
|
+
/** */
|
255
|
+
Error(message = null, title = null, icon = null, autohide = 3000) {
|
256
|
+
//Title
|
257
|
+
if (Tools.IsOnlyWhiteSpace(title))
|
258
|
+
title = 'Error';
|
259
|
+
const alertErrorTitle = document.getElementById('alert-error-title');
|
260
|
+
alertErrorTitle.textContent = title;
|
261
|
+
//Icon
|
262
|
+
icon = this.GetIcon(title, icon, 'bi-exclamation-octagon fa-beat');
|
263
|
+
const alertErrorIcon = document.getElementById('alert-error-icon');
|
264
|
+
this.SetIcon(alertErrorIcon, icon);
|
265
|
+
//Message
|
266
|
+
if (Tools.IsNull(message))
|
267
|
+
message = '';
|
268
|
+
const alertErrorBody = document.getElementById('alert-error-message');
|
269
|
+
alertErrorBody.innerHTML = message;
|
270
|
+
//Toast
|
271
|
+
const alertError = document.getElementById('alert-error');
|
272
|
+
this.SetAutoHide(alertError, autohide);
|
273
|
+
const toast = bootstrap.Toast.getOrCreateInstance(alertError);
|
274
|
+
toast.show();
|
275
|
+
}
|
276
|
+
/** */
|
277
|
+
Info(message = null, title = null, icon = null, autohide = 3000) {
|
278
|
+
//Title
|
279
|
+
if (Tools.IsOnlyWhiteSpace(title))
|
280
|
+
title = 'Info';
|
281
|
+
const alertInfoTitle = document.getElementById('alert-info-title');
|
282
|
+
alertInfoTitle.textContent = title;
|
283
|
+
//Icon
|
284
|
+
icon = this.GetIcon(title, icon, 'bi-info-circle fa-beat');
|
285
|
+
const alertInfoIcon = document.getElementById('alert-info-icon');
|
286
|
+
this.SetIcon(alertInfoIcon, icon);
|
287
|
+
//Message
|
288
|
+
if (Tools.IsNull(message))
|
289
|
+
message = '';
|
290
|
+
const alertInfoBody = document.getElementById('alert-info-message');
|
291
|
+
alertInfoBody.innerHTML = message;
|
292
|
+
//Toast
|
293
|
+
const alertInfo = document.getElementById('alert-info');
|
294
|
+
this.SetAutoHide(alertInfo, autohide);
|
295
|
+
const toast = bootstrap.Toast.getOrCreateInstance(alertInfo);
|
296
|
+
toast.show();
|
297
|
+
}
|
298
|
+
/** */
|
299
|
+
Warning(message = null, title = null, icon = null, autohide = 3000) {
|
300
|
+
//Title
|
301
|
+
if (Tools.IsOnlyWhiteSpace(title))
|
302
|
+
title = 'Warning';
|
303
|
+
const alertWarningTitle = document.getElementById('alert-warning-title');
|
304
|
+
alertWarningTitle.textContent = title;
|
305
|
+
//Icon
|
306
|
+
icon = this.GetIcon(title, icon, 'bi-exclamation-triangle-fill fa-beat');
|
307
|
+
const alertWarningIcon = document.getElementById('alert-warning-icon');
|
308
|
+
this.SetIcon(alertWarningIcon, icon);
|
309
|
+
//Message
|
310
|
+
if (Tools.IsNull(message))
|
311
|
+
message = '';
|
312
|
+
const alertWarningBody = document.getElementById('alert-warning-message');
|
313
|
+
alertWarningBody.innerHTML = message;
|
314
|
+
//Toast
|
315
|
+
const alertWarning = document.getElementById('alert-warning');
|
316
|
+
this.SetAutoHide(alertWarning, autohide);
|
317
|
+
const toast = bootstrap.Toast.getOrCreateInstance(alertWarning);
|
318
|
+
toast.show();
|
319
|
+
}
|
320
|
+
/** */
|
321
|
+
Close(alert) {
|
322
|
+
return new Promise(Resolve => {
|
323
|
+
const element = document.getElementById(alert);
|
324
|
+
const toast = bootstrap.Toast.getOrCreateInstance(element);
|
325
|
+
toast.hide();
|
326
|
+
setTimeout(() => { Resolve(); }, 200);
|
327
|
+
});
|
328
|
+
}
|
329
|
+
/** */
|
330
|
+
Confirm(message = 'Proceed?', alertType = 'warning', icon = null) {
|
331
|
+
return new Promise(Resolve => {
|
332
|
+
let color;
|
333
|
+
let iconType;
|
334
|
+
switch (alertType) {
|
335
|
+
case 'danger':
|
336
|
+
{
|
337
|
+
if (Tools.IsNull(icon))
|
338
|
+
icon = 'bi-exclamation-octagon';
|
339
|
+
iconType = 'error';
|
340
|
+
color = '#dc3545'; //red
|
341
|
+
break;
|
342
|
+
}
|
343
|
+
;
|
344
|
+
case 'success':
|
345
|
+
{
|
346
|
+
if (Tools.IsNull(icon))
|
347
|
+
icon = 'bi-check-circle';
|
348
|
+
iconType = 'info';
|
349
|
+
color = '#198754'; //green
|
350
|
+
break;
|
351
|
+
}
|
352
|
+
;
|
353
|
+
case 'info':
|
354
|
+
{
|
355
|
+
if (Tools.IsNull(icon))
|
356
|
+
icon = 'bi-info-circle';
|
357
|
+
iconType = 'error';
|
358
|
+
color = '#0d6efd'; //blue
|
359
|
+
break;
|
360
|
+
}
|
361
|
+
;
|
362
|
+
default: {
|
363
|
+
if (Tools.IsNull(icon))
|
364
|
+
icon = 'bi-exclamation-triangle-fill';
|
365
|
+
iconType = 'warning';
|
366
|
+
color = '#ffc107'; //yellow
|
367
|
+
break;
|
368
|
+
}
|
369
|
+
}
|
370
|
+
switch (icon) {
|
371
|
+
case 'delete':
|
372
|
+
icon = 'fa-regular fa-trash-can';
|
373
|
+
break;
|
374
|
+
}
|
375
|
+
Swal.fire({
|
376
|
+
icon: iconType,
|
377
|
+
iconColor: 'transparent',
|
378
|
+
iconHtml: `<i class="${icon}" style="color: ${color};"></i>`,
|
379
|
+
html: message,
|
380
|
+
showConfirmButton: true,
|
381
|
+
confirmButtonText: 'Yes',
|
382
|
+
confirmButtonColor: color,
|
383
|
+
focusConfirm: true,
|
384
|
+
showDenyButton: true,
|
385
|
+
denyButtonColor: color,
|
386
|
+
focusDeny: false,
|
387
|
+
reverseButtons: true,
|
388
|
+
allowOutsideClick: false,
|
389
|
+
allowEscapeKey: false,
|
390
|
+
allowEnterKey: true,
|
391
|
+
customClass: {
|
392
|
+
denyButton: 'sweet-alert-button',
|
393
|
+
confirmButton: 'sweet-alert-button'
|
394
|
+
}
|
395
|
+
}).then(({ value }) => setTimeout(() => Resolve(value)));
|
396
|
+
});
|
397
|
+
}
|
398
|
+
/** */
|
399
|
+
SetIcon(element, icon) {
|
400
|
+
for (const item of [...element.classList.value.split(' ')]) {
|
401
|
+
if (item.length > 0) {
|
402
|
+
element.classList.remove(item);
|
403
|
+
element.classList.remove('q');
|
404
|
+
}
|
405
|
+
}
|
406
|
+
icon = icon.trim();
|
407
|
+
const hasWhiteSpaces = / /;
|
408
|
+
if (hasWhiteSpaces.test(icon)) {
|
409
|
+
const classes = icon.split(' ');
|
410
|
+
for (const icon of classes)
|
411
|
+
element.classList.add(icon);
|
412
|
+
}
|
413
|
+
else
|
414
|
+
element.classList.add(icon);
|
415
|
+
}
|
416
|
+
/** */
|
417
|
+
SetAutoHide(element, autohide) {
|
418
|
+
element.removeAttribute('data-bs-autohide');
|
419
|
+
element.removeAttribute('data-bs-delay');
|
420
|
+
if (autohide && autohide > 0) {
|
421
|
+
if (autohide < 1000)
|
422
|
+
autohide = 1000;
|
423
|
+
element.setAttribute('data-bs-autohide', 'true');
|
424
|
+
element.setAttribute('data-bs-delay', String(autohide));
|
425
|
+
}
|
426
|
+
else
|
427
|
+
element.setAttribute('data-bs-autohide', 'false');
|
428
|
+
}
|
429
|
+
/** */
|
430
|
+
GetIcon(title, icon, iconDefault) {
|
431
|
+
if (icon == null || icon == '') {
|
432
|
+
title = title.replaceAll(' ', '').toUpperCase();
|
433
|
+
switch (title) {
|
434
|
+
case 'ENABLED': return 'fa-solid fa-thumbs-up fa-flip-horizontal';
|
435
|
+
case 'ACTIVE': return 'fa-solid fa-thumbs-up fa-flip-horizontal';
|
436
|
+
case 'ACTIVED': return 'fa-solid fa-thumbs-up fa-flip-horizontal';
|
437
|
+
case 'DISABLE': return 'fa-solid fa-thumbs-down fa-flip-horizontal';
|
438
|
+
case 'DISABLED': return 'fa-solid fa-thumbs-down fa-flip-horizontal';
|
439
|
+
case 'DELETE': return 'fa-regular fa-trash-can';
|
440
|
+
case 'DELETED': return 'fa-regular fa-trash-can';
|
441
|
+
default: return iconDefault;
|
442
|
+
}
|
443
|
+
}
|
444
|
+
return icon;
|
445
|
+
}
|
446
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CoerAlert, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
447
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: CoerAlert, isStandalone: true, selector: "coer-alert", ngImport: i0, template: "<aside class=\"toast-container coer-alert\">\r\n <!-- Success -->\r\n <div id=\"alert-success\" role=\"alert\" aria-live=\"assertive\" aria-atomic=\"true\" class=\"toast\">\r\n <div class=\"toast-header\">\r\n <i id=\"alert-success-icon\"></i>\r\n <strong id=\"alert-success-title\"></strong>\r\n <button type=\"button\" (click)=\"Close('alert-success')\" class=\"btn-close btn-close-white\"></button>\r\n </div>\r\n\r\n <div class=\"toast-body\">\r\n <pre id=\"alert-success-message\"></pre>\r\n </div>\r\n </div>\r\n\r\n\r\n <!-- Error -->\r\n <div id=\"alert-error\" role=\"alert\" aria-live=\"assertive\" aria-atomic=\"true\" class=\"toast\">\r\n <div class=\"toast-header\">\r\n <i id=\"alert-error-icon\"></i>\r\n <strong id=\"alert-error-title\"></strong>\r\n <button type=\"button\" (click)=\"Close('alert-error')\" class=\"btn-close btn-close-white\"></button>\r\n </div>\r\n\r\n <div class=\"toast-body\">\r\n <pre id=\"alert-error-message\"></pre>\r\n </div>\r\n </div>\r\n\r\n\r\n <!-- Info -->\r\n <div id=\"alert-info\" role=\"alert\" aria-live=\"assertive\" aria-atomic=\"true\" class=\"toast\">\r\n <div class=\"toast-header\">\r\n <i id=\"alert-info-icon\"></i>\r\n <strong id=\"alert-info-title\"></strong>\r\n <button type=\"button\" (click)=\"Close('alert-info')\" class=\"btn-close btn-close-white\"></button>\r\n </div>\r\n\r\n <div class=\"toast-body\">\r\n <pre id=\"alert-info-message\"></pre>\r\n </div>\r\n </div>\r\n\r\n\r\n <!-- Warning -->\r\n <div id=\"alert-warning\" role=\"alert\" aria-live=\"assertive\" aria-atomic=\"true\" class=\"toast\">\r\n <div class=\"toast-header\">\r\n <i id=\"alert-warning-icon\"></i>\r\n <strong id=\"alert-warning-title\"></strong>\r\n <button type=\"button\" (click)=\"Close('alert-warning')\" class=\"btn-close\"></button>\r\n </div>\r\n\r\n <div class=\"toast-body\">\r\n <pre id=\"alert-warning-message\"></pre>\r\n </div>\r\n </div>\r\n</aside>", styles: ["*{--blue: #0d6efd;--gray: #6c757d;--green: #198754;--yellow: #ffc107;--red: #dc3545;--white: #f5f5f5;--black: #252525;--orange: #fd6031}.text-blue{color:#0d6efd!important}.text-blue-bold{color:#0d6efd!important;font-weight:700!important}.background-blue{background-color:#0d6efd!important}.background-border-blue{background-color:#0d6efd!important;border-color:#0d6efd!important}.border-blue{border-color:#0d6efd!important}.text-gray{color:#6c757d!important}.text-gray-bold{color:#6c757d!important;font-weight:700!important}.background-gray{background-color:#6c757d!important}.background-border-gray{background-color:#6c757d!important;border-color:#6c757d!important}.border-gray{border-color:#6c757d!important}.text-green{color:#198754!important}.text-green-bold{color:#198754!important;font-weight:700!important}.background-green{background-color:#198754!important}.background-border-green{background-color:#198754!important;border-color:#198754!important}.border-green{border-color:#198754!important}.text-yellow{color:#ffc107!important}.text-yellow-bold{color:#ffc107!important;font-weight:700!important}.background-yellow{background-color:#ffc107!important}.background-border-yellow{background-color:#ffc107!important;border-color:#ffc107!important}.border-yellow{border-color:#ffc107!important}.text-red{color:#dc3545!important}.text-red-bold{color:#dc3545!important;font-weight:700!important}.background-red{background-color:#dc3545!important}.background-border-red{background-color:#dc3545!important;border-color:#dc3545!important}.border-red{border-color:#dc3545!important}.text-white{color:#f5f5f5!important}.text-white-bold{color:#f5f5f5!important;font-weight:700!important}.background-white{background-color:#f5f5f5!important}.background-border-white{background-color:#f5f5f5!important;border-color:#f5f5f5!important}.border-white{border-color:#f5f5f5!important}.text-black{color:#252525!important}.text-black-bold{color:#252525!important;font-weight:700!important}.background-black{background-color:#252525!important}.background-border-black{background-color:#252525!important;border-color:#252525!important}.border-black{border-color:#252525!important}.text-orange{color:#fd6031!important}.text-orange-bold{color:#fd6031!important;font-weight:700!important}.background-orange{background-color:#fd6031!important}.background-border-orange{background-color:#fd6031!important;border-color:#fd6031!important}.border-orange{border-color:#fd6031!important}aside.toast-container{position:fixed;bottom:0;right:0;padding:15px!important;z-index:2000!important}aside.toast-container i,aside.toast-container svg{display:flex;align-items:center}aside.toast-container strong{margin:0 auto 0 5px}aside.toast-container div.toast,aside.toast-container div.toast-header{border-top-left-radius:10px;border-top-right-radius:10px;color:#f5f5f5}aside.toast-container div.toast,aside.toast-container div.toast-body{border-bottom-left-radius:10px;border-bottom-right-radius:10px;color:#f5f5f5}aside.toast-container div.toast-body{min-height:36px}aside.toast-container pre{font-family:Roboto,RobotoFallback,Noto Kufi Arabic,Helvetica,Arial,sans-serif;white-space:pre-wrap;font-size:medium}aside.toast-container button{margin:0 2px!important;width:10px!important;height:10px!important;box-shadow:none!important;outline:none!important;border:none!important}aside.toast-container div#alert-success div.toast-header,aside.toast-container div#alert-success div.toast-body{background-color:#198754}aside.toast-container div#alert-info div.toast-header,aside.toast-container div#alert-info div.toast-body{background-color:#0d6efd}aside.toast-container div#alert-error div.toast-header,aside.toast-container div#alert-error div.toast-body{background-color:#dc3545}aside.toast-container div#alert-warning div.toast-header,aside.toast-container div#alert-warning div.toast-body{background-color:#ffc107;border-color:#252525;color:#252525}aside.toast-container div#alert-success:hover,aside.toast-container div#alert-info:hover,aside.toast-container div#alert-error:hover,aside.toast-container div#alert-warning:hover{transform:scale(1.01);box-shadow:2px 2px 10px #789;cursor:default}button.sweet-alert-button{width:100px!important;height:40px!important;display:flex!important;align-items:center!important;justify-content:center!important;margin:0 5px!important;outline:none!important;border:none!important;box-shadow:none!important}aside.toast-container>*{border:none!important;z-index:2000!important;margin:15px 0 0!important}\n"] }); }
|
448
|
+
}
|
449
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CoerAlert, decorators: [{
|
450
|
+
type: Component,
|
451
|
+
args: [{ selector: 'coer-alert', standalone: true, template: "<aside class=\"toast-container coer-alert\">\r\n <!-- Success -->\r\n <div id=\"alert-success\" role=\"alert\" aria-live=\"assertive\" aria-atomic=\"true\" class=\"toast\">\r\n <div class=\"toast-header\">\r\n <i id=\"alert-success-icon\"></i>\r\n <strong id=\"alert-success-title\"></strong>\r\n <button type=\"button\" (click)=\"Close('alert-success')\" class=\"btn-close btn-close-white\"></button>\r\n </div>\r\n\r\n <div class=\"toast-body\">\r\n <pre id=\"alert-success-message\"></pre>\r\n </div>\r\n </div>\r\n\r\n\r\n <!-- Error -->\r\n <div id=\"alert-error\" role=\"alert\" aria-live=\"assertive\" aria-atomic=\"true\" class=\"toast\">\r\n <div class=\"toast-header\">\r\n <i id=\"alert-error-icon\"></i>\r\n <strong id=\"alert-error-title\"></strong>\r\n <button type=\"button\" (click)=\"Close('alert-error')\" class=\"btn-close btn-close-white\"></button>\r\n </div>\r\n\r\n <div class=\"toast-body\">\r\n <pre id=\"alert-error-message\"></pre>\r\n </div>\r\n </div>\r\n\r\n\r\n <!-- Info -->\r\n <div id=\"alert-info\" role=\"alert\" aria-live=\"assertive\" aria-atomic=\"true\" class=\"toast\">\r\n <div class=\"toast-header\">\r\n <i id=\"alert-info-icon\"></i>\r\n <strong id=\"alert-info-title\"></strong>\r\n <button type=\"button\" (click)=\"Close('alert-info')\" class=\"btn-close btn-close-white\"></button>\r\n </div>\r\n\r\n <div class=\"toast-body\">\r\n <pre id=\"alert-info-message\"></pre>\r\n </div>\r\n </div>\r\n\r\n\r\n <!-- Warning -->\r\n <div id=\"alert-warning\" role=\"alert\" aria-live=\"assertive\" aria-atomic=\"true\" class=\"toast\">\r\n <div class=\"toast-header\">\r\n <i id=\"alert-warning-icon\"></i>\r\n <strong id=\"alert-warning-title\"></strong>\r\n <button type=\"button\" (click)=\"Close('alert-warning')\" class=\"btn-close\"></button>\r\n </div>\r\n\r\n <div class=\"toast-body\">\r\n <pre id=\"alert-warning-message\"></pre>\r\n </div>\r\n </div>\r\n</aside>", styles: ["*{--blue: #0d6efd;--gray: #6c757d;--green: #198754;--yellow: #ffc107;--red: #dc3545;--white: #f5f5f5;--black: #252525;--orange: #fd6031}.text-blue{color:#0d6efd!important}.text-blue-bold{color:#0d6efd!important;font-weight:700!important}.background-blue{background-color:#0d6efd!important}.background-border-blue{background-color:#0d6efd!important;border-color:#0d6efd!important}.border-blue{border-color:#0d6efd!important}.text-gray{color:#6c757d!important}.text-gray-bold{color:#6c757d!important;font-weight:700!important}.background-gray{background-color:#6c757d!important}.background-border-gray{background-color:#6c757d!important;border-color:#6c757d!important}.border-gray{border-color:#6c757d!important}.text-green{color:#198754!important}.text-green-bold{color:#198754!important;font-weight:700!important}.background-green{background-color:#198754!important}.background-border-green{background-color:#198754!important;border-color:#198754!important}.border-green{border-color:#198754!important}.text-yellow{color:#ffc107!important}.text-yellow-bold{color:#ffc107!important;font-weight:700!important}.background-yellow{background-color:#ffc107!important}.background-border-yellow{background-color:#ffc107!important;border-color:#ffc107!important}.border-yellow{border-color:#ffc107!important}.text-red{color:#dc3545!important}.text-red-bold{color:#dc3545!important;font-weight:700!important}.background-red{background-color:#dc3545!important}.background-border-red{background-color:#dc3545!important;border-color:#dc3545!important}.border-red{border-color:#dc3545!important}.text-white{color:#f5f5f5!important}.text-white-bold{color:#f5f5f5!important;font-weight:700!important}.background-white{background-color:#f5f5f5!important}.background-border-white{background-color:#f5f5f5!important;border-color:#f5f5f5!important}.border-white{border-color:#f5f5f5!important}.text-black{color:#252525!important}.text-black-bold{color:#252525!important;font-weight:700!important}.background-black{background-color:#252525!important}.background-border-black{background-color:#252525!important;border-color:#252525!important}.border-black{border-color:#252525!important}.text-orange{color:#fd6031!important}.text-orange-bold{color:#fd6031!important;font-weight:700!important}.background-orange{background-color:#fd6031!important}.background-border-orange{background-color:#fd6031!important;border-color:#fd6031!important}.border-orange{border-color:#fd6031!important}aside.toast-container{position:fixed;bottom:0;right:0;padding:15px!important;z-index:2000!important}aside.toast-container i,aside.toast-container svg{display:flex;align-items:center}aside.toast-container strong{margin:0 auto 0 5px}aside.toast-container div.toast,aside.toast-container div.toast-header{border-top-left-radius:10px;border-top-right-radius:10px;color:#f5f5f5}aside.toast-container div.toast,aside.toast-container div.toast-body{border-bottom-left-radius:10px;border-bottom-right-radius:10px;color:#f5f5f5}aside.toast-container div.toast-body{min-height:36px}aside.toast-container pre{font-family:Roboto,RobotoFallback,Noto Kufi Arabic,Helvetica,Arial,sans-serif;white-space:pre-wrap;font-size:medium}aside.toast-container button{margin:0 2px!important;width:10px!important;height:10px!important;box-shadow:none!important;outline:none!important;border:none!important}aside.toast-container div#alert-success div.toast-header,aside.toast-container div#alert-success div.toast-body{background-color:#198754}aside.toast-container div#alert-info div.toast-header,aside.toast-container div#alert-info div.toast-body{background-color:#0d6efd}aside.toast-container div#alert-error div.toast-header,aside.toast-container div#alert-error div.toast-body{background-color:#dc3545}aside.toast-container div#alert-warning div.toast-header,aside.toast-container div#alert-warning div.toast-body{background-color:#ffc107;border-color:#252525;color:#252525}aside.toast-container div#alert-success:hover,aside.toast-container div#alert-info:hover,aside.toast-container div#alert-error:hover,aside.toast-container div#alert-warning:hover{transform:scale(1.01);box-shadow:2px 2px 10px #789;cursor:default}button.sweet-alert-button{width:100px!important;height:40px!important;display:flex!important;align-items:center!important;justify-content:center!important;margin:0 5px!important;outline:none!important;border:none!important;box-shadow:none!important}aside.toast-container>*{border:none!important;z-index:2000!important;margin:15px 0 0!important}\n"] }]
|
452
|
+
}] });
|
453
|
+
|
454
|
+
class Breadcrumbs {
|
455
|
+
static { this.storage = 'COER-System'; }
|
456
|
+
/** */
|
457
|
+
static Add(page, path) {
|
458
|
+
const breadcrumbs = this.Get();
|
459
|
+
const paths = breadcrumbs.map(item => item.path);
|
460
|
+
if (!paths.includes(path)) {
|
461
|
+
breadcrumbs.push({ page, path });
|
462
|
+
this.Save(breadcrumbs);
|
463
|
+
}
|
464
|
+
}
|
465
|
+
/** */
|
466
|
+
static Get() {
|
467
|
+
let storage = sessionStorage.getItem(this.storage);
|
468
|
+
if (storage) {
|
469
|
+
storage = JSON.parse(storage);
|
470
|
+
if (storage.hasOwnProperty('breadcrumbs')) {
|
471
|
+
return Tools.BreakReference(storage.breadcrumbs);
|
472
|
+
}
|
473
|
+
}
|
474
|
+
return [];
|
475
|
+
}
|
476
|
+
/** */
|
477
|
+
static GetFirst() {
|
478
|
+
const breadcrumbs = this.Get();
|
479
|
+
return (breadcrumbs.length > 0) ? breadcrumbs.shift() : null;
|
480
|
+
}
|
481
|
+
/** */
|
482
|
+
static Save(breadcrumbs) {
|
483
|
+
let storage = sessionStorage.getItem(this.storage);
|
484
|
+
if (storage)
|
485
|
+
storage = JSON.parse(storage);
|
486
|
+
storage = Object.assign({}, storage, { breadcrumbs });
|
487
|
+
sessionStorage.setItem(this.storage, JSON.stringify(storage));
|
488
|
+
}
|
489
|
+
/** */
|
490
|
+
static Remove(path) {
|
491
|
+
let breadcrumbs = this.Get();
|
492
|
+
const index = breadcrumbs.findIndex(x => x.path.toLowerCase().trim() === path.toLowerCase().trim());
|
493
|
+
if (index >= 0) {
|
494
|
+
breadcrumbs = Tools.BreakReference(breadcrumbs).splice(0, index + 1);
|
495
|
+
this.Save(breadcrumbs);
|
496
|
+
}
|
497
|
+
}
|
498
|
+
/** */
|
499
|
+
static SetLast(page, path) {
|
500
|
+
const breadcrumbs = this.Get();
|
501
|
+
if (breadcrumbs.length > 0) {
|
502
|
+
breadcrumbs[breadcrumbs.length - 1] = { page, path };
|
503
|
+
this.Save(breadcrumbs);
|
504
|
+
}
|
505
|
+
}
|
506
|
+
/** */
|
507
|
+
static RemoveLast() {
|
508
|
+
const breadcrumbs = this.Get();
|
509
|
+
if (breadcrumbs.length > 0) {
|
510
|
+
breadcrumbs.pop();
|
511
|
+
this.Save(breadcrumbs);
|
512
|
+
}
|
513
|
+
}
|
514
|
+
}
|
515
|
+
|
516
|
+
const CONTROL_VALUE = (component) => {
|
517
|
+
return {
|
518
|
+
provide: NG_VALUE_ACCESSOR,
|
519
|
+
useExisting: forwardRef(() => component),
|
520
|
+
multi: true
|
521
|
+
};
|
522
|
+
};
|
523
|
+
class ControlValue {
|
524
|
+
constructor() {
|
525
|
+
this._isTouched = false;
|
526
|
+
}
|
527
|
+
get isTouched() {
|
528
|
+
return this._isTouched;
|
529
|
+
}
|
530
|
+
/** */
|
531
|
+
SetValue(value) {
|
532
|
+
if (typeof this._UpdateValue === 'function') {
|
533
|
+
this._UpdateValue(value);
|
534
|
+
}
|
535
|
+
this._value = value;
|
536
|
+
}
|
537
|
+
/** */
|
538
|
+
SetTouched(isTouched) {
|
539
|
+
if (typeof this._IsTouched === 'function') {
|
540
|
+
this._IsTouched(isTouched);
|
541
|
+
}
|
542
|
+
this._isTouched = isTouched;
|
543
|
+
}
|
544
|
+
/** */
|
545
|
+
writeValue(value) {
|
546
|
+
this._value = value;
|
547
|
+
}
|
548
|
+
/** */
|
549
|
+
registerOnChange(callback) {
|
550
|
+
this._UpdateValue = callback;
|
551
|
+
}
|
552
|
+
/** */
|
553
|
+
registerOnTouched(callback) {
|
554
|
+
this._IsTouched = callback;
|
555
|
+
}
|
556
|
+
/** */
|
557
|
+
setDisabledState(isDisabled) { }
|
558
|
+
}
|
559
|
+
|
560
|
+
class DateTime {
|
561
|
+
/** Get UTC Offset */
|
562
|
+
static GetOffset() {
|
563
|
+
return moment().utcOffset();
|
564
|
+
}
|
565
|
+
/** YYYY-MM-DD HH:mm:ss */
|
566
|
+
static GetFormatDB(date) {
|
567
|
+
if ((typeof date === 'string'))
|
568
|
+
date = date.replaceAll('/', '-');
|
569
|
+
return moment(date).format('YYYY-MM-DD HH:mm:ss');
|
570
|
+
}
|
571
|
+
/** Convert UTC Date to Local Zone */
|
572
|
+
static ToLocalZone(date) {
|
573
|
+
date = DateTime.GetFormatDB(date);
|
574
|
+
return moment(date).add(DateTime.GetOffset(), 'minutes').format('YYYY-MM-DD HH:mm:ss');
|
575
|
+
}
|
576
|
+
/** Convert Local Zone Date to UTC */
|
577
|
+
static ToUTC(date) {
|
578
|
+
date = DateTime.GetFormatDB(date);
|
579
|
+
return moment(date).subtract(DateTime.GetOffset(), 'minutes').format('YYYY-MM-DD HH:mm:ss');
|
580
|
+
}
|
581
|
+
/** DD MMM YYYY */
|
582
|
+
static GetDateFormat(date) {
|
583
|
+
date = DateTime.GetFormatDB(date);
|
584
|
+
return moment(date).parseZone().local(true).format('DD MMM YYYY');
|
585
|
+
}
|
586
|
+
}
|
587
|
+
|
588
|
+
class Files {
|
589
|
+
static { this.EXCEL_EXTENSIONS = ['xls', 'xlsx', 'csv']; }
|
590
|
+
/** Get Extension File */
|
591
|
+
static GetExtension(file) {
|
592
|
+
const fileName = file.name;
|
593
|
+
if (fileName.includes('.')) {
|
594
|
+
let worlds = fileName.split('.');
|
595
|
+
if (worlds.length > 0) {
|
596
|
+
let extension = worlds.pop();
|
597
|
+
extension = extension.trim().toLowerCase();
|
598
|
+
if (extension.length > 0)
|
599
|
+
return extension;
|
600
|
+
}
|
601
|
+
}
|
602
|
+
return null;
|
603
|
+
}
|
604
|
+
/** Is Excel File */
|
605
|
+
static IsExcel(file) {
|
606
|
+
const EXTENSION = Files.GetExtension(file);
|
607
|
+
return Tools.IsNotNull(EXTENSION)
|
608
|
+
? this.EXCEL_EXTENSIONS.includes(EXTENSION)
|
609
|
+
: false;
|
610
|
+
}
|
611
|
+
/** Read excel file */
|
612
|
+
static ReadExcel(file) {
|
613
|
+
return new Promise(Resolve => {
|
614
|
+
let columns = [];
|
615
|
+
let rows = [];
|
616
|
+
const reader = new FileReader();
|
617
|
+
reader.readAsArrayBuffer(file);
|
618
|
+
reader.onload = () => {
|
619
|
+
const dataBytes = new Uint8Array(reader.result);
|
620
|
+
if (dataBytes) {
|
621
|
+
const workbook = XLSX.read(dataBytes, {});
|
622
|
+
const sheet = workbook.Sheets[workbook.SheetNames[0]];
|
623
|
+
let dataSheet = XLSX.utils.sheet_to_json(sheet, {
|
624
|
+
header: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
|
625
|
+
});
|
626
|
+
//Get Headers
|
627
|
+
for (const column in dataSheet[0]) {
|
628
|
+
columns.push(Tools.FirstCharToLower(String(dataSheet[0][column]).replaceAll(' ', '')));
|
629
|
+
}
|
630
|
+
//Get Rows
|
631
|
+
rows = XLSX.utils.sheet_to_json(sheet, { header: columns });
|
632
|
+
rows.shift();
|
633
|
+
rows = rows.map(row => {
|
634
|
+
const item = Tools.BreakReference(row);
|
635
|
+
delete item['__rowNum__'];
|
636
|
+
return item;
|
637
|
+
});
|
638
|
+
}
|
639
|
+
Resolve({ columns, rows });
|
640
|
+
};
|
641
|
+
reader.onerror = () => { Resolve({ columns, rows }); };
|
642
|
+
});
|
643
|
+
}
|
644
|
+
/** Export to excel file */
|
645
|
+
static ExportExcel(data, fileName = 'coer_report', sheetName = 'Sheet1') {
|
646
|
+
sheetName = Tools.CleanUpBlanks(sheetName);
|
647
|
+
fileName = Tools.CleanUpBlanks(fileName);
|
648
|
+
if (fileName.endsWith('.xls') || fileName.endsWith('.xlsx') || fileName.endsWith('.csv')) {
|
649
|
+
if (fileName.includes('.xls')) {
|
650
|
+
fileName = fileName.replaceAll('.xls', '.xlsx');
|
651
|
+
}
|
652
|
+
if (fileName.includes('.csv')) {
|
653
|
+
fileName = fileName.replaceAll('.csv', '.xlsx');
|
654
|
+
}
|
655
|
+
}
|
656
|
+
else {
|
657
|
+
fileName += '.xlsx';
|
658
|
+
}
|
659
|
+
const WORK_SHEET = XLSX.utils.json_to_sheet(data);
|
660
|
+
const WORK_BOOK = XLSX.utils.book_new();
|
661
|
+
XLSX.utils.book_append_sheet(WORK_BOOK, WORK_SHEET, sheetName);
|
662
|
+
XLSX.writeFile(WORK_BOOK, fileName);
|
663
|
+
}
|
664
|
+
/** Convert file to string base64 */
|
665
|
+
static ConvertToBase64(file) {
|
666
|
+
return new Promise(Resolve => {
|
667
|
+
const reader = new FileReader();
|
668
|
+
reader.readAsDataURL(file);
|
669
|
+
reader.onload = () => {
|
670
|
+
Resolve(reader.result?.toString() || '');
|
671
|
+
};
|
672
|
+
reader.onerror = () => Resolve('');
|
673
|
+
});
|
674
|
+
}
|
675
|
+
}
|
676
|
+
|
677
|
+
class Menu {
|
678
|
+
static { this.storage = 'COER-System'; }
|
679
|
+
/** */
|
680
|
+
static Set(menu) {
|
681
|
+
let storage = sessionStorage.getItem(this.storage);
|
682
|
+
if (storage)
|
683
|
+
storage = JSON.parse(storage);
|
684
|
+
storage = Object.assign({}, storage, { menu });
|
685
|
+
sessionStorage.setItem(this.storage, JSON.stringify(storage));
|
686
|
+
}
|
687
|
+
/** */
|
688
|
+
static Get() {
|
689
|
+
let storage = sessionStorage.getItem(this.storage);
|
690
|
+
if (storage) {
|
691
|
+
storage = JSON.parse(storage);
|
692
|
+
if (storage.hasOwnProperty('menu')) {
|
693
|
+
return storage.menu;
|
694
|
+
}
|
695
|
+
}
|
696
|
+
return null;
|
697
|
+
}
|
698
|
+
}
|
699
|
+
|
700
|
+
class Source {
|
701
|
+
static { this.storage = 'COER-System'; }
|
702
|
+
/** */
|
703
|
+
static Set(page) {
|
704
|
+
const ROUTER = inject(Router);
|
705
|
+
let path = ROUTER.url;
|
706
|
+
if (path.includes('?'))
|
707
|
+
path = path.split('?')[0];
|
708
|
+
Breadcrumbs.Add(page, path);
|
709
|
+
const breadcrumbs = Breadcrumbs.Get();
|
710
|
+
if (breadcrumbs.length >= 2) {
|
711
|
+
breadcrumbs.pop();
|
712
|
+
const breadcrumb = breadcrumbs.pop();
|
713
|
+
this.Save({ page: breadcrumb.page, path: breadcrumb.path });
|
714
|
+
}
|
715
|
+
else
|
716
|
+
this.Save(null);
|
717
|
+
}
|
718
|
+
/** */
|
719
|
+
static Save(source) {
|
720
|
+
let storage = sessionStorage.getItem(this.storage);
|
721
|
+
if (storage)
|
722
|
+
storage = JSON.parse(storage);
|
723
|
+
storage = Object.assign({}, storage, { source });
|
724
|
+
sessionStorage.setItem(this.storage, JSON.stringify(storage));
|
725
|
+
}
|
726
|
+
/** */
|
727
|
+
static Get() {
|
728
|
+
let storage = sessionStorage.getItem(this.storage);
|
729
|
+
if (storage) {
|
730
|
+
storage = JSON.parse(storage);
|
731
|
+
if (storage.hasOwnProperty('source')) {
|
732
|
+
return storage.source;
|
733
|
+
}
|
734
|
+
}
|
735
|
+
return null;
|
736
|
+
}
|
737
|
+
/** */
|
738
|
+
static GetRoot() {
|
739
|
+
const breadcrumbs = Breadcrumbs.Get();
|
740
|
+
return (breadcrumbs.length > 0) ? breadcrumbs.shift() : null;
|
741
|
+
}
|
742
|
+
/** */
|
743
|
+
static SetPageResponse(pageResponse) {
|
744
|
+
let storage = sessionStorage.getItem(this.storage);
|
745
|
+
storage = JSON.parse(storage);
|
746
|
+
storage = Object.assign({}, storage, { pageResponse });
|
747
|
+
sessionStorage.setItem(this.storage, JSON.stringify(storage));
|
748
|
+
}
|
749
|
+
/** */
|
750
|
+
static GetPageResponse() {
|
751
|
+
let storage = sessionStorage.getItem(this.storage);
|
752
|
+
if (storage) {
|
753
|
+
storage = JSON.parse(storage);
|
754
|
+
if (storage.hasOwnProperty('pageResponse')) {
|
755
|
+
return Tools.BreakReference(storage.pageResponse);
|
756
|
+
}
|
757
|
+
}
|
758
|
+
return null;
|
759
|
+
}
|
760
|
+
/** */
|
761
|
+
static ClearPageResponse() {
|
762
|
+
let storage = sessionStorage.getItem(this.storage);
|
763
|
+
storage = JSON.parse(storage);
|
764
|
+
if (storage.hasOwnProperty('pageResponse')) {
|
765
|
+
delete storage.pageResponse;
|
766
|
+
}
|
767
|
+
storage = Object.assign({}, storage);
|
768
|
+
sessionStorage.setItem(this.storage, JSON.stringify(storage));
|
769
|
+
}
|
770
|
+
/** */
|
771
|
+
static Reset() {
|
772
|
+
sessionStorage.removeItem(this.storage);
|
773
|
+
}
|
774
|
+
}
|
775
|
+
|
776
|
+
class Page {
|
777
|
+
constructor(page) {
|
778
|
+
//Injection
|
779
|
+
this.alert = inject(CoerAlert);
|
780
|
+
this.router = inject(Router);
|
781
|
+
this.activatedRoute = inject(ActivatedRoute);
|
782
|
+
/** */
|
783
|
+
this.isUpdate = false;
|
784
|
+
/** */
|
785
|
+
this.isLoading = false;
|
786
|
+
/** */
|
787
|
+
this.isReadyPage = false;
|
788
|
+
/** */
|
789
|
+
this.enableAnimations = false;
|
790
|
+
/** */
|
791
|
+
this.breadcrumbs = [];
|
792
|
+
/** */
|
793
|
+
this.pageResponse = null;
|
794
|
+
/** */
|
795
|
+
this.goBack = { show: false };
|
796
|
+
//Private Variables
|
797
|
+
this._page = '';
|
798
|
+
this._source = null;
|
799
|
+
this._preventDestroy = false;
|
800
|
+
/** */
|
801
|
+
this.GoBack = (path) => (() => {
|
802
|
+
if (path)
|
803
|
+
Breadcrumbs.Remove(path);
|
804
|
+
else
|
805
|
+
Breadcrumbs.RemoveLast();
|
806
|
+
});
|
807
|
+
this.SetPageName(page);
|
808
|
+
this.SetSource();
|
809
|
+
this.GetSource();
|
810
|
+
this.GetNavigation();
|
811
|
+
this.SetGoBack();
|
812
|
+
this.GetPageResponse();
|
813
|
+
}
|
814
|
+
ngAfterViewInit() {
|
815
|
+
this.routeParams = this.activatedRoute.snapshot.params;
|
816
|
+
this.queryParams = this.activatedRoute.snapshot.queryParams;
|
817
|
+
setTimeout(() => {
|
818
|
+
this.isReadyPage = true;
|
819
|
+
this.RunPage();
|
820
|
+
setTimeout(() => { this.enableAnimations = true; }, 1000);
|
821
|
+
});
|
822
|
+
}
|
823
|
+
ngOnDestroy() {
|
824
|
+
if (!this._preventDestroy)
|
825
|
+
Source.ClearPageResponse();
|
826
|
+
}
|
827
|
+
/** Main method. Starts after ngAfterViewInit() */
|
828
|
+
RunPage() { }
|
829
|
+
;
|
830
|
+
/** Rename the last breadcrumb and update the url id */
|
831
|
+
SetPageName(name, id = null) {
|
832
|
+
this._page = name;
|
833
|
+
let path = this.router.url;
|
834
|
+
if (path.includes('?'))
|
835
|
+
path = path.split('?')[0];
|
836
|
+
if (id) {
|
837
|
+
const PATH_ARRAY = path.split('/');
|
838
|
+
const PATH_ID = Tools.BreakReference(PATH_ARRAY).pop();
|
839
|
+
if (PATH_ID) {
|
840
|
+
PATH_ARRAY[PATH_ARRAY.length - 1] = String(id);
|
841
|
+
path = PATH_ARRAY.join('/');
|
842
|
+
}
|
843
|
+
}
|
844
|
+
if (this.breadcrumbs.length > 0) {
|
845
|
+
this.breadcrumbs[this.breadcrumbs.length - 1].page = name;
|
846
|
+
this.breadcrumbs[this.breadcrumbs.length - 1].path = path;
|
847
|
+
Breadcrumbs.SetLast(name, path);
|
848
|
+
}
|
849
|
+
this.router.navigateByUrl(path);
|
850
|
+
}
|
851
|
+
/** */
|
852
|
+
SetSource() {
|
853
|
+
Source.Set(this._page);
|
854
|
+
}
|
855
|
+
/** */
|
856
|
+
GetSource() {
|
857
|
+
this._source = Source.Get();
|
858
|
+
}
|
859
|
+
/** */
|
860
|
+
GetPageResponse() {
|
861
|
+
this.pageResponse = Source.GetPageResponse();
|
862
|
+
}
|
863
|
+
/** */
|
864
|
+
GetNavigation() {
|
865
|
+
if (this._source) {
|
866
|
+
this.breadcrumbs = Breadcrumbs.Get().map(item => Object.assign({
|
867
|
+
page: item.page,
|
868
|
+
path: item.path,
|
869
|
+
click: this.GoBack(item.path)
|
870
|
+
}));
|
871
|
+
}
|
872
|
+
else
|
873
|
+
this.breadcrumbs = [{ page: this._page }];
|
874
|
+
}
|
875
|
+
/** */
|
876
|
+
SetGoBack() {
|
877
|
+
if (this._source) {
|
878
|
+
this.goBack = {
|
879
|
+
show: true,
|
880
|
+
path: this._source.path,
|
881
|
+
click: this.GoBack()
|
882
|
+
};
|
883
|
+
}
|
884
|
+
}
|
885
|
+
/** Navigate to previous page */
|
886
|
+
GoToSource(pageResponse = null) {
|
887
|
+
if (this._source) {
|
888
|
+
Breadcrumbs.RemoveLast();
|
889
|
+
this.SetPageResponse(pageResponse);
|
890
|
+
Tools.Sleep().then(_ => this.router.navigateByUrl(this._source.path));
|
891
|
+
}
|
892
|
+
}
|
893
|
+
;
|
894
|
+
/** */
|
895
|
+
SetPageResponse(pageResponse = null) {
|
896
|
+
if (Tools.IsNotNull(pageResponse)) {
|
897
|
+
this._preventDestroy = true;
|
898
|
+
Source.SetPageResponse(pageResponse);
|
899
|
+
}
|
900
|
+
}
|
901
|
+
;
|
902
|
+
/** */
|
903
|
+
ReloadPage() {
|
904
|
+
Breadcrumbs.RemoveLast();
|
905
|
+
setTimeout(() => window.location.reload());
|
906
|
+
}
|
907
|
+
/** */
|
908
|
+
Log(value, log = null) {
|
909
|
+
if (Tools.IsNotNull(log))
|
910
|
+
console.log({ log, value });
|
911
|
+
else
|
912
|
+
console.log(value);
|
913
|
+
}
|
914
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: Page, deps: [{ token: String }], target: i0.ɵɵFactoryTarget.Component }); }
|
915
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: Page, selector: "ng-component", ngImport: i0, template: '', isInline: true }); }
|
916
|
+
}
|
917
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: Page, decorators: [{
|
918
|
+
type: Component,
|
919
|
+
args: [{ template: '' }]
|
920
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
921
|
+
type: Inject,
|
922
|
+
args: [String]
|
923
|
+
}] }] });
|
924
|
+
|
925
|
+
class Screen {
|
926
|
+
static get WINDOW_WIDTH() {
|
927
|
+
return window.innerWidth;
|
928
|
+
}
|
929
|
+
static get WINDOW_HEIGHT() {
|
930
|
+
return window.innerHeight;
|
931
|
+
}
|
932
|
+
static get DEVICE_WIDTH() {
|
933
|
+
return window.screen.width;
|
934
|
+
}
|
935
|
+
static get DEVICE_HEIGHT() {
|
936
|
+
return window.screen.height;
|
937
|
+
}
|
938
|
+
static get BREAKPOINT() {
|
939
|
+
if (window.innerWidth < 576)
|
940
|
+
return 'xs';
|
941
|
+
else if (window.innerWidth >= 576 && window.innerWidth < 768)
|
942
|
+
return 'sm';
|
943
|
+
else if (window.innerWidth >= 768 && window.innerWidth < 992)
|
944
|
+
return 'md';
|
945
|
+
else if (window.innerWidth >= 992 && window.innerWidth < 1200)
|
946
|
+
return 'lg';
|
947
|
+
else if (window.innerWidth >= 1200 && window.innerWidth < 1400)
|
948
|
+
return 'xl';
|
949
|
+
else
|
950
|
+
return 'xxl';
|
951
|
+
}
|
952
|
+
/** */
|
953
|
+
static { this.Resize = new Observable(subscriber => {
|
954
|
+
window.addEventListener("load", () => {
|
955
|
+
window.dispatchEvent(new Event('resize'));
|
956
|
+
});
|
957
|
+
window.onresize = () => {
|
958
|
+
subscriber.next({
|
959
|
+
width: this.WINDOW_WIDTH,
|
960
|
+
height: this.WINDOW_HEIGHT,
|
961
|
+
breakpoin: this.BREAKPOINT
|
962
|
+
});
|
963
|
+
};
|
964
|
+
}); }
|
965
|
+
/** */
|
966
|
+
static { this.BackButtonBrowser = new Observable(subscriber => {
|
967
|
+
window.addEventListener('popstate', popStateEvent => {
|
968
|
+
if (popStateEvent.state && popStateEvent.target) {
|
969
|
+
subscriber.next(popStateEvent.target.location.href);
|
970
|
+
}
|
971
|
+
});
|
972
|
+
}); }
|
973
|
+
}
|
974
|
+
|
975
|
+
class Service {
|
976
|
+
constructor() {
|
977
|
+
//Injections
|
978
|
+
this.alert = inject(CoerAlert);
|
979
|
+
this.http = inject(HttpClient);
|
980
|
+
this.httpCode = {
|
981
|
+
Ok: 200,
|
982
|
+
Created: 201,
|
983
|
+
NoContent: 204,
|
984
|
+
BadRequest: 400,
|
985
|
+
Unauthorize: 401,
|
986
|
+
NotFound: 404,
|
987
|
+
NotAllowed: 405,
|
988
|
+
NotAcceptable: 406,
|
989
|
+
Conflict: 409,
|
990
|
+
PayloadTooLarge: 413,
|
991
|
+
InnerError: 500
|
992
|
+
};
|
993
|
+
}
|
994
|
+
/** */
|
995
|
+
ReleaseSubscription(subscription) {
|
996
|
+
if (subscription && !subscription.closed)
|
997
|
+
subscription.unsubscribe();
|
998
|
+
}
|
999
|
+
/** HTTP GET */
|
1000
|
+
HTTP_GET(request) {
|
1001
|
+
return new Promise(Resolve => {
|
1002
|
+
this.ReleaseSubscription(this._GET$);
|
1003
|
+
this._GET$ = this.http.request(new HttpRequest("GET", request.url, { params: request.queryParams, headers: request.headers })).subscribe({
|
1004
|
+
next: (response) => {
|
1005
|
+
if (response.type > 0) {
|
1006
|
+
Resolve({
|
1007
|
+
body: Tools.BreakReference(response.body),
|
1008
|
+
status: response.status,
|
1009
|
+
message: response.statusText,
|
1010
|
+
ok: true
|
1011
|
+
});
|
1012
|
+
}
|
1013
|
+
},
|
1014
|
+
error: (httpError) => {
|
1015
|
+
this.ReleaseSubscription(this._GET$);
|
1016
|
+
//this.AlertError(httpError, request.alertError);
|
1017
|
+
Resolve({
|
1018
|
+
body: {},
|
1019
|
+
status: httpError.status,
|
1020
|
+
message: httpError.error?.message || httpError.error,
|
1021
|
+
ok: false
|
1022
|
+
});
|
1023
|
+
},
|
1024
|
+
complete: () => {
|
1025
|
+
this.ReleaseSubscription(this._GET$);
|
1026
|
+
if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
|
1027
|
+
////this.alert.Success(request.alertSuccess);
|
1028
|
+
}
|
1029
|
+
}
|
1030
|
+
});
|
1031
|
+
});
|
1032
|
+
}
|
1033
|
+
/** HTTP POST */
|
1034
|
+
HTTP_POST(request) {
|
1035
|
+
return new Promise(Resolve => {
|
1036
|
+
this.ReleaseSubscription(this._POST$);
|
1037
|
+
this._POST$ = this.http.request(new HttpRequest("POST", request.url, request.body, { params: request.queryParams, headers: request.headers })).subscribe({
|
1038
|
+
next: (response) => {
|
1039
|
+
if (response.type > 0) {
|
1040
|
+
Resolve({
|
1041
|
+
body: Tools.BreakReference(response.body),
|
1042
|
+
status: response.status,
|
1043
|
+
message: response.statusText,
|
1044
|
+
ok: true
|
1045
|
+
});
|
1046
|
+
}
|
1047
|
+
},
|
1048
|
+
error: (httpError) => {
|
1049
|
+
this.ReleaseSubscription(this._POST$);
|
1050
|
+
//this.AlertError(httpError, request.alertError);
|
1051
|
+
Resolve({
|
1052
|
+
body: {},
|
1053
|
+
status: httpError.status,
|
1054
|
+
message: httpError.error?.message || httpError.error,
|
1055
|
+
ok: false
|
1056
|
+
});
|
1057
|
+
},
|
1058
|
+
complete: () => {
|
1059
|
+
this.ReleaseSubscription(this._POST$);
|
1060
|
+
if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
|
1061
|
+
//this.alert.Success(request.alertSuccess);
|
1062
|
+
}
|
1063
|
+
}
|
1064
|
+
});
|
1065
|
+
});
|
1066
|
+
}
|
1067
|
+
/** HTTP PUT */
|
1068
|
+
HTTP_PUT(request) {
|
1069
|
+
return new Promise(Resolve => {
|
1070
|
+
this.ReleaseSubscription(this._PUT$);
|
1071
|
+
this._PUT$ = this.http.request(new HttpRequest("PUT", request.url, request.body, { params: request.queryParams, headers: request.headers })).subscribe({
|
1072
|
+
next: (response) => {
|
1073
|
+
if (response.type > 0) {
|
1074
|
+
Resolve({
|
1075
|
+
body: {},
|
1076
|
+
status: response.status,
|
1077
|
+
message: response.statusText,
|
1078
|
+
ok: true
|
1079
|
+
});
|
1080
|
+
}
|
1081
|
+
},
|
1082
|
+
error: (httpError) => {
|
1083
|
+
this.ReleaseSubscription(this._PUT$);
|
1084
|
+
//this.AlertError(httpError, request.alertError);
|
1085
|
+
Resolve({
|
1086
|
+
body: {},
|
1087
|
+
status: httpError.status,
|
1088
|
+
message: httpError.error?.message || httpError.error,
|
1089
|
+
ok: false
|
1090
|
+
});
|
1091
|
+
},
|
1092
|
+
complete: () => {
|
1093
|
+
this.ReleaseSubscription(this._PUT$);
|
1094
|
+
if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
|
1095
|
+
//this.alert.Success(request.alertSuccess, 'Updated', 'fa-solid fa-arrows-rotate fa-spin');
|
1096
|
+
}
|
1097
|
+
}
|
1098
|
+
});
|
1099
|
+
});
|
1100
|
+
}
|
1101
|
+
/** HTTP PATCH */
|
1102
|
+
HTTP_PATCH(request) {
|
1103
|
+
return new Promise(Resolve => {
|
1104
|
+
this.ReleaseSubscription(this._PATCH$);
|
1105
|
+
this._PATCH$ = this.http.request(new HttpRequest("PATCH", request.url, request.body, { params: request.queryParams, headers: request.headers })).subscribe({
|
1106
|
+
next: (response) => {
|
1107
|
+
if (response.type > 0) {
|
1108
|
+
Resolve({
|
1109
|
+
body: {},
|
1110
|
+
status: response.status,
|
1111
|
+
message: response.statusText,
|
1112
|
+
ok: true
|
1113
|
+
});
|
1114
|
+
}
|
1115
|
+
},
|
1116
|
+
error: (httpError) => {
|
1117
|
+
this.ReleaseSubscription(this._PATCH$);
|
1118
|
+
//this.AlertError(httpError, request.alertError);
|
1119
|
+
Resolve({
|
1120
|
+
body: {},
|
1121
|
+
status: httpError.status,
|
1122
|
+
message: httpError.error?.message || httpError.error,
|
1123
|
+
ok: false
|
1124
|
+
});
|
1125
|
+
},
|
1126
|
+
complete: () => {
|
1127
|
+
this.ReleaseSubscription(this._PATCH$);
|
1128
|
+
if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
|
1129
|
+
//this.alert.Success(request.alertSuccess, 'Updated', 'fa-solid fa-arrows-rotate fa-spin');
|
1130
|
+
}
|
1131
|
+
}
|
1132
|
+
});
|
1133
|
+
});
|
1134
|
+
}
|
1135
|
+
/** HTTP DELETE */
|
1136
|
+
HTTP_DELETE(request) {
|
1137
|
+
return new Promise(Resolve => {
|
1138
|
+
this.ReleaseSubscription(this._DELETE$);
|
1139
|
+
this._DELETE$ = this.http.request(new HttpRequest("DELETE", request.url, { params: request.queryParams, headers: request.headers })).subscribe({
|
1140
|
+
next: (response) => {
|
1141
|
+
if (response.type > 0) {
|
1142
|
+
Resolve({
|
1143
|
+
body: {},
|
1144
|
+
status: response.status,
|
1145
|
+
message: response.statusText,
|
1146
|
+
ok: true
|
1147
|
+
});
|
1148
|
+
}
|
1149
|
+
},
|
1150
|
+
error: (httpError) => {
|
1151
|
+
this.ReleaseSubscription(this._DELETE$);
|
1152
|
+
//this.AlertError(httpError, request.alertError);
|
1153
|
+
Resolve({
|
1154
|
+
body: {},
|
1155
|
+
status: httpError.status,
|
1156
|
+
message: httpError.error?.message || httpError.error,
|
1157
|
+
ok: false
|
1158
|
+
});
|
1159
|
+
},
|
1160
|
+
complete: () => {
|
1161
|
+
this.ReleaseSubscription(this._DELETE$);
|
1162
|
+
if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
|
1163
|
+
//this.alert.Success(request.alertSuccess, 'Deleted', 'fa-regular fa-trash-can');
|
1164
|
+
}
|
1165
|
+
}
|
1166
|
+
});
|
1167
|
+
});
|
1168
|
+
}
|
1169
|
+
/** */
|
1170
|
+
AlertError(httpError, message) {
|
1171
|
+
if (httpError.status >= 500) {
|
1172
|
+
if (Tools.IsNotOnlyWhiteSpace(message)) {
|
1173
|
+
//this.alert.Error('', message, 'fa-solid fa-bug', null);
|
1174
|
+
}
|
1175
|
+
}
|
1176
|
+
else if (httpError.status < 500) {
|
1177
|
+
switch (httpError.status) {
|
1178
|
+
case 400: {
|
1179
|
+
//this.alert.Warning(httpError.error?.message || httpError.error, 'Bad Request', 'fa-regular fa-face-grin-beam-sweat fa-lg');
|
1180
|
+
break;
|
1181
|
+
}
|
1182
|
+
case 401: {
|
1183
|
+
//this.alert.Warning(httpError.error?.message || httpError.error, 'Unauthorize', 'fa-regular fa-face-rolling-eyes fa-lg');
|
1184
|
+
break;
|
1185
|
+
}
|
1186
|
+
case 404: {
|
1187
|
+
//this.alert.Warning(httpError.error?.message || httpError.error, 'Not Found', 'fa-regular fa-face-meh fa-lg');
|
1188
|
+
break;
|
1189
|
+
}
|
1190
|
+
case 405: {
|
1191
|
+
//this.alert.Warning(httpError.error?.message || httpError.error, 'Not Allowed', 'fa-regular fa-face-grimace fa-lg');
|
1192
|
+
break;
|
1193
|
+
}
|
1194
|
+
case 406: {
|
1195
|
+
//this.alert.Warning(httpError.error?.message || httpError.error, 'Not Acceptable', 'fa-regular fa-face-frown-open fa-lg');
|
1196
|
+
break;
|
1197
|
+
}
|
1198
|
+
case 409: {
|
1199
|
+
//this.alert.Warning(httpError.error?.message || httpError.error, 'Conflict', 'fa-regular fa-face-dizzy fa-lg');
|
1200
|
+
break;
|
1201
|
+
}
|
1202
|
+
case 413: {
|
1203
|
+
//this.alert.Warning(httpError.error?.message || httpError.error, 'Too Large', 'fa-regular fa-face-flushed fa-lg');
|
1204
|
+
break;
|
1205
|
+
}
|
1206
|
+
default: {
|
1207
|
+
if (httpError.status <= 0) {
|
1208
|
+
//this.alert.Warning('Without Connection', 'WEB API DOWN', 'fa-solid fa-plug-circle-xmark fa-lg', null);
|
1209
|
+
}
|
1210
|
+
else //this.alert.Warning(httpError.error?.message || httpError.error);
|
1211
|
+
break;
|
1212
|
+
}
|
1213
|
+
}
|
1214
|
+
}
|
1215
|
+
}
|
1216
|
+
}
|
1217
|
+
|
1218
|
+
/**
|
1219
|
+
* Generated bundle index. Do not edit.
|
1220
|
+
*/
|
1221
|
+
|
1222
|
+
export { Breadcrumbs, CONTROL_VALUE, CoerAlert, ControlValue, DateTime, Files, Menu, Page, Screen, Service, Source, Tools };
|
1223
|
+
//# sourceMappingURL=coer-elements-tools.mjs.map
|