Skip to content

Commit

Permalink
Updates to new data format
Browse files Browse the repository at this point in the history
  • Loading branch information
johc committed Mar 28, 2024
1 parent f6fac41 commit ce98102
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 40 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fmd-telemetry/src/assets/UserSession.json
fmd-telemetry/src/assets/Endpoints.json
1 change: 0 additions & 1 deletion data.json

This file was deleted.

6 changes: 3 additions & 3 deletions fmd-telemetry/src/app/model/endpoints.model.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export interface Endpoints {
objectId: string;
createdAt: Date;
updatedAt: Date;
_id: string;
_created_at: { $date: string };
_updated_at: { $date: string };
ACL: any;
name: string;
fmd_id: string;
Expand Down
6 changes: 3 additions & 3 deletions fmd-telemetry/src/app/model/userSession.model.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export interface UserSession {
objectId: string;
createdAt: Date;
updatedAt: Date;
_id: string;
_created_at: { $date: string };
_updated_at: { $date: string };
ACL: any;
fmd_id: string;
session: number;
Expand Down
48 changes: 30 additions & 18 deletions fmd-telemetry/src/app/pages/data/data.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,43 +13,49 @@ <h1>Telemetry Data</h1>
<table mat-table [dataSource]="userSessionDataSource" #sortUserSession="matSort" matSort
class="mat-elevation-z8">

<ng-container matColumnDef="objectId">
<ng-container matColumnDef="_id">
<th mat-header-cell *matHeaderCellDef mat-sort-header>
<div class="header-with-filter">
<div class="header-title">Object ID</div>
<div class="filter-container">
<input matInput (keyup)="applyUserSessionFilter($event, 'objectId')"
<input matInput (keyup)="applyUserSessionFilter($event, '_id')"
(click)="stopPropagation($event)" placeholder=" ">
</div>
</div>
</th>
<td mat-cell *matCellDef="let session"> {{session.objectId}} </td>
<td mat-cell *matCellDef="let session"> {{session._id}} </td>
</ng-container>

<ng-container matColumnDef="createdAt">
<ng-container matColumnDef="_created_at">
<th mat-header-cell *matHeaderCellDef mat-sort-header>
<div class="header-with-filter">
<div class="header-title"> Created At</div>
<div class="filter-container">
<input matInput (keyup)="applyUserSessionFilter($event, 'createdAt')"
<input matInput (keyup)="applyUserSessionFilter($event, '_created_at')"
(click)="stopPropagation($event)" placeholder=" ">
</div>
</div>
</th>
<td mat-cell *matCellDef="let session"> {{session.createdAt}} </td>
<td mat-cell *matCellDef="let session">
{{convertDateToDisplayFormat(session._created_at?.$date)}}
</td>

</ng-container>

<ng-container matColumnDef="updatedAt">
<ng-container matColumnDef="_updated_at">
<th mat-header-cell *matHeaderCellDef mat-sort-header>
<div class="header-with-filter">
<div class="header-title">Updated At</div>
<div class="filter-container">
<input matInput (keyup)="applyUserSessionFilter($event, 'updatedAt')"
<input matInput (keyup)="applyUserSessionFilter($event, '_updated_at')"
(click)="stopPropagation($event)" placeholder=" ">
</div>
</div>
</th>
<td mat-cell *matCellDef="let session"> {{session.updatedAt}} </td>
<td mat-cell *matCellDef="let session">
{{convertDateToDisplayFormat(session._updated_at?.$date)}}
</td>

</ng-container>


Expand Down Expand Up @@ -184,43 +190,49 @@ <h1>Telemetry Data</h1>
<cdk-virtual-scroll-viewport itemSize="50" class="table-viewport">
<table mat-table [dataSource]="endpointsDataSource" #sortEndpoints="matSort" matSort
class="mat-elevation-z8">
<ng-container matColumnDef="objectId">
<ng-container matColumnDef="_id">
<th mat-header-cell *matHeaderCellDef mat-sort-header>
<div class="header-with-filter">
<div class="header-title"> Object ID</div>
<div class="filter-container">
<input matInput (keyup)="applyEndpointsFilter($event, 'objectId')"
<input matInput (keyup)="applyEndpointsFilter($event, '_id')"
(click)="stopPropagation($event)" placeholder=" ">
</div>
</div>
</th>
<td mat-cell *matCellDef="let endpoint"> {{endpoint.objectId}} </td>
<td mat-cell *matCellDef="let endpoint"> {{endpoint._id}} </td>
</ng-container>

<ng-container matColumnDef="createdAt">
<ng-container matColumnDef="_created_at">
<th mat-header-cell *matHeaderCellDef mat-sort-header>
<div class="header-with-filter">
<div class="header-title"> Created At</div>
<div class="filter-container">
<input matInput (keyup)="applyEndpointsFilter($event, 'createdAt')"
<input matInput (keyup)="applyEndpointsFilter($event, '_created_at')"
(click)="stopPropagation($event)" placeholder=" ">
</div>
</div>
</th>
<td mat-cell *matCellDef="let endpoint"> {{endpoint.createdAt}} </td>
<td mat-cell *matCellDef="let endpoint">
{{convertDateToDisplayFormat(endpoint._created_at?.$date)}}
</td>

</ng-container>

<ng-container matColumnDef="updatedAt">
<ng-container matColumnDef="_updated_at">
<th mat-header-cell *matHeaderCellDef mat-sort-header>
<div class="header-with-filter">
<div class="header-title">Updated At </div>
<div class="filter-container">
<input matInput (keyup)="applyEndpointsFilter($event, 'updatedAt')"
<input matInput (keyup)="applyEndpointsFilter($event, '_updated_at')"
(click)="stopPropagation($event)" placeholder=" ">
</div>
</div>
</th>
<td mat-cell *matCellDef="let endpoint"> {{endpoint.updatedAt}} </td>
<td mat-cell *matCellDef="let endpoint">
{{convertDateToDisplayFormat(endpoint._updated_at?.$date)}}
</td>

</ng-container>

<ng-container matColumnDef="name">
Expand Down
16 changes: 7 additions & 9 deletions fmd-telemetry/src/app/pages/data/data.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ import { UserSession } from '../../model/userSession.model';
import { MatTableDataSource } from '@angular/material/table';
import { MatSort } from '@angular/material/sort';
import { Endpoints } from '../../model/endpoints.model';
import { DatePipe } from '@angular/common';

@Component({
selector: 'app-data',
templateUrl: './data.component.html',
styleUrls: ['./data.component.scss']
})
export class DataComponent implements OnInit {
userSessionDisplayedColumns: string[] = ['objectId', 'createdAt', 'updatedAt', 'fmd_id', 'session', 'endpoints', 'blueprints', 'monitoring_0', 'monitoring_1', 'monitoring_2', 'monitoring_3', 'time_initialized'];
userSessionDisplayedColumns: string[] = ['_id', '_created_at', '_updated_at', 'fmd_id', 'session', 'endpoints', 'blueprints', 'monitoring_0', 'monitoring_1', 'monitoring_2', 'monitoring_3', 'time_initialized'];
userSessionDataSource = new MatTableDataSource<UserSession>();

endpointsDisplayedColumns: string[] = ['objectId', 'createdAt', 'updatedAt', 'name', 'fmd_id', 'session'];
endpointsDisplayedColumns: string[] = ['_id', '_created_at', '_updated_at', 'name', 'fmd_id', 'session'];
endpointsDataSource = new MatTableDataSource<Endpoints>();
@ViewChild('sortUserSession') sortUserSession?: MatSort;
@ViewChild('sortEndpoints') sortEndpoints?: MatSort;
Expand Down Expand Up @@ -44,7 +45,7 @@ export class DataComponent implements OnInit {
if (this.activeEndpointsFilters[key]) {
let searchValue = data[key as keyof Endpoints]?.toString().toLowerCase() || '';

if (key === 'createdAt' || key === 'updatedAt') {
if (key === '_created_at' || key === '_updated_at') {
searchValue = this.convertDateToDisplayFormat(searchValue);
}

Expand Down Expand Up @@ -108,17 +109,14 @@ export class DataComponent implements OnInit {

convertDateToDisplayFormat(dateStr: string): string {
if (!dateStr) return '';
const date = new Date(dateStr);
return isNaN(date.getTime()) ? '' : date.toLocaleDateString('en-US', {
year: 'numeric',
month: 'short',
day: 'numeric'
}).toLowerCase();
return dateStr;
}


stopPropagation(event: Event) {
event.stopPropagation();
}




Expand Down
12 changes: 6 additions & 6 deletions fmd-telemetry/src/app/pages/stats/stats.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,6 @@ export class StatsComponent implements OnInit {
});
}




private processEndpointVisitsData(data: Endpoints[]) {
const excludedEndpoints = ['users', 'deploy_details', 'deploy_config'];
const visitCounts = data
Expand All @@ -278,11 +275,13 @@ export class StatsComponent implements OnInit {
const processedFmdIds = new Set<string>();

this.userData.forEach(session => {
if (session.createdAt && !processedFmdIds.has(session.fmd_id)) {
if (session._created_at && !processedFmdIds.has(session.fmd_id)) {
processedFmdIds.add(session.fmd_id);
const date = new Date(session.createdAt);
// Parse the date considering the new format
const date = new Date(session._created_at.$date);
if (!isNaN(date.getTime())) {
const formattedDate = date.toLocaleDateString('en-CA');
// Format the date as 'yyyy-mm-dd'
const formattedDate = date.toISOString().split('T')[0];
if (sessionCountsByDate[formattedDate]) {
sessionCountsByDate[formattedDate] += session.session;
} else {
Expand All @@ -303,6 +302,7 @@ export class StatsComponent implements OnInit {
}






Expand Down

0 comments on commit ce98102

Please sign in to comment.