Skip to content

Commit e464e21

Browse files
committed
Merge branch 'main' into backend_pg_proxy
2 parents e0e5a0c + 218fdbc commit e464e21

4 files changed

Lines changed: 61 additions & 129 deletions

File tree

frontend/src/app/services/connections.service.spec.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@ import { ConnectionType, DBtype } from '../models/connection';
1111
import { AccessLevel } from '../models/user';
1212
import { CedarPermissionService } from './cedar-permission.service';
1313
import { ConnectionsService } from './connections.service';
14-
import { HostedDatabaseService } from './hosted-database.service';
1514
import { MasterPasswordService } from './master-password.service';
1615
import { NotificationsService } from './notifications.service';
17-
import { UserService } from './user.service';
1816
import { UsersService } from './users.service';
1917

2018
describe('ConnectionsService', () => {
@@ -26,8 +24,6 @@ describe('ConnectionsService', () => {
2624
let mockCanI: ReturnType<typeof vi.fn>;
2725
let mockCanIAny: ReturnType<typeof vi.fn>;
2826
let mockPermissions: Partial<CedarPermissionService>;
29-
let fakeHostedDatabaseService;
30-
let fakeUserService;
3127

3228
const connectionCredsApp = {
3329
title: 'Test connection via SSH tunnel to mySQL',
@@ -119,13 +115,6 @@ describe('ConnectionsService', () => {
119115
canIAny: mockCanIAny,
120116
ready: signal(false).asReadonly(),
121117
};
122-
fakeHostedDatabaseService = {
123-
listHostedDatabases: vi.fn().mockResolvedValue([]),
124-
};
125-
fakeUserService = {
126-
cast: of({ company: { id: 'test-company-id' } }),
127-
};
128-
129118
TestBed.configureTestingModule({
130119
imports: [MatSnackBarModule, MatDialogModule],
131120
providers: [
@@ -149,14 +138,6 @@ describe('ConnectionsService', () => {
149138
provide: CedarPermissionService,
150139
useValue: mockPermissions,
151140
},
152-
{
153-
provide: HostedDatabaseService,
154-
useValue: fakeHostedDatabaseService,
155-
},
156-
{
157-
provide: UserService,
158-
useValue: fakeUserService,
159-
},
160141
],
161142
});
162143

frontend/src/app/services/connections.service.ts

Lines changed: 7 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@ import { HttpClient } from '@angular/common/http';
22
import { Injectable } from '@angular/core';
33
import { NavigationEnd, Router } from '@angular/router';
44
import { IColorConfig, NgxThemeService } from '@brumeilde/ngx-theme';
5-
import { BehaviorSubject, EMPTY, firstValueFrom, throwError } from 'rxjs';
5+
import { BehaviorSubject, EMPTY, throwError } from 'rxjs';
66
import { catchError, filter, map } from 'rxjs/operators';
7+
import { environment } from 'src/environments/environment';
78
import { AlertActionType, AlertType } from '../models/alert';
89
import { Connection, ConnectionSettings, ConnectionType, DBtype } from '../models/connection';
910
import { AccessLevel } from '../models/user';
1011
import { CedarPermissionService } from './cedar-permission.service';
11-
import { HostedDatabaseService } from './hosted-database.service';
1212
import { MasterPasswordService } from './master-password.service';
1313
import { NotificationsService } from './notifications.service';
14-
import { UserService } from './user.service';
1514
import { UsersService } from './users.service';
1615

1716
interface LogParams {
@@ -73,8 +72,6 @@ export class ConnectionsService {
7372
public defaultDisplayTable: string;
7473
public ownConnections: Connection[] = null;
7574
public testConnections: Connection[] = null;
76-
public isHostedConnection: boolean = false;
77-
private hostedDatabaseHostnames: Set<string> = new Set();
7875

7976
private connectionNameSubject: BehaviorSubject<string> = new BehaviorSubject<string>('Rocketadmin');
8077
private connectionSigningKeySubject: BehaviorSubject<string> = new BehaviorSubject<string>(null);
@@ -94,8 +91,6 @@ export class ConnectionsService {
9491
private _usersService: UsersService,
9592
private _permissions: CedarPermissionService,
9693
public _themeService: NgxThemeService<IColorConfig<Palettes, Colors>>,
97-
private _hostedDatabaseService: HostedDatabaseService,
98-
private _userService: UserService,
9994
) {
10095
this.connection = { ...this.connectionInitialState };
10196
this.router = router;
@@ -145,6 +140,11 @@ export class ConnectionsService {
145140
return this.currentPage;
146141
}
147142

143+
get isHostedConnection(): boolean {
144+
const host = this.connection?.host;
145+
return !!environment.saas && !!host && host.endsWith('.db.rocketadmin.com');
146+
}
147+
148148
canEditConnection() {
149149
return this._permissions.canI('connection:edit', 'Connection', this.connectionID)();
150150
}
@@ -181,7 +181,6 @@ export class ConnectionsService {
181181

182182
setConnectionInfo(id: string) {
183183
this.defaultDisplayTable = null;
184-
this.isHostedConnection = false;
185184
if (id) {
186185
this.fetchConnection(id).subscribe((res) => {
187186
this.connection = res.connection;
@@ -219,7 +218,6 @@ export class ConnectionsService {
219218
},
220219
});
221220
}
222-
this.checkIfHostedConnection(res.connection.host);
223221
});
224222
} else {
225223
this.connection = { ...this.connectionInitialState };
@@ -237,9 +235,6 @@ export class ConnectionsService {
237235
},
238236
});
239237
}
240-
241-
console.log('this.defaultDisplayTable');
242-
console.log(this.defaultDisplayTable);
243238
}
244239

245240
isPermitted(accessLevel: AccessLevel) {
@@ -610,30 +605,4 @@ export class ConnectionsService {
610605
}),
611606
);
612607
}
613-
614-
private async checkIfHostedConnection(connectionHost: string) {
615-
if (!connectionHost) {
616-
this.isHostedConnection = false;
617-
return;
618-
}
619-
if (this.hostedDatabaseHostnames.size === 0) {
620-
await this.loadHostedDatabaseHostnames();
621-
}
622-
this.isHostedConnection = this.hostedDatabaseHostnames.has(connectionHost);
623-
}
624-
625-
private async loadHostedDatabaseHostnames() {
626-
try {
627-
const user = await firstValueFrom(this._userService.cast.pipe(filter((u) => !!u?.company?.id)));
628-
const databases = await this._hostedDatabaseService.listHostedDatabases(user.company.id);
629-
this.hostedDatabaseHostnames.clear();
630-
if (databases) {
631-
for (const db of databases) {
632-
this.hostedDatabaseHostnames.add(db.hostname);
633-
}
634-
}
635-
} catch {
636-
// Silently fail - non-hosted path will be used
637-
}
638-
}
639608
}

package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,13 @@
2222
"pnpm": {
2323
"overrides": {
2424
"cipher-base": "1.0.7",
25-
"tar-fs": "1.16.6"
25+
"tar-fs": "1.16.6",
26+
"ajv@>=7.0.0-alpha.0 <8.18.0": ">=8.18.0",
27+
"picomatch@>=4.0.0 <4.0.4": ">=4.0.4",
28+
"path-to-regexp@>=8.0.0 <8.4.0": ">=8.4.0",
29+
"lodash@>=4.0.0 <=4.17.23": ">=4.18.0",
30+
"lodash@<=4.17.23": ">=4.18.0",
31+
"@nestjs/core@<=11.1.17": ">=11.1.18"
2632
},
2733
"packageExtensions": {
2834
"ibm_db": {

0 commit comments

Comments
 (0)