Added csv dump button to observations view.
This commit is contained in:
parent
770e4546e8
commit
d25ec78fd9
@ -98,7 +98,7 @@ data class Observation(
|
||||
val persons: Set<Person>
|
||||
) {
|
||||
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(conservatism)},${roundScore(teamworkCommunications)},${roundScore(teamworkLeadership)}," +
|
||||
"${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.
|
||||
*/
|
||||
|
@ -119,6 +119,7 @@
|
||||
</b-col>
|
||||
</b-row>
|
||||
</b-container>
|
||||
<b-button v-if="observationData != null" class="mt-2" variant="success" @click="getCSV()">CSV Dump</b-button>
|
||||
</b-container>
|
||||
</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: {
|
||||
|
Loading…
Reference in New Issue
Block a user