@@ -2,16 +2,15 @@ import { HttpClient } from '@angular/common/http';
22import { Injectable } from '@angular/core' ;
33import { NavigationEnd , Router } from '@angular/router' ;
44import { IColorConfig , NgxThemeService } from '@brumeilde/ngx-theme' ;
5- import { BehaviorSubject , EMPTY , firstValueFrom , throwError } from 'rxjs' ;
5+ import { BehaviorSubject , EMPTY , throwError } from 'rxjs' ;
66import { catchError , filter , map } from 'rxjs/operators' ;
7+ import { environment } from 'src/environments/environment' ;
78import { AlertActionType , AlertType } from '../models/alert' ;
89import { Connection , ConnectionSettings , ConnectionType , DBtype } from '../models/connection' ;
910import { AccessLevel } from '../models/user' ;
1011import { CedarPermissionService } from './cedar-permission.service' ;
11- import { HostedDatabaseService } from './hosted-database.service' ;
1212import { MasterPasswordService } from './master-password.service' ;
1313import { NotificationsService } from './notifications.service' ;
14- import { UserService } from './user.service' ;
1514import { UsersService } from './users.service' ;
1615
1716interface 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}
0 commit comments