Added dropdown for authentication methods

This commit is contained in:
Josua Frank 2023-03-21 13:40:24 +01:00
parent 442f54de84
commit 35a56dd9e0
5 changed files with 2213 additions and 2192 deletions

View file

@ -9,11 +9,11 @@ class Ntfy extends NotificationProvider {
let okMsg = "Sent Successfully."; let okMsg = "Sent Successfully.";
try { try {
let headers = {}; let headers = {};
if (notification.ntfyusername) { if (notification.ntfyAuthenticationMethod === "usernamePassword") {
headers = { headers = {
"Authorization": "Basic " + Buffer.from(notification.ntfyusername + ":" + notification.ntfypassword).toString("base64"), "Authorization": "Basic " + Buffer.from(notification.ntfyusername + ":" + notification.ntfypassword).toString("base64"),
}; };
} else if (notification.ntfyaccesstoken) { } else if (notification.ntfyAuthenticationMethod === "accessToken") {
headers = { headers = {
"Authorization": "Bearer " + notification.ntfyaccesstoken, "Authorization": "Bearer " + notification.ntfyaccesstoken,
}; };

View file

@ -16,19 +16,25 @@
<input id="ntfy-priority" v-model="$parent.notification.ntfyPriority" type="number" class="form-control" required min="1" max="5" step="1"> <input id="ntfy-priority" v-model="$parent.notification.ntfyPriority" type="number" class="form-control" required min="1" max="5" step="1">
</div> </div>
<div class="mb-3"> <div class="mb-3">
<label for="ntfy-username" class="form-label">{{ $t("Username") }} ({{ $t("Optional") }})</label> <label for="authentication-method" class="form-label">{{ $t("AuthenticationMethod") }}</label>
<select id="authentication-method" v-model="$parent.notification.ntfyAuthenticationMethod" class="form-select">
<option v-for="(name, type) in authenticationMethods" :key="type" :value="type">{{ name }}</option>
</select>
</div>
<div class="mb-3" v-if="$parent.notification.ntfyAuthenticationMethod === 'usernamePassword'">
<label for="ntfy-username" class="form-label">{{ $t("Username") }}</label>
<div class="input-group mb-3"> <div class="input-group mb-3">
<input id="ntfy-username" v-model="$parent.notification.ntfyusername" type="text" class="form-control"> <input id="ntfy-username" v-model="$parent.notification.ntfyusername" type="text" class="form-control">
</div> </div>
</div> </div>
<div class="mb-3"> <div class="mb-3" v-if="$parent.notification.ntfyAuthenticationMethod === 'usernamePassword'">
<label for="ntfy-password" class="form-label">{{ $t("Password") }} ({{ $t("Optional") }})</label> <label for="ntfy-password" class="form-label">{{ $t("Password") }}</label>
<div class="input-group mb-3"> <div class="input-group mb-3">
<HiddenInput id="ntfy-password" v-model="$parent.notification.ntfypassword" autocomplete="new-password"></HiddenInput> <HiddenInput id="ntfy-password" v-model="$parent.notification.ntfypassword" autocomplete="new-password"></HiddenInput>
</div> </div>
</div> </div>
<div class="mb-3"> <div class="mb-3" v-if="$parent.notification.ntfyAuthenticationMethod === 'accessToken'">
<label for="ntfy-access-token" class="form-label">{{ $t("Access Token") }} ({{ $t("Optional") }})</label> <label for="ntfy-access-token" class="form-label">{{ $t("Access Token") }}</label>
<div class="input-group mb-3"> <div class="input-group mb-3">
<HiddenInput id="ntfy-access-token" v-model="$parent.notification.ntfyaccesstoken"></HiddenInput> <HiddenInput id="ntfy-access-token" v-model="$parent.notification.ntfyaccesstoken"></HiddenInput>
</div> </div>
@ -46,6 +52,15 @@ export default {
components: { components: {
HiddenInput, HiddenInput,
}, },
computed: {
authenticationMethods() {
return {
none: this.$t("None"),
usernamePassword: this.$t("UsernameAndPassword"),
accessToken: this.$t("Access Token")
}
}
},
mounted() { mounted() {
if (typeof this.$parent.notification.ntfyPriority === "undefined") { if (typeof this.$parent.notification.ntfyPriority === "undefined") {
this.$parent.notification.ntfyserverurl = "https://ntfy.sh"; this.$parent.notification.ntfyserverurl = "https://ntfy.sh";

View file

@ -735,5 +735,7 @@
"Add New Tag": "Neuen Tag hinzufügen", "Add New Tag": "Neuen Tag hinzufügen",
"lunaseaTarget": "Ziel", "lunaseaTarget": "Ziel",
"lunaseaDeviceID": "Geräte-ID", "lunaseaDeviceID": "Geräte-ID",
"lunaseaUserID": "Benutzer-ID" "lunaseaUserID": "Benutzer-ID",
"AuthenticationMethod": "Authentifizierungsmethode",
"UsernameAndPassword": "Benutzername und Passwort"
} }

View file

@ -738,5 +738,7 @@
"Add New Tag": "Neuen Tag hinzufügen", "Add New Tag": "Neuen Tag hinzufügen",
"lunaseaDeviceID": "Geräte-ID", "lunaseaDeviceID": "Geräte-ID",
"lunaseaTarget": "Ziel", "lunaseaTarget": "Ziel",
"lunaseaUserID": "Benutzer-ID" "lunaseaUserID": "Benutzer-ID",
"AuthenticationMethod": "Authentifizierungsmethode",
"UsernameAndPassword": "Benutzername und Passwort"
} }

View file

@ -706,5 +706,7 @@
"wayToGetPagerTreeIntegrationURL": "After creating the Uptime Kuma integration in PagerTree, copy the Endpoint. See full details {0}", "wayToGetPagerTreeIntegrationURL": "After creating the Uptime Kuma integration in PagerTree, copy the Endpoint. See full details {0}",
"lunaseaTarget": "Target", "lunaseaTarget": "Target",
"lunaseaDeviceID": "Device ID", "lunaseaDeviceID": "Device ID",
"lunaseaUserID": "User ID" "lunaseaUserID": "User ID",
"AuthenticationMethod": "Authentication Method",
"UsernameAndPassword": "Username and Password"
} }