import { CephServiceService } from '~/app/shared/api/ceph-service.service';
import { TaskWrapperService } from '~/app/shared/services/task-wrapper.service';
import { DeleteConfirmationModalComponent } from '~/app/shared/components/delete-confirmation-modal/delete-confirmation-modal.component';
+import { DetailItem } from '~/app/shared/components/details-card/details-card.component';
import { FinishedTask } from '~/app/shared/models/finished-task';
import { DeletionImpact } from '~/app/shared/enum/delete-confirmation-modal-impact.enum';
import { NotificationService } from '~/app/shared/services/notification.service';
selection: CdTableSelection = new CdTableSelection();
gatewayGroup$: Observable<CephServiceSpec[]> = of([]);
subject = new BehaviorSubject<CephServiceSpec[]>([]);
- context!: CdTableFetchDataContext;
+ context?: CdTableFetchDataContext;
gatewayGroupName = '';
subsystemCount = 0;
gatewayCount = 0;
+ selectedGatewayDetails: DetailItem[] = [];
private lastGroupCount = 0;
viewUrl = `/${BASE_URL}/view`;
canBePrimary: (selection: CdTableSelection) => !selection.hasSelection
};
+ const editAction: CdTableAction = {
+ permission: 'update',
+ icon: Icons.edit,
+ routerLink: () => this.urlBuilder.getEdit(this.selection.first()?.name),
+ name: this.actionLabels.EDIT,
+ canBePrimary: (selection: CdTableSelection) => selection.hasSingleSelection
+ };
+
const viewAction: CdTableAction = {
permission: 'read',
icon: Icons.eye,
canBePrimary: (selection: CdTableSelection) => selection.hasMultiSelection
};
- this.tableActions = [createAction, viewAction, deleteAction];
+ this.tableActions = [createAction, editAction, viewAction, deleteAction];
this.gatewayGroup$ = this.subject.pipe(
switchMap(() =>
updateSelection(selection: CdTableSelection): void {
this.selection = selection;
+ this.selectedGatewayDetails = this.buildGatewayDetails(selection.first());
}
deleteGatewayGroupModal() {
this.router.navigate([this.viewUrl, groupName]);
}
+ editSelectedGatewayGroup(): void {
+ const selectedGroup = this.selection.first();
+ if (!selectedGroup) {
+ return;
+ }
+ this.router.navigate([this.urlBuilder.getEdit(selectedGroup.name)]);
+ }
+
+ private buildGatewayDetails(selectedGroup: any): DetailItem[] {
+ if (!selectedGroup) {
+ return [];
+ }
+
+ const runningGateways = selectedGroup.statusCount?.running ?? 0;
+ const errorGateways = selectedGroup.statusCount?.error ?? 0;
+ const totalGateways = runningGateways + errorGateways;
+
+ return [
+ {
+ label: $localize`Gateway name`,
+ value: selectedGroup.name
+ },
+ {
+ label: $localize`Gateway nodes`,
+ value: totalGateways
+ },
+ {
+ label: $localize`Encryption`,
+ value: selectedGroup.spec?.enable_auth ? $localize`Enabled` : $localize`Disabled`,
+ type: 'status'
+ },
+ {
+ label: $localize`mTLS`,
+ value: selectedGroup.spec?.enable_mtls ? $localize`Enabled` : $localize`Disabled`,
+ type: 'status'
+ }
+ ];
+ }
+
ngOnDestroy(): void {
this.destroy$.next();
this.destroy$.complete();
<ng-template #header>
@if (cardTitle) {
<h3 class="cds--type-heading-03" i18n>{{ cardTitle }}</h3>
+ @if (showEditButton) {
+ <button
+ cdsButton="ghost"
+ size="sm"
+ [disabled]="editButtonDisabled"
+ (click)="onEditClick()"
+ [attr.aria-label]="editButtonLabel"
+ >
+ {{ editButtonLabel }}
+ <cd-icon class="cds-ml-5" type="edit"></cd-icon>
+ </button>
+ }
}
</ng-template>
- <div [cdsStack]="'vertical'"
- [gap]="0">
+ <div [cdsStack]="'vertical'" [gap]="0">
@if (details && details.length > 0) {
- <div [cdsStack]="'horizontal'"
- [gap]="6">
+ <div [cdsStack]="'horizontal'" [gap]="6">
@for (detail of getVisibleDetails(); track detail.label) {
- <div [cdsStack]="'vertical'"
- [gap]="2">
+ <div [cdsStack]="'vertical'" [gap]="2">
<label class="cds--type-label-01">{{ detail.label }}</label>
<div class="cds--type-body-01">
@switch (detail.type) {
@case ('status') {
- <div [cdsStack]="'horizontal'"
- [gap]="3">
+ <div [cdsStack]="'horizontal'" [gap]="3">
<cd-icon [type]="getStatusIcon(detail)"></cd-icon>
<span>{{ getDisplayValue(detail.value) }}</span>
</div>