Skip to content
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
10 changes: 6 additions & 4 deletions src/app/dashboards/users-dashboard/users-dashboard.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface dashboardUsers extends User {
progresses?: Progress[];
uniqueScenarios?: number;
otac?: OTAC;
started?: string;
started?: Date;
status?: string;
}

Expand Down Expand Up @@ -52,7 +52,7 @@ export class UsersDashboardComponent implements OnInit, OnChanges {
`${userData.id || ''},` + // ID column
`${userData.email || ''},` + // Email column
`${userData.otac?.name || ''},` + // OTAC name column
`${userData.started || ''},` + // Started column
`${userData.started?.toISOString() || ''},` + // Started column
`${userData.progresses?.length || 0},` + // Progress count column
`${userData.uniqueScenarios || 0},` + // Unique scenarios column
`${userData.status || ''}\n`, // Status column and newline
Expand Down Expand Up @@ -109,7 +109,9 @@ export class UsersDashboardComponent implements OnInit, OnChanges {
const safeOtacs = otacs || []; // Default to empty array if null
// Map OTACs to users
const otacMap = new Map<string, OTAC>(
safeOtacs.map((otac) => [otac.user, otac]),
safeOtacs
.filter((o): o is OTAC & { user: string } => !!o.user)
.map((o) => [o.user, o]),
);

// Group progresses by user ID
Expand Down Expand Up @@ -212,7 +214,7 @@ export class UsersDashboardComponent implements OnInit, OnChanges {
return false;
}

const redeemedTimestamp = Date.parse(otac.redeemed_timestamp);
const redeemedTimestamp = otac.redeemed_timestamp.getTime();
const duration = parse(otac.max_duration);
if (!duration) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/app/data/otac.type.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export type OTAC = {
name: string;
user?: string;
redeemed_timestamp?: string;
redeemed_timestamp?: Date;
max_duration?: string;
};
11 changes: 11 additions & 0 deletions src/app/data/scheduledevent.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
GargantuaClientFactory,
ListableResourceClient,
} from './gargantua.service';
import { OTAC } from './otac.type';

@Injectable({
providedIn: 'root',
Expand Down Expand Up @@ -151,6 +152,16 @@ export class ScheduledeventService extends ListableResourceClient<ScheduledEvent
const se = JSON.parse(atou(s.content));
return of(se);
}),
map((otac: OTAC[]) => {
otac.map((iOTAC: OTAC) => {
if (iOTAC.redeemed_timestamp) {
iOTAC.redeemed_timestamp = new Date(iOTAC.redeemed_timestamp);
} else {
iOTAC.redeemed_timestamp = undefined;
}
});
return otac;
}),
);
}

Expand Down
4 changes: 3 additions & 1 deletion src/app/event/otacmanagement/otacmanagement.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ <h3 class="modal-title">
</clr-dg-cell>
<clr-dg-cell>{{ otac.name }}</clr-dg-cell>
<clr-dg-cell>{{ otac.userEmail }}</clr-dg-cell>
<clr-dg-cell>{{ otac.redeemed_timestamp }}</clr-dg-cell>
<clr-dg-cell>{{
otac.redeemed_timestamp | date: 'MMMM d, y, HH:mm:ss z'
}}</clr-dg-cell>
@if (hasMaxDuration(otac)) {
<clr-dg-cell
><cds-icon shape="clock"></cds-icon>
Expand Down
4 changes: 2 additions & 2 deletions src/app/event/otacmanagement/otacmanagement.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export class OTACManagementComponent implements OnInit, OnDestroy {
userCSVpart = `${otacUser}, ${this.getUsername(otacUser)}`;
}
otacCSV = otacCSV.concat(
`${otac.name}, ${userCSVpart}, ${otac.redeemed_timestamp}, ${otac.max_duration}, ${otac.status}\n`,
`${otac.name}, ${userCSVpart || ''}, ${otac.redeemed_timestamp?.toISOString() || ''}, ${otac.max_duration || ''}, ${otac.status || ''}\n`,
);
});
const filename = currentScheduledEvent.event_name + '_OTACs.csv';
Expand Down Expand Up @@ -196,7 +196,7 @@ export class OTACManagementComponent implements OnInit, OnDestroy {
if (!otac.user || !otac.redeemed_timestamp || !otac.max_duration) {
return false;
}
const redeemedTimestamp = Date.parse(otac.redeemed_timestamp);
const redeemedTimestamp = otac.redeemed_timestamp.getTime();
const duration = parse(otac.max_duration);
if (!duration) {
// duration could not be parsed and therefore does not seem to represent a valid duration string
Expand Down