diff --git a/frontend/src/components/ObservationSearchBar.vue b/frontend/src/components/ObservationSearchBar.vue
new file mode 100644
index 0000000..4238277
--- /dev/null
+++ b/frontend/src/components/ObservationSearchBar.vue
@@ -0,0 +1,160 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Refresh
+
+
+
+
diff --git a/frontend/src/views/Stats.vue b/frontend/src/views/Stats.vue
index 970d5f5..cee40cb 100644
--- a/frontend/src/views/Stats.vue
+++ b/frontend/src/views/Stats.vue
@@ -31,42 +31,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Refresh
-
-
+
{
this.chartData = response.data;
@@ -226,52 +154,10 @@ export default {
this.loading = false;
});
},
- getTutors: function() {
- if (this.siteSelection != null) {
- Vue.axios
- .get("/site/" + this.siteSelection + "/tutors")
- .then(response => {
- this.tutorOptions = [{ text: "Any", value: null }].concat(
- response.data
- );
- });
- }
- },
- changeStartDate: function(e) {
- this.startDate = e.date;
- },
- changeEndDate: function(e) {
- this.endDate = e.date;
- },
setInterval: function(amount, timeType){
this.endDate = moment();
this.startDate = moment().subtract(amount, timeType);
}
- },
- watch: {
- siteSelection: function() {
- this.tutorOptions = [];
- this.tutorSelection = null;
- this.getTutors();
- }
- },
- mounted() {
- Vue.axios
- .get("/site")
- .then(response => {
- this.siteOptions = response.data;
- })
- .catch(error => {
- if (error.response.status === 404) {
- this.$router.push("/dberror");
- return;
- }
- this.errorStatus = error.response.status;
- this.errorMessage = error.response.data;
- this.$refs.errorModal.show();
- });
- this.getTutors();
- this.getFilteredAverage();
}
};
diff --git a/frontend/src/views/ViewObservations.vue b/frontend/src/views/ViewObservations.vue
index 822f326..3d45e1d 100644
--- a/frontend/src/views/ViewObservations.vue
+++ b/frontend/src/views/ViewObservations.vue
@@ -12,51 +12,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Refresh
-
-
+
@@ -185,40 +141,20 @@
import Vue from "vue";
import "vue-awesome/icons/search";
import ObservationEntry from "../components/ObservationEntry.vue";
+import ObservationSearchBar from "../components/ObservationSearchBar"
var moment = require("moment");
export default {
name: "viewobservations",
title: "Observations History",
- components: { ObservationEntry },
+ components: { ObservationEntry, ObservationSearchBar },
data: function() {
return {
- dateOptions: {
- format: "DD/MM/YYYY",
- useCurrent: false
- },
- siteOptions: [],
- tutorOptions: [],
observationData: null,
errorStatus: null,
errorMessage: null
};
},
- mounted() {
- Vue.axios
- .get("/site")
- .then(response => {
- this.siteOptions = response.data;
- })
- .catch(error => {
- if (error.response.status === 404) {
- this.$router.push("/dberror");
- return;
- }
- });
- this.getTutors();
- this.getFiltered();
- },
computed: {
startDate: {
get() {
@@ -235,50 +171,18 @@ export default {
set(data) {
this.$store.commit("setSearchEndDate", data);
}
- },
- siteSelection: {
- get() {
- return this.$store.state.search.site;
- },
- set(data) {
- this.$store.commit("setSearchSite", data);
- }
- },
- tutorSelection: {
- get() {
- return this.$store.state.search.tutor;
- },
- set(data) {
- this.$store.commit("setSearchTutor", data);
- }
- },
- whom: {
- get() {
- return this.$store.state.search.whom;
- },
- set(data) {
- this.$store.commit("setSearchWhom", data);
- }
- },
- person: {
- get() {
- return this.$store.state.search.person;
- },
- set(data) {
- this.$store.commit("setSearchPerson", data);
- }
}
},
methods: {
getFiltered: function() {
Vue.axios
.post("/observations", {
- site: this.siteSelection,
- tutor: this.tutorSelection,
+ site: this.$store.state.search.site,
+ tutor: this.$store.state.search.tutor,
startDate: moment(this.startDate).format("YYYY-MM-DD"),
endDate: moment(this.endDate).format("YYYY-MM-DD"),
- whom: this.whom,
- person: this.person
+ whom: this.$store.state.search.whom,
+ person: this.$store.state.search.person
})
.then(response => {
this.observationData = response.data;
@@ -289,23 +193,6 @@ export default {
this.$refs.errorModal.show();
});
},
- changeStartDate: function(e) {
- this.startDate = e.date;
- },
- changeEndDate: function(e) {
- this.endDate = e.date;
- },
- getTutors: function() {
- if (this.siteSelection != null) {
- Vue.axios
- .get("/site/" + this.siteSelection + "/tutors")
- .then(response => {
- this.tutorOptions = [{ text: "Any", value: null }].concat(
- response.data
- );
- });
- }
- },
getCSV: function() {
Vue.axios
.post("/observations/csv", {
@@ -338,13 +225,6 @@ export default {
return data.substr(0, 20) + "...";
}
}
- },
- watch: {
- siteSelection: function() {
- this.tutorOptions = [];
- this.tutorSelection = null;
- this.getTutors();
- }
}
};