Added quick interval to observations view

This commit is contained in:
neviyn 2019-02-21 16:26:48 +00:00
parent f93607cb08
commit c2ffa88912

View File

@ -12,6 +12,29 @@
</button> </button>
</div> </div>
</b-modal> </b-modal>
<b-row class="pb-2">
<b-col>
<b-button-group size="sm">
<b-button variant="dark">Quick Interval:</b-button>
<b-button
variant="outline-primary"
v-on:click="setInterval(1, 'w'); getFiltered()"
>1 Week</b-button>
<b-button
variant="outline-primary"
v-on:click="setInterval(1, 'M'); getFiltered()"
>1 Month</b-button>
<b-button
variant="outline-primary"
v-on:click="setInterval(3, 'M'); getFiltered()"
>3 Months</b-button>
<b-button
variant="outline-primary"
v-on:click="setInterval(1, 'y'); getFiltered()"
>1 Year</b-button>
</b-button-group>
</b-col>
</b-row>
<observation-search-bar v-on:refresh="getFiltered()"></observation-search-bar> <observation-search-bar v-on:refresh="getFiltered()"></observation-search-bar>
<b-container v-if="observationData != null && observationData.length > 0" fluid> <b-container v-if="observationData != null && observationData.length > 0" fluid>
<b-card no-body> <b-card no-body>
@ -30,7 +53,8 @@
{{ observation.type }} / {{ observation.observed }} {{ observation.type }} / {{ observation.observed }}
</h2> </h2>
<b-row align-h="center"> <b-row align-h="center">
<h4>Observed by: <h4>
Observed by:
<span v-bind:key="index" v-for="(tutor, index) in observation.tutors"> <span v-bind:key="index" v-for="(tutor, index) in observation.tutors">
<i> <i>
{{ tutor.name }} {{ tutor.name }}
@ -45,35 +69,67 @@
<br> <br>
<b-row class="mb-2"> <b-row class="mb-2">
<b-col class="centered-image" v-if="observation.monitoring"> <b-col class="centered-image" v-if="observation.monitoring">
<img src="../assets/Monitoring.svg" class="image-opacity" v-bind:class="{ scorewarning: observation.monitoring < 2.5 }"> <img
src="../assets/Monitoring.svg"
class="image-opacity"
v-bind:class="{ scorewarning: observation.monitoring < 2.5 }"
>
<div class="image-centered-text">{{ observation.monitoring.toFixed(1) }}</div> <div class="image-centered-text">{{ observation.monitoring.toFixed(1) }}</div>
</b-col> </b-col>
<b-col class="centered-image" v-if="observation.controlProcedural"> <b-col class="centered-image" v-if="observation.controlProcedural">
<img src="../assets/Control.svg" class="image-opacity" v-bind:class="{ scorewarning: observation.controlProcedural < 2.5 }"> <img
src="../assets/Control.svg"
class="image-opacity"
v-bind:class="{ scorewarning: observation.controlProcedural < 2.5 }"
>
<div class="image-centered-text">{{ observation.controlProcedural.toFixed(1) }}</div> <div class="image-centered-text">{{ observation.controlProcedural.toFixed(1) }}</div>
</b-col> </b-col>
<b-col class="centered-image" v-if="observation.control"> <b-col class="centered-image" v-if="observation.control">
<img src="../assets/Control.svg" class="image-opacity" v-bind:class="{ scorewarning: observation.control < 2.5 }"> <img
src="../assets/Control.svg"
class="image-opacity"
v-bind:class="{ scorewarning: observation.control < 2.5 }"
>
<div class="image-centered-text">{{ observation.control.toFixed(1) }}</div> <div class="image-centered-text">{{ observation.control.toFixed(1) }}</div>
</b-col> </b-col>
<b-col class="centered-image" v-if="observation.conservatism"> <b-col class="centered-image" v-if="observation.conservatism">
<img src="../assets/Conservatism.svg" class="image-opacity" v-bind:class="{ scorewarning: observation.conservatism < 2.5 }"> <img
src="../assets/Conservatism.svg"
class="image-opacity"
v-bind:class="{ scorewarning: observation.conservatism < 2.5 }"
>
<div class="image-centered-text">{{ observation.conservatism.toFixed(1) }}</div> <div class="image-centered-text">{{ observation.conservatism.toFixed(1) }}</div>
</b-col> </b-col>
<b-col class="centered-image" v-if="observation.teamworkCommunications"> <b-col class="centered-image" v-if="observation.teamworkCommunications">
<img src="../assets/Teamwork.svg" class="image-opacity" v-bind:class="{ scorewarning: observation.teamworkCommunications < 2.5 }"> <img
src="../assets/Teamwork.svg"
class="image-opacity"
v-bind:class="{ scorewarning: observation.teamworkCommunications < 2.5 }"
>
<div class="image-centered-text">{{ observation.teamworkCommunications.toFixed(1) }}</div> <div class="image-centered-text">{{ observation.teamworkCommunications.toFixed(1) }}</div>
</b-col> </b-col>
<b-col class="centered-image" v-if="observation.teamworkLeadership"> <b-col class="centered-image" v-if="observation.teamworkLeadership">
<img src="../assets/Teamwork.svg" class="image-opacity" v-bind:class="{ scorewarning: observation.teamworkLeadership < 2.5 }"> <img
src="../assets/Teamwork.svg"
class="image-opacity"
v-bind:class="{ scorewarning: observation.teamworkLeadership < 2.5 }"
>
<div class="image-centered-text">{{ observation.teamworkLeadership.toFixed(1) }}</div> <div class="image-centered-text">{{ observation.teamworkLeadership.toFixed(1) }}</div>
</b-col> </b-col>
<b-col class="centered-image" v-if="observation.teamworkWorkload"> <b-col class="centered-image" v-if="observation.teamworkWorkload">
<img src="../assets/Teamwork.svg" class="image-opacity" v-bind:class="{ scorewarning: observation.teamworkWorkload < 2.5 }"> <img
src="../assets/Teamwork.svg"
class="image-opacity"
v-bind:class="{ scorewarning: observation.teamworkWorkload < 2.5 }"
>
<div class="image-centered-text">{{ observation.teamworkWorkload.toFixed(1) }}</div> <div class="image-centered-text">{{ observation.teamworkWorkload.toFixed(1) }}</div>
</b-col> </b-col>
<b-col class="centered-image" v-if="observation.knowledge"> <b-col class="centered-image" v-if="observation.knowledge">
<img src="../assets/Knowledge.svg" class="image-opacity" v-bind:class="{ scorewarning: observation.knowledge < 2.5 }"> <img
src="../assets/Knowledge.svg"
class="image-opacity"
v-bind:class="{ scorewarning: observation.knowledge < 2.5 }"
>
<div class="image-centered-text">{{ observation.knowledge.toFixed(1) }}</div> <div class="image-centered-text">{{ observation.knowledge.toFixed(1) }}</div>
</b-col> </b-col>
</b-row> </b-row>
@ -126,9 +182,7 @@
</b-card> </b-card>
<b-button class="mt-2" variant="success" @click="getCSV()">CSV Dump</b-button> <b-button class="mt-2" variant="success" @click="getCSV()">CSV Dump</b-button>
</b-container> </b-container>
<b-container v-else-if="loading"> <b-container v-else-if="loading">Loading...</b-container>
Loading...
</b-container>
<b-container v-else> <b-container v-else>
<b-row> <b-row>
<b-col> <b-col>
@ -144,7 +198,7 @@
import Vue from "vue"; import Vue from "vue";
import "vue-awesome/icons/search"; import "vue-awesome/icons/search";
import ObservationEntry from "../components/ObservationEntry.vue"; import ObservationEntry from "../components/ObservationEntry.vue";
import ObservationSearchBar from "../components/ObservationSearchBar" import ObservationSearchBar from "../components/ObservationSearchBar";
var moment = require("moment"); var moment = require("moment");
export default { export default {
@ -179,7 +233,7 @@ export default {
}, },
methods: { methods: {
getFiltered: function() { getFiltered: function() {
this.loading = true this.loading = true;
Vue.axios Vue.axios
.post("/observations", { .post("/observations", {
site: this.$store.state.search.site, site: this.$store.state.search.site,
@ -191,13 +245,13 @@ export default {
}) })
.then(response => { .then(response => {
this.observationData = response.data; this.observationData = response.data;
this.loading = false this.loading = false;
}) })
.catch(error => { .catch(error => {
this.errorStatus = error.response.status; this.errorStatus = error.response.status;
this.errorMessage = error.response.data; this.errorMessage = error.response.data;
this.$refs.errorModal.show(); this.$refs.errorModal.show();
this.loading = false this.loading = false;
}); });
}, },
getCSV: function() { getCSV: function() {
@ -231,6 +285,10 @@ export default {
} else { } else {
return data.substr(0, 20) + "..."; return data.substr(0, 20) + "...";
} }
},
setInterval: function(amount, timeType) {
this.endDate = moment();
this.startDate = moment().subtract(amount, timeType);
} }
} }
}; };