Skip to content

Commit

Permalink
Add programme transcription page #20
Browse files Browse the repository at this point in the history
  • Loading branch information
dcabo committed Nov 3, 2019
1 parent e1c7248 commit 42e9618
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 10 deletions.
21 changes: 21 additions & 0 deletions api/src/captions.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,25 @@ export default class Captions {
})
return results.aggregations.programmes.buckets.map(d => { return d.key })
}

async fetchProgrammeTranscription(
programme_id
) {
const query = {
query: {
bool: {
filter: [
{ term: { programme_id: programme_id } }
]
}
},
size: 10000,
sort: { start: { order: 'asc' }}
}
const results = await this.client.search({
index: 'captions',
body: query
})
return results.hits.hits.map(this.mapResult)
}
}
7 changes: 7 additions & 0 deletions api/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,12 @@ app.get('/fetchProgrammeList', cors(), async (request, response) => {
response.json(results)
})

app.get('/fetchProgrammeTranscription', cors(), async (request, response) => {
const results = await captions.fetchProgrammeTranscription(
request.query.programme_id
)
response.json(results)
})

// Register express routes & serve
app.listen(PORT, () => console.log(`Server running on port ${PORT}`))
32 changes: 32 additions & 0 deletions web/src/Programme.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<template>
<div>
<div class="container">
<div v-if="content">
<h4>{{ content[0].programme.title }}</h4>
<p v-for="(item, key) in content" :key="key" :id="item.time_start">
{{ item.time_start | formatTime }}: {{ item.content }}
</p>
</div>
</div>
</div>
</template>

<script>
import Vue from 'vue'
export default {
data() {
return {
content: null
}
},
mounted() {
const params = {
programme_id: this.$route.params.id
}
Vue.verbaAPI('fetchProgrammeTranscription', params, response => {
this.content = response.data
})
}
}
</script>
4 changes: 3 additions & 1 deletion web/src/Programmes.vue → web/src/ProgrammeList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
<div class="container">
<ul class="list-unstyled">
<li v-for="(programme, key) in programmeList" :key="key">
{{ programme }}
<router-link
:to="{ name: 'programme-details', params: { id: programme.id } }"
class="nav-link">{{ programme.title }}</router-link>
</li>
</ul>
</div>
Expand Down
20 changes: 13 additions & 7 deletions web/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { sync } from 'vuex-router-sync'

import App from './App.vue'
import Search from './Search.vue'
import Programmes from './Programmes.vue'
import ProgrammeList from './ProgrammeList.vue'
import Programme from './Programme.vue'
import About from './About.vue'
import VerbaAPI from './verba-api.js'

Expand Down Expand Up @@ -33,18 +34,23 @@ global.router = new VueRouter({
routes: [
{
path: '/',
component: Search,
name: 'search'
name: 'search',
component: Search
},
{
path: '/programmes',
component: Programmes,
name: 'programmes'
name: 'programmes',
component: ProgrammeList
},
{
path: '/programmes/:id',
name: 'programme-details',
component: Programme
},
{
path: '/about',
component: About,
name: 'about'
name: 'about',
component: About
}
]
})
Expand Down
4 changes: 2 additions & 2 deletions web/src/verba-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import axios from 'axios'

const VerbaAPI = {
install(Vue, options) {
Vue.verbaAPI = function (methodName, params, callback) {
Vue.verbaAPI = function(methodName, params, callback) {
axios
.get(process.env.VUE_APP_API_URL + methodName, { params })
.then(callback)
}
}
}

export default VerbaAPI;
export default VerbaAPI

0 comments on commit 42e9618

Please sign in to comment.