diff --git a/frontend/src/app/components/connect-db/connect-db.component.ts b/frontend/src/app/components/connect-db/connect-db.component.ts index c6c0776e6..7fe35917b 100644 --- a/frontend/src/app/components/connect-db/connect-db.component.ts +++ b/frontend/src/app/components/connect-db/connect-db.component.ts @@ -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(); } @@ -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'; diff --git a/frontend/src/app/components/connect-db/db-connection-confirm-dialog/db-connection-confirm-dialog.component.ts b/frontend/src/app/components/connect-db/db-connection-confirm-dialog/db-connection-confirm-dialog.component.ts index 0dbce7165..e8d94bbc4 100644 --- a/frontend/src/app/components/connect-db/db-connection-confirm-dialog/db-connection-confirm-dialog.component.ts +++ b/frontend/src/app/components/connect-db/db-connection-confirm-dialog/db-connection-confirm-dialog.component.ts @@ -27,6 +27,8 @@ 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', @@ -34,6 +36,8 @@ export class DbConnectionConfirmDialogComponent implements OnInit { 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( diff --git a/frontend/src/app/components/db-table-row-edit/db-table-row-edit.component.ts b/frontend/src/app/components/db-table-row-edit/db-table-row-edit.component.ts index c9cf2c679..eeb01f3ee 100644 --- a/frontend/src/app/components/db-table-row-edit/db-table-row-edit.component.ts +++ b/frontend/src/app/components/db-table-row-edit/db-table-row-edit.component.ts @@ -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', @@ -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}; @@ -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]; @@ -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')