@pongrass/utils 0.0.3-v20 → 1.0.1-v20

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.
@@ -7,7 +7,7 @@ import { FormsModule, NgControl, FormBuilder, Validators, ReactiveFormsModule }
7
7
  import * as i2$1 from '@coreui/angular-pro';
8
8
  import { FormModule, ButtonModule, MultiSelectModule, MultiSelectComponent, InputGroupComponent, DatePickerModule, ModalModule, TooltipModule, OffcanvasModule } from '@coreui/angular-pro';
9
9
  import { HttpClient, HttpHeaders } from '@angular/common/http';
10
- import { lastValueFrom, map, Subject } from 'rxjs';
10
+ import { map, lastValueFrom, Subject } from 'rxjs';
11
11
  import * as i5 from '@coreui/icons-angular';
12
12
  import { IconModule } from '@coreui/icons-angular';
13
13
  import * as i8 from 'ngx-bootstrap/datepicker';
@@ -26,10 +26,12 @@ class ConfigurationServiceLib {
26
26
  currentTablePreference;
27
27
  allConfigValues;
28
28
  openFilterModal;
29
+ utilsAppliedTheme;
29
30
  constructor() {
30
31
  this.currentTablePreference = signal({}, ...(ngDevMode ? [{ debugName: "currentTablePreference" }] : []));
31
32
  this.allConfigValues = signal(null, ...(ngDevMode ? [{ debugName: "allConfigValues" }] : []));
32
33
  this.openFilterModal = signal(false, ...(ngDevMode ? [{ debugName: "openFilterModal" }] : []));
34
+ this.utilsAppliedTheme = signal('', ...(ngDevMode ? [{ debugName: "utilsAppliedTheme" }] : []));
33
35
  }
34
36
  /* Generate Unique ID as String */
35
37
  generateUniqueId() {
@@ -363,50 +365,138 @@ var JSONRPCMethods;
363
365
  JSONRPCMethods["getIndustryList"] = "get_industry";
364
366
  })(JSONRPCMethods || (JSONRPCMethods = {}));
365
367
 
