coer-elements 1.1.9 → 1.1.11

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.
@@ -12,13 +12,13 @@ class JWTService {
12
12
  return User.Get()?.jwt || '';
13
13
  }
14
14
  /** */
15
- get GetExpirationDate() {
15
+ get expirationDate() {
16
16
  return Tools.IsNotOnlyWhiteSpace(this.jwt) && Tools.IsNotNull(this.jwtService.getTokenExpirationDate(this.jwt))
17
17
  ? DateTime.GetFormatDB(this.jwtService.getTokenExpirationDate(this.jwt))
18
18
  : null;
19
19
  }
20
20
  /** */
21
- get IsExpired() {
21
+ get isExpired() {
22
22
  return Tools.IsNotOnlyWhiteSpace(this.jwt)
23
23
  ? this.jwtService.isTokenExpired(this.jwt)
24
24
  : true;
@@ -1 +1 @@
1
- {"version":3,"file":"coer-elements-services.mjs","sources":["../../../projects/coer-elements/services/lib/jwt.service.ts","../../../projects/coer-elements/services/lib/services.module.ts","../../../projects/coer-elements/services/coer-elements-services.ts"],"sourcesContent":["import { inject, Injectable } from '@angular/core';\r\nimport { JwtHelperService } from '@auth0/angular-jwt';\r\nimport { DateTime, Tools, User } from 'coer-elements/tools'; \r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class JWTService {\r\n\r\n private readonly jwtService = inject(JwtHelperService);\r\n \r\n \r\n /** */\r\n public get jwt(): string {\r\n return User.Get<any>()?.jwt || '';\r\n }\r\n\r\n \r\n /** */\r\n public get GetExpirationDate(): string | null { \r\n return Tools.IsNotOnlyWhiteSpace(this.jwt) && Tools.IsNotNull(this.jwtService.getTokenExpirationDate(this.jwt))\r\n ? DateTime.GetFormatDB(this.jwtService.getTokenExpirationDate(this.jwt)!)\r\n : null\r\n }\r\n\r\n\r\n /** */\r\n public get IsExpired(): boolean { \r\n return Tools.IsNotOnlyWhiteSpace(this.jwt)\r\n ? this.jwtService.isTokenExpired(this.jwt)\r\n : true\r\n }\r\n}","import { NgModule } from '@angular/core'; \r\n\r\n//Services\r\nimport { JWTService } from './jwt.service';\r\n\r\n@NgModule({ \r\n providers: [ \r\n JWTService \r\n ]\r\n})\r\nexport class ServicesModule { }","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;MAOa,UAAU,CAAA;AAHvB,IAAA,WAAA,GAAA;AAKqB,QAAA,IAAA,CAAA,UAAU,GAAG,MAAM,CAAC,gBAAgB,CAAC;AAuBzD;;AAnBG,IAAA,IAAW,GAAG,GAAA;QACV,OAAO,IAAI,CAAC,GAAG,EAAO,EAAE,GAAG,IAAI,EAAE;;;AAKrC,IAAA,IAAW,iBAAiB,GAAA;QACxB,OAAO,KAAK,CAAC,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,sBAAsB,CAAC,IAAI,CAAC,GAAG,CAAC;AAC1G,cAAE,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,sBAAsB,CAAC,IAAI,CAAC,GAAG,CAAE;cACtE,IAAI;;;AAKd,IAAA,IAAW,SAAS,GAAA;AAChB,QAAA,OAAO,KAAK,CAAC,mBAAmB,CAAC,IAAI,CAAC,GAAG;cACnC,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG;cACvC,IAAI;;8GAvBL,UAAU,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAAV,IAAA,SAAA,IAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,UAAU,cAFP,MAAM,EAAA,CAAA,CAAA;;2FAET,UAAU,EAAA,UAAA,EAAA,CAAA;kBAHtB,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,UAAU,EAAE;AACf,iBAAA;;;MCIY,cAAc,CAAA;8GAAd,cAAc,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;+GAAd,cAAc,EAAA,CAAA,CAAA;AAAd,IAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,cAAc,EAJZ,SAAA,EAAA;YACP;AACH,SAAA,EAAA,CAAA,CAAA;;2FAEQ,cAAc,EAAA,UAAA,EAAA,CAAA;kBAL1B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACN,oBAAA,SAAS,EAAE;wBACP;AACH;AACJ,iBAAA;;;ACTD;;AAEG;;;;"}
1
+ {"version":3,"file":"coer-elements-services.mjs","sources":["../../../projects/coer-elements/services/lib/jwt.service.ts","../../../projects/coer-elements/services/lib/services.module.ts","../../../projects/coer-elements/services/coer-elements-services.ts"],"sourcesContent":["import { inject, Injectable } from '@angular/core';\r\nimport { JwtHelperService } from '@auth0/angular-jwt';\r\nimport { DateTime, Tools, User } from 'coer-elements/tools'; \r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class JWTService {\r\n\r\n private readonly jwtService = inject(JwtHelperService);\r\n \r\n \r\n /** */\r\n public get jwt(): string { \r\n return User.Get<any>()?.jwt || '';\r\n }\r\n\r\n \r\n /** */\r\n public get expirationDate(): string | null { \r\n return Tools.IsNotOnlyWhiteSpace(this.jwt) && Tools.IsNotNull(this.jwtService.getTokenExpirationDate(this.jwt))\r\n ? DateTime.GetFormatDB(this.jwtService.getTokenExpirationDate(this.jwt)!)\r\n : null\r\n }\r\n\r\n\r\n /** */\r\n public get isExpired(): boolean { \r\n return Tools.IsNotOnlyWhiteSpace(this.jwt)\r\n ? this.jwtService.isTokenExpired(this.jwt)\r\n : true\r\n }\r\n}","import { NgModule } from '@angular/core'; \r\n\r\n//Services\r\nimport { JWTService } from './jwt.service';\r\n\r\n@NgModule({ \r\n providers: [ \r\n JWTService \r\n ]\r\n})\r\nexport class ServicesModule { }","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;MAOa,UAAU,CAAA;AAHvB,IAAA,WAAA,GAAA;AAKqB,QAAA,IAAA,CAAA,UAAU,GAAG,MAAM,CAAC,gBAAgB,CAAC;AAuBzD;;AAnBG,IAAA,IAAW,GAAG,GAAA;QACV,OAAO,IAAI,CAAC,GAAG,EAAO,EAAE,GAAG,IAAI,EAAE;;;AAKrC,IAAA,IAAW,cAAc,GAAA;QACrB,OAAO,KAAK,CAAC,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,sBAAsB,CAAC,IAAI,CAAC,GAAG,CAAC;AAC1G,cAAE,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,sBAAsB,CAAC,IAAI,CAAC,GAAG,CAAE;cACtE,IAAI;;;AAKd,IAAA,IAAW,SAAS,GAAA;AAChB,QAAA,OAAO,KAAK,CAAC,mBAAmB,CAAC,IAAI,CAAC,GAAG;cACnC,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG;cACvC,IAAI;;8GAvBL,UAAU,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAAV,IAAA,SAAA,IAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,UAAU,cAFP,MAAM,EAAA,CAAA,CAAA;;2FAET,UAAU,EAAA,UAAA,EAAA,CAAA;kBAHtB,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,UAAU,EAAE;AACf,iBAAA;;;MCIY,cAAc,CAAA;8GAAd,cAAc,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;+GAAd,cAAc,EAAA,CAAA,CAAA;AAAd,IAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,cAAc,EAJZ,SAAA,EAAA;YACP;AACH,SAAA,EAAA,CAAA,CAAA;;2FAEQ,cAAc,EAAA,UAAA,EAAA,CAAA;kBAL1B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACN,oBAAA,SAAS,EAAE;wBACP;AACH;AACJ,iBAAA;;;ACTD;;AAEG;;;;"}
@@ -1511,381 +1511,221 @@ class Service {
1511
1511
  /** HTTP GET */
1512
1512
  HTTP_GET(request, cancelPrevious = true) {
1513
1513
  return new Promise(Resolve => {
1514
+ let subscription;
1514
1515
  if (cancelPrevious) {
1515
- this.ReleaseSubscription(this._GET$);
1516
- this._GET$ = this.http.request(new HttpRequest("GET", request.url, {
1517
- params: request.queryParams,
1518
- headers: request.headers,
1519
- responseType: request.responseType,
1520
- withCredentials: request.withCredentials
1521
- })).subscribe({
1522
- next: (response) => {
1523
- if (response.type > 0) {
1524
- Resolve({
1525
- body: response.body,
1526
- status: response.status,
1527
- message: response.statusText,
1528
- ok: true
1529
- });
1530
- }
1531
- },
1532
- error: (httpError) => {
1533
- this.ReleaseSubscription(this._GET$);
1534
- this.AlertError(httpError, request.alertError);
1535
- Resolve({
1536
- body: {},
1537
- status: httpError.status,
1538
- message: httpError.error?.message || httpError.error,
1539
- ok: false
1540
- });
1541
- },
1542
- complete: () => {
1543
- this.ReleaseSubscription(this._GET$);
1544
- if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
1545
- this.alert.Success(request.alertSuccess);
1546
- }
1547
- }
1548
- });
1516
+ let subscription = this._GET$;
1517
+ this.ReleaseSubscription(subscription);
1549
1518
  }
1550
- else {
1551
- const subscription = this.http.request(new HttpRequest("GET", request.url, {
1552
- params: request.queryParams,
1553
- headers: request.headers,
1554
- responseType: request.responseType,
1555
- withCredentials: request.withCredentials
1556
- })).subscribe({
1557
- next: (response) => {
1558
- if (response.type > 0) {
1559
- Resolve({
1560
- body: response.body,
1561
- status: response.status,
1562
- message: response.statusText,
1563
- ok: true
1564
- });
1565
- }
1566
- },
1567
- error: (httpError) => {
1568
- this.ReleaseSubscription(subscription);
1569
- this.AlertError(httpError, request.alertError);
1519
+ const responseType = request?.responseType || 'json';
1520
+ subscription = this.http.request(new HttpRequest("GET", request.url, {
1521
+ params: request.queryParams,
1522
+ headers: request.headers,
1523
+ responseType: responseType,
1524
+ withCredentials: request.withCredentials
1525
+ })).subscribe({
1526
+ next: (response) => {
1527
+ if (response.type > 0) {
1570
1528
  Resolve({
1571
- body: {},
1572
- status: httpError.status,
1573
- message: httpError.error?.message || httpError.error,
1574
- ok: false
1529
+ body: responseType == 'text' ? response : response.body,
1530
+ status: response.status,
1531
+ message: response.statusText,
1532
+ ok: true
1575
1533
  });
1576
- },
1577
- complete: () => {
1578
- this.ReleaseSubscription(subscription);
1579
- if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
1580
- this.alert.Success(request.alertSuccess);
1581
- }
1582
1534
  }
1583
- });
1584
- }
1535
+ },
1536
+ error: (httpError) => {
1537
+ this.ReleaseSubscription(subscription);
1538
+ this.AlertError(httpError, request.alertError);
1539
+ Resolve({
1540
+ body: {},
1541
+ status: httpError.status,
1542
+ message: httpError.error?.message || httpError.error,
1543
+ ok: false
1544
+ });
1545
+ },
1546
+ complete: () => {
1547
+ this.ReleaseSubscription(subscription);
1548
+ if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
1549
+ this.alert.Success(request.alertSuccess);
1550
+ }
1551
+ }
1552
+ });
1585
1553
  });
1586
1554
  }
1587
1555
  /** HTTP POST */
1588
1556
  HTTP_POST(request, cancelPrevious = true) {
1589
1557
  return new Promise(Resolve => {
1558
+ let subscription;
1590
1559
  if (cancelPrevious) {
1591
- this.ReleaseSubscription(this._POST$);
1592
- this._POST$ = this.http.request(new HttpRequest("POST", request.url, request.body, {
1593
- params: request.queryParams,
1594
- headers: request.headers,
1595
- responseType: request.responseType,
1596
- withCredentials: request.withCredentials
1597
- })).subscribe({
1598
- next: (response) => {
1599
- if (response.type > 0) {
1600
- Resolve({
1601
- body: response.body,
1602
- status: response.status,
1603
- message: response.statusText,
1604
- ok: true
1605
- });
1606
- }
1607
- },
1608
- error: (httpError) => {
1609
- this.ReleaseSubscription(this._POST$);
1610
- this.AlertError(httpError, request.alertError);
1611
- Resolve({
1612
- body: {},
1613
- status: httpError.status,
1614
- message: httpError.error?.message || httpError.error,
1615
- ok: false
1616
- });
1617
- },
1618
- complete: () => {
1619
- this.ReleaseSubscription(this._POST$);
1620
- if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
1621
- this.alert.Success(request.alertSuccess);
1622
- }
1623
- }
1624
- });
1560
+ let subscription = this._POST$;
1561
+ this.ReleaseSubscription(subscription);
1625
1562
  }
1626
- else {
1627
- const subscription = this.http.request(new HttpRequest("POST", request.url, request.body, {
1628
- params: request.queryParams,
1629
- headers: request.headers,
1630
- responseType: request.responseType,
1631
- withCredentials: request.withCredentials
1632
- })).subscribe({
1633
- next: (response) => {
1634
- if (response.type > 0) {
1635
- Resolve({
1636
- body: response.body,
1637
- status: response.status,
1638
- message: response.statusText,
1639
- ok: true
1640
- });
1641
- }
1642
- },
1643
- error: (httpError) => {
1644
- this.ReleaseSubscription(subscription);
1645
- this.AlertError(httpError, request.alertError);
1563
+ const responseType = request?.responseType || 'json';
1564
+ subscription = this.http.request(new HttpRequest("POST", request.url, request.body, {
1565
+ params: request.queryParams,
1566
+ headers: request.headers,
1567
+ responseType: responseType,
1568
+ withCredentials: request.withCredentials
1569
+ })).subscribe({
1570
+ next: (response) => {
1571
+ if (response.type > 0) {
1646
1572
  Resolve({
1647
- body: {},
1648
- status: httpError.status,
1649
- message: httpError.error?.message || httpError.error,
1650
- ok: false
1573
+ body: responseType == 'text' ? response : response.body,
1574
+ status: response.status,
1575
+ message: response.statusText,
1576
+ ok: true
1651
1577
  });
1652
- },
1653
- complete: () => {
1654
- this.ReleaseSubscription(subscription);
1655
- if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
1656
- this.alert.Success(request.alertSuccess);
1657
- }
1658
1578
  }
1659
- });
1660
- }
1579
+ },
1580
+ error: (httpError) => {
1581
+ this.ReleaseSubscription(subscription);
1582
+ this.AlertError(httpError, request.alertError);
1583
+ Resolve({
1584
+ body: {},
1585
+ status: httpError.status,
1586
+ message: httpError.error?.message || httpError.error,
1587
+ ok: false
1588
+ });
1589
+ },
1590
+ complete: () => {
1591
+ this.ReleaseSubscription(subscription);
1592
+ if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
1593
+ this.alert.Success(request.alertSuccess);
1594
+ }
1595
+ }
1596
+ });
1661
1597
  });
1662
1598
  }
1663
1599
  /** HTTP PUT */
1664
1600
  HTTP_PUT(request, cancelPrevious = true) {
1665
1601
  return new Promise(Resolve => {
1602
+ let subscription;
1666
1603
  if (cancelPrevious) {
1667
- this.ReleaseSubscription(this._PUT$);
1668
- this._PUT$ = this.http.request(new HttpRequest("PUT", request.url, request.body, {
1669
- params: request.queryParams,
1670
- headers: request.headers,
1671
- responseType: request.responseType,
1672
- withCredentials: request.withCredentials
1673
- })).subscribe({
1674
- next: (response) => {
1675
- if (response.type > 0) {
1676
- Resolve({
1677
- body: {},
1678
- status: response.status,
1679
- message: response.statusText,
1680
- ok: true
1681
- });
1682
- }
1683
- },
1684
- error: (httpError) => {
1685
- this.ReleaseSubscription(this._PUT$);
1686
- this.AlertError(httpError, request.alertError);
1687
- Resolve({
1688
- body: {},
1689
- status: httpError.status,
1690
- message: httpError.error?.message || httpError.error,
1691
- ok: false
1692
- });
1693
- },
1694
- complete: () => {
1695
- this.ReleaseSubscription(this._PUT$);
1696
- if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
1697
- this.alert.Success(request.alertSuccess, 'Updated', 'fa-solid fa-arrows-rotate fa-spin');
1698
- }
1699
- }
1700
- });
1604
+ let subscription = this._PUT$;
1605
+ this.ReleaseSubscription(subscription);
1701
1606
  }
1702
- else {
1703
- const subscription = this.http.request(new HttpRequest("PUT", request.url, request.body, {
1704
- params: request.queryParams,
1705
- headers: request.headers,
1706
- responseType: request.responseType,
1707
- withCredentials: request.withCredentials
1708
- })).subscribe({
1709
- next: (response) => {
1710
- if (response.type > 0) {
1711
- Resolve({
1712
- body: {},
1713
- status: response.status,
1714
- message: response.statusText,
1715
- ok: true
1716
- });
1717
- }
1718
- },
1719
- error: (httpError) => {
1720
- this.ReleaseSubscription(subscription);
1721
- this.AlertError(httpError, request.alertError);
1607
+ const responseType = request?.responseType || 'json';
1608
+ subscription = this.http.request(new HttpRequest("PUT", request.url, request.body, {
1609
+ params: request.queryParams,
1610
+ headers: request.headers,
1611
+ responseType: responseType,
1612
+ withCredentials: request.withCredentials
1613
+ })).subscribe({
1614
+ next: (response) => {
1615
+ if (response.type > 0) {
1722
1616
  Resolve({
1723
- body: {},
1724
- status: httpError.status,
1725
- message: httpError.error?.message || httpError.error,
1726
- ok: false
1617
+ body: responseType == 'text' ? response : {},
1618
+ status: response.status,
1619
+ message: response.statusText,
1620
+ ok: true
1727
1621
  });
1728
- },
1729
- complete: () => {
1730
- this.ReleaseSubscription(subscription);
1731
- if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
1732
- this.alert.Success(request.alertSuccess, 'Updated', 'fa-solid fa-arrows-rotate fa-spin');
1733
- }
1734
1622
  }
1735
- });
1736
- }
1623
+ },
1624
+ error: (httpError) => {
1625
+ this.ReleaseSubscription(subscription);
1626
+ this.AlertError(httpError, request.alertError);
1627
+ Resolve({
1628
+ body: {},
1629
+ status: httpError.status,
1630
+ message: httpError.error?.message || httpError.error,
1631
+ ok: false
1632
+ });
1633
+ },
1634
+ complete: () => {
1635
+ this.ReleaseSubscription(subscription);
1636
+ if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
1637
+ this.alert.Success(request.alertSuccess, 'Updated', 'fa-solid fa-arrows-rotate fa-spin');
1638
+ }
1639
+ }
1640
+ });
1737
1641
  });
1738
1642
  }
