Skip to content

Commit 32d167a

Browse files
feat(admin): last successful propagation
Added column with time of last successful propagation into destinations table.
1 parent b991740 commit 32d167a

File tree

8 files changed

+45
-10
lines changed

8 files changed

+45
-10
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export class FacilityServicesDestinationsComponent implements OnInit {
3939
'type',
4040
'status',
4141
'propagationType',
42+
'lastSuccessfulPropagation',
4243
];
4344
@Input()
4445
configServices: Service[] = [];

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,17 @@
108108
</th>
109109
<td *matCellDef="let destination" mat-cell>{{destination.propagationType}}</td>
110110
</ng-container>
111+
<ng-container matColumnDef="lastSuccessfulPropagation">
112+
<th *matHeaderCellDef mat-header-cell mat-sort-header>
113+
{{'SHARED.COMPONENTS.DESTINATIONS_LIST.LAST_SUCCESS' | translate}}
114+
</th>
115+
<td
116+
*matCellDef="let destination"
117+
mat-cell
118+
class="{{!destination.lastSuccessfulPropagation ? 'fst-italic' : ''}}">
119+
{{destination.lastSuccessfulPropagation | lastSuccessfulPropagation}}
120+
</td>
121+
</ng-container>
111122

112123
<tr *matHeaderRowDef="displayedColumns" mat-header-row></tr>
113124
<tr

apps/admin-gui/src/app/shared/components/destination-list/destination-list.component.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ import {
1212
TableWrapperComponent,
1313
} from '@perun-web-apps/perun/utils';
1414
import { GuiAuthResolver, TableCheckbox } from '@perun-web-apps/perun/services';
15+
import { LastSuccessfulPropagationPipe } from '@perun-web-apps/perun/pipes';
1516

