Skip to content

Commit 624f65a

Browse files
xflordHejdaJakub
authored andcommitted
fix(admin): minor fixes to facility hosts page
* removed double load of the facility entity * added pointer cursor to the hosts list * used one-entity-attribute-page.component on the hosts detail page
1 parent 26e34db commit 624f65a

File tree

5 files changed

+14
-131
lines changed

5 files changed

+14
-131
lines changed

apps/admin-gui/src/app/facilities/pages/facility-detail-page/facility-hosts/facility-hosts-detail/facility-hosts-detail.component.html

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,7 @@
22
<h1 class="page-subtitle">
33
{{'FACILITY_DETAIL.HOSTS.HOSTS_DETAIL.TITLE' | translate}} {{host.hostname}}
44
</h1>
5-
<perun-web-apps-refresh-button (refresh)="refreshTable()"></perun-web-apps-refresh-button>
6-
<button (click)="addAttribute()" class="me-2" color="accent" mat-flat-button>
7-
{{'FACILITY_DETAIL.HOSTS.HOSTS_DETAIL.ADD' | translate}}
8-
</button>
9-
<button
10-
(click)="onSave()"
11-
class="me-2"
12-
color="accent"
13-
[disabled]="selected.selected.length === 0"
14-
mat-flat-button>
15-
{{'FACILITY_DETAIL.HOSTS.HOSTS_DETAIL.SAVE' | translate}}
16-
</button>
17-
<button
18-
(click)="removeAttribute()"
19-
color="warn"
20-
[disabled]="selected.selected.length === 0"
21-
mat-flat-button>
22-
{{'FACILITY_DETAIL.HOSTS.HOSTS_DETAIL.REMOVE' | translate}}
23-
</button>
24-
<ng-template #spinner>
25-
<perun-web-apps-loading-table></perun-web-apps-loading-table>
26-
</ng-template>
27-
<div class="position-relative">
28-
<perun-web-apps-attributes-list
29-
[selection]="selected"
30-
#list
31-
*perunWebAppsLoader="loading; indicator: spinner"
32-
[attributes]="attributes"
33-
[tableId]="tableId">
34-
</perun-web-apps-attributes-list>
35-
</div>
5+
<app-one-entity-attribute-page
6+
[entityId]="hostId"
7+
[entity]="'host'"></app-one-entity-attribute-page>
368
</div>
Original file line numberDiff line numberDiff line change
@@ -1,117 +1,24 @@
1-
import { Component, OnInit, ViewChild } from '@angular/core';
2-
import { SelectionModel } from '@angular/cdk/collections';
3-
import {
4-
Attribute,
5-
AttributesManagerService,
6-
FacilitiesManagerService,
7-
Host,
8-
} from '@perun-web-apps/perun/openapi';
9-
import { MatDialog } from '@angular/material/dialog';
10-
import { TABLE_ATTRIBUTES_SETTINGS } from '@perun-web-apps/config/table-config';
1+
import { Component, OnInit } from '@angular/core';
2+
import { FacilitiesManagerService, Host } from '@perun-web-apps/perun/openapi';
113
import { ActivatedRoute } from '@angular/router';
12-
import { filterCoreAttributes, getDefaultDialogConfig } from '@perun-web-apps/perun/utils';
13-
import { AttributesListComponent } from '@perun-web-apps/perun/components';
14-
import { DeleteAttributeDialogComponent } from '../../../../../shared/components/dialogs/delete-attribute-dialog/delete-attribute-dialog.component';
15-
import { EditAttributeDialogComponent } from '@perun-web-apps/perun/dialogs';
16-
import { CreateAttributeDialogComponent } from '../../../../../shared/components/dialogs/create-attribute-dialog/create-attribute-dialog.component';
174

