Skip to content

Commit abdbf3b

Browse files
Merge pull request #1772 from rocket-admin/ddl-ai
Ddl ai
2 parents 1096f52 + 7a1f992 commit abdbf3b

14 files changed

Lines changed: 354 additions & 155 deletions

frontend/src/app/app-routing.module.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,15 @@ const routes: Routes = [
160160
loadComponent: () => import('./components/connect-db/connect-db.component').then((m) => m.ConnectDBComponent),
161161
canActivate: [AuthGuard],
162162
},
163+
{
164+
path: 'edit-database-schema/:connection-id',
165+
loadComponent: () =>
166+
import('./components/edit-database-schema/edit-database-schema.component').then(
167+
(m) => m.EditDatabaseSchemaComponent,
168+
),
169+
canActivate: [AuthGuard],
170+
title: 'Edit Database Schema | Rocketadmin',
171+
},
163172
{
164173
path: 'connection-settings/:connection-id',
165174
loadComponent: () =>

frontend/src/app/components/connections-list/own-connections/own-connections.component.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,8 @@
320320
.connectionInfo {
321321
display: flex;
322322
flex-direction: column;
323+
min-width: 0;
324+
flex: 1;
323325
}
324326

325327
.connectionInfo .connectionInfo__connectionTitle {
@@ -331,6 +333,18 @@
331333
width: 100%;
332334
}
333335

336+
/* ── Schema button inside card ── */
337+
338+
.connectionSchemaButton {
339+
margin-left: auto;
340+
flex-shrink: 0;
341+
color: rgba(255, 255, 255, 0.7);
342+
}
343+
344+
.connectionSchemaButton:hover {
345+
color: #fff;
346+
}
347+
334348
/* ── Show more / less ── */
335349

336350
.showAllButton {

frontend/src/app/components/connections-list/own-connections/own-connections.component.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ <h1 class="mat-display-1">Create your first connection</h1>
3030
<h2 class="connectionInfo__connectionTitle">{{ $any(connectionItem).displayTitle }}</h2>
3131
<span class="mat-body-2">{{ supportedDatabasesTitles[connectionItem.connection.type] }}</span>
3232
</div>
33+
@if (connectionItem.accessLevel === 'edit') {
34+
<a mat-icon-button
35+
class="connectionSchemaButton"
36+
routerLink="/edit-database-schema/{{connectionItem.connection.id}}"
37+
matTooltip="Edit schema"
38+
(click)="$event.stopPropagation()">
39+
<mat-icon>schema</mat-icon>
40+
</a>
41+
}
3342
</div>
3443
</a>
3544
</li>

frontend/src/app/components/connections-list/own-connections/own-connections.component.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Component, Input, OnChanges, OnInit, SimpleChanges, signal } from '@ang
33
import { MatButtonModule } from '@angular/material/button';
44
import { MatDialog } from '@angular/material/dialog';
55
import { MatIconModule } from '@angular/material/icon';
6+
import { MatTooltipModule } from '@angular/material/tooltip';
67
import { Router, RouterModule } from '@angular/router';
78
import posthog from 'posthog-js';
89
import { firstValueFrom } from 'rxjs';
@@ -33,7 +34,7 @@ import {
3334

3435
@Component({
3536
selector: 'app-own-connections',
36-
imports: [CommonModule, RouterModule, MatIconModule, MatButtonModule],
37+
imports: [CommonModule, RouterModule, MatIconModule, MatButtonModule, MatTooltipModule],
3738
templateUrl: './own-connections.component.html',
3839
styleUrl: './own-connections.component.css',
3940
})
@@ -240,11 +241,15 @@ export class OwnConnectionsComponent implements OnInit, OnChanges {
240241
}
241242

242243
private _openRenameDialog(data: HostedDatabaseRenameDialogData): void {
243-
this._dialog.open(HostedDatabaseRenameDialogComponent, {
244+
const dialogRef = this._dialog.open(HostedDatabaseRenameDialogComponent, {
244245
width: '28em',
245246
maxWidth: '95vw',
246247
data,
247248
});
249+
250+
dialogRef.afterClosed().subscribe(() => {
251+
this._router.navigate(['/dashboard', data.connectionId]);
252+
});
248253
}
249254

250255
private _getErrorMessage(error: unknown): string {

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

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -315,31 +315,3 @@
315315
display: none !important;
316316
}
317317

318-
.schema-editor-panel {
319-
position: fixed;
320-
bottom: 0;
321-
left: 0;
322-
right: 0;
323-
height: 0;
324-
background: var(--mat-sidenav-content-background-color);
325-
border-top: 1px solid rgba(0, 0, 0, 0.12);
326-
box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.12);
327-
overflow: hidden;
328-
transition: height 0.3s ease;
329-
z-index: 100;
330-
}
331-
332-
.schema-editor-panel--open {
333-
height: 380px;
334-
}
335-
336-
.table-preview-content--panel-open {
337-
padding-bottom: 380px;
338-
}
339-
340-
@media (prefers-color-scheme: dark) {
341-
.schema-editor-panel {
342-
border-top-color: rgba(255, 255, 255, 0.12);
343-
box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.4);
344-
}
345-
}

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

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
</div>
2222
</app-banner>
2323

24-
<app-db-generate-schema
24+
<app-edit-database-schema
2525
*ngIf="noTablesError"
2626
[connectionID]="connectionID"
2727
(schemaApplied)="onSchemaApplied()"
2828
data-testid="no-tables-generate-schema">
29-
</app-db-generate-schema>
29+
</app-edit-database-schema>
3030

3131
<ng-container *ngIf="!loading && !isServerError && !noTablesError">
3232

@@ -87,12 +87,11 @@
8787
[connectionID]="connectionID"
8888
[selectedTable]="selectedTableName"
8989
[uiSettings]="uiSettings"
90-
(expandSidebar)="toggleSideBar()"
91-
(editStructure)="onEditStructure()">
90+
(expandSidebar)="toggleSideBar()">
9291
</app-db-tables-list>
9392
</mat-sidenav>
9493
<mat-sidenav-content class="table-preview">
95-
<div class="table-preview-content" [class.table-preview-content--panel-open]="showSchemaEditor">
94+
<div class="table-preview-content">
9695
<div class="alerts">
9796
<app-alert></app-alert>
9897
<div *ngIf="dataSource.alert_settingsInfo && canEditConnection() && !isConfiguring" class="ai-config-alert">
@@ -129,24 +128,14 @@
129128
(applyFilter)="applyFilter($event)">
130129
</app-db-table-view>
131130
</div>
132-
<app-db-table-row-view *ngIf="selectedRow && !showSchemaEditor"
131+
<app-db-table-row-view *ngIf="selectedRow"
133132
[activeFilters]="filters"
134133
></app-db-table-row-view>
135-
<app-db-table-ai-panel *ngIf="isAIpanelOpened && !showSchemaEditor"
134+
<app-db-table-ai-panel *ngIf="isAIpanelOpened"
136135
[displayName]="selectedTableDisplayName"
137136
[tableColumns]="dataSource?.dataColumns || []"
138137
[sidebarExpanded]="shownTableTitles"
139138
></app-db-table-ai-panel>
140-
<div class="schema-editor-panel" [class.schema-editor-panel--open]="showSchemaEditor">
141-
<app-db-generate-schema
142-
*ngIf="showSchemaEditor"
143-
[connectionID]="connectionID"
144-
[showClose]="true"
145-
(schemaApplied)="onSchemaApplied()"
146-
(closeEditor)="showSchemaEditor = false"
147-
data-testid="edit-structure-generate-schema">
148-
</app-db-generate-schema>
149-
</div>
150139
</mat-sidenav-content>
151140
</mat-sidenav-container>
152141
</ng-container>

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import { DbTableFiltersDialogComponent } from './db-table-view/db-table-filters-
3737
import { DbTableRowViewComponent } from './db-table-view/db-table-row-view/db-table-row-view.component';
3838
import { DbTableViewComponent } from './db-table-view/db-table-view.component';
3939
import { TablesDataSource } from './db-tables-data-source';
40-
import { DbGenerateSchemaComponent } from './db-generate-schema/db-generate-schema.component';
40+
import { EditDatabaseSchemaComponent } from '../edit-database-schema/edit-database-schema.component';
4141
import { DbTablesListComponent } from './db-tables-list/db-tables-list.component';
4242

4343
interface DataToActivateActions {
@@ -56,7 +56,7 @@ interface DataToActivateActions {
5656
MatIconModule,
5757
MatDialogModule,
5858
MatSidenavModule,
59-
DbGenerateSchemaComponent,
59+
EditDatabaseSchemaComponent,
6060
DbTablesListComponent,
6161
DbTableViewComponent,
6262
DbTableAiPanelComponent,
@@ -103,7 +103,6 @@ export class DashboardComponent implements OnInit, OnDestroy {
103103
public uiSettings: ConnectionSettingsUI;
104104
public tableFolders: any[] = [];
105105
public isConfiguring: boolean = false;
106-
public showSchemaEditor: boolean = false;
107106

108107
constructor(
109108
private _connections: ConnectionsService,
@@ -451,14 +450,9 @@ export class DashboardComponent implements OnInit, OnDestroy {
451450
this._uiSettings.updateConnectionSetting(this.connectionID, 'shownTableTitles', this.shownTableTitles);
452451
}
453452

454-
onEditStructure() {
455-
this.showSchemaEditor = true;
456-
}
457-
458453
onSchemaApplied() {
459454
setTimeout(() => {
460455
this.noTablesError = false;
461-
this.showSchemaEditor = false;
462456
this.loading = true;
463457
this.getData();
464458
}, 1500);

frontend/src/app/components/dashboard/db-tables-list/db-tables-list.component.css

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@
445445
.expanded-container.has-custom-folders .add-folder-button-container {
446446
order: 4; /* After folders section */
447447
position: sticky;
448-
bottom: 40px;
448+
bottom: 0;
449449
background-color: #ffffff;
450450
padding: 8px 16px;
451451
z-index: 10;
@@ -459,50 +459,6 @@
459459
}
460460
}
461461

462-
/* Edit structure button container */
463-
.edit-structure-button-container {
464-
order: 5; /* Always at the very bottom */
465-
position: sticky;
466-
bottom: 0;
467-
background-color: #ffffff;
468-
padding: 8px 16px;
469-
z-index: 10;
470-
margin-left: 16px;
471-
margin-right: 16px;
472-
margin-top: 4px;
473-
margin-bottom: 8px;
474-
width: calc(100% - 32px);
475-
box-sizing: border-box;
476-
}
477-
478-
.expanded-container.has-custom-folders .edit-structure-button-container {
479-
padding: 0 16px 8px;
480-
margin-top: 0;
481-
margin-left: 0;
482-
margin-right: 0;
483-
width: 100%;
484-
}
485-
486-
.edit-structure-button {
487-
width: 100%;
488-
}
489-
490-
.edit-structure-button mat-icon {
491-
font-size: 18px;
492-
width: 18px;
493-
height: 18px;
494-
}
495-
496-
@media (prefers-color-scheme: dark) {
497-
.edit-structure-button-container {
498-
background-color: #303030;
499-
}
500-
501-
.expanded-container.has-custom-folders .edit-structure-button-container {
502-
background-color: #303030;
503-
}
504-
}
505-
506462
.search-input ::ng-deep * {
507463
background-color: transparent !important;
508464
}

frontend/src/app/components/dashboard/db-tables-list/db-tables-list.component.html

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,6 @@
6161

6262
<!-- Bottom section with add folder button (fixed at bottom) -->
6363
<div class="collapsed-bottom-section" *ngIf="canEditConnection()">
64-
<!-- Edit structure button -->
65-
<div class="collapsed-add-button"
66-
(click)="editStructure.emit()"
67-
matTooltip="Edit structure"
68-
matTooltipPosition="right">
69-
<mat-icon class="collapsed-action-icon">construction</mat-icon>
70-
</div>
7164
<!-- Add folder button -->
7265
<div class="collapsed-add-button"
7366
(click)="onAddFolder()"
@@ -97,14 +90,6 @@
9790
</button>
9891
</div>
9992

100-
<!-- Edit structure button -->
101-
<div *ngIf="canEditConnection()" class="edit-structure-button-container">
102-
<button type="button" mat-stroked-button color="primary" class="edit-structure-button" (click)="editStructure.emit()">
103-
<mat-icon>construction</mat-icon>
104-
Edit structure
105-
</button>
106-
</div>
107-
10893
<!-- Collections Section -->
10994
<div *ngIf="folders && folders.length > 0" class="folders-section">
11095
<ng-container *ngFor="let folder of folders; trackBy: trackByFolderId">

frontend/src/app/components/dashboard/db-tables-list/db-tables-list.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ export class DbTablesListComponent implements OnInit, OnChanges {
7575
@Input() uiSettings: any;
7676

7777
@Output() expandSidebar = new EventEmitter<void>();
78-
@Output() editStructure = new EventEmitter<void>();
7978

8079
private _connections = inject(ConnectionsService);
8180
protected canEditConnection = () => this._connections.canEditConnection();

0 commit comments

Comments
 (0)