Skip to content

Commit 8363e3c

Browse files
Merge pull request #1467 from rocket-admin/saas-and-mobile-fixes
saas and mobile fixes
2 parents 6a3af80 + b03c13a commit 8363e3c

File tree

12 files changed

+137
-50
lines changed

12 files changed

+137
-50
lines changed

frontend/src/app/app.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,13 +200,13 @@
200200
class="action">
201201
Login
202202
</a>
203-
<a mat-flat-button color="accent" routerLink="/registration"
203+
<a *ngIf="isSaas" mat-flat-button color="accent" routerLink="/registration"
204204
data-testid="registration-header-link"
205205
class="action">
206206
Sign up
207207
</a>
208208
</ng-container>
209-
<ng-container *ngIf="page === '/registration'">
209+
<ng-container *ngIf="page === '/registration' && isSaas">
210210
<a mat-flat-button color="accent" routerLink="/login"
211211
data-testid="login-header-link"
212212
class="action">

frontend/src/app/components/company/company.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ <h3>Configure DNS Records</h3>
491491
</div>
492492
</ng-container >
493493

494-
<div *ngIf="currentUser && currentUser.role === 'USER' && currentPlan !== 'free' && companyCustomDomainHostname">
494+
<div *ngIf="isSaas && currentUser && currentUser.role === 'USER' && currentPlan !== 'free' && companyCustomDomainHostname">
495495
<strong>Your admin panel address: </strong>
496496
<span data-testid="company-custom-domain">{{companyCustomDomainHostname}}</span>
497497
</div>

frontend/src/app/components/dashboard/dashboard.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ <h3 class='mat-subheading-2'>Rocketadmin can not find any tables</h3>
9999
[isTestConnection]="currentConnectionIsTest"
100100
[accessLevel]="currentConnectionAccessLevel"
101101
[tables]="tablesList"
102+
[folders]="tableFolders"
102103
(openFilters)="openTableFilters($event)"
103104
(removeFilter)="removeFilter($event)"
104105
(resetAllFilters)="clearAllFilters()"

frontend/src/app/components/dashboard/dashboard.component.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ describe('DashboardComponent', () => {
2222
},
2323
get currentConnectionAccessLevel(): AccessLevel {
2424
return AccessLevel.None;
25-
}
25+
},
26+
getTablesFolders: () => of([])
2627
};
2728
const fakeRouter = jasmine.createSpyObj('Router', {navigate: Promise.resolve('')});
2829

frontend/src/app/components/dashboard/dashboard.component.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import { Angulartics2, Angulartics2Module } from 'angulartics2';
33
import { Component, OnDestroy, OnInit } from '@angular/core';
44
import { ConnectionSettingsUI, UiSettings } from 'src/app/models/ui-settings';
55
import { CustomEvent, TableProperties } from 'src/app/models/table';
6-
import { map } from 'rxjs/operators';
6+
import { TableCategory } from 'src/app/models/connection';
7+
import { Folder } from './db-table-view/db-table-view.component';
8+
import { first, map } from 'rxjs/operators';
79

810
import { AlertComponent } from '../ui-components/alert/alert.component';
911
import { BannerComponent } from '../ui-components/banner/banner.component';
@@ -101,6 +103,7 @@ export class DashboardComponent implements OnInit, OnDestroy {
101103
public isAIpanelOpened: boolean = false;
102104

103105
public uiSettings: ConnectionSettingsUI;
106+
public tableFolders: Folder[] = [];
104107

105108
constructor(
106109
private _connections: ConnectionsService,
@@ -153,6 +156,8 @@ export class DashboardComponent implements OnInit, OnDestroy {
153156
this.getData();
154157
console.log('getData from ngOnInit');
155158
});
159+
160+
this.loadTableFolders();
156161
}
157162

158163
ngOnDestroy() {
@@ -429,4 +434,24 @@ export class DashboardComponent implements OnInit, OnDestroy {
429434
this.shownTableTitles = !this.shownTableTitles;
430435
this._uiSettings.updateConnectionSetting(this.connectionID, 'shownTableTitles', this.shownTableTitles);
431436
}
437+
438+
private loadTableFolders() {
439+
this._connections.getTablesFolders(this.connectionID).subscribe({
440+
next: (categories: TableCategory[]) => {
441+
if (categories && categories.length > 0) {
442+
this.tableFolders = categories.map(cat => ({
443+
id: cat.category_id,
444+
name: cat.category_name,
445+
tableIds: cat.tables
446+
}));
447+
} else {
448+
this.tableFolders = [];
449+
}
450+
},
451+
error: (error) => {
452+
console.error('Error fetching table folders:', error);
453+
this.tableFolders = [];
454+
}
455+
});
456+
}
432457
}

frontend/src/app/components/dashboard/db-table-view/db-table-view.component.html

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,25 @@ <h2 class="mat-h2 table-name">{{ displayName }}</h2>
44

