Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix UptimeKuma url breaking (#526) #603

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/components/services/UptimeKuma.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,15 @@ export default {
},
},
created() {
/* eslint-disable */
this.item.url = `${this.item.url}/status/${this.dashboard}`;
// eslint-disable-next-line vue/no-mutating-props
this.item.url = this.item.url.endsWith(this.dashboard)
? this.item.url
: `${this.item.url}/status/${this.dashboard}`;
Comment on lines -115 to +118
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid mutating props, I would suggest to remove all this, remove the slug property (need documentation update too), to use the common endpoint property. If you remove those line and configure the service this way:

- name: "Uptime Kuma"
  url: "http://192.168.0.151:3001"
  endpoint: "http://192.168.0.151:3001/status/default" # Replace default by your dashboard name if any
  type: "UptimeKuma"

instead of

- name: "Uptime Kuma"
  url: "http://192.168.0.151:3001"
  slug: "myCustomDashboard" # Defaults to "default" if not provided.
  type: "UptimeKuma"

It should works fine.

Copy link
Author

@dukeofsussex dukeofsussex Oct 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree mutating props isn't great, however your suggestion doesn't seem feasible, as endpoint is required to be a base path for the status queries to work

fetchStatus: function () {
const now = Date.now()
this.fetch(`/api/status-page/${this.dashboard}?cachebust=${now}`)
.catch((e) => console.error(e))
.then((resp) => (this.incident = resp));
this.fetch(
`/api/status-page/heartbeat/${this.dashboard}?cachebust=${now}`
)
.catch((e) => console.error(e))
.then((resp) => (this.heartbeat = resp));
},

let url = this.endpoint;
if (path) {
url = `${this.endpoint}/${path}`;
}

this.fetchStatus();
},
methods: {
fetchStatus: function () {
const now = Date.now()
const now = Date.now();
this.fetch(`/api/status-page/${this.dashboard}?cachebust=${now}`)
.catch((e) => console.error(e))
.then((resp) => (this.incident = resp));
Expand Down