Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions frontend/src/app/components/dashboard/dashboard.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export class DashboardComponent implements OnInit, OnDestroy {
} else {
tableName = this.allTables[0]?.table;
}
this.router.navigate([`/dashboard/${this.connectionID}/${tableName}`], { replaceUrl: true });
this.router.navigate([`/dashboard/${this.connectionID}/${tableName}`], { replaceUrl: true, queryParamsHandling: 'preserve' });
this.selectedTableName = tableName;
}
}),
Expand Down Expand Up @@ -271,7 +271,8 @@ export class DashboardComponent implements OnInit, OnDestroy {
this.sortOrder = queryParams.sort_direction;

const search = queryParams.search;
this.getRows(search);
const uncached = queryParams.uncached === 'true';
this.getRows(search, uncached);
console.log('getRows from setTable');

const selectedTableProperties = this.allTables.find((table: any) => table.table === this.selectedTableName);
Expand Down Expand Up @@ -389,7 +390,7 @@ export class DashboardComponent implements OnInit, OnDestroy {
});
}

getRows(search?: string) {
getRows(search?: string, uncached?: boolean) {
console.log('getRows, filters:', this.filters);
this._uiSettings.getUiSettings().subscribe((settings: UiSettings) => {
this.uiSettings = settings?.connections[this.connectionID];
Expand All @@ -404,6 +405,7 @@ export class DashboardComponent implements OnInit, OnDestroy {
sortOrder: this.sortOrder,
filters: this.filters,
search,
uncached,
});
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ interface RowsParams {
comparators?: object;
search?: string;
isTablePageSwitched?: boolean;
uncached?: boolean;
}

export class TablesDataSource implements DataSource<Object> {
Expand Down Expand Up @@ -118,6 +119,7 @@ export class TablesDataSource implements DataSource<Object> {
comparators,
search,
isTablePageSwitched,
uncached,
}: RowsParams) {
this.loadingSubject.next(true);
this.alert_primaryKeysInfo = null;
Expand All @@ -135,6 +137,7 @@ export class TablesDataSource implements DataSource<Object> {
filters,
comparators,
search,
uncached,
});

if (fetchedTable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ <h3 class="schema-chat__diagram-title">{{ message.text }}</h3>
<div class="schema-chat__open-tables">
<a mat-flat-button color="primary" (click)="onOpenTables()"
[routerLink]="['/dashboard', connectionID]"
[queryParams]="{uncached: 'true'}"
data-testid="schema-open-tables-button">
<mat-icon>table_chart</mat-icon>
Open tables
Expand All @@ -164,45 +165,44 @@ <h3 class="schema-chat__diagram-title">{{ message.text }}</h3>
}

<!-- Input form / Actions -->
@if (!applied()) {
<div class="schema-chat__form">
@if (pendingBatch()) {
<div class="schema-chat__actions">
<button mat-stroked-button type="button" (click)="onReject()" [disabled]="applying()"
data-testid="schema-reject-button">
Reject
</button>
<button mat-flat-button color="primary" type="button" (click)="onApprove()" [disabled]="applying()"
data-testid="schema-approve-button">
@if (applying()) {
Applying...
} @else {
<mat-icon>check</mat-icon>
Apply All
}
<div class="schema-chat__form">
@if (pendingBatch()) {
<div class="schema-chat__actions">
<button mat-stroked-button type="button" (click)="onReject()" [disabled]="applying()"
data-testid="schema-reject-button">
Reject
</button>
<button mat-flat-button color="primary" type="button" (click)="onApprove()" [disabled]="applying()"
data-testid="schema-approve-button">
@if (applying()) {
Applying...
} @else {
<mat-icon>check</mat-icon>
Apply All
}
</button>
</div>
} @else {
<form (ngSubmit)="onSubmit()">
<mat-form-field appearance="outline" class="schema-chat__input-field">
<mat-label>{{showClose || isRoutedPage() ? 'Describe the changes you need...' : 'Describe the database you need...'}}</mat-label>
<textarea matInput
name="schemaPrompt"
[ngModel]="userPrompt()"
(ngModelChange)="userPrompt.set($event)"
(keydown)="onKeydown($event)"
rows="2"
maxlength="1000"
[disabled]="submitting()"
data-testid="schema-prompt-textarea"
></textarea>
<button mat-icon-button matSuffix type="submit"
[disabled]="!userPrompt().trim() || submitting()"
class="schema-chat__send-button">
<mat-icon>send</mat-icon>
</button>
</div>
} @else {
<form (ngSubmit)="onSubmit()">
<mat-form-field appearance="outline" class="schema-chat__input-field">
<mat-label>{{showClose || isRoutedPage() ? 'Describe the changes you need...' : 'Describe the database you need...'}}</mat-label>
<textarea matInput
name="schemaPrompt"
[ngModel]="userPrompt()"
(ngModelChange)="userPrompt.set($event)"
(keydown)="onKeydown($event)"
rows="2"
maxlength="1000"
data-testid="schema-prompt-textarea"
></textarea>
<button mat-icon-button matSuffix type="submit"
[disabled]="!userPrompt().trim() || submitting()"
class="schema-chat__send-button">
<mat-icon>send</mat-icon>
</button>
</mat-form-field>
</form>
}
</div>
}
</mat-form-field>
</form>
}
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export class EditDatabaseSchemaComponent implements OnInit, AfterViewInit {
}
if (result && result.changes.length > 0) {
const summary = result.changes.map(c => `**${c.changeType}** \`${c.targetTableName}\`${c.aiSummary ? ' — ' + c.aiSummary : ''}`).join('\n');
this.applied.set(false);
this.messages.update(msgs => [...msgs, {
role: 'ai',
text: `I've generated ${result.changes.length} change(s) for your database:\n\n${summary}\n\nReview the SQL below and approve or reject.`,
Expand Down Expand Up @@ -145,10 +146,12 @@ export class EditDatabaseSchemaComponent implements OnInit, AfterViewInit {
}]);
} else {
this.applied.set(true);
this.messages.update(msgs => [...msgs, {
this.messages.update(msgs => msgs.map(m =>
m === batch ? { ...m, batchId: undefined } : m
).concat({
role: 'ai',
text: 'All changes applied successfully! Your tables have been created.',
}]);
}));
this._loadDiagram('Updated Database Structure');
}
}
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/app/services/tables.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ interface TableParams {
filters?: object;
comparators?: object;
search?: string;
uncached?: boolean;
}

@Injectable({
Expand Down Expand Up @@ -121,6 +122,7 @@ export class TablesService {
referencedColumn,
filters,
search,
uncached,
}: TableParams) {
let foreignKeyRowParamName =
foreignKeyRowName === 'autocomplete' ? foreignKeyRowName : `f_${foreignKeyRowName}__eq`;
Expand All @@ -140,6 +142,7 @@ export class TablesService {
...(referencedColumn ? { referencedColumn } : {}),
...(sortColumn ? { sort_by: sortColumn } : {}),
...(sortOrder ? { sort_order: sortOrder } : {}),
...(uncached ? { _uncached: 'true' } : {}),
},
},
)
Expand Down
Loading