Added csv dump button to observations view.
This commit is contained in:
parent
770e4546e8
commit
d25ec78fd9
@ -201,7 +201,7 @@ class Controller {
|
|||||||
"Develop-Teamwork Leadership,Develop-Teamwork Workload,\"Develop-Knowledge, Skills and Attitudes\""
|
"Develop-Teamwork Leadership,Develop-Teamwork Workload,\"Develop-Knowledge, Skills and Attitudes\""
|
||||||
}
|
}
|
||||||
val data = getObservations(observationsRequest)
|
val data = getObservations(observationsRequest)
|
||||||
if(data.isEmpty()) return null
|
if (data.isEmpty()) return null
|
||||||
val builder = StringBuilder(csvHeaderString())
|
val builder = StringBuilder(csvHeaderString())
|
||||||
data.forEach {
|
data.forEach {
|
||||||
builder.append('\n')
|
builder.append('\n')
|
||||||
|
@ -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)}\"," +
|
||||||
@ -111,12 +111,12 @@ data class Observation(
|
|||||||
"\"${getImprovements(RatingCategory.TEAMWORK_WORKLOAD)}\",\"${getImprovements(RatingCategory.KNOWLEDGE)}\""
|
"\"${getImprovements(RatingCategory.TEAMWORK_WORKLOAD)}\",\"${getImprovements(RatingCategory.KNOWLEDGE)}\""
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getStrengths(category: RatingCategory): String{
|
private fun getStrengths(category: RatingCategory): String {
|
||||||
return entries.asSequence().filter { it.type == category }.map{ it.strengths }.joinToString()
|
return entries.asSequence().filter { it.type == category }.map { it.strengths }.joinToString()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getImprovements(category: RatingCategory): String{
|
private fun getImprovements(category: RatingCategory): String {
|
||||||
return entries.asSequence().filter { it.type == category }.map{ it.improvements }.joinToString()
|
return entries.asSequence().filter { it.type == category }.map { it.improvements }.joinToString()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun roundScore(input: Double?): String {
|
private fun roundScore(input: Double?): String {
|
||||||
@ -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.
|
||||||
*/
|
*/
|
||||||
|
@ -119,14 +119,15 @@
|
|||||||
</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>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Vue from "vue";
|
import Vue from "vue";
|
||||||
import "vue-awesome/icons/search";
|
import "vue-awesome/icons/search";
|
||||||
|
|
||||||
var moment = require("moment");
|
var moment = require("moment");
|
||||||
export default {
|
export default {
|
||||||
name: "viewobservations",
|
name: "viewobservations",
|
||||||
title: "Observations History",
|
title: "Observations History",
|
||||||
@ -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: {
|
||||||
|
Loading…
Reference in New Issue
Block a user