366
- class UtilsService {
368
+ /* eslint-disable @typescript-eslint/no-explicit-any */
369
+ class JsonrpcServiceLib {
367
370
  httpService = inject(HttpClient);
368
- configurationServiceLib = inject(ConfigurationServiceLib);
369
- allConfigValues = this.configurationServiceLib.allConfigValues() || {};
370
- constructor() { }
371
- // JSONRPC POST Request With promise
372
- async postJsonRpcRequestPromiseLib(method, params) {
371
+ configService = inject(ConfigurationServiceLib);
372
+ // JSONRPC POST Request
373
+ postJsonRpcRequest(method, params) {
373
374
  const headers = new HttpHeaders({ 'Content-Type': 'application/json' });
374
375
  const body = {
375
376
  jsonrpc: '2.0',
376
377
  method: method,
377
378
  params: params,
378
- id: this.configurationServiceLib.generateUniqueId()
379
+ id: this.configService.generateUniqueId()
379
380
  };
380
- const request$ = this.httpService.post(this.allConfigValues.apiBaseURLWebMaint, body, { headers });
381
- const response = await lastValueFrom(request$);
382
- return { ...response, timestamp: new Date().toISOString() };
381
+ return this.httpService
382
+ .post(window.config.apiBaseURLWebMaint, body, { headers })
383
+ .pipe(map(response => ({ ...response, timestamp: new Date().toISOString() })));
383
384
  }
384
- // JSONRPC POST Request
385
- postJsonRpcRequest(method, params) {
385
+ // JSONRPC POST Request With promise
386
+ async postJsonRpcRequestPromise(method, params) {
386
387
  const headers = new HttpHeaders({ 'Content-Type': 'application/json' });
387
388
  const body = {
388
389
  jsonrpc: '2.0',
389
390
  method: method,
390
391
  params: params,
391
- id: this.configurationServiceLib.generateUniqueId()
392
+ id: this.configService.generateUniqueId()
392
393
  };
393
- return this.httpService
394
- .post(window.config.apiBaseURLWebMaint, body, { headers })
395
- .pipe(map(response => ({ ...response, timestamp: new Date().toISOString() })));
394
+ const request$ = this.httpService.post(window.config.apiBaseURLWebMaint, body, { headers });
395
+ const response = await lastValueFrom(request$);
396
+ return { ...response, timestamp: new Date().toISOString() };
396
397
  }
397
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: UtilsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
398
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: UtilsService, providedIn: 'root' });
398
+ /**
399
+ *
400
+ * @param formName Form config name
401
+ * @param tableName Table Name
402
+ */
403
+ async getFormConfig(formName, tableName) {
404
+ const params = {
405
+ uid: +localStorage.getItem(BrowserConstantsEnum.loginUid),
406
+ form_name: formName,
407
+ table_name: tableName
408
+ };
409
+ return this.postJsonRpcRequestPromise(JSONRPCMethods.getFormsConfig, params)
410
+ .then((response) => {
411
+ return response.result ? response.result[0] : { rows: [] };
412
+ })
413
+ .finally(() => { });
414
+ }
415
+ /**
416
+ *
417
+ * @param formName Report config name
418
+ * @param reportName Table Name
419
+ */
420
+ async getFormConfigReports(formName, reportName) {
421
+ const params = {
422
+ uid: +localStorage.getItem(BrowserConstantsEnum.loginUid),
423
+ form_name: formName,
424
+ report_name: reportName
425
+ };
426
+ return this.postJsonRpcRequestPromise(JSONRPCMethods.report, params)
427
+ .then((response) => {
428
+ return response.result ? response.result[0] : { rows: [] };
429
+ })
430
+ .finally(() => { });
431
+ }
432
+ /** Get available forms */
433
+ async getTableConfig(tableName) {
434
+ try {
435
+ const response = await this.postJsonRpcRequestPromise(JSONRPCMethods.getFormsConfig, {
436
+ uid: +localStorage.getItem(BrowserConstantsEnum.loginUid),
437
+ table_name: tableName
438
+ });
439
+ if (response.result) {
440
+ return response.result;
441
+ }
442
+ return [];
443
+ }
444
+ catch (error) {
445
+ return [];
446
+ }
447
+ }
448
+ /** Get single row data by their params */
449
+ async getTableRow(tableName, param) {
450
+ let params = {
451
+ uid: +localStorage.getItem(BrowserConstantsEnum.loginUid),
452
+ table_name: tableName
453
+ };
454
+ params = { ...params, ...param };
455
+ return await this.postJsonRpcRequestPromise(JSONRPCMethods.tableSearch, params);
456
+ }
457
+ /**
458
+ *
459
+ * @param tableName Table Name
460
+ * @param param Form values and params needed fo the call
461
+ * @param action 'U' for update and 'N' for create and 'D' for delete
462
+ * @returns Promise<any>
463
+ */
464
+ async createUpdateDeleteTableRow(tableName, requests, action) {
465
+ let params = {
466
+ uid: +localStorage.getItem(BrowserConstantsEnum.loginUid),
467
+ table_name: tableName,
468
+ maint_action: action
469
+ };
470
+ params = { ...params, ...requests };
471
+ return await this.postJsonRpcRequestPromise(JSONRPCMethods.tableUpdate, params);
472
+ }
473
+ /**
474
+ *
475
+ * @param tableName Table Name
476
+ * @param param Params to get the list of data
477
+ * @returns Array of data
478
+ */
479
+ async getTableList(tableName, param) {
480
+ let params = {
481
+ uid: +localStorage.getItem(BrowserConstantsEnum.loginUid),
482
+ table_name: tableName
483
+ };
484
+ params = { ...params, ...param };
485
+ return await this.postJsonRpcRequestPromise(JSONRPCMethods.tableList, params);
486
+ }
487
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: JsonrpcServiceLib, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
488
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: JsonrpcServiceLib, providedIn: 'root' });
399
489
  }
