Skip to content

Commit 08faffe

Browse files
committed
add clustername on backup details
1 parent 5ae6141 commit 08faffe

File tree

4 files changed

+39
-3
lines changed

4 files changed

+39
-3
lines changed

modules/web/src/app/backup/details/automatic-backup/component.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {Component, OnDestroy, OnInit} from '@angular/core';
1616
import {MatDialog, MatDialogConfig} from '@angular/material/dialog';
1717
import {ActivatedRoute, Router} from '@angular/router';
1818
import {getBackupHealthStatus, HealthStatus} from '@app/shared/utils/health-status';
19+
import {ClusterService} from '@core/services/cluster';
1920
import {BackupService} from '@core/services/backup';
2021
import {ProjectService} from '@core/services/project';
2122
import {UserService} from '@core/services/user';
@@ -29,6 +30,7 @@ import {MemberUtils, Permission} from '@shared/utils/member';
2930
import _ from 'lodash';
3031
import {Subject} from 'rxjs';
3132
import {filter, map, switchMap, take, takeUntil} from 'rxjs/operators';
33+
import { Cluster } from '@app/shared/entity/cluster';
3234

3335
@Component({
3436
selector: 'km-automatic-backup-details',
@@ -43,7 +45,7 @@ export class AutomaticBackupDetailsComponent implements OnInit, OnDestroy {
4345
selectedProject = {} as Project;
4446
isInitialized = false;
4547
backup: EtcdBackupConfig = {} as EtcdBackupConfig;
46-
48+
cluster: Cluster;
4749
get canDelete(): boolean {
4850
return MemberUtils.hasPermission(this._user, this._currentGroupConfig, View.Backups, Permission.Delete);
4951
}
@@ -57,6 +59,7 @@ export class AutomaticBackupDetailsComponent implements OnInit, OnDestroy {
5759
}
5860

5961
constructor(
62+
private readonly _clusterService: ClusterService,
6063
private readonly _backupService: BackupService,
6164
private readonly _projectService: ProjectService,
6265
private readonly _userService: UserService,
@@ -90,6 +93,13 @@ export class AutomaticBackupDetailsComponent implements OnInit, OnDestroy {
9093
this.backup = backup;
9194
this.isInitialized = true;
9295
});
96+
97+
this._projectService.selectedProject
98+
.pipe(switchMap(project => this._clusterService.clusters(project.id, false)))
99+
.pipe(takeUntil(this._unsubscribe))
100+
.subscribe(clusters => {
101+
this.cluster = clusters.find(cluster => cluster.id === this.backup.spec.clusterId);
102+
});
93103
}
94104

95105
ngOnDestroy(): void {
@@ -101,6 +111,10 @@ export class AutomaticBackupDetailsComponent implements OnInit, OnDestroy {
101111
this._router.navigate(['/projects/' + this.selectedProject.id + '/backups']);
102112
}
103113

114+
getClusterName(): string {
115+
return this.cluster?.name;
116+
}
117+
104118
delete(backup: EtcdBackupConfig): void {
105119
const config: MatDialogConfig = {
106120
data: {

modules/web/src/app/backup/details/automatic-backup/template.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@
5454
</div>
5555
</mat-card-header>
5656
<mat-card-content fxLayout="row">
57+
<km-property>
58+
<div key>Cluster Name</div>
59+
<div value>{{getClusterName()}}</div>
60+
</km-property>
5761
<km-property>
5862
<div key>Cluster ID</div>
5963
<div value>{{backup.spec?.clusterId}}</div>

modules/web/src/app/backup/details/snapshot/component.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
DeleteSnapshotDialogComponent,
2020
DeleteSnapshotDialogConfig,
2121
} from '@app/backup/list/snapshot/delete-dialog/component';
22+
import {ClusterService} from '@core/services/cluster';
2223
import {BackupService} from '@core/services/backup';
2324
import {ProjectService} from '@core/services/project';
2425
import {UserService} from '@core/services/user';
@@ -28,9 +29,10 @@ import {Member} from '@shared/entity/member';
2829
import {Project} from '@shared/entity/project';
2930
import {GroupConfig} from '@shared/model/Config';
3031
import {MemberUtils, Permission} from '@shared/utils/member';
31-
import {Subject} from 'rxjs';
32+
import {Observable, Subject} from 'rxjs';
3233
import {filter, map, switchMap, take, takeUntil} from 'rxjs/operators';
3334
import {getBackupHealthStatus, HealthStatus} from '@shared/utils/health-status';
35+
import { Cluster } from '@app/shared/entity/cluster';
3436

3537
@Component({
3638
selector: 'km-snapshot-details',
@@ -45,7 +47,7 @@ export class SnapshotDetailsComponent implements OnInit, OnDestroy {
4547
selectedProject = {} as Project;
4648
isInitialized = false;
4749
backup: EtcdBackupConfig = {} as EtcdBackupConfig;
48-
50+
cluster: Cluster;
4951
get canDelete(): boolean {
5052
return MemberUtils.hasPermission(this._user, this._currentGroupConfig, View.Backups, Permission.Delete);
5153
}
@@ -59,6 +61,7 @@ export class SnapshotDetailsComponent implements OnInit, OnDestroy {
5961
}
6062

6163
constructor(
64+
private readonly _clusterService: ClusterService,
6265
private readonly _backupService: BackupService,
6366
private readonly _projectService: ProjectService,
6467
private readonly _userService: UserService,
@@ -92,6 +95,13 @@ export class SnapshotDetailsComponent implements OnInit, OnDestroy {
9295
this.backup = backup;
9396
this.isInitialized = true;
9497
});
98+
99+
this._projectService.selectedProject
100+
.pipe(switchMap(project => this._clusterService.clusters(project.id, false)))
101+
.pipe(takeUntil(this._unsubscribe))
102+
.subscribe(clusters => {
103+
this.cluster = clusters.find(cluster => cluster.id === this.backup.spec.clusterId);
104+
});
95105
}
96106

97107
ngOnDestroy(): void {
@@ -108,6 +118,10 @@ export class SnapshotDetailsComponent implements OnInit, OnDestroy {
108118
return getBackupHealthStatus(backup, condition);
109119
}
110120

121+
getClusterName(): string {
122+
return this.cluster?.name;
123+
}
124+
111125
delete(backup: EtcdBackupConfig): void {
112126
const config: MatDialogConfig = {
113127
data: {

modules/web/src/app/backup/details/snapshot/template.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@
4747
</mat-card-title>
4848
</mat-card-header>
4949
<mat-card-content fxLayout="row">
50+
<km-property>
51+
<div key>Cluster Name</div>
52+
<div value>{{getClusterName()}}</div>
53+
</km-property>
5054
<km-property>
5155
<div key>Cluster ID</div>
5256
<div value>{{backup.spec?.clusterId}}</div>

0 commit comments

Comments
 (0)