mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-23 14:54:05 +00:00
chore:Webhook custom documentation (#3636)
* improved the documentation * fixed the `customBodyPlaceholder` not being translated * fixed required not being set where necessary * changed the docs that `monitorJSON` is also avalibale for cert-expiry
This commit is contained in:
parent
3fcb7bf181
commit
1515f4e121
2 changed files with 37 additions and 46 deletions
|
@ -12,9 +12,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="webhook-request-body" class="form-label">{{
|
<label for="webhook-request-body" class="form-label">{{ $t("Request Body") }}</label>
|
||||||
$t("Request Body")
|
|
||||||
}}</label>
|
|
||||||
<select
|
<select
|
||||||
id="webhook-request-body"
|
id="webhook-request-body"
|
||||||
v-model="$parent.notification.webhookContentType"
|
v-model="$parent.notification.webhookContentType"
|
||||||
|
@ -26,40 +24,29 @@
|
||||||
<option value="custom">{{ $t("webhookBodyCustomOption") }}</option>
|
<option value="custom">{{ $t("webhookBodyCustomOption") }}</option>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<div class="form-text">
|
<div v-if="$parent.notification.webhookContentType == 'json'" class="form-text">{{ $t("webhookJsonDesc", ['"application/json"']) }}</div>
|
||||||
<div v-if="$parent.notification.webhookContentType == 'json'">
|
<i18n-t v-else-if="$parent.notification.webhookContentType == 'form-data'" tag="div" keypath="webhookFormDataDesc" class="form-text">
|
||||||
<p>{{ $t("webhookJsonDesc", ['"application/json"']) }}</p>
|
<template #multipart>multipart/form-data"</template>
|
||||||
</div>
|
<template #decodeFunction>
|
||||||
<div v-if="$parent.notification.webhookContentType == 'form-data'">
|
<strong>json_decode($_POST['data'])</strong>
|
||||||
<i18n-t tag="p" keypath="webhookFormDataDesc">
|
</template>
|
||||||
<template #multipart>multipart/form-data"</template>
|
</i18n-t>
|
||||||
<template #decodeFunction>
|
<template v-else-if="$parent.notification.webhookContentType == 'custom'">
|
||||||
<strong>json_decode($_POST['data'])</strong>
|
<i18n-t tag="div" keypath="liquidIntroduction" class="form-text">
|
||||||
</template>
|
<a href="https://liquidjs.com/" target="_blank">{{ $t("documentation") }}</a>
|
||||||
</i18n-t>
|
</i18n-t>
|
||||||
</div>
|
<code v-pre>{{msg}}</code>: {{ $t("templateMsg") }}<br />
|
||||||
<div v-if="$parent.notification.webhookContentType == 'custom'">
|
<code v-pre>{{heartbeatJSON}}</code>: {{ $t("templateHeartbeatJSON") }} <b>({{ $t("templateLimitedToUpDownNotifications") }})</b><br />
|
||||||
<i18n-t tag="p" keypath="webhookCustomBodyDesc">
|
<code v-pre>{{monitorJSON}}</code>: {{ $t("templateMonitorJSON") }} <b>({{ $t("templateLimitedToUpDownCertNotifications") }})</b><br />
|
||||||
<template #msg>
|
|
||||||
<code>msg</code>
|
|
||||||
</template>
|
|
||||||
<template #heartbeat>
|
|
||||||
<code>heartbeatJSON</code>
|
|
||||||
</template>
|
|
||||||
<template #monitor>
|
|
||||||
<code>monitorJSON</code>
|
|
||||||
</template>
|
|
||||||
</i18n-t>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<textarea
|
<textarea
|
||||||
v-if="$parent.notification.webhookContentType == 'custom'"
|
id="customBody"
|
||||||
id="customBody"
|
v-model="$parent.notification.webhookCustomBody"
|
||||||
v-model="$parent.notification.webhookCustomBody"
|
class="form-control"
|
||||||
class="form-control"
|
:placeholder="customBodyPlaceholder"
|
||||||
:placeholder="customBodyPlaceholder"
|
required
|
||||||
></textarea>
|
></textarea>
|
||||||
|
</template>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
|
@ -67,15 +54,14 @@
|
||||||
<input v-model="showAdditionalHeadersField" class="form-check-input" type="checkbox">
|
<input v-model="showAdditionalHeadersField" class="form-check-input" type="checkbox">
|
||||||
<label class="form-check-label">{{ $t("webhookAdditionalHeadersTitle") }}</label>
|
<label class="form-check-label">{{ $t("webhookAdditionalHeadersTitle") }}</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-text">
|
<div class="form-text">{{ $t("webhookAdditionalHeadersDesc") }}</div>
|
||||||
<i18n-t tag="p" keypath="webhookAdditionalHeadersDesc"> </i18n-t>
|
|
||||||
</div>
|
|
||||||
<textarea
|
<textarea
|
||||||
v-if="showAdditionalHeadersField"
|
v-if="showAdditionalHeadersField"
|
||||||
id="additionalHeaders"
|
id="additionalHeaders"
|
||||||
v-model="$parent.notification.webhookAdditionalHeaders"
|
v-model="$parent.notification.webhookAdditionalHeaders"
|
||||||
class="form-control"
|
class="form-control"
|
||||||
:placeholder="headersPlaceholder"
|
:placeholder="headersPlaceholder"
|
||||||
|
:required="showAdditionalHeadersField"
|
||||||
></textarea>
|
></textarea>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -90,18 +76,18 @@ export default {
|
||||||
computed: {
|
computed: {
|
||||||
headersPlaceholder() {
|
headersPlaceholder() {
|
||||||
return this.$t("Example:", [
|
return this.$t("Example:", [
|
||||||
`
|
`{
|
||||||
{
|
|
||||||
"Authorization": "Authorization Token"
|
"Authorization": "Authorization Token"
|
||||||
}`,
|
}`,
|
||||||
]);
|
]);
|
||||||
},
|
},
|
||||||
customBodyPlaceholder() {
|
customBodyPlaceholder() {
|
||||||
return `Example:
|
return this.$t("Example:", [
|
||||||
{
|
`{
|
||||||
"Title": "Uptime Kuma Alert - {{ monitorJSON['name'] }}",
|
"Title": "Uptime Kuma Alert{% if monitorJSON %} - {{ monitorJSON['name'] }}{% endif %}",
|
||||||
"Body": "{{ msg }}"
|
"Body": "{{ msg }}"
|
||||||
}`;
|
}`
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -213,7 +213,12 @@
|
||||||
"Content Type": "Content Type",
|
"Content Type": "Content Type",
|
||||||
"webhookJsonDesc": "{0} is good for any modern HTTP servers such as Express.js",
|
"webhookJsonDesc": "{0} is good for any modern HTTP servers such as Express.js",
|
||||||
"webhookFormDataDesc": "{multipart} is good for PHP. The JSON will need to be parsed with {decodeFunction}",
|
"webhookFormDataDesc": "{multipart} is good for PHP. The JSON will need to be parsed with {decodeFunction}",
|
||||||
"webhookCustomBodyDesc": "Define a custom HTTP Body for the request. Template variables {msg}, {heartbeat}, {monitor} are accepted.",
|
"liquidIntroduction": "Templatability is achieved via the Liquid templating language. Please refer to the {0} for usage instructions. These are the available variables:",
|
||||||
|
"templateMsg": "message of the notification",
|
||||||
|
"templateHeartbeatJSON": "object describing the heartbeat",
|
||||||
|
"templateMonitorJSON": "object describing the monitor",
|
||||||
|
"templateLimitedToUpDownCertNotifications": "only available for UP/DOWN/Certificate expiry notifications",
|
||||||
|
"templateLimitedToUpDownNotifications": "only available for UP/DOWN notifications",
|
||||||
"webhookAdditionalHeadersTitle": "Additional Headers",
|
"webhookAdditionalHeadersTitle": "Additional Headers",
|
||||||
"webhookAdditionalHeadersDesc": "Sets additional headers sent with the webhook. Each header should be defined as a JSON key/value.",
|
"webhookAdditionalHeadersDesc": "Sets additional headers sent with the webhook. Each header should be defined as a JSON key/value.",
|
||||||
"webhookBodyPresetOption": "Preset - {0}",
|
"webhookBodyPresetOption": "Preset - {0}",
|
||||||
|
|
Loading…
Reference in a new issue