dts-backoffice-util 21.0.1 → 21.2.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 CHANGED
@@ -12,9 +12,9 @@ Segue abaixo as últimas versões da Biblioteca, conforme a versão do PO-UI e A
12
12
 
13
13
  | PO-UI | Angular | Versão dtsBackofficeUtil |
14
14
  |-|-|-|
15
- | v21 | v21 | 21.0.1 |
16
- | v20 | v20 | 20.0.0 |
17
- | v19 | v19 | 19.4.0 |
15
+ | v21 | v21 | 21.2.0 |
16
+ | v20 | v20 | 20.2.0 |
17
+ | v19 | v19 | 19.6.0 |
18
18
  | v18 | v18 | 18.3.0 |
19
19
  | v17 | v17 | 17.2.0 |
20
20
  | v16 | v16 | 16.1.0 |
@@ -271,6 +271,15 @@ class MenuDatasulService {
271
271
  this.openHTMLProgram('THF1', externalName, params, parent);
272
272
  }
273
273
  openHTMLProgram(type, HTMLProgram, params, parent) {
274
+ const backendType = sessionStorage.getItem('totvs.product.backend.type');
275
+ if (backendType === 'DSS') {
276
+ this.openOnDSS(type, HTMLProgram, params, parent);
277
+ }
278
+ else {
279
+ this.openOnDTS4THF(type, HTMLProgram, params, parent);
280
+ }
281
+ }
282
+ openOnDTS4THF(type, HTMLProgram, params, parent) {
274
283
  const datasulPath = document.referrer.indexOf('totvs-menu') > 0 ? 'totvs-menu' : 'menu-html';
275
284
  HTMLProgram = HTMLProgram.replace(/\\/g, '/');
276
285
  if (HTMLProgram.charAt(0) === '/') {
@@ -290,8 +299,33 @@ class MenuDatasulService {
290
299
  if (baseUrl.charAt(baseUrl.length - 1) === '/') {
291
300
  baseUrl = baseUrl.slice(0, -1);
292
301
  }
293
- baseUrl = `${baseUrl}/#/${params}`;
302
+ if (type === 'THF2') {
303
+ baseUrl = `${baseUrl}/#`;
304
+ }
305
+ baseUrl = `${baseUrl}/${params}`;
306
+ }
307
+ this.openWindow(baseUrl, parent);
308
+ }
309
+ openOnDSS(type, HTMLProgram, params, parent) {
310
+ let baseUrl = `${HTMLProgram}`;
311
+ if (params) {
312
+ baseUrl = `${baseUrl}/${params}`;
313
+ }
314
+ try {
315
+ if (window.top && typeof window.top.navigateSmartX === 'function') {
316
+ window.top.navigateSmartX(baseUrl);
317
+ }
318
+ else {
319
+ // Se falhar e precisar do window.open, a barra na frente e o smart-x
320
+ // são necessários para o navegador não emendar na URL atual do iframe
321
+ this.openWindow(`/smart-x/${baseUrl}`, parent);
322
+ }
323
+ }
324
+ catch (e) {
325
+ this.openWindow(`/smart-x/${baseUrl}`, parent);
294
326
  }
327
+ }
328
+ openWindow(baseUrl, parent) {
295
329
  if (parent) {
296
330
  window.open(baseUrl, '_parent');
297
331
  }
@@ -318,7 +352,7 @@ class MenuDatasulService {
318
352
  }
319
353
  const aRequest = [];
320
354
  programList.forEach(programSearch => {
321
- aRequest.push(this.http.post(this.urlMenuPrograms, { search: programSearch }));
355
+ aRequest.push(this.http.post(this.urlMenuPrograms, this.getPayloadSearchProg(programSearch)));
322
356
  });
323
357
  return forkJoin(aRequest).pipe(map$1((response) => {
324
358
  if (!response) {
@@ -348,6 +382,9 @@ class MenuDatasulService {
348
382
  return responseReturn;
349
383
  }));
350
384
  }
385
+ getPayloadSearchProg(programSearch) {
386
+ return { 'codModul': null, 'search': programSearch, 'typeProg': '4,3,1,2', 'groupAplicat': [] };
387
+ }
351
388
  /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: MenuDatasulService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
352
389
  /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: MenuDatasulService }); }
353
390
  }
@@ -1554,6 +1591,9 @@ class TotvsScheduleExecutionService {
1554
1591
  }
