coer-elements 1.0.16 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +63 -1
- package/components/index.d.ts +5 -0
- package/components/lib/coer-accordion/coer-accordion.component.d.ts +32 -0
- package/components/lib/coer-button/coer-button.component.d.ts +46 -0
- package/components/lib/coer-checkbox/coer-checkbox.component.d.ts +29 -0
- package/components/lib/coer-datebox/coer-datebox.component.d.ts +58 -0
- package/components/lib/coer-dropdown/coer-dropdown.component.d.ts +69 -0
- package/components/lib/coer-filebox/coer-filebox.component.d.ts +36 -0
- package/components/lib/coer-form/coer-form.component.d.ts +36 -0
- package/components/lib/coer-grid/coer-grid.component.d.ts +53 -0
- package/components/lib/coer-grid/coer-grid.extension.d.ts +111 -0
- package/components/lib/coer-list/coer-list.component.d.ts +57 -0
- package/components/lib/coer-modal/coer-modal.component.d.ts +38 -0
- package/components/lib/coer-numberbox/coer-numberbox.component.d.ts +56 -0
- package/components/lib/coer-page-title/coer-page-title.component.d.ts +14 -0
- package/components/lib/coer-selectbox/coer-selectbox.component.d.ts +79 -0
- package/components/lib/coer-sidenav/coer-menu-option/coer-menu-option.component.d.ts +22 -0
- package/components/lib/coer-sidenav/coer-sidenav.component.d.ts +49 -0
- package/components/lib/coer-sidenav/coer-toolbar/coer-toolbar.component.d.ts +32 -0
- package/components/lib/coer-sidenav/coer-tree-accordion/coer-tree-accordion.component.d.ts +43 -0
- package/components/lib/coer-switch/coer-switch.component.d.ts +32 -0
- package/components/lib/coer-tab/coer-tab.component.d.ts +36 -0
- package/components/lib/coer-textarea/coer-textarea.component.d.ts +52 -0
- package/components/lib/coer-textbox/coer-textbox.component.d.ts +66 -0
- package/components/lib/components.module.d.ts +46 -0
- package/components/public-api.d.ts +21 -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/extensions/index.d.ts +5 -0
- package/extensions/lib/object.extension.d.ts +1 -0
- package/extensions/lib/string.extension.d.ts +19 -0
- package/extensions/public-api.d.ts +2 -0
- package/fesm2022/coer-elements-components.mjs +4040 -0
- package/fesm2022/coer-elements-components.mjs.map +1 -0
- package/fesm2022/coer-elements-directives.mjs +84 -0
- package/fesm2022/coer-elements-directives.mjs.map +1 -0
- package/fesm2022/coer-elements-extensions.mjs +68 -0
- package/fesm2022/coer-elements-extensions.mjs.map +1 -0
- package/fesm2022/coer-elements-guards.mjs +28 -0
- package/fesm2022/coer-elements-guards.mjs.map +1 -0
- package/fesm2022/coer-elements-interceptors.mjs +64 -0
- package/fesm2022/coer-elements-interceptors.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-pages.mjs +441 -0
- package/fesm2022/coer-elements-pages.mjs.map +1 -0
- package/fesm2022/coer-elements-pipes.mjs +87 -0
- package/fesm2022/coer-elements-pipes.mjs.map +1 -0
- package/fesm2022/coer-elements-signals.mjs +35 -0
- package/fesm2022/coer-elements-signals.mjs.map +1 -0
- package/fesm2022/coer-elements-tools.mjs +1899 -0
- package/fesm2022/coer-elements-tools.mjs.map +1 -0
- package/fesm2022/coer-elements.mjs +68 -0
- package/fesm2022/coer-elements.mjs.map +1 -0
- package/guards/index.d.ts +5 -0
- package/guards/lib/login.guard.d.ts +2 -0
- package/guards/lib/page.guard.d.ts +2 -0
- package/guards/public-api.d.ts +2 -0
- package/images/loading.gif +0 -0
- package/images/no-image.png +0 -0
- package/images/no-user.png +0 -0
- package/index.d.ts +12 -0
- package/interceptors/index.d.ts +5 -0
- package/interceptors/lib/user.interceptor.d.ts +8 -0
- package/interceptors/lib/utc-offset.interceptor.d.ts +8 -0
- package/interceptors/public-api.d.ts +1 -0
- package/interfaces/index.d.ts +5 -0
- package/interfaces/lib/app-source.interface.d.ts +4 -0
- package/interfaces/lib/box-button.interface.d.ts +6 -0
- package/interfaces/lib/bulk-load.interface.d.ts +5 -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 +24 -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 +5 -0
- package/interfaces/lib/coer-grid/grid-sort.interface.d.ts +5 -0
- package/interfaces/lib/coer-menu/menu-access.interface.d.ts +7 -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 +10 -0
- package/interfaces/lib/coer-ref.interface.d.ts +10 -0
- package/interfaces/lib/image.interface.d.ts +11 -0
- package/interfaces/lib/login-response.interface.d.ts +10 -0
- package/interfaces/lib/login.interface.d.ts +4 -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/page-title/information.interface.d.ts +4 -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/lib/toolbar-menu.interface.d.ts +5 -0
- package/interfaces/public-api.d.ts +41 -0
- package/package.json +67 -34
- package/pages/index.d.ts +5 -0
- package/pages/lib/coer-loading/loading.component.d.ts +5 -0
- package/pages/lib/coer-menu/coer-menu.component.d.ts +12 -0
- package/pages/lib/coer-system/coer-system.component.d.ts +64 -0
- package/pages/lib/coer-system/login/login.component.d.ts +31 -0
- package/pages/lib/home/home.component.d.ts +7 -0
- package/pages/lib/pages.module.d.ts +18 -0
- package/pages/public-api.d.ts +5 -0
- 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-selected.signal.d.ts +2 -0
- package/signals/lib/navigation.signal.d.ts +2 -0
- package/signals/public-api.d.ts +6 -0
- package/styles/angular-material.scss +20 -0
- package/styles/animations.scss +11 -0
- package/styles/bootstrap.scss +1 -14
- package/styles/coer-elements.css +2054 -0
- package/styles/colors.scss +90 -49
- package/styles/containers.scss +44 -0
- package/styles/cursores.scss +19 -0
- package/styles/index.scss +58 -0
- package/styles/layout.scss +49 -0
- package/styles/position.scss +7 -0
- package/styles/scroll-bar.scss +20 -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/coer-grid.templates.d.ts +11 -0
- package/tools/lib/colors.class.d.ts +21 -0
- package/tools/lib/control-value.class.d.ts +25 -0
- package/tools/lib/date-time.class.d.ts +21 -0
- package/tools/lib/elements-html.class.d.ts +8 -0
- package/tools/lib/files.class.d.ts +16 -0
- package/tools/lib/filters.class.d.ts +11 -0
- package/tools/lib/menu.class.d.ts +9 -0
- package/tools/lib/page.class.d.ts +83 -0
- package/tools/lib/screen.class.d.ts +13 -0
- package/tools/lib/section.class.d.ts +33 -0
- package/tools/lib/service.class.d.ts +40 -0
- package/tools/lib/source.class.d.ts +20 -0
- package/tools/lib/tools.d.ts +42 -0
- package/tools/lib/user.class.d.ts +11 -0
- package/tools/public-api.d.ts +17 -0
- package/Signals/index.ts +0 -7
- package/Tools/Breadcrumbs.class.ts +0 -84
- package/Tools/ControlValue.ts +0 -63
- package/Tools/DateTime.class.ts +0 -27
- package/Tools/Files.class.ts +0 -119
- package/Tools/Page.class.ts +0 -197
- package/Tools/Screen.class.ts +0 -50
- package/Tools/Source.class.ts +0 -107
- package/Tools/Tools.ts +0 -212
- package/components/coer-alert/coer-alert.component.html +0 -56
- package/components/coer-alert/coer-alert.component.scss +0 -100
- package/components/coer-alert/coer-alert.component.ts +0 -249
- package/components/index.ts +0 -96
- package/index.ts +0 -8
- package/interfaces/index.ts +0 -47
- package/styles/coer.scss +0 -95
- package/tsconfig.json +0 -29
@@ -0,0 +1,1899 @@
|
|
1
|
+
import * as i0 from '@angular/core';
|
2
|
+
import { signal, Component, forwardRef, inject, Inject, input, output } 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 { navigationSIGNAL } from 'coer-elements/signals';
|
9
|
+
import { Router, ActivatedRoute } from '@angular/router';
|
10
|
+
import { Observable } from 'rxjs';
|
11
|
+
import { HttpClient, HttpRequest } from '@angular/common/http';
|
12
|
+
|
13
|
+
const reference_signal = signal({});
|
14
|
+
const Tools = {
|
15
|
+
/** Generate a Guid */
|
16
|
+
GetGuid: (seed = 'coer-system') => {
|
17
|
+
let time = new Date().getTime();
|
18
|
+
seed = seed.toString().trim();
|
19
|
+
return seed + `-xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g, (c) => {
|
20
|
+
const random = (time + Math.random() * 16) % 16 | 0;
|
21
|
+
time = Math.floor(time / 16);
|
22
|
+
return (c == 'x' ? random : (random & 0x3 | 0x8)).toString(16);
|
23
|
+
});
|
24
|
+
},
|
25
|
+
/** Returns true if the value is null or undefined, false otherwise */
|
26
|
+
IsNull: (value) => {
|
27
|
+
return (value === undefined || value === null);
|
28
|
+
},
|
29
|
+
/** Returns true if the value is not null or undefined, false otherwise */
|
30
|
+
IsNotNull: (value) => {
|
31
|
+
return !Tools.IsNull(value);
|
32
|
+
},
|
33
|
+
/** Returns true if the value is null or undefined or contains only whitespace, false otherwise */
|
34
|
+
IsOnlyWhiteSpace: (value) => {
|
35
|
+
return Tools.IsNull(value) || (typeof value === 'string' && value.trim() === '');
|
36
|
+
},
|
37
|
+
/** Returns true if has string value and is not only whitespace, false otherwise */
|
38
|
+
IsNotOnlyWhiteSpace: (value) => {
|
39
|
+
return Tools.IsNotNull(value) && !Tools.IsOnlyWhiteSpace(value);
|
40
|
+
},
|
41
|
+
/** Avoid Null value */
|
42
|
+
AvoidNull: (value, type = null) => {
|
43
|
+
if (typeof value === 'string') {
|
44
|
+
if (type === null || type === 'string') {
|
45
|
+
return (Tools.IsNotNull(value) ? value : '');
|
46
|
+
}
|
47
|
+
else if (type === 'number') {
|
48
|
+
return (Tools.IsNotNull(value) ? Number(value) : 0);
|
49
|
+
}
|
50
|
+
else if (type === 'boolean') {
|
51
|
+
return (Tools.IsNotNull(value) ? (value.toUpperCase().trim() === 'TRUE') : false);
|
52
|
+
}
|
53
|
+
}
|
54
|
+
if (typeof value === 'number') {
|
55
|
+
if (type === null || type === 'number') {
|
56
|
+
return (Tools.IsNotNull(value) ? value : 0);
|
57
|
+
}
|
58
|
+
else if (type === 'string') {
|
59
|
+
return (Tools.IsNotNull(value) ? String(value) : '0');
|
60
|
+
}
|
61
|
+
else if (type === 'boolean') {
|
62
|
+
return (Tools.IsNotNull(value) ? (value >= 1) : false);
|
63
|
+
}
|
64
|
+
}
|
65
|
+
if (typeof value === "boolean") {
|
66
|
+
if (type === null || type === 'boolean') {
|
67
|
+
return (Tools.IsNotNull(value) ? value : false);
|
68
|
+
}
|
69
|
+
else if (type === 'string') {
|
70
|
+
return (Tools.IsNotNull(value) ? (value ? 'true' : 'false') : 'false');
|
71
|
+
}
|
72
|
+
else if (type === 'number') {
|
73
|
+
return (Tools.IsNotNull(value) ? (value ? 1 : 0) : 0);
|
74
|
+
}
|
75
|
+
}
|
76
|
+
switch (type) {
|
77
|
+
case 'string': return '';
|
78
|
+
case 'number': return 0;
|
79
|
+
case 'boolean': return false;
|
80
|
+
default: return '';
|
81
|
+
}
|
82
|
+
},
|
83
|
+
/** */
|
84
|
+
RemoveAccents: (value) => {
|
85
|
+
if (Tools.IsOnlyWhiteSpace(value))
|
86
|
+
return '';
|
87
|
+
return value.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
|
88
|
+
},
|
89
|
+
/** Break reference of a object or array */
|
90
|
+
BreakReference: (object) => {
|
91
|
+
if (object === null)
|
92
|
+
return object;
|
93
|
+
if (typeof object === 'undefined')
|
94
|
+
return object;
|
95
|
+
if (typeof object === 'string')
|
96
|
+
return object;
|
97
|
+
if (typeof object === 'number')
|
98
|
+
return object;
|
99
|
+
if (typeof object === 'boolean')
|
100
|
+
return object;
|
101
|
+
const OBJECT = JSON.parse(JSON.stringify(object));
|
102
|
+
return (Array.isArray(OBJECT)) ? [...OBJECT] : { ...OBJECT };
|
103
|
+
},
|
104
|
+
/** Clean extra whitespaces */
|
105
|
+
CleanUpBlanks: (text) => {
|
106
|
+
if (Tools.IsOnlyWhiteSpace(text))
|
107
|
+
return '';
|
108
|
+
let words = String(text).split(' ');
|
109
|
+
words = words.filter(x => x.length > 0);
|
110
|
+
return words.join(' ');
|
111
|
+
},
|
112
|
+
/** Get properties of an object */
|
113
|
+
GetPropertyList: (object) => {
|
114
|
+
const properties = [];
|
115
|
+
if (object === null)
|
116
|
+
return properties;
|
117
|
+
if (typeof object === 'undefined')
|
118
|
+
return properties;
|
119
|
+
if (typeof object === 'string')
|
120
|
+
return properties;
|
121
|
+
if (typeof object === 'number')
|
122
|
+
return properties;
|
123
|
+
if (typeof object === 'boolean')
|
124
|
+
return properties;
|
125
|
+
for (const property in object)
|
126
|
+
properties.push(String(property));
|
127
|
+
return properties;
|
128
|
+
},
|
129
|
+
/**
|
130
|
+
* Set an index and merge more arrays of the same type
|
131
|
+
* */
|
132
|
+
SetIndex: (array, ...args) => {
|
133
|
+
let index = 0;
|
134
|
+
for (const arg of args) {
|
135
|
+
array = Tools.BreakReference(array).concat(Tools.BreakReference(arg));
|
136
|
+
}
|
137
|
+
return Tools.BreakReference(array).map(item => Object.assign({ index: index++ }, item));
|
138
|
+
},
|
139
|
+
/** Set First Char To Lower */
|
140
|
+
FirstCharToLower: (text) => {
|
141
|
+
if (Tools.IsOnlyWhiteSpace(text))
|
142
|
+
return '';
|
143
|
+
const textArray = [];
|
144
|
+
for (let i = 0; i < text.length; i++) {
|
145
|
+
if (i === 0)
|
146
|
+
textArray.push(text[i].toLowerCase());
|
147
|
+
else
|
148
|
+
textArray.push(text[i]);
|
149
|
+
}
|
150
|
+
return textArray.join('');
|
151
|
+
},
|
152
|
+
/** Set First Char To Upper */
|
153
|
+
FirstCharToUpper: (text) => {
|
154
|
+
if (Tools.IsOnlyWhiteSpace(text))
|
155
|
+
return '';
|
156
|
+
const textArray = [];
|
157
|
+
for (let i = 0; i < text.length; i++) {
|
158
|
+
if (i === 0)
|
159
|
+
textArray.push(text[i].toUpperCase());
|
160
|
+
else
|
161
|
+
textArray.push(text[i]);
|
162
|
+
}
|
163
|
+
return textArray.join('');
|
164
|
+
},
|
165
|
+
/** Sort an array in ascending order by property */
|
166
|
+
SortBy: (array, property, propertyType = 'string') => {
|
167
|
+
switch (propertyType) {
|
168
|
+
case 'string': {
|
169
|
+
return array.sort((x, y) => {
|
170
|
+
if (String(x[property]).toUpperCase().trim() < String(y[property]).toUpperCase().trim())
|
171
|
+
return -1;
|
172
|
+
else if (String(x[property]).toUpperCase().trim() > String(y[property]).toUpperCase().trim())
|
173
|
+
return 1;
|
174
|
+
else
|
175
|
+
return 0;
|
176
|
+
});
|
177
|
+
}
|
178
|
+
case 'number': {
|
179
|
+
return array.sort((x, y) => Number(x[property] - Number(y[property])));
|
180
|
+
}
|
181
|
+
}
|
182
|
+
},
|
183
|
+
/** Sort an array in descending order by property */
|
184
|
+
SortByDesc: (array, property, propertyType = 'string') => {
|
185
|
+
switch (propertyType) {
|
186
|
+
case 'string': {
|
187
|
+
return array.sort((x, y) => {
|
188
|
+
if (String(x[property]).toUpperCase().trim() < String(y[property]).toUpperCase().trim())
|
189
|
+
return 1;
|
190
|
+
else if (String(x[property]).toUpperCase().trim() > String(y[property]).toUpperCase().trim())
|
191
|
+
return -1;
|
192
|
+
else
|
193
|
+
return 0;
|
194
|
+
});
|
195
|
+
}
|
196
|
+
case 'number': {
|
197
|
+
return array.sort((x, y) => Number(Number(y[property])) - x[property]);
|
198
|
+
}
|
199
|
+
}
|
200
|
+
},
|
201
|
+
/** Return a string with forman numeric */
|
202
|
+
GetNumericFormat: (value, decimals = 0) => {
|
203
|
+
if (Tools.IsOnlyWhiteSpace(value) || isNaN(Number(value))) {
|
204
|
+
return '0';
|
205
|
+
}
|
206
|
+
let valueInteger = '';
|
207
|
+
let valueDecimal = '';
|
208
|
+
value = value.toString().replaceAll(' ', '');
|
209
|
+
if (value.includes('.') || (decimals > 0)) {
|
210
|
+
valueInteger = value.includes('.') ? value.split('.')[0] : value;
|
211
|
+
if (decimals > 0) {
|
212
|
+
const PADDING = decimals - valueDecimal.length;
|
213
|
+
valueDecimal = value.includes('.') ? value.split('.')[1] : '';
|
214
|
+
for (let i = 0; i < PADDING; i++)
|
215
|
+
valueDecimal += '0';
|
216
|
+
valueDecimal = valueDecimal.substring(0, decimals);
|
217
|
+
valueDecimal = `.${valueDecimal}`;
|
218
|
+
}
|
219
|
+
}
|
220
|
+
else {
|
221
|
+
valueInteger = value;
|
222
|
+
}
|
223
|
+
let counter = 0;
|
224
|
+
const VALUE_INTEGER_ARRAY = [];
|
225
|
+
for (const char of valueInteger.split('').reverse()) {
|
226
|
+
if (counter == 3) {
|
227
|
+
VALUE_INTEGER_ARRAY.push(',');
|
228
|
+
counter = 0;
|
229
|
+
}
|
230
|
+
VALUE_INTEGER_ARRAY.push(char);
|
231
|
+
++counter;
|
232
|
+
}
|
233
|
+
valueInteger = VALUE_INTEGER_ARRAY.reverse().join('');
|
234
|
+
return `${valueInteger}${valueDecimal}`;
|
235
|
+
},
|
236
|
+
/** Wait the time indicated */
|
237
|
+
Sleep: (milliseconds = 0, reference = null) => {
|
238
|
+
if (Tools.IsNull(reference)) {
|
239
|
+
return new Promise(Resolve => setTimeout(Resolve, milliseconds));
|
240
|
+
}
|
241
|
+
else
|
242
|
+
return new Promise(Resolve => {
|
243
|
+
reference = reference.replaceAll(' ', '_').toLowerCase();
|
244
|
+
if (reference_signal().hasOwnProperty(reference)) {
|
245
|
+
clearInterval(reference_signal()[reference]);
|
246
|
+
}
|
247
|
+
reference_signal.set(Object.assign(reference_signal(), {
|
248
|
+
[reference]: setTimeout(() => {
|
249
|
+
Resolve();
|
250
|
+
clearInterval(reference_signal()[reference]);
|
251
|
+
const _reference = { ...reference_signal() };
|
252
|
+
delete _reference[reference];
|
253
|
+
reference_signal.set({ ..._reference });
|
254
|
+
}, milliseconds)
|
255
|
+
}));
|
256
|
+
});
|
257
|
+
},
|
258
|
+
/** */
|
259
|
+
Distinct: (array, ...args) => {
|
260
|
+
for (const arg of args) {
|
261
|
+
array = Tools.BreakReference(array).concat(Tools.BreakReference(arg));
|
262
|
+
}
|
263
|
+
return Array.from(new Set(array));
|
264
|
+
},
|
265
|
+
/** */
|
266
|
+
Except: (array, filter, ...properties) => {
|
267
|
+
const result = [];
|
268
|
+
for (const item of array) {
|
269
|
+
if (typeof item === 'object' && Tools.IsNotNull(properties) && properties.length > 0) {
|
270
|
+
if (!filter.some(x => x[properties[0]] === item[properties[0]])) {
|
271
|
+
result.push(item);
|
272
|
+
}
|
273
|
+
}
|
274
|
+
}
|
275
|
+
return [...result];
|
276
|
+
}
|
277
|
+
};
|
278
|
+
|
279
|
+
class Colors {
|
280
|
+
static { this.blue = '#0d6efd'; }
|
281
|
+
static { this.gray = '#6c757d'; }
|
282
|
+
static { this.green = '#198754'; }
|
283
|
+
static { this.yellow = '#ffc107'; }
|
284
|
+
static { this.red = '#dc3545'; }
|
285
|
+
static { this.white = '#f5f5f5'; }
|
286
|
+
static { this.black = '#252525'; }
|
287
|
+
static { this.orange = '#fd6031'; }
|
288
|
+
static { this.purple = '#a615bc'; }
|
289
|
+
/** Returns the color palette in hexadecimal */
|
290
|
+
static { this.colorsHex = new Map([
|
291
|
+
['blue', '#0d6efd'],
|
292
|
+
['gray', '#6c757d'],
|
293
|
+
['green', '#198754'],
|
294
|
+
['yellow', '#ffc107'],
|
295
|
+
['red', '#dc3545'],
|
296
|
+
['white', '#f5f5f5'],
|
297
|
+
['black', '#252525'],
|
298
|
+
['orange', '#fd6031'],
|
299
|
+
['purple', '#a615bc'],
|
300
|
+
]); }
|
301
|
+
/** Returns the color palette in RGB */
|
302
|
+
static { this.ColorsRGB = new Map([
|
303
|
+
['blue', [13, 110, 253]],
|
304
|
+
['gray', [108, 117, 125]],
|
305
|
+
['green', [25, 135, 84]],
|
306
|
+
['yellow', [225, 193, 7]],
|
307
|
+
['red', [220, 53, 69]],
|
308
|
+
['white', [245, 245, 245]],
|
309
|
+
['black', [37, 37, 37]],
|
310
|
+
['orange', [253, 96, 49]],
|
311
|
+
['purple', [166, 21, 188]],
|
312
|
+
]); }
|
313
|
+
/** Returns a random color in hexadecimal */
|
314
|
+
static { this.GetRandomColorHex = () => "#xxxxxx".replace(/x/g, () => (Math.random() * 16 | 0).toString(16)); }
|
315
|
+
/** Returns the number of colors requested */
|
316
|
+
static GetColorHexList(quantity) {
|
317
|
+
const colors = [];
|
318
|
+
let counter = 0;
|
319
|
+
while (counter < quantity) {
|
320
|
+
for (const color of this.colorsHex.values()) {
|
321
|
+
colors.push(color);
|
322
|
+
if (++counter === quantity)
|
323
|
+
break;
|
324
|
+
}
|
325
|
+
}
|
326
|
+
return colors;
|
327
|
+
}
|
328
|
+
/** Returns the number of colors requested with opacity */
|
329
|
+
static GetColorRGBList(quantity) {
|
330
|
+
const colors = [];
|
331
|
+
let alpha = 1.0;
|
332
|
+
let counter = 0;
|
333
|
+
let lastColor = [...Array.from(this.ColorsRGB.keys())].pop();
|
334
|
+
while (counter < quantity) {
|
335
|
+
for (const [color, value] of this.ColorsRGB.entries()) {
|
336
|
+
colors.push(`rgba(${value[0]}, ${value[1]}, ${value[2]}, ${alpha})`);
|
337
|
+
if (color === lastColor)
|
338
|
+
alpha -= 0.2;
|
339
|
+
if (++counter === quantity)
|
340
|
+
break;
|
341
|
+
}
|
342
|
+
}
|
343
|
+
return colors;
|
344
|
+
}
|
345
|
+
}
|
346
|
+
|
347
|
+
class CoerAlert {
|
348
|
+
/** */
|
349
|
+
Success(message = null, title = null, icon = null, autohide = 3000) {
|
350
|
+
//Title
|
351
|
+
if (Tools.IsOnlyWhiteSpace(title))
|
352
|
+
title = 'Success';
|
353
|
+
const alertSuccessTitle = document.getElementById('alert-success-title');
|
354
|
+
alertSuccessTitle.textContent = title;
|
355
|
+
//Icon
|
356
|
+
icon = this.GetIcon(title, icon, 'bi-check-circle fa-beat');
|
357
|
+
const alertSuccessIcon = document.getElementById('alert-success-icon');
|
358
|
+
this.SetIcon(alertSuccessIcon, icon);
|
359
|
+
//Message
|
360
|
+
if (Tools.IsNull(message))
|
361
|
+
message = '';
|
362
|
+
const alertSuccessMessage = document.getElementById('alert-success-message');
|
363
|
+
alertSuccessMessage.innerHTML = message;
|
364
|
+
//Toast
|
365
|
+
const alertSuccess = document.getElementById('alert-success');
|
366
|
+
this.SetAutoHide(alertSuccess, autohide);
|
367
|
+
const toast = bootstrap.Toast.getOrCreateInstance(alertSuccess);
|
368
|
+
toast.show();
|
369
|
+
}
|
370
|
+
/** */
|
371
|
+
Error(message = null, title = null, icon = null, autohide = 3000) {
|
372
|
+
//Title
|
373
|
+
if (Tools.IsOnlyWhiteSpace(title))
|
374
|
+
title = 'Error';
|
375
|
+
const alertErrorTitle = document.getElementById('alert-error-title');
|
376
|
+
alertErrorTitle.textContent = title;
|
377
|
+
//Icon
|
378
|
+
icon = this.GetIcon(title, icon, 'bi-exclamation-octagon fa-beat');
|
379
|
+
const alertErrorIcon = document.getElementById('alert-error-icon');
|
380
|
+
this.SetIcon(alertErrorIcon, icon);
|
381
|
+
//Message
|
382
|
+
if (Tools.IsNull(message))
|
383
|
+
message = '';
|
384
|
+
const alertErrorBody = document.getElementById('alert-error-message');
|
385
|
+
alertErrorBody.innerHTML = message;
|
386
|
+
//Toast
|
387
|
+
const alertError = document.getElementById('alert-error');
|
388
|
+
this.SetAutoHide(alertError, autohide);
|
389
|
+
const toast = bootstrap.Toast.getOrCreateInstance(alertError);
|
390
|
+
toast.show();
|
391
|
+
}
|
392
|
+
/** */
|
393
|
+
Info(message = null, title = null, icon = null, autohide = 3000) {
|
394
|
+
//Title
|
395
|
+
if (Tools.IsOnlyWhiteSpace(title))
|
396
|
+
title = 'Info';
|
397
|
+
const alertInfoTitle = document.getElementById('alert-info-title');
|
398
|
+
alertInfoTitle.textContent = title;
|
399
|
+
//Icon
|
400
|
+
icon = this.GetIcon(title, icon, 'bi-info-circle fa-beat');
|
401
|
+
const alertInfoIcon = document.getElementById('alert-info-icon');
|
402
|
+
this.SetIcon(alertInfoIcon, icon);
|
403
|
+
//Message
|
404
|
+
if (Tools.IsNull(message))
|
405
|
+
message = '';
|
406
|
+
const alertInfoBody = document.getElementById('alert-info-message');
|
407
|
+
alertInfoBody.innerHTML = message;
|
408
|
+
//Toast
|
409
|
+
const alertInfo = document.getElementById('alert-info');
|
410
|
+
this.SetAutoHide(alertInfo, autohide);
|
411
|
+
const toast = bootstrap.Toast.getOrCreateInstance(alertInfo);
|
412
|
+
toast.show();
|
413
|
+
}
|
414
|
+
/** */
|
415
|
+
Warning(message = null, title = null, icon = null, autohide = 3000) {
|
416
|
+
//Title
|
417
|
+
if (Tools.IsOnlyWhiteSpace(title))
|
418
|
+
title = 'Warning';
|
419
|
+
const alertWarningTitle = document.getElementById('alert-warning-title');
|
420
|
+
alertWarningTitle.textContent = title;
|
421
|
+
//Icon
|
422
|
+
icon = this.GetIcon(title, icon, 'bi-exclamation-triangle-fill fa-beat');
|
423
|
+
const alertWarningIcon = document.getElementById('alert-warning-icon');
|
424
|
+
this.SetIcon(alertWarningIcon, icon);
|
425
|
+
//Message
|
426
|
+
if (Tools.IsNull(message))
|
427
|
+
message = '';
|
428
|
+
const alertWarningBody = document.getElementById('alert-warning-message');
|
429
|
+
alertWarningBody.innerHTML = message;
|
430
|
+
//Toast
|
431
|
+
const alertWarning = document.getElementById('alert-warning');
|
432
|
+
this.SetAutoHide(alertWarning, autohide);
|
433
|
+
const toast = bootstrap.Toast.getOrCreateInstance(alertWarning);
|
434
|
+
toast.show();
|
435
|
+
}
|
436
|
+
/** */
|
437
|
+
Close(alert) {
|
438
|
+
return new Promise(Resolve => {
|
439
|
+
const element = document.getElementById(alert);
|
440
|
+
const toast = bootstrap.Toast.getOrCreateInstance(element);
|
441
|
+
toast.hide();
|
442
|
+
setTimeout(() => { Resolve(); }, 200);
|
443
|
+
});
|
444
|
+
}
|
445
|
+
/** */
|
446
|
+
Confirm(message = 'Proceed?', alertType = 'warning', icon = null) {
|
447
|
+
return new Promise(Resolve => {
|
448
|
+
let color;
|
449
|
+
let iconType;
|
450
|
+
switch (alertType) {
|
451
|
+
case 'danger':
|
452
|
+
{
|
453
|
+
if (Tools.IsNull(icon))
|
454
|
+
icon = 'bi-exclamation-octagon';
|
455
|
+
iconType = 'error';
|
456
|
+
color = Colors.red;
|
457
|
+
break;
|
458
|
+
}
|
459
|
+
;
|
460
|
+
case 'success':
|
461
|
+
{
|
462
|
+
if (Tools.IsNull(icon))
|
463
|
+
icon = 'bi-check-circle';
|
464
|
+
iconType = 'info';
|
465
|
+
color = Colors.green;
|
466
|
+
break;
|
467
|
+
}
|
468
|
+
;
|
469
|
+
case 'info':
|
470
|
+
{
|
471
|
+
if (Tools.IsNull(icon))
|
472
|
+
icon = 'bi-info-circle';
|
473
|
+
iconType = 'error';
|
474
|
+
color = Colors.black;
|
475
|
+
break;
|
476
|
+
}
|
477
|
+
;
|
478
|
+
default: {
|
479
|
+
if (Tools.IsNull(icon))
|
480
|
+
icon = 'bi-exclamation-triangle-fill';
|
481
|
+
iconType = 'warning';
|
482
|
+
color = Colors.yellow;
|
483
|
+
break;
|
484
|
+
}
|
485
|
+
}
|
486
|
+
switch (icon) {
|
487
|
+
case 'delete':
|
488
|
+
icon = 'fa-regular fa-trash-can';
|
489
|
+
break;
|
490
|
+
}
|
491
|
+
Swal.fire({
|
492
|
+
icon: iconType,
|
493
|
+
iconColor: 'transparent',
|
494
|
+
iconHtml: `<i class="${icon}" style="color: ${color};"></i>`,
|
495
|
+
html: message,
|
496
|
+
showConfirmButton: true,
|
497
|
+
confirmButtonText: 'Yes',
|
498
|
+
confirmButtonColor: color,
|
499
|
+
focusConfirm: true,
|
500
|
+
showDenyButton: true,
|
501
|
+
denyButtonColor: color,
|
502
|
+
focusDeny: false,
|
503
|
+
reverseButtons: true,
|
504
|
+
allowOutsideClick: false,
|
505
|
+
allowEscapeKey: false,
|
506
|
+
allowEnterKey: true,
|
507
|
+
customClass: {
|
508
|
+
denyButton: 'sweet-alert-button',
|
509
|
+
confirmButton: 'sweet-alert-button'
|
510
|
+
}
|
511
|
+
}).then(({ value }) => setTimeout(() => Resolve(value)));
|
512
|
+
});
|
513
|
+
}
|
514
|
+
/** */
|
515
|
+
SetIcon(element, icon) {
|
516
|
+
if (icon.toUpperCase() != 'NONE') {
|
517
|
+
for (const item of [...element.classList.value.split(' ')]) {
|
518
|
+
if (item.length > 0) {
|
519
|
+
element.classList.remove(item);
|
520
|
+
element.classList.remove('q');
|
521
|
+
}
|
522
|
+
}
|
523
|
+
icon = icon.trim();
|
524
|
+
const hasWhiteSpaces = / /;
|
525
|
+
if (hasWhiteSpaces.test(icon)) {
|
526
|
+
const classes = icon.split(' ');
|
527
|
+
for (const icon of classes)
|
528
|
+
element.classList.add(icon);
|
529
|
+
}
|
530
|
+
else
|
531
|
+
element.classList.add(icon);
|
532
|
+
}
|
533
|
+
}
|
534
|
+
/** */
|
535
|
+
SetAutoHide(element, autohide) {
|
536
|
+
element.removeAttribute('data-bs-autohide');
|
537
|
+
element.removeAttribute('data-bs-delay');
|
538
|
+
if (autohide && autohide > 0) {
|
539
|
+
if (autohide < 1000)
|
540
|
+
autohide = 1000;
|
541
|
+
element.setAttribute('data-bs-autohide', 'true');
|
542
|
+
element.setAttribute('data-bs-delay', String(autohide));
|
543
|
+
}
|
544
|
+
else
|
545
|
+
element.setAttribute('data-bs-autohide', 'false');
|
546
|
+
}
|
547
|
+
/** */
|
548
|
+
GetIcon(title, icon, iconDefault) {
|
549
|
+
if (icon == null || icon == '') {
|
550
|
+
title = title.replaceAll(' ', '').toUpperCase();
|
551
|
+
switch (title) {
|
552
|
+
case 'ENABLED': return 'fa-solid fa-thumbs-up fa-flip-horizontal';
|
553
|
+
case 'ACTIVE': return 'fa-solid fa-thumbs-up fa-flip-horizontal';
|
554
|
+
case 'ACTIVED': return 'fa-solid fa-thumbs-up fa-flip-horizontal';
|
555
|
+
case 'DISABLE': return 'fa-solid fa-thumbs-down fa-flip-horizontal';
|
556
|
+
case 'DISABLED': return 'fa-solid fa-thumbs-down fa-flip-horizontal';
|
557
|
+
case 'DELETE': return 'fa-regular fa-trash-can';
|
558
|
+
case 'DELETED': return 'fa-regular fa-trash-can';
|
559
|
+
default: return iconDefault;
|
560
|
+
}
|
561
|
+
}
|
562
|
+
return icon;
|
563
|
+
}
|
564
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: CoerAlert, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
565
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.1", 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: [":root{--blue: #0d6efd;--gray: #6c757d;--green: #198754;--yellow: #ffc107;--red: #dc3545;--white: #f5f5f5;--black: #252525;--orange: #fd6031;--purple: #a615bc}.text-blue{color:var(--blue)!important}.text-blue-bold{color:var(--blue)!important;font-weight:700!important}.background-blue{background-color:var(--blue)!important}.background-border-blue{background-color:var(--blue)!important;border-color:var(--blue)!important}.border-blue{border-color:var(--blue)!important}.text-gray{color:var(--gray)!important}.text-gray-bold{color:var(--gray)!important;font-weight:700!important}.background-gray{background-color:var(--gray)!important}.background-border-gray{background-color:var(--gray)!important;border-color:var(--gray)!important}.border-gray{border-color:var(--gray)!important}.text-green{color:var(--green)!important}.text-green-bold{color:var(--green)!important;font-weight:700!important}.background-green{background-color:var(--green)!important}.background-border-green{background-color:var(--green)!important;border-color:var(--green)!important}.border-green{border-color:var(--green)!important}.text-yellow{color:var(--yellow)!important}.text-yellow-bold{color:var(--yellow)!important;font-weight:700!important}.background-yellow{background-color:var(--yellow)!important}.background-border-yellow{background-color:var(--yellow)!important;border-color:var(--yellow)!important}.border-yellow{border-color:var(--yellow)!important}.text-red{color:var(--red)!important}.text-red-bold{color:var(--red)!important;font-weight:700!important}.background-red{background-color:var(--red)!important}.background-border-red{background-color:var(--red)!important;border-color:var(--red)!important}.border-red{border-color:var(--red)!important}.text-white{color:var(--white)!important}.text-white-bold{color:var(--white)!important;font-weight:700!important}.background-white{background-color:var(--white)!important}.background-border-white{background-color:var(--white)!important;border-color:var(--white)!important}.border-white{border-color:var(--white)!important}.text-black{color:var(--black)!important}.text-black-bold{color:var(--black)!important;font-weight:700!important}.background-black{background-color:var(--black)!important}.background-border-black{background-color:var(--black)!important;border-color:var(--black)!important}.border-black{border-color:var(--black)!important}.text-orange{color:var(--orange)!important}.text-orange-bold{color:var(--orange)!important;font-weight:700!important}.background-orange{background-color:var(--orange)!important}.background-border-orange{background-color:var(--orange)!important;border-color:var(--orange)!important}.border-orange{border-color:var(--orange)!important}.text-transparent{color:transparent!important}.background-transparent{background-color:transparent!important}.border-transparent{border-color:transparent!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:var(--white)}aside.toast-container div.toast,aside.toast-container div.toast-body{border-bottom-left-radius:10px;border-bottom-right-radius:10px;width:auto!important;min-width:350px!important;max-width:470px!important;color:var(--white)}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:var(--green)}aside.toast-container div#alert-info div.toast-header,aside.toast-container div#alert-info div.toast-body{background-color:var(--blue)}aside.toast-container div#alert-error div.toast-header,aside.toast-container div#alert-error div.toast-body{background-color:var(--red)}aside.toast-container div#alert-warning div.toast-header,aside.toast-container div#alert-warning div.toast-body{background-color:var(--yellow);border-color:var(--black);color:var(--black)}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"] }); }
|
566
|
+
}
|
567
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: CoerAlert, decorators: [{
|
568
|
+
type: Component,
|
569
|
+
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: [":root{--blue: #0d6efd;--gray: #6c757d;--green: #198754;--yellow: #ffc107;--red: #dc3545;--white: #f5f5f5;--black: #252525;--orange: #fd6031;--purple: #a615bc}.text-blue{color:var(--blue)!important}.text-blue-bold{color:var(--blue)!important;font-weight:700!important}.background-blue{background-color:var(--blue)!important}.background-border-blue{background-color:var(--blue)!important;border-color:var(--blue)!important}.border-blue{border-color:var(--blue)!important}.text-gray{color:var(--gray)!important}.text-gray-bold{color:var(--gray)!important;font-weight:700!important}.background-gray{background-color:var(--gray)!important}.background-border-gray{background-color:var(--gray)!important;border-color:var(--gray)!important}.border-gray{border-color:var(--gray)!important}.text-green{color:var(--green)!important}.text-green-bold{color:var(--green)!important;font-weight:700!important}.background-green{background-color:var(--green)!important}.background-border-green{background-color:var(--green)!important;border-color:var(--green)!important}.border-green{border-color:var(--green)!important}.text-yellow{color:var(--yellow)!important}.text-yellow-bold{color:var(--yellow)!important;font-weight:700!important}.background-yellow{background-color:var(--yellow)!important}.background-border-yellow{background-color:var(--yellow)!important;border-color:var(--yellow)!important}.border-yellow{border-color:var(--yellow)!important}.text-red{color:var(--red)!important}.text-red-bold{color:var(--red)!important;font-weight:700!important}.background-red{background-color:var(--red)!important}.background-border-red{background-color:var(--red)!important;border-color:var(--red)!important}.border-red{border-color:var(--red)!important}.text-white{color:var(--white)!important}.text-white-bold{color:var(--white)!important;font-weight:700!important}.background-white{background-color:var(--white)!important}.background-border-white{background-color:var(--white)!important;border-color:var(--white)!important}.border-white{border-color:var(--white)!important}.text-black{color:var(--black)!important}.text-black-bold{color:var(--black)!important;font-weight:700!important}.background-black{background-color:var(--black)!important}.background-border-black{background-color:var(--black)!important;border-color:var(--black)!important}.border-black{border-color:var(--black)!important}.text-orange{color:var(--orange)!important}.text-orange-bold{color:var(--orange)!important;font-weight:700!important}.background-orange{background-color:var(--orange)!important}.background-border-orange{background-color:var(--orange)!important;border-color:var(--orange)!important}.border-orange{border-color:var(--orange)!important}.text-transparent{color:transparent!important}.background-transparent{background-color:transparent!important}.border-transparent{border-color:transparent!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:var(--white)}aside.toast-container div.toast,aside.toast-container div.toast-body{border-bottom-left-radius:10px;border-bottom-right-radius:10px;width:auto!important;min-width:350px!important;max-width:470px!important;color:var(--white)}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:var(--green)}aside.toast-container div#alert-info div.toast-header,aside.toast-container div#alert-info div.toast-body{background-color:var(--blue)}aside.toast-container div#alert-error div.toast-header,aside.toast-container div#alert-error div.toast-body{background-color:var(--red)}aside.toast-container div#alert-warning div.toast-header,aside.toast-container div#alert-warning div.toast-body{background-color:var(--yellow);border-color:var(--black);color:var(--black)}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"] }]
|
570
|
+
}] });
|
571
|
+
|
572
|
+
class Breadcrumbs {
|
573
|
+
static { this.storage = 'COER-System'; }
|
574
|
+
/** */
|
575
|
+
static Add(page, path) {
|
576
|
+
const breadcrumbs = this.Get();
|
577
|
+
const paths = breadcrumbs.map(item => item.path);
|
578
|
+
if (!paths.includes(path)) {
|
579
|
+
breadcrumbs.push({ page, path });
|
580
|
+
this.Save(breadcrumbs);
|
581
|
+
}
|
582
|
+
}
|
583
|
+
/** */
|
584
|
+
static Get() {
|
585
|
+
let storage = sessionStorage.getItem(this.storage);
|
586
|
+
if (storage) {
|
587
|
+
storage = JSON.parse(storage);
|
588
|
+
if (storage.hasOwnProperty('breadcrumbs')) {
|
589
|
+
return Tools.BreakReference(storage.breadcrumbs);
|
590
|
+
}
|
591
|
+
}
|
592
|
+
return [];
|
593
|
+
}
|
594
|
+
/** */
|
595
|
+
static GetFirst() {
|
596
|
+
const breadcrumbs = this.Get();
|
597
|
+
return (breadcrumbs.length > 0) ? breadcrumbs.shift() : null;
|
598
|
+
}
|
599
|
+
/** */
|
600
|
+
static Save(breadcrumbs) {
|
601
|
+
let storage = sessionStorage.getItem(this.storage);
|
602
|
+
if (storage)
|
603
|
+
storage = JSON.parse(storage);
|
604
|
+
storage = Object.assign({}, storage, { breadcrumbs });
|
605
|
+
sessionStorage.setItem(this.storage, JSON.stringify(storage));
|
606
|
+
}
|
607
|
+
/** */
|
608
|
+
static Remove(path) {
|
609
|
+
let breadcrumbs = this.Get();
|
610
|
+
const index = breadcrumbs.findIndex(x => x.path.toLowerCase().trim() === path.toLowerCase().trim());
|
611
|
+
if (index >= 0) {
|
612
|
+
breadcrumbs = Tools.BreakReference(breadcrumbs).splice(0, index + 1);
|
613
|
+
this.Save(breadcrumbs);
|
614
|
+
}
|
615
|
+
}
|
616
|
+
/** */
|
617
|
+
static SetLast(page, path) {
|
618
|
+
const breadcrumbs = this.Get();
|
619
|
+
if (breadcrumbs.length > 0) {
|
620
|
+
breadcrumbs[breadcrumbs.length - 1] = { page, path };
|
621
|
+
this.Save(breadcrumbs);
|
622
|
+
}
|
623
|
+
}
|
624
|
+
/** */
|
625
|
+
static RemoveLast() {
|
626
|
+
const breadcrumbs = this.Get();
|
627
|
+
if (breadcrumbs.length > 0) {
|
628
|
+
breadcrumbs.pop();
|
629
|
+
this.Save(breadcrumbs);
|
630
|
+
}
|
631
|
+
}
|
632
|
+
}
|
633
|
+
|
634
|
+
const GridTemplates = {
|
635
|
+
/** Template for boolean property */
|
636
|
+
isActiveTemplate: (item) => {
|
637
|
+
if (item.value) {
|
638
|
+
return `
|
639
|
+
<span class='text-green-bold'>
|
640
|
+
<i class="fa-solid fa-circle-check"></i> Active
|
641
|
+
</span>
|
642
|
+
`;
|
643
|
+
}
|
644
|
+
else {
|
645
|
+
return `
|
646
|
+
<span class='text-gray-bold'>
|
647
|
+
<i class="fa-solid fa-circle-minus"></i> Disabled
|
648
|
+
</span>
|
649
|
+
`;
|
650
|
+
}
|
651
|
+
},
|
652
|
+
/** Template for boolean property */
|
653
|
+
coerSwitchTemplate: (item) => ({
|
654
|
+
isInput: true,
|
655
|
+
tooltip: `${item.value ? 'Active' : 'Disabled'}`
|
656
|
+
}),
|
657
|
+
/** Template for text property */
|
658
|
+
coerTextboxTemplate: (item) => ({
|
659
|
+
isInput: true,
|
660
|
+
isInvalid: item.value.length <= 0
|
661
|
+
}),
|
662
|
+
/** Template for text property */
|
663
|
+
coerIconTemplate: (icon, color = 'black') => {
|
664
|
+
return `<i class='${icon} d-block w-100 text-center' style='color: ${color};'></i>`;
|
665
|
+
}
|
666
|
+
};
|
667
|
+
|
668
|
+
const CONTROL_VALUE = (component) => {
|
669
|
+
return {
|
670
|
+
provide: NG_VALUE_ACCESSOR,
|
671
|
+
useExisting: forwardRef(() => component),
|
672
|
+
multi: true
|
673
|
+
};
|
674
|
+
};
|
675
|
+
class ControlValue {
|
676
|
+
constructor() {
|
677
|
+
this._isTouched = false;
|
678
|
+
}
|
679
|
+
get isTouched() {
|
680
|
+
return this._isTouched;
|
681
|
+
}
|
682
|
+
/** */
|
683
|
+
SetValue(value) {
|
684
|
+
if (typeof this._UpdateValue === 'function') {
|
685
|
+
this._UpdateValue(value);
|
686
|
+
}
|
687
|
+
this._value = value;
|
688
|
+
}
|
689
|
+
/** */
|
690
|
+
SetTouched(isTouched) {
|
691
|
+
if (typeof this._IsTouched === 'function') {
|
692
|
+
this._IsTouched(isTouched);
|
693
|
+
}
|
694
|
+
this._isTouched = isTouched;
|
695
|
+
}
|
696
|
+
/** */
|
697
|
+
writeValue(value) {
|
698
|
+
this._value = value;
|
699
|
+
}
|
700
|
+
/** */
|
701
|
+
registerOnChange(callback) {
|
702
|
+
this._UpdateValue = callback;
|
703
|
+
}
|
704
|
+
/** */
|
705
|
+
registerOnTouched(callback) {
|
706
|
+
this._IsTouched = callback;
|
707
|
+
}
|
708
|
+
/** */
|
709
|
+
setDisabledState(isDisabled) { }
|
710
|
+
}
|
711
|
+
|
712
|
+
class DateTime {
|
713
|
+
/** Get UTC Offset */
|
714
|
+
static GetOffset() {
|
715
|
+
return moment().utcOffset();
|
716
|
+
}
|
717
|
+
/** YYYY-MM-DD HH:mm:ss */
|
718
|
+
static GetFormatDB(date) {
|
719
|
+
date = new Date(date.toString());
|
720
|
+
return moment(date).format('YYYY-MM-DD HH:mm:ss');
|
721
|
+
}
|
722
|
+
/** Convert UTC Date to Local Zone */
|
723
|
+
static ToLocalZone(date) {
|
724
|
+
date = DateTime.GetFormatDB(date);
|
725
|
+
return moment(date).add(DateTime.GetOffset(), 'minutes').format('YYYY-MM-DD HH:mm:ss');
|
726
|
+
}
|
727
|
+
/** Convert Local Zone Date to UTC */
|
728
|
+
static ToUTC(date) {
|
729
|
+
date = DateTime.GetFormatDB(date);
|
730
|
+
return moment(date).subtract(DateTime.GetOffset(), 'minutes').format('YYYY-MM-DD HH:mm:ss');
|
731
|
+
}
|
732
|
+
/** MMM, DD YYYY */
|
733
|
+
static GetDateFormat(date) {
|
734
|
+
date = DateTime.GetFormatDB(date);
|
735
|
+
return moment(date).parseZone().local(true).format('MMM, DD YYYY');
|
736
|
+
}
|
737
|
+
/** MMM, DD YYYY at hh:mm a */
|
738
|
+
static GetDateTimeFormat(date) {
|
739
|
+
date = DateTime.GetFormatDB(date);
|
740
|
+
return moment(date).parseZone().local(true).format('MMM, DD YYYY - hh:mm a').replace('-', 'at');
|
741
|
+
}
|
742
|
+
/** */
|
743
|
+
static IsValidDate(date) {
|
744
|
+
if (Tools.IsOnlyWhiteSpace(date))
|
745
|
+
return false;
|
746
|
+
date = DateTime.GetFormatDB(date);
|
747
|
+
return moment(date).isValid();
|
748
|
+
}
|
749
|
+
/** */
|
750
|
+
static SetFirstHour(date = '', format = 'database') {
|
751
|
+
if (Tools.IsOnlyWhiteSpace(date))
|
752
|
+
date = moment();
|
753
|
+
else {
|
754
|
+
date = DateTime.GetFormatDB(date);
|
755
|
+
date = moment(date);
|
756
|
+
}
|
757
|
+
date = date.set('hour', 0).set('minute', 0).set('second', 0).set('millisecond', 0);
|
758
|
+
return (format === 'database')
|
759
|
+
? DateTime.GetFormatDB(date)
|
760
|
+
: DateTime.GetDateFormat(date);
|
761
|
+
}
|
762
|
+
/** */
|
763
|
+
static SetLastHour(date = '', format = 'database') {
|
764
|
+
if (Tools.IsOnlyWhiteSpace(date))
|
765
|
+
date = moment();
|
766
|
+
else {
|
767
|
+
date = DateTime.GetFormatDB(date);
|
768
|
+
date = moment(date);
|
769
|
+
}
|
770
|
+
date = date.set('hour', 23).set('minute', 59).set('second', 59).set('millisecond', 59);
|
771
|
+
return (format === 'database')
|
772
|
+
? DateTime.GetFormatDB(date)
|
773
|
+
: DateTime.GetDateFormat(date);
|
774
|
+
}
|
775
|
+
}
|
776
|
+
|
777
|
+
const ElementsHTML = {
|
778
|
+
/** Get width in px */
|
779
|
+
GetElementWidth: (element, ...args) => {
|
780
|
+
let width = 0;
|
781
|
+
if (Tools.IsNotNull(element) && Tools.IsNotOnlyWhiteSpace(element?.offsetWidth)) {
|
782
|
+
width += element.offsetWidth;
|
783
|
+
for (const arg of args) {
|
784
|
+
if (typeof arg == 'number')
|
785
|
+
width += arg;
|
786
|
+
else if (Tools.IsNotNull(arg) && Tools.IsNotOnlyWhiteSpace(arg?.offsetWidth)) {
|
787
|
+
width += arg.offsetWidth;
|
788
|
+
}
|
789
|
+
}
|
790
|
+
}
|
791
|
+
return `${width}px`;
|
792
|
+
},
|
793
|
+
/** Get height in px */
|
794
|
+
GetElementHeight: (element, ...args) => {
|
795
|
+
let height = 0;
|
796
|
+
if (Tools.IsNotNull(element) && Tools.IsNotOnlyWhiteSpace(element?.offsetHeight)) {
|
797
|
+
height += element.offsetHeight;
|
798
|
+
for (const arg of args) {
|
799
|
+
if (typeof arg == 'number')
|
800
|
+
height += arg;
|
801
|
+
else if (Tools.IsNotNull(arg) && Tools.IsNotOnlyWhiteSpace(arg?.offsetHeight)) {
|
802
|
+
height += arg.offsetHeight;
|
803
|
+
}
|
804
|
+
}
|
805
|
+
}
|
806
|
+
return `${height}px`;
|
807
|
+
},
|
808
|
+
/** */
|
809
|
+
IsInvalidElement: (element) => {
|
810
|
+
let isInvalid = true;
|
811
|
+
if (Tools.IsNotNull(element)) {
|
812
|
+
if (typeof element == 'object') {
|
813
|
+
const properties = Tools.GetPropertyList(element);
|
814
|
+
if (properties.includes('_isTouched') && properties.includes('_value')) {
|
815
|
+
isInvalid = element.isTouched && Tools.IsOnlyWhiteSpace(element.value);
|
816
|
+
}
|
817
|
+
}
|
818
|
+
}
|
819
|
+
return isInvalid;
|
820
|
+
},
|
821
|
+
};
|
822
|
+
|
823
|
+
class Files {
|
824
|
+
static { this.EXCEL_EXTENSIONS = ['xls', 'xlsx', 'csv']; }
|
825
|
+
/** Get Extension File */
|
826
|
+
static GetExtension(file) {
|
827
|
+
const fileName = file.name;
|
828
|
+
if (fileName.includes('.')) {
|
829
|
+
let worlds = fileName.split('.');
|
830
|
+
if (worlds.length > 0) {
|
831
|
+
let extension = worlds.pop();
|
832
|
+
extension = extension.trim().toLowerCase();
|
833
|
+
if (extension.length > 0)
|
834
|
+
return extension;
|
835
|
+
}
|
836
|
+
}
|
837
|
+
return null;
|
838
|
+
}
|
839
|
+
/** Is Excel File */
|
840
|
+
static IsExcel(file) {
|
841
|
+
const EXTENSION = Files.GetExtension(file);
|
842
|
+
return Tools.IsNotNull(EXTENSION)
|
843
|
+
? this.EXCEL_EXTENSIONS.includes(EXTENSION)
|
844
|
+
: false;
|
845
|
+
}
|
846
|
+
/** Read excel file */
|
847
|
+
static ReadExcel(file) {
|
848
|
+
return new Promise(Resolve => {
|
849
|
+
let columns = [];
|
850
|
+
let rows = [];
|
851
|
+
const reader = new FileReader();
|
852
|
+
reader.readAsArrayBuffer(file);
|
853
|
+
reader.onload = () => {
|
854
|
+
const dataBytes = new Uint8Array(reader.result);
|
855
|
+
if (dataBytes) {
|
856
|
+
const workbook = XLSX.read(dataBytes, {});
|
857
|
+
const sheet = workbook.Sheets[workbook.SheetNames[0]];
|
858
|
+
let dataSheet = XLSX.utils.sheet_to_json(sheet, {
|
859
|
+
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']
|
860
|
+
});
|
861
|
+
//Get Headers
|
862
|
+
for (const column in dataSheet[0]) {
|
863
|
+
columns.push(Tools.FirstCharToLower(String(dataSheet[0][column]).replaceAll(' ', '')));
|
864
|
+
}
|
865
|
+
//Get Rows
|
866
|
+
rows = XLSX.utils.sheet_to_json(sheet, { header: columns });
|
867
|
+
rows.shift();
|
868
|
+
rows = rows.map(row => {
|
869
|
+
const item = Tools.BreakReference(row);
|
870
|
+
delete item['__rowNum__'];
|
871
|
+
return item;
|
872
|
+
});
|
873
|
+
}
|
874
|
+
Resolve({ columns, rows });
|
875
|
+
};
|
876
|
+
reader.onerror = () => { Resolve({ columns, rows }); };
|
877
|
+
});
|
878
|
+
}
|
879
|
+
/** Export to excel file */
|
880
|
+
static ExportExcel(data, fileName = 'coer_report', sheetName = 'Sheet1') {
|
881
|
+
sheetName = Tools.CleanUpBlanks(sheetName);
|
882
|
+
fileName = Tools.CleanUpBlanks(fileName);
|
883
|
+
if (fileName.endsWith('.xls') || fileName.endsWith('.xlsx') || fileName.endsWith('.csv')) {
|
884
|
+
if (fileName.endsWith('.xls')) {
|
885
|
+
fileName = fileName.replaceAll('.xls', '.xlsx');
|
886
|
+
}
|
887
|
+
if (fileName.endsWith('.csv')) {
|
888
|
+
fileName = fileName.replaceAll('.csv', '.xlsx');
|
889
|
+
}
|
890
|
+
}
|
891
|
+
else {
|
892
|
+
fileName += '.xlsx';
|
893
|
+
}
|
894
|
+
const WORK_SHEET = XLSX.utils.json_to_sheet(data);
|
895
|
+
const WORK_BOOK = XLSX.utils.book_new();
|
896
|
+
XLSX.utils.book_append_sheet(WORK_BOOK, WORK_SHEET, sheetName);
|
897
|
+
XLSX.writeFile(WORK_BOOK, fileName);
|
898
|
+
}
|
899
|
+
/** Convert file to string base64 */
|
900
|
+
static ConvertToBase64(file) {
|
901
|
+
return new Promise(Resolve => {
|
902
|
+
const reader = new FileReader();
|
903
|
+
reader.readAsDataURL(file);
|
904
|
+
reader.onload = () => {
|
905
|
+
Resolve(reader.result?.toString() || '');
|
906
|
+
};
|
907
|
+
reader.onerror = () => Resolve('');
|
908
|
+
});
|
909
|
+
}
|
910
|
+
}
|
911
|
+
|
912
|
+
class User {
|
913
|
+
static { this.storage = 'COER-System'; }
|
914
|
+
/** */
|
915
|
+
static Set(user) {
|
916
|
+
let storage = localStorage.getItem(this.storage);
|
917
|
+
if (storage) {
|
918
|
+
storage = JSON.parse(storage);
|
919
|
+
storage = Object.assign({}, storage, { user });
|
920
|
+
}
|
921
|
+
else {
|
922
|
+
storage = Object.assign({}, storage, { user });
|
923
|
+
}
|
924
|
+
localStorage.setItem(this.storage, JSON.stringify(storage));
|
925
|
+
}
|
926
|
+
/** */
|
927
|
+
static Get() {
|
928
|
+
let storage = localStorage.getItem(this.storage);
|
929
|
+
if (storage) {
|
930
|
+
storage = JSON.parse(storage);
|
931
|
+
if (storage.hasOwnProperty('user')) {
|
932
|
+
return storage.user;
|
933
|
+
}
|
934
|
+
}
|
935
|
+
return null;
|
936
|
+
}
|
937
|
+
/** */
|
938
|
+
static LogIn() {
|
939
|
+
let storage = localStorage.getItem(this.storage);
|
940
|
+
storage = JSON.parse(storage);
|
941
|
+
return Tools.IsNotOnlyWhiteSpace(storage)
|
942
|
+
&& Tools.IsNotNull(storage?.user)
|
943
|
+
&& Tools.IsNotOnlyWhiteSpace(storage?.user?.jwt);
|
944
|
+
}
|
945
|
+
/** */
|
946
|
+
static LogOut() {
|
947
|
+
sessionStorage.removeItem(this.storage);
|
948
|
+
localStorage.removeItem(this.storage);
|
949
|
+
document.location.href = '/';
|
950
|
+
}
|
951
|
+
}
|
952
|
+
|
953
|
+
class Filters {
|
954
|
+
static { this.storage = 'COER-System'; }
|
955
|
+
/** */
|
956
|
+
static Add(filters, path) {
|
957
|
+
let storage = sessionStorage.getItem(this.storage);
|
958
|
+
storage = JSON.parse(storage);
|
959
|
+
let dictionary = [[path, filters]];
|
960
|
+
if (Tools.IsNotNull(storage?.filters)) {
|
961
|
+
const index = storage.filters.findIndex((x) => x.some(y => y === path));
|
962
|
+
if (index > -1) {
|
963
|
+
storage.filters[index][1] = filters;
|
964
|
+
dictionary = storage.filters;
|
965
|
+
}
|
966
|
+
else {
|
967
|
+
dictionary = storage.filters.concat(dictionary);
|
968
|
+
}
|
969
|
+
}
|
970
|
+
storage = Object.assign({}, storage, {
|
971
|
+
filters: dictionary
|
972
|
+
});
|
973
|
+
sessionStorage.setItem(this.storage, JSON.stringify(storage));
|
974
|
+
}
|
975
|
+
/** */
|
976
|
+
static Get(path) {
|
977
|
+
let storage = sessionStorage.getItem(this.storage);
|
978
|
+
storage = JSON.parse(storage);
|
979
|
+
if (Tools.IsNotNull(storage?.filters)) {
|
980
|
+
for (const filterList of storage.filters) {
|
981
|
+
if (filterList.some((x) => x === path)) {
|
982
|
+
return filterList[1];
|
983
|
+
}
|
984
|
+
}
|
985
|
+
}
|
986
|
+
return null;
|
987
|
+
}
|
988
|
+
/** */
|
989
|
+
static Remove(path) {
|
990
|
+
let storage = sessionStorage.getItem(this.storage);
|
991
|
+
storage = JSON.parse(storage);
|
992
|
+
if (Tools.IsNotNull(storage?.filters)) {
|
993
|
+
let index = 0;
|
994
|
+
for (index; index < storage.filters.length; index++) {
|
995
|
+
if (storage.filters[index].some((x) => x === path)) {
|
996
|
+
break;
|
997
|
+
}
|
998
|
+
}
|
999
|
+
storage.filters.splice(index, 1);
|
1000
|
+
}
|
1001
|
+
sessionStorage.setItem(this.storage, JSON.stringify(storage));
|
1002
|
+
}
|
1003
|
+
/** */
|
1004
|
+
static RemoveAll() {
|
1005
|
+
let storage = sessionStorage.getItem(this.storage);
|
1006
|
+
storage = JSON.parse(storage);
|
1007
|
+
if (Tools.IsNotNull(storage?.filters)) {
|
1008
|
+
delete storage.filters;
|
1009
|
+
}
|
1010
|
+
sessionStorage.setItem(this.storage, JSON.stringify(storage));
|
1011
|
+
}
|
1012
|
+
}
|
1013
|
+
|
1014
|
+
class Menu {
|
1015
|
+
static { this.storage = 'COER-System'; }
|
1016
|
+
/** */
|
1017
|
+
static SetSelectedOption(menu) {
|
1018
|
+
let storage = sessionStorage.getItem(this.storage);
|
1019
|
+
if (storage)
|
1020
|
+
storage = JSON.parse(storage);
|
1021
|
+
storage = Object.assign({}, storage, { menu });
|
1022
|
+
sessionStorage.setItem(this.storage, JSON.stringify(storage));
|
1023
|
+
}
|
1024
|
+
/** */
|
1025
|
+
static GetSelectedOption() {
|
1026
|
+
let storage = sessionStorage.getItem(this.storage);
|
1027
|
+
if (storage) {
|
1028
|
+
storage = JSON.parse(storage);
|
1029
|
+
if (storage.hasOwnProperty('menu')) {
|
1030
|
+
return storage.menu;
|
1031
|
+
}
|
1032
|
+
}
|
1033
|
+
return null;
|
1034
|
+
}
|
1035
|
+
static { this.GetMenuAccess = () => {
|
1036
|
+
const menuAccess = [];
|
1037
|
+
//LV1
|
1038
|
+
for (const lv1 of navigationSIGNAL()) {
|
1039
|
+
//LV1 - Page
|
1040
|
+
if (Tools.IsNotOnlyWhiteSpace(lv1.path) && Tools.IsNull(lv1.items)) {
|
1041
|
+
menuAccess.push({
|
1042
|
+
module: null,
|
1043
|
+
submodule: null,
|
1044
|
+
page: lv1.label,
|
1045
|
+
path: lv1.path,
|
1046
|
+
readonly: Tools.IsNotNull(lv1?.readonly) ? lv1.readonly : true
|
1047
|
+
});
|
1048
|
+
}
|
1049
|
+
//LV1 - Module
|
1050
|
+
else if (Tools.IsOnlyWhiteSpace(lv1.path) && Tools.IsNotNull(lv1.items)) {
|
1051
|
+
//LV2
|
1052
|
+
for (const lv2 of lv1.items) {
|
1053
|
+
//LV2 - Page
|
1054
|
+
if (Tools.IsNotOnlyWhiteSpace(lv2.path) && Tools.IsNull(lv2.items)) {
|
1055
|
+
menuAccess.push({
|
1056
|
+
module: lv1.label,
|
1057
|
+
submodule: null,
|
1058
|
+
page: lv2.label,
|
1059
|
+
path: lv2.path,
|
1060
|
+
readonly: Tools.IsNotNull(lv2?.readonly) ? lv2.readonly : true
|
1061
|
+
});
|
1062
|
+
}
|
1063
|
+
//LV2 - Submodule
|
1064
|
+
else if (Tools.IsOnlyWhiteSpace(lv2.path) && Tools.IsNotNull(lv2.items)) {
|
1065
|
+
//LV3
|
1066
|
+
for (const lv3 of lv2.items) {
|
1067
|
+
//LV3 Page
|
1068
|
+
if (Tools.IsNotOnlyWhiteSpace(lv3.path) && Tools.IsNull(lv3.items)) {
|
1069
|
+
menuAccess.push({
|
1070
|
+
module: lv1.label,
|
1071
|
+
submodule: lv2.label,
|
1072
|
+
page: lv3.label,
|
1073
|
+
path: lv3.path,
|
1074
|
+
readonly: Tools.IsNotNull(lv3?.readonly) ? lv3.readonly : true
|
1075
|
+
});
|
1076
|
+
}
|
1077
|
+
}
|
1078
|
+
}
|
1079
|
+
}
|
1080
|
+
}
|
1081
|
+
}
|
1082
|
+
return menuAccess;
|
1083
|
+
}; }
|
1084
|
+
}
|
1085
|
+
|
1086
|
+
class Source {
|
1087
|
+
static { this.storage = 'COER-System'; }
|
1088
|
+
/** */
|
1089
|
+
static Set(page) {
|
1090
|
+
const ROUTER = inject(Router);
|
1091
|
+
let path = ROUTER.url;
|
1092
|
+
if (path.includes('?'))
|
1093
|
+
path = path.split('?')[0];
|
1094
|
+
Breadcrumbs.Add(page, path);
|
1095
|
+
const breadcrumbs = Breadcrumbs.Get();
|
1096
|
+
if (breadcrumbs.length >= 2) {
|
1097
|
+
breadcrumbs.pop();
|
1098
|
+
const breadcrumb = breadcrumbs.pop();
|
1099
|
+
this.Save({ page: breadcrumb.page, path: breadcrumb.path });
|
1100
|
+
}
|
1101
|
+
else
|
1102
|
+
this.Save(null);
|
1103
|
+
}
|
1104
|
+
/** */
|
1105
|
+
static Save(source) {
|
1106
|
+
let storage = sessionStorage.getItem(this.storage);
|
1107
|
+
if (storage)
|
1108
|
+
storage = JSON.parse(storage);
|
1109
|
+
storage = Object.assign({}, storage, { source });
|
1110
|
+
sessionStorage.setItem(this.storage, JSON.stringify(storage));
|
1111
|
+
}
|
1112
|
+
/** */
|
1113
|
+
static Get() {
|
1114
|
+
let storage = sessionStorage.getItem(this.storage);
|
1115
|
+
if (storage) {
|
1116
|
+
storage = JSON.parse(storage);
|
1117
|
+
if (storage.hasOwnProperty('source')) {
|
1118
|
+
return storage.source;
|
1119
|
+
}
|
1120
|
+
}
|
1121
|
+
return null;
|
1122
|
+
}
|
1123
|
+
/** */
|
1124
|
+
static GetRoot() {
|
1125
|
+
const breadcrumbs = Breadcrumbs.Get();
|
1126
|
+
return (breadcrumbs.length > 0) ? breadcrumbs.shift() : null;
|
1127
|
+
}
|
1128
|
+
/** */
|
1129
|
+
static SetPageResponse(pageResponse) {
|
1130
|
+
let storage = sessionStorage.getItem(this.storage);
|
1131
|
+
storage = JSON.parse(storage);
|
1132
|
+
storage = Object.assign({}, storage, { pageResponse });
|
1133
|
+
sessionStorage.setItem(this.storage, JSON.stringify(storage));
|
1134
|
+
}
|
1135
|
+
/** */
|
1136
|
+
static GetPageResponse() {
|
1137
|
+
let storage = sessionStorage.getItem(this.storage);
|
1138
|
+
if (storage) {
|
1139
|
+
storage = JSON.parse(storage);
|
1140
|
+
if (storage.hasOwnProperty('pageResponse')) {
|
1141
|
+
return Tools.BreakReference(storage.pageResponse);
|
1142
|
+
}
|
1143
|
+
}
|
1144
|
+
return null;
|
1145
|
+
}
|
1146
|
+
/** */
|
1147
|
+
static ClearPageResponse() {
|
1148
|
+
let storage = sessionStorage.getItem(this.storage);
|
1149
|
+
storage = JSON.parse(storage);
|
1150
|
+
if (Tools.IsNotNull(storage)) {
|
1151
|
+
if (storage.hasOwnProperty('pageResponse')) {
|
1152
|
+
delete storage.pageResponse;
|
1153
|
+
}
|
1154
|
+
storage = Object.assign({}, storage);
|
1155
|
+
sessionStorage.setItem(this.storage, JSON.stringify(storage));
|
1156
|
+
}
|
1157
|
+
}
|
1158
|
+
/** */
|
1159
|
+
static Reset() {
|
1160
|
+
let storage = localStorage.getItem(this.storage);
|
1161
|
+
storage = JSON.parse(storage);
|
1162
|
+
const user = storage?.user || null;
|
1163
|
+
localStorage.removeItem(this.storage);
|
1164
|
+
sessionStorage.removeItem(this.storage);
|
1165
|
+
if (Tools.IsNotNull(user)) {
|
1166
|
+
storage = Object.assign({ user });
|
1167
|
+
localStorage.setItem(this.storage, JSON.stringify(storage));
|
1168
|
+
}
|
1169
|
+
}
|
1170
|
+
}
|
1171
|
+
|
1172
|
+
class Page {
|
1173
|
+
constructor(page) {
|
1174
|
+
//Injection
|
1175
|
+
this.alert = inject(CoerAlert);
|
1176
|
+
this.router = inject(Router);
|
1177
|
+
this.activatedRoute = inject(ActivatedRoute);
|
1178
|
+
/** */
|
1179
|
+
this.isUpdate = false;
|
1180
|
+
/** */
|
1181
|
+
this.isLoading = false;
|
1182
|
+
/** */
|
1183
|
+
this.isReadonlyPage = true;
|
1184
|
+
/** */
|
1185
|
+
this.isReadyPage = false;
|
1186
|
+
/** */
|
1187
|
+
this.enableAnimations = false;
|
1188
|
+
/** */
|
1189
|
+
this.breadcrumbs = [];
|
1190
|
+
/** */
|
1191
|
+
this.pageResponse = null;
|
1192
|
+
/** */
|
1193
|
+
this.pageFilters = {};
|
1194
|
+
/** */
|
1195
|
+
this.goBack = { show: false };
|
1196
|
+
//Private Variables
|
1197
|
+
this._path = '';
|
1198
|
+
this._page = '';
|
1199
|
+
this._source = null;
|
1200
|
+
this._preventDestroy = false;
|
1201
|
+
/** */
|
1202
|
+
this.GoBack = (path) => (() => {
|
1203
|
+
if (path)
|
1204
|
+
Breadcrumbs.Remove(path);
|
1205
|
+
else
|
1206
|
+
Breadcrumbs.RemoveLast();
|
1207
|
+
});
|
1208
|
+
//Grid Templates
|
1209
|
+
this.isActiveTemplate = GridTemplates.isActiveTemplate;
|
1210
|
+
this.coerSwitchTemplate = GridTemplates.coerSwitchTemplate;
|
1211
|
+
this.coerTextboxTemplate = GridTemplates.coerTextboxTemplate;
|
1212
|
+
this.coerIconTemplate = GridTemplates.coerIconTemplate;
|
1213
|
+
//Tools
|
1214
|
+
this.IsNull = Tools.IsNull;
|
1215
|
+
this.IsNotNull = Tools.IsNotNull;
|
1216
|
+
this.IsOnlyWhiteSpace = Tools.IsOnlyWhiteSpace;
|
1217
|
+
this.IsNotOnlyWhiteSpace = Tools.IsNotOnlyWhiteSpace;
|
1218
|
+
this.Sleep = Tools.Sleep;
|
1219
|
+
//ElementsHTML
|
1220
|
+
this.IsInvalidElement = ElementsHTML.IsInvalidElement;
|
1221
|
+
if (page.toUpperCase().toUpperCase() === 'HOME')
|
1222
|
+
Source.Reset();
|
1223
|
+
this.SetPageName(page);
|
1224
|
+
this.__SetSource();
|
1225
|
+
this.__GetSource();
|
1226
|
+
this.__GetNavigation();
|
1227
|
+
this.__SetGoBack();
|
1228
|
+
this.__GetPageMode();
|
1229
|
+
this.__GetPageFilter();
|
1230
|
+
this.__GetPageResponse();
|
1231
|
+
}
|
1232
|
+
async ngAfterViewInit() {
|
1233
|
+
this.routeParams = this.activatedRoute.snapshot.params;
|
1234
|
+
this.queryParams = this.activatedRoute.snapshot.queryParams;
|
1235
|
+
await Tools.Sleep();
|
1236
|
+
this.isReadyPage = true;
|
1237
|
+
this.RunPage();
|
1238
|
+
await Tools.Sleep(1000);
|
1239
|
+
this.enableAnimations = true;
|
1240
|
+
}
|
1241
|
+
ngOnDestroy() {
|
1242
|
+
if (!this._preventDestroy)
|
1243
|
+
Source.ClearPageResponse();
|
1244
|
+
}
|
1245
|
+
/** Main method. Starts after ngAfterViewInit() */
|
1246
|
+
RunPage() { }
|
1247
|
+
;
|
1248
|
+
/** Rename the last breadcrumb and update the url id */
|
1249
|
+
SetPageName(name, id = null) {
|
1250
|
+
this._page = name;
|
1251
|
+
this._path = this.router.url;
|
1252
|
+
if (this._path.includes('?'))
|
1253
|
+
this._path = this._path.split('?')[0];
|
1254
|
+
if (id) {
|
1255
|
+
const PATH_ARRAY = this._path.split('/');
|
1256
|
+
const PATH_ID = Tools.BreakReference(PATH_ARRAY).pop();
|
1257
|
+
if (PATH_ID) {
|
1258
|
+
PATH_ARRAY[PATH_ARRAY.length - 1] = String(id);
|
1259
|
+
this._path = PATH_ARRAY.join('/');
|
1260
|
+
}
|
1261
|
+
}
|
1262
|
+
if (this.breadcrumbs.length > 0) {
|
1263
|
+
this.breadcrumbs[this.breadcrumbs.length - 1].page = name;
|
1264
|
+
this.breadcrumbs[this.breadcrumbs.length - 1].path = this._path;
|
1265
|
+
Breadcrumbs.SetLast(name, this._path);
|
1266
|
+
}
|
1267
|
+
this.router.navigateByUrl(this._path);
|
1268
|
+
}
|
1269
|
+
/** */
|
1270
|
+
__SetSource() {
|
1271
|
+
Source.Set(this._page);
|
1272
|
+
}
|
1273
|
+
/** */
|
1274
|
+
__GetSource() {
|
1275
|
+
this._source = Source.Get();
|
1276
|
+
}
|
1277
|
+
/** */
|
1278
|
+
__GetPageResponse() {
|
1279
|
+
this.pageResponse = Source.GetPageResponse();
|
1280
|
+
}
|
1281
|
+
/** */
|
1282
|
+
__GetNavigation() {
|
1283
|
+
if (this._source) {
|
1284
|
+
this.breadcrumbs = Breadcrumbs.Get().map(item => Object.assign({
|
1285
|
+
page: item.page,
|
1286
|
+
path: item.path,
|
1287
|
+
click: this.GoBack(item.path)
|
1288
|
+
}));
|
1289
|
+
}
|
1290
|
+
else
|
1291
|
+
this.breadcrumbs = [{ page: this._page }];
|
1292
|
+
}
|
1293
|
+
/** */
|
1294
|
+
__SetGoBack() {
|
1295
|
+
if (this._source) {
|
1296
|
+
this.goBack = {
|
1297
|
+
show: true,
|
1298
|
+
path: this._source.path,
|
1299
|
+
click: this.GoBack()
|
1300
|
+
};
|
1301
|
+
}
|
1302
|
+
}
|
1303
|
+
/** */
|
1304
|
+
__GetPageMode() {
|
1305
|
+
const subscribe$ = this.activatedRoute.data.subscribe({
|
1306
|
+
next: ({ module, submodule, page }) => {
|
1307
|
+
const menuAccess = Menu.GetMenuAccess().find(x => x.module === module
|
1308
|
+
&& x.submodule === submodule
|
1309
|
+
&& x.page === page);
|
1310
|
+
this.isReadonlyPage = Tools.IsNotNull(menuAccess) ? menuAccess.readonly : true;
|
1311
|
+
},
|
1312
|
+
error: (message) => { console.error(message); },
|
1313
|
+
complete: () => { subscribe$.unsubscribe(); }
|
1314
|
+
});
|
1315
|
+
}
|
1316
|
+
/** Navigate to previous page */
|
1317
|
+
GoToSource(pageResponse = null) {
|
1318
|
+
if (this._source) {
|
1319
|
+
Breadcrumbs.RemoveLast();
|
1320
|
+
this.SetPageResponse(pageResponse);
|
1321
|
+
this.RemovePageFilter();
|
1322
|
+
Tools.Sleep().then(_ => this.router.navigateByUrl(this._source.path));
|
1323
|
+
}
|
1324
|
+
}
|
1325
|
+
;
|
1326
|
+
/** */
|
1327
|
+
SetPageResponse(pageResponse = null) {
|
1328
|
+
if (Tools.IsNotNull(pageResponse)) {
|
1329
|
+
this._preventDestroy = true;
|
1330
|
+
Source.SetPageResponse(pageResponse);
|
1331
|
+
}
|
1332
|
+
}
|
1333
|
+
;
|
1334
|
+
/** */
|
1335
|
+
ReloadPage() {
|
1336
|
+
Breadcrumbs.RemoveLast();
|
1337
|
+
setTimeout(() => window.location.reload());
|
1338
|
+
}
|
1339
|
+
/** */
|
1340
|
+
SetPageFilters(filters) {
|
1341
|
+
this.pageFilters = Tools.BreakReference(filters);
|
1342
|
+
Filters.Add(this.pageFilters, this._path);
|
1343
|
+
}
|
1344
|
+
/** */
|
1345
|
+
__GetPageFilter() {
|
1346
|
+
this.pageFilters = Filters.Get(this._path);
|
1347
|
+
}
|
1348
|
+
/** */
|
1349
|
+
RemovePageFilter() {
|
1350
|
+
this.pageFilters = {};
|
1351
|
+
Filters.Remove(this._path);
|
1352
|
+
}
|
1353
|
+
/** */
|
1354
|
+
Log(value, log = null) {
|
1355
|
+
if (Tools.IsNotNull(log))
|
1356
|
+
console.log({ log, value });
|
1357
|
+
else
|
1358
|
+
console.log(value);
|
1359
|
+
}
|
1360
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: Page, deps: [{ token: String }], target: i0.ɵɵFactoryTarget.Component }); }
|
1361
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.1", type: Page, isStandalone: true, selector: "ng-component", ngImport: i0, template: '', isInline: true }); }
|
1362
|
+
}
|
1363
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: Page, decorators: [{
|
1364
|
+
type: Component,
|
1365
|
+
args: [{ template: '' }]
|
1366
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
1367
|
+
type: Inject,
|
1368
|
+
args: [String]
|
1369
|
+
}] }] });
|
1370
|
+
|
1371
|
+
class Screen {
|
1372
|
+
static get WINDOW_WIDTH() {
|
1373
|
+
return window.innerWidth;
|
1374
|
+
}
|
1375
|
+
static get WINDOW_HEIGHT() {
|
1376
|
+
return window.innerHeight;
|
1377
|
+
}
|
1378
|
+
static get DEVICE_WIDTH() {
|
1379
|
+
return window.screen.width;
|
1380
|
+
}
|
1381
|
+
static get DEVICE_HEIGHT() {
|
1382
|
+
return window.screen.height;
|
1383
|
+
}
|
1384
|
+
static get BREAKPOINT() {
|
1385
|
+
if (window.innerWidth < 576)
|
1386
|
+
return 'xs';
|
1387
|
+
else if (window.innerWidth >= 576 && window.innerWidth < 768)
|
1388
|
+
return 'sm';
|
1389
|
+
else if (window.innerWidth >= 768 && window.innerWidth < 992)
|
1390
|
+
return 'md';
|
1391
|
+
else if (window.innerWidth >= 992 && window.innerWidth < 1200)
|
1392
|
+
return 'lg';
|
1393
|
+
else if (window.innerWidth >= 1200 && window.innerWidth < 1400)
|
1394
|
+
return 'xl';
|
1395
|
+
else
|
1396
|
+
return 'xxl';
|
1397
|
+
}
|
1398
|
+
/** */
|
1399
|
+
static { this.Resize = new Observable(subscriber => {
|
1400
|
+
const handleResize = () => {
|
1401
|
+
subscriber.next({
|
1402
|
+
width: window.innerWidth,
|
1403
|
+
height: window.innerHeight,
|
1404
|
+
breakpoint: this.BREAKPOINT
|
1405
|
+
});
|
1406
|
+
};
|
1407
|
+
window.addEventListener("resize", handleResize);
|
1408
|
+
window.addEventListener("load", handleResize);
|
1409
|
+
return () => {
|
1410
|
+
window.removeEventListener("resize", handleResize);
|
1411
|
+
window.removeEventListener("load", handleResize);
|
1412
|
+
};
|
1413
|
+
}); }
|
1414
|
+
/** */
|
1415
|
+
static { this.BackButtonBrowser = new Observable(subscriber => {
|
1416
|
+
const handlePopState = (popStateEvent) => {
|
1417
|
+
if (popStateEvent.state && popStateEvent.target) {
|
1418
|
+
subscriber.next(popStateEvent.target.location.href);
|
1419
|
+
}
|
1420
|
+
};
|
1421
|
+
window.addEventListener('popstate', handlePopState);
|
1422
|
+
return () => {
|
1423
|
+
window.removeEventListener('popstate', handlePopState);
|
1424
|
+
};
|
1425
|
+
}); }
|
1426
|
+
}
|
1427
|
+
|
1428
|
+
class Section {
|
1429
|
+
constructor() {
|
1430
|
+
//Injection
|
1431
|
+
this.alert = inject(CoerAlert);
|
1432
|
+
this.router = inject(Router);
|
1433
|
+
//Inputs
|
1434
|
+
this.isLoading = input(false);
|
1435
|
+
this.isUpdate = input(false);
|
1436
|
+
//Outputs
|
1437
|
+
this.onReady = output();
|
1438
|
+
this.onDestroy = output();
|
1439
|
+
this.onIsLoading = output();
|
1440
|
+
this.onUpdated = output();
|
1441
|
+
//Variables
|
1442
|
+
this.enableAnimations = false;
|
1443
|
+
//Grid Templates
|
1444
|
+
this.isActiveTemplate = GridTemplates.isActiveTemplate;
|
1445
|
+
this.coerSwitchTemplate = GridTemplates.coerSwitchTemplate;
|
1446
|
+
this.coerTextboxTemplate = GridTemplates.coerTextboxTemplate;
|
1447
|
+
this.coerIconTemplate = GridTemplates.coerIconTemplate;
|
1448
|
+
//Tools
|
1449
|
+
this.IsNull = Tools.IsNull;
|
1450
|
+
this.IsNotNull = Tools.IsNotNull;
|
1451
|
+
this.IsOnlyWhiteSpace = Tools.IsOnlyWhiteSpace;
|
1452
|
+
this.IsNotOnlyWhiteSpace = Tools.IsNotOnlyWhiteSpace;
|
1453
|
+
this.Sleep = Tools.Sleep;
|
1454
|
+
//ElementsHTML
|
1455
|
+
this.IsInvalidElement = ElementsHTML.IsInvalidElement;
|
1456
|
+
}
|
1457
|
+
ngAfterViewInit() {
|
1458
|
+
Tools.Sleep().then(_ => {
|
1459
|
+
this.RunSection();
|
1460
|
+
this.onReady.emit();
|
1461
|
+
});
|
1462
|
+
Tools.Sleep(1000).then(_ => this.enableAnimations = true);
|
1463
|
+
}
|
1464
|
+
ngOnDestroy() {
|
1465
|
+
this.onDestroy.emit(null);
|
1466
|
+
}
|
1467
|
+
/** Main method. Starts after ngAfterViewInit() */
|
1468
|
+
RunSection() { }
|
1469
|
+
;
|
1470
|
+
/** */
|
1471
|
+
Log(value, log = null) {
|
1472
|
+
if (Tools.IsNotNull(log))
|
1473
|
+
console.log({ log, value });
|
1474
|
+
else
|
1475
|
+
console.log(value);
|
1476
|
+
}
|
1477
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: Section, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
1478
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.0.1", type: Section, isStandalone: true, selector: "ng-component", inputs: { isLoading: { classPropertyName: "isLoading", publicName: "isLoading", isSignal: true, isRequired: false, transformFunction: null }, isUpdate: { classPropertyName: "isUpdate", publicName: "isUpdate", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onReady: "onReady", onDestroy: "onDestroy", onIsLoading: "onIsLoading", onUpdated: "onUpdated" }, ngImport: i0, template: '', isInline: true }); }
|
1479
|
+
}
|
1480
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: Section, decorators: [{
|
1481
|
+
type: Component,
|
1482
|
+
args: [{ template: '' }]
|
1483
|
+
}] });
|
1484
|
+
|
1485
|
+
class Service {
|
1486
|
+
constructor() {
|
1487
|
+
//Injections
|
1488
|
+
this.alert = inject(CoerAlert);
|
1489
|
+
this.http = inject(HttpClient);
|
1490
|
+
this.httpCode = {
|
1491
|
+
Ok: 200,
|
1492
|
+
Created: 201,
|
1493
|
+
NoContent: 204,
|
1494
|
+
BadRequest: 400,
|
1495
|
+
Unauthorize: 401,
|
1496
|
+
Forbidden: 403,
|
1497
|
+
NotFound: 404,
|
1498
|
+
NotAllowed: 405,
|
1499
|
+
NotAcceptable: 406,
|
1500
|
+
Conflict: 409,
|
1501
|
+
PayloadTooLarge: 413,
|
1502
|
+
InnerError: 500
|
1503
|
+
};
|
1504
|
+
}
|
1505
|
+
/** */
|
1506
|
+
ReleaseSubscription(subscription) {
|
1507
|
+
if (subscription && !subscription.closed)
|
1508
|
+
subscription.unsubscribe();
|
1509
|
+
}
|
1510
|
+
/** HTTP GET */
|
1511
|
+
HTTP_GET(request, cancelPrevious = true) {
|
1512
|
+
return new Promise(Resolve => {
|
1513
|
+
if (cancelPrevious) {
|
1514
|
+
this.ReleaseSubscription(this._GET$);
|
1515
|
+
this._GET$ = this.http.request(new HttpRequest("GET", request.url, { params: request.queryParams, headers: request.headers })).subscribe({
|
1516
|
+
next: (response) => {
|
1517
|
+
if (response.type > 0) {
|
1518
|
+
Resolve({
|
1519
|
+
body: Tools.BreakReference(response.body),
|
1520
|
+
status: response.status,
|
1521
|
+
message: response.statusText,
|
1522
|
+
ok: true
|
1523
|
+
});
|
1524
|
+
}
|
1525
|
+
},
|
1526
|
+
error: (httpError) => {
|
1527
|
+
this.ReleaseSubscription(this._GET$);
|
1528
|
+
this.AlertError(httpError, request.alertError);
|
1529
|
+
Resolve({
|
1530
|
+
body: {},
|
1531
|
+
status: httpError.status,
|
1532
|
+
message: httpError.error?.message || httpError.error,
|
1533
|
+
ok: false
|
1534
|
+
});
|
1535
|
+
},
|
1536
|
+
complete: () => {
|
1537
|
+
this.ReleaseSubscription(this._GET$);
|
1538
|
+
if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
|
1539
|
+
this.alert.Success(request.alertSuccess);
|
1540
|
+
}
|
1541
|
+
}
|
1542
|
+
});
|
1543
|
+
}
|
1544
|
+
else {
|
1545
|
+
const subscription = this.http.request(new HttpRequest("GET", request.url, { params: request.queryParams, headers: request.headers })).subscribe({
|
1546
|
+
next: (response) => {
|
1547
|
+
if (response.type > 0) {
|
1548
|
+
Resolve({
|
1549
|
+
body: Tools.BreakReference(response.body),
|
1550
|
+
status: response.status,
|
1551
|
+
message: response.statusText,
|
1552
|
+
ok: true
|
1553
|
+
});
|
1554
|
+
}
|
1555
|
+
},
|
1556
|
+
error: (httpError) => {
|
1557
|
+
this.ReleaseSubscription(subscription);
|
1558
|
+
this.AlertError(httpError, request.alertError);
|
1559
|
+
Resolve({
|
1560
|
+
body: {},
|
1561
|
+
status: httpError.status,
|
1562
|
+
message: httpError.error?.message || httpError.error,
|
1563
|
+
ok: false
|
1564
|
+
});
|
1565
|
+
},
|
1566
|
+
complete: () => {
|
1567
|
+
this.ReleaseSubscription(subscription);
|
1568
|
+
if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
|
1569
|
+
this.alert.Success(request.alertSuccess);
|
1570
|
+
}
|
1571
|
+
}
|
1572
|
+
});
|
1573
|
+
}
|
1574
|
+
});
|
1575
|
+
}
|
1576
|
+
/** HTTP POST */
|
1577
|
+
HTTP_POST(request, cancelPrevious = true) {
|
1578
|
+
return new Promise(Resolve => {
|
1579
|
+
if (cancelPrevious) {
|
1580
|
+
this.ReleaseSubscription(this._POST$);
|
1581
|
+
this._POST$ = this.http.request(new HttpRequest("POST", request.url, request.body, { params: request.queryParams, headers: request.headers })).subscribe({
|
1582
|
+
next: (response) => {
|
1583
|
+
if (response.type > 0) {
|
1584
|
+
Resolve({
|
1585
|
+
body: Tools.BreakReference(response.body),
|
1586
|
+
status: response.status,
|
1587
|
+
message: response.statusText,
|
1588
|
+
ok: true
|
1589
|
+
});
|
1590
|
+
}
|
1591
|
+
},
|
1592
|
+
error: (httpError) => {
|
1593
|
+
this.ReleaseSubscription(this._POST$);
|
1594
|
+
this.AlertError(httpError, request.alertError);
|
1595
|
+
Resolve({
|
1596
|
+
body: {},
|
1597
|
+
status: httpError.status,
|
1598
|
+
message: httpError.error?.message || httpError.error,
|
1599
|
+
ok: false
|
1600
|
+
});
|
1601
|
+
},
|
1602
|
+
complete: () => {
|
1603
|
+
this.ReleaseSubscription(this._POST$);
|
1604
|
+
if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
|
1605
|
+
this.alert.Success(request.alertSuccess);
|
1606
|
+
}
|
1607
|
+
}
|
1608
|
+
});
|
1609
|
+
}
|
1610
|
+
else {
|
1611
|
+
const subscription = this.http.request(new HttpRequest("POST", request.url, request.body, { params: request.queryParams, headers: request.headers })).subscribe({
|
1612
|
+
next: (response) => {
|
1613
|
+
if (response.type > 0) {
|
1614
|
+
Resolve({
|
1615
|
+
body: Tools.BreakReference(response.body),
|
1616
|
+
status: response.status,
|
1617
|
+
message: response.statusText,
|
1618
|
+
ok: true
|
1619
|
+
});
|
1620
|
+
}
|
1621
|
+
},
|
1622
|
+
error: (httpError) => {
|
1623
|
+
this.ReleaseSubscription(subscription);
|
1624
|
+
this.AlertError(httpError, request.alertError);
|
1625
|
+
Resolve({
|
1626
|
+
body: {},
|
1627
|
+
status: httpError.status,
|
1628
|
+
message: httpError.error?.message || httpError.error,
|
1629
|
+
ok: false
|
1630
|
+
});
|
1631
|
+
},
|
1632
|
+
complete: () => {
|
1633
|
+
this.ReleaseSubscription(subscription);
|
1634
|
+
if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
|
1635
|
+
this.alert.Success(request.alertSuccess);
|
1636
|
+
}
|
1637
|
+
}
|
1638
|
+
});
|
1639
|
+
}
|
1640
|
+
});
|
1641
|
+
}
|
1642
|
+
/** HTTP PUT */
|
1643
|
+
HTTP_PUT(request, cancelPrevious = true) {
|
1644
|
+
return new Promise(Resolve => {
|
1645
|
+
if (cancelPrevious) {
|
1646
|
+
this.ReleaseSubscription(this._PUT$);
|
1647
|
+
this._PUT$ = this.http.request(new HttpRequest("PUT", request.url, request.body, { params: request.queryParams, headers: request.headers })).subscribe({
|
1648
|
+
next: (response) => {
|
1649
|
+
if (response.type > 0) {
|
1650
|
+
Resolve({
|
1651
|
+
body: {},
|
1652
|
+
status: response.status,
|
1653
|
+
message: response.statusText,
|
1654
|
+
ok: true
|
1655
|
+
});
|
1656
|
+
}
|
1657
|
+
},
|
1658
|
+
error: (httpError) => {
|
1659
|
+
this.ReleaseSubscription(this._PUT$);
|
1660
|
+
this.AlertError(httpError, request.alertError);
|
1661
|
+
Resolve({
|
1662
|
+
body: {},
|
1663
|
+
status: httpError.status,
|
1664
|
+
message: httpError.error?.message || httpError.error,
|
1665
|
+
ok: false
|
1666
|
+
});
|
1667
|
+
},
|
1668
|
+
complete: () => {
|
1669
|
+
this.ReleaseSubscription(this._PUT$);
|
1670
|
+
if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
|
1671
|
+
this.alert.Success(request.alertSuccess, 'Updated', 'fa-solid fa-arrows-rotate fa-spin');
|
1672
|
+
}
|
1673
|
+
}
|
1674
|
+
});
|
1675
|
+
}
|
1676
|
+
else {
|
1677
|
+
const subscription = this.http.request(new HttpRequest("PUT", request.url, request.body, { params: request.queryParams, headers: request.headers })).subscribe({
|
1678
|
+
next: (response) => {
|
1679
|
+
if (response.type > 0) {
|
1680
|
+
Resolve({
|
1681
|
+
body: {},
|
1682
|
+
status: response.status,
|
1683
|
+
message: response.statusText,
|
1684
|
+
ok: true
|
1685
|
+
});
|
1686
|
+
}
|
1687
|
+
},
|
1688
|
+
error: (httpError) => {
|
1689
|
+
this.ReleaseSubscription(subscription);
|
1690
|
+
this.AlertError(httpError, request.alertError);
|
1691
|
+
Resolve({
|
1692
|
+
body: {},
|
1693
|
+
status: httpError.status,
|
1694
|
+
message: httpError.error?.message || httpError.error,
|
1695
|
+
ok: false
|
1696
|
+
});
|
1697
|
+
},
|
1698
|
+
complete: () => {
|
1699
|
+
this.ReleaseSubscription(subscription);
|
1700
|
+
if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
|
1701
|
+
this.alert.Success(request.alertSuccess, 'Updated', 'fa-solid fa-arrows-rotate fa-spin');
|
1702
|
+
}
|
1703
|
+
}
|
1704
|
+
});
|
1705
|
+
}
|
1706
|
+
});
|
1707
|
+
}
|
1708
|
+
/** HTTP PATCH */
|
1709
|
+
HTTP_PATCH(request, cancelPrevious = true) {
|
1710
|
+
return new Promise(Resolve => {
|
1711
|
+
if (cancelPrevious) {
|
1712
|
+
this.ReleaseSubscription(this._PATCH$);
|
1713
|
+
this._PATCH$ = this.http.request(new HttpRequest("PATCH", request.url, request.body, { params: request.queryParams, headers: request.headers })).subscribe({
|
1714
|
+
next: (response) => {
|
1715
|
+
if (response.type > 0) {
|
1716
|
+
Resolve({
|
1717
|
+
body: {},
|
1718
|
+
status: response.status,
|
1719
|
+
message: response.statusText,
|
1720
|
+
ok: true
|
1721
|
+
});
|
1722
|
+
}
|
1723
|
+
},
|
1724
|
+
error: (httpError) => {
|
1725
|
+
this.ReleaseSubscription(this._PATCH$);
|
1726
|
+
this.AlertError(httpError, request.alertError);
|
1727
|
+
Resolve({
|
1728
|
+
body: {},
|
1729
|
+
status: httpError.status,
|
1730
|
+
message: httpError.error?.message || httpError.error,
|
1731
|
+
ok: false
|
1732
|
+
});
|
1733
|
+
},
|
1734
|
+
complete: () => {
|
1735
|
+
this.ReleaseSubscription(this._PATCH$);
|
1736
|
+
if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
|
1737
|
+
this.alert.Success(request.alertSuccess, 'Updated', 'fa-solid fa-arrows-rotate fa-spin');
|
1738
|
+
}
|
1739
|
+
}
|
1740
|
+
});
|
1741
|
+
}
|
1742
|
+
else {
|
1743
|
+
const subscription = this.http.request(new HttpRequest("PATCH", request.url, request.body, { params: request.queryParams, headers: request.headers })).subscribe({
|
1744
|
+
next: (response) => {
|
1745
|
+
if (response.type > 0) {
|
1746
|
+
Resolve({
|
1747
|
+
body: {},
|
1748
|
+
status: response.status,
|
1749
|
+
message: response.statusText,
|
1750
|
+
ok: true
|
1751
|
+
});
|
1752
|
+
}
|
1753
|
+
},
|
1754
|
+
error: (httpError) => {
|
1755
|
+
this.ReleaseSubscription(subscription);
|
1756
|
+
this.AlertError(httpError, request.alertError);
|
1757
|
+
Resolve({
|
1758
|
+
body: {},
|
1759
|
+
status: httpError.status,
|
1760
|
+
message: httpError.error?.message || httpError.error,
|
1761
|
+
ok: false
|
1762
|
+
});
|
1763
|
+
},
|
1764
|
+
complete: () => {
|
1765
|
+
this.ReleaseSubscription(subscription);
|
1766
|
+
if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
|
1767
|
+
this.alert.Success(request.alertSuccess, 'Updated', 'fa-solid fa-arrows-rotate fa-spin');
|
1768
|
+
}
|
1769
|
+
}
|
1770
|
+
});
|
1771
|
+
}
|
1772
|
+
});
|
1773
|
+
}
|
1774
|
+
/** HTTP DELETE */
|
1775
|
+
HTTP_DELETE(request, cancelPrevious = true) {
|
1776
|
+
return new Promise(Resolve => {
|
1777
|
+
if (cancelPrevious) {
|
1778
|
+
this.ReleaseSubscription(this._DELETE$);
|
1779
|
+
this._DELETE$ = this.http.request(new HttpRequest("DELETE", request.url, { params: request.queryParams, headers: request.headers })).subscribe({
|
1780
|
+
next: (response) => {
|
1781
|
+
if (response.type > 0) {
|
1782
|
+
Resolve({
|
1783
|
+
body: {},
|
1784
|
+
status: response.status,
|
1785
|
+
message: response.statusText,
|
1786
|
+
ok: true
|
1787
|
+
});
|
1788
|
+
}
|
1789
|
+
},
|
1790
|
+
error: (httpError) => {
|
1791
|
+
this.ReleaseSubscription(this._DELETE$);
|
1792
|
+
this.AlertError(httpError, request.alertError);
|
1793
|
+
Resolve({
|
1794
|
+
body: {},
|
1795
|
+
status: httpError.status,
|
1796
|
+
message: httpError.error?.message || httpError.error,
|
1797
|
+
ok: false
|
1798
|
+
});
|
1799
|
+
},
|
1800
|
+
complete: () => {
|
1801
|
+
this.ReleaseSubscription(this._DELETE$);
|
1802
|
+
if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
|
1803
|
+
this.alert.Success(request.alertSuccess, 'Deleted', 'fa-regular fa-trash-can');
|
1804
|
+
}
|
1805
|
+
}
|
1806
|
+
});
|
1807
|
+
}
|
1808
|
+
else {
|
1809
|
+
const subscription = this.http.request(new HttpRequest("DELETE", request.url, { params: request.queryParams, headers: request.headers })).subscribe({
|
1810
|
+
next: (response) => {
|
1811
|
+
if (response.type > 0) {
|
1812
|
+
Resolve({
|
1813
|
+
body: {},
|
1814
|
+
status: response.status,
|
1815
|
+
message: response.statusText,
|
1816
|
+
ok: true
|
1817
|
+
});
|
1818
|
+
}
|
1819
|
+
},
|
1820
|
+
error: (httpError) => {
|
1821
|
+
this.ReleaseSubscription(subscription);
|
1822
|
+
this.AlertError(httpError, request.alertError);
|
1823
|
+
Resolve({
|
1824
|
+
body: {},
|
1825
|
+
status: httpError.status,
|
1826
|
+
message: httpError.error?.message || httpError.error,
|
1827
|
+
ok: false
|
1828
|
+
});
|
1829
|
+
},
|
1830
|
+
complete: () => {
|
1831
|
+
this.ReleaseSubscription(subscription);
|
1832
|
+
if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
|
1833
|
+
this.alert.Success(request.alertSuccess, 'Deleted', 'fa-regular fa-trash-can');
|
1834
|
+
}
|
1835
|
+
}
|
1836
|
+
});
|
1837
|
+
}
|
1838
|
+
});
|
1839
|
+
}
|
1840
|
+
/** */
|
1841
|
+
AlertError(httpError, message) {
|
1842
|
+
if (httpError.status >= 500) {
|
1843
|
+
if (Tools.IsNotOnlyWhiteSpace(message)) {
|
1844
|
+
this.alert.Error(message, 'BUG', 'fa-solid fa-bug', null);
|
1845
|
+
}
|
1846
|
+
}
|
1847
|
+
else if (httpError.status < 500) {
|
1848
|
+
switch (httpError.status) {
|
1849
|
+
case 400: {
|
1850
|
+
this.alert.Warning(httpError.error?.message || httpError.error, 'Bad Request', 'fa-regular fa-face-grin-beam-sweat fa-lg');
|
1851
|
+
break;
|
1852
|
+
}
|
1853
|
+
case 401: {
|
1854
|
+
this.alert.Warning(httpError.error?.message || httpError.error, 'Unauthorize', 'fa-regular fa-face-rolling-eyes fa-lg');
|
1855
|
+
break;
|
1856
|
+
}
|
1857
|
+
case 403: {
|
1858
|
+
this.alert.Warning(httpError.error?.message || httpError.error, 'Forbidden', 'fa-regular fa-face-rolling-eyes fa-lg');
|
1859
|
+
break;
|
1860
|
+
}
|
1861
|
+
case 404: {
|
1862
|
+
this.alert.Warning(httpError.error?.message || httpError.error, 'Not Found', 'fa-regular fa-face-meh fa-lg');
|
1863
|
+
break;
|
1864
|
+
}
|
1865
|
+
case 405: {
|
1866
|
+
this.alert.Warning(httpError.error?.message || httpError.error, 'Not Allowed', 'fa-regular fa-face-grimace fa-lg');
|
1867
|
+
break;
|
1868
|
+
}
|
1869
|
+
case 406: {
|
1870
|
+
this.alert.Warning(httpError.error?.message || httpError.error, 'Not Acceptable', 'fa-regular fa-face-frown-open fa-lg');
|
1871
|
+
break;
|
1872
|
+
}
|
1873
|
+
case 409: {
|
1874
|
+
this.alert.Warning(httpError.error?.message || httpError.error, 'Conflict', 'fa-regular fa-face-dizzy fa-lg');
|
1875
|
+
break;
|
1876
|
+
}
|
1877
|
+
case 413: {
|
1878
|
+
this.alert.Warning(httpError.error?.message || httpError.error, 'Too Large', 'fa-regular fa-face-flushed fa-lg');
|
1879
|
+
break;
|
1880
|
+
}
|
1881
|
+
default: {
|
1882
|
+
if (httpError.status <= 0) {
|
1883
|
+
this.alert.Warning('Without Connection', 'WEB API DOWN', 'fa-solid fa-plug-circle-xmark fa-lg');
|
1884
|
+
}
|
1885
|
+
else
|
1886
|
+
this.alert.Warning(httpError.error?.message || httpError.error);
|
1887
|
+
break;
|
1888
|
+
}
|
1889
|
+
}
|
1890
|
+
}
|
1891
|
+
}
|
1892
|
+
}
|
1893
|
+
|
1894
|
+
/**
|
1895
|
+
* Generated bundle index. Do not edit.
|
1896
|
+
*/
|
1897
|
+
|
1898
|
+
export { Breadcrumbs, CONTROL_VALUE, CoerAlert, Colors, ControlValue, DateTime, ElementsHTML, Files, Filters, GridTemplates, Menu, Page, Screen, Section, Service, Source, Tools, User };
|
1899
|
+
//# sourceMappingURL=coer-elements-tools.mjs.map
|