400
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: UtilsService, decorators: [{
490
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: JsonrpcServiceLib, decorators: [{
401
491
  type: Injectable,
402
492
  args: [{
403
493
  providedIn: 'root'
404
494
  }]
405
- }], ctorParameters: () => [] });
495
+ }] });
406
496
 
407
497
  /* eslint-disable @typescript-eslint/no-explicit-any */
408
498
  class EditionListGroupedComponent {
409
- utilsService = inject(UtilsService);
499
+ jsonrpcService = inject(JsonrpcServiceLib);
410
500
  isActive;
411
501
  editionPublicationList;
412
502
  selectedRegions;
@@ -435,8 +525,8 @@ class EditionListGroupedComponent {
435
525
  uid: +localStorage.getItem(BrowserConstantsEnum.loginUid),
436
526
  for_approval: true
437
527
  };
438
- await this.utilsService
439
- .postJsonRpcRequestPromiseLib(JSONRPCMethods.getEditionPublicationList, params)
528
+ await this.jsonrpcService
529
+ .postJsonRpcRequestPromise(JSONRPCMethods.getEditionPublicationList, params)
440
530
  .then((response) => {
441
531
  if (response.result) {
442
532
  const result = response.result;
@@ -611,135 +701,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImpor
611
701
  args: [{ standalone: true, imports: [FormModule, CommonModule, FormsModule], selector: 'app-status-select-cell-renderer', template: "<div class=\"wrapper-production-status-select\">\n <select\n class=\"status-dropdown\"\n aria-label=\"status-dropdown\"\n cSelect\n sizing=\"sm\"\n (click)=\"$event.stopPropagation()\"\n [ngModel]=\"this.fileStatus!.it_prodstatusid\"\n (ngModelChange)=\"updatePageStatus($event)\"\n [ngStyle]=\"{ '--select-background': getStatusColor() }\">\n @for (status of prodStatusList; track $index) {\n <option [value]=\"status.statusid\">\n {{ status.statusdesc }}\n </option>\n }\n </select>\n</div>\n", styles: [".status-dropdown:not(.options){background-color:var(--select-background)}.status-dropdown option{background-color:#fff;color:#000}\n"] }]
612
702
  }] });
613
703
 
