Added csv dump button to observations view.

This commit is contained in:
neviyn 2018-10-30 16:47:26 +00:00
parent 770e4546e8
commit d25ec78fd9
3 changed files with 35 additions and 10 deletions

View File

@ -98,7 +98,7 @@ data class Observation(
val persons: Set<Person> val persons: Set<Person>
) { ) {
fun toCsvFormat(): String { fun toCsvFormat(): String {
return ",,${tutors.elementAt(0).name},$date,\"$observed\",\"Training\",\"Performance Improvement - Training\",\"${site.name}\",\"N/A\"," + return ",,\"${tutors.elementAt(0).name}\",$date,\"$observed\",\"Training\",\"Performance Improvement - Training\",\"${site.name}\",\"N/A\"," +
"${roundScore(monitoring)},${roundScore(controlProcedural)},${roundScore(control)}," + "${roundScore(monitoring)},${roundScore(controlProcedural)},${roundScore(control)}," +
"${roundScore(conservatism)},${roundScore(teamworkCommunications)},${roundScore(teamworkLeadership)}," + "${roundScore(conservatism)},${roundScore(teamworkCommunications)},${roundScore(teamworkLeadership)}," +
"${roundScore(teamworkWorkload)},${roundScore(knowledge)},\"${getStrengths(RatingCategory.MONITORING)}\"," + "${roundScore(teamworkWorkload)},${roundScore(knowledge)},\"${getStrengths(RatingCategory.MONITORING)}\"," +
@ -127,7 +127,6 @@ data class Observation(
} }
} }
/** /**
* Entry giving specific details on observation performance for a tutor defined constraint. * Entry giving specific details on observation performance for a tutor defined constraint.
*/ */

View File

@ -119,6 +119,7 @@
</b-col> </b-col>
</b-row> </b-row>
</b-container> </b-container>
<b-button v-if="observationData != null" class="mt-2" variant="success" @click="getCSV()">CSV Dump</b-button>
</b-container> </b-container>
</template> </template>
@ -199,6 +200,31 @@ export default {
); );
}); });
} }
},
getCSV: function() {
Vue.axios
.post("/observations/csv", {
site: this.siteSelection,
tutor: this.tutorSelection,
startDate: moment(this.startDate).format("YYYY-MM-DD"),
endDate: moment(this.endDate).format("YYYY-MM-DD"),
whom: this.whom,
person: this.person
})
.then(response => {
let blob = new Blob([response.data], {type: 'text/csv'});
let url = URL.createObjectURL(blob);
let link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'dump.csv');
document.body.appendChild(link);
link.click();
})
.catch(error => {
this.errorStatus = error.response.status;
this.errorMessage = error.response.data;
this.$refs.errorModal.show();
});
} }
}, },
watch: { watch: {