dts-backoffice-util 3.0.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dts-backoffice-util.d.ts +1 -0
- package/esm2020/dts-backoffice-util.mjs +5 -0
- package/esm2020/lib/components/totvs-schedule-execution/totvs-schedule-execution.component.mjs +269 -0
- package/esm2020/lib/components/totvs-schedule-execution/totvs-schedule-execution.model.mjs +7 -0
- package/esm2020/lib/components/totvs-schedule-execution/totvs-schedule-execution.service.mjs +183 -0
- package/esm2020/lib/dts-backoffice-util.module.mjs +56 -0
- package/esm2020/lib/interfaces/filter-range.interface.mjs +2 -0
- package/esm2020/lib/interfaces/totvs-response.interface.mjs +2 -0
- package/esm2020/lib/model/session-info.model.mjs +67 -0
- package/esm2020/lib/pipes/dts-date-format.pipe.mjs +20 -0
- package/esm2020/lib/services/breadcrumb-control.service.mjs +82 -0
- package/esm2020/lib/services/cache-params.service.mjs +25 -0
- package/esm2020/lib/services/menu-datasul.service.mjs +41 -0
- package/esm2020/lib/services/profile.service.mjs +55 -0
- package/esm2020/lib/services/report.service.mjs +57 -0
- package/esm2020/lib/services/session-info.service.mjs +36 -0
- package/esm2020/lib/services/translate.service.mjs +23 -0
- package/esm2020/lib/utils/date.util.mjs +56 -0
- package/esm2020/lib/utils/disclaimer.util.mjs +453 -0
- package/esm2020/lib/utils/field-validation.util.mjs +179 -0
- package/esm2020/lib/utils/file.util.mjs +122 -0
- package/esm2020/lib/utils/filter-range.util.mjs +33 -0
- package/esm2020/lib/utils/generic-functions.utils.mjs +170 -0
- package/esm2020/public-api.mjs +34 -0
- package/fesm2015/{dts-backoffice-util.js → dts-backoffice-util.mjs} +230 -1626
- package/fesm2015/dts-backoffice-util.mjs.map +1 -0
- package/fesm2020/dts-backoffice-util.mjs +1844 -0
- package/fesm2020/dts-backoffice-util.mjs.map +1 -0
- package/lib/components/totvs-schedule-execution/totvs-schedule-execution.component.d.ts +3 -0
- package/lib/components/totvs-schedule-execution/totvs-schedule-execution.service.d.ts +3 -0
- package/lib/dts-backoffice-util.module.d.ts +10 -0
- package/lib/pipes/dts-date-format.pipe.d.ts +3 -0
- package/lib/services/breadcrumb-control.service.d.ts +3 -0
- package/lib/services/cache-params.service.d.ts +3 -0
- package/lib/services/menu-datasul.service.d.ts +3 -0
- package/lib/services/profile.service.d.ts +3 -0
- package/lib/services/report.service.d.ts +3 -0
- package/lib/services/session-info.service.d.ts +3 -0
- package/lib/services/translate.service.d.ts +3 -0
- package/package.json +23 -11
- package/CHANGELOG.md +0 -159
- package/bundles/dts-backoffice-util.umd.js +0 -3296
- package/bundles/dts-backoffice-util.umd.js.map +0 -1
- package/bundles/dts-backoffice-util.umd.min.js +0 -2
- package/bundles/dts-backoffice-util.umd.min.js.map +0 -1
- package/dts-backoffice-util.metadata.json +0 -1
- package/esm2015/dts-backoffice-util.js +0 -10
- package/esm2015/lib/components/totvs-schedule-execution/totvs-schedule-execution.component.js +0 -391
- package/esm2015/lib/components/totvs-schedule-execution/totvs-schedule-execution.model.js +0 -132
- package/esm2015/lib/components/totvs-schedule-execution/totvs-schedule-execution.service.js +0 -344
- package/esm2015/lib/dts-backoffice-util.module.js +0 -47
- package/esm2015/lib/interfaces/filter-range.interface.js +0 -48
- package/esm2015/lib/interfaces/totvs-response.interface.js +0 -17
- package/esm2015/lib/model/session-info.model.js +0 -183
- package/esm2015/lib/pipes/dts-date-format.pipe.js +0 -27
- package/esm2015/lib/services/breadcrumb-control.service.js +0 -124
- package/esm2015/lib/services/cache-params.service.js +0 -47
- package/esm2015/lib/services/menu-datasul.service.js +0 -57
- package/esm2015/lib/services/profile.service.js +0 -127
- package/esm2015/lib/services/report.service.js +0 -127
- package/esm2015/lib/services/session-info.service.js +0 -62
- package/esm2015/lib/services/translate.service.js +0 -35
- package/esm2015/lib/utils/date.util.js +0 -95
- package/esm2015/lib/utils/disclaimer.util.js +0 -738
- package/esm2015/lib/utils/field-validation.util.js +0 -275
- package/esm2015/lib/utils/file.util.js +0 -224
- package/esm2015/lib/utils/filter-range.util.js +0 -53
- package/esm2015/lib/utils/generic-functions.utils.js +0 -296
- package/esm2015/public-api.js +0 -38
- package/fesm2015/dts-backoffice-util.js.map +0 -1
|
@@ -0,0 +1,1844 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Injectable, EventEmitter, Component, ViewChild, Input, Output, Pipe, NgModule } from '@angular/core';
|
|
3
|
+
import { of } from 'rxjs';
|
|
4
|
+
import { map } from 'rxjs/operators';
|
|
5
|
+
import * as i1 from '@angular/common/http';
|
|
6
|
+
import { HttpErrorResponse, HttpClientModule } from '@angular/common/http';
|
|
7
|
+
import * as i1$1 from '@po-ui/ng-components';
|
|
8
|
+
import { PoModule } from '@po-ui/ng-components';
|
|
9
|
+
import * as i3 from '@angular/forms';
|
|
10
|
+
import { FormsModule } from '@angular/forms';
|
|
11
|
+
import * as i4 from '@angular/common';
|
|
12
|
+
import { CommonModule } from '@angular/common';
|
|
13
|
+
|
|
14
|
+
class UserLoginService {
|
|
15
|
+
constructor(http) {
|
|
16
|
+
this.http = http;
|
|
17
|
+
this.apiUrl = '/totvs-menu/rest/getSessionInfo';
|
|
18
|
+
this.userLogin = undefined;
|
|
19
|
+
}
|
|
20
|
+
getUserLogin() {
|
|
21
|
+
if (localStorage.getItem('username')) {
|
|
22
|
+
return of(localStorage.getItem('username'));
|
|
23
|
+
}
|
|
24
|
+
if (this.userLogin) {
|
|
25
|
+
return of(this.userLogin);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
return this.http.get(`${this.apiUrl}`)
|
|
29
|
+
.pipe(map((response) => {
|
|
30
|
+
this.userLogin = response.userName;
|
|
31
|
+
return response.userName;
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/** @nocollapse */ UserLoginService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: UserLoginService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
37
|
+
/** @nocollapse */ UserLoginService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: UserLoginService, providedIn: 'root' });
|
|
38
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: UserLoginService, decorators: [{
|
|
39
|
+
type: Injectable,
|
|
40
|
+
args: [{
|
|
41
|
+
providedIn: 'root'
|
|
42
|
+
}]
|
|
43
|
+
}], ctorParameters: function () { return [{ type: i1.HttpClient }]; } });
|
|
44
|
+
|
|
45
|
+
var EDataType;
|
|
46
|
+
(function (EDataType) {
|
|
47
|
+
EDataType[EDataType["STRING"] = 1] = "STRING";
|
|
48
|
+
EDataType[EDataType["JSON"] = 2] = "JSON";
|
|
49
|
+
})(EDataType || (EDataType = {}));
|
|
50
|
+
class ProfileService {
|
|
51
|
+
constructor(http) {
|
|
52
|
+
this.http = http;
|
|
53
|
+
this.apiURL = '/dts/datasul-rest/resources/api/btb/btapi930za';
|
|
54
|
+
}
|
|
55
|
+
setProfile(profile) {
|
|
56
|
+
const headers = { 'X-PO-Screen-Lock': 'true' };
|
|
57
|
+
const { pageId, userCode } = profile;
|
|
58
|
+
return this.http
|
|
59
|
+
.post(`${this.apiURL}/setProfile?userCode=${userCode}&pageId=${pageId}`, profile, { headers });
|
|
60
|
+
}
|
|
61
|
+
getProfileAsString(profile, showLoading) {
|
|
62
|
+
return this.getProfile(profile, EDataType.STRING, showLoading ? 'true' : 'false');
|
|
63
|
+
}
|
|
64
|
+
getProfileAsJSON(profile, showLoading) {
|
|
65
|
+
return this.getProfile(profile, EDataType.JSON, showLoading ? 'true' : 'false');
|
|
66
|
+
}
|
|
67
|
+
getProfile(profile, dataType, showLoading) {
|
|
68
|
+
const headers = { 'X-PO-Screen-Lock': showLoading };
|
|
69
|
+
const { pageId, dataCode, userCode } = profile;
|
|
70
|
+
return this.http
|
|
71
|
+
.get(`${this.apiURL}/getProfile?userCode=${userCode}&pageId=${pageId}&dataCode=${dataCode}`, { headers })
|
|
72
|
+
.pipe(map(preference => {
|
|
73
|
+
if (preference.data[0]) {
|
|
74
|
+
if (dataType === EDataType.STRING) {
|
|
75
|
+
return preference.data[0].dataValue;
|
|
76
|
+
}
|
|
77
|
+
if (dataType === EDataType.JSON) {
|
|
78
|
+
return JSON.parse(preference.data[0].dataValue);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
}));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/** @nocollapse */ ProfileService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ProfileService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
88
|
+
/** @nocollapse */ ProfileService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ProfileService, providedIn: 'root' });
|
|
89
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ProfileService, decorators: [{
|
|
90
|
+
type: Injectable,
|
|
91
|
+
args: [{
|
|
92
|
+
providedIn: 'root'
|
|
93
|
+
}]
|
|
94
|
+
}], ctorParameters: function () { return [{ type: i1.HttpClient }]; } });
|
|
95
|
+
|
|
96
|
+
var ReportFormats;
|
|
97
|
+
(function (ReportFormats) {
|
|
98
|
+
ReportFormats["XLSX"] = "xlsx";
|
|
99
|
+
ReportFormats["PDF"] = "pdf";
|
|
100
|
+
ReportFormats["DOCX"] = "docx";
|
|
101
|
+
ReportFormats["HTML"] = "html";
|
|
102
|
+
})(ReportFormats || (ReportFormats = {}));
|
|
103
|
+
class ReportService {
|
|
104
|
+
constructor(httpClient) {
|
|
105
|
+
this.httpClient = httpClient;
|
|
106
|
+
this.URL = window.location.href.indexOf('totvs-menu') > 0 ? '/totvs-menu/rest/report/run/'
|
|
107
|
+
: '/dts/datasul-report/resources/run/';
|
|
108
|
+
}
|
|
109
|
+
generate(params, showLoading = true) {
|
|
110
|
+
const headers = { 'X-PO-Screen-Lock': showLoading ? 'true' : 'false' };
|
|
111
|
+
let reportURL = `${this.URL}${params.reportName}`;
|
|
112
|
+
if (params.properties.length > 0) {
|
|
113
|
+
reportURL += '?';
|
|
114
|
+
params.properties.forEach((property, index) => {
|
|
115
|
+
if (index > 0) {
|
|
116
|
+
reportURL += '&';
|
|
117
|
+
}
|
|
118
|
+
reportURL += `c_properties=${property.name}&c_values=${property.value}`;
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
reportURL += `&dialect=${params.dialect}&format=${params.format}`;
|
|
122
|
+
reportURL += `&program=${params.programName}&resultFileName=${params.downloadName}`;
|
|
123
|
+
return this.httpClient.post(reportURL, {}, { headers, responseType: 'blob' })
|
|
124
|
+
.pipe(map(report => {
|
|
125
|
+
if (params.download) {
|
|
126
|
+
this.download(report, `${params.downloadName}.${params.format}`);
|
|
127
|
+
}
|
|
128
|
+
return report;
|
|
129
|
+
}));
|
|
130
|
+
}
|
|
131
|
+
download(file, fileName) {
|
|
132
|
+
const binaryData = [file];
|
|
133
|
+
const downloadLink = document.createElement('a');
|
|
134
|
+
const urlDownload = window.URL.createObjectURL(new Blob(binaryData, { type: file.type }));
|
|
135
|
+
downloadLink.href = urlDownload;
|
|
136
|
+
downloadLink.setAttribute('download', fileName);
|
|
137
|
+
document.body.appendChild(downloadLink);
|
|
138
|
+
downloadLink.click();
|
|
139
|
+
window.URL.revokeObjectURL(urlDownload);
|
|
140
|
+
downloadLink.remove();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/** @nocollapse */ ReportService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ReportService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
144
|
+
/** @nocollapse */ ReportService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ReportService });
|
|
145
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ReportService, decorators: [{
|
|
146
|
+
type: Injectable
|
|
147
|
+
}], ctorParameters: function () { return [{ type: i1.HttpClient }]; } });
|
|
148
|
+
|
|
149
|
+
/*
|
|
150
|
+
Versão: 1.003
|
|
151
|
+
Data Criação: 06/08/2018
|
|
152
|
+
*/
|
|
153
|
+
class BreadcrumbControlService {
|
|
154
|
+
constructor() { }
|
|
155
|
+
newBreadcrumb() {
|
|
156
|
+
this.breadcrumb = { items: [] };
|
|
157
|
+
}
|
|
158
|
+
addBreadcrumb(literal, activatedRoute) {
|
|
159
|
+
this.addBreadcrumbURL(literal, decodeURIComponent(activatedRoute.snapshot['_routerState'].url));
|
|
160
|
+
}
|
|
161
|
+
addBreadcrumbURL(literal, url) {
|
|
162
|
+
if (!literal || literal === '') {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
if (!this.breadcrumb) {
|
|
166
|
+
this.newBreadcrumb();
|
|
167
|
+
}
|
|
168
|
+
const breadcrumbAux = { items: [] };
|
|
169
|
+
let idx = 0;
|
|
170
|
+
for (idx = 0; idx < this.breadcrumb.items.length; idx++) {
|
|
171
|
+
if (this.breadcrumb.items[idx].label !== literal) {
|
|
172
|
+
breadcrumbAux.items.push(this.breadcrumb.items[idx]);
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
breadcrumbAux.items.push({ label: literal, link: url });
|
|
179
|
+
this.breadcrumb = breadcrumbAux;
|
|
180
|
+
}
|
|
181
|
+
updBreadcrumbURL(literal, valueOld, valueNew) {
|
|
182
|
+
let currentRouterURL = this.getCurrentRouter();
|
|
183
|
+
if (!currentRouterURL) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
if (!valueOld) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
if (!valueNew) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
currentRouterURL = currentRouterURL.replace(valueOld, valueNew);
|
|
193
|
+
this.addBreadcrumbURL(literal, currentRouterURL);
|
|
194
|
+
}
|
|
195
|
+
getBreadcrumb() {
|
|
196
|
+
if (!this.breadcrumb) {
|
|
197
|
+
this.newBreadcrumb();
|
|
198
|
+
}
|
|
199
|
+
return this.breadcrumb;
|
|
200
|
+
}
|
|
201
|
+
getCurrentRouter() {
|
|
202
|
+
if (!this.breadcrumb) {
|
|
203
|
+
this.newBreadcrumb();
|
|
204
|
+
}
|
|
205
|
+
if (this.breadcrumb.items.length <= 0) {
|
|
206
|
+
return '';
|
|
207
|
+
}
|
|
208
|
+
return this.breadcrumb.items[this.breadcrumb.items.length - 1].link;
|
|
209
|
+
}
|
|
210
|
+
getPrevRouter() {
|
|
211
|
+
if (!this.breadcrumb) {
|
|
212
|
+
this.newBreadcrumb();
|
|
213
|
+
}
|
|
214
|
+
if (this.breadcrumb.items.length <= 1) {
|
|
215
|
+
return '';
|
|
216
|
+
}
|
|
217
|
+
return this.breadcrumb.items[this.breadcrumb.items.length - 2].link;
|
|
218
|
+
}
|
|
219
|
+
hasPreviousRouter() {
|
|
220
|
+
return this.breadcrumb.items.length > 1;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
/** @nocollapse */ BreadcrumbControlService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: BreadcrumbControlService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
224
|
+
/** @nocollapse */ BreadcrumbControlService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: BreadcrumbControlService });
|
|
225
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: BreadcrumbControlService, decorators: [{
|
|
226
|
+
type: Injectable
|
|
227
|
+
}], ctorParameters: function () { return []; } });
|
|
228
|
+
|
|
229
|
+
class MenuDatasulService {
|
|
230
|
+
constructor() { }
|
|
231
|
+
/**
|
|
232
|
+
* var program = {};
|
|
233
|
+
* program['prg'] = "cd0210";
|
|
234
|
+
* program['params'] = '01|123456'
|
|
235
|
+
*/
|
|
236
|
+
callProgress(program) {
|
|
237
|
+
parent.postMessage({ program }, '*');
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* var notification = {};
|
|
241
|
+
* notification['type'] = 'success';
|
|
242
|
+
* notification['title'] = 'Notification Title'
|
|
243
|
+
* notification['detail'] = 'Notification Detail'
|
|
244
|
+
*/
|
|
245
|
+
sendNotification(notification) {
|
|
246
|
+
parent.postMessage({ notification }, '*');
|
|
247
|
+
}
|
|
248
|
+
openPath(programName, params, parent = true) {
|
|
249
|
+
const datasulPath = document.referrer.indexOf('totvs-menu') > 0 ? 'totvs-menu' : 'menu-html';
|
|
250
|
+
let baseUrl = `/${datasulPath}/#/${datasulPath}/program-html/${programName}/#`;
|
|
251
|
+
if (params) {
|
|
252
|
+
baseUrl = `${baseUrl}/${params}`;
|
|
253
|
+
}
|
|
254
|
+
if (parent) {
|
|
255
|
+
window.open(baseUrl, '_parent');
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
window.open(baseUrl);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
/** @nocollapse */ MenuDatasulService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: MenuDatasulService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
263
|
+
/** @nocollapse */ MenuDatasulService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: MenuDatasulService });
|
|
264
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: MenuDatasulService, decorators: [{
|
|
265
|
+
type: Injectable
|
|
266
|
+
}], ctorParameters: function () { return []; } });
|
|
267
|
+
|
|
268
|
+
class CacheParamsService {
|
|
269
|
+
constructor() {
|
|
270
|
+
this.values = {};
|
|
271
|
+
}
|
|
272
|
+
setValue(key, value) {
|
|
273
|
+
this.values[key] = value;
|
|
274
|
+
}
|
|
275
|
+
getValue(key) {
|
|
276
|
+
return this.values[key];
|
|
277
|
+
}
|
|
278
|
+
removeValue(key) {
|
|
279
|
+
delete this.values[key];
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
/** @nocollapse */ CacheParamsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: CacheParamsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
283
|
+
/** @nocollapse */ CacheParamsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: CacheParamsService, providedIn: 'root' });
|
|
284
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: CacheParamsService, decorators: [{
|
|
285
|
+
type: Injectable,
|
|
286
|
+
args: [{
|
|
287
|
+
providedIn: 'root'
|
|
288
|
+
}]
|
|
289
|
+
}], ctorParameters: function () { return []; } });
|
|
290
|
+
|
|
291
|
+
class TranslateService {
|
|
292
|
+
static getSuportLanguage() {
|
|
293
|
+
return ['pt-BR', 'pt', 'en-US', 'en', 'es'];
|
|
294
|
+
}
|
|
295
|
+
static getDefaultCurrencyCode() {
|
|
296
|
+
return '$';
|
|
297
|
+
}
|
|
298
|
+
static getCurrentLanguage() {
|
|
299
|
+
const locale = localStorage.getItem('user.language') || navigator.language;
|
|
300
|
+
if (locale && this.getSuportLanguage().includes(locale)) {
|
|
301
|
+
return locale;
|
|
302
|
+
}
|
|
303
|
+
return 'en-US';
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
/** @nocollapse */ TranslateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: TranslateService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
307
|
+
/** @nocollapse */ TranslateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: TranslateService });
|
|
308
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: TranslateService, decorators: [{
|
|
309
|
+
type: Injectable
|
|
310
|
+
}] });
|
|
311
|
+
|
|
312
|
+
/*
|
|
313
|
+
Versão: 1.000
|
|
314
|
+
Data Criação: 18/04/2019
|
|
315
|
+
*/
|
|
316
|
+
class DateUtil {
|
|
317
|
+
constructor() { }
|
|
318
|
+
/* Transforma data para o padrão YYYY-MM-DD */
|
|
319
|
+
static dateToQueryParam(date) {
|
|
320
|
+
const iDay = date.getDate();
|
|
321
|
+
const iMonth = date.getMonth() + 1;
|
|
322
|
+
const iYear = date.getFullYear();
|
|
323
|
+
return `${iYear}-${this.pad(iMonth)}-${this.pad(iDay)}`;
|
|
324
|
+
}
|
|
325
|
+
/* Transforma data no padrão YYYY-MM-DD para DATE */
|
|
326
|
+
static queryParamToDate(param) {
|
|
327
|
+
const iDay = +param.split('-')[2];
|
|
328
|
+
const iMonth = +param.split('-')[1];
|
|
329
|
+
const iYear = +param.split('-')[0];
|
|
330
|
+
return new Date(iYear, iMonth - 1, iDay);
|
|
331
|
+
}
|
|
332
|
+
/* Valida se foi informado uma data válida */
|
|
333
|
+
static isValidDate(date) {
|
|
334
|
+
return date instanceof Date && !isNaN(date.getTime());
|
|
335
|
+
}
|
|
336
|
+
/* Ajusta a data retornando o padrão DATE */
|
|
337
|
+
static ajustDate(param) {
|
|
338
|
+
if (param instanceof Date) {
|
|
339
|
+
return param;
|
|
340
|
+
}
|
|
341
|
+
if (!param) {
|
|
342
|
+
return param;
|
|
343
|
+
}
|
|
344
|
+
return this.queryParamToDate(param.split('T')[0]);
|
|
345
|
+
}
|
|
346
|
+
/* Ajusta a data para o padrão DATE - utilizada nos construtores dos modelos */
|
|
347
|
+
static ajustDateToModel(values = {}, fieldName) {
|
|
348
|
+
if (values.hasOwnProperty(fieldName) && (values[fieldName])) {
|
|
349
|
+
if (values[fieldName].indexOf('T') >= 0) {
|
|
350
|
+
return new Date(values[fieldName]);
|
|
351
|
+
}
|
|
352
|
+
const iDay = +values[fieldName].split('-')[2];
|
|
353
|
+
const iMonth = +values[fieldName].split('-')[1];
|
|
354
|
+
const iYear = +values[fieldName].split('-')[0];
|
|
355
|
+
return new Date(iYear, iMonth - 1, iDay);
|
|
356
|
+
}
|
|
357
|
+
return null;
|
|
358
|
+
}
|
|
359
|
+
/* Adicona zero a esquerda do número */
|
|
360
|
+
static pad(number) {
|
|
361
|
+
if (number < 10) {
|
|
362
|
+
return '0' + number;
|
|
363
|
+
}
|
|
364
|
+
return number;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/*
|
|
369
|
+
Versão: 1.009
|
|
370
|
+
Data Criação: 06/08/2018
|
|
371
|
+
*/
|
|
372
|
+
class DisclaimerUtil {
|
|
373
|
+
constructor(poNotification, poI18nPipe, literals) {
|
|
374
|
+
this.literals = {};
|
|
375
|
+
this.poNotification = poNotification;
|
|
376
|
+
this.poI18nPipe = poI18nPipe;
|
|
377
|
+
this.literals = literals;
|
|
378
|
+
}
|
|
379
|
+
makeDisclaimer(property, value, hideClose = false, tradValue = false, vldBlank = false) {
|
|
380
|
+
if (value === null || value === undefined) {
|
|
381
|
+
return { label: '', property: '', value: '' };
|
|
382
|
+
}
|
|
383
|
+
if (vldBlank && value === '') {
|
|
384
|
+
return { label: '', property: '', value: '' };
|
|
385
|
+
}
|
|
386
|
+
return {
|
|
387
|
+
hideClose,
|
|
388
|
+
label: `${this.literals[property]}: ${tradValue ? this.literals[value] : value}`,
|
|
389
|
+
property: `${property}`,
|
|
390
|
+
value: `${value}`
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
makeDisclaimerFromNumber(property, value, hideClose = false, vldBlank = false) {
|
|
394
|
+
if (value === null || value === undefined) {
|
|
395
|
+
return { label: '', property: '', value: '' };
|
|
396
|
+
}
|
|
397
|
+
if (vldBlank && value === 0) {
|
|
398
|
+
return { label: '', property: '', value: '' };
|
|
399
|
+
}
|
|
400
|
+
return {
|
|
401
|
+
hideClose,
|
|
402
|
+
label: `${this.literals[property]}: ${value}`,
|
|
403
|
+
property: `${property}`,
|
|
404
|
+
value: `${value}`
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
makeDisclaimerFromBoolean(property, value, hideClose = false) {
|
|
408
|
+
if (value === null || value === undefined) {
|
|
409
|
+
return { label: '', property: '', value: '' };
|
|
410
|
+
}
|
|
411
|
+
return {
|
|
412
|
+
hideClose,
|
|
413
|
+
label: `${this.literals[property]}: ${value ? this.literals['yes'] : this.literals['no']}`,
|
|
414
|
+
property: `${property}`,
|
|
415
|
+
value: `${value}`
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
makeDisclaimerFromDate(property, value, hideClose = false) {
|
|
419
|
+
const dDate = this.ajustDate(value);
|
|
420
|
+
if (!this.isValidDate(dDate)) {
|
|
421
|
+
return { label: '', property: '', value: '' };
|
|
422
|
+
}
|
|
423
|
+
return {
|
|
424
|
+
hideClose,
|
|
425
|
+
label: `${this.literals[property]}: ${dDate.toLocaleDateString()}`,
|
|
426
|
+
property: `${property}`,
|
|
427
|
+
value: `${this.dateToQueryParam(dDate)}`
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
makeDisclaimerFromMultiSelect(property, value, length = 0, hideClose = false, tradValue = false) {
|
|
431
|
+
let lstLabels = '';
|
|
432
|
+
let lstValues = '';
|
|
433
|
+
if (!value) {
|
|
434
|
+
return { label: '', property: '', value: '' };
|
|
435
|
+
}
|
|
436
|
+
if (value.length === 0 || (length > 0 && value.length === length)) {
|
|
437
|
+
lstLabels = this.literals['all'];
|
|
438
|
+
lstValues = 'all';
|
|
439
|
+
}
|
|
440
|
+
else {
|
|
441
|
+
value.map(item => {
|
|
442
|
+
if (lstLabels !== '') {
|
|
443
|
+
lstLabels = `${lstLabels}, `;
|
|
444
|
+
}
|
|
445
|
+
if (lstValues !== '') {
|
|
446
|
+
lstValues = `${lstValues},`;
|
|
447
|
+
}
|
|
448
|
+
lstLabels = `${lstLabels}${tradValue ? this.literals[item] : item}`;
|
|
449
|
+
lstValues = `${lstValues}${item}`;
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
return {
|
|
453
|
+
hideClose,
|
|
454
|
+
label: `${this.literals[property]}: ${lstLabels}`,
|
|
455
|
+
property: `${property}`,
|
|
456
|
+
value: `${lstValues}`
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
makeDisclaimerFromMultiSelectNumber(property, value, options, length = 0, hideClose = false) {
|
|
460
|
+
let lstLabels = '';
|
|
461
|
+
let lstValues = '';
|
|
462
|
+
let opt = null;
|
|
463
|
+
if (!value || !options) {
|
|
464
|
+
return { label: '', property: '', value: '' };
|
|
465
|
+
}
|
|
466
|
+
if (value.length === 0 || (length > 0 && value.length === length)) {
|
|
467
|
+
lstLabels = this.literals['all'];
|
|
468
|
+
lstValues = 'all';
|
|
469
|
+
}
|
|
470
|
+
else {
|
|
471
|
+
value.map(item => {
|
|
472
|
+
if (lstLabels !== '') {
|
|
473
|
+
lstLabels = `${lstLabels}, `;
|
|
474
|
+
}
|
|
475
|
+
if (lstValues !== '') {
|
|
476
|
+
lstValues = `${lstValues},`;
|
|
477
|
+
}
|
|
478
|
+
opt = options.find(itOpt => itOpt.value === item);
|
|
479
|
+
lstLabels = `${lstLabels}${opt ? opt.label : item}`;
|
|
480
|
+
lstValues = `${lstValues}${item}`;
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
return {
|
|
484
|
+
hideClose,
|
|
485
|
+
label: `${this.literals[property]}: ${lstLabels}`,
|
|
486
|
+
property: `${property}`,
|
|
487
|
+
value: `${lstValues}`
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
makeDisclaimerFromCheckboxGroup(property, value, length = 0, hideClose = false) {
|
|
491
|
+
let lstLabels = '';
|
|
492
|
+
let lstValues = '';
|
|
493
|
+
if (!value) {
|
|
494
|
+
return { label: '', property: '', value: '' };
|
|
495
|
+
}
|
|
496
|
+
if (value.length === 0) {
|
|
497
|
+
lstLabels = this.literals['none'];
|
|
498
|
+
lstValues = 'none';
|
|
499
|
+
}
|
|
500
|
+
else if (length > 0 && value.length === length) {
|
|
501
|
+
lstLabels = this.literals['all'];
|
|
502
|
+
lstValues = 'all';
|
|
503
|
+
}
|
|
504
|
+
else {
|
|
505
|
+
value.map(checkParam => {
|
|
506
|
+
if (lstLabels !== '') {
|
|
507
|
+
lstLabels = `${lstLabels}, `;
|
|
508
|
+
}
|
|
509
|
+
if (lstValues !== '') {
|
|
510
|
+
lstValues = `${lstValues},`;
|
|
511
|
+
}
|
|
512
|
+
lstLabels = `${lstLabels}${this.literals[checkParam]}`;
|
|
513
|
+
lstValues = `${lstValues}${checkParam}`;
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
return {
|
|
517
|
+
hideClose,
|
|
518
|
+
label: `${this.literals[property]}: ${lstLabels}`,
|
|
519
|
+
property: `${property}`,
|
|
520
|
+
value: `${lstValues}`
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
makeDisclaimerFromRangeCharacter(property, value, hideClose = false, validateEqual = true) {
|
|
524
|
+
if (value.valInitial === null || value.valInitial === undefined) {
|
|
525
|
+
value.valInitial = value.iniInitial;
|
|
526
|
+
}
|
|
527
|
+
if (value.valFinal === null || value.valFinal === undefined) {
|
|
528
|
+
value.valFinal = value.iniFinal;
|
|
529
|
+
}
|
|
530
|
+
if (validateEqual &&
|
|
531
|
+
value.iniInitial === value.valInitial &&
|
|
532
|
+
value.iniFinal === value.valFinal) {
|
|
533
|
+
return { label: '', property: '', value: '' };
|
|
534
|
+
}
|
|
535
|
+
return {
|
|
536
|
+
hideClose,
|
|
537
|
+
label: this.poI18nPipe.transform(this.literals['filterRange'], [this.literals[property], `'${value.valInitial}'`, `'${value.valFinal}'`]),
|
|
538
|
+
property: `${property}`,
|
|
539
|
+
value: `${value.valInitial};${value.valFinal}`
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
makeDisclaimerFromRangeNumber(property, value, hideClose = false, validateEqual = true) {
|
|
543
|
+
if (value.valInitial === null || value.valInitial === undefined) {
|
|
544
|
+
value.valInitial = value.iniInitial;
|
|
545
|
+
}
|
|
546
|
+
if (value.valFinal === null || value.valFinal === undefined) {
|
|
547
|
+
value.valFinal = value.iniFinal;
|
|
548
|
+
}
|
|
549
|
+
if (validateEqual &&
|
|
550
|
+
value.iniInitial === value.valInitial &&
|
|
551
|
+
value.iniFinal === value.valFinal) {
|
|
552
|
+
return { label: '', property: '', value: '' };
|
|
553
|
+
}
|
|
554
|
+
return {
|
|
555
|
+
hideClose,
|
|
556
|
+
label: this.poI18nPipe.transform(this.literals['filterRange'], [this.literals[property], value.valInitial, value.valFinal]),
|
|
557
|
+
property: `${property}`,
|
|
558
|
+
value: `${value.valInitial};${value.valFinal}`
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
makeDisclaimerFromRangeDate(property, value, hideClose = false, validateEqual = true) {
|
|
562
|
+
let valInitDate = this.ajustDate(value.valInitial);
|
|
563
|
+
let valFinalDate = this.ajustDate(value.valFinal);
|
|
564
|
+
if (!this.isValidDate(valInitDate)) {
|
|
565
|
+
valInitDate = value.iniInitial;
|
|
566
|
+
value.valInitial = value.iniInitial;
|
|
567
|
+
}
|
|
568
|
+
if (!this.isValidDate(valFinalDate)) {
|
|
569
|
+
valFinalDate = value.iniFinal;
|
|
570
|
+
value.valFinal = value.iniFinal;
|
|
571
|
+
}
|
|
572
|
+
if (validateEqual &&
|
|
573
|
+
this.dateToQueryParam(value.iniInitial) === this.dateToQueryParam(valInitDate) &&
|
|
574
|
+
this.dateToQueryParam(value.iniFinal) === this.dateToQueryParam(valFinalDate)) {
|
|
575
|
+
return { label: '', property: '', value: '' };
|
|
576
|
+
}
|
|
577
|
+
return {
|
|
578
|
+
hideClose,
|
|
579
|
+
label: this.poI18nPipe.transform(this.literals['filterRange'], [this.literals[property], valInitDate.toLocaleDateString(), valFinalDate.toLocaleDateString()]),
|
|
580
|
+
property: `${property}`,
|
|
581
|
+
value: `${this.dateToQueryParam(valInitDate)};${this.dateToQueryParam(valFinalDate)}`
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
atzCharFromDisclamer(disclaimers, property, defaultValue) {
|
|
585
|
+
let returnValue = defaultValue;
|
|
586
|
+
if (disclaimers && disclaimers.length > 0) {
|
|
587
|
+
disclaimers.find((item) => {
|
|
588
|
+
if (item.property === property) {
|
|
589
|
+
if (item.value === null) {
|
|
590
|
+
return false;
|
|
591
|
+
}
|
|
592
|
+
returnValue = item.value;
|
|
593
|
+
return true;
|
|
594
|
+
}
|
|
595
|
+
return false;
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
return returnValue;
|
|
599
|
+
}
|
|
600
|
+
atzNumberFromDisclamer(disclaimers, property, defaultValue) {
|
|
601
|
+
let returnValue = defaultValue;
|
|
602
|
+
if (disclaimers && disclaimers.length > 0) {
|
|
603
|
+
disclaimers.find((item) => {
|
|
604
|
+
if (item.property === property) {
|
|
605
|
+
if (item.value === null) {
|
|
606
|
+
return false;
|
|
607
|
+
}
|
|
608
|
+
returnValue = item.value;
|
|
609
|
+
return true;
|
|
610
|
+
}
|
|
611
|
+
return false;
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
return returnValue;
|
|
615
|
+
}
|
|
616
|
+
atzBooleanFromDisclamer(disclaimers, property, defaultValue) {
|
|
617
|
+
const returnValue = defaultValue;
|
|
618
|
+
if (disclaimers && disclaimers.length > 0) {
|
|
619
|
+
const disclaimerFind = disclaimers.find((item) => item.property === property);
|
|
620
|
+
if (disclaimerFind && disclaimerFind.value !== null && disclaimerFind.value !== undefined) {
|
|
621
|
+
if (disclaimerFind.value === 'true') {
|
|
622
|
+
return true;
|
|
623
|
+
}
|
|
624
|
+
else {
|
|
625
|
+
return false;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
return returnValue;
|
|
630
|
+
}
|
|
631
|
+
atzDateFromDisclamer(disclaimers, property, defaultValue) {
|
|
632
|
+
let returnValue = this.ajustDate(defaultValue);
|
|
633
|
+
if (disclaimers && disclaimers.length > 0) {
|
|
634
|
+
disclaimers.find((item) => {
|
|
635
|
+
if (item.property === property) {
|
|
636
|
+
if (item.value === null) {
|
|
637
|
+
return false;
|
|
638
|
+
}
|
|
639
|
+
returnValue = this.ajustDate(item.value);
|
|
640
|
+
return true;
|
|
641
|
+
}
|
|
642
|
+
return false;
|
|
643
|
+
});
|
|
644
|
+
}
|
|
645
|
+
return returnValue;
|
|
646
|
+
}
|
|
647
|
+
atzMultiSelectCharFromDisclamer(disclaimers, property, defaultValue) {
|
|
648
|
+
return this.atzMultiSelectFromDisclamer('char', disclaimers, property, defaultValue);
|
|
649
|
+
}
|
|
650
|
+
atzMultiSelectNumberFromDisclamer(disclaimers, property, defaultValue) {
|
|
651
|
+
return this.atzMultiSelectFromDisclamer('number', disclaimers, property, defaultValue);
|
|
652
|
+
}
|
|
653
|
+
atzMultiSelectFromDisclamer(type, disclaimers, property, defaultValue) {
|
|
654
|
+
let returnValue = [];
|
|
655
|
+
defaultValue.map(item => {
|
|
656
|
+
returnValue.push(item.value);
|
|
657
|
+
});
|
|
658
|
+
if (disclaimers && disclaimers.length > 0) {
|
|
659
|
+
disclaimers.find((item) => {
|
|
660
|
+
if (item.property === property) {
|
|
661
|
+
if (item.value === null || item.value === 'all' || item.value === 'none') {
|
|
662
|
+
return false;
|
|
663
|
+
}
|
|
664
|
+
returnValue = [];
|
|
665
|
+
item.value.split(',').forEach(itemOpt => {
|
|
666
|
+
if (type === 'char') {
|
|
667
|
+
returnValue.push(itemOpt);
|
|
668
|
+
}
|
|
669
|
+
if (type === 'number') {
|
|
670
|
+
returnValue.push(+itemOpt);
|
|
671
|
+
}
|
|
672
|
+
});
|
|
673
|
+
return true;
|
|
674
|
+
}
|
|
675
|
+
return false;
|
|
676
|
+
});
|
|
677
|
+
}
|
|
678
|
+
return returnValue;
|
|
679
|
+
}
|
|
680
|
+
atzCheckboxFromDisclamer(disclaimers, property, options) {
|
|
681
|
+
let returnValue = [];
|
|
682
|
+
options.map(item => {
|
|
683
|
+
returnValue.push(item.value);
|
|
684
|
+
});
|
|
685
|
+
if (disclaimers && disclaimers.length > 0) {
|
|
686
|
+
disclaimers.find((item) => {
|
|
687
|
+
if (item.property === property) {
|
|
688
|
+
if (item.value === null || item.value === 'all' || item.value === 'none') {
|
|
689
|
+
return false;
|
|
690
|
+
}
|
|
691
|
+
returnValue = [];
|
|
692
|
+
item.value.split(',').forEach(itemOpt => {
|
|
693
|
+
returnValue.push(itemOpt);
|
|
694
|
+
});
|
|
695
|
+
return true;
|
|
696
|
+
}
|
|
697
|
+
return false;
|
|
698
|
+
});
|
|
699
|
+
}
|
|
700
|
+
return returnValue;
|
|
701
|
+
}
|
|
702
|
+
atzRangeCharFromDisclamer(disclaimers, property, rangeChar) {
|
|
703
|
+
let value = '';
|
|
704
|
+
if (disclaimers && disclaimers.length > 0) {
|
|
705
|
+
disclaimers.find((item) => {
|
|
706
|
+
if (item.property === property) {
|
|
707
|
+
if (item.value === null) {
|
|
708
|
+
return false;
|
|
709
|
+
}
|
|
710
|
+
value = item.value;
|
|
711
|
+
return true;
|
|
712
|
+
}
|
|
713
|
+
return false;
|
|
714
|
+
});
|
|
715
|
+
}
|
|
716
|
+
return this.atzRangeCharFromQueryParam(value, rangeChar);
|
|
717
|
+
}
|
|
718
|
+
atzRangeNumFromDisclamer(disclaimers, property, rangeNum) {
|
|
719
|
+
let value = '';
|
|
720
|
+
if (disclaimers && disclaimers.length > 0) {
|
|
721
|
+
disclaimers.find((item) => {
|
|
722
|
+
if (item.property === property) {
|
|
723
|
+
if (item.value === null) {
|
|
724
|
+
return false;
|
|
725
|
+
}
|
|
726
|
+
value = item.value;
|
|
727
|
+
return true;
|
|
728
|
+
}
|
|
729
|
+
return false;
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
return this.atzRangeNumFromQueryParam(value, rangeNum);
|
|
733
|
+
}
|
|
734
|
+
atzRangeDateFromDisclamer(disclaimers, property, rangeDate) {
|
|
735
|
+
let value = '';
|
|
736
|
+
if (disclaimers && disclaimers.length > 0) {
|
|
737
|
+
disclaimers.find((item) => {
|
|
738
|
+
if (item.property === property) {
|
|
739
|
+
if (item.value === null) {
|
|
740
|
+
return false;
|
|
741
|
+
}
|
|
742
|
+
value = item.value;
|
|
743
|
+
return true;
|
|
744
|
+
}
|
|
745
|
+
return false;
|
|
746
|
+
});
|
|
747
|
+
}
|
|
748
|
+
return this.atzRangeDateFromQueryParam(value, rangeDate);
|
|
749
|
+
}
|
|
750
|
+
atzRangeCharFromQueryParam(value, rangeChar) {
|
|
751
|
+
rangeChar.valInitial = rangeChar.iniInitial;
|
|
752
|
+
rangeChar.valFinal = rangeChar.iniFinal;
|
|
753
|
+
if (!value || value === '') {
|
|
754
|
+
return rangeChar;
|
|
755
|
+
}
|
|
756
|
+
rangeChar.valInitial = value.split(';')[0];
|
|
757
|
+
rangeChar.valFinal = value.split(';')[1];
|
|
758
|
+
if (rangeChar.valFinal === null || rangeChar.valFinal === undefined) {
|
|
759
|
+
rangeChar.valFinal = rangeChar.iniFinal;
|
|
760
|
+
}
|
|
761
|
+
return rangeChar;
|
|
762
|
+
}
|
|
763
|
+
atzRangeNumFromQueryParam(value, rangeNum) {
|
|
764
|
+
rangeNum.valInitial = rangeNum.iniInitial;
|
|
765
|
+
rangeNum.valFinal = rangeNum.iniFinal;
|
|
766
|
+
if (!value || value === '') {
|
|
767
|
+
return rangeNum;
|
|
768
|
+
}
|
|
769
|
+
rangeNum.valInitial = +value.split(';')[0];
|
|
770
|
+
rangeNum.valFinal = +value.split(';')[1];
|
|
771
|
+
if (rangeNum.valFinal === null || rangeNum.valFinal === undefined) {
|
|
772
|
+
rangeNum.valFinal = rangeNum.iniFinal;
|
|
773
|
+
}
|
|
774
|
+
return rangeNum;
|
|
775
|
+
}
|
|
776
|
+
atzRangeDateFromQueryParam(value, rangeDate) {
|
|
777
|
+
rangeDate.valInitial = rangeDate.iniInitial;
|
|
778
|
+
rangeDate.valFinal = rangeDate.iniFinal;
|
|
779
|
+
if (!value || value === '') {
|
|
780
|
+
return rangeDate;
|
|
781
|
+
}
|
|
782
|
+
rangeDate.valInitial = this.queryParamToDate(value.split(';')[0]);
|
|
783
|
+
rangeDate.valFinal = this.queryParamToDate(value.split(';')[1]);
|
|
784
|
+
if (rangeDate.valFinal === null || rangeDate.valFinal === undefined) {
|
|
785
|
+
rangeDate.valFinal = rangeDate.iniFinal;
|
|
786
|
+
}
|
|
787
|
+
return rangeDate;
|
|
788
|
+
}
|
|
789
|
+
dateToQueryParam(date) {
|
|
790
|
+
const iDay = date.getDate();
|
|
791
|
+
const iMonth = date.getMonth() + 1;
|
|
792
|
+
const iYear = date.getFullYear();
|
|
793
|
+
return `${iYear}-${this.pad(iMonth)}-${this.pad(iDay)}`;
|
|
794
|
+
}
|
|
795
|
+
queryParamToDate(param) {
|
|
796
|
+
const iDay = +param.split('-')[2];
|
|
797
|
+
const iMonth = +param.split('-')[1];
|
|
798
|
+
const iYear = +param.split('-')[0];
|
|
799
|
+
return new Date(iYear, iMonth - 1, iDay);
|
|
800
|
+
}
|
|
801
|
+
isValidDate(date) {
|
|
802
|
+
return date instanceof Date && !isNaN(date.getTime());
|
|
803
|
+
}
|
|
804
|
+
ajustDate(param) {
|
|
805
|
+
if (param instanceof Date) {
|
|
806
|
+
return param;
|
|
807
|
+
}
|
|
808
|
+
if (!param) {
|
|
809
|
+
return param;
|
|
810
|
+
}
|
|
811
|
+
return this.queryParamToDate(param.split('T')[0]);
|
|
812
|
+
}
|
|
813
|
+
pad(number) {
|
|
814
|
+
if (number < 10) {
|
|
815
|
+
return '0' + number;
|
|
816
|
+
}
|
|
817
|
+
return number;
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
/*
|
|
822
|
+
Versão: 1.002
|
|
823
|
+
Data Criação: 19/02/2019
|
|
824
|
+
*/
|
|
825
|
+
class FieldValidationUtil {
|
|
826
|
+
constructor(poNotification, poI18nPipe, literals) {
|
|
827
|
+
this.literals = {};
|
|
828
|
+
this.poNotification = poNotification;
|
|
829
|
+
this.poI18nPipe = poI18nPipe;
|
|
830
|
+
this.literals = literals;
|
|
831
|
+
this.disclaimerUtil = new DisclaimerUtil(this.poNotification, this.poI18nPipe, this.literals);
|
|
832
|
+
}
|
|
833
|
+
vldFieldCharacter(field, value) {
|
|
834
|
+
if (!value || value.trim() === '') {
|
|
835
|
+
this.poNotification.error({
|
|
836
|
+
message: this.poI18nPipe.transform(this.literals['fieldVldRequered'], [this.literals[field]])
|
|
837
|
+
});
|
|
838
|
+
return false;
|
|
839
|
+
}
|
|
840
|
+
return true;
|
|
841
|
+
}
|
|
842
|
+
// Valida uma faixa de caracteres se o inicial é menor que final
|
|
843
|
+
vldRangeCharacter(initialField, finalField, initialValue, finalValue) {
|
|
844
|
+
if (!initialValue || !finalValue) {
|
|
845
|
+
return true;
|
|
846
|
+
}
|
|
847
|
+
if (initialValue.trim().toUpperCase() > finalValue.trim().toUpperCase()) {
|
|
848
|
+
this.poNotification.error({
|
|
849
|
+
message: this.poI18nPipe.transform(this.literals['fieldVldRange'], [this.literals[initialField], this.literals[finalField]])
|
|
850
|
+
});
|
|
851
|
+
return false;
|
|
852
|
+
}
|
|
853
|
+
return true;
|
|
854
|
+
}
|
|
855
|
+
vldFieldNumber(field, value, vldValue = false, zeroAccept = false) {
|
|
856
|
+
if (vldValue && !this.vldValueOfNumber(field, value)) {
|
|
857
|
+
return false;
|
|
858
|
+
}
|
|
859
|
+
if ((!value) || value <= 0) {
|
|
860
|
+
if (value === 0 && zeroAccept === true) {
|
|
861
|
+
return true;
|
|
862
|
+
}
|
|
863
|
+
this.poNotification.error({
|
|
864
|
+
message: this.poI18nPipe.transform(this.literals['fieldVldRequered'], [this.literals[field]])
|
|
865
|
+
});
|
|
866
|
+
return false;
|
|
867
|
+
}
|
|
868
|
+
return true;
|
|
869
|
+
}
|
|
870
|
+
vldValueOfNumber(field, value) {
|
|
871
|
+
if (value && value < 0) {
|
|
872
|
+
this.poNotification.error({ message: this.poI18nPipe.transform(this.literals['fieldVldNumber'], [value.toString(), this.literals[field]]) });
|
|
873
|
+
return false;
|
|
874
|
+
}
|
|
875
|
+
return true;
|
|
876
|
+
}
|
|
877
|
+
vldFieldPercent(field, value, vldValue = false) {
|
|
878
|
+
if (vldValue && !this.vldValueOfPercent(field, value)) {
|
|
879
|
+
return false;
|
|
880
|
+
}
|
|
881
|
+
if (!this.vldFieldNumber(field, value)) {
|
|
882
|
+
return false;
|
|
883
|
+
}
|
|
884
|
+
return true;
|
|
885
|
+
}
|
|
886
|
+
vldValueOfPercent(field, value) {
|
|
887
|
+
if (value && value < 0) {
|
|
888
|
+
this.poNotification.error({ message: this.poI18nPipe.transform(this.literals['fieldVldNumber'], [value.toString(), this.literals[field]]) });
|
|
889
|
+
return false;
|
|
890
|
+
}
|
|
891
|
+
if (value && value > 100) {
|
|
892
|
+
this.poNotification.error({ message: this.poI18nPipe.transform(this.literals['fieldVldNumber'], [value.toString(), this.literals[field]]) });
|
|
893
|
+
return false;
|
|
894
|
+
}
|
|
895
|
+
return true;
|
|
896
|
+
}
|
|
897
|
+
// Valida uma faixa de números se o inicial é menor que final
|
|
898
|
+
vldRangeNumber(initialField, finalField, initialValue, finalValue) {
|
|
899
|
+
if (!initialValue) {
|
|
900
|
+
initialValue = 0;
|
|
901
|
+
}
|
|
902
|
+
if (!finalValue) {
|
|
903
|
+
finalValue = 0;
|
|
904
|
+
}
|
|
905
|
+
if (initialValue > finalValue) {
|
|
906
|
+
this.poNotification.error({
|
|
907
|
+
message: this.poI18nPipe.transform(this.literals['fieldVldRange'], [this.literals[initialField], this.literals[finalField]])
|
|
908
|
+
});
|
|
909
|
+
return false;
|
|
910
|
+
}
|
|
911
|
+
return true;
|
|
912
|
+
}
|
|
913
|
+
vldFieldDate(field, value) {
|
|
914
|
+
const valDate = this.disclaimerUtil.ajustDate(value);
|
|
915
|
+
if (!this.disclaimerUtil.isValidDate(valDate)) {
|
|
916
|
+
this.poNotification.error({
|
|
917
|
+
message: this.poI18nPipe.transform(this.literals['fieldVldDate'], [this.literals[field]])
|
|
918
|
+
});
|
|
919
|
+
return false;
|
|
920
|
+
}
|
|
921
|
+
return true;
|
|
922
|
+
}
|
|
923
|
+
// Valida uma faixa de datas se o inicial é menor que final
|
|
924
|
+
vldRangeDate(initialField, finalField, initialValue, finalValue) {
|
|
925
|
+
if (!initialValue || !finalValue) {
|
|
926
|
+
return true;
|
|
927
|
+
}
|
|
928
|
+
const valInitialDate = this.disclaimerUtil.ajustDate(initialValue).getTime();
|
|
929
|
+
const valFinalDate = this.disclaimerUtil.ajustDate(finalValue).getTime();
|
|
930
|
+
if (valInitialDate > valFinalDate) {
|
|
931
|
+
this.poNotification.error({
|
|
932
|
+
message: this.poI18nPipe.transform(this.literals['fieldVldRange'], [this.literals[initialField], this.literals[finalField]])
|
|
933
|
+
});
|
|
934
|
+
return false;
|
|
935
|
+
}
|
|
936
|
+
return true;
|
|
937
|
+
}
|
|
938
|
+
vldFieldMultiSelect(field, value) {
|
|
939
|
+
if (!value || value.length === 0) {
|
|
940
|
+
this.poNotification.error({
|
|
941
|
+
message: this.poI18nPipe.transform(this.literals['fieldVldSelected'], [this.literals[field]])
|
|
942
|
+
});
|
|
943
|
+
return false;
|
|
944
|
+
}
|
|
945
|
+
return true;
|
|
946
|
+
}
|
|
947
|
+
vldFieldCheckbox(field, value) {
|
|
948
|
+
if (!value || value.length === 0) {
|
|
949
|
+
this.poNotification.error({
|
|
950
|
+
message: this.poI18nPipe.transform(this.literals['fieldVldSelected'], [this.literals[field]])
|
|
951
|
+
});
|
|
952
|
+
return false;
|
|
953
|
+
}
|
|
954
|
+
return true;
|
|
955
|
+
}
|
|
956
|
+
// Valida formato conforme regra: "9" apenas números, "X" qualquer caracter, "!" apenas letras maiúsculas
|
|
957
|
+
vldFieldFormat(field, value, format, replacePoint = false) {
|
|
958
|
+
let lOK = true;
|
|
959
|
+
let oldFormat;
|
|
960
|
+
if (!value) {
|
|
961
|
+
return lOK;
|
|
962
|
+
}
|
|
963
|
+
/*Retira os pontos do formato*/
|
|
964
|
+
if (replacePoint) {
|
|
965
|
+
oldFormat = format;
|
|
966
|
+
format = format.replace(/\./g, '');
|
|
967
|
+
}
|
|
968
|
+
if (value.length !== format.length) {
|
|
969
|
+
lOK = false;
|
|
970
|
+
}
|
|
971
|
+
else {
|
|
972
|
+
for (let idx = 0; idx < format.length; idx++) {
|
|
973
|
+
if (format[idx] === '9') {
|
|
974
|
+
if (value[idx].replace(/[0-9]/, '9') !== '9') {
|
|
975
|
+
lOK = false;
|
|
976
|
+
break;
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
if (format[idx] === '!') {
|
|
980
|
+
if (value[idx].replace(/[A-Z]/, 'A') !== 'A') {
|
|
981
|
+
lOK = false;
|
|
982
|
+
break;
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
if (replacePoint) {
|
|
988
|
+
format = oldFormat;
|
|
989
|
+
}
|
|
990
|
+
if (!lOK) {
|
|
991
|
+
this.poNotification.error({
|
|
992
|
+
message: this.poI18nPipe.transform(this.literals['fieldVldFormat'], [this.literals[field], format])
|
|
993
|
+
});
|
|
994
|
+
}
|
|
995
|
+
return lOK;
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
/*
|
|
1000
|
+
Versão: 1.000
|
|
1001
|
+
Data Criação: 06/08/2018
|
|
1002
|
+
*/
|
|
1003
|
+
class FilterRangeUtil {
|
|
1004
|
+
constructor() {
|
|
1005
|
+
}
|
|
1006
|
+
static makeFilterRangeCharacter(iniInitial, iniFinal) {
|
|
1007
|
+
return {
|
|
1008
|
+
iniInitial,
|
|
1009
|
+
iniFinal,
|
|
1010
|
+
valInitial: iniInitial,
|
|
1011
|
+
valFinal: iniFinal
|
|
1012
|
+
};
|
|
1013
|
+
}
|
|
1014
|
+
static makeFilterRangeNumber(iniInitial, iniFinal) {
|
|
1015
|
+
return {
|
|
1016
|
+
iniInitial,
|
|
1017
|
+
iniFinal,
|
|
1018
|
+
valInitial: iniInitial,
|
|
1019
|
+
valFinal: iniFinal
|
|
1020
|
+
};
|
|
1021
|
+
}
|
|
1022
|
+
static makeFilterRangeDate(iniInitial, iniFinal) {
|
|
1023
|
+
return {
|
|
1024
|
+
iniInitial,
|
|
1025
|
+
iniFinal,
|
|
1026
|
+
valInitial: iniInitial,
|
|
1027
|
+
valFinal: iniFinal
|
|
1028
|
+
};
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
/*
|
|
1033
|
+
Versão: 1.003
|
|
1034
|
+
Data Criação: 18/04/2019
|
|
1035
|
+
*/
|
|
1036
|
+
class GenericFunctionsUtils {
|
|
1037
|
+
constructor(literals) {
|
|
1038
|
+
this.literals = {};
|
|
1039
|
+
this.literals = literals;
|
|
1040
|
+
}
|
|
1041
|
+
/* Transforma uma Lista separada por "," em um Array */
|
|
1042
|
+
static listToArrayCharacter(list) {
|
|
1043
|
+
let returnArray = new Array();
|
|
1044
|
+
if (list && list !== '') {
|
|
1045
|
+
returnArray = list.split(',');
|
|
1046
|
+
}
|
|
1047
|
+
return returnArray;
|
|
1048
|
+
}
|
|
1049
|
+
/* Transforma um Array em uma Lista separada por "," */
|
|
1050
|
+
static ArrayToListCharacter(array) {
|
|
1051
|
+
let list = '';
|
|
1052
|
+
if (array && array.length > 0) {
|
|
1053
|
+
list = array.join(',');
|
|
1054
|
+
}
|
|
1055
|
+
return list;
|
|
1056
|
+
}
|
|
1057
|
+
static isEmpty(object) {
|
|
1058
|
+
let isEmpty = true;
|
|
1059
|
+
for (const content in object) {
|
|
1060
|
+
if (object.hasOwnProperty(content)) {
|
|
1061
|
+
isEmpty = false;
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
return isEmpty;
|
|
1065
|
+
}
|
|
1066
|
+
static getChartValues(chartData) {
|
|
1067
|
+
let chartValues;
|
|
1068
|
+
let maxValue, minValue;
|
|
1069
|
+
maxValue = undefined;
|
|
1070
|
+
minValue = undefined;
|
|
1071
|
+
chartData.map(item => {
|
|
1072
|
+
if (maxValue === undefined && minValue === undefined) {
|
|
1073
|
+
maxValue = item.data[0];
|
|
1074
|
+
minValue = item.data[0];
|
|
1075
|
+
}
|
|
1076
|
+
else {
|
|
1077
|
+
if (item.data < minValue) {
|
|
1078
|
+
minValue = item.data[0];
|
|
1079
|
+
}
|
|
1080
|
+
if (item.data > maxValue) {
|
|
1081
|
+
maxValue = item.data[0];
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
});
|
|
1085
|
+
if (maxValue > 0 && minValue > 0) {
|
|
1086
|
+
chartValues = { maxValue: maxValue, minValue: 0 };
|
|
1087
|
+
}
|
|
1088
|
+
if (maxValue > 0 && minValue < 0) {
|
|
1089
|
+
chartValues = { maxValue: maxValue, minValue: minValue };
|
|
1090
|
+
}
|
|
1091
|
+
if (maxValue < 0 && minValue < 0) {
|
|
1092
|
+
const max = (minValue / 3) * (-1);
|
|
1093
|
+
chartValues = { maxValue: max, minValue: minValue };
|
|
1094
|
+
}
|
|
1095
|
+
if (maxValue > 0 && minValue === 0) {
|
|
1096
|
+
chartValues = { maxValue: maxValue, minValue: 0 };
|
|
1097
|
+
}
|
|
1098
|
+
if (maxValue === 0 && minValue < 0) {
|
|
1099
|
+
const max = (minValue / 3) * (-1);
|
|
1100
|
+
chartValues = { maxValue: max, minValue: minValue };
|
|
1101
|
+
}
|
|
1102
|
+
if (maxValue === 0 && minValue === 0) {
|
|
1103
|
+
chartValues = { maxValue: undefined, minValue: undefined };
|
|
1104
|
+
}
|
|
1105
|
+
chartValues.maxValue = Math.round(chartValues.maxValue);
|
|
1106
|
+
chartValues.minValue = Math.round(chartValues.minValue);
|
|
1107
|
+
return chartValues;
|
|
1108
|
+
}
|
|
1109
|
+
/*Deixa no list apenas o itens que existem no options*/
|
|
1110
|
+
static atzMultiSelectListByOptions(options, list) {
|
|
1111
|
+
let idx;
|
|
1112
|
+
let newList;
|
|
1113
|
+
if (!list) {
|
|
1114
|
+
return list;
|
|
1115
|
+
}
|
|
1116
|
+
newList = new Array();
|
|
1117
|
+
list.map(item => {
|
|
1118
|
+
if (item) {
|
|
1119
|
+
idx = options.findIndex(itemOptions => itemOptions.value === item);
|
|
1120
|
+
if (idx >= 0) {
|
|
1121
|
+
newList.push(item);
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
});
|
|
1125
|
+
return newList;
|
|
1126
|
+
}
|
|
1127
|
+
/*Carrega o Options com os valores defaults passados como parâmetro (list)*/
|
|
1128
|
+
loadOptionsMultiSelect(options, list) {
|
|
1129
|
+
let idx;
|
|
1130
|
+
if (!list) {
|
|
1131
|
+
return;
|
|
1132
|
+
}
|
|
1133
|
+
list.map(item => {
|
|
1134
|
+
if (item) {
|
|
1135
|
+
idx = options.findIndex(itemOptions => itemOptions.value === item);
|
|
1136
|
+
if (idx === -1) {
|
|
1137
|
+
options.push({ label: item === 'all' ? this.literals['all'] : item, value: item });
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
});
|
|
1141
|
+
}
|
|
1142
|
+
/*Carrega o Options com os valores defaults passados como parâmetro (list)*/
|
|
1143
|
+
loadOptionsSelect(options, selectValue, tradValue = false) {
|
|
1144
|
+
let idx;
|
|
1145
|
+
if (!selectValue) {
|
|
1146
|
+
return;
|
|
1147
|
+
}
|
|
1148
|
+
if (selectValue) {
|
|
1149
|
+
idx = options.findIndex(itemOptions => itemOptions.value === selectValue);
|
|
1150
|
+
if (idx === -1) {
|
|
1151
|
+
options.push({ label: tradValue ? this.literals[selectValue] : selectValue, value: selectValue });
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
/*Método que compara 2 objetos e retorna se são iguais ou diferentes*/
|
|
1156
|
+
compareObjects(firstObject, secondObject) {
|
|
1157
|
+
if (!firstObject || !secondObject) {
|
|
1158
|
+
return false;
|
|
1159
|
+
}
|
|
1160
|
+
/*Pega a lista de nomes dos campos do objetos e compara*/
|
|
1161
|
+
if (Object.getOwnPropertyNames(firstObject).length !== Object.getOwnPropertyNames(secondObject).length) {
|
|
1162
|
+
return false;
|
|
1163
|
+
}
|
|
1164
|
+
for (const content in firstObject) {
|
|
1165
|
+
if (content.substr(0, 1) === '$' || content.substr(0, 1) === '_') {
|
|
1166
|
+
continue;
|
|
1167
|
+
}
|
|
1168
|
+
if (firstObject[content] !== secondObject[content]) {
|
|
1169
|
+
return false;
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
return true;
|
|
1173
|
+
}
|
|
1174
|
+
referenceGeneration(charInd, dateRef) {
|
|
1175
|
+
let reference;
|
|
1176
|
+
let random;
|
|
1177
|
+
const iDay = dateRef.getDate();
|
|
1178
|
+
const iMonth = dateRef.getMonth() + 1;
|
|
1179
|
+
const iYear = dateRef.getFullYear();
|
|
1180
|
+
reference = `${this.pad(iYear)}${this.pad(iMonth)}${this.pad(iDay)}${charInd}`;
|
|
1181
|
+
random = btoa(`${(new Date()).getTime()}`);
|
|
1182
|
+
random = random.replace(/[=]/g, '');
|
|
1183
|
+
random = random.slice(random.length - 3, random.length);
|
|
1184
|
+
return `${reference}${random}`;
|
|
1185
|
+
}
|
|
1186
|
+
pad(number) {
|
|
1187
|
+
if (number < 10) {
|
|
1188
|
+
return '0' + number;
|
|
1189
|
+
}
|
|
1190
|
+
if (number > 99) {
|
|
1191
|
+
return (number + '').slice(2, 4);
|
|
1192
|
+
}
|
|
1193
|
+
return number;
|
|
1194
|
+
}
|
|
1195
|
+
focusInternalInput(idField) {
|
|
1196
|
+
const fieldComponent = document.getElementById(idField);
|
|
1197
|
+
const fieldInput = fieldComponent.getElementsByClassName('po-input')[0];
|
|
1198
|
+
fieldInput.focus();
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
class FileUtil {
|
|
1203
|
+
constructor() { }
|
|
1204
|
+
static downloadFile(data, fileName, contentType, base64) {
|
|
1205
|
+
base64 = (base64 === false) ? false : true;
|
|
1206
|
+
const dataBlob = base64 ? this.b64toBlob(data, contentType) : data;
|
|
1207
|
+
this.download(dataBlob, fileName);
|
|
1208
|
+
}
|
|
1209
|
+
static downloadData(data, dwldDataParam = null) {
|
|
1210
|
+
if (!data) {
|
|
1211
|
+
return;
|
|
1212
|
+
}
|
|
1213
|
+
if (!dwldDataParam) {
|
|
1214
|
+
dwldDataParam = new DownloadDataParams();
|
|
1215
|
+
}
|
|
1216
|
+
if (!dwldDataParam.fileName) {
|
|
1217
|
+
dwldDataParam.fileName = 'data.csv';
|
|
1218
|
+
}
|
|
1219
|
+
if (!dwldDataParam.literals) {
|
|
1220
|
+
dwldDataParam.literals = {};
|
|
1221
|
+
}
|
|
1222
|
+
if (!dwldDataParam.columnDelimiter) {
|
|
1223
|
+
dwldDataParam.columnDelimiter = ';';
|
|
1224
|
+
}
|
|
1225
|
+
if (!dwldDataParam.columnList) {
|
|
1226
|
+
dwldDataParam.columnList = [];
|
|
1227
|
+
}
|
|
1228
|
+
if (!dwldDataParam.columnExclude) {
|
|
1229
|
+
dwldDataParam.columnExclude = [];
|
|
1230
|
+
}
|
|
1231
|
+
const datab64 = btoa(this.jsonToString(data, dwldDataParam));
|
|
1232
|
+
this.downloadFile(datab64, dwldDataParam.fileName, 'text/csv');
|
|
1233
|
+
}
|
|
1234
|
+
static download(file, fileName) {
|
|
1235
|
+
const binaryData = [file];
|
|
1236
|
+
const downloadLink = document.createElement('a');
|
|
1237
|
+
const urlDownload = window.URL.createObjectURL(new Blob(binaryData, { type: file.type }));
|
|
1238
|
+
downloadLink.href = urlDownload;
|
|
1239
|
+
downloadLink.setAttribute('download', fileName);
|
|
1240
|
+
document.body.appendChild(downloadLink);
|
|
1241
|
+
downloadLink.click();
|
|
1242
|
+
window.URL.revokeObjectURL(urlDownload);
|
|
1243
|
+
downloadLink.remove();
|
|
1244
|
+
}
|
|
1245
|
+
static b64toBlob(b64Data, contentType, sliceSize) {
|
|
1246
|
+
contentType = contentType || '';
|
|
1247
|
+
sliceSize = sliceSize || 512;
|
|
1248
|
+
const byteCharacters = atob(b64Data);
|
|
1249
|
+
const byteArrays = [];
|
|
1250
|
+
for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) {
|
|
1251
|
+
const slice = byteCharacters.slice(offset, offset + sliceSize);
|
|
1252
|
+
const byteNumbers = new Array(slice.length);
|
|
1253
|
+
for (let i = 0; i < slice.length; i++) {
|
|
1254
|
+
byteNumbers[i] = slice.charCodeAt(i);
|
|
1255
|
+
}
|
|
1256
|
+
const byteArray = new Uint8Array(byteNumbers);
|
|
1257
|
+
byteArrays.push(byteArray);
|
|
1258
|
+
}
|
|
1259
|
+
const blob = new Blob(byteArrays, { type: contentType });
|
|
1260
|
+
return blob;
|
|
1261
|
+
}
|
|
1262
|
+
static jsonToString(jsonData, dwldDataParam) {
|
|
1263
|
+
if (!jsonData || jsonData.length === 0) {
|
|
1264
|
+
return '';
|
|
1265
|
+
}
|
|
1266
|
+
const lineDelimiter = '\n';
|
|
1267
|
+
let columnOrig = null;
|
|
1268
|
+
let columnHeader = null;
|
|
1269
|
+
const keys = [];
|
|
1270
|
+
let includeKey;
|
|
1271
|
+
if (dwldDataParam.columnList &&
|
|
1272
|
+
dwldDataParam.columnList.length > 0) {
|
|
1273
|
+
columnOrig = dwldDataParam.columnList;
|
|
1274
|
+
}
|
|
1275
|
+
else {
|
|
1276
|
+
columnOrig = Object.keys(jsonData[0]);
|
|
1277
|
+
}
|
|
1278
|
+
columnOrig.forEach(key => {
|
|
1279
|
+
includeKey = true;
|
|
1280
|
+
if (dwldDataParam.columnExclude &&
|
|
1281
|
+
dwldDataParam.columnExclude.length > 0 &&
|
|
1282
|
+
dwldDataParam.columnExclude.indexOf(key) !== -1) {
|
|
1283
|
+
includeKey = false;
|
|
1284
|
+
}
|
|
1285
|
+
if (includeKey) {
|
|
1286
|
+
keys.push(key);
|
|
1287
|
+
columnHeader = (!columnHeader) ? '' : columnHeader + dwldDataParam.columnDelimiter;
|
|
1288
|
+
columnHeader += (dwldDataParam.literals[key]) ? dwldDataParam.literals[key] : key;
|
|
1289
|
+
}
|
|
1290
|
+
});
|
|
1291
|
+
const lineStr = jsonData.reduce((accLineStr, currentItem) => {
|
|
1292
|
+
let first = true;
|
|
1293
|
+
let columnValue = null;
|
|
1294
|
+
keys.forEach(key => {
|
|
1295
|
+
if (!first) {
|
|
1296
|
+
accLineStr += dwldDataParam.columnDelimiter;
|
|
1297
|
+
}
|
|
1298
|
+
columnValue = currentItem[key];
|
|
1299
|
+
if (columnValue === null || columnValue === undefined) {
|
|
1300
|
+
columnValue = '';
|
|
1301
|
+
}
|
|
1302
|
+
switch (typeof (columnValue)) {
|
|
1303
|
+
case 'number':
|
|
1304
|
+
columnValue = columnValue.toLocaleString();
|
|
1305
|
+
break;
|
|
1306
|
+
case 'boolean':
|
|
1307
|
+
columnValue = (dwldDataParam.literals[`${columnValue}`]) ?
|
|
1308
|
+
dwldDataParam.literals[`${columnValue}`] : columnValue;
|
|
1309
|
+
break;
|
|
1310
|
+
case 'object':
|
|
1311
|
+
columnValue = JSON.stringify(columnValue);
|
|
1312
|
+
}
|
|
1313
|
+
accLineStr += columnValue;
|
|
1314
|
+
first = false;
|
|
1315
|
+
});
|
|
1316
|
+
return accLineStr + lineDelimiter;
|
|
1317
|
+
}, columnHeader + lineDelimiter);
|
|
1318
|
+
return lineStr;
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
class DownloadDataParams {
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
class ScheduleParameters {
|
|
1325
|
+
}
|
|
1326
|
+
class ExecutionStatus {
|
|
1327
|
+
}
|
|
1328
|
+
class ExecutionParameters {
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
class TotvsScheduleExecutionService {
|
|
1332
|
+
constructor(http) {
|
|
1333
|
+
this.http = http;
|
|
1334
|
+
this.headers = { headers: { 'X-PO-Screen-Lock': 'true' } };
|
|
1335
|
+
this.urlCadServidor = '/dts/datasul-rest/resources/prg/btb/v1/servidoresExecucao';
|
|
1336
|
+
this.urlJobScheduler = '/dts/datasul-rest/resources/prg/framework/v1/jobScheduler';
|
|
1337
|
+
this.urlJobExecution = '/dts/datasul-rest/resources/prg/framework/v1/jobExecution';
|
|
1338
|
+
}
|
|
1339
|
+
getFilteredItems(params) {
|
|
1340
|
+
const urlParams = new Array();
|
|
1341
|
+
urlParams.push(`pageSize=${params.pageSize.toString()}`);
|
|
1342
|
+
urlParams.push(`page=${params.page.toString()}`);
|
|
1343
|
+
if (params.filter && params.filter.length > 0) {
|
|
1344
|
+
urlParams.push(`quickSearch=${params.filter}`);
|
|
1345
|
+
}
|
|
1346
|
+
return this.http.get(`${this.urlCadServidor}?${urlParams.join('&')}`);
|
|
1347
|
+
}
|
|
1348
|
+
getObjectByValue(id) {
|
|
1349
|
+
return this.http.get(`${this.urlCadServidor}/${id}`, this.headers);
|
|
1350
|
+
}
|
|
1351
|
+
createExecution(parameters, loading) {
|
|
1352
|
+
const params = JSON.parse(JSON.stringify(parameters).replace(/\\\\/g, '*|'));
|
|
1353
|
+
if (loading) {
|
|
1354
|
+
return this.http.post(`${this.urlJobScheduler}`, params, this.headers);
|
|
1355
|
+
}
|
|
1356
|
+
else {
|
|
1357
|
+
return this.http.post(`${this.urlJobScheduler}`, params);
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
createExecutionForNow(executionParams, loading) {
|
|
1361
|
+
let jobScheduleParams;
|
|
1362
|
+
const date = new Date();
|
|
1363
|
+
const params = JSON.parse(JSON.stringify(executionParams).replace(/\\\\/g, '*|'));
|
|
1364
|
+
if (!params.businessParams || params.businessParams.length === 0) {
|
|
1365
|
+
params.businessParams = [{ chave: '', valor: '' }];
|
|
1366
|
+
}
|
|
1367
|
+
jobScheduleParams = {};
|
|
1368
|
+
jobScheduleParams.status = 'active';
|
|
1369
|
+
jobScheduleParams.processID = params.programName;
|
|
1370
|
+
jobScheduleParams.firstExecution = `${date.getFullYear()}-${(date.getMonth() + 1)}-${date.getDate()}T${this.addZero(date.getHours())}:${this.addZero(date.getMinutes())}:00.000Z`;
|
|
1371
|
+
jobScheduleParams.recurrent = false;
|
|
1372
|
+
jobScheduleParams.executionParameter = {
|
|
1373
|
+
parametros: [
|
|
1374
|
+
{ chave: 'rpwServer', valor: params.executionServer },
|
|
1375
|
+
{ chave: 'RPW_PROGRAM', valor: params.externalName },
|
|
1376
|
+
{ chave: 'RPW_PRG_EMS5', valor: params.programEMS5 ? 'yes' : 'no' },
|
|
1377
|
+
{ chave: 'RPW_PRG_VERS', valor: params.programVersion },
|
|
1378
|
+
{ parametros_negocio: params.businessParams }
|
|
1379
|
+
]
|
|
1380
|
+
};
|
|
1381
|
+
if (loading) {
|
|
1382
|
+
return this.http.post(`${this.urlJobScheduler}`, jobScheduleParams, this.headers);
|
|
1383
|
+
}
|
|
1384
|
+
else {
|
|
1385
|
+
return this.http.post(`${this.urlJobScheduler}`, jobScheduleParams);
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
getExecutionByJobScheduleID(jobScheduleID, loading = false) {
|
|
1389
|
+
const url = `${this.urlJobExecution}?jobScheduleID=${jobScheduleID}`;
|
|
1390
|
+
return this.getExecution(url, loading).pipe(map((response) => this.transformExecution('jobScheduleID', response)));
|
|
1391
|
+
}
|
|
1392
|
+
getExecutionByExecutionID(executionID, loading = false) {
|
|
1393
|
+
const url = `${this.urlJobExecution}/${executionID}`;
|
|
1394
|
+
return this.getExecution(url, loading).pipe(map((response) => this.transformExecution('executionID', response)));
|
|
1395
|
+
}
|
|
1396
|
+
getExecution(url, loading) {
|
|
1397
|
+
if (loading) {
|
|
1398
|
+
return this.http.get(url, this.headers);
|
|
1399
|
+
}
|
|
1400
|
+
else {
|
|
1401
|
+
return this.http.get(url);
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
transformExecution(type, response) {
|
|
1405
|
+
if (!response || !response.items || response.items.length === 0) {
|
|
1406
|
+
return;
|
|
1407
|
+
}
|
|
1408
|
+
response = response.items[0];
|
|
1409
|
+
const execStatus = new ExecutionStatus();
|
|
1410
|
+
execStatus.jobScheduleID = response.jobScheduleID;
|
|
1411
|
+
execStatus.executionID = response.executionID;
|
|
1412
|
+
execStatus.startedDate = response.startedDate;
|
|
1413
|
+
execStatus.error = response.error;
|
|
1414
|
+
execStatus.status = response.status;
|
|
1415
|
+
return execStatus;
|
|
1416
|
+
}
|
|
1417
|
+
followUpExcByJobScheduleID(jobScheduleID, intervalNum, fncCallBack, loading = false) {
|
|
1418
|
+
this.followUpExecution('jobScheduleID', jobScheduleID, intervalNum, fncCallBack, loading);
|
|
1419
|
+
}
|
|
1420
|
+
followUpExcByExecutionID(executionID, intervalNum, fncCallBack, loading = false) {
|
|
1421
|
+
this.followUpExecution('executionID', executionID, intervalNum, fncCallBack, loading);
|
|
1422
|
+
}
|
|
1423
|
+
followUpExecution(type, execID, intervalNum, fncCallBack, loading) {
|
|
1424
|
+
this.jobExecutionSubscription$ = null;
|
|
1425
|
+
const intervalID = setInterval(() => {
|
|
1426
|
+
const execStatus = new ExecutionStatus();
|
|
1427
|
+
execStatus.jobScheduleID = (type === 'jobScheduleID') ? execID : '';
|
|
1428
|
+
execStatus.executionID = (type === 'executionID') ? execID : '';
|
|
1429
|
+
execStatus.startedDate = null;
|
|
1430
|
+
execStatus.error = '';
|
|
1431
|
+
execStatus.status = 'PENDING'; // PENDING, RUNNING, SUCCESS, FAILURE
|
|
1432
|
+
if (this.jobExecutionSubscription$) {
|
|
1433
|
+
return;
|
|
1434
|
+
}
|
|
1435
|
+
if (type === 'jobScheduleID') {
|
|
1436
|
+
this.jobExecutionSubscription$ = this.getExecutionByJobScheduleID(execID, loading)
|
|
1437
|
+
.subscribe((response) => {
|
|
1438
|
+
this.followUpExecReturnOk(execID, execStatus, response, intervalID, fncCallBack);
|
|
1439
|
+
}, (error) => {
|
|
1440
|
+
this.followUpExecReturnError(error, execStatus, intervalID, fncCallBack);
|
|
1441
|
+
});
|
|
1442
|
+
}
|
|
1443
|
+
if (type === 'executionID') {
|
|
1444
|
+
this.jobExecutionSubscription$ = this.getExecutionByExecutionID(execID, loading)
|
|
1445
|
+
.subscribe((response) => {
|
|
1446
|
+
this.followUpExecReturnOk(execID, execStatus, response, intervalID, fncCallBack);
|
|
1447
|
+
}, (error) => {
|
|
1448
|
+
this.followUpExecReturnError(error, execStatus, intervalID, fncCallBack);
|
|
1449
|
+
});
|
|
1450
|
+
}
|
|
1451
|
+
}, intervalNum);
|
|
1452
|
+
}
|
|
1453
|
+
followUpExecReturnOk(execID, execStatus, response, intervalID, fncCallBack) {
|
|
1454
|
+
if (response) {
|
|
1455
|
+
execStatus = response;
|
|
1456
|
+
}
|
|
1457
|
+
else {
|
|
1458
|
+
execStatus.error = `Agendamento não encontrado com ID: ${execID}`;
|
|
1459
|
+
execStatus.status = 'FAILURE';
|
|
1460
|
+
}
|
|
1461
|
+
if (!fncCallBack(execStatus) ||
|
|
1462
|
+
execStatus.status === 'SUCCESS' ||
|
|
1463
|
+
execStatus.status === 'FAILURE') {
|
|
1464
|
+
clearInterval(intervalID);
|
|
1465
|
+
}
|
|
1466
|
+
this.jobExecutionSubscription$ = null;
|
|
1467
|
+
}
|
|
1468
|
+
followUpExecReturnError(error, execStatus, intervalID, fncCallBack) {
|
|
1469
|
+
let erroDesc = '';
|
|
1470
|
+
if (error instanceof HttpErrorResponse) {
|
|
1471
|
+
erroDesc = error.message;
|
|
1472
|
+
if (error.error) {
|
|
1473
|
+
erroDesc = '';
|
|
1474
|
+
if (error.error.code) {
|
|
1475
|
+
erroDesc = error.error.code;
|
|
1476
|
+
}
|
|
1477
|
+
if (error.error.message) {
|
|
1478
|
+
erroDesc = `${erroDesc} - ${error.error.message}`;
|
|
1479
|
+
}
|
|
1480
|
+
if (error.error.detailedMessage) {
|
|
1481
|
+
erroDesc = `${erroDesc} - ${error.error.detailedMessage}`;
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
else {
|
|
1486
|
+
erroDesc = error;
|
|
1487
|
+
}
|
|
1488
|
+
execStatus.error = erroDesc;
|
|
1489
|
+
execStatus.status = 'FAILURE';
|
|
1490
|
+
fncCallBack(execStatus);
|
|
1491
|
+
clearInterval(intervalID);
|
|
1492
|
+
this.jobExecutionSubscription$ = null;
|
|
1493
|
+
}
|
|
1494
|
+
addZero(num) {
|
|
1495
|
+
let str = `${num}`;
|
|
1496
|
+
if (num < 10) {
|
|
1497
|
+
str = `0${num}`;
|
|
1498
|
+
}
|
|
1499
|
+
return str;
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
/** @nocollapse */ TotvsScheduleExecutionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: TotvsScheduleExecutionService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1503
|
+
/** @nocollapse */ TotvsScheduleExecutionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: TotvsScheduleExecutionService });
|
|
1504
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: TotvsScheduleExecutionService, decorators: [{
|
|
1505
|
+
type: Injectable
|
|
1506
|
+
}], ctorParameters: function () { return [{ type: i1.HttpClient }]; } });
|
|
1507
|
+
|
|
1508
|
+
class TotvsScheduleExecutionComponent {
|
|
1509
|
+
constructor(poI18nService, rpwService, poNotification) {
|
|
1510
|
+
this.poI18nService = poI18nService;
|
|
1511
|
+
this.rpwService = rpwService;
|
|
1512
|
+
this.poNotification = poNotification;
|
|
1513
|
+
this.programEMS5 = false;
|
|
1514
|
+
this.programVersion = '';
|
|
1515
|
+
this.disabledParams = false;
|
|
1516
|
+
this.loading = false;
|
|
1517
|
+
this.endExecution = new EventEmitter();
|
|
1518
|
+
this.jsonObject = {};
|
|
1519
|
+
this.literals = {};
|
|
1520
|
+
}
|
|
1521
|
+
ngOnInit() {
|
|
1522
|
+
/* VERIFICAR COMO FICARÁ A TRADUÇÃO
|
|
1523
|
+
forkJoin(
|
|
1524
|
+
this.poI18nService.getLiterals(),
|
|
1525
|
+
this.poI18nService.getLiterals({ context: 'generalRpw' })
|
|
1526
|
+
).subscribe(literals => {
|
|
1527
|
+
literals.map(item => Object.assign(this.literals, item) );
|
|
1528
|
+
this.setupComponents();
|
|
1529
|
+
});*/
|
|
1530
|
+
this.setupComponents();
|
|
1531
|
+
}
|
|
1532
|
+
setupComponents() {
|
|
1533
|
+
this.executionTypeOptions = [
|
|
1534
|
+
{ label: 'Executar Hoje', value: 1 },
|
|
1535
|
+
{ label: 'Agendar Execução', value: 2 }
|
|
1536
|
+
];
|
|
1537
|
+
this.frequencyOptions = [
|
|
1538
|
+
{ label: 'Uma vez no dia', value: 'no' },
|
|
1539
|
+
{ label: 'Várias vezes no dia', value: 'yes' }
|
|
1540
|
+
];
|
|
1541
|
+
this.frequencyTypeOptions = [
|
|
1542
|
+
{ label: 'Hora(s)', value: 'hour' },
|
|
1543
|
+
{ label: 'Minuto(s)', value: 'minute' }
|
|
1544
|
+
];
|
|
1545
|
+
this.weeklyOptions = [
|
|
1546
|
+
{ label: 'Domingo', value: 'Sunday' },
|
|
1547
|
+
{ label: 'Segunda', value: 'Monday' },
|
|
1548
|
+
{ label: 'Terça', value: 'Tuesday' },
|
|
1549
|
+
{ label: 'Quarta', value: 'Wednesday' },
|
|
1550
|
+
{ label: 'Quinta', value: 'Thursday' },
|
|
1551
|
+
{ label: 'Sexta', value: 'Friday' },
|
|
1552
|
+
{ label: 'Sábado', value: 'Saturday' }
|
|
1553
|
+
];
|
|
1554
|
+
this.zoomRpwServiceColumns = [
|
|
1555
|
+
{ property: 'code', label: 'Servidor', type: 'string', width: '20%' },
|
|
1556
|
+
{ property: 'name', label: 'Descrição', type: 'string', width: '80%' }
|
|
1557
|
+
];
|
|
1558
|
+
this.model = new ScheduleParameters();
|
|
1559
|
+
this.model.executionType = 1;
|
|
1560
|
+
this.model.repeatType = 1;
|
|
1561
|
+
this.model.repeatExecution = false;
|
|
1562
|
+
}
|
|
1563
|
+
setScheduleParameters(schParam) {
|
|
1564
|
+
if (!schParam) {
|
|
1565
|
+
return;
|
|
1566
|
+
}
|
|
1567
|
+
this.model = schParam;
|
|
1568
|
+
}
|
|
1569
|
+
fieldRpwServiceFormat(value) {
|
|
1570
|
+
return `${value.code} - ${value.name}`;
|
|
1571
|
+
}
|
|
1572
|
+
isExecutionSchedule() {
|
|
1573
|
+
return (this.model.executionType === 2);
|
|
1574
|
+
}
|
|
1575
|
+
isRepeatExecution() {
|
|
1576
|
+
return this.model.repeatExecution;
|
|
1577
|
+
}
|
|
1578
|
+
isFrenquency() {
|
|
1579
|
+
return (this.model.frequency === 'yes');
|
|
1580
|
+
}
|
|
1581
|
+
changeRepeatExecution() {
|
|
1582
|
+
const date = new Date();
|
|
1583
|
+
if (!this.model.execAppointHourInit) {
|
|
1584
|
+
this.model.execAppointHourInit = `${this.addZero(date.getHours())}:${this.addZero(date.getMinutes())}`;
|
|
1585
|
+
}
|
|
1586
|
+
if (!this.model.execAppointHourFinal) {
|
|
1587
|
+
this.model.execAppointHourFinal = `${this.addZero(date.getHours())}:${this.addZero(date.getMinutes())}`;
|
|
1588
|
+
}
|
|
1589
|
+
this.model.selectWeeklys = [];
|
|
1590
|
+
this.model.dayOfMonth = 0;
|
|
1591
|
+
this.model.frequency = 'no';
|
|
1592
|
+
this.model.frequencyType = 'hour';
|
|
1593
|
+
this.model.frequencyValue = 0;
|
|
1594
|
+
}
|
|
1595
|
+
changeExecutionType() {
|
|
1596
|
+
const date = new Date();
|
|
1597
|
+
this.model.execAppointDate = date;
|
|
1598
|
+
this.model.execAppointHour = `${this.addZero(date.getHours())}:${this.addZero(date.getMinutes())}`;
|
|
1599
|
+
}
|
|
1600
|
+
changeTypeFrequency() {
|
|
1601
|
+
}
|
|
1602
|
+
getActiveTab(codTab) {
|
|
1603
|
+
return (this.model.repeatType === codTab);
|
|
1604
|
+
}
|
|
1605
|
+
setActiveTab(codTab) {
|
|
1606
|
+
this.model.repeatType = codTab;
|
|
1607
|
+
}
|
|
1608
|
+
addZero(num) {
|
|
1609
|
+
let str = `${num}`;
|
|
1610
|
+
if (num < 10) {
|
|
1611
|
+
str = `0${num}`;
|
|
1612
|
+
}
|
|
1613
|
+
return str;
|
|
1614
|
+
}
|
|
1615
|
+
executeSchedule() {
|
|
1616
|
+
if (this.disabledParams) {
|
|
1617
|
+
return;
|
|
1618
|
+
}
|
|
1619
|
+
if (!this.validate()) {
|
|
1620
|
+
return;
|
|
1621
|
+
}
|
|
1622
|
+
this.jsonObject = {};
|
|
1623
|
+
this.jsonObject.status = 'active';
|
|
1624
|
+
this.jsonObject.processID = this.programName;
|
|
1625
|
+
this.jsonObject.recurrent = this.model.repeatExecution;
|
|
1626
|
+
this.jsonObject.executionParameter = {};
|
|
1627
|
+
if (this.model.executionType === 1) {
|
|
1628
|
+
const date = new Date();
|
|
1629
|
+
this.jsonObject.firstExecution = `${date.getFullYear()}-${(date.getMonth() + 1)}-${date.getDate()}T${this.addZero(date.getHours())}:${this.addZero(date.getMinutes())}:00.000Z`;
|
|
1630
|
+
}
|
|
1631
|
+
if (this.model.executionType === 2) {
|
|
1632
|
+
this.jsonObject.firstExecution = `${this.model.execAppointDate}T${this.model.execAppointHour}:00.000Z`;
|
|
1633
|
+
}
|
|
1634
|
+
this.jsonObject.executionParameter.parametros = [];
|
|
1635
|
+
this.jsonObject.executionParameter.parametros[0] = { chave: 'rpwServer', valor: this.model.executionServer };
|
|
1636
|
+
this.jsonObject.executionParameter.parametros[1] = { chave: 'RPW_PROGRAM', valor: this.externalName };
|
|
1637
|
+
this.jsonObject.executionParameter.parametros[2] = { chave: 'RPW_PRG_EMS5', valor: this.programEMS5 ? 'yes' : 'no' };
|
|
1638
|
+
this.jsonObject.executionParameter.parametros[3] = { chave: 'RPW_PRG_VERS', valor: this.programVersion };
|
|
1639
|
+
this.jsonObject.executionParameter.parametros[4] = {};
|
|
1640
|
+
this.jsonObject.executionParameter.parametros[4].parametros_negocio = this.parameters;
|
|
1641
|
+
// Executa hoje ou agendada
|
|
1642
|
+
this.rpwService.createExecution(this.jsonObject, this.loading).subscribe(() => {
|
|
1643
|
+
this.poNotification.success('Agendamento realizado com sucesso !');
|
|
1644
|
+
});
|
|
1645
|
+
if (this.model.repeatExecution) {
|
|
1646
|
+
if (this.model.repeatType === 1) {
|
|
1647
|
+
this.jsonObject.daily = {
|
|
1648
|
+
hour: this.getHourOrMinute(this.model.execAppointHourInit, 'h'),
|
|
1649
|
+
minute: this.getHourOrMinute(this.model.execAppointHourInit, 'm')
|
|
1650
|
+
};
|
|
1651
|
+
}
|
|
1652
|
+
if (this.model.repeatType === 2) {
|
|
1653
|
+
this.jsonObject.weekly = {
|
|
1654
|
+
hour: this.getHourOrMinute(this.model.execAppointHourInit, 'h'),
|
|
1655
|
+
minute: this.getHourOrMinute(this.model.execAppointHourInit, 'm'),
|
|
1656
|
+
daysOfWeek: this.model.selectWeeklys
|
|
1657
|
+
};
|
|
1658
|
+
}
|
|
1659
|
+
if (this.model.repeatType === 3) {
|
|
1660
|
+
this.jsonObject.monthly = {
|
|
1661
|
+
hour: this.getHourOrMinute(this.model.execAppointHourInit, 'h'),
|
|
1662
|
+
minute: this.getHourOrMinute(this.model.execAppointHourInit, 'm'),
|
|
1663
|
+
day: this.model.dayOfMonth
|
|
1664
|
+
};
|
|
1665
|
+
}
|
|
1666
|
+
if (this.isFrenquency()) {
|
|
1667
|
+
this.jsonObject.rangeExecutions = {
|
|
1668
|
+
frequency: {
|
|
1669
|
+
type: this.model.frequencyType,
|
|
1670
|
+
value: this.model.frequencyValue
|
|
1671
|
+
},
|
|
1672
|
+
rangeLimit: {
|
|
1673
|
+
hour: this.getHourOrMinute(this.model.execAppointHourFinal, 'h'),
|
|
1674
|
+
minute: this.getHourOrMinute(this.model.execAppointHourFinal, 'm')
|
|
1675
|
+
}
|
|
1676
|
+
};
|
|
1677
|
+
}
|
|
1678
|
+
// Executa a diária, semanal ou mensal
|
|
1679
|
+
this.rpwService.createExecution(this.jsonObject, this.loading).subscribe(() => {
|
|
1680
|
+
});
|
|
1681
|
+
}
|
|
1682
|
+
this.endExecution.emit(this.model);
|
|
1683
|
+
}
|
|
1684
|
+
getHourOrMinute(value, type) {
|
|
1685
|
+
if (type === 'h') {
|
|
1686
|
+
return +value.substring(0, 2);
|
|
1687
|
+
}
|
|
1688
|
+
if (type === 'm') {
|
|
1689
|
+
return +value.substring(3, 6);
|
|
1690
|
+
}
|
|
1691
|
+
}
|
|
1692
|
+
compareHour(hourInit, hourFinal) {
|
|
1693
|
+
if (hourInit === hourFinal) {
|
|
1694
|
+
return false;
|
|
1695
|
+
}
|
|
1696
|
+
if (this.getHourOrMinute(hourInit, 'h') < this.getHourOrMinute(hourFinal, 'h')) {
|
|
1697
|
+
return true;
|
|
1698
|
+
}
|
|
1699
|
+
if (this.getHourOrMinute(hourInit, 'm') > this.getHourOrMinute(hourFinal, 'm')) {
|
|
1700
|
+
return false;
|
|
1701
|
+
}
|
|
1702
|
+
return true;
|
|
1703
|
+
}
|
|
1704
|
+
validate() {
|
|
1705
|
+
if (!this.scheduleExecutionForm.valid) {
|
|
1706
|
+
this.poNotification.error('Verifique as inconsistências em tela.');
|
|
1707
|
+
return false;
|
|
1708
|
+
}
|
|
1709
|
+
if (!this.model.executionServer) {
|
|
1710
|
+
this.poNotification.error('Servidor de Execução não foi informado.');
|
|
1711
|
+
return false;
|
|
1712
|
+
}
|
|
1713
|
+
if (this.isExecutionSchedule() && (!this.model.execAppointDate || !this.model.execAppointHour)) {
|
|
1714
|
+
this.poNotification.error('Informar a data e a hora para agendamento da execução.');
|
|
1715
|
+
return false;
|
|
1716
|
+
}
|
|
1717
|
+
if (this.model.repeatExecution) {
|
|
1718
|
+
if (!this.model.execAppointHourInit) {
|
|
1719
|
+
this.poNotification.error('Informar a hora de início para a execução.');
|
|
1720
|
+
return false;
|
|
1721
|
+
}
|
|
1722
|
+
if (this.model.repeatType === 2 && (this.model.selectWeeklys.length === 0)) {
|
|
1723
|
+
this.poNotification.error('Informar os dias da semana para a execução.');
|
|
1724
|
+
return false;
|
|
1725
|
+
}
|
|
1726
|
+
if (this.model.repeatType === 3 && (!this.model.dayOfMonth)) {
|
|
1727
|
+
this.poNotification.error('Informar o dia para a execução.');
|
|
1728
|
+
return false;
|
|
1729
|
+
}
|
|
1730
|
+
if (this.isFrenquency()) {
|
|
1731
|
+
if (!this.compareHour(this.model.execAppointHourInit, this.model.execAppointHourFinal)) {
|
|
1732
|
+
this.poNotification.error('Hora Fim deve ser maior que Hora Início.');
|
|
1733
|
+
return false;
|
|
1734
|
+
}
|
|
1735
|
+
if (this.model.frequencyValue === 0) {
|
|
1736
|
+
this.poNotification.error('Informar a frequência de execução (A cada hora/minuto).');
|
|
1737
|
+
return false;
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
return true;
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
/** @nocollapse */ TotvsScheduleExecutionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: TotvsScheduleExecutionComponent, deps: [{ token: i1$1.PoI18nService }, { token: TotvsScheduleExecutionService }, { token: i1$1.PoNotificationService }], target: i0.ɵɵFactoryTarget.Component });
|
|
1745
|
+
/** @nocollapse */ TotvsScheduleExecutionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: TotvsScheduleExecutionComponent, selector: "app-totvs-schedule-execution", inputs: { programName: "programName", externalName: "externalName", programEMS5: "programEMS5", programVersion: "programVersion", parameters: "parameters", disabledParams: "disabledParams", loading: "loading" }, outputs: { endExecution: "endExecution" }, viewQueries: [{ propertyName: "scheduleExecutionForm", first: true, predicate: ["scheduleExecutionForm"], descendants: true, static: true }], ngImport: i0, template: "<form #scheduleExecutionForm=\"ngForm\">\r\n <div class=\"po-row po-sm-12 po-md-12 po-lg-12 po-xl-12\">\r\n <po-radio-group \r\n class=\"po-sm-12 po-md-12 po-lg-12 po-xl-12\"\r\n name=\"executionType\"\r\n p-label=\"Data de Execu\u00E7\u00E3o\"\r\n [p-disabled]=\"disabledParams\"\r\n [(ngModel)]=\"model.executionType\"\r\n [p-options]=\"executionTypeOptions\"\r\n (p-change)=\"changeExecutionType()\">\r\n </po-radio-group>\r\n\r\n <po-datepicker *ngIf=isExecutionSchedule()\r\n class=\"po-sm-6 po-md-6 po-lg-6 po-xl-6\"\r\n name=\"model.execAppointDate\"\r\n p-label=\"Agendar para\"\r\n [p-disabled]=\"disabledParams\"\r\n [(ngModel)]=\"model.execAppointDate\">\r\n </po-datepicker>\r\n\r\n <po-input *ngIf=isExecutionSchedule()\r\n class=\"po-sm-6 po-md-6 po-lg-6 po-xl-6\"\r\n name=\"execAppointHour\"\r\n p-label=\"Hora\"\r\n p-mask=\"99:99\"\r\n p-mask-format-model=\"true\"\r\n p-pattern=\"^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$\"\r\n p-error-pattern=\"Hora inv\u00E1lida\"\r\n [p-disabled]=\"disabledParams\"\r\n [(ngModel)]=\"model.execAppointHour\">\r\n </po-input>\r\n </div>\r\n\r\n <div class=\"po-row po-sm-12 po-md-12 po-lg-12 po-xl-12\">\r\n <po-lookup\r\n class=\"po-sm-12 po-md-12 po-lg-12 po-xl-12\"\r\n name=\"executionServer\"\r\n p-label=\"Servidor de Execu\u00E7\u00E3o\"\r\n p-placeholder=\"Servidor de Execu\u00E7\u00E3o\"\r\n [p-columns]=\"zoomRpwServiceColumns\"\r\n [p-field-format]=\"fieldRpwServiceFormat\"\r\n [p-filter-service]=\"rpwService\"\r\n p-field-label=\"name\"\r\n p-field-value=\"code\"\r\n [p-disabled]=\"disabledParams\"\r\n [(ngModel)]=\"model.executionServer\">\r\n </po-lookup>\r\n </div>\r\n\r\n <div class=\"po-row po-sm-12 po-md-12 po-lg-12 po-xl-12\">\r\n <po-switch\r\n class=\"po-sm-6 po-md-6 po-lg-6 po-xl-6\"\r\n name=\"repeatExecution\"\r\n p-label=\"Repetir ocorr\u00EAncia ?\"\r\n p-label-off=\"N\u00E3o\"\r\n p-label-on=\"Sim\"\r\n [(ngModel)]=\"model.repeatExecution\"\r\n [p-disabled]=\"disabledParams\"\r\n (click)=\"changeRepeatExecution()\">\r\n </po-switch>\r\n </div>\r\n\r\n <div class=\"po-row\" *ngIf=\"isRepeatExecution()\">\r\n \r\n <po-tabs>\r\n\r\n <po-tab \r\n p-label=\"Di\u00E1ria\" \r\n [p-active]=\"getActiveTab(1)\" \r\n (p-click)=\"setActiveTab(1)\">\r\n\r\n <div class=\"po-sm-6 po-md-6 po-lg-6 po-xl-6\">\r\n <po-radio-group \r\n class=\"po-sm-12 po-md-12 po-lg-12 po-xl-12\"\r\n name=\"frequencyDaily\"\r\n p-label=\"Frequ\u00EAncia\"\r\n p-columns=1\r\n [(ngModel)]=\"model.frequency\"\r\n [p-disabled]=\"disabledParams\"\r\n [p-options]=\"frequencyOptions\"\r\n (p-change)=\"changeTypeFrequency()\">\r\n </po-radio-group>\r\n </div>\r\n \r\n <div class=\"po-sm-6 po-md-6 po-lg-6 po-xl-6\"> \r\n <po-input\r\n class=\"po-sm-6 po-md-6 po-lg-6 po-xl-6\"\r\n name=\"execAppointHourInitDaily\"\r\n p-label=\"Hora In\u00EDcio\"\r\n p-mask=\"99:99\"\r\n p-mask-format-model=\"true\"\r\n p-pattern=\"^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$\"\r\n p-error-pattern=\"Hora inv\u00E1lida\"\r\n [p-disabled]=\"disabledParams\"\r\n [(ngModel)]=\"model.execAppointHourInit\">\r\n </po-input>\r\n \r\n <po-input *ngIf=\"isFrenquency()\"\r\n class=\"po-sm-6 po-md-6 po-lg-6 po-xl-6\"\r\n name=\"execAppointHourFinalDaily\"\r\n p-label=\"Hora Fim\"\r\n p-mask=\"99:99\"\r\n p-mask-format-model=\"true\"\r\n p-pattern=\"^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$\"\r\n p-error-pattern=\"Hora inv\u00E1lida\"\r\n [p-disabled]=\"disabledParams\"\r\n [(ngModel)]=\"model.execAppointHourFinal\">\r\n </po-input>\r\n \r\n <po-number *ngIf=\"isFrenquency()\"\r\n class=\"po-sm-5 po-md-5 po-lg-5 po-xl-5\"\r\n name=\"frequencyValueDaily\"\r\n p-label=\"A cada\"\r\n p-minlength=\"1\"\r\n p-maxlength=\"3\"\r\n p-min=\"0\"\r\n p-max=\"999\"\r\n [p-disabled]=\"disabledParams\"\r\n [(ngModel)]=\"model.frequencyValue\">\r\n </po-number>\r\n \r\n <po-select *ngIf=\"isFrenquency()\"\r\n class=\"po-mt-3 po-sm-7 po-md-7 po-lg-7 po-xl-7\"\r\n name=\"frequencyTypeDaily\"\r\n p-label=\"\"\r\n [p-options]=\"frequencyTypeOptions\"\r\n [p-disabled]=\"disabledParams\"\r\n [(ngModel)]=\"model.frequencyType\">\r\n </po-select>\r\n </div>\r\n </po-tab>\r\n\r\n <po-tab \r\n p-label=\"Semanal\"\r\n [p-active]=\"getActiveTab(2)\"\r\n (p-click)=\"setActiveTab(2)\">\r\n\r\n <div class=\"po-row po-sm-12 po-md-12 po-lg-12 po-xl-12\">\r\n <po-multiselect\r\n class=\"po-sm-12 po-md-12 po-lg-12 po-xl-12\"\r\n name=\"selectWeeklys\"\r\n p-label=\"Dias da Semana\"\r\n p-placeholder=\"Escolha os dias da semana\"\r\n [p-disabled]=\"disabledParams\"\r\n [(ngModel)]=\"model.selectWeeklys\"\r\n [p-options]=\"weeklyOptions\">\r\n </po-multiselect>\r\n </div>\r\n\r\n <div class=\"po-sm-6 po-md-6 po-lg-6 po-xl-6\">\r\n <po-radio-group \r\n class=\"po-sm-12 po-md-12 po-lg-12 po-xl-12\"\r\n name=\"frequencyWeekly\"\r\n p-label=\"Frequ\u00EAncia\"\r\n p-columns=1\r\n [(ngModel)]=\"model.frequency\"\r\n [p-disabled]=\"disabledParams\"\r\n [p-options]=\"frequencyOptions\"\r\n (p-change)=\"changeTypeFrequency()\">\r\n </po-radio-group>\r\n </div>\r\n\r\n <div class=\"po-sm-6 po-md-6 po-lg-6 po-xl-6\">\r\n <po-input\r\n class=\"po-sm-6 po-md-6 po-lg-6 po-xl-6\"\r\n name=\"execAppointHourInitWeekly\"\r\n p-label=\"Hora In\u00EDcio\"\r\n p-mask=\"99:99\"\r\n p-mask-format-model=\"true\"\r\n p-pattern=\"^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$\"\r\n p-error-pattern=\"Hora inv\u00E1lida\"\r\n [p-disabled]=\"disabledParams\"\r\n [(ngModel)]=\"model.execAppointHourInit\">\r\n </po-input>\r\n\r\n <po-input *ngIf=\"isFrenquency()\"\r\n class=\"po-sm-6 po-md-6 po-lg-6 po-xl-6\"\r\n name=\"execAppointHourFinalWeekly\"\r\n p-label=\"Hora Fim\"\r\n p-mask=\"99:99\"\r\n p-mask-format-model=\"true\"\r\n p-pattern=\"^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$\"\r\n p-error-pattern=\"Hora inv\u00E1lida\"\r\n [p-disabled]=\"disabledParams\"\r\n [(ngModel)]=\"model.execAppointHourFinal\">\r\n </po-input>\r\n\r\n <po-number *ngIf=\"isFrenquency()\"\r\n class=\"po-sm-5 po-md-5 po-lg-5 po-xl-5\"\r\n name=\"frequencyValueWeekly\"\r\n p-label=\"A cada\"\r\n p-minlength=\"1\"\r\n p-maxlength=\"3\"\r\n p-min=\"0\"\r\n p-max=\"999\"\r\n [p-disabled]=\"disabledParams\"\r\n [(ngModel)]=\"model.frequencyValue\">\r\n </po-number>\r\n\r\n <po-select *ngIf=\"isFrenquency()\"\r\n class=\"po-mt-3 po-sm-7 po-md-7 po-lg-7 po-xl-7\"\r\n name=\"frequencyTypeWeekly\"\r\n p-label=\"\"\r\n [p-options]=\"frequencyTypeOptions\"\r\n [p-disabled]=\"disabledParams\"\r\n [(ngModel)]=\"model.frequencyType\">\r\n </po-select>\r\n </div>\r\n </po-tab>\r\n\r\n <po-tab \r\n p-label=\"Mensal\" \r\n [p-active]=\"getActiveTab(3)\" \r\n (p-click)=\"setActiveTab(3)\">\r\n\r\n <div class=\"po-row po-sm-12 po-md-12 po-lg-12 po-xl-12\">\r\n <po-number\r\n class=\"po-sm-3 po-md-3 po-lg-3 po-xl-3\"\r\n name=\"dayOfMonth\"\r\n p-label=\"Dia do m\u00EAs\"\r\n p-minlength=\"1\"\r\n p-maxlength=\"2\"\r\n p-min=\"0\"\r\n p-max=\"31\"\r\n [p-disabled]=\"disabledParams\"\r\n [(ngModel)]=\"model.dayOfMonth\">\r\n </po-number>\r\n </div>\r\n\r\n <div class=\"po-row po-sm-6 po-md-6 po-lg-6 po-xl-6\">\r\n <po-radio-group \r\n class=\"po-sm-12 po-md-12 po-lg-12 po-xl-12\"\r\n name=\"frequencyMonthly\"\r\n p-label=\"Frequ\u00EAncia\"\r\n p-columns=1\r\n [(ngModel)]=\"model.frequency\"\r\n [p-disabled]=\"disabledParams\"\r\n [p-options]=\"frequencyOptions\"\r\n (p-change)=\"changeTypeFrequency()\">\r\n </po-radio-group>\r\n </div>\r\n\r\n <div class=\"po-row po-sm-6 po-md-6 po-lg-6 po-xl-6\">\r\n <po-input\r\n class=\"po-sm-6 po-md-6 po-lg-6 po-xl-6\"\r\n name=\"execAppointHourInitMonthly\"\r\n p-label=\"Hora In\u00EDcio\"\r\n p-mask=\"99:99\"\r\n p-mask-format-model=\"true\"\r\n p-pattern=\"^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$\"\r\n p-error-pattern=\"Hora inv\u00E1lida\"\r\n [p-disabled]=\"disabledParams\"\r\n [(ngModel)]=\"model.execAppointHourInit\">\r\n </po-input>\r\n\r\n <po-input *ngIf=\"isFrenquency()\"\r\n class=\"po-sm-6 po-md-6 po-lg-6 po-xl-6\"\r\n name=\"execAppointHourFinalWeekly\"\r\n p-label=\"Hora Fim\"\r\n p-mask=\"99:99\"\r\n p-mask-format-model=\"true\"\r\n p-pattern=\"^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$\"\r\n p-error-pattern=\"Hora inv\u00E1lida\"\r\n [p-disabled]=\"disabledParams\"\r\n [(ngModel)]=\"model.execAppointHourFinal\">\r\n </po-input>\r\n\r\n <po-number *ngIf=\"isFrenquency()\"\r\n class=\"po-sm-5 po-md-5 po-lg-5 po-xl-5\"\r\n name=\"frequencyValueWeekly\"\r\n p-label=\"A cada\"\r\n p-minlength=\"1\"\r\n p-maxlength=\"3\"\r\n p-min=\"0\"\r\n p-max=\"999\"\r\n [p-disabled]=\"disabledParams\"\r\n [(ngModel)]=\"model.frequencyValue\">\r\n </po-number>\r\n\r\n <po-select *ngIf=\"isFrenquency()\"\r\n class=\"po-mt-3 po-sm-7 po-md-7 po-lg-7 po-xl-7\"\r\n name=\"frequencyTypeWeekly\"\r\n p-label=\"\"\r\n [p-options]=\"frequencyTypeOptions\"\r\n [p-disabled]=\"disabledParams\"\r\n [(ngModel)]=\"model.frequencyType\">\r\n </po-select>\r\n </div>\r\n </po-tab>\r\n </po-tabs>\r\n </div>\r\n\r\n <div class=\"po-sm-12 po-md-12 po-lg-12 po-xl-12\" style=\"padding-top: 15px;\">\r\n <po-button\r\n style=\"float: right;\"\r\n p-label=\"Gerar Agendamento RPW\"\r\n [p-disabled]=\"disabledParams\"\r\n (click)=\"executeSchedule()\">\r\n </po-button>\r\n </div>\r\n</form>\r\n", styles: [""], components: [{ type: i1$1.PoRadioGroupComponent, selector: "po-radio-group", inputs: ["p-label", "p-help"] }, { type: i1$1.PoDatepickerComponent, selector: "po-datepicker", inputs: ["p-label", "p-help"] }, { type: i1$1.PoInputComponent, selector: "po-input" }, { type: i1$1.PoLookupComponent, selector: "po-lookup" }, { type: i1$1.PoSwitchComponent, selector: "po-switch", inputs: ["p-label-position", "p-label-off", "p-label-on"] }, { type: i1$1.PoTabsComponent, selector: "po-tabs" }, { type: i1$1.PoTabComponent, selector: "po-tab" }, { type: i1$1.PoNumberComponent, selector: "po-number", inputs: ["p-step", "p-min", "p-max"] }, { type: i1$1.PoSelectComponent, selector: "po-select", inputs: ["p-readonly", "p-placeholder", "p-options"], outputs: ["ngModelChange"] }, { type: i1$1.PoMultiselectComponent, selector: "po-multiselect" }, { type: i1$1.PoButtonComponent, selector: "po-button" }], directives: [{ type: i3.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i3.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i3.NgForm, selector: "form:not([ngNoForm]):not([formGroup]),ng-form,[ngForm]", inputs: ["ngFormOptions"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i3.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
|
|
1746
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: TotvsScheduleExecutionComponent, decorators: [{
|
|
1747
|
+
type: Component,
|
|
1748
|
+
args: [{ selector: 'app-totvs-schedule-execution', template: "<form #scheduleExecutionForm=\"ngForm\">\r\n <div class=\"po-row po-sm-12 po-md-12 po-lg-12 po-xl-12\">\r\n <po-radio-group \r\n class=\"po-sm-12 po-md-12 po-lg-12 po-xl-12\"\r\n name=\"executionType\"\r\n p-label=\"Data de Execu\u00E7\u00E3o\"\r\n [p-disabled]=\"disabledParams\"\r\n [(ngModel)]=\"model.executionType\"\r\n [p-options]=\"executionTypeOptions\"\r\n (p-change)=\"changeExecutionType()\">\r\n </po-radio-group>\r\n\r\n <po-datepicker *ngIf=isExecutionSchedule()\r\n class=\"po-sm-6 po-md-6 po-lg-6 po-xl-6\"\r\n name=\"model.execAppointDate\"\r\n p-label=\"Agendar para\"\r\n [p-disabled]=\"disabledParams\"\r\n [(ngModel)]=\"model.execAppointDate\">\r\n </po-datepicker>\r\n\r\n <po-input *ngIf=isExecutionSchedule()\r\n class=\"po-sm-6 po-md-6 po-lg-6 po-xl-6\"\r\n name=\"execAppointHour\"\r\n p-label=\"Hora\"\r\n p-mask=\"99:99\"\r\n p-mask-format-model=\"true\"\r\n p-pattern=\"^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$\"\r\n p-error-pattern=\"Hora inv\u00E1lida\"\r\n [p-disabled]=\"disabledParams\"\r\n [(ngModel)]=\"model.execAppointHour\">\r\n </po-input>\r\n </div>\r\n\r\n <div class=\"po-row po-sm-12 po-md-12 po-lg-12 po-xl-12\">\r\n <po-lookup\r\n class=\"po-sm-12 po-md-12 po-lg-12 po-xl-12\"\r\n name=\"executionServer\"\r\n p-label=\"Servidor de Execu\u00E7\u00E3o\"\r\n p-placeholder=\"Servidor de Execu\u00E7\u00E3o\"\r\n [p-columns]=\"zoomRpwServiceColumns\"\r\n [p-field-format]=\"fieldRpwServiceFormat\"\r\n [p-filter-service]=\"rpwService\"\r\n p-field-label=\"name\"\r\n p-field-value=\"code\"\r\n [p-disabled]=\"disabledParams\"\r\n [(ngModel)]=\"model.executionServer\">\r\n </po-lookup>\r\n </div>\r\n\r\n <div class=\"po-row po-sm-12 po-md-12 po-lg-12 po-xl-12\">\r\n <po-switch\r\n class=\"po-sm-6 po-md-6 po-lg-6 po-xl-6\"\r\n name=\"repeatExecution\"\r\n p-label=\"Repetir ocorr\u00EAncia ?\"\r\n p-label-off=\"N\u00E3o\"\r\n p-label-on=\"Sim\"\r\n [(ngModel)]=\"model.repeatExecution\"\r\n [p-disabled]=\"disabledParams\"\r\n (click)=\"changeRepeatExecution()\">\r\n </po-switch>\r\n </div>\r\n\r\n <div class=\"po-row\" *ngIf=\"isRepeatExecution()\">\r\n \r\n <po-tabs>\r\n\r\n <po-tab \r\n p-label=\"Di\u00E1ria\" \r\n [p-active]=\"getActiveTab(1)\" \r\n (p-click)=\"setActiveTab(1)\">\r\n\r\n <div class=\"po-sm-6 po-md-6 po-lg-6 po-xl-6\">\r\n <po-radio-group \r\n class=\"po-sm-12 po-md-12 po-lg-12 po-xl-12\"\r\n name=\"frequencyDaily\"\r\n p-label=\"Frequ\u00EAncia\"\r\n p-columns=1\r\n [(ngModel)]=\"model.frequency\"\r\n [p-disabled]=\"disabledParams\"\r\n [p-options]=\"frequencyOptions\"\r\n (p-change)=\"changeTypeFrequency()\">\r\n </po-radio-group>\r\n </div>\r\n \r\n <div class=\"po-sm-6 po-md-6 po-lg-6 po-xl-6\"> \r\n <po-input\r\n class=\"po-sm-6 po-md-6 po-lg-6 po-xl-6\"\r\n name=\"execAppointHourInitDaily\"\r\n p-label=\"Hora In\u00EDcio\"\r\n p-mask=\"99:99\"\r\n p-mask-format-model=\"true\"\r\n p-pattern=\"^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$\"\r\n p-error-pattern=\"Hora inv\u00E1lida\"\r\n [p-disabled]=\"disabledParams\"\r\n [(ngModel)]=\"model.execAppointHourInit\">\r\n </po-input>\r\n \r\n <po-input *ngIf=\"isFrenquency()\"\r\n class=\"po-sm-6 po-md-6 po-lg-6 po-xl-6\"\r\n name=\"execAppointHourFinalDaily\"\r\n p-label=\"Hora Fim\"\r\n p-mask=\"99:99\"\r\n p-mask-format-model=\"true\"\r\n p-pattern=\"^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$\"\r\n p-error-pattern=\"Hora inv\u00E1lida\"\r\n [p-disabled]=\"disabledParams\"\r\n [(ngModel)]=\"model.execAppointHourFinal\">\r\n </po-input>\r\n \r\n <po-number *ngIf=\"isFrenquency()\"\r\n class=\"po-sm-5 po-md-5 po-lg-5 po-xl-5\"\r\n name=\"frequencyValueDaily\"\r\n p-label=\"A cada\"\r\n p-minlength=\"1\"\r\n p-maxlength=\"3\"\r\n p-min=\"0\"\r\n p-max=\"999\"\r\n [p-disabled]=\"disabledParams\"\r\n [(ngModel)]=\"model.frequencyValue\">\r\n </po-number>\r\n \r\n <po-select *ngIf=\"isFrenquency()\"\r\n class=\"po-mt-3 po-sm-7 po-md-7 po-lg-7 po-xl-7\"\r\n name=\"frequencyTypeDaily\"\r\n p-label=\"\"\r\n [p-options]=\"frequencyTypeOptions\"\r\n [p-disabled]=\"disabledParams\"\r\n [(ngModel)]=\"model.frequencyType\">\r\n </po-select>\r\n </div>\r\n </po-tab>\r\n\r\n <po-tab \r\n p-label=\"Semanal\"\r\n [p-active]=\"getActiveTab(2)\"\r\n (p-click)=\"setActiveTab(2)\">\r\n\r\n <div class=\"po-row po-sm-12 po-md-12 po-lg-12 po-xl-12\">\r\n <po-multiselect\r\n class=\"po-sm-12 po-md-12 po-lg-12 po-xl-12\"\r\n name=\"selectWeeklys\"\r\n p-label=\"Dias da Semana\"\r\n p-placeholder=\"Escolha os dias da semana\"\r\n [p-disabled]=\"disabledParams\"\r\n [(ngModel)]=\"model.selectWeeklys\"\r\n [p-options]=\"weeklyOptions\">\r\n </po-multiselect>\r\n </div>\r\n\r\n <div class=\"po-sm-6 po-md-6 po-lg-6 po-xl-6\">\r\n <po-radio-group \r\n class=\"po-sm-12 po-md-12 po-lg-12 po-xl-12\"\r\n name=\"frequencyWeekly\"\r\n p-label=\"Frequ\u00EAncia\"\r\n p-columns=1\r\n [(ngModel)]=\"model.frequency\"\r\n [p-disabled]=\"disabledParams\"\r\n [p-options]=\"frequencyOptions\"\r\n (p-change)=\"changeTypeFrequency()\">\r\n </po-radio-group>\r\n </div>\r\n\r\n <div class=\"po-sm-6 po-md-6 po-lg-6 po-xl-6\">\r\n <po-input\r\n class=\"po-sm-6 po-md-6 po-lg-6 po-xl-6\"\r\n name=\"execAppointHourInitWeekly\"\r\n p-label=\"Hora In\u00EDcio\"\r\n p-mask=\"99:99\"\r\n p-mask-format-model=\"true\"\r\n p-pattern=\"^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$\"\r\n p-error-pattern=\"Hora inv\u00E1lida\"\r\n [p-disabled]=\"disabledParams\"\r\n [(ngModel)]=\"model.execAppointHourInit\">\r\n </po-input>\r\n\r\n <po-input *ngIf=\"isFrenquency()\"\r\n class=\"po-sm-6 po-md-6 po-lg-6 po-xl-6\"\r\n name=\"execAppointHourFinalWeekly\"\r\n p-label=\"Hora Fim\"\r\n p-mask=\"99:99\"\r\n p-mask-format-model=\"true\"\r\n p-pattern=\"^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$\"\r\n p-error-pattern=\"Hora inv\u00E1lida\"\r\n [p-disabled]=\"disabledParams\"\r\n [(ngModel)]=\"model.execAppointHourFinal\">\r\n </po-input>\r\n\r\n <po-number *ngIf=\"isFrenquency()\"\r\n class=\"po-sm-5 po-md-5 po-lg-5 po-xl-5\"\r\n name=\"frequencyValueWeekly\"\r\n p-label=\"A cada\"\r\n p-minlength=\"1\"\r\n p-maxlength=\"3\"\r\n p-min=\"0\"\r\n p-max=\"999\"\r\n [p-disabled]=\"disabledParams\"\r\n [(ngModel)]=\"model.frequencyValue\">\r\n </po-number>\r\n\r\n <po-select *ngIf=\"isFrenquency()\"\r\n class=\"po-mt-3 po-sm-7 po-md-7 po-lg-7 po-xl-7\"\r\n name=\"frequencyTypeWeekly\"\r\n p-label=\"\"\r\n [p-options]=\"frequencyTypeOptions\"\r\n [p-disabled]=\"disabledParams\"\r\n [(ngModel)]=\"model.frequencyType\">\r\n </po-select>\r\n </div>\r\n </po-tab>\r\n\r\n <po-tab \r\n p-label=\"Mensal\" \r\n [p-active]=\"getActiveTab(3)\" \r\n (p-click)=\"setActiveTab(3)\">\r\n\r\n <div class=\"po-row po-sm-12 po-md-12 po-lg-12 po-xl-12\">\r\n <po-number\r\n class=\"po-sm-3 po-md-3 po-lg-3 po-xl-3\"\r\n name=\"dayOfMonth\"\r\n p-label=\"Dia do m\u00EAs\"\r\n p-minlength=\"1\"\r\n p-maxlength=\"2\"\r\n p-min=\"0\"\r\n p-max=\"31\"\r\n [p-disabled]=\"disabledParams\"\r\n [(ngModel)]=\"model.dayOfMonth\">\r\n </po-number>\r\n </div>\r\n\r\n <div class=\"po-row po-sm-6 po-md-6 po-lg-6 po-xl-6\">\r\n <po-radio-group \r\n class=\"po-sm-12 po-md-12 po-lg-12 po-xl-12\"\r\n name=\"frequencyMonthly\"\r\n p-label=\"Frequ\u00EAncia\"\r\n p-columns=1\r\n [(ngModel)]=\"model.frequency\"\r\n [p-disabled]=\"disabledParams\"\r\n [p-options]=\"frequencyOptions\"\r\n (p-change)=\"changeTypeFrequency()\">\r\n </po-radio-group>\r\n </div>\r\n\r\n <div class=\"po-row po-sm-6 po-md-6 po-lg-6 po-xl-6\">\r\n <po-input\r\n class=\"po-sm-6 po-md-6 po-lg-6 po-xl-6\"\r\n name=\"execAppointHourInitMonthly\"\r\n p-label=\"Hora In\u00EDcio\"\r\n p-mask=\"99:99\"\r\n p-mask-format-model=\"true\"\r\n p-pattern=\"^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$\"\r\n p-error-pattern=\"Hora inv\u00E1lida\"\r\n [p-disabled]=\"disabledParams\"\r\n [(ngModel)]=\"model.execAppointHourInit\">\r\n </po-input>\r\n\r\n <po-input *ngIf=\"isFrenquency()\"\r\n class=\"po-sm-6 po-md-6 po-lg-6 po-xl-6\"\r\n name=\"execAppointHourFinalWeekly\"\r\n p-label=\"Hora Fim\"\r\n p-mask=\"99:99\"\r\n p-mask-format-model=\"true\"\r\n p-pattern=\"^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$\"\r\n p-error-pattern=\"Hora inv\u00E1lida\"\r\n [p-disabled]=\"disabledParams\"\r\n [(ngModel)]=\"model.execAppointHourFinal\">\r\n </po-input>\r\n\r\n <po-number *ngIf=\"isFrenquency()\"\r\n class=\"po-sm-5 po-md-5 po-lg-5 po-xl-5\"\r\n name=\"frequencyValueWeekly\"\r\n p-label=\"A cada\"\r\n p-minlength=\"1\"\r\n p-maxlength=\"3\"\r\n p-min=\"0\"\r\n p-max=\"999\"\r\n [p-disabled]=\"disabledParams\"\r\n [(ngModel)]=\"model.frequencyValue\">\r\n </po-number>\r\n\r\n <po-select *ngIf=\"isFrenquency()\"\r\n class=\"po-mt-3 po-sm-7 po-md-7 po-lg-7 po-xl-7\"\r\n name=\"frequencyTypeWeekly\"\r\n p-label=\"\"\r\n [p-options]=\"frequencyTypeOptions\"\r\n [p-disabled]=\"disabledParams\"\r\n [(ngModel)]=\"model.frequencyType\">\r\n </po-select>\r\n </div>\r\n </po-tab>\r\n </po-tabs>\r\n </div>\r\n\r\n <div class=\"po-sm-12 po-md-12 po-lg-12 po-xl-12\" style=\"padding-top: 15px;\">\r\n <po-button\r\n style=\"float: right;\"\r\n p-label=\"Gerar Agendamento RPW\"\r\n [p-disabled]=\"disabledParams\"\r\n (click)=\"executeSchedule()\">\r\n </po-button>\r\n </div>\r\n</form>\r\n", styles: [""] }]
|
|
1749
|
+
}], ctorParameters: function () { return [{ type: i1$1.PoI18nService }, { type: TotvsScheduleExecutionService }, { type: i1$1.PoNotificationService }]; }, propDecorators: { scheduleExecutionForm: [{
|
|
1750
|
+
type: ViewChild,
|
|
1751
|
+
args: ['scheduleExecutionForm', { static: true }]
|
|
1752
|
+
}], programName: [{
|
|
1753
|
+
type: Input
|
|
1754
|
+
}], externalName: [{
|
|
1755
|
+
type: Input
|
|
1756
|
+
}], programEMS5: [{
|
|
1757
|
+
type: Input
|
|
1758
|
+
}], programVersion: [{
|
|
1759
|
+
type: Input
|
|
1760
|
+
}], parameters: [{
|
|
1761
|
+
type: Input
|
|
1762
|
+
}], disabledParams: [{
|
|
1763
|
+
type: Input
|
|
1764
|
+
}], loading: [{
|
|
1765
|
+
type: Input
|
|
1766
|
+
}], endExecution: [{
|
|
1767
|
+
type: Output
|
|
1768
|
+
}] } });
|
|
1769
|
+
|
|
1770
|
+
class DtsDateFormatPipe {
|
|
1771
|
+
transform(value, format = 'dd/MM/yyyy') {
|
|
1772
|
+
const { 0: year, 1: month, 2: day } = value.split('-');
|
|
1773
|
+
const formattedDate = format.replace('dd', day)
|
|
1774
|
+
.replace('MM', month)
|
|
1775
|
+
.replace('yyyy', year);
|
|
1776
|
+
return formattedDate;
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1779
|
+
/** @nocollapse */ DtsDateFormatPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: DtsDateFormatPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
1780
|
+
/** @nocollapse */ DtsDateFormatPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: DtsDateFormatPipe, name: "dtsDateFormat" });
|
|
1781
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: DtsDateFormatPipe, decorators: [{
|
|
1782
|
+
type: Pipe,
|
|
1783
|
+
args: [{
|
|
1784
|
+
name: 'dtsDateFormat'
|
|
1785
|
+
}]
|
|
1786
|
+
}] });
|
|
1787
|
+
|
|
1788
|
+
class DtsBackofficeUtilsModule {
|
|
1789
|
+
static forRoot() {
|
|
1790
|
+
return {
|
|
1791
|
+
ngModule: DtsBackofficeUtilsModule,
|
|
1792
|
+
providers: [TotvsScheduleExecutionService]
|
|
1793
|
+
};
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
1796
|
+
/** @nocollapse */ DtsBackofficeUtilsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: DtsBackofficeUtilsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1797
|
+
/** @nocollapse */ DtsBackofficeUtilsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: DtsBackofficeUtilsModule, declarations: [TotvsScheduleExecutionComponent,
|
|
1798
|
+
DtsDateFormatPipe], imports: [CommonModule,
|
|
1799
|
+
PoModule,
|
|
1800
|
+
FormsModule,
|
|
1801
|
+
HttpClientModule], exports: [TotvsScheduleExecutionComponent,
|
|
1802
|
+
DtsDateFormatPipe] });
|
|
1803
|
+
/** @nocollapse */ DtsBackofficeUtilsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: DtsBackofficeUtilsModule, providers: [
|
|
1804
|
+
TotvsScheduleExecutionService
|
|
1805
|
+
], imports: [[
|
|
1806
|
+
CommonModule,
|
|
1807
|
+
PoModule,
|
|
1808
|
+
FormsModule,
|
|
1809
|
+
HttpClientModule
|
|
1810
|
+
]] });
|
|
1811
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: DtsBackofficeUtilsModule, decorators: [{
|
|
1812
|
+
type: NgModule,
|
|
1813
|
+
args: [{
|
|
1814
|
+
declarations: [
|
|
1815
|
+
TotvsScheduleExecutionComponent,
|
|
1816
|
+
DtsDateFormatPipe
|
|
1817
|
+
],
|
|
1818
|
+
imports: [
|
|
1819
|
+
CommonModule,
|
|
1820
|
+
PoModule,
|
|
1821
|
+
FormsModule,
|
|
1822
|
+
HttpClientModule
|
|
1823
|
+
],
|
|
1824
|
+
exports: [
|
|
1825
|
+
TotvsScheduleExecutionComponent,
|
|
1826
|
+
DtsDateFormatPipe
|
|
1827
|
+
],
|
|
1828
|
+
providers: [
|
|
1829
|
+
TotvsScheduleExecutionService
|
|
1830
|
+
]
|
|
1831
|
+
}]
|
|
1832
|
+
}] });
|
|
1833
|
+
|
|
1834
|
+
/*
|
|
1835
|
+
* Public API Surface of dts-backoffice-util
|
|
1836
|
+
*/
|
|
1837
|
+
// Pipes
|
|
1838
|
+
|
|
1839
|
+
/**
|
|
1840
|
+
* Generated bundle index. Do not edit.
|
|
1841
|
+
*/
|
|
1842
|
+
|
|
1843
|
+
export { BreadcrumbControlService, CacheParamsService, DateUtil, DisclaimerUtil, DownloadDataParams, DtsBackofficeUtilsModule, DtsDateFormatPipe, ExecutionParameters, ExecutionStatus, FieldValidationUtil, FileUtil, FilterRangeUtil, GenericFunctionsUtils, MenuDatasulService, ProfileService, ReportFormats, ReportService, ScheduleParameters, TotvsScheduleExecutionComponent, TotvsScheduleExecutionService, TranslateService, UserLoginService };
|
|
1844
|
+
//# sourceMappingURL=dts-backoffice-util.mjs.map
|