1555
1592
  createExecution(parameters, loading) {
1556
1593
  const params = JSON.parse(JSON.stringify(parameters).replace(/\\\\/g, '*|'));
1594
+ if (params) {
1595
+ params.svUuidToken = this.getUuidAccessToken();
1596
+ }
1557
1597
  if (loading) {
1558
1598
  return this.http.post(`${this.urlJobScheduler}`, params, this.headers);
1559
1599
  }
@@ -1564,55 +1604,49 @@ class TotvsScheduleExecutionService {
1564
1604
  createExecutionForNow(executionParams, loading) {
1565
1605
  let jobScheduleParams;
1566
1606
  const date = new Date();
1567
- const params = JSON.parse(JSON.stringify(executionParams).replace(/\\\\/g, '*|'));
1568
- if (!params.programEMS5) {
1569
- params.programEMS5 = false;
1607
+ if (!executionParams.programEMS5) {
1608
+ executionParams.programEMS5 = false;
1570
1609
  }
1571
- if (!params.programStyle) {
1572
- params.programStyle = 0;
1610
+ if (!executionParams.programStyle) {
1611
+ executionParams.programStyle = 0;
1573
1612
  }
1574
- if (!params.programVersion) {
1575
- params.programVersion = '';
1613
+ if (!executionParams.programVersion) {
1614
+ executionParams.programVersion = '';
1576
1615
  }
1577
- if (!params.businessParams || params.businessParams.length === 0) {
1578
- params.businessParams = [{ chave: '', valor: '' }];
1616
+ if (!executionParams.businessParams || executionParams.businessParams.length === 0) {
1617
+ executionParams.businessParams = [{ chave: '', valor: '' }];
1579
1618
  }
1580
1619
  jobScheduleParams = {};
1581
1620
  jobScheduleParams.status = 'active';
1582
- jobScheduleParams.processID = params.programName;
1621
+ jobScheduleParams.processID = executionParams.programName;
1583
1622
  jobScheduleParams.firstExecution = `${date.getFullYear()}-${(date.getMonth() + 1)}-${date.getDate()}T${this.addZero(date.getHours())}:${this.addZero(date.getMinutes())}:00.000Z`;
1584
1623
  jobScheduleParams.recurrent = false;
1585
1624
  jobScheduleParams.executionParameter = {
1586
1625
  parametros: [
1587
- { chave: 'rpwServer', valor: params.executionServer },
1588
- { chave: 'RPW_PROGRAM', valor: params.externalName },
1589
- { chave: 'RPW_PRG_EMS5', valor: params.programEMS5 ? 'yes' : 'no' },
1590
- { chave: 'RPW_PRG_ESTILO', valor: params.programStyle },
1591
- { chave: 'RPW_PRG_VERS', valor: params.programVersion },
1592
- { parametros_negocio: params.businessParams }
1626
+ { chave: 'rpwServer', valor: executionParams.executionServer },
1627
+ { chave: 'RPW_PROGRAM', valor: executionParams.externalName },
1628
+ { chave: 'RPW_PRG_EMS5', valor: executionParams.programEMS5 ? 'yes' : 'no' },
1629
+ { chave: 'RPW_PRG_ESTILO', valor: executionParams.programStyle },
1630
+ { chave: 'RPW_PRG_VERS', valor: executionParams.programVersion },
1631
+ { parametros_negocio: executionParams.businessParams }
1593
1632
  ]
1594
1633
  };
1595
- if (params.paramDigitDef && params.paramDigitDef.length > 0) {
1634
+ if (executionParams.paramDigitDef && executionParams.paramDigitDef.length > 0) {
1596
1635
  jobScheduleParams.executionParameter.parametros.push({
1597
- param_digita_def: params.paramDigitDef
1636
+ param_digita_def: executionParams.paramDigitDef
1598
1637
  });
1599
1638
  }
1600
- if (params.paramDigitData && params.paramDigitData.length > 0) {
1639
+ if (executionParams.paramDigitData && executionParams.paramDigitData.length > 0) {
1601
1640
  jobScheduleParams.executionParameter.parametros.push({
1602
- param_digita_dados: params.paramDigitData
1641
+ param_digita_dados: executionParams.paramDigitData
1603
1642
  });
1604
1643
  }
1605
- if (params.paramSelections && params.paramSelections.length > 0) {
1644
+ if (executionParams.paramSelections && executionParams.paramSelections.length > 0) {
1606
1645
  jobScheduleParams.executionParameter.parametros.push({
1607
- selecoes: params.paramSelections
1646
+ selecoes: executionParams.paramSelections
1608
1647
  });
1609
1648
  }
1610
- if (loading) {
1611
- return this.http.post(`${this.urlJobScheduler}`, jobScheduleParams, this.headers);
1612
- }
1613
- else {
1614
- return this.http.post(`${this.urlJobScheduler}`, jobScheduleParams);
1615
- }
1649
+ return this.createExecution(jobScheduleParams, loading);
1616
1650
  }
1617
1651
  getExecutionByJobScheduleID(jobScheduleID, loading = false) {
1618
1652
  const url = `${this.urlJobExecution}?jobScheduleID=${jobScheduleID}`;
@@ -1727,6 +1761,18 @@ class TotvsScheduleExecutionService {
1727
1761
  }
1728
1762
  return str;
1729
1763
  }
1764
+ getUuidAccessToken() {
1765
+ let tokenService = localStorage.getItem('token-service.token');
1766
+ if (tokenService) {
1767
+ let jsonTokenService = JSON.parse(tokenService);
1768
+ let accessToken = jsonTokenService['access_token'];
1769
+ let payload = accessToken.split(".");
1770
+ let decodedAccessToken = atob(payload[1]);
1771
+ let jsonDecodedAccessToken = JSON.parse(decodedAccessToken);
1772
+ return jsonDecodedAccessToken['jti'];
1773
+ }
1774
+ return '';
1775
+ }
1730
1776
  /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: TotvsScheduleExecutionService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
1731
1777
  /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: TotvsScheduleExecutionService }); }
1732
1778
  }