diff --git a/frontend/app/components/monitoring-datatable-g/monitoring-datatable-g.component.ts b/frontend/app/components/monitoring-datatable-g/monitoring-datatable-g.component.ts index 01cafd5bb..e307902b7 100644 --- a/frontend/app/components/monitoring-datatable-g/monitoring-datatable-g.component.ts +++ b/frontend/app/components/monitoring-datatable-g/monitoring-datatable-g.component.ts @@ -81,7 +81,6 @@ export class MonitoringDatatableGComponent implements OnInit { initDatatable() { console.log("Inside initDatatable"); console.log("this.rows", this.rows); - this.filters = {}; this.filterSubject.pipe(debounceTime(500)).subscribe(() => { this.filter(); }); @@ -179,13 +178,17 @@ export class MonitoringDatatableGComponent implements OnInit { ngOnChanges(changes: SimpleChanges) { console.log("inside ngOnChanges"); console.log("changes", changes); - if (changes["rows"] && this.rows) { + if (changes["rows"] && this.rows && this.rows.length > 0) { this.columns = this._dataTableService.colsTable( this.colsname, this.rows[0] ); } + if (changes["colsname"]) { + this.filters = {}; + } + if (changes["obj"] && this.obj) { this.objectsStatus, (this.rowStatus = this._dataTableService.initObjectsStatus( @@ -196,7 +199,7 @@ export class MonitoringDatatableGComponent implements OnInit { for (const propName of Object.keys(changes)) { const chng = changes[propName]; const cur = chng.currentValue; - const pre = chng.currentValue; + const pre = chng.previousValue; switch (propName) { case "rowStatus": this.setSelected(); diff --git a/frontend/app/components/monitoring-sitesgroups/monitoring-sitesgroups.component.ts b/frontend/app/components/monitoring-sitesgroups/monitoring-sitesgroups.component.ts index a3f6a56d9..a6a28d030 100644 --- a/frontend/app/components/monitoring-sitesgroups/monitoring-sitesgroups.component.ts +++ b/frontend/app/components/monitoring-sitesgroups/monitoring-sitesgroups.component.ts @@ -1,8 +1,6 @@ import { Component, OnInit, Input } from "@angular/core"; import { SitesGroupService } from "../../services/sites_group.service"; -import { - columnNameSiteGroup, -} from "../../class/monitoring-sites-group"; +import { columnNameSiteGroup } from "../../class/monitoring-sites-group"; import { IPaginated, IPage } from "../../interfaces/page"; import { Router, @@ -41,15 +39,15 @@ export class MonitoringSitesGroupsComponent implements OnInit { path: string; currentRoute: string = ""; id: string | null; + changeFromTable: boolean = false; private routerSubscription: Subscription; constructor( private _sites_group_service: SitesGroupService, private router: Router, - private _Activatedroute: ActivatedRoute - ) // private _routingService: RoutingService - { + private _Activatedroute: ActivatedRoute // private _routingService: RoutingService + ) { // TODO: Try to refactor into routingService ? // console.log(this.id) // this.id = this._routingService.id @@ -161,12 +159,13 @@ export class MonitoringSitesGroupsComponent implements OnInit { console.log("inside getDataAccording to path, params", params); params["id_sites_group"] = this.id; this.displayDetails = true; - this.getSitesGroupsById( - (page = 1), - (params = { id_sites_group: this.id }) - ); + if (this.changeFromTable == false) { + this.getSitesGroupsById(1, (params = { id_sites_group: this.id })); + } this.getSitesGroupsChild(page, params); + this.changeFromTable = false; } else { + console.log("inside getDataAccording to path, params", params); this.getSitesGroups(page, params); } // }); @@ -174,7 +173,8 @@ export class MonitoringSitesGroupsComponent implements OnInit { setPage($event) { console.log("setPage Sitesgroups Components"); - this.getDataAccordingTopath($event.page + 1, this.filters); + this.changeFromTable = true; + this.getDataAccordingTopath($event.filter + 1, this.filters); } onSortEvent(filters) { @@ -186,6 +186,11 @@ export class MonitoringSitesGroupsComponent implements OnInit { onFilterEvent(filters) { console.log("onFilterEvent sitegroups component, filters", filters); this.filters = filters; + this.changeFromTable = true; + console.log( + "onFilterEvent sitegroups component, this.filters", + this.filters + ); this.getDataAccordingTopath(1, this.filters); }