Linked Site and Tutor retrieval to front end.
This commit is contained in:
parent
cca23fa995
commit
95ad37c164
@ -12,6 +12,7 @@ import uk.co.neviyn.Observations.dao.SiteDao;
|
|||||||
import uk.co.neviyn.Observations.dao.TutorDao;
|
import uk.co.neviyn.Observations.dao.TutorDao;
|
||||||
import uk.co.neviyn.Observations.resources.ObservationResource;
|
import uk.co.neviyn.Observations.resources.ObservationResource;
|
||||||
import uk.co.neviyn.Observations.resources.TutorResource;
|
import uk.co.neviyn.Observations.resources.TutorResource;
|
||||||
|
import uk.co.neviyn.Observations.resources.SiteResource;
|
||||||
|
|
||||||
public class ObservationsApplication extends Application<ObservationsConfiguration> {
|
public class ObservationsApplication extends Application<ObservationsConfiguration> {
|
||||||
|
|
||||||
@ -44,5 +45,7 @@ public class ObservationsApplication extends Application<ObservationsConfigurati
|
|||||||
jersey.register(tutorResource);
|
jersey.register(tutorResource);
|
||||||
final ObservationResource observationResource = new ObservationResource(observationDao);
|
final ObservationResource observationResource = new ObservationResource(observationDao);
|
||||||
jersey.register(observationResource);
|
jersey.register(observationResource);
|
||||||
|
final SiteResource siteResource = new SiteResource(siteDao);
|
||||||
|
jersey.register(siteResource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
package uk.co.neviyn.Observations.resources;
|
||||||
|
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import uk.co.neviyn.Observations.api.SelectOption;
|
||||||
|
import uk.co.neviyn.Observations.dao.SiteDao;
|
||||||
|
|
||||||
|
import javax.ws.rs.GET;
|
||||||
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.Produces;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
@Path("/site")
|
||||||
|
@Slf4j
|
||||||
|
public class SiteResource {
|
||||||
|
|
||||||
|
private final SiteDao dao;
|
||||||
|
|
||||||
|
@Path("/all")
|
||||||
|
@GET
|
||||||
|
public List<SelectOption<Integer>> allSites(){
|
||||||
|
return dao.allSites().stream().map(x -> new SelectOption<>(x.getName(), x.getId())).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
}
|
27
frontend/package-lock.json
generated
27
frontend/package-lock.json
generated
@ -1979,6 +1979,15 @@
|
|||||||
"integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==",
|
"integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"axios": {
|
||||||
|
"version": "0.18.0",
|
||||||
|
"resolved": "http://registry.npmjs.org/axios/-/axios-0.18.0.tgz",
|
||||||
|
"integrity": "sha1-MtU+SFHv3AoRmTts0AB4nXDAUQI=",
|
||||||
|
"requires": {
|
||||||
|
"follow-redirects": "^1.3.0",
|
||||||
|
"is-buffer": "^1.1.5"
|
||||||
|
}
|
||||||
|
},
|
||||||
"babel-code-frame": {
|
"babel-code-frame": {
|
||||||
"version": "6.26.0",
|
"version": "6.26.0",
|
||||||
"resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz",
|
"resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz",
|
||||||
@ -5751,7 +5760,6 @@
|
|||||||
"version": "1.5.8",
|
"version": "1.5.8",
|
||||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.8.tgz",
|
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.8.tgz",
|
||||||
"integrity": "sha512-sy1mXPmv7kLAMKW/8XofG7o9T+6gAjzdZK4AJF6ryqQYUa/hnzgiypoeUecZ53x7XiqKNEpNqLtS97MshW2nxg==",
|
"integrity": "sha512-sy1mXPmv7kLAMKW/8XofG7o9T+6gAjzdZK4AJF6ryqQYUa/hnzgiypoeUecZ53x7XiqKNEpNqLtS97MshW2nxg==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"debug": "=3.1.0"
|
"debug": "=3.1.0"
|
||||||
},
|
},
|
||||||
@ -5760,7 +5768,6 @@
|
|||||||
"version": "3.1.0",
|
"version": "3.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
|
||||||
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
|
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"ms": "2.0.0"
|
"ms": "2.0.0"
|
||||||
}
|
}
|
||||||
@ -5768,11 +5775,15 @@
|
|||||||
"ms": {
|
"ms": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||||
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=",
|
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
|
||||||
"dev": true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"font-awesome": {
|
||||||
|
"version": "4.7.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/font-awesome/-/font-awesome-4.7.0.tgz",
|
||||||
|
"integrity": "sha1-j6jPBBGhoxr9B7BtKQK7n8gVoTM="
|
||||||
|
},
|
||||||
"for-in": {
|
"for-in": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz",
|
||||||
@ -7530,8 +7541,7 @@
|
|||||||
"is-buffer": {
|
"is-buffer": {
|
||||||
"version": "1.1.6",
|
"version": "1.1.6",
|
||||||
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz",
|
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz",
|
||||||
"integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==",
|
"integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w=="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"is-builtin-module": {
|
"is-builtin-module": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
@ -14362,6 +14372,11 @@
|
|||||||
"resolved": "https://registry.npmjs.org/vue/-/vue-2.5.17.tgz",
|
"resolved": "https://registry.npmjs.org/vue/-/vue-2.5.17.tgz",
|
||||||
"integrity": "sha512-mFbcWoDIJi0w0Za4emyLiW72Jae0yjANHbCVquMKijcavBGypqlF7zHRgMa5k4sesdv7hv2rB4JPdZfR+TPfhQ=="
|
"integrity": "sha512-mFbcWoDIJi0w0Za4emyLiW72Jae0yjANHbCVquMKijcavBGypqlF7zHRgMa5k4sesdv7hv2rB4JPdZfR+TPfhQ=="
|
||||||
},
|
},
|
||||||
|
"vue-awesome": {
|
||||||
|
"version": "3.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/vue-awesome/-/vue-awesome-3.1.2.tgz",
|
||||||
|
"integrity": "sha512-5Ax5GvbCQDz0zx4PvqJ8b8MEMRQ1IGYtOVQ6u2NBGcWjFnxq0tprCk/YtGAGlYGKwx+OQSoYKb0qZHc4qVfAIg=="
|
||||||
|
},
|
||||||
"vue-axios": {
|
"vue-axios": {
|
||||||
"version": "2.1.3",
|
"version": "2.1.3",
|
||||||
"resolved": "https://registry.npmjs.org/vue-axios/-/vue-axios-2.1.3.tgz",
|
"resolved": "https://registry.npmjs.org/vue-axios/-/vue-axios-2.1.3.tgz",
|
||||||
|
@ -9,8 +9,11 @@
|
|||||||
"test:unit": "vue-cli-service test:unit"
|
"test:unit": "vue-cli-service test:unit"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"axios": "^0.18.0",
|
||||||
"bootstrap-vue": "^2.0.0-rc.11",
|
"bootstrap-vue": "^2.0.0-rc.11",
|
||||||
|
"font-awesome": "^4.7.0",
|
||||||
"vue": "^2.5.17",
|
"vue": "^2.5.17",
|
||||||
|
"vue-awesome": "^3.1.2",
|
||||||
"vue-axios": "^2.1.3",
|
"vue-axios": "^2.1.3",
|
||||||
"vue-router": "^3.0.1",
|
"vue-router": "^3.0.1",
|
||||||
"vuex": "^3.0.1"
|
"vuex": "^3.0.1"
|
||||||
|
@ -2,8 +2,16 @@ import Vue from "vue";
|
|||||||
import App from "./App.vue";
|
import App from "./App.vue";
|
||||||
import router from "./router";
|
import router from "./router";
|
||||||
import store from "./store";
|
import store from "./store";
|
||||||
|
import axios from 'axios';
|
||||||
|
import VueAxios from 'vue-axios';
|
||||||
|
import BootstrapVue from 'bootstrap-vue';
|
||||||
|
import Icon from 'vue-awesome/components/Icon';
|
||||||
|
|
||||||
Vue.config.productionTip = false;
|
Vue.config.productionTip = false;
|
||||||
|
axios.defaults.baseUrl = "http://localhost:8090/api";
|
||||||
|
Vue.use(VueAxios, axios);
|
||||||
|
Vue.use(BootstrapVue);
|
||||||
|
Vue.component('v-icon', Icon);
|
||||||
|
|
||||||
new Vue({
|
new Vue({
|
||||||
router,
|
router,
|
||||||
|
@ -1,18 +1,73 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="home">
|
<b-container class="home">
|
||||||
<img alt="Vue logo" src="../assets/logo.png">
|
<h1>Training Observations</h1>
|
||||||
<HelloWorld msg="Welcome to Your Vue.js App"/>
|
<b-row>
|
||||||
</div>
|
<b-form-group label="Site">
|
||||||
|
<b-form-select v-model="site" :options="siteOptions"></b-form-select>
|
||||||
|
</b-form-group>
|
||||||
|
</b-row>
|
||||||
|
<b-row>
|
||||||
|
<b-form-group label="Description">
|
||||||
|
<b-form-input v-model="description" type="text"></b-form-input>
|
||||||
|
</b-form-group>
|
||||||
|
</b-row>
|
||||||
|
<b-row>
|
||||||
|
<b-form-group label="Type">
|
||||||
|
<b-form-select v-model="type">
|
||||||
|
<option :value=null>Select a training type</option>
|
||||||
|
<option value="INITIAL">INITIAL</option>
|
||||||
|
<option value="CONTINUING">CONTINUING</option>
|
||||||
|
</b-form-select>
|
||||||
|
</b-form-group>
|
||||||
|
</b-row>
|
||||||
|
<b-row>
|
||||||
|
<b-form-group label="Tutor(s)">
|
||||||
|
<p v-if="site == null">Select a site first.</p>
|
||||||
|
<v-icon name="spinner" spin v-if="loadingTutors"/>
|
||||||
|
<b-form-checkbox-group v-model="tutors" :options="tutorOptions"></b-form-checkbox-group>
|
||||||
|
</b-form-group>
|
||||||
|
</b-row>
|
||||||
|
</b-container>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// @ is an alias to /src
|
import Vue from 'vue'
|
||||||
import HelloWorld from "@/components/HelloWorld.vue";
|
import 'vue-awesome/icons/spinner';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "home",
|
name: "home",
|
||||||
components: {
|
data () {
|
||||||
HelloWorld
|
return {
|
||||||
|
site: null,
|
||||||
|
description: null,
|
||||||
|
type: null,
|
||||||
|
tutors: [],
|
||||||
|
siteOptions: [],
|
||||||
|
tutorOptions: [],
|
||||||
|
loadingTutors: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted () {
|
||||||
|
Vue.axios.get("/api/site/all").then((response) => {
|
||||||
|
this.siteOptions = response.data;
|
||||||
|
})
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
site: function () {
|
||||||
|
this.loadingTutors = true;
|
||||||
|
this.tutorOptions = [];
|
||||||
|
this.tutors = [];
|
||||||
|
this.getTutors();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
getTutors: function () {
|
||||||
|
if(this.site != null){
|
||||||
|
Vue.axios.get("/api/tutor/site/" + this.site).then((response) => {
|
||||||
|
this.tutorOptions = response.data;
|
||||||
|
this.loadingTutors = false;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user