185
@Component({
196
selector: 'app-facility-hosts-detail',
207
templateUrl: './facility-hosts-detail.component.html',
218
styleUrls: ['./facility-hosts-detail.component.scss'],
229
})
2310
export class FacilityHostsDetailComponent implements OnInit {
24-
@ViewChild('list')
25-
list: AttributesListComponent;
26-
27-
attributes: Attribute[] = [];
28-
selected = new SelectionModel<Attribute>(true, []);
2911
hostId: number;
3012
host: Host = { beanName: '', id: 0 };
31-
loading: boolean;
32-
tableId = TABLE_ATTRIBUTES_SETTINGS;
3313

34-
constructor(
35-
private dialog: MatDialog,
36-
private attributesManager: AttributesManagerService,
37-
private facilityManager: FacilitiesManagerService,
38-
private route: ActivatedRoute
39-
) {}
14+
constructor(private facilityManager: FacilitiesManagerService, private route: ActivatedRoute) {}
4015

4116
ngOnInit(): void {
4217
this.route.params.subscribe((params) => {
4318
this.hostId = Number(params['hostId']);
4419
this.facilityManager.getHostById(this.hostId).subscribe((host) => {
4520
this.host = host;
4621
});
47-
this.refreshTable();
48-
});
49-
}
50-
51-
refreshTable(): void {
52-
this.loading = true;
53-
this.attributesManager.getHostAttributes(this.hostId).subscribe((attributes) => {
54-
this.attributes = filterCoreAttributes(attributes);
55-
this.selected.clear();
56-
this.loading = false;
57-
});
58-
}
59-
60-
onSave(): void {
61-
this.list.updateMapAttributes();
62-
63-
const config = getDefaultDialogConfig();
64-
config.width = '450px';
65-
config.data = {
66-
entityId: this.hostId,
67-
entity: 'host',
68-
attributes: this.selected.selected,
69-
};
70-
71-
const dialogRef = this.dialog.open(EditAttributeDialogComponent, config);
72-
73-
dialogRef.afterClosed().subscribe((result) => {
74-
if (result) {
75-
this.refreshTable();
76-
}
77-
});
78-
}
79-
80-
addAttribute(): void {
81-
const config = getDefaultDialogConfig();
82-
config.width = '1050px';
83-
config.data = {
84-
entityId: this.hostId,
85-
entity: 'host',
86-
notEmptyAttributes: this.attributes,
87-
style: 'facility-theme',
88-
};
89-
90-
const dialogRef = this.dialog.open(CreateAttributeDialogComponent, config);
91-
92-
dialogRef.afterClosed().subscribe((result) => {
93-
if (result === 'saved') {
94-
this.refreshTable();
95-
}
96-
});
97-
}
98-
99-
removeAttribute(): void {
100-
const config = getDefaultDialogConfig();
101-
config.width = '450px';
102-
config.data = {
103-
entityId: this.hostId,
104-
entity: 'host',
105-
attributes: this.selected.selected,
106-
theme: 'facility-theme',
107-
};
108-
109-
const dialogRef = this.dialog.open(DeleteAttributeDialogComponent, config);
110-
111-
dialogRef.afterClosed().subscribe((result) => {
112-
if (result) {
113-
this.refreshTable();
114-
}
11522
});
11623
}
11724
}

apps/admin-gui/src/app/facilities/pages/facility-detail-page/facility-hosts/facility-hosts.component.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@ export class FacilityHostsComponent implements OnInit {
4343
this.loading = true;
4444
this.facility = this.entityStorageService.getEntity();
4545
this.setAuthRights();
46-
this.facilitiesManager.getFacilityById(this.facility.id).subscribe((facility) => {
47-
this.facility = facility;
48-
this.refreshTable();
49-
});
46+
this.refreshTable();
5047
}
5148

5249
refreshTable(): void {

apps/admin-gui/src/app/shared/components/hosts-list/hosts-list.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
<tr *matHeaderRowDef="displayedColumns" mat-header-row></tr>
5555
<tr
5656
*matRowDef="let host; columns: displayedColumns;"
57+
[class.cursor-pointer]="!disableRouting"
5758
[perunWebAppsMiddleClickRouterLink]="disableRouting ? null : ['/facilities', this.facilityId.toString(), 'hosts', host.id.toString()]"
5859
[routerLink]="disableRouting ? null : ['/facilities', this.facilityId, 'hosts', host.id]"
5960
class="dark-hover-list-item"

apps/admin-gui/src/app/shared/components/one-entity-attribute-page/one-entity-attribute-page.component.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ export class OneEntityAttributePageComponent implements OnInit {
8585
this.loading = false;
8686
});
8787
break;
88+
case 'host':
89+
this.attributesManagerService.getHostAttributes(this.entityId).subscribe((attributes) => {
90+
this.attributes = attributes;
91+
this.selection.clear();
92+
this.loading = false;
93+
});
8894
}
8995
}
9096

0 commit comments

Comments
 (0)