Skip to content

Commit 8796f51

Browse files
xflordHejdaJakub
authored andcommitted
feat(admin): group synchronization dialog now displays the interval between synchronizations
* refactored group synchronization dialog to match the visual of the rest of the app * added interval between synchronizations
1 parent 678d980 commit 8796f51

File tree

7 files changed

+87
-114
lines changed

7 files changed

+87
-114
lines changed

apps/admin-gui/src/app/vos/pages/group-detail-page/group-detail-page.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export class GroupDetailPageComponent extends destroyDetailMixin() implements On
7575

7676
onSyncDetail(): void {
7777
const config = getDefaultDialogConfig();
78+
config.width = '450px';
7879
config.data = {
7980
groupId: this.group.id,
8081
theme: 'group-theme',

apps/admin-gui/src/assets/i18n/en.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,10 +1000,12 @@
10001000
"CANCEL": "Close",
10011001
"NORMAL_SYNC": "Basic synchronization",
10021002
"STRUCT_SYNC": "Structured synchronization",
1003-
"GROUP_NAME": "Group name: ",
1004-
"SYNCHRONIZATION": "Synchronization: ",
1005-
"LAST_SYNC_STATE": "Last synchronization state: ",
1006-
"LAST_SYNC_TIME": "Last synchronization time: "
1003+
"GROUP_NAME": "Group name",
1004+
"SYNCHRONIZATION": "Synchronization",
1005+
"LAST_SYNC_STATE": "Last synchronization state",
1006+
"LAST_SYNC_TIME": "Last synchronization time",
1007+
"SYNC_INTERVAL": "Group synchronization happens every",
1008+
"SYNC_INTERVAL_MINUTES": "{{interval}} minutes"
10071009
},
10081010
"IMPORT_ATTRIBUTE": {
10091011
"INFO": "To import an attribute, you have to paste the content, which you copied on the attribute definitions detail dialog.",

libs/perun/components/src/lib/groups-list/groups-list.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ export class GroupsListComponent {
219219

220220
openSyncDetail(group: GroupWithStatus): void {
221221
const config = getDefaultDialogConfig();
222+
config.width = '450px';
222223
config.data = {
223224
groupId: group.id,
224225
theme: this.theme,

libs/perun/components/src/lib/groups-tree/groups-tree.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ export class GroupsTreeComponent implements OnChanges {
106106

107107
onSyncDetail(rg: RichGroup): void {
108108
const config = getDefaultDialogConfig();
109+
config.width = '450px';
109110
config.data = {
110111
groupId: rg.id,
111112
theme: this.theme,
Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,57 @@
11
<div class="{{theme}}">
22
<h1 mat-dialog-title>{{'DIALOGS.GROUP_SYNC_DETAIL.TITLE' | translate}}</h1>
33
<mat-spinner *ngIf="loading" class="ml-auto mr-auto"></mat-spinner>
4-
<div *ngIf="!loading" mat-dialog-content>
5-
<span>
6-
{{'DIALOGS.GROUP_SYNC_DETAIL.GROUP_NAME' | translate}}
7-
<b>{{group.name}}</b>
8-
</span>
9-
<br />
10-
<span>
11-
{{'DIALOGS.GROUP_SYNC_DETAIL.SYNCHRONIZATION' | translate}}
12-
<b>{{getSynchronizationType() | translate}}</b>
13-
</span>
14-
<br />
15-
<span>
16-
{{'DIALOGS.GROUP_SYNC_DETAIL.LAST_SYNC_STATE' | translate}}
17-
<b>{{getLastSyncState() | translate}}</b>
18-
</span>
19-
<br />
20-
<span>
21-
{{'DIALOGS.GROUP_SYNC_DETAIL.LAST_SYNC_TIME' | translate}}
22-
<b>{{getLastSyncTime() | translate}}</b>
23-
</span>
4+
<div *ngIf="!loading" class="dialog-container" mat-dialog-content>
5+
<mat-form-field>
6+
<input
7+
matInput
8+
[value]="group.name"
9+
readonly
10+
placeholder="{{'DIALOGS.GROUP_SYNC_DETAIL.GROUP_NAME' | translate}}" />
11+
</mat-form-field>
12+
<mat-form-field>
13+
<input
14+
matInput
15+
[value]="syncType | translate"
16+
readonly
17+
placeholder="{{'DIALOGS.GROUP_SYNC_DETAIL.SYNCHRONIZATION' | translate}}" />
18+
</mat-form-field>
19+
<mat-form-field>
20+
<input
21+
matInput
22+
[value]="syncState"
23+
readonly
24+
placeholder="{{'DIALOGS.GROUP_SYNC_DETAIL.LAST_SYNC_STATE' | translate}}" />
25+
</mat-form-field>
26+
<mat-form-field>
27+
<input
28+
matInput
29+
[value]="syncTime | translate"
30+
readonly
31+
placeholder="{{'DIALOGS.GROUP_SYNC_DETAIL.LAST_SYNC_TIME' | translate}}" />
32+
</mat-form-field>
33+
<mat-form-field>
34+
<input
35+
matInput
36+
[value]="'DIALOGS.GROUP_SYNC_DETAIL.SYNC_INTERVAL_MINUTES' | translate : {interval: syncInterval}"
37+
readonly
38+
placeholder="{{'DIALOGS.GROUP_SYNC_DETAIL.SYNC_INTERVAL' | translate}}" />
39+
</mat-form-field>
2440
</div>
2541
<div mat-dialog-actions>
2642
<div class="ml-auto">
27-
<button (click)="refresh()" mat-icon-button>
28-
<mat-icon>refresh</mat-icon>
29-
</button>
30-
<button
31-
(click)="onForceStructure()"
32-
*ngIf="this.isStructured()"
33-
[disabled]="this.loading"
34-
class="ml-2"
35-
mat-flat-button>
36-
{{'DIALOGS.GROUP_SYNC_DETAIL.FORCE_STRUCTURE' | translate}}
43+
<button (click)="onCancel()" class="ml-2" mat-flat-button>
44+
{{'DIALOGS.GROUP_SYNC_DETAIL.CANCEL' | translate}}
3745
</button>
3846
<button
3947
(click)="onForce()"
40-
*ngIf="this.isBasic() || this.isStructured()"
41-
[disabled]="this.loading"
48+
*ngIf="type === 'BASIC' || type === 'STRUCTURED'"
49+
[disabled]="loading"
4250
class="ml-2"
51+
color="accent"
4352
mat-flat-button>
4453
{{'DIALOGS.GROUP_SYNC_DETAIL.FORCE' | translate}}
4554
</button>
46-
<button (click)="onCancel()" class="ml-2" mat-flat-button>
47-
{{'DIALOGS.GROUP_SYNC_DETAIL.CANCEL' | translate}}
48-
</button>
4955
</div>
5056
</div>
5157
</div>

libs/perun/dialogs/src/lib/group-sync-detail-dialog/group-sync-detail-dialog.component.ts

Lines changed: 36 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { GroupsManagerService, RichGroup } from '@perun-web-apps/perun/openapi';
44
import { Urns } from '@perun-web-apps/perun/urns';
55
import { getAttribute } from '@perun-web-apps/perun/utils';
66
import { NotificatorService } from '@perun-web-apps/perun/services';
7+
import { formatDate } from '@angular/common';
78

89
export type SyncType = 'BASIC' | 'STRUCTURED';
910

@@ -21,13 +22,11 @@ export class GroupSyncDetailDialogComponent implements OnInit {
2122
theme: string;
2223
loading = true;
2324
group: RichGroup;
24-
private syncEnabled: string;
25-
private lastSyncState: string;
26-
private lastSyncTime: string;
27-
private structSyncEnabled: boolean;
28-
private lastStructSyncState: string;
29-
private lastStructSyncTime: string;
30-
private type: SyncType;
25+
syncInterval = '';
26+
syncState = '';
27+
syncTime = '';
28+
syncType = '';
29+
type: SyncType;
3130

3231
constructor(
3332
public dialogRef: MatDialogRef<GroupSyncDetailDialogComponent>,
@@ -41,79 +40,29 @@ export class GroupSyncDetailDialogComponent implements OnInit {
4140
this.loadGroup();
4241
}
4342

44-
onForceStructure(): void {
45-
this.loading = true;
46-
this.groupService.forceGroupStructureSynchronization(this.data.groupId).subscribe(
47-
() => {
48-
this.notificator.showSuccess('DIALOGS.GROUP_SYNC_DETAIL.STRUCT_FORCE_SUCCESS');
49-
this.loading = false;
50-
},
51-
() => (this.loading = false)
52-
);
53-
}
54-
5543
onCancel(): void {
5644
this.dialogRef.close(null);
5745
}
5846

5947
onForce(): void {
6048
this.loading = true;
61-
if (this.isBasic()) {
62-
this.groupService.forceGroupSynchronization(this.group.id).subscribe(
63-
() => {
49+
if (this.type === 'BASIC') {
50+
this.groupService.forceGroupSynchronization(this.group.id).subscribe({
51+
next: () => {
6452
this.notificator.showSuccess('DIALOGS.GROUP_SYNC_DETAIL.FORCE_SUCCESS');
6553
this.refresh();
6654
},
67-
() => (this.loading = false)
68-
);
69-
}
70-
if (this.isStructured()) {
71-
this.groupService.forceGroupStructureSynchronization(this.group.id).subscribe(
72-
() => {
55+
error: () => (this.loading = false),
56+
});
57+
} else {
58+
this.groupService.forceGroupStructureSynchronization(this.group.id).subscribe({
59+
next: () => {
7360
this.notificator.showSuccess('DIALOGS.GROUP_SYNC_DETAIL.FORCE_SUCCESS');
7461
this.refresh();
7562
},
76-
() => (this.loading = false)
77-
);
78-
}
79-
}
80-
81-
getSynchronizationType(): string {
82-
if (this.isBasic()) {
83-
return 'DIALOGS.GROUP_SYNC_DETAIL.NORMAL_SYNC';
84-
}
85-
if (this.isStructured()) {
86-
return 'DIALOGS.GROUP_SYNC_DETAIL.STRUCT_SYNC';
87-
}
88-
return 'N/A';
89-
}
90-
91-
isBasic(): boolean {
92-
return this.type === 'BASIC';
93-
}
94-
95-
isStructured(): boolean {
96-
return this.type === 'STRUCTURED';
97-
}
98-
99-
getLastSyncState(): string {
100-
if (this.isBasic()) {
101-
return this.lastSyncState !== '' ? this.lastSyncState : 'OK';
102-
}
103-
if (this.isStructured()) {
104-
return this.lastStructSyncState !== '' ? this.lastStructSyncState : 'OK';
105-
}
106-
return 'N/A';
107-
}
108-
109-
getLastSyncTime(): string {
110-
if (this.isBasic()) {
111-
return this.lastSyncTime;
112-
}
113-
if (this.isStructured()) {
114-
return this.lastStructSyncTime;
63+
error: () => (this.loading = false),
64+
});
11565
}
116-
return 'N/A';
11766
}
11867

11968
refresh(): void {
@@ -130,33 +79,45 @@ export class GroupSyncDetailDialogComponent implements OnInit {
13079
Urns.GROUP_STRUCTURE_SYNC_ENABLED,
13180
Urns.GROUP_LAST_STRUCTURE_SYNC_STATE,
13281
Urns.GROUP_LAST_STRUCTURE_SYNC_TIMESTAMP,
82+
Urns.GROUP_SYNC_INTERVAL,
13383
])
13484
.subscribe((richGroup) => {
13585
this.group = richGroup;
13686

137-
this.syncEnabled = getAttribute(this.group.attributes, Urns.GROUP_SYNC_ENABLED)
87+
const syncEnabled = getAttribute(this.group.attributes, Urns.GROUP_SYNC_ENABLED)
13888
.value as string;
139-
this.lastSyncState = getAttribute(this.group.attributes, Urns.GROUP_LAST_SYNC_STATE)
89+
const lastSyncState = getAttribute(this.group.attributes, Urns.GROUP_LAST_SYNC_STATE)
14090
.value as string;
141-
this.lastSyncTime = getAttribute(this.group.attributes, Urns.GROUP_LAST_SYNC_TIMESTAMP)
91+
const lastSyncTime = getAttribute(this.group.attributes, Urns.GROUP_LAST_SYNC_TIMESTAMP)
14292
.value as string;
143-
this.structSyncEnabled = getAttribute(
93+
const structSyncEnabled = getAttribute(
14494
this.group.attributes,
14595
Urns.GROUP_STRUCTURE_SYNC_ENABLED
14696
).value as boolean;
147-
this.lastStructSyncState = getAttribute(
97+
const lastStructSyncState = getAttribute(
14898
this.group.attributes,
14999
Urns.GROUP_LAST_STRUCTURE_SYNC_STATE
150100
).value as string;
151-
this.lastStructSyncTime = getAttribute(
101+
const lastStructSyncTime = getAttribute(
152102
this.group.attributes,
153103
Urns.GROUP_LAST_STRUCTURE_SYNC_TIMESTAMP
154104
).value as string;
155-
if (this.syncEnabled !== null && this.syncEnabled === 'true') {
105+
const syncInterval = getAttribute(this.group.attributes, Urns.GROUP_SYNC_INTERVAL)
106+
.value as string;
107+
// value is in chunks of 5 minutes
108+
this.syncInterval = syncInterval === null ? 'N/A' : (+syncInterval * 5).toString();
109+
110+
if (syncEnabled !== null && syncEnabled === 'true') {
156111
this.type = 'BASIC';
112+
this.syncType = 'DIALOGS.GROUP_SYNC_DETAIL.NORMAL_SYNC';
113+
this.syncState = lastSyncState !== '' ? lastSyncState : 'OK';
114+
this.syncTime = formatDate(lastSyncTime, 'YYYY-MM-dd H:mm:ss', 'en');
157115
}
158-
if (this.structSyncEnabled !== null && this.structSyncEnabled) {
116+
if (structSyncEnabled !== null && structSyncEnabled) {
159117
this.type = 'STRUCTURED';
118+
this.syncType = 'DIALOGS.GROUP_SYNC_DETAIL.STRUCT_SYNC';
119+
this.syncState = lastStructSyncState !== '' ? lastStructSyncState : 'OK';
120+
this.syncTime = formatDate(lastStructSyncTime, 'YYYY-MM-dd H:mm:ss', 'en');
160121
}
161122
this.loading = false;
162123
});

libs/perun/urns/src/lib/perun-urns.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export class Urns {
3737
'urn:perun:group:attribute-def:def:lastGroupStructureSynchronizationState';
3838
static GROUP_LAST_STRUCTURE_SYNC_TIMESTAMP =
3939
'urn:perun:group:attribute-def:def:lastGroupStructureSynchronizationTimestamp';
40+
static GROUP_SYNC_INTERVAL = 'urn:perun:group:attribute-def:def:synchronizationInterval';
4041
static GROUP_BLOCK_MANUAL_MEMBER_ADDING =
4142
'urn:perun:group:attribute-def:def:blockManualMemberAdding';
4243

0 commit comments

Comments
 (0)