1739
1643
  /** HTTP PATCH */
1740
1644
  HTTP_PATCH(request, cancelPrevious = true) {
1741
1645
  return new Promise(Resolve => {
1646
+ let subscription;
1742
1647
  if (cancelPrevious) {
1743
- this.ReleaseSubscription(this._PATCH$);
1744
- this._PATCH$ = this.http.request(new HttpRequest("PATCH", request.url, request.body, {
1745
- params: request.queryParams,
1746
- headers: request.headers,
1747
- responseType: request.responseType,
1748
- withCredentials: request.withCredentials
1749
- })).subscribe({
1750
- next: (response) => {
1751
- if (response.type > 0) {
1752
- Resolve({
1753
- body: {},
1754
- status: response.status,
1755
- message: response.statusText,
1756
- ok: true
1757
- });
1758
- }
1759
- },
1760
- error: (httpError) => {
1761
- this.ReleaseSubscription(this._PATCH$);
1762
- this.AlertError(httpError, request.alertError);
1763
- Resolve({
1764
- body: {},
1765
- status: httpError.status,
1766
- message: httpError.error?.message || httpError.error,
1767
- ok: false
1768
- });
1769
- },
1770
- complete: () => {
1771
- this.ReleaseSubscription(this._PATCH$);
1772
- if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
1773
- this.alert.Success(request.alertSuccess, 'Updated', 'fa-solid fa-arrows-rotate fa-spin');
1774
- }
1775
- }
1776
- });
1648
+ let subscription = this._PATCH$;
1649
+ this.ReleaseSubscription(subscription);
1777
1650
  }
1778
- else {
1779
- const subscription = this.http.request(new HttpRequest("PATCH", request.url, request.body, {
1780
- params: request.queryParams,
1781
- headers: request.headers,
1782
- responseType: request.responseType,
1783
- withCredentials: request.withCredentials
1784
- })).subscribe({
1785
- next: (response) => {
1786
- if (response.type > 0) {
1787
- Resolve({
1788
- body: {},
1789
- status: response.status,
1790
- message: response.statusText,
1791
- ok: true
1792
- });
1793
- }
1794
- },
1795
- error: (httpError) => {
1796
- this.ReleaseSubscription(subscription);
1797
- this.AlertError(httpError, request.alertError);
1651
+ const responseType = request?.responseType || 'json';
1652
+ subscription = this.http.request(new HttpRequest("PATCH", request.url, request.body, {
1653
+ params: request.queryParams,
1654
+ headers: request.headers,
1655
+ responseType: responseType,
1656
+ withCredentials: request.withCredentials
1657
+ })).subscribe({
1658
+ next: (response) => {
1659
+ if (response.type > 0) {
1798
1660
  Resolve({
1799
- body: {},
1800
- status: httpError.status,
1801
- message: httpError.error?.message || httpError.error,
1802
- ok: false
1661
+ body: responseType == 'text' ? response : {},
1662
+ status: response.status,
1663
+ message: response.statusText,
1664
+ ok: true
1803
1665
  });
1804
- },
1805
- complete: () => {
1806
- this.ReleaseSubscription(subscription);
1807
- if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
1808
- this.alert.Success(request.alertSuccess, 'Updated', 'fa-solid fa-arrows-rotate fa-spin');
1809
- }
1810
1666
  }
1811
- });
1812
- }
1667
+ },
1668
+ error: (httpError) => {
1669
+ this.ReleaseSubscription(subscription);
1670
+ this.AlertError(httpError, request.alertError);
1671
+ Resolve({
1672
+ body: {},
1673
+ status: httpError.status,
1674
+ message: httpError.error?.message || httpError.error,
1675
+ ok: false
1676
+ });
1677
+ },
1678
+ complete: () => {
1679
+ this.ReleaseSubscription(subscription);
1680
+ if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
1681
+ this.alert.Success(request.alertSuccess, 'Updated', 'fa-solid fa-arrows-rotate fa-spin');
1682
+ }
1683
+ }
1684
+ });
1813
1685
  });
