-
-
Notifications
You must be signed in to change notification settings - Fork 18
saas and mobile fixes #1467
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
saas and mobile fixes #1467
Changes from all commits
cb3e12c
f19b84b
f7d28d5
432de92
b03c13a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,9 @@ import { Angulartics2, Angulartics2Module } from 'angulartics2'; | |
| import { Component, OnDestroy, OnInit } from '@angular/core'; | ||
| import { ConnectionSettingsUI, UiSettings } from 'src/app/models/ui-settings'; | ||
| import { CustomEvent, TableProperties } from 'src/app/models/table'; | ||
| import { map } from 'rxjs/operators'; | ||
| import { TableCategory } from 'src/app/models/connection'; | ||
| import { Folder } from './db-table-view/db-table-view.component'; | ||
| import { first, map } from 'rxjs/operators'; | ||
|
|
||
| import { AlertComponent } from '../ui-components/alert/alert.component'; | ||
| import { BannerComponent } from '../ui-components/banner/banner.component'; | ||
|
|
@@ -101,6 +103,7 @@ export class DashboardComponent implements OnInit, OnDestroy { | |
| public isAIpanelOpened: boolean = false; | ||
|
|
||
| public uiSettings: ConnectionSettingsUI; | ||
| public tableFolders: Folder[] = []; | ||
|
|
||
| constructor( | ||
| private _connections: ConnectionsService, | ||
|
|
@@ -153,6 +156,8 @@ export class DashboardComponent implements OnInit, OnDestroy { | |
| this.getData(); | ||
| console.log('getData from ngOnInit'); | ||
| }); | ||
|
|
||
| this.loadTableFolders(); | ||
| } | ||
|
|
||
| ngOnDestroy() { | ||
|
|
@@ -429,4 +434,24 @@ export class DashboardComponent implements OnInit, OnDestroy { | |
| this.shownTableTitles = !this.shownTableTitles; | ||
| this._uiSettings.updateConnectionSetting(this.connectionID, 'shownTableTitles', this.shownTableTitles); | ||
| } | ||
|
|
||
| private loadTableFolders() { | ||
| this._connections.getTablesFolders(this.connectionID).subscribe({ | ||
| next: (categories: TableCategory[]) => { | ||
| if (categories && categories.length > 0) { | ||
| this.tableFolders = categories.map(cat => ({ | ||
| id: cat.category_id, | ||
| name: cat.category_name, | ||
| tableIds: cat.tables | ||
| })); | ||
| } else { | ||
| this.tableFolders = []; | ||
| } | ||
| }, | ||
| error: (error) => { | ||
| console.error('Error fetching table folders:', error); | ||
| this.tableFolders = []; | ||
| } | ||
| }); | ||
| } | ||
|
Comment on lines
+438
to
+456
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ import { DynamicModule } from 'ng-dynamic-component'; | |
| import { ForeignKeyDisplayComponent } from '../../ui-components/table-display-fields/foreign-key/foreign-key.component'; | ||
| import JsonURL from "@jsonurl/jsonurl"; | ||
| import { MatAutocompleteModule } from '@angular/material/autocomplete'; | ||
| import { MatSelectModule } from '@angular/material/select'; | ||
| import { MatButtonModule } from '@angular/material/button'; | ||
| import { MatCheckboxModule } from '@angular/material/checkbox'; | ||
| import { MatChipsModule } from '@angular/material/chips'; | ||
|
|
@@ -51,6 +52,12 @@ interface Column { | |
| selected: boolean | ||
| } | ||
|
|
||
| export interface Folder { | ||
| id: string; | ||
| name: string; | ||
| tableIds: string[]; | ||
| } | ||
|
Comment on lines
+55
to
+59
|
||
|
|
||
| @Component({ | ||
| selector: 'app-db-table-view', | ||
| templateUrl: './db-table-view.component.html', | ||
|
|
@@ -71,6 +78,7 @@ interface Column { | |
| ReactiveFormsModule, | ||
| MatInputModule, | ||
| MatAutocompleteModule, | ||
| MatSelectModule, | ||
| MatMenuModule, | ||
| MatTooltipModule, | ||
| ClipboardModule, | ||
|
|
@@ -95,6 +103,7 @@ export class DbTableViewComponent implements OnInit { | |
| @Input() filterComparators: object; | ||
| @Input() selection: SelectionModel<any>; | ||
| @Input() tables: TableProperties[]; | ||
| @Input() folders: Folder[] = []; | ||
|
|
||
| @Output() openFilters = new EventEmitter(); | ||
| @Output() openPage = new EventEmitter(); | ||
|
|
@@ -514,8 +523,24 @@ export class DbTableViewComponent implements OnInit { | |
| this._notifications.showSuccessSnackbar(message); | ||
| } | ||
|
|
||
| switchTable(_e) { | ||
| switchTable(tableName: string) { | ||
| if (tableName && tableName !== this.name) { | ||
| this.router.navigate([`/dashboard/${this.connectionID}/${tableName}`], { | ||
| queryParams: { page_index: 0, page_size: 30 } | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| getFolderTables(folder: Folder): TableProperties[] { | ||
| return this.tables.filter(table => folder.tableIds.includes(table.table)); | ||
| } | ||
|
|
||
| getUncategorizedTables(): TableProperties[] { | ||
| const categorizedTableIds = new Set<string>(); | ||
| this.folders.forEach(folder => { | ||
| folder.tableIds.forEach(id => categorizedTableIds.add(id)); | ||
| }); | ||
| return this.tables.filter(table => !categorizedTableIds.has(table.table)); | ||
| } | ||
|
Comment on lines
+534
to
544
|
||
|
|
||
| onFilterSelected($event) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The property name
tableFolderscould be more consistent with the API terminology. Since the backend API endpoint is/table-categoriesand uses theTableCategoryinterface, consider renaming totableCategoriesto maintain consistency with the domain model throughout the codebase.