Skip to content
Snippets Groups Projects
Commit f963aaeb authored by David Trattnig's avatar David Trattnig
Browse files

refact: settings for hosts

parent 0d14189b
No related branches found
No related tags found
1 merge request!1Local settings via JSON and initial use of Context API
Pipeline #2677 passed
<script>
import { onMount } from 'svelte'
import Spinner from '../common/Spinner.svelte'
import { fetchApi } from '../common/Common.svelte'
import { settings, fetchApi } from '../common/Common.svelte'
import HostCardBig from '../cards/HostCardBig.svelte'
export let api = 'https://prog-info.o94.at/api.php'
export let endpoint_hosts = 'hosts/'
export let endpoint_shows = 'shows?host='
export let hostid = undefined
/* Nested Component Props */
export let renderhtml = false // Attention: to avoid XSS attack vectors use with trusted API sources only
......@@ -23,9 +21,11 @@
let urlHostId = parseInt(url.searchParams.get('id'))
if (urlHostId) hostid = urlHostId
let hostUrl = `${api}/${endpoint_hosts}${hostid}`
let endpoint_host = settings.api.endpoints.host
let hostUrl = `${settings.api.url}/${endpoint_host}/${hostid}`
fetchApi(hostUrl, processHostResponse)
let showsUrl = `${api}/${endpoint_shows}${hostid}`
let endpoint_host_shows = settings.api.endpoints.show + `?host=${hostid}`
let showsUrl = `${settings.api.url}/${endpoint_host_shows}`
fetchApi(showsUrl, processShowsResponse)
})
......
......@@ -2,12 +2,12 @@
import { onMount } from 'svelte'
import Spinner from '../common/Spinner.svelte'
import Button, { Label } from '@smui/button'
import { fetchApi } from '../common/Common.svelte'
import { settings, fetchApi } from '../common/Common.svelte'
import HostCardAvatar from '../cards/HostCardAvatar.svelte'
// import Pagination from '../Pagination.svelte'
export let api = 'https://prog-info.o94.at/api.php'
export let endpoint = 'hosts'
// export let api = 'https://prog-info.o94.at/api.php'
// export let endpoint = 'hosts'
export let urlHostDetail = undefined
export let page = 0
export let limit = 300
......@@ -30,8 +30,8 @@
active_hosts = '?'
if (activeonly) active_hosts = '?active=true&'
let pagination = initPagination()
let url = `${api}/${endpoint}${active_hosts}${pagination}`
let endpoint = settings.api.endpoints.host
let url = `${settings.api.url}/${endpoint}${active_hosts}${pagination}`
fetchApi(url, processResponse)
})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment