mirror of https://github.com/Lissy93/dashy.git
✨ Re: #181 Adds option to ignore SSL in ping
This commit is contained in:
parent
e7557832d8
commit
f343af3b00
|
@ -72,6 +72,7 @@ export default {
|
||||||
statusCheckHeaders: Object,
|
statusCheckHeaders: Object,
|
||||||
statusCheckUrl: String,
|
statusCheckUrl: String,
|
||||||
statusCheckInterval: Number,
|
statusCheckInterval: Number,
|
||||||
|
statusCheckAllowInsecure: Boolean,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -144,18 +145,33 @@ export default {
|
||||||
default: return '"\\f054"';
|
default: return '"\\f054"';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
/* Pulls together all user options, returns URL + Get params for ping endpoint */
|
||||||
|
makeApiUrl() {
|
||||||
|
const {
|
||||||
|
url, statusCheckUrl, statusCheckHeaders, statusCheckAllowInsecure,
|
||||||
|
} = this;
|
||||||
|
const encode = (str) => encodeURIComponent(str);
|
||||||
|
this.statusResponse = undefined;
|
||||||
|
// Find base URL, where the API is hosted
|
||||||
|
const baseUrl = process.env.VUE_APP_DOMAIN || window.location.origin;
|
||||||
|
// Find correct URL to check, and encode
|
||||||
|
const urlToCheck = `?&url=${encode(statusCheckUrl || url)}`;
|
||||||
|
// Get, stringify and encode any headers
|
||||||
|
const headers = statusCheckHeaders
|
||||||
|
? `&headers=${encode(JSON.stringify(statusCheckHeaders))}` : '';
|
||||||
|
// Deterimine if user disabled security
|
||||||
|
const enableInsecure = statusCheckAllowInsecure ? '&enableInsecure=true' : '';
|
||||||
|
// Construct the full API endpoint's URL with GET params
|
||||||
|
return `${baseUrl}/ping/${urlToCheck}${headers}${enableInsecure}`;
|
||||||
|
},
|
||||||
/* Checks if a given service is currently online */
|
/* Checks if a given service is currently online */
|
||||||
checkWebsiteStatus() {
|
checkWebsiteStatus() {
|
||||||
this.statusResponse = undefined;
|
const endpoint = this.makeApiUrl();
|
||||||
const baseUrl = process.env.VUE_APP_DOMAIN || window.location.origin;
|
axios.get(endpoint)
|
||||||
const urlToCheck = this.statusCheckUrl || this.url;
|
|
||||||
const headers = this.statusCheckHeaders || {};
|
|
||||||
const endpoint = `${baseUrl}/ping?url=${urlToCheck}`;
|
|
||||||
axios.get(endpoint, { headers })
|
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
if (response.data) this.statusResponse = response.data;
|
if (response.data) this.statusResponse = response.data;
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => { // Something went very wrong.
|
||||||
this.statusResponse = {
|
this.statusResponse = {
|
||||||
statusText: 'Failed to make request',
|
statusText: 'Failed to make request',
|
||||||
statusSuccess: false,
|
statusSuccess: false,
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
:hotkey="item.hotkey"
|
:hotkey="item.hotkey"
|
||||||
:enableStatusCheck="shouldEnableStatusCheck(item.statusCheck)"
|
:enableStatusCheck="shouldEnableStatusCheck(item.statusCheck)"
|
||||||
:statusCheckInterval="getStatusCheckInterval()"
|
:statusCheckInterval="getStatusCheckInterval()"
|
||||||
|
:statusCheckAllowInsecure="item.statusCheckAllowInsecure"
|
||||||
@itemClicked="$emit('itemClicked')"
|
@itemClicked="$emit('itemClicked')"
|
||||||
@triggerModal="triggerModal"
|
@triggerModal="triggerModal"
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in New Issue