614
- /* eslint-disable @typescript-eslint/no-explicit-any */
615
- class JsonrpcService {
616
- httpService = inject(HttpClient);
617
- configService = inject(ConfigurationServiceLib);
618
- // JSONRPC POST Request
619
- postJsonRpcRequest(method, params) {
620
- const headers = new HttpHeaders({ 'Content-Type': 'application/json' });
621
- const body = {
622
- jsonrpc: '2.0',
623
- method: method,
624
- params: params,
625
- id: this.configService.generateUniqueId()
626
- };
627
- return this.httpService
628
- .post(window.config.apiBaseURLWebMaint, body, { headers })
629
- .pipe(map(response => ({ ...response, timestamp: new Date().toISOString() })));
630
- }
631
- // JSONRPC POST Request With promise
632
- async postJsonRpcRequestPromise(method, params) {
633
- const headers = new HttpHeaders({ 'Content-Type': 'application/json' });
634
- const body = {
635
- jsonrpc: '2.0',
636
- method: method,
637
- params: params,
638
- id: this.configService.generateUniqueId()
639
- };
640
- const request$ = this.httpService.post(window.config.apiBaseURLWebMaint, body, { headers });
641
- const response = await lastValueFrom(request$);
642
- return { ...response, timestamp: new Date().toISOString() };
643
- }
644
- /**
645
- *
646
- * @param formName Form config name
647
- * @param tableName Table Name
648
- */
649
- async getFormConfig(formName, tableName) {
650
- const params = {
651
- uid: +localStorage.getItem(BrowserConstantsEnum.loginUid),
652
- form_name: formName,
653
- table_name: tableName
654
- };
655
- return this.postJsonRpcRequestPromise(JSONRPCMethods.getFormsConfig, params)
656
- .then((response) => {
657
- return response.result ? response.result[0] : { rows: [] };
658
- })
659
- .finally(() => { });
660
- }
661
- /**
662
- *
663
- * @param formName Report config name
664
- * @param reportName Table Name
665
- */
666
- async getFormConfigReports(formName, reportName) {
667
- const params = {
668
- uid: +localStorage.getItem(BrowserConstantsEnum.loginUid),
669
- form_name: formName,
670
- report_name: reportName
671
- };
672
- return this.postJsonRpcRequestPromise(JSONRPCMethods.report, params)
673
- .then((response) => {
674
- return response.result ? response.result[0] : { rows: [] };
675
- })
676
- .finally(() => { });
677
- }
678
- /** Get available forms */
679
- async getTableConfig(tableName) {
680
- try {
681
- const response = await this.postJsonRpcRequestPromise(JSONRPCMethods.getFormsConfig, {
682
- uid: +localStorage.getItem(BrowserConstantsEnum.loginUid),
683
- table_name: tableName
684
- });
685
- if (response.result) {
686
- return response.result;
687
- }
688
- return [];
689
- }
690
- catch (error) {
691
- return [];
692
- }
693
- }
694
- /** Get single row data by their params */
695
- async getTableRow(tableName, param) {
696
- let params = {
697
- uid: +localStorage.getItem(BrowserConstantsEnum.loginUid),
698
- table_name: tableName
699
- };
700
- params = { ...params, ...param };
701
- return await this.postJsonRpcRequestPromise(JSONRPCMethods.tableSearch, params);
702
- }
703
- /**
704
- *
705
- * @param tableName Table Name
706
- * @param param Form values and params needed fo the call
707
- * @param action 'U' for update and 'N' for create and 'D' for delete
708
- * @returns Promise<any>
709
- */
710
- async createUpdateDeleteTableRow(tableName, requests, action) {
711
- let params = {
712
- uid: +localStorage.getItem(BrowserConstantsEnum.loginUid),
713
- table_name: tableName,
714
- maint_action: action
715
- };
716
- params = { ...params, ...requests };
717
- return await this.postJsonRpcRequestPromise(JSONRPCMethods.tableUpdate, params);
718
- }
719
- /**
720
- *
721
- * @param tableName Table Name
722
- * @param param Params to get the list of data
723
- * @returns Array of data
724
- */
725
- async getTableList(tableName, param) {
726
- let params = {
727
- uid: +localStorage.getItem(BrowserConstantsEnum.loginUid),
728
- table_name: tableName
729
- };
730
- params = { ...params, ...param };
731
- return await this.postJsonRpcRequestPromise(JSONRPCMethods.tableList, params);
732
- }
733
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: JsonrpcService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
734
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: JsonrpcService, providedIn: 'root' });
735
- }
736
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: JsonrpcService, decorators: [{
737
- type: Injectable,
738
- args: [{
739
- providedIn: 'root'
740
- }]
741
- }] });
742
-
743
704
  var FormFieldType;
