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
pull/3910/head
Frank Elsinga 1 year ago committed by GitHub
parent 3fcb7bf181
commit 1515f4e121
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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>
</div>
<div v-if="$parent.notification.webhookContentType == 'form-data'">
<i18n-t tag="p" keypath="webhookFormDataDesc">
<template #multipart>multipart/form-data"</template> <template #multipart>multipart/form-data"</template>
<template #decodeFunction> <template #decodeFunction>
<strong>json_decode($_POST['data'])</strong> <strong>json_decode($_POST['data'])</strong>
</template> </template>
</i18n-t> </i18n-t>
</div> <template v-else-if="$parent.notification.webhookContentType == 'custom'">
<div v-if="$parent.notification.webhookContentType == 'custom'"> <i18n-t tag="div" keypath="liquidIntroduction" class="form-text">
<i18n-t tag="p" keypath="webhookCustomBodyDesc"> <a href="https://liquidjs.com/" target="_blank">{{ $t("documentation") }}</a>
<template #msg>
<code>msg</code>
</template>
<template #heartbeat>
<code>heartbeatJSON</code>
</template>
<template #monitor>
<code>monitorJSON</code>
</template>
</i18n-t> </i18n-t>
</div> <code v-pre>{{msg}}</code>: {{ $t("templateMsg") }}<br />
</div> <code v-pre>{{heartbeatJSON}}</code>: {{ $t("templateHeartbeatJSON") }} <b>({{ $t("templateLimitedToUpDownNotifications") }})</b><br />
<code v-pre>{{monitorJSON}}</code>: {{ $t("templateMonitorJSON") }} <b>({{ $t("templateLimitedToUpDownCertNotifications") }})</b><br />
<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…
Cancel
Save