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

adds downloadable data sheets for course visualizations #8218

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
37f1f46
install papaparse as dependency in common.
stopfstedt Nov 7, 2024
ba310f5
move create-download-file from frontend into ilios-common so it can b…
stopfstedt Nov 7, 2024
e941b1a
adds data download feature to course objectives viz.
stopfstedt Nov 7, 2024
bfa8eef
adds right-hand margin to viz styles.
stopfstedt Nov 7, 2024
d34b815
adds data download feature to course session types viz.
stopfstedt Nov 8, 2024
f37de91
rm unnecessary delays in download task.
stopfstedt Nov 8, 2024
1acfb6d
create better files names.
stopfstedt Nov 8, 2024
31a9f78
adds data download feature to course/session-type vocab-terms viz.
stopfstedt Nov 8, 2024
c836fc3
adds data download feature to course vocabularies viz.
stopfstedt Nov 8, 2024
103b594
adds data download feature to course vocabulary terms viz.
stopfstedt Nov 8, 2024
3cd34cc
adds data download feature to course/vocabulary-term session types viz.
stopfstedt Nov 8, 2024
08c90ac
adds data download feature to course instructors viz.
stopfstedt Nov 8, 2024
edc3819
ads data download feature to course/instructor session types viz.
stopfstedt Nov 8, 2024
7a5d750
ads data download feature to course/instructor vocab terms viz.
stopfstedt Nov 8, 2024
87325ea
redeclare the papaparse dependency in ilios-common as peer-dependency…
stopfstedt Dec 10, 2024
bc65b6c
adds "test" coverage for download button to course viz.
stopfstedt Dec 10, 2024
b9861d3
rm unneccesary attribute from d/l buttons.
stopfstedt Dec 10, 2024
dabc835
strip tags from course objectives while generating downloadable data.
stopfstedt Dec 10, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { action } from '@ember/object';
import { service } from '@ember/service';
import PapaParse from 'papaparse';
import { dropTask, timeout, waitForProperty } from 'ember-concurrency';
import createDownloadFile from 'frontend/utils/create-download-file';
import createDownloadFile from 'ilios-common/utils/create-download-file';
import { validatable, Length } from 'ilios-common/decorators/validation';
import { TrackedAsyncData } from 'ember-async-data';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ const definition = {
},
dataTable: {
scope: '[data-test-data-table]',
actions: {
scope: '[data-test-data-table-actions]',
download: {
scope: '[data-test-download-data]',
},
},
header: {
scope: 'thead',
sessionType: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ const definition = {
},
dataTable: {
scope: '[data-test-data-table]',
actions: {
scope: '[data-test-data-table-actions]',
download: {
scope: '[data-test-download-data]',
},
},
header: {
scope: 'thead',
vocabularyTerm: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ const definition = {
},
dataTable: {
scope: '[data-test-data-table]',
actions: {
scope: '[data-test-data-table-actions]',
download: {
scope: '[data-test-download-data]',
},
},
header: {
scope: 'thead',
instructor: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ const definition = {
},
dataTable: {
scope: '[data-test-data-table]',
actions: {
scope: '[data-test-data-table-actions]',
download: {
scope: '[data-test-download-data]',
},
},
header: {
scope: 'thead',
percentage: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ const definition = {
},
dataTable: {
scope: '[data-test-data-table]',
actions: {
scope: '[data-test-data-table-actions]',
download: {
scope: '[data-test-download-data]',
},
},
header: {
scope: 'thead',
vocabularyTerm: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ const definition = {
},
dataTable: {
scope: '[data-test-data-table]',
actions: {
scope: '[data-test-data-table-actions]',
download: {
scope: '[data-test-download-data]',
},
},
header: {
scope: 'thead',
sessionType: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ const definition = {
},
dataTable: {
scope: '[data-test-data-table]',
actions: {
scope: '[data-test-data-table-actions]',
download: {
scope: '[data-test-download-data]',
},
},
header: {
scope: 'thead',
sessionType: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ const definition = {
},
dataTable: {
scope: '[data-test-data-table]',
actions: {
scope: '[data-test-data-table-actions]',
download: {
scope: '[data-test-download-data]',
},
},
header: {
scope: 'thead',
vocabulary: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ const definition = {
},
dataTable: {
scope: '[data-test-data-table]',
actions: {
scope: '[data-test-data-table-actions]',
download: {
scope: '[data-test-download-data]',
},
},
header: {
scope: 'thead',
term: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@
{{/if}}
{{#if (and (not @isIcon) this.hasData @showDataTable)}}
<div class="data-table" data-test-data-table>
<div class="table-actions" data-test-data-table-actions>
<button
type="button"
{{on "click" (perform this.downloadData)}}
data-test-download-data
>
<FaIcon @icon="download" /> {{t "general.download"}}
</button>
</div>
<table>
<thead>
<tr>
Expand Down Expand Up @@ -78,4 +87,4 @@
{{else}}
<LoadingSpinner />
{{/if}}
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import Component from '@glimmer/component';
import { filter, map } from 'rsvp';
import { htmlSafe } from '@ember/template';
import { restartableTask, timeout } from 'ember-concurrency';
import { dropTask, restartableTask, timeout } from 'ember-concurrency';
import { service } from '@ember/service';
import { cached, tracked } from '@glimmer/tracking';
import { TrackedAsyncData } from 'ember-async-data';
import { findById, mapBy, sortBy, uniqueValues } from 'ilios-common/utils/array-helpers';
import { action } from '@ember/object';
import PapaParse from 'papaparse';
import createDownloadFile from 'ilios-common/utils/create-download-file';
import { findById, mapBy, sortBy, uniqueValues } from 'ilios-common/utils/array-helpers';

export default class CourseVisualizeInstructorSessionTypeGraph extends Component {
@service router;
Expand Down Expand Up @@ -135,4 +137,21 @@ export default class CourseVisualizeInstructorSessionTypeGraph extends Component
);
this.tooltipContent = htmlSafe(uniqueValues(mapBy(meta.sessions, 'title')).sort().join(', '));
});

downloadData = dropTask(async () => {
const data = await this.getData(this.args.course, this.args.user);
const output = data.map((obj) => {
const rhett = {};
rhett[`${this.intl.t('general.sessionType')}`] = obj.meta.sessionType.title;
rhett[this.intl.t('general.sessions')] = mapBy(obj.meta.sessions, 'title').sort().join(', ');
rhett[this.intl.t('general.minutes')] = obj.data;
return rhett;
});
const csv = PapaParse.unparse(output);
createDownloadFile(
`ilios-course-${this.args.course.id}-instructor-${this.args.user.id}-session-types.csv`,
csv,
'text/csv',
);
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@
{{/if}}
{{#if (and (not @isIcon) this.hasData @showDataTable)}}
<div class="data-table" data-test-data-table>
<div class="table-actions" data-test-data-table-actions>
<button
type="button"
{{on "click" (perform this.downloadData)}}
data-test-download-data
>
<FaIcon @icon="download" /> {{t "general.download"}}
</button>
</div>
<table>
<thead>
<tr>
Expand Down Expand Up @@ -78,4 +87,4 @@
{{else}}
<LoadingSpinner />
{{/if}}
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import Component from '@glimmer/component';
import { filter, map } from 'rsvp';
import { isEmpty } from '@ember/utils';
import { htmlSafe } from '@ember/template';
import { restartableTask, timeout } from 'ember-concurrency';
import { dropTask, restartableTask, timeout } from 'ember-concurrency';
import { service } from '@ember/service';
import { cached, tracked } from '@glimmer/tracking';
import { TrackedAsyncData } from 'ember-async-data';
import { findById, mapBy, sortBy } from 'ilios-common/utils/array-helpers';
import { action } from '@ember/object';
import PapaParse from 'papaparse';
import createDownloadFile from 'ilios-common/utils/create-download-file';
import { findById, mapBy, sortBy } from 'ilios-common/utils/array-helpers';

export default class CourseVisualizeInstructorTermGraph extends Component {
@service router;
Expand Down Expand Up @@ -156,4 +158,21 @@ export default class CourseVisualizeInstructorTermGraph extends Component {
);
this.tooltipContent = htmlSafe(mapBy(meta.sessions, 'title').sort().join(', '));
});

downloadData = dropTask(async () => {
const data = await this.getData(this.args.course, this.args.user);
const output = data.map((obj) => {
const rhett = {};
rhett[`${this.intl.t('general.term')}`] = obj.meta.term.title;
rhett[this.intl.t('general.sessions')] = mapBy(obj.meta.sessions, 'title').sort().join(', ');
rhett[this.intl.t('general.minutes')] = obj.data;
return rhett;
});
const csv = PapaParse.unparse(output);
createDownloadFile(
`ilios-course-${this.args.course.id}-instructor-${this.args.user.id}-vocabulary-terms.csv`,
csv,
'text/csv',
);
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@
{{/if}}
{{#if (and (not @isIcon) this.hasData @showDataTable)}}
<div class="data-table" data-test-data-table>
<div class="table-actions" data-test-data-table-actions>
<button
type="button"
{{on "click" (perform this.downloadData)}}
data-test-download-data
>
<FaIcon @icon="download" /> {{t "general.download"}}
</button>
</div>
<table>
<thead>
<tr>
Expand Down Expand Up @@ -83,4 +92,4 @@
{{else}}
<LoadingSpinner />
{{/if}}
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import Component from '@glimmer/component';
import { isEmpty } from '@ember/utils';
import { htmlSafe } from '@ember/template';
import { restartableTask, timeout } from 'ember-concurrency';
import { dropTask, restartableTask, timeout } from 'ember-concurrency';
import { map } from 'rsvp';
import { service } from '@ember/service';
import { cached, tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
import { cleanQuery } from 'ilios-common/utils/query-utils';
import { TrackedAsyncData } from 'ember-async-data';
import PapaParse from 'papaparse';
import createDownloadFile from 'ilios-common/utils/create-download-file';
import { findById, mapBy, sortBy, uniqueValues } from 'ilios-common/utils/array-helpers';

export default class CourseVisualizeInstructorsGraph extends Component {
Expand Down Expand Up @@ -155,4 +157,17 @@ export default class CourseVisualizeInstructorsGraph extends Component {

this.router.transitionTo('course-visualize-instructor', this.args.course.id, obj.meta.user.id);
}

downloadData = dropTask(async () => {
const data = await this.getData(this.args.course);
const output = data.map((obj) => {
const rhett = {};
rhett[`${this.intl.t('general.instructor')}`] = obj.meta.user.fullName;
rhett[this.intl.t('general.sessions')] = mapBy(obj.meta.sessions, 'title').sort().join(', ');
rhett[this.intl.t('general.minutes')] = obj.data;
return rhett;
});
const csv = PapaParse.unparse(output);
createDownloadFile(`ilios-course-${this.args.course.id}-instructors.csv`, csv, 'text/csv');
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@
{{/if}}
{{#if (and (not @isIcon) this.hasData @showDataTable)}}
<div class="data-table" data-test-data-table>
<div class="table-actions" data-test-data-table-actions>
<button
type="button"
{{on "click" (perform this.downloadData)}}
data-test-download-data
>
<FaIcon @icon="download" /> {{t "general.download"}}
</button>
</div>
<table>
<thead>
<tr>
Expand Down Expand Up @@ -126,4 +135,4 @@
{{else}}
<LoadingSpinner />
{{/if}}
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import { action } from '@ember/object';
import { service } from '@ember/service';
import { htmlSafe } from '@ember/template';
import { filter, map } from 'rsvp';
import { restartableTask, timeout } from 'ember-concurrency';
import { dropTask, restartableTask, timeout } from 'ember-concurrency';
import { TrackedAsyncData } from 'ember-async-data';
import PapaParse from 'papaparse';
import { mapBy, sortBy, uniqueValues } from 'ilios-common/utils/array-helpers';
import createDownloadFile from 'ilios-common/utils/create-download-file';

export default class CourseVisualizeObjectivesGraph extends Component {
@service router;
Expand Down Expand Up @@ -38,6 +40,7 @@ export default class CourseVisualizeObjectivesGraph extends Component {
get hasData() {
return this.data.length;
}

get sortedAscending() {
return this.sortBy.search(/desc/) === -1;
}
Expand Down Expand Up @@ -191,4 +194,23 @@ export default class CourseVisualizeObjectivesGraph extends Component {
);
this.tooltipContent = htmlSafe(mapBy(meta.sessionObjectives, 'sessionTitle').sort().join(', '));
});

downloadData = dropTask(async () => {
const sessions = await this.args.course.sessions;
const data = await this.getDataObjects(sessions);
const output = data.map((obj) => {
const rhett = {};
rhett[this.intl.t('general.percentage')] = obj.percentage;
rhett[this.intl.t('general.courseObjective')] = obj.meta.courseObjective.title;
rhett[this.intl.t('general.competencies')] = obj.meta.competencies;
rhett[this.intl.t('general.sessions')] = mapBy(
sortBy(mapBy(obj.meta.sessionObjectives, 'session'), 'title'),
'title',
).join(', ');
rhett[this.intl.t('general.minutes')] = obj.data;
return rhett;
});
const csv = PapaParse.unparse(output);
createDownloadFile(`ilios-course-${this.args.course.id}-objectives.csv`, csv, 'text/csv');
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@
{{/if}}
{{#if (and (not @isIcon) this.hasData @showDataTable)}}
<div class="data-table" data-test-data-table>
<div class="table-actions" data-test-data-table-actions>
<button
type="button"
{{on "click" (perform this.downloadData)}}
data-test-download-data
>
<FaIcon @icon="download" /> {{t "general.download"}}
</button>
</div>
<table>
<thead>
<tr>
Expand Down Expand Up @@ -78,4 +87,4 @@
{{else}}
<LoadingSpinner />
{{/if}}
</div>
</div>
Loading
Loading