Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated admin screen to show seperate lists #357

Merged
merged 3 commits into from
Oct 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 35 additions & 39 deletions src/app/admin/home/active-sessions/active-sessions.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,20 @@ <h4 class="marginless">
</span>
</td>
</ng-container>
<ng-container matColumnDef="lastAccessedUrl">
<th mat-header-cell *matHeaderCellDef mat-sort-header [disabled]="!hideFilters" style="cursor: pointer; max-width: 20%; width: 20%;" columnName="lastAccessedUrl">
<span [hidden]="!hideFilters">Last Access URL</span>
<div [hidden]="hideFilters">
<mat-form-field class="filter" [style.width.px]="100" floatLabel="never">
<mat-label>Last Access Url</mat-label>
<input #filters matInput name="last" (keyup)="applyFilter()">
</mat-form-field>
</div>
</th>
<td mat-cell *matCellDef="let record" style="max-width: 20%; width: 20%; text-align: left; word-wrap: break-word;">
{{record.lastAccessedUrl}}
</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let record; columns: displayedColumns;"></tr>
</table>
Expand All @@ -136,56 +150,24 @@ <h4 class="marginless">
</div>
<div class="table-responsive">
<table mat-table matSort [dataSource]="unauthorised" class="mdm--mat-table table table-striped marginless">
<ng-container matColumnDef="userEmailAddress">
<th mat-header-cell *matHeaderCellDef mat-sort-header="userEmailAddress" [disabled]="!hideFilters" style="cursor: pointer; max-width: 35%; width: 35%;" columnName="userEmailAddress">
<span [hidden]="!hideFilters">Email</span>
<ng-container matColumnDef="id">
<th mat-header-cell *matHeaderCellDef mat-sort-header="id" [disabled]="!hideFilters" style="cursor: pointer; max-width: 35%; width: 35%;" columnName="id">
<span [hidden]="!hideFilters">Session Id</span>
<div [hidden]="hideFilters">
<mat-form-field class="filter" floatLabel="never">
<mat-label>Email</mat-label>
<input #filters matInput name="userEmailAddress" (keyup)="applyFilter()">
<mat-label>Session Id</mat-label>
<input #filters matInput name="Id" (keyup)="applyFilter()">
</mat-form-field>
</div>
</th>
<td mat-cell *matCellDef="let record" style="max-width: 35%; width: 35%; text-align: left; word-wrap: break-word;">
<div>
<i class="fas fa-circle onlineUser" aria-hidden="true" matTooltip="Online"></i>
{{ record.userEmailAddress }}
{{ record.id }}
</div>
</td>
</ng-container>
<ng-container matColumnDef="userName">
<th mat-header-cell *matHeaderCellDef mat-sort-header="userName" [disabled]="!hideFilters" style="cursor: pointer; max-width: 20%; width: 20%;" columnName="userName">
<span [hidden]="!hideFilters">Name</span>
<div [hidden]="hideFilters">
<mat-form-field class="filter" [style.width.px]="100" floatLabel="never">
<mat-label>Name</mat-label>
<input #filters matInput name="userName" (keyup)="applyFilter()">
</mat-form-field>
</div>
</th>
<td mat-cell *matCellDef="let record" style="max-width: 20%; width: 20%; text-align: left; word-wrap: break-word;">
<div>
{{record.userName}}
</div>
</td>
</ng-container>
<ng-container matColumnDef="userOrganisation">
<th mat-header-cell *matHeaderCellDef mat-sort-header="userOrganisation" [disabled]="!hideFilters" style="cursor: pointer; max-width: 22%; width: 22%;" columnName="userOrganisation">
<span [hidden]="!hideFilters">Organisation</span>
<div [hidden]="hideFilters">
<mat-form-field class="filter" [style.width.px]="100" floatLabel="never">
<mat-label>Organisation</mat-label>
<input #filters matInput name="userOrganisation" (keyup)="applyFilter()">
</mat-form-field>
</div>
</th>
<td mat-cell *matCellDef="let record" style="max-width: 22%; width: 22%; text-align: left; word-wrap: break-word;">
<div>
{{record.userOrganisation}}
</div>
</td>
</ng-container>
<ng-container matColumnDef="start">
<ng-container matColumnDef="start">
<th mat-header-cell *matHeaderCellDef mat-sort-header [disabled]="!hideFilters" style="cursor: pointer; max-width: 10%; width: 10%;" columnName="start">
<span [hidden]="!hideFilters">Start</span>
<div [hidden]="hideFilters">
Expand Down Expand Up @@ -223,6 +205,20 @@ <h4 class="marginless">
</span>
</td>
</ng-container>
<ng-container matColumnDef="lastAccessedUrl">
<th mat-header-cell *matHeaderCellDef mat-sort-header [disabled]="!hideFilters" style="cursor: pointer; max-width: 20%; width: 20%;" columnName="lastAccessedUrl">
<span [hidden]="!hideFilters">Last Access URL</span>
<div [hidden]="hideFilters">
<mat-form-field class="filter" [style.width.px]="100" floatLabel="never">
<mat-label>Last Access Url</mat-label>
<input #filters matInput name="last" (keyup)="applyFilter()">
</mat-form-field>
</div>
</th>
<td mat-cell *matCellDef="let record" style="max-width: 20%; width: 20%; text-align: left; word-wrap: break-word;">
{{record.lastAccessedUrl}}
</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumnsUnauthorised"></tr>
<tr mat-row *matRowDef="let record; columns: displayedColumnsUnauthorised;"></tr>
</table>
Expand Down
31 changes: 17 additions & 14 deletions src/app/admin/home/active-sessions/active-sessions.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ export class ActiveSessionsComponent implements OnInit, AfterViewInit {
hideFilters = true;
dataSource = new MatTableDataSource<any>();

constructor(private messageHandler: MessageHandlerService, private resourcesService: MdmResourcesService) {
this.displayedColumns = ['userEmailAddress', 'userName', 'userOrganisation', 'start', 'lastAccess'];
this.displayedColumnsUnauthorised = ['userEmailAddress', 'userName', 'userOrganisation', 'start', 'lastAccess'];
constructor(private messageHandler: MessageHandlerService, private resourcesService: MdmResourcesService) {
this.displayedColumns = ['userEmailAddress', 'userName', 'userOrganisation', 'start', 'lastAccess','lastAccessedUrl'];
this.displayedColumnsUnauthorised = ['id', 'start', 'lastAccess','lastAccessedUrl'];
}

ngOnInit() {
Expand All @@ -72,18 +72,21 @@ export class ActiveSessionsComponent implements OnInit, AfterViewInit {
order: 'asc'
};

this.resourcesService.admin.activeSessions(options).subscribe(resp => {
for (const [key] of Object.entries(resp.body.items)) {
resp.body.items[key].creationDateTime = new Date(resp.body.items[key].creationDateTime);
resp.body.items[key].lastAccessedDateTime = new Date(resp.body.items[key].lastAccessedDateTime);
if (resp.body.countAuthorised > 0) {
this.records.push(resp.body.items[key]);
}

if (resp.body.countUnauthorised > 0) {
this.unauthorised.push(resp.body.items[key]);
}


this.resourcesService.session.activeSessions({},options).subscribe(resp => {
for (const [key] of Object.entries(resp.body.authorisedItems)) {
resp.body.authorisedItems[key].creationDateTime = new Date(resp.body.authorisedItems[key].creationDateTime);
resp.body.authorisedItems[key].lastAccessedDateTime = new Date(resp.body.authorisedItems[key].lastAccessedDateTime);
this.records.push(resp.body.authorisedItems[key]);
}

for (const [key] of Object.entries(resp.body.unauthorisedItems)) {
resp.body.unauthorisedItems[key].creationDateTime = new Date(resp.body.unauthorisedItems[key].creationDateTime);
resp.body.unauthorisedItems[key].lastAccessedDateTime = new Date(resp.body.unauthorisedItems[key].lastAccessedDateTime);
this.unauthorised.push(resp.body.unauthorisedItems[key]);
}

this.totalItemCount = resp.body.countAuthorised;
this.unauthorisedCount = resp.body.countUnauthorised;
this.dataSource.data = this.records;
Expand Down