-
-
Notifications
You must be signed in to change notification settings - Fork 18
Add AI auto-configure route for new connections #1632
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
Merged
+129
−58
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
bd9ea27
Add AI auto-configure route for new connections
gugu 3d78337
Merge branch 'main' into frontend-ai-auto-configure-route
gugu 8d9fba2
Fix test: add auto-configure route to connect-db spec router
gugu 217bc36
Merge branch 'main' into frontend-ai-auto-configure-route
lyubov-voloshko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
frontend/src/app/components/auto-configure/auto-configure.component.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| .auto-configure { | ||
| display: flex; | ||
| flex-direction: column; | ||
| justify-content: center; | ||
| align-items: center; | ||
| gap: 24px; | ||
| height: 100vh; | ||
| } | ||
|
|
||
| .auto-configure__title { | ||
| color: var(--mat-sidenav-content-text-color); | ||
| margin: 0; | ||
| font-weight: 500; | ||
| } | ||
|
|
||
| .auto-configure__text { | ||
| color: var(--mat-sidenav-content-text-color); | ||
| opacity: 0.7; | ||
| margin: 0; | ||
| max-width: 400px; | ||
| text-align: center; | ||
| } | ||
|
|
||
| .auto-configure__notice { | ||
| color: var(--mat-sidenav-content-text-color); | ||
| opacity: 0.7; | ||
| margin: 0; | ||
| text-align: center; | ||
| max-width: 400px; | ||
| } |
12 changes: 12 additions & 0 deletions
12
frontend/src/app/components/auto-configure/auto-configure.component.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| @if (loading()) { | ||
| <div class="auto-configure"> | ||
| <mat-spinner diameter="48"></mat-spinner> | ||
| <h2 class="auto-configure__title">Auto-configuring your dashboard</h2> | ||
| <p class="auto-configure__text">Please wait while we analyze your database and set up the best configuration. This may take a moment.</p> | ||
| </div> | ||
| } @else if (errorMessage()) { | ||
| <div class="auto-configure"> | ||
| <p class="auto-configure__notice">{{ errorMessage() }}</p> | ||
| <a mat-flat-button [routerLink]="'/dashboard/' + connectionId()">Continue to dashboard</a> | ||
| </div> | ||
| } |
44 changes: 44 additions & 0 deletions
44
frontend/src/app/components/auto-configure/auto-configure.component.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import { Component, inject, OnInit, signal } from '@angular/core'; | ||
| import { MatButtonModule } from '@angular/material/button'; | ||
| import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'; | ||
| import { ActivatedRoute, Router, RouterModule } from '@angular/router'; | ||
|
|
||
| import { ApiService } from '../../services/api.service'; | ||
|
|
||
| @Component({ | ||
| selector: 'app-auto-configure', | ||
| templateUrl: './auto-configure.component.html', | ||
| styleUrls: ['./auto-configure.component.css'], | ||
| imports: [MatProgressSpinnerModule, MatButtonModule, RouterModule], | ||
| }) | ||
| export class AutoConfigureComponent implements OnInit { | ||
| private _route = inject(ActivatedRoute); | ||
| private _router = inject(Router); | ||
| private _api = inject(ApiService); | ||
|
|
||
| protected connectionId = signal<string | null>(null); | ||
| protected loading = signal(true); | ||
| protected errorMessage = signal<string | null>(null); | ||
|
|
||
| ngOnInit(): void { | ||
| const connectionId = this._route.snapshot.paramMap.get('connection-id'); | ||
| if (!connectionId) { | ||
| this._router.navigate(['/connections-list']); | ||
| return; | ||
| } | ||
|
|
||
| this.connectionId.set(connectionId); | ||
| this._configure(connectionId); | ||
| } | ||
|
|
||
| private async _configure(connectionId: string): Promise<void> { | ||
| const result = await this._api.get<string>(`/ai/v2/setup/${connectionId}`, { responseType: 'text' }); | ||
|
|
||
| if (result !== null) { | ||
| this._router.navigate([`/dashboard/${connectionId}`]); | ||
| } else { | ||
| this.loading.set(false); | ||
| this.errorMessage.set('Auto-configuration could not be completed. You can still configure your tables manually.'); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 error handling logic assumes that a null result always indicates an error, but the API service returns null for any error (including network errors, 401 unauthorized, 404 not found, etc.). This makes it impossible to distinguish between different types of failures or provide more specific error messages to users. Consider checking the specific error type or HTTP status code to provide more contextual error messages, especially for cases like permission denied or connection not found.