-
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathhosted-database-delete-dialog.component.ts
More file actions
38 lines (33 loc) · 1.53 KB
/
Copy pathhosted-database-delete-dialog.component.ts
File metadata and controls
38 lines (33 loc) · 1.53 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
import { Component, inject, signal } from '@angular/core';
import { MatButtonModule } from '@angular/material/button';
import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog';
import posthog from 'posthog-js';
import { FoundHostedDatabase } from 'src/app/models/hosted-database';
import { HostedDatabaseService } from 'src/app/services/hosted-database.service';
import { NotificationsService } from 'src/app/services/notifications.service';
@Component({
selector: 'app-hosted-database-delete-dialog',
templateUrl: './hosted-database-delete-dialog.component.html',
styleUrls: ['./hosted-database-delete-dialog.component.css'],
imports: [MatDialogModule, MatButtonModule],
})
export class HostedDatabaseDeleteDialogComponent {
private _hostedDatabaseService = inject(HostedDatabaseService);
private _notifications = inject(NotificationsService);
private _dialogRef = inject(MatDialogRef<HostedDatabaseDeleteDialogComponent>);
protected data: FoundHostedDatabase = inject(MAT_DIALOG_DATA);
protected submitting = signal(false);
async deleteDatabase(): Promise<void> {
this.submitting.set(true);
try {
const result = await this._hostedDatabaseService.deleteHostedDatabase(this.data.companyId, this.data.id);
if (result?.success) {
posthog.capture('Hosted Databases: database deleted', { databaseName: this.data.databaseName });
this._notifications.showSuccessSnackbar('Hosted database deleted successfully.');
this._dialogRef.close('delete');
}
} finally {
this.submitting.set(false);
}
}
}