55
<mat-form-field appearance="outline" class="table-switcher">
66
<mat-label>Table</mat-label>
7-
<input type="text"
8-
placeholder="Select a table"
9-
matInput
10-
[value]="name"
11-
[matAutocomplete]="auto"
12-
(focus)="onInputFocus()"
13-
(input)="onInput($event.target.value)">
14-
<mat-autocomplete autoActiveFirstOption
15-
#auto="matAutocomplete">
16-
<mat-option *ngFor="let table of filteredTables"
17-
class="table-switcher-option"
18-
[value]="table.table">
19-
<a class="table-switcher-link"
20-
routerLink="/dashboard/{{connectionID}}/{{table.table}}"
21-
[queryParams]="{page_index: 0, page_size: 30}">
7+
<mat-select [value]="name" (selectionChange)="switchTable($event.value)">
8+
<ng-container *ngIf="folders && folders.length > 0; else flatList">
9+
<mat-optgroup *ngFor="let folder of folders" [label]="folder.name">
10+
<mat-option *ngFor="let table of getFolderTables(folder)" [value]="table.table">
11+
{{table.normalizedTableName}}
12+
</mat-option>
13+
</mat-optgroup>
14+
<mat-optgroup *ngIf="getUncategorizedTables().length > 0" label="Other">
15+
<mat-option *ngFor="let table of getUncategorizedTables()" [value]="table.table">
16+
{{table.normalizedTableName}}
17+
</mat-option>
18+
</mat-optgroup>
19+
</ng-container>
20+
<ng-template #flatList>
21+
<mat-option *ngFor="let table of tables" [value]="table.table">
2222
{{table.normalizedTableName}}
23-
</a>
24-
</mat-option>
25-
</mat-autocomplete>
23+
</mat-option>
24+
</ng-template>
25+
</mat-select>
2626
</mat-form-field>
2727

2828
<button mat-icon-button (click)="loadRowsPage()">

frontend/src/app/components/dashboard/db-table-view/db-table-view.component.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { DynamicModule } from 'ng-dynamic-component';
1818
import { ForeignKeyDisplayComponent } from '../../ui-components/table-display-fields/foreign-key/foreign-key.component';
1919
import JsonURL from "@jsonurl/jsonurl";
2020
import { MatAutocompleteModule } from '@angular/material/autocomplete';
21+
import { MatSelectModule } from '@angular/material/select';
2122
import { MatButtonModule } from '@angular/material/button';
2223
import { MatCheckboxModule } from '@angular/material/checkbox';
2324
import { MatChipsModule } from '@angular/material/chips';
@@ -51,6 +52,12 @@ interface Column {
5152
selected: boolean
5253
}
5354

