|
|
@@ -2,6 +2,7 @@ import { HttpErrorResponse } from '@angular/common/http';
|
|
|
import { Component, AfterViewInit, ViewChild } from '@angular/core';
|
|
|
import { MatDialog } from '@angular/material/dialog';
|
|
|
import { MatPaginator } from '@angular/material/paginator';
|
|
|
+import { MatSort } from '@angular/material/sort';
|
|
|
import { MatTableDataSource } from '@angular/material/table';
|
|
|
import { lastValueFrom } from 'rxjs';
|
|
|
import { AlertData } from 'src/app/interfaces/alert.interface';
|
|
|
@@ -17,7 +18,13 @@ import { GetbsbFormComponent } from './getbsb-form/getbsb-form.component';
|
|
|
styleUrls: ['./getbsb.component.css']
|
|
|
})
|
|
|
export class GETBSBComponent implements AfterViewInit {
|
|
|
- displayedColumns: string[] = ['codigo', 'submodulo', 'modulo', 'estado', 'acciones'];
|
|
|
+ displayedColumns: string[] = [
|
|
|
+ 'CODIGO_SUBMODULO',
|
|
|
+ 'SUBMODULO',
|
|
|
+ 'MODULO',
|
|
|
+ 'FECHA_MOD',
|
|
|
+ 'ESTADO',
|
|
|
+ 'acciones'];
|
|
|
|
|
|
public dataSource: MatTableDataSource<any> = new MatTableDataSource<any>([]);
|
|
|
|
|
|
@@ -31,17 +38,20 @@ export class GETBSBComponent implements AfterViewInit {
|
|
|
public card_size = 'card-size-normal mat-elevation-z8';
|
|
|
|
|
|
@ViewChild(MatPaginator) paginator!: MatPaginator;
|
|
|
+ @ViewChild(MatSort) sort!: MatSort;
|
|
|
|
|
|
constructor(
|
|
|
public dialog: MatDialog,
|
|
|
private _getbsmService: GETBSMService,
|
|
|
- private _resourceService:ResourcesService
|
|
|
- ) {
|
|
|
- this.consultarModulos();
|
|
|
+ private _resourceService: ResourcesService
|
|
|
+ ) {
|
|
|
+ this.consultarSubmodulos();
|
|
|
}
|
|
|
|
|
|
ngAfterViewInit() {
|
|
|
this.dataSource.paginator = this.paginator;
|
|
|
+ this.dataSource.sort = this.sort;
|
|
|
+
|
|
|
if (window.innerWidth <= 721) {
|
|
|
this.btnSmall = true;
|
|
|
this.card_size = 'card-size-small';
|
|
|
@@ -69,11 +79,11 @@ export class GETBSBComponent implements AfterViewInit {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private async consultarModulos() {
|
|
|
+ public async consultarSubmodulos() {
|
|
|
this.isLoading = true;
|
|
|
await lastValueFrom(this._getbsmService.getSubmodules()).then(
|
|
|
(data: ResponseData) => {
|
|
|
- if (!data.error) {
|
|
|
+ if (!data.error) {
|
|
|
this.dataSource.data = data.response;
|
|
|
}
|
|
|
},
|
|
|
@@ -82,7 +92,7 @@ export class GETBSBComponent implements AfterViewInit {
|
|
|
this.isLoading = false;
|
|
|
}
|
|
|
|
|
|
- openDialogVerModulos (data: any) {
|
|
|
+ public openDialogVerModulos(data: any) {
|
|
|
this.dialog.open(GetbsbConsultarModulosComponent, {
|
|
|
data: data,
|
|
|
});
|
|
|
@@ -90,19 +100,19 @@ export class GETBSBComponent implements AfterViewInit {
|
|
|
|
|
|
public async registro(data: any, action: string) {
|
|
|
this.isLoadingComponent = true;
|
|
|
- await this.consultarModulos();
|
|
|
+ await this.consultarSubmodulos();
|
|
|
let dataAction = {
|
|
|
data: data,
|
|
|
action: action
|
|
|
}
|
|
|
const dialogRef = this.dialog.open(GetbsbFormComponent, {
|
|
|
data: dataAction,
|
|
|
- width: '350px',
|
|
|
+ width: '500px',
|
|
|
disableClose: true,
|
|
|
});
|
|
|
|
|
|
- dialogRef.afterClosed().subscribe(result => {
|
|
|
- if (result) this.consultarModulos();
|
|
|
+ dialogRef.afterClosed().subscribe(result => {
|
|
|
+ if (result) this.consultarSubmodulos();
|
|
|
})
|
|
|
this.isLoadingComponent = false;
|
|
|
}
|
|
|
@@ -140,15 +150,23 @@ export class GETBSBComponent implements AfterViewInit {
|
|
|
await lastValueFrom(
|
|
|
this._getbsmService.deleteSubmodule({ codigo: codigo })
|
|
|
).then(
|
|
|
- (data:ResponseData) => {
|
|
|
+ (data: ResponseData) => {
|
|
|
if (!data.error) {
|
|
|
this._resourceService.openSnackBar("¡Eliminación exitosa!");
|
|
|
- this.consultarModulos();
|
|
|
+ this.consultarSubmodulos();
|
|
|
}
|
|
|
},
|
|
|
(error: HttpErrorResponse) => this._resourceService.checkErrors(error)
|
|
|
);
|
|
|
-
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // Método para dar formato a las fechas y horas
|
|
|
+ public dateTimeFormart(date: string): string {
|
|
|
+ let arrDateTime: Array<string> = date.split(' ');
|
|
|
+ let arrDate: Array<string> = arrDateTime[0].split('-');
|
|
|
+ let strDate: string = `${arrDate[2]}/${arrDate[1]}/${arrDate[0]} T${arrDateTime[1]}`;
|
|
|
+ return strDate;
|
|
|
}
|
|
|
}
|
|
|
|