Skip to content

Commit

Permalink
Add subpath support
Browse files Browse the repository at this point in the history
Fixes TwiN#88
  • Loading branch information
simonhammes committed Nov 20, 2024
1 parent 2fe9913 commit 129567b
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 16 deletions.
3 changes: 3 additions & 0 deletions config/ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const (
defaultHeader = "Health Status"
defaultLogo = ""
defaultLink = ""
defaultBase = "/"
)

var (
Expand All @@ -27,6 +28,7 @@ type Config struct {
Header string `yaml:"header,omitempty"` // Header is the text at the top of the page
Logo string `yaml:"logo,omitempty"` // Logo to display on the page
Link string `yaml:"link,omitempty"` // Link to open when clicking on the logo
Base string `yaml:"base,omitempty"` // TODO:
Buttons []Button `yaml:"buttons,omitempty"` // Buttons to display below the header
}

Expand All @@ -52,6 +54,7 @@ func GetDefaultConfig() *Config {
Header: defaultHeader,
Logo: defaultLogo,
Link: defaultLink,
Base: defaultBase,
}
}

Expand Down
11 changes: 6 additions & 5 deletions web/app/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
window.config = {logo: "{{ .Logo }}", header: "{{ .Header }}", link: "{{ .Link }}", buttons: []};{{- range .Buttons}}window.config.buttons.push({name:"{{ .Name }}",link:"{{ .Link }}"});{{end}}
</script>
<title>{{ .Title }}</title>
<base href="{{ .Base }}" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
<link rel="manifest" href="/manifest.json" crossorigin="use-credentials" />
<link rel="shortcut icon" href="/favicon.ico" />
<link rel="apple-touch-icon" sizes="180x180" href="apple-touch-icon.png" />
<link rel="icon" type="image/png" sizes="32x32" href="favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="favicon-16x16.png" />
<link rel="manifest" href="manifest.json" crossorigin="use-credentials" />
<link rel="shortcut icon" href="favicon.ico" />
<meta name="description" content="{{ .Description }}" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="apple-mobile-web-app-title" content="{{ .Title }}" />
Expand Down
4 changes: 1 addition & 3 deletions web/app/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
<script>
import Social from './components/Social.vue'
import Tooltip from './components/Tooltip.vue';
import {SERVER_URL} from "@/main";
import Loading from "@/components/Loading";
export default {
Expand All @@ -62,7 +61,7 @@ export default {
},
methods: {
fetchConfig() {
fetch(`${SERVER_URL}/api/v1/config`, {credentials: 'include'})
fetch('api/v1/config', {credentials: 'include'})
.then(response => {
this.retrievedConfig = true;
if (response.status === 200) {
Expand Down Expand Up @@ -96,7 +95,6 @@ export default {
retrievedConfig: false,
config: { oidc: false, authenticated: true },
tooltip: {},
SERVER_URL
}
},
created() {
Expand Down
10 changes: 5 additions & 5 deletions web/app/src/views/Details.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export default {
methods: {
fetchData() {
//console.log("[Details][fetchData] Fetching data");
fetch(`${this.serverUrl}/api/v1/endpoints/${this.$route.params.key}/statuses?page=${this.currentPage}`, {credentials: 'include'})
fetch(`api/v1/endpoints/${this.$route.params.key}/statuses?page=${this.currentPage}`, {credentials: 'include'})
.then(response => {
if (response.status === 200) {
response.json().then(data => {
Expand Down Expand Up @@ -166,16 +166,16 @@ export default {
});
},
generateHealthBadgeImageURL() {
return `${this.serverUrl}/api/v1/endpoints/${this.endpointStatus.key}/health/badge.svg`;
return `api/v1/endpoints/${this.endpointStatus.key}/health/badge.svg`;
},
generateUptimeBadgeImageURL(duration) {
return `${this.serverUrl}/api/v1/endpoints/${this.endpointStatus.key}/uptimes/${duration}/badge.svg`;
return `api/v1/endpoints/${this.endpointStatus.key}/uptimes/${duration}/badge.svg`;
},
generateResponseTimeBadgeImageURL(duration) {
return `${this.serverUrl}/api/v1/endpoints/${this.endpointStatus.key}/response-times/${duration}/badge.svg`;
return `api/v1/endpoints/${this.endpointStatus.key}/response-times/${duration}/badge.svg`;
},
generateResponseTimeChartImageURL() {
return `${this.serverUrl}/api/v1/endpoints/${this.endpointStatus.key}/response-times/24h/chart.svg`;
return `api/v1/endpoints/${this.endpointStatus.key}/response-times/24h/chart.svg`;
},
changePage(page) {
this.currentPage = page;
Expand Down
3 changes: 1 addition & 2 deletions web/app/src/views/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import Settings from '@/components/Settings.vue'
import Endpoints from '@/components/Endpoints.vue';
import Pagination from "@/components/Pagination";
import Loading from "@/components/Loading";
import {SERVER_URL} from "@/main.js";
export default {
name: 'Home',
Expand All @@ -32,7 +31,7 @@ export default {
emits: ['showTooltip', 'toggleShowAverageResponseTime'],
methods: {
fetchData() {
fetch(`${SERVER_URL}/api/v1/endpoints/statuses?page=${this.currentPage}`, {credentials: 'include'})
fetch(`api/v1/endpoints/statuses?page=${this.currentPage}`, {credentials: 'include'})
.then(response => {
this.retrievedData = true;
if (response.status === 200) {
Expand Down
2 changes: 1 addition & 1 deletion web/app/vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ module.exports = {
filenameHashing: false,
productionSourceMap: false,
outputDir: '../static',
publicPath: '/'
publicPath: './'
}

0 comments on commit 129567b

Please sign in to comment.