mirror of
https://github.com/BluemediaDev/fancy-gatus.git
synced 2025-07-01 09:22:41 +02:00
Merge pull request #13 from BluemediaDev/fix/filter-overall-status
Only consider statuses in the summary that are not hidden
This commit is contained in:
commit
17f4e66d87
2 changed files with 36 additions and 33 deletions
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
|
@ -27,7 +27,7 @@ jobs:
|
||||||
id: release
|
id: release
|
||||||
uses: mikepenz/release-changelog-builder-action@v5
|
uses: mikepenz/release-changelog-builder-action@v5
|
||||||
with:
|
with:
|
||||||
configuration: ".github/changelog-configuration.json"
|
configuration: '.github/changelog-configuration.json'
|
||||||
failOnError: true
|
failOnError: true
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
|
import type { AxiosError } from 'axios'
|
||||||
import { onMount } from 'svelte'
|
import { onMount } from 'svelte'
|
||||||
import type { Config } from '$lib/types/config'
|
import type { Config } from '$lib/types/config'
|
||||||
import type { Status } from '$lib/types/api'
|
import type { Status } from '$lib/types/api'
|
||||||
|
@ -15,41 +16,42 @@
|
||||||
let config: Config = $state({})
|
let config: Config = $state({})
|
||||||
let apiData: Status[] = $state([])
|
let apiData: Status[] = $state([])
|
||||||
|
|
||||||
function getConfig() {
|
async function getConfig() {
|
||||||
axios
|
try {
|
||||||
.get('config.json', { baseURL: '/' })
|
const response = await axios.get('config.json', { baseURL: '/' })
|
||||||
.then((response) => {
|
|
||||||
config = response.data
|
config = response.data
|
||||||
// Set title if defined in config
|
// Set title if defined in config
|
||||||
if (config.title) {
|
if (config.title) {
|
||||||
document.title = config.title
|
document.title = config.title
|
||||||
}
|
}
|
||||||
getApiData()
|
} catch (err) {
|
||||||
})
|
const error = err as AxiosError
|
||||||
.catch((error) => {
|
if (error.response && error.response.status === 404) {
|
||||||
if (error.response.status === 404) {
|
|
||||||
console.warn('No config.json file found. Using default values.')
|
console.warn('No config.json file found. Using default values.')
|
||||||
getApiData()
|
}
|
||||||
} else {
|
|
||||||
console.log('Error getting config: ' + error)
|
console.log('Error getting config: ' + error)
|
||||||
}
|
}
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getApiData() {
|
async function getApiData() {
|
||||||
// Set base URL for API calls if defined in config
|
// Set base URL for API calls if defined in config
|
||||||
if (config.gatusBaseUrl && axios.defaults.baseURL !== config.gatusBaseUrl) {
|
if (config.gatusBaseUrl && axios.defaults.baseURL !== config.gatusBaseUrl) {
|
||||||
axios.defaults.baseURL = config.gatusBaseUrl
|
axios.defaults.baseURL = config.gatusBaseUrl
|
||||||
}
|
}
|
||||||
axios
|
|
||||||
.get('/api/v1/endpoints/statuses')
|
try {
|
||||||
.then((response) => {
|
const response = await axios.get('/api/v1/endpoints/statuses')
|
||||||
apiData = response.data
|
apiData = response.data
|
||||||
loading = false
|
loading = false
|
||||||
})
|
} catch (error) {
|
||||||
.catch((error) => {
|
|
||||||
console.log(error)
|
console.log(error)
|
||||||
})
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function refresh() {
|
||||||
|
await getConfig()
|
||||||
|
await getApiData()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Group statuses by their group name
|
// Group statuses by their group name
|
||||||
|
@ -93,13 +95,14 @@
|
||||||
|
|
||||||
// Array of statuses where the last result has success = false
|
// Array of statuses where the last result has success = false
|
||||||
let failedStatuses = $derived.by(() => {
|
let failedStatuses = $derived.by(() => {
|
||||||
return apiData.filter((status) => {
|
const filteredStatuses = groups.flatMap((item) => item.statuses)
|
||||||
|
return filteredStatuses.filter((status) => {
|
||||||
return !status.results[status.results.length - 1].success
|
return !status.results[status.results.length - 1].success
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
getConfig()
|
refresh()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -118,6 +121,6 @@
|
||||||
expandByDefault={config.defaultExpandGroups}
|
expandByDefault={config.defaultExpandGroups}
|
||||||
/>
|
/>
|
||||||
{/each}
|
{/each}
|
||||||
<RefreshSettings defaultRefreshInterval={config.defaultRefreshInterval} onRefresh={getConfig} />
|
<RefreshSettings defaultRefreshInterval={config.defaultRefreshInterval} onRefresh={refresh} />
|
||||||
<Footer />
|
<Footer />
|
||||||
{/if}
|
{/if}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue