From f49d471f26e433e8acfedeaff950c7753fbd9745 Mon Sep 17 00:00:00 2001 From: Jan-Gerrit Goebel Date: Mon, 6 May 2024 13:24:27 +0200 Subject: [PATCH] Export session data --- src/app/app.module.ts | 4 +- .../progress-dashboard.component.html | 188 +++++++++++------- .../progress-dashboard.component.ts | 51 ++++- 3 files changed, 161 insertions(+), 82 deletions(-) diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 5343e63a..7e6ec6ff 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -145,6 +145,7 @@ import { timesIcon, buildingIcon, numberListIcon, + downloadIcon, } from '@cds/core/icon'; ClarityIcons.addIcons( @@ -183,7 +184,8 @@ ClarityIcons.addIcons( clockIcon, timesIcon, buildingIcon, - numberListIcon + numberListIcon, + downloadIcon ); const appInitializerFn = (appConfig: AppConfigService) => { diff --git a/src/app/dashboards/progress-dashboard/progress-dashboard.component.html b/src/app/dashboards/progress-dashboard/progress-dashboard.component.html index 1e567130..bcdb6b23 100644 --- a/src/app/dashboards/progress-dashboard/progress-dashboard.component.html +++ b/src/app/dashboards/progress-dashboard/progress-dashboard.component.html @@ -1,83 +1,125 @@
-
-
-
-
- - - - - - Whether finished sessions should be included. - - -
-
- - Filter by users email -
-
- - - - - - {{sc}} - - - - - - - -
-
-

Showing {{filteredProgress.length}} of {{currentProgress.length}} Sessions -

- -
-
+
+
+
+
+ + + + + + Whether finished sessions should be included. + +
-
- + + + + {{ sc }} + + + + + + +
- +

+ Showing {{ filteredProgress.length }} of + {{ currentProgress.length }} Sessions +

+ +
+
-
- -
- -
-
+
+
- -
-

- No sessions found. -

-
-
+
+ +
+
+
+ +
+ +
+
+
+ +
+

No sessions found.

+
+
- - - \ No newline at end of file + + diff --git a/src/app/dashboards/progress-dashboard/progress-dashboard.component.ts b/src/app/dashboards/progress-dashboard/progress-dashboard.component.ts index 65a9849d..d4fc2341 100644 --- a/src/app/dashboards/progress-dashboard/progress-dashboard.component.ts +++ b/src/app/dashboards/progress-dashboard/progress-dashboard.component.ts @@ -1,12 +1,6 @@ -import { - Component, - OnInit, - ViewChild, - Input, - SimpleChanges, -} from '@angular/core'; +import { Component, OnInit, ViewChild, Input } from '@angular/core'; import { ProgressService } from 'src/app/data/progress.service'; -import { Progress, ProgressCount } from 'src/app/data/progress'; +import { Progress } from 'src/app/data/progress'; import { UserService } from '../../data/user.service'; import { ScheduledEvent } from '../../data/scheduledevent'; import { ScheduledeventService } from '../../data/scheduledevent.service'; @@ -156,4 +150,45 @@ export class ProgressDashboardComponent implements OnInit { this.filter(); }); } + + exportCSV() { + let progressCSV = ''; + this.filteredProgress.forEach((progress) => { + progressCSV = progressCSV.concat( + progress.id + + ', ' + + progress.user + + ', ' + + progress.username + + ', ' + + progress.scenario + + ', ' + + progress.scenario_name + + ', ' + + progress.course + + ', ' + + progress.course_name + + ', ' + + progress.total_step + + ', ' + + progress.max_step + + ', ' + + progress.started + + ', ' + + progress.last_update + + '\n' + ); + }); + const filename = this.selectedEvent.event_name + '_sessions.csv'; + var element = document.createElement('a'); + element.setAttribute( + 'href', + 'data:text/plain;charset=utf-8,' + encodeURIComponent(progressCSV) + ); + element.setAttribute('download', filename); + element.style.display = 'none'; + document.body.appendChild(element); + element.click(); + document.body.removeChild(element); + } }