@@ -7,16 +7,16 @@ import { first, map } from 'rxjs/operators';
77
88import { AlertComponent } from '../ui-components/alert/alert.component' ;
99import { BannerComponent } from '../ui-components/banner/banner.component' ;
10- import { BbBulkActionConfirmationDialogComponent } from './db-bulk-action-confirmation-dialog/db-bulk-action-confirmation-dialog.component' ;
10+ import { BbBulkActionConfirmationDialogComponent } from './db-table-view/db- bulk-action-confirmation-dialog/db-bulk-action-confirmation-dialog.component' ;
1111import { CommonModule } from '@angular/common' ;
1212import { CompanyService } from 'src/app/services/company.service' ;
1313import { ConnectionsService } from 'src/app/services/connections.service' ;
1414import { ContentLoaderComponent } from '../ui-components/content-loader/content-loader.component' ;
15- import { DbActionLinkDialogComponent } from './db-action-link-dialog/db-action-link-dialog.component' ;
16- import { DbTableAiPanelComponent } from './db-table-ai-panel/db-table-ai-panel.component' ;
17- import { DbTableComponent } from './db-table/db-table.component' ;
18- import { DbTableFiltersDialogComponent } from './db-table-filters-dialog /db-table-filters-dialog .component' ;
19- import { DbTableRowViewComponent } from './db-table-row- view/db-table-row -view.component' ;
15+ import { DbActionLinkDialogComponent } from './db-table-view/db- action-link-dialog/db-action-link-dialog.component' ;
16+ import { DbTableAiPanelComponent } from './db-table-view/db-table- ai-panel/db-table-ai-panel.component' ;
17+ import { DbTableFiltersDialogComponent } from './db-table-view /db-table-filters-dialog/db-table-filters-dialog .component' ;
18+ import { DbTableRowViewComponent } from './db-table-view/db-table-row-view /db-table-row-view .component' ;
19+ import { DbTableViewComponent } from './db-table-view/db-table-view.component' ;
2020import { DbTablesListComponent } from './db-tables-list/db-tables-list.component' ;
2121import { HttpErrorResponse } from '@angular/common/http' ;
2222import JsonURL from "@jsonurl/jsonurl" ;
@@ -58,7 +58,7 @@ interface DataToActivateActions {
5858 MatDialogModule ,
5959 MatSidenavModule ,
6060 DbTablesListComponent ,
61- DbTableComponent ,
61+ DbTableViewComponent ,
6262 DbTableAiPanelComponent ,
6363 DbTableRowViewComponent ,
6464 AlertComponent ,
@@ -151,6 +151,7 @@ export class DashboardComponent implements OnInit, OnDestroy {
151151 this . shownTableTitles = settings ?. connections [ this . connectionID ] ?. shownTableTitles ?? true ;
152152
153153 this . getData ( ) ;
154+ console . log ( 'getData from ngOnInit' ) ;
154155 } ) ;
155156 }
156157
@@ -159,6 +160,7 @@ export class DashboardComponent implements OnInit, OnDestroy {
159160 }
160161
161162 async getData ( ) {
163+ console . log ( 'getData' ) ;
162164 let tables ;
163165 try {
164166 tables = await this . getTables ( ) ;
@@ -185,6 +187,7 @@ export class DashboardComponent implements OnInit, OnDestroy {
185187 if ( tableName ) {
186188 this . selectedTableName = tableName ;
187189 this . setTable ( tableName ) ;
190+ console . log ( 'setTable from getData paramMap' ) ;
188191 this . title . setTitle ( `${ this . selectedTableDisplayName } table | ${ this . _company . companyTabTitle || 'Rocketadmin' } ` ) ;
189192 this . selection . clear ( ) ;
190193 } else {
@@ -201,12 +204,14 @@ export class DashboardComponent implements OnInit, OnDestroy {
201204 this . _tableRow . cast . subscribe ( ( arg ) => {
202205 if ( arg === 'delete row' && this . selectedTableName ) {
203206 this . setTable ( this . selectedTableName ) ;
207+ console . log ( 'setTable from getData _tableRow cast' ) ;
204208 this . selection . clear ( ) ;
205209 } ;
206210 } ) ;
207211 this . _tables . cast . subscribe ( ( arg ) => {
208212 if ( ( arg === 'delete rows' || arg === 'import' ) && this . selectedTableName ) {
209213 this . setTable ( this . selectedTableName ) ;
214+ console . log ( 'setTable from getData _tables cast' ) ;
210215 this . selection . clear ( ) ;
211216 } ;
212217 if ( arg === 'activate actions' ) {
@@ -217,6 +222,7 @@ export class DashboardComponent implements OnInit, OnDestroy {
217222 }
218223
219224 getTables ( ) {
225+ console . log ( 'getTables' ) ;
220226 return this . _tables . fetchTables ( this . connectionID ) . toPromise ( ) ;
221227 }
222228
@@ -243,17 +249,17 @@ export class DashboardComponent implements OnInit, OnDestroy {
243249
244250 setTable ( tableName : string ) {
245251 this . selectedTableName = tableName ;
246- this . route . queryParams . pipe ( first ( ) ) . subscribe ( ( queryParams ) => {
247- this . filters = JsonURL . parse ( queryParams . filters ) ;
248- this . comparators = getComparatorsFromUrl ( this . filters ) ;
249- this . pageIndex = parseInt ( queryParams . page_index ) || 0 ;
250- this . pageSize = parseInt ( queryParams . page_size ) || 30 ;
251- this . sortColumn = queryParams . sort_active ;
252- this . sortOrder = queryParams . sort_direction ;
253-
254- const search = queryParams . search ;
255- this . getRows ( search ) ;
256- } )
252+ const queryParams = this . route . snapshot . queryParams ;
253+ this . filters = JsonURL . parse ( queryParams . filters ) ;
254+ this . comparators = getComparatorsFromUrl ( this . filters ) ;
255+ this . pageIndex = parseInt ( queryParams . page_index ) || 0 ;
256+ this . pageSize = parseInt ( queryParams . page_size ) || 30 ;
257+ this . sortColumn = queryParams . sort_active ;
258+ this . sortOrder = queryParams . sort_direction ;
259+
260+ const search = queryParams . search ;
261+ this . getRows ( search ) ;
262+ console . log ( 'getRows from setTable' ) ;
257263
258264 const selectedTableProperties = this . tablesList . find ( ( table : any ) => table . table == this . selectedTableName ) ;
259265 if ( selectedTableProperties ) {
@@ -279,21 +285,27 @@ export class DashboardComponent implements OnInit, OnDestroy {
279285 if ( action === 'filter' ) {
280286 const filtersFromDialog = { ...filterDialodRef . componentInstance . tableRowFieldsShown } ;
281287
288+ console . log ( 'Filters from dialog:' , filtersFromDialog ) ;
289+
282290 const nonEmptyFilters = omitBy ( filtersFromDialog , ( value ) => value === undefined ) ;
283291 this . comparators = filterDialodRef . componentInstance . tableRowFieldsComparator ;
284292
285293 if ( Object . keys ( nonEmptyFilters ) . length ) {
286294 this . filters = { } ;
287295 for ( const key in nonEmptyFilters ) {
288- if ( this . comparators [ key ] !== undefined ) {
289- this . filters [ key ] = {
290- [ this . comparators [ key ] ] : nonEmptyFilters [ key ]
291- } ;
292- }
296+ if ( this . comparators [ key ] !== undefined ) {
297+ this . filters [ key ] = {
298+ [ this . comparators [ key ] ] : nonEmptyFilters [ key ]
299+ } ;
300+ }
293301 }
294302
303+ console . log ( 'Filters to apply:' , this . filters ) ;
304+
295305 const filters = JsonURL . stringify ( this . filters ) ;
296306
307+ console . log ( 'Filters to navigate:' , filters ) ;
308+
297309 this . router . navigate ( [ `/dashboard/${ this . connectionID } /${ this . selectedTableName } ` ] , {
298310 queryParams : {
299311 filters,
@@ -302,6 +314,8 @@ export class DashboardComponent implements OnInit, OnDestroy {
302314 }
303315 } ) ;
304316 this . getRows ( ) ;
317+ console . log ( 'getRows from afterClosed' ) ;
318+
305319
306320 this . angulartics2 . eventTrack . next ( {
307321 action : 'Dashboard: filter is applied' ,
@@ -310,6 +324,7 @@ export class DashboardComponent implements OnInit, OnDestroy {
310324 } else if ( action === 'reset' ) {
311325 this . filters = { } ;
312326 this . getRows ( ) ;
327+ console . log ( 'getRows from reset filters afterClosed' ) ;
313328 this . router . navigate ( [ `/dashboard/${ this . connectionID } /${ this . selectedTableName } ` ] ) ;
314329 }
315330 } )
@@ -324,6 +339,7 @@ export class DashboardComponent implements OnInit, OnDestroy {
324339 this . selection . clear ( ) ;
325340
326341 this . getRows ( ) ;
342+ console . log ( 'getRows from removeFilter' ) ;
327343 this . router . navigate ( [ `/dashboard/${ this . connectionID } /${ this . selectedTableName } ` ] , {
328344 queryParams : {
329345 filters,
@@ -337,6 +353,7 @@ export class DashboardComponent implements OnInit, OnDestroy {
337353 this . filters = { } ;
338354 this . comparators = { } ;
339355 this . getRows ( ) ;
356+ console . log ( 'getRows from clearAllFilters' ) ;
340357 this . router . navigate ( [ `/dashboard/${ this . connectionID } /${ this . selectedTableName } ` ] , {
341358 queryParams : {
342359 page_index : 0 ,
@@ -347,6 +364,7 @@ export class DashboardComponent implements OnInit, OnDestroy {
347364
348365 search ( value : string ) {
349366 this . getRows ( value ) ;
367+ console . log ( 'getRows from search' ) ;
350368 this . filters = { } ;
351369 this . router . navigate ( [ `/dashboard/${ this . connectionID } /${ this . selectedTableName } ` ] , {
352370 queryParams : {
@@ -358,6 +376,7 @@ export class DashboardComponent implements OnInit, OnDestroy {
358376 }
359377
360378 getRows ( search ?: string ) {
379+ console . log ( 'getRows, filters:' , this . filters ) ;
361380 this . _uiSettings . getUiSettings ( )
362381 . subscribe ( ( settings : UiSettings ) => {
363382 this . uiSettings = settings ?. connections [ this . connectionID ] ;
@@ -376,7 +395,13 @@ export class DashboardComponent implements OnInit, OnDestroy {
376395 shownColumns
377396 } ) ;
378397 } ) ;
398+ }
379399
400+ applyFilter ( filters : any ) {
401+ console . log ( 'applyFilter with filters:' , filters ) ;
402+ this . filters = filters ?. filters ;
403+ this . getRows ( ) ;
404+ console . log ( 'getRows from applyFilter' ) ;
380405 }
381406
382407 openIntercome ( ) {
0 commit comments