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

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from
Draft
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
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 @@ -26,6 +26,16 @@
{{/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"
disabled={{not this.hasData}}
{{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 +88,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,16 @@
{{/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"
disabled={{not this.hasData}}
{{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 +88,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,16 @@
{{/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"
disabled={{not this.hasData}}
{{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 +93,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,16 @@
{{/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"
disabled={{not this.hasData}}
{{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 +136,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,16 @@
{{/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"
disabled={{not this.hasData}}
{{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 +88,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 { 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 CourseVisualizeSessionTypeGraph extends Component {
@service router;
Expand Down Expand Up @@ -149,4 +151,22 @@ export default class CourseVisualizeSessionTypeGraph extends Component {
this.tooltipTitle = title;
this.tooltipContent = content;
});

downloadData = dropTask(async () => {
const data = await this.getDataObjects(this.args.course, this.args.sessionType);
const output = data.map((obj) => {
const rhett = {};
rhett[`${this.intl.t('general.vocabulary')} - ${this.intl.t('general.term')}`] =
`${obj.meta.vocabulary.title} - ${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}-session-type-${this.args.sessionType.id}-vocabulary-terms.csv`,
csv,
'text/csv',
);
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@
{{/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"
disabled={{not this.hasData}}
{{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 +93,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 { 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 { action } from '@ember/object';
import { cleanQuery } from 'ilios-common/utils/query-utils';
import { map } from 'rsvp';
import { TrackedAsyncData } from 'ember-async-data';
import PapaParse from 'papaparse';
import { cleanQuery } from 'ilios-common/utils/query-utils';
import { findById, mapBy, sortBy, uniqueValues } from 'ilios-common/utils/array-helpers';
import createDownloadFile from 'ilios-common/utils/create-download-file';

export default class CourseVisualizeSessionTypesGraph extends Component {
@service router;
Expand Down Expand Up @@ -156,4 +158,17 @@ export default class CourseVisualizeSessionTypesGraph extends Component {
obj.meta.sessionType.id,
);
}

downloadData = dropTask(async () => {
const data = await this.getData(this.args.course);
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}-session-types.csv`, csv, 'text/csv');
});
}
Loading