-
-
Notifications
You must be signed in to change notification settings - Fork 18
Elasticsearch db #1446
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
Merged
Elasticsearch db #1446
Changes from all commits
Commits
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
14 changes: 14 additions & 0 deletions
14
...t-db/db-credentials-forms/elastic-credentials-form/elastic-credentials-form.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,14 @@ | ||
| .connectForm__hostname, | ||
| .connectForm__port { | ||
| padding-bottom: 20px; | ||
| } | ||
|
|
||
| @media (width <= 600px) { | ||
| .connectForm__hostname { | ||
| padding-bottom: 44px; | ||
| } | ||
|
|
||
| .connectForm__port { | ||
| padding-bottom: 0; | ||
| } | ||
| } |
188 changes: 188 additions & 0 deletions
188
...-db/db-credentials-forms/elastic-credentials-form/elastic-credentials-form.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,188 @@ | ||||||
| <mat-form-field appearance="outline" class="connectForm__hostname credentials-fieldset__1-3-columns"> | ||||||
| <mat-label>Hostname</mat-label> | ||||||
| <input matInput name="hostname" #hostname="ngModel" | ||||||
| data-testid="connection-hostname-input" | ||||||
| angulartics2On="change" | ||||||
| angularticsAction="Connection creds {{ connection.id ? 'edit' : 'add' }}: hostname is edited" | ||||||
| required hostnameValidator | ||||||
| [readonly]="(accessLevel === 'readonly' || connection.isTestConnection) && connection.id" | ||||||
| [disabled]="submitting" | ||||||
| [(ngModel)]="connection.host"> | ||||||
| <mat-hint> | ||||||
| E.g. <strong><code>cluster-123456.es.europe-west1.gcp.elastic-cloud.com</code></strong><br> | ||||||
| Connections from internal IPs (e.g. localhost) are not supported | ||||||
| </mat-hint> | ||||||
|
|
||||||
| <mat-error *ngIf="hostname.errors?.isLocalhost && hostname.invalid"> | ||||||
| To connect a database to an internal IP, use something like <strong>Pinggy</strong> | ||||||
| (<a [href]="tunnelingServiceLink" target="_blank" class="credentials-fieldset__hint-link">here's a guide</a>), | ||||||
| or <button type="button" (click)="switchToAgent.emit()" class="credentials-fieldset__hint-button">click here</button> to connect through an agent | ||||||
| </mat-error> | ||||||
| <mat-error *ngIf="hostname.errors?.isInvalidHostname && hostname.invalid">Hostname is invalid</mat-error> | ||||||
| </mat-form-field> | ||||||
|
|
||||||
| <mat-form-field appearance="outline" class="connectForm__port"> | ||||||
| <mat-label>Port</mat-label> | ||||||
| <input matInput type="number" name="port" #port="ngModel" | ||||||
| data-testid="connection-port-input" | ||||||
| angulartics2On="change" | ||||||
| angularticsAction="Connection creds {{ connection.id ? 'edit' : 'add' }}: port is edited" | ||||||
| required | ||||||
| [readonly]="(accessLevel === 'readonly' || connection.isTestConnection) && connection.id" | ||||||
| [disabled]="submitting" | ||||||
| [(ngModel)]="connection.port"> | ||||||
| <mat-error *ngIf="port.errors?.required && (port.invalid && port.touched)">Port should not be empty</mat-error> | ||||||
| </mat-form-field> | ||||||
|
|
||||||
| <mat-form-field appearance="outline" class="credentials-fieldset__1-2-columns"> | ||||||
| <mat-label>Username</mat-label> | ||||||
| <input matInput name="username" #username="ngModel" | ||||||
| data-testid="connection-username-input" | ||||||
| angulartics2On="change" | ||||||
| angularticsAction="Connection creds {{ connection.id ? 'edit' : 'add' }}: username is edited" | ||||||
| required | ||||||
| [readonly]="readonly" | ||||||
| [disabled]="submitting" | ||||||
| [(ngModel)]="connection.username"> | ||||||
| <mat-error *ngIf="username.errors?.required && (username.invalid && username.touched)">Username should not be empty</mat-error> | ||||||
| </mat-form-field> | ||||||
|
|
||||||
| <mat-form-field appearance="outline" class="credentials-fieldset__3-4-columns"> | ||||||
| <mat-label>Password</mat-label> | ||||||
| <input type="password" matInput name="password" #password="ngModel" | ||||||
| data-testid="connection-password-input" | ||||||
| angulartics2On="change" | ||||||
| angularticsAction="Connection creds {{ connection.id ? 'edit' : 'add' }}: password is edited" | ||||||
| [required]="!connection.id || hostname.touched || port.touched" | ||||||
| [readonly]="(accessLevel === 'readonly' || connection.isTestConnection) && connection.id" | ||||||
| [disabled]="submitting" | ||||||
| [(ngModel)]="connection.password"> | ||||||
| <mat-hint *ngIf="connection.id && (hostname.pristine && port.pristine)">To keep password the same keep this field blank</mat-hint> | ||||||
| <mat-hint *ngIf="connection.id && (hostname.dirty || port.dirty)">Password needed due to hostname/port change</mat-hint> | ||||||
| </mat-form-field> | ||||||
|
|
||||||
| <mat-expansion-panel class="credentials-fieldset__1-4-columns"> | ||||||
| <mat-expansion-panel-header data-testid="connection-advanced-settings-expansion-panel-header"> | ||||||
| <mat-panel-title> | ||||||
| Advanced settings | ||||||
| </mat-panel-title> | ||||||
| </mat-expansion-panel-header> | ||||||
|
|
||||||
| <div class="advanced-settings"> | ||||||
| <app-master-encryption-password class="advanced-settings__fullLine" | ||||||
| [masterKey]="masterKey" | ||||||
| [disabled]="accessLevel === 'readonly' || submitting || connection.isTestConnection" | ||||||
| (onMasterKeyChange)="handleMasterKeyChange($event)"> | ||||||
| </app-master-encryption-password> | ||||||
|
|
||||||
| <mat-form-field appearance="outline" class="advanced-settings__fullLine"> | ||||||
| <mat-label>Username</mat-label> | ||||||
| <input matInput name="username" #username="ngModel" | ||||||
| data-testid="connection-username-input" | ||||||
| angulartics2On="change" | ||||||
| angularticsAction="Connection creds {{ connection.id ? 'edit' : 'add' }}: username is edited" | ||||||
| [readonly]="(accessLevel === 'readonly' || connection.isTestConnection) && connection.id" | ||||||
| [disabled]="submitting" | ||||||
| [(ngModel)]="connection.username"> | ||||||
| <mat-error *ngIf="username.errors?.required && (username.invalid && username.touched)">Username should not be empty</mat-error> | ||||||
| </mat-form-field> | ||||||
|
|
||||||
| <mat-form-field appearance="outline" class="advanced-settings__fullLine"> | ||||||
| <mat-label>Database name</mat-label> | ||||||
| <input matInput name="database" #database="ngModel" | ||||||
| data-testid="connection-database-input" | ||||||
| angulartics2On="change" | ||||||
| angularticsAction="Connection creds {{ connection.id ? 'edit' : 'add' }}: database name is edited" | ||||||
| [readonly]="(accessLevel === 'readonly' || connection.isTestConnection) && connection.id" | ||||||
| [disabled]="submitting" | ||||||
| [(ngModel)]="connection.database"> | ||||||
| <mat-error *ngIf="database.errors?.required && (database.invalid && database.touched)">Name should not be empty</mat-error> | ||||||
| </mat-form-field> | ||||||
|
|
||||||
| <mat-checkbox class="checkbox-line advanced-settings__fullLine" name="ssh" #ssh="ngModel" | ||||||
| data-testid="connection-ssh-checkbox" | ||||||
| labelPosition="after" | ||||||
| angulartics2On="click" | ||||||
| angularticsAction="Connection creds {{ connection.id ? 'edit' : 'add' }}: SSH is switched" | ||||||
| [angularticsProperties]="{'enable': connection.ssh}" | ||||||
| [disabled]="submitting || connection.isTestConnection" | ||||||
| [(ngModel)]="connection.ssh"> | ||||||
| Use SSH tunnel | ||||||
| </mat-checkbox> | ||||||
|
|
||||||
| <mat-form-field *ngIf="connection.ssh" appearance="outline" floatLabel="always" class="advanced-settings__fullLine"> | ||||||
| <mat-label>Private SSH key</mat-label> | ||||||
| <textarea matInput resizeToFitContent rows="8" name="privateSSHKey" #privateSSHKey="ngModel" | ||||||
| placeholder="Sensitive — write-only field" | ||||||
| data-testid="connection-ssh-key-textarea" | ||||||
| angulartics2On="change" | ||||||
| angularticsAction="Connection creds {{ connection.id ? 'edit' : 'add' }}: SSH key is edited" | ||||||
| [required]="connection.ssh && !connection.id" [readonly]="accessLevel === 'readonly' && connection.id" | ||||||
| [disabled]="submitting" | ||||||
| [(ngModel)]="connection.privateSSHKey" | ||||||
| ></textarea> | ||||||
| <mat-error *ngIf="privateSSHKey.errors?.required && (privateSSHKey.invalid && privateSSHKey.touched)">Private SSH key should not be empty</mat-error> | ||||||
| </mat-form-field> | ||||||
|
|
||||||
| <mat-form-field *ngIf="connection.ssh" appearance="outline"> | ||||||
| <mat-label>SSH host</mat-label> | ||||||
| <input matInput name="sshHost" #sshHost="ngModel" | ||||||
| data-testid="connection-ssh-host-input" | ||||||
| angulartics2On="change" | ||||||
| angularticsAction="Connection creds {{ connection.id ? 'edit' : 'add' }}: SSH host is edited" | ||||||
| [required]="connection.ssh" [readonly]="accessLevel === 'readonly' && connection.id" | ||||||
| [disabled]="submitting" | ||||||
| [(ngModel)]="connection.sshHost"> | ||||||
| <mat-error *ngIf="sshHost.errors?.required && (sshHost.invalid && sshHost.touched)">SSH host should not be empty</mat-error> | ||||||
| </mat-form-field> | ||||||
|
|
||||||
| <mat-form-field *ngIf="connection.ssh" appearance="outline"> | ||||||
| <mat-label>SSH port</mat-label> | ||||||
| <input matInput type="number" name="sshPort" #sshPort="ngModel" | ||||||
| data-testid="connection-ssh-port-input" | ||||||
| angulartics2On="change" | ||||||
| angularticsAction="Connection creds {{ connection.id ? 'edit' : 'add' }}: SSH port is edited" | ||||||
| [required]="connection.ssh" [readonly]="accessLevel === 'readonly' && connection.id" | ||||||
| [disabled]="submitting" | ||||||
| [(ngModel)]="connection.sshPort"> | ||||||
| <mat-error *ngIf="sshPort.errors?.required && (sshPort.invalid && sshPort.touched)">SSH port should not be empty</mat-error> | ||||||
| </mat-form-field> | ||||||
|
|
||||||
| <mat-form-field *ngIf="connection.ssh" appearance="outline" floatLabel="always"> | ||||||
| <mat-label>SSH username</mat-label> | ||||||
| <input matInput name="sshUsername" #sshUsername="ngModel" | ||||||
| placeholder="Sensitive — write-only field" | ||||||
| data-testid="connection-ssh-username-input" | ||||||
| angulartics2On="change" | ||||||
| angularticsAction="Connection creds {{ connection.id ? 'edit' : 'add' }}: SSH username is edited" | ||||||
| [required]="connection.ssh" [readonly]="accessLevel === 'readonly' && connection.id" | ||||||
| [disabled]="submitting" | ||||||
| [(ngModel)]="connection.sshUsername"> | ||||||
| <mat-error *ngIf="sshUsername.errors?.required && (sshUsername.invalid && sshUsername.touched)">SSH username should not be empty</mat-error> | ||||||
| </mat-form-field> | ||||||
|
|
||||||
| <mat-checkbox class="checkbox-line advanced-settings__fullLine" name="ssl" #ssh="ngModel" | ||||||
|
||||||
| <mat-checkbox class="checkbox-line advanced-settings__fullLine" name="ssl" #ssh="ngModel" | |
| <mat-checkbox class="checkbox-line advanced-settings__fullLine" name="ssl" #ssl="ngModel" |
61 changes: 61 additions & 0 deletions
61
.../db-credentials-forms/elastic-credentials-form/elastic-credentials-form.component.spec.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,61 @@ | ||
| import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
|
||
| import { Angulartics2Module } from 'angulartics2'; | ||
| import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; | ||
| import { ElasticCredentialsFormComponent } from './elastic-credentials-form.component'; | ||
| import { FormsModule } from '@angular/forms'; | ||
| import { MatCheckboxModule } from '@angular/material/checkbox'; | ||
| import { provideHttpClient } from '@angular/common/http'; | ||
|
|
||
| describe('ElasticCredentialsFormComponent', () => { | ||
| let component: ElasticCredentialsFormComponent; | ||
| let fixture: ComponentFixture<ElasticCredentialsFormComponent>; | ||
|
|
||
| beforeEach(async () => { | ||
| await TestBed.configureTestingModule({ | ||
| imports: [ | ||
| FormsModule, | ||
| MatCheckboxModule, | ||
| BrowserAnimationsModule, | ||
| Angulartics2Module.forRoot({}), | ||
| ElasticCredentialsFormComponent | ||
| ], | ||
| providers: [provideHttpClient()] | ||
| }) | ||
| .compileComponents(); | ||
|
|
||
| fixture = TestBed.createComponent(ElasticCredentialsFormComponent); | ||
| component = fixture.componentInstance; | ||
|
|
||
| component.connection = { | ||
| id: "12345678" | ||
| } as any; | ||
|
|
||
| // component.connection = { | ||
| // "title": "Test connection via SSH tunnel to mySQL", | ||
| // "masterEncryption": false, | ||
| // "type": DBtype.MySQL, | ||
| // "host": "database-2.cvfuxe8nltiq.us-east-2.rds.amazonaws.com", | ||
| // "port": "3306", | ||
| // "username": "admin", | ||
| // "database": "testDB", | ||
| // "schema": null, | ||
| // "sid": null, | ||
| // "id": "9d5f6d0f-9516-4598-91c4-e4fe6330b4d4", | ||
| // "ssh": true, | ||
| // "sshHost": "3.134.99.192", | ||
| // "sshPort": '22', | ||
| // "sshUsername": "ubuntu", | ||
| // "ssl": false, | ||
| // "cert": null, | ||
| // "connectionType": ConnectionType.Direct, | ||
| // "azure_encryption": false, | ||
| // "signing_key": '' | ||
| // }; | ||
| fixture.detectChanges(); | ||
| }); | ||
|
|
||
| it('should create', () => { | ||
| expect(component).toBeTruthy(); | ||
| }); | ||
| }); |
31 changes: 31 additions & 0 deletions
31
...ct-db/db-credentials-forms/elastic-credentials-form/elastic-credentials-form.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,31 @@ | ||
| import { Angulartics2Module } from 'angulartics2'; | ||
| import { BaseCredentialsFormComponent } from '../base-credentials-form/base-credentials-form.component'; | ||
| import { Component } from '@angular/core'; | ||
| import { FormsModule } from '@angular/forms'; | ||
| import { HostnameValidationDirective } from 'src/app/directives/hostnameValidator.directive'; | ||
| import { MasterEncryptionPasswordComponent } from '../../master-encryption-password/master-encryption-password.component'; | ||
| import { MatCheckboxModule } from '@angular/material/checkbox'; | ||
| import { MatExpansionModule } from '@angular/material/expansion'; | ||
| import { MatFormFieldModule } from '@angular/material/form-field'; | ||
| import { MatInputModule } from '@angular/material/input'; | ||
| import { NgIf } from '@angular/common'; | ||
|
|
||
| @Component({ | ||
| selector: 'app-elastic-credentials-form', | ||
| templateUrl: './elastic-credentials-form.component.html', | ||
| styleUrls: ['../base-credentials-form/base-credentials-form.component.css', './elastic-credentials-form.component.css'], | ||
| imports: [ | ||
| NgIf, | ||
| FormsModule, | ||
| MatFormFieldModule, | ||
| MatInputModule, | ||
| MatCheckboxModule, | ||
| MatExpansionModule, | ||
| HostnameValidationDirective, | ||
| MasterEncryptionPasswordComponent, | ||
| Angulartics2Module | ||
| ] | ||
| }) | ||
| export class ElasticCredentialsFormComponent extends BaseCredentialsFormComponent { | ||
|
|
||
| } |
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
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.
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.
Duplicate "Username" field. This field is already defined at lines 38-48 with
requiredvalidation. The duplicate field in the advanced settings section (lines 78-88) should be removed. For comparison, other credential forms like Postgres only have the username field once in the main form section, not duplicated in advanced settings.