744
705
  (function (FormFieldType) {
745
706
  FormFieldType["Text"] = "text";
@@ -1608,7 +1569,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImpor
1608
1569
  /* eslint-disable @typescript-eslint/no-explicit-any */
1609
1570
  class GenericFilterModelComponent {
1610
1571
  configurationService = inject(ConfigurationServiceLib);
1611
- jsonrpcService = inject(JsonrpcService);
1572
+ jsonrpcService = inject(JsonrpcServiceLib);
1612
1573
  filterFormConfiguration = [];
1613
1574
  tableName = '';
1614
1575
  sendFilteredData;
@@ -1694,7 +1655,7 @@ const MessageLabel = {
1694
1655
 
1695
1656
  class TableGridComponent {
1696
1657
  formBuilder = inject(FormBuilder);
1697
- utilsService = inject(UtilsService);
1658
+ jsonrpcService = inject(JsonrpcServiceLib);
1698
1659
  toastrService = inject(ToastrService);
1699
1660
  configurationService = inject(ConfigurationServiceLib);
1700
1661
  tableConfiguration;
@@ -1764,11 +1725,12 @@ class TableGridComponent {
1764
1725
  this.initialPageNumber = 0;
1765
1726
  this.tableGridState = [];
1766
1727
  effect(() => {
1767
- // if (this.layoutService.appliedTheme() === 'dark') {
1768
- // this.tableConfiguration.tableTheme = `${this.tableConfiguration.themeClass}-dark`;
1769
- // } else {
1770
- // this.tableConfiguration.tableTheme = this.tableConfiguration.themeClass;
1771
- // }
1728
+ if (this.configurationService.utilsAppliedTheme() === 'dark') {
1729
+ this.tableConfiguration.tableTheme = `${this.tableConfiguration.themeClass}-dark`;
1730
+ }
1731
+ else {
1732
+ this.tableConfiguration.tableTheme = this.tableConfiguration.themeClass;
1733
+ }
1772
1734
  });
1773
1735
  }
1774
1736
  ngOnChanges(changes) {
@@ -1955,7 +1917,7 @@ class TableGridComponent {
1955
1917
  table_name: this.tableConfiguration.tablename,
1956
1918
  maint_action: 'D'
1957
1919
  };
1958
- this.utilsService.postJsonRpcRequest(JSONRPCMethods.updateTablePreference, params).subscribe({
1920
+ this.jsonrpcService.postJsonRpcRequest(JSONRPCMethods.updateTablePreference, params).subscribe({
1959
1921
  next: (response) => {
1960
1922
  if (response.result) {
1961
1923
  this.tableGridState = [];
@@ -2006,7 +1968,7 @@ class TableGridComponent {
2006
1968
  table_name: this.tableConfiguration.tablename,
2007
1969
  display_options: this.tableGridState
2008
1970
  };
2009
- this.utilsService.postJsonRpcRequest(JSONRPCMethods.updateTablePreference, params).subscribe({
1971
+ this.jsonrpcService.postJsonRpcRequest(JSONRPCMethods.updateTablePreference, params).subscribe({
2010
1972
  next: (response) => {
2011
1973
  if (response?.result) {
2012
1974
  this.handleSuccessfulReset(response.result);
@@ -2173,5 +2135,5 @@ class ITableGridPagination {
2173
2135
  * Generated bundle index. Do not edit.
2174
2136
  */
2175
2137
 
2176
- export { CheckboxCellRendererComponent, ColorCellRendererComponent, CommentsButtonCellRendererComponent, ConfigurationServiceLib, CustomSelectFilterComponent, EditionListGroupedComponent, FormFieldType, GenericFilterModelComponent, ITableGridConfiguration, ITableGridPagination, IndustryUpdateListboxCellRendererComponent, MultiFormComponent, MultiFormModule, PageStatusCellRendererComponent, StatusSelectCellRendererComponent, TableGridComponent, TableGridModule };
2138
+ export { CheckboxCellRendererComponent, CircularFocusDirective, ColorCellRendererComponent, CommentsButtonCellRendererComponent, ConfigurationServiceLib, CustomSelectFilterComponent, DecimalInputDirective, EditionListGroupedComponent, FormFieldType, GenericFilterModelComponent, ITableGridConfiguration, ITableGridPagination, IndustryUpdateListboxCellRendererComponent, MultiFormComponent, MultiFormModule, MultiSelectStylerDirective, PageStatusCellRendererComponent, ShowTooltipIfTruncatedDirective, StatusSelectCellRendererComponent, TableGridComponent, TableGridModule };
2177
2139
  //# sourceMappingURL=pongrass-utils.mjs.map