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:
@@ -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?
|
||||
|
||||
@@ -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
4
src/config.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"SEASONED_URL": "http://localhost:31459/api",
|
||||
"ELASTIC_URL": "http://localhost:9200"
|
||||
}
|
||||
Reference in New Issue
Block a user