1814
1686
  }
1815
1687
  /** HTTP DELETE */
1816
1688
  HTTP_DELETE(request, cancelPrevious = true) {
1817
1689
  return new Promise(Resolve => {
1690
+ let subscription;
1818
1691
  if (cancelPrevious) {
1819
- this.ReleaseSubscription(this._DELETE$);
1820
- this._DELETE$ = this.http.request(new HttpRequest("DELETE", request.url, {
1821
- params: request.queryParams,
1822
- headers: request.headers,
1823
- responseType: request.responseType,
1824
- withCredentials: request.withCredentials
1825
- })).subscribe({
1826
- next: (response) => {
1827
- if (response.type > 0) {
1828
- Resolve({
1829
- body: {},
1830
- status: response.status,
1831
- message: response.statusText,
1832
- ok: true
1833
- });
1834
- }
1835
- },
1836
- error: (httpError) => {
1837
- this.ReleaseSubscription(this._DELETE$);
1838
- this.AlertError(httpError, request.alertError);
1839
- Resolve({
1840
- body: {},
1841
- status: httpError.status,
1842
- message: httpError.error?.message || httpError.error,
1843
- ok: false
1844
- });
1845
- },
1846
- complete: () => {
1847
- this.ReleaseSubscription(this._DELETE$);
1848
- if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
1849
- this.alert.Success(request.alertSuccess, 'Deleted', 'fa-regular fa-trash-can');
1850
- }
1851
- }
1852
- });
1692
+ let subscription = this._DELETE$;
1693
+ this.ReleaseSubscription(subscription);
1853
1694
  }
1854
- else {
1855
- const subscription = this.http.request(new HttpRequest("DELETE", request.url, {
1856
- params: request.queryParams,
1857
- headers: request.headers,
1858
- responseType: request.responseType,
1859
- withCredentials: request.withCredentials
1860
- })).subscribe({
1861
- next: (response) => {
1862
- if (response.type > 0) {
1863
- Resolve({
1864
- body: {},
1865
- status: response.status,
1866
- message: response.statusText,
1867
- ok: true
1868
- });
1869
- }
1870
- },
1871
- error: (httpError) => {
1872
- this.ReleaseSubscription(subscription);
1873
- this.AlertError(httpError, request.alertError);
1695
+ const responseType = request?.responseType || 'json';
1696
+ subscription = this.http.request(new HttpRequest("DELETE", request.url, {
1697
+ params: request.queryParams,
1698
+ headers: request.headers,
1699
+ responseType: responseType,
1700
+ withCredentials: request.withCredentials
1701
+ })).subscribe({
1702
+ next: (response) => {
1703
+ if (response.type > 0) {
1874
1704
  Resolve({
1875
- body: {},
1876
- status: httpError.status,
1877
- message: httpError.error?.message || httpError.error,
1878
- ok: false
1705
+ body: responseType == 'text' ? response : {},
1706
+ status: response.status,
1707
+ message: response.statusText,
1708
+ ok: true
1879
1709
  });
1880
- },
1881
- complete: () => {
1882
- this.ReleaseSubscription(subscription);
1883
- if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
1884
- this.alert.Success(request.alertSuccess, 'Deleted', 'fa-regular fa-trash-can');
1885
- }
1886
1710
  }
1887
- });
1888
- }
1711
+ },
1712
+ error: (httpError) => {
1713
+ this.ReleaseSubscription(subscription);
1714
+ this.AlertError(httpError, request.alertError);
1715
+ Resolve({
1716
+ body: {},
1717
+ status: httpError.status,
1718
+ message: httpError.error?.message || httpError.error,
1719
+ ok: false
1720
+ });
1721
+ },
1722
+ complete: () => {
1723
+ this.ReleaseSubscription(subscription);
1724
+ if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
1725
+ this.alert.Success(request.alertSuccess, 'Deleted', 'fa-regular fa-trash-can');
1726
+ }
1727
+ }
1728
+ });
1889
1729
  });
1890
1730
  }
1891
1731
  /** */