Moved configurable api addresses to config.json. Elasticsearch relatime search can also be disabled by setting to false or undefined

This commit is contained in:
2019-06-10 00:43:09 +02:00
parent 1898fb3855
commit 2ae175d1b5
3 changed files with 16 additions and 5 deletions

View File

@@ -1,10 +1,9 @@
import axios from 'axios'
import storage from '@/storage.js'
import config from '@/config.json'
// const SEASONED_URL = 'https://api.kevinmidboe.com/api/'
const SEASONED_URL = 'http://localhost:31459/api/'
const ELASTIC_URL = 'http://localhost:9200/'
const SEASONED_URL = config.SEASONED_URL
const ELASTIC_URL = config.ELASTIC_URL
// TODO
// - Move autorization token and errors here?

View File

@@ -19,7 +19,7 @@
</div>
<transition name="fade">
<div class="dropdown" v-if="focus && query.length > 0">
<div class="dropdown" v-if="!disabled && focus && query.length > 0">
<div class="dropdown--results">
<ul v-for="(item, index) in elasticSearchResults"
@@ -46,6 +46,7 @@
import SeasonedButton from '@/components/ui/SeasonedButton.vue'
import { elasticSearchMoviesAndShows } from '@/api.js'
import config from '@/config.json'
export default {
name: 'SearchInput',
@@ -57,6 +58,7 @@ export default {
return {
query: this.value,
focus: false,
disabled: false,
scrollListener: undefined,
scrollDistance: 0,
elasticSearchResults: '',
@@ -73,6 +75,12 @@ export default {
}
}
},
beforeMount() {
const elasticUrl = config.ELASTIC_URL
if (elasticUrl === undefined || elasticUrl === false || elasticUrl === '') {
this.disabled = true
}
},
beforeDestroy() {
console.log('scroll eventlistener not removed, destroying!')
window.removeEventListener('scroll', this.disableFocus)

4
src/config.json Normal file
View File

@@ -0,0 +1,4 @@
{
"SEASONED_URL": "http://localhost:31459/api",
"ELASTIC_URL": "http://localhost:9200"
}