55+
export interface Folder {
56+
id: string;
57+
name: string;
58+
tableIds: string[];
59+
}
60+
5461
@Component({
5562
selector: 'app-db-table-view',
5663
templateUrl: './db-table-view.component.html',
@@ -71,6 +78,7 @@ interface Column {
7178
ReactiveFormsModule,
7279
MatInputModule,
7380
MatAutocompleteModule,
81+
MatSelectModule,
7482
MatMenuModule,
7583
MatTooltipModule,
7684
ClipboardModule,
@@ -95,6 +103,7 @@ export class DbTableViewComponent implements OnInit {
95103
@Input() filterComparators: object;
96104
@Input() selection: SelectionModel<any>;
97105
@Input() tables: TableProperties[];
106+
@Input() folders: Folder[] = [];
98107

99108
@Output() openFilters = new EventEmitter();
100109
@Output() openPage = new EventEmitter();
@@ -514,8 +523,24 @@ export class DbTableViewComponent implements OnInit {
514523
this._notifications.showSuccessSnackbar(message);
515524
}
516525

517-
switchTable(_e) {
526+
switchTable(tableName: string) {
527+
if (tableName && tableName !== this.name) {
528+
this.router.navigate([`/dashboard/${this.connectionID}/${tableName}`], {
529+
queryParams: { page_index: 0, page_size: 30 }
530+
});
531+
}
532+
}
518533

534+
getFolderTables(folder: Folder): TableProperties[] {
535+
return this.tables.filter(table => folder.tableIds.includes(table.table));
536+
}
537+
538+
getUncategorizedTables(): TableProperties[] {
539+
const categorizedTableIds = new Set<string>();
540+
this.folders.forEach(folder => {
541+
folder.tableIds.forEach(id => categorizedTableIds.add(id));
542+
});
543+
return this.tables.filter(table => !categorizedTableIds.has(table.table));
519544
}
520545

521546
onFilterSelected($event) {

frontend/src/app/components/dashboard/db-table-view/saved-filters-panel/saved-filters-panel.component.css

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@
7171
transform: translateX(-10%) scale(0.8);
7272
}
7373

74+
@media (width <= 600px) {
75+
.filters-container {
76+
flex-direction: column;
77+
transform: none;
78+
}
79+
}
80+
7481
.dynamic-column-editor {
7582
display: flex;
7683
align-items: center;
@@ -83,6 +90,20 @@
8390
margin-top: -8px;
8491
}
8592

93+
.comparator-text {
94+
display: none;
95+
}
96+
97+
@media (width <= 600px) {
98+
.comparator-select {
99+
display: none;
100+
}
101+
102+
.comparator-text {
103+
display: inline;
104+
}
105+
}
106+
86107
@media (prefers-color-scheme: light) {
87108
.column-name {
88109
color: rgba(0,0,0,0.64);
@@ -118,6 +139,12 @@
118139
padding-bottom: 16px;
119140
}
120141

142+
@media (width <= 600px) {
143+
.static-filters {
144+
transform: none;
145+
}
146+
}
147+
121148
.static-filter-chip {
122149
cursor: default;
123150
}

frontend/src/app/components/dashboard/db-table-view/saved-filters-panel/saved-filters-panel.component.html

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,14 @@
4848
<strong *ngIf="getComparatorType(getInputType(savedFilterMap[selectedFilterSetId]?.dynamicColumn.column)) !== 'nonComparable'">
4949
{{ savedFilterMap[selectedFilterSetId]?.dynamicColumn.column }}
5050
</strong>
51+
<span *ngIf="getComparatorType(getInputType(savedFilterMap[selectedFilterSetId]?.dynamicColumn.column)) === 'text'" class="comparator-text">
52+
{{ {startswith: 'starts with', endswith: 'ends with', eq: 'equal', contains: 'contains', icontains: 'not contains', empty: 'is empty'}[savedFilterMap[selectedFilterSetId].dynamicColumn.operator] }}
53+
</span>
54+
<span *ngIf="getComparatorType(getInputType(savedFilterMap[selectedFilterSetId]?.dynamicColumn.column)) === 'number'" class="comparator-text">
55+
{{ {eq: '=', gt: '>', lt: '<', gte: '≥', lte: '≤'}[savedFilterMap[selectedFilterSetId].dynamicColumn.operator] }}
56+
</span>
5157
</span>
52-
<mat-form-field *ngIf="getComparatorType(getInputType(savedFilterMap[selectedFilterSetId]?.dynamicColumn.column)) === 'text'" appearance="outline">
58+
<mat-form-field *ngIf="getComparatorType(getInputType(savedFilterMap[selectedFilterSetId]?.dynamicColumn.column)) === 'text'" appearance="outline" class="comparator-select">
5359
<mat-select [(ngModel)]="savedFilterMap[selectedFilterSetId].dynamicColumn.operator"
5460
name="textComparator"
5561
(ngModelChange)="updateDynamicColumnComparator($event)">
@@ -62,7 +68,7 @@
6268
</mat-select>
6369
</mat-form-field>
6470

65-
<mat-form-field *ngIf="getComparatorType(getInputType(savedFilterMap[selectedFilterSetId]?.dynamicColumn.column)) === 'number'" appearance="outline">
71+
<mat-form-field *ngIf="getComparatorType(getInputType(savedFilterMap[selectedFilterSetId]?.dynamicColumn.column)) === 'number'" appearance="outline" class="comparator-select">
6672
<mat-select [(ngModel)]="savedFilterMap[selectedFilterSetId].dynamicColumn.operator"
6773
name="numberComparator"
6874
(ngModelChange)="updateDynamicColumnComparator($event)">

frontend/src/app/components/login/login.component.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<div class="login-page">
55
<form
66
[ngClass]="{
7-
'login-form': !isCustomDomain,
8-
'login-form--native-login': isCustomDomain
7+
'login-form': isSaas && !isCustomDomain,
8+
'login-form--native-login': !isSaas || isCustomDomain
99
}"
1010
[hidden]="is2FAShown"
1111
#loginForm="ngForm"
@@ -65,9 +65,9 @@ <h1 class="mat-headline-4 loginTitle">
6565
<!-- <mat-error *ngIf="port.errors?.required && (port.invalid && port.touched)">Port should not be empty.</mat-error> -->
6666
</mat-form-field>
6767

68-
<div *ngIf="!isCustomDomain" class="divider"><span class="divider__label">or</span></div>
68+
<div *ngIf="isSaas && !isCustomDomain" class="divider"><span class="divider__label">or</span></div>
6969

70-
<div id="google_login_button" *ngIf="!isCustomDomain"
70+
<div id="google_login_button" *ngIf="isSaas && !isCustomDomain"
7171
class="login-form__google-button"
7272
angulartics2On="click"
7373
angularticsAction="Login: login with google is clicked">
@@ -82,7 +82,7 @@ <h1 class="mat-headline-4 loginTitle">
8282
<span class="login-form__github-caption">Continue with GitHub</span>
8383
</button>
8484

85-
<div *ngIf="!isCustomDomain" class="login-form__sso-button-box">
85+
<div *ngIf="isSaas && !isCustomDomain" class="login-form__sso-button-box">
8686
<button type="button" mat-stroked-button color="primary"
8787
data-testid="login-sso-button"
8888
class="login-form__sso-button"

0 commit comments

Comments
 (0)