1617
@Component({
1718
selector: 'app-perun-web-apps-destination-list',
1819
templateUrl: './destination-list.component.html',
1920
styleUrls: ['./destination-list.component.scss'],
21+
providers: [LastSuccessfulPropagationPipe],
2022
})
2123
export class DestinationListComponent implements AfterViewInit, OnChanges {
2224
@Input()
@@ -36,14 +38,18 @@ export class DestinationListComponent implements AfterViewInit, OnChanges {
3638
pageSizeOptions = TABLE_ITEMS_COUNT_OPTIONS;
3739
private sort: MatSort;
3840

39-
constructor(private authResolver: GuiAuthResolver, private tableCheckbox: TableCheckbox) {}
41+
constructor(
42+
private authResolver: GuiAuthResolver,
43+
private tableCheckbox: TableCheckbox,
44+
private lastSuccessPipe: LastSuccessfulPropagationPipe
45+
) {}
4046

4147
@ViewChild(MatSort, { static: true }) set matSort(ms: MatSort) {
4248
this.sort = ms;
4349
this.setDataSource();
4450
}
4551

46-
static getDataForColumn(data: RichDestination, column: string): string {
52+
getDataForColumn(data: RichDestination, column: string): string {
4753
switch (column) {
4854
case 'destinationId':
4955
return data.id.toString();
@@ -59,6 +65,8 @@ export class DestinationListComponent implements AfterViewInit, OnChanges {
5965
return data.blocked ? 'blocked' : 'allowed';
6066
case 'propagationType':
6167
return data.propagationType;
68+
case 'lastSuccessfulPropagation':
69+
return this.lastSuccessPipe.transform(data.lastSuccessfulPropagation);
6270
default:
6371
return '';
6472
}
@@ -75,10 +83,8 @@ export class DestinationListComponent implements AfterViewInit, OnChanges {
7583

7684
exportAllData(format: string): void {
7785
downloadData(
78-
getDataForExport(
79-
this.dataSource.filteredData,
80-
this.displayedColumns,
81-
DestinationListComponent.getDataForColumn
86+
getDataForExport(this.dataSource.filteredData, this.displayedColumns, (data, column) =>
87+
this.getDataForColumn(data, column)
8288
),
8389
format
8490
);
@@ -93,7 +99,7 @@ export class DestinationListComponent implements AfterViewInit, OnChanges {
9399
.sortData(this.dataSource.filteredData, this.dataSource.sort)
94100
.slice(start, end),
95101
this.displayedColumns,
96-
DestinationListComponent.getDataForColumn
102+
(data, column) => this.getDataForColumn(data, column)
97103
),
98104
format
99105
);
@@ -107,10 +113,12 @@ export class DestinationListComponent implements AfterViewInit, OnChanges {
107113
data,
108114
filter,
109115
this.displayedColumns,
110-
DestinationListComponent.getDataForColumn
116+
(destination, column) => this.getDataForColumn(destination, column)
111117
);
112118
this.dataSource.sortData = (data: Vo[], sort: MatSort): Vo[] =>
113-
customDataSourceSort(data, sort, DestinationListComponent.getDataForColumn);
119+
customDataSourceSort(data, sort, (destination, column) =>
120+
this.getDataForColumn(destination, column)
121+
);
114122
this.dataSource.paginator = this.child.paginator;
115123
}
116124
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2787,7 +2787,8 @@
27872787
"BLOCKED": "Blocked",
27882788
"PROPAGATION_TYPE": "Propagation type",
27892789
"NO_DESTINATIONS": "No destinations found",
2790-
"WARN": "Destination is not properly configured. The service, to which it is connected is not in your service selection"
2790+
"WARN": "Destination is not properly configured. The service, to which it is connected is not in your service selection",
2791+
"LAST_SUCCESS": "Last successful propagation"
27912792
},
27922793
"FACILITIES_LIST": {
27932794
"ID": "Id",

libs/perun/openapi/src/lib/model/richDestination.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ export interface RichDestination extends Destination {
1717
blocked?: boolean;
1818
service?: Service;
1919
facility?: Facility;
20+
lastSuccessfulPropagation?: string;
2021
}

libs/perun/pipes/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,4 @@ export * from './lib/transform-member-status.pipe';
4242
export * from './lib/application-column-select-label.pipe';
4343
export * from './lib/selected-consent-statuses.pipe';
4444
export * from './lib/global-namespace.pipe';
45+
export * from './lib/last-successful-propagation.pipe';
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Pipe, PipeTransform } from '@angular/core';
2+
import { formatDate } from '@angular/common';
3+
4+
@Pipe({ name: 'lastSuccessfulPropagation' })
5+
export class LastSuccessfulPropagationPipe implements PipeTransform {
6+
transform(successAt: string): string {
7+
return successAt ? formatDate(successAt.toString(), 'yyyy.MM.dd HH:mm:ss', 'en') : 'NEVER';
8+
}
9+
}

libs/perun/pipes/src/lib/perun-pipes.module.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ import { TransformMemberStatusPipe } from './transform-member-status.pipe';
6161
import { ApplicationColumnSelectLabelPipe } from './application-column-select-label.pipe';
6262
import { SelectedSponsorPipe } from './selected-sponsor.pipe';
6363
import { GlobalNamespacePipe } from './global-namespace.pipe';
64+
import { LastSuccessfulPropagationPipe } from './last-successful-propagation.pipe';
6465

6566
@NgModule({
6667
declarations: [
@@ -126,6 +127,7 @@ import { GlobalNamespacePipe } from './global-namespace.pipe';
126127
TransformMemberStatusPipe,
127128
ApplicationColumnSelectLabelPipe,
128129
GlobalNamespacePipe,
130+
LastSuccessfulPropagationPipe,
129131
],
130132
exports: [
131133
ResourceTagsToStringPipe,
@@ -190,6 +192,7 @@ import { GlobalNamespacePipe } from './global-namespace.pipe';
190192
TransformMemberStatusPipe,
191193
ApplicationColumnSelectLabelPipe,
192194
GlobalNamespacePipe,
195+
LastSuccessfulPropagationPipe,
193196
],
194197
imports: [CommonModule],
195198
})

0 commit comments

Comments
 (0)