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
73 changes: 51 additions & 22 deletions frontend/src/app/components/connect-db/connect-db.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,38 +270,66 @@ export class ConnectDBComponent implements OnInit, OnDestroy {

createConnection(connectForm: NgForm) {
if (this.db.connectionType === 'direct') {
const ipAddressDilaog = this.dialog.open(DbConnectionIpAccessDialogComponent, {
width: '36em',
data: {
db: this.db,
provider: this.getProvider()
}
});

ipAddressDilaog.afterClosed().subscribe( async (action) => {
if (action === 'confirmed') {
this.submitting = true;
let credsCorrect: TestConnection = null;

try {
(credsCorrect as any) = await this._connections.testConnection(this.connectionID, this.db).toPromise();
if (this.db.type !== DBtype.Dynamo) {
const ipAddressDilaog = this.dialog.open(DbConnectionIpAccessDialogComponent, {
width: '36em',
data: {
db: this.db,
provider: this.getProvider()
}
});

ipAddressDilaog.afterClosed().subscribe( async (action) => {
if (action === 'confirmed') {
this.submitting = true;
let credsCorrect: TestConnection = null;

try {
(credsCorrect as any) = await this._connections.testConnection(this.connectionID, this.db).toPromise();

this.angulartics2.eventTrack.next({
action: `Connect DB: automatic test connection on add is ${credsCorrect.result ? 'passed' : 'failed'}`,
properties: { connectionType: this.db.connectionType, dbType: this.db.type, errorMessage: credsCorrect.message }
});

if (credsCorrect && credsCorrect.result) {
this.createConnectionRequest();
} else {
this.handleConnectionError(credsCorrect.message);
};
} catch (e) {
credsCorrect = null;
this.submitting = false;
}
}
})
} else {
this.submitting = true;
let credsCorrect: TestConnection = null;

this._connections.testConnection(this.connectionID, this.db).toPromise()
.then((res: TestConnection) => {
credsCorrect = res;
this.angulartics2.eventTrack.next({
action: `Connect DB: automatic test connection on add is ${credsCorrect.result ? 'passed' : 'failed'}`,
properties: { connectionType: this.db.connectionType, dbType: this.db.type, errorMessage: credsCorrect.message }
properties: {
connectionType: this.db.connectionType,
dbType: this.db.type,
errorMessage: credsCorrect.message
}
});

if (credsCorrect && credsCorrect.result) {
this.createConnectionRequest();
} else {
this.handleConnectionError(credsCorrect.message);
};
} catch (e) {
}
})
.catch((e) => {
credsCorrect = null;
this.submitting = false;
}
}
})
});
}

} else {
this.createConnectionRequest();
}
Expand Down Expand Up @@ -340,6 +368,7 @@ export class ConnectDBComponent implements OnInit, OnDestroy {
getProvider() {
let provider: string = null;
if (this.db.host.endsWith('.amazonaws.com')) provider = 'amazon';
if (this.db.host.endsWith('.amazonaws.com') && this.db.type === DBtype.Dynamo) provider = 'amazonDynamoDB';
if (this.db.host.endsWith('.azure.com')) provider = 'azure';
if (this.db.host.endsWith('.mongodb.net')) provider = 'mongoatlas';
if (this.db.host.endsWith('.ondigitalocean.com')) provider = 'digitalocean';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,17 @@ export class DbConnectionConfirmDialogComponent implements OnInit {
google: 'Google Cloud Platform',
mongoatlas: 'MongoDB Atlas',
digitalocean: 'DigitalOcean',

amazonDynamoDB: 'Amazon DynamoDB',
};
public providerDocsLink = {
amazon: 'https://docs.rocketadmin.com/Create%20connections/Direct%20connection/create_aws_mysql',
azure: 'https://learn.microsoft.com/en-us/azure/mysql/flexible-server/how-to-manage-firewall-portal',
google: 'https://docs.rocketadmin.com/Create%20connections/Direct%20connection/create_google_cloud',
mongoatlas: 'https://docs.rocketadmin.com/Create%20connections/Direct%20connection/create_mongo_atlas',
digitalocean: 'https://docs.rocketadmin.com/Create%20connections/Direct%20connection/create_digitalocean_postgresql',

amazonDynamoDB: 'https://docs.rocketadmin.com/Create%20connections/Direct%20connection/create_aws_dynamodb',
}

constructor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ import { MatDialogModule } from '@angular/material/dialog';
import { MatExpansionModule } from '@angular/material/expansion';
import { MatIconModule } from '@angular/material/icon';
import { MatInputModule } from '@angular/material/input';
import { MatListModule } from '@angular/material/list';
import { MatSelectModule } from '@angular/material/select';
import { MatTooltipModule } from '@angular/material/tooltip';
import { NotificationsService } from 'src/app/services/notifications.service';
import { PlaceholderRowEditComponent } from '../skeletons/placeholder-row-edit/placeholder-row-edit.component';
import { RouterModule } from '@angular/router';
import { Subscription } from 'rxjs';
import { TableRowService } from 'src/app/services/table-row.service';
import { TableStateService } from 'src/app/services/table-state.service';
import { TablesService } from 'src/app/services/tables.service';
import { Title } from '@angular/platform-browser';
import { getTableTypes } from 'src/app/lib/setup-table-row-structure';
import { normalizeTableName } from '../../lib/normalize';
import { MatListModule } from '@angular/material/list';
import { Subscription } from 'rxjs';

@Component({
selector: 'app-db-table-row-edit',
Expand Down Expand Up @@ -195,6 +195,9 @@ export class DbTableRowEditComponent implements OnInit {

this.nonModifyingFields = res.structure.filter((field: TableField) => !this.getModifyingFields(res.structure).some(modifyingField => field.column_name === modifyingField.column_name)).map((field: TableField) => field.column_name);
this.readonlyFields = [...res.readonly_fields, ...this.nonModifyingFields];
if (this.connectionType === DBtype.Dynamo) {
this.readonlyFields = [...this.readonlyFields, ...res.primaryColumns.map((field: TableField) => field.column_name)];
}
this.tableForeignKeys = res.foreignKeys;
// this.shownRows = res.structure.filter((field: TableField) => !field.column_default?.startsWith('nextval'));
this.tableRowValues = {...res.row};
Expand Down Expand Up @@ -386,7 +389,6 @@ export class DbTableRowEditComponent implements OnInit {
}

updateField = (updatedValue: any, field: string) => {
console.log(typeof(updatedValue));
if (typeof(updatedValue) === 'object' && updatedValue !== null) {
for (const prop of Object.getOwnPropertyNames(this.tableRowValues[field])) {
delete this.tableRowValues[field][prop];
Expand Down Expand Up @@ -431,6 +433,14 @@ export class DbTableRowEditComponent implements OnInit {
}
//end crutch

// don't ovverride primary key fields for dynamoDB
if (this.connectionType === DBtype.Dynamo) {
const primaryKeyFields = Object.keys(this.keyAttributesFromURL);
primaryKeyFields.forEach((field) => {
delete updatedRow[field];
});
}

//parse json fields
const jsonFields = Object.entries(this.tableTypes)
.filter(([key, value]) => value === 'json' || value === 'jsonb' || value === 'array' || value === 'object')
Expand Down
Loading