-
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathconnect-db.component.html
More file actions
373 lines (344 loc) · 18.7 KB
/
connect-db.component.html
File metadata and controls
373 lines (344 loc) · 18.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
<app-alert></app-alert>
<app-alert *ngIf="isDemo" [alert]="isDemoConnectionWarning"></app-alert>
<div class="connectPage">
<form #connectForm="ngForm" class="form"
(ngSubmit)="handleCredentialsSubmitting(connectForm)">
<h1 class="mat-h1 connectForm__fullLine">
{{ connectionID ? 'Edit credentials' : 'Connect database' }}
</h1>
<mat-form-field appearance="outline" class="connectForm__title">
<mat-label>Connection name</mat-label>
<input matInput name="title" #title="ngModel"
data-testid="connection-title-input"
angulartics2On="change"
angularticsAction="Connection creds {{ db.id ? 'edit' : 'add' }}: title is edited"
(change)="posthog.capture('Connection creds {{ db.id ? \'edit\' : \'add\' }}: title is edited')"
[required]="db.connectionType === 'agent'"
[readonly]="(accessLevel === 'readonly' || db.isTestConnection) && db.id"
[disabled]="submitting"
[(ngModel)]="db.title">
</mat-form-field>
<mat-form-field appearance="outline">
<mat-label>Database type</mat-label>
<mat-select name="dbtype" #dbtype="ngModel"
data-testid="connection-dbtype-select"
angulartics2On="click"
angularticsAction="Connection creds {{ db.id ? 'edit' : 'add' }}: db type is selected"
(click)="posthog.capture('Connection creds {{ db.id ? \'edit\' : \'add\' }}: db type is selected')"
[angularticsProperties]="{'dbType': db.type}"
[disabled]="submitting"
[(ngModel)]="db.type"
(ngModelChange)="dbTypeChange()" >
<mat-option *ngFor="let dbType of supportedOrderedDatabases" [value]="dbType">
{{supportedDatabasesTitles[dbType]}}
</mat-option>
</mat-select>
</mat-form-field>
<div class="connectForm__fullLine">
<mat-button-toggle-group name="connectionType"
data-testid="connection-type-toggle"
class="connectForm__typeSwitch"
[disabled]="submitting || db.isTestConnection || db.type === 'dynamodb'"
[(ngModel)]="db.connectionType">
<mat-button-toggle value="direct">Direct connection</mat-button-toggle>
<mat-button-toggle value="agent">Agent connection</mat-button-toggle>
</mat-button-toggle-group>
</div>
<div *ngIf="db && db.connectionType === 'direct' && !db.isTestConnection && isSaas && db.type !== 'dynamodb'"
data-testid="direct-connection-warning"
class="connectForm__fullLine">
<div *ngIf="connectionID; else warningAlert" class="warningMessage">
<mat-icon class="warningMessage__icon">warning_amber</mat-icon>
<div class="mat-body-1">
Please make sure our servers are able to access your database. <br/> Rocketadmin uses the IP address
<app-ip-address-button ip="18.221.81.73"></app-ip-address-button>
for all outbound requests.
</div>
</div>
<ng-template #warningAlert>
<app-alert [alert]="warning" class="connectForm__ipAlert">
<div class="mat-body-1" style="margin-bottom: 0">
Please make sure our servers are able to access your database. <br/> Rocketadmin uses the IP address
<app-ip-address-button ip="18.221.81.73"></app-ip-address-button>
for all outbound requests.
</div>
</app-alert>
</ng-template>
</div>
<app-mysql-credentials-form *ngIf="db.type === 'mysql' && db.connectionType === 'direct'"
[ngClass]="{
'credentials-fieldset': !db.isTestConnection,
'credentials-fieldset-no-warning': db.isTestConnection || !isSaas
}"
[connection]="db"
[submitting]="submitting"
[accessLevel]="accessLevel"
[masterKey]="masterKey"
[readonly]="(accessLevel === 'readonly' || db.isTestConnection) && db.id"
(switchToAgent)="switchToAgent()"
(masterKeyChange)="handleMasterKeyChange($event)">
</app-mysql-credentials-form>
<app-postgres-credentials-form *ngIf="db.type === 'postgres' && db.connectionType === 'direct'"
[ngClass]="{
'credentials-fieldset': !db.isTestConnection,
'credentials-fieldset-no-warning': db.isTestConnection || !isSaas
}"
[connection]="db"
[submitting]="submitting"
[accessLevel]="accessLevel"
[masterKey]="masterKey"
[readonly]="(accessLevel === 'readonly' || db.isTestConnection) && db.id"
(switchToAgent)="switchToAgent"
(masterKeyChange)="handleMasterKeyChange($event)">
</app-postgres-credentials-form>
<app-mongodb-credentials-form *ngIf="db.type === 'mongodb' && db.connectionType === 'direct'"
[ngClass]="{
'credentials-fieldset': !db.isTestConnection,
'credentials-fieldset-no-warning': db.isTestConnection || !isSaas
}"
[connection]="db"
[submitting]="submitting"
[accessLevel]="accessLevel"
[masterKey]="masterKey"
[readonly]="(accessLevel === 'readonly' || db.isTestConnection) && db.id"
(switchToAgent)="switchToAgent"
(masterKeyChange)="handleMasterKeyChange($event)">
</app-mongodb-credentials-form>
<app-dynamodb-credentials-form *ngIf="db.type === 'dynamodb' && db.connectionType === 'direct'"
class="credentials-fieldset-no-warning"
[connection]="db"
[submitting]="submitting"
[accessLevel]="accessLevel"
[masterKey]="masterKey"
[readonly]="(accessLevel === 'readonly' || db.isTestConnection) && db.id"
(switchToAgent)="switchToAgent"
(masterKeyChange)="handleMasterKeyChange($event)">
</app-dynamodb-credentials-form>
<app-cassandra-credentials-form *ngIf="db.type === 'cassandra' && db.connectionType === 'direct'"
[ngClass]="{
'credentials-fieldset': !db.isTestConnection,
'credentials-fieldset-no-warning': db.isTestConnection || !isSaas
}"
[connection]="db"
[submitting]="submitting"
[accessLevel]="accessLevel"
[masterKey]="masterKey"
[readonly]="(accessLevel === 'readonly' || db.isTestConnection) && db.id"
(switchToAgent)="switchToAgent"
(masterKeyChange)="handleMasterKeyChange($event)">
</app-cassandra-credentials-form>
<app-oracledb-credentials-form *ngIf="db.type === 'oracledb' && db.connectionType === 'direct'"
[ngClass]="{
'credentials-fieldset': !db.isTestConnection,
'credentials-fieldset-no-warning': db.isTestConnection || !isSaas
}"
[connection]="db"
[submitting]="submitting"
[accessLevel]="accessLevel"
[masterKey]="masterKey"
[readonly]="(accessLevel === 'readonly' || db.isTestConnection) && db.id"
(switchToAgent)="switchToAgent"
(masterKeyChange)="handleMasterKeyChange($event)">
</app-oracledb-credentials-form>
<app-mssql-credentials-form *ngIf="db.type === 'mssql' && db.connectionType === 'direct'"
[ngClass]="{
'credentials-fieldset': !db.isTestConnection,
'credentials-fieldset-no-warning': db.isTestConnection || !isSaas
}"
[connection]="db"
[submitting]="submitting"
[accessLevel]="accessLevel"
[masterKey]="masterKey"
[readonly]="(accessLevel === 'readonly' || db.isTestConnection) && db.id"
(switchToAgent)="switchToAgent"
(masterKeyChange)="handleMasterKeyChange($event)">
</app-mssql-credentials-form>
<app-redis-credentials-form *ngIf="db.type === 'redis' && db.connectionType === 'direct'"
[ngClass]="{
'credentials-fieldset': !db.isTestConnection,
'credentials-fieldset-no-warning': db.isTestConnection || !isSaas
}"
[connection]="db"
[submitting]="submitting"
[accessLevel]="accessLevel"
[masterKey]="masterKey"
[readonly]="(accessLevel === 'readonly' || db.isTestConnection) && db.id"
(switchToAgent)="switchToAgent"
(masterKeyChange)="handleMasterKeyChange($event)">
</app-redis-credentials-form>
<app-elastic-credentials-form *ngIf="db.type === 'elasticsearch' && db.connectionType === 'direct'"
[ngClass]="{
'credentials-fieldset': !db.isTestConnection,
'credentials-fieldset-no-warning': db.isTestConnection || !isSaas
}"
[connection]="db"
[submitting]="submitting"
[accessLevel]="accessLevel"
[masterKey]="masterKey"
[readonly]="(accessLevel === 'readonly' || db.isTestConnection) && db.id"
(switchToAgent)="switchToAgent"
(masterKeyChange)="handleMasterKeyChange($event)">
</app-elastic-credentials-form>
<app-clickhouse-credentials-form *ngIf="db.type === 'clickhouse' && db.connectionType === 'direct'"
[ngClass]="{
'credentials-fieldset': !db.isTestConnection,
'credentials-fieldset-no-warning': db.isTestConnection || !isSaas
}"
[connection]="db"
[submitting]="submitting"
[accessLevel]="accessLevel"
[masterKey]="masterKey"
[readonly]="(accessLevel === 'readonly' || db.isTestConnection) && db.id"
(switchToAgent)="switchToAgent()"
(masterKeyChange)="handleMasterKeyChange($event)">
</app-clickhouse-credentials-form>
<app-db2-credentials-form *ngIf="db.type === 'ibmdb2' && db.connectionType === 'direct'"
[ngClass]="{
'credentials-fieldset': !db.isTestConnection,
'credentials-fieldset-no-warning': db.isTestConnection || !isSaas
}"
[connection]="db"
[submitting]="submitting"
[accessLevel]="accessLevel"
[masterKey]="masterKey"
[readonly]="(accessLevel === 'readonly' || db.isTestConnection) && db.id"
(switchToAgent)="switchToAgent"
(masterKeyChange)="handleMasterKeyChange($event)">
</app-db2-credentials-form>
<div *ngIf="db.connectionType === 'agent'" class="connectForm__fullLine instruction">
<div class="instruction__docker">
<p class="mat-body-1">
Visit our DockerHub page to install the Rocketadmin agent.
</p>
<a mat-flat-button color="accent" class="github-button"
href="https://hub.docker.com/r/rocketadmin/rocketadmin-agent" target="_blank"
data-testid="connection-agent-dockerhub-link"
angulartics2On="click"
angularticsAction="Connection creds {{ db.id ? 'edit' : 'add' }}: open github agent page"
(click)="posthog.capture('Connection creds {{ db.id ? \'edit\' : \'add\' }}: open github agent page')">
<svg class="github-icon" xmlns="http://www.w3.org/2000/svg"
aria-label="Docker" role="img"
viewBox="0 0 512 512"><rect
width="512" height="512"
rx="15%"
fill="transparent"/><path stroke="#fff" stroke-width="38" d="M296 226h42m-92 0h42m-91 0h42m-91 0h41m-91 0h42m8-46h41m8 0h42m7 0h42m-42-46h42"/><path fill="#fff" d="m472 228s-18-17-55-11c-4-29-35-46-35-46s-29 35-8 74c-6 3-16 7-31 7H68c-5 19-5 145 133 145 99 0 173-46 208-130 52 4 63-39 63-39"/></svg>
<span>Install Rocketadmin agent</span>
</a>
<p class="mat-body-1">
Once the installation is successfully completed, the new connection will appear in the list of your admin panels.
</p>
<a mat-stroked-button color="accent"
href="https://docs.rocketadmin.com/Create%20connections/Agent%20connection/agent_connection"
target="_blank"
data-testid="connection-agent-instruction-link"
angulartics2On="click"
angularticsAction="Connection creds {{ db.id ? 'edit' : 'add' }}: open agent connection instruction"
(click)="posthog.capture('Connection creds {{ db.id ? \'edit\' : \'add\' }}: open agent connection instruction')">
Check out the complete guide
</a>
</div>
<div *ngIf="connectionToken" class="agent-token">
<mat-form-field appearance="outline" style="width:100%">
<mat-label>Token</mat-label>
<input matInput name="token" #token="ngModel" readonly
data-testid="connection-agent-token-input"
[(ngModel)]="connectionToken">
<mat-hint>
Please save this token and use it to configure your agent connection in .config.env file.
</mat-hint>
</mat-form-field>
<button type="button" mat-icon-button
data-testid="connection-agent-token-copy-button"
class="agent-token__copy-button"
matTooltip="Copy mater password"
[cdkCopyToClipboard]="connectionToken"
(cdkCopyToClipboardCopied)="showCopyNotification('Connection token was copied to clipboard.')">
<mat-icon>content_copy</mat-icon>
</button>
</div>
</div>
<!-- test connection actions -->
<div *ngIf="db.isTestConnection" class="test-connection-actions">
<p class="mat-body-1 test-connection-message">You cannot edit test connection.</p>
<a *ngIf="db.isTestConnection"
routerLink="/connect-db"
data-testid="test-connection-actions-create-own-link"
mat-flat-button color="accent">
Create your own
</a>
<button type="button" mat-button color="warn"
data-testid="test-connection-actions-delete-button"
angulartics2On="click"
angularticsAction="Connection creds test: delete db is clicked"
[disabled]="submitting"
(click)="confirmDeleteConnection(db, $event); posthog.capture('Connection creds test: delete db is clicked')">
Delete
</button>
</div>
<!-- add connection actions -->
<div class="actions" *ngIf="!db.id && !db.isTestConnection">
<a mat-stroked-button routerLink="/connections-list"
data-testid="add-connection-actions-back-link"
class="delete-button">
Back
</a>
<button *ngIf="db.connectionType === 'direct'" type="button" mat-button color="primary" class="test-button"
data-testid="add-connection-actions-test-button"
angulartics2On="click"
angularticsAction="Connection creds {{ db.id ? 'edit' : 'add' }}: test db creds is clicked"
(click)="testConnection(); posthog.capture('Connection creds {{ db.id ? \'edit\' : \'add\' }}: test db creds is clicked')"
[disabled]="submitting">
Test connection
</button>
<button mat-flat-button type="submit" *ngIf="!connectionToken && !connectionID"
data-testid="add-connection-actions-add-button"
color="primary"
angulartics2On="click"
angularticsAction="Connection creds add: db add clicked"
(click)="posthog.capture('Connection creds add: db add clicked')"
[disabled]="submitting">
{{ submitting ? 'Checking' : 'Add'}}
</button>
<a *ngIf="connectionToken && connectionID" mat-flat-button color="primary"
routerLink="/dashboard/{{connectionID}}"
data-testid="add-connection-actions-open-dashboard-link">
Open dashboard
</a>
</div>
<!-- edit connection actions -->
<div class="actions" *ngIf="canEditConnection() && db.id && !db.isTestConnection">
<button type="button" mat-button color="warn"
class="delete-button"
data-testid="edit-connection-actions-delete-button"
angulartics2On="click"
angularticsAction="Connection creds edit: delete db is clicked"
[disabled]="submitting"
(click)="confirmDeleteConnection(db, $event); posthog.capture('Connection creds edit: delete db is clicked')">
Delete
</button>
<button type="button" mat-button color="primary" class="test-button"
data-testid="edit-connection-actions-test-button"
angulartics2On="click"
angularticsAction="Connection creds {{ db.id ? 'edit' : 'add' }}: test db creads is clicked"
(click)="testConnection(); posthog.capture('Connection creds {{ db.id ? \'edit\' : \'add\' }}: test db creads is clicked')"
[disabled]="submitting">
Test connection
</button>
<!-- right button -->
<button type="submit" *ngIf="db.id && (db.connectionType === 'direct' || (!connectionToken && db.connectionType === 'agent'))"
mat-flat-button color="primary"
data-testid="edit-connection-actions-edit-button"
angulartics2On="click"
angularticsAction="Connection creds edit: db edit is clicked"
(click)="posthog.capture('Connection creds edit: db edit is clicked')"
[disabled]="submitting || db.isTestConnection">
{{ submitting ? 'Checking' : 'Edit'}}
</button>
<a *ngIf="connectionToken && connectionID && db.connectionType === 'agent'" mat-flat-button color="primary"
routerLink="/dashboard/{{connectionID}}"
data-testid="edit-connection-actions-open-dashboard-link">
Open dashboard
</a>
</div>
</form>
</div>