Add ESLint formatting

This commit is contained in:
AxeKam333 2025-04-07 14:38:04 +02:00
parent fdec75abe9
commit 6164cff8e7
3 changed files with 68 additions and 55 deletions

View file

@ -11,7 +11,7 @@ class SMSEagle extends NotificationProvider {
const okMsg = "Sent Successfully."; const okMsg = "Sent Successfully.";
try { try {
if (notification.smseagleApiType === "smseagle-apiv1") { if (notification.smseagleApiType === "smseagle-apiv1") { // according to https://www.smseagle.eu/apiv1/
let config = { let config = {
headers: { headers: {
"Content-Type": "application/x-www-form-urlencoded", "Content-Type": "application/x-www-form-urlencoded",
@ -20,7 +20,8 @@ class SMSEagle extends NotificationProvider {
let sendMethod; let sendMethod;
let recipientType; let recipientType;
let duration, voice_id; let duration;
let voiceId;
if (notification.smseagleRecipientType === "smseagle-contact") { if (notification.smseagleRecipientType === "smseagle-contact") {
recipientType = "contactname"; recipientType = "contactname";
@ -31,38 +32,39 @@ class SMSEagle extends NotificationProvider {
} else if (notification.smseagleRecipientType === "smseagle-to") { } else if (notification.smseagleRecipientType === "smseagle-to") {
recipientType = "to"; recipientType = "to";
sendMethod = "/send_sms"; sendMethod = "/send_sms";
if (notification.smseagleMsgType != "smseagle-sms") { if (notification.smseagleMsgType !== "smseagle-sms") {
if (notification.smseagleDuration) if (notification.smseagleDuration) {
duration = notification.smseagleDuration; duration = notification.smseagleDuration;
else } else {
duration = 10; duration = 10;
}
if (notification.smseagleMsgType == "smseagle-ring") { if (notification.smseagleMsgType === "smseagle-ring") {
sendMethod = "/ring_call"; sendMethod = "/ring_call";
} else if (notification.smseagleMsgType == "smseagle-tts") { } else if (notification.smseagleMsgType === "smseagle-tts") {
sendMethod = "/tts_call"; sendMethod = "/tts_call";
} else if (notification.smseagleMsgType == "smseagle-tts-advanced") { } else if (notification.smseagleMsgType === "smseagle-tts-advanced") {
sendMethod = "/tts_adv_call"; sendMethod = "/tts_adv_call";
voice_id = notification.smseagleTtsModel ? notification.smseagleTtsModel : 1; voiceId = notification.smseagleTtsModel ? notification.smseagleTtsModel : 1;
} }
} }
} }
const url = new URL(notification.smseagleUrl + "/http_api" + sendMethod); const url = new URL(notification.smseagleUrl + "/http_api" + sendMethod);
url.searchParams.append('access_token', notification.smseagleToken); url.searchParams.append("access_token", notification.smseagleToken);
url.searchParams.append(recipientType, notification.smseagleRecipient); url.searchParams.append(recipientType, notification.smseagleRecipient);
if (!["smseagle-ring", "smseagle-tts", "smseagle-tts-advanced"].includes(notification.smseagleRecipientType)) { if (![ "smseagle-ring", "smseagle-tts", "smseagle-tts-advanced" ].includes(notification.smseagleRecipientType)) {
url.searchParams.append('unicode', (notification.smseagleEncoding) ? "1" : "0"); url.searchParams.append("access_token", (notification.smseagleEncoding) ? "1" : "0");
url.searchParams.append('highpriority', (notification.smseaglePriority) ? notification.smseaglePriority : "0"); url.searchParams.append("access_token", (notification.smseaglePriority) ? notification.smseaglePriority : "0");
} else { } else {
url.searchParams.append('duration', duration); url.searchParams.append("duration", duration);
} }
if (notification.smseagleRecipientType != "smseagle-ring") { if (notification.smseagleRecipientType !== "smseagle-ring") {
url.searchParams.append('message', msg); url.searchParams.append("message", msg);
} }
if (voice_id) { if (voiceId) {
url.searchParams.append('voice_id', voice_id); url.searchParams.append("voice_id", voiceId);
} }
let resp = await axios.get(url.toString(), config); let resp = await axios.get(url.toString(), config);
@ -73,7 +75,7 @@ class SMSEagle extends NotificationProvider {
} }
return okMsg; return okMsg;
} else if (notification.smseagleApiType === "smseagle-apiv2") { } else if (notification.smseagleApiType === "smseagle-apiv2") { // according to https://www.smseagle.eu/docs/apiv2/
let config = { let config = {
headers: { headers: {
"access-token": notification.smseagleToken, "access-token": notification.smseagleToken,
@ -97,7 +99,7 @@ class SMSEagle extends NotificationProvider {
if (contacts) { if (contacts) {
contacts = contacts.split(","); contacts = contacts.split(",");
contacts = contacts.map(e => { contacts = contacts.map(e => {
return Number(e) return Number(e);
}); });
postData["contacts"] = contacts; postData["contacts"] = contacts;
} }
@ -105,7 +107,7 @@ class SMSEagle extends NotificationProvider {
if (groups) { if (groups) {
groups = groups.split(","); groups = groups.split(",");
groups = groups.map(e => { groups = groups.map(e => {
return Number(e) return Number(e);
}); });
postData["groups"] = groups; postData["groups"] = groups;
} }
@ -117,21 +119,22 @@ class SMSEagle extends NotificationProvider {
let endpoint = "/messages/sms"; let endpoint = "/messages/sms";
if (notification.smseagleMsgType != "smseagle-sms") { if (notification.smseagleMsgType !== "smseagle-sms") {
let duration; let duration;
if (notification.smseagleDuration) if (notification.smseagleDuration) {
duration = notification.smseagleDuration duration = notification.smseagleDuration;
else } else {
duration = 10; duration = 10;
}
postData["duration"] = duration; postData["duration"] = duration;
if (notification.smseagleMsgType == "smseagle-ring") { if (notification.smseagleMsgType === "smseagle-ring") {
endpoint = "/calls/ring"; endpoint = "/calls/ring";
} else if (notification.smseagleMsgType == "smseagle-tts") { } else if (notification.smseagleMsgType === "smseagle-tts") {
endpoint = "/calls/tts"; endpoint = "/calls/tts";
} else if (notification.smseagleMsgType == "smseagle-tts-advanced") { } else if (notification.smseagleMsgType === "smseagle-tts-advanced") {
endpoint = "/calls/tts_advanced"; endpoint = "/calls/tts_advanced";
postData["voice_id"] = notification.smseagleTtsModel ? notification.smseagleTtsModel : "1"; postData["voice_id"] = notification.smseagleTtsModel ? notification.smseagleTtsModel : "1";
} }
@ -140,9 +143,9 @@ class SMSEagle extends NotificationProvider {
let resp = await axios.post(notification.smseagleUrl + "/api/v2" + endpoint, postData, config); let resp = await axios.post(notification.smseagleUrl + "/api/v2" + endpoint, postData, config);
let countAll = resp.data.length; let countAll = resp.data.length;
let countQueued = resp.data.filter(x => x.status == "queued").length; let countQueued = resp.data.filter(x => x.status === "queued").length;
if (resp.status !== 200 || countQueued == 0) { if (resp.status !== 200 || countQueued === 0) {
let error = ""; let error = "";
if (resp.data.length > 0) { if (resp.data.length > 0) {
error = `SMSEagle API returned error: ${JSON.stringify(resp.data)}`; error = `SMSEagle API returned error: ${JSON.stringify(resp.data)}`;

View file

@ -1,8 +1,10 @@
<template> <template>
<div class="mb-3"> <div class="mb-3">
<label for="smseagle-url" class="form-label">{{ $t("smseagleUrl") }}</label> <label for="smseagle-url" class="form-label">{{ $t("smseagleUrl") }}</label>
<input id="smseagle-url" v-model="$parent.notification.smseagleUrl" type="text" minlength="7" <input
class="form-control" placeholder="http://127.0.0.1" required> id="smseagle-url" v-model="$parent.notification.smseagleUrl" type="text" minlength="7"
class="form-control" placeholder="http://127.0.0.1"
>
</div> </div>
<div class="mb-3"> <div class="mb-3">
<label for="smseagle-token" class="form-label">{{ $t("smseagleToken") }}</label> <label for="smseagle-token" class="form-label">{{ $t("smseagleToken") }}</label>
@ -18,8 +20,10 @@
<div v-if="$parent.notification.smseagleApiType === 'smseagle-apiv1'" class="mb-3"> <div v-if="$parent.notification.smseagleApiType === 'smseagle-apiv1'" class="mb-3">
<div class="mb-3"> <div class="mb-3">
<label for="smseagle-recipient-type" class="form-label">{{ $t("smseagleRecipientType") }}</label> <label for="smseagle-recipient-type" class="form-label">{{ $t("smseagleRecipientType") }}</label>
<select id="smseagle-recipient-type" v-model="$parent.notification.smseagleRecipientType" <select
class="form-select"> id="smseagle-recipient-type" v-model="$parent.notification.smseagleRecipientType"
class="form-select"
>
<option value="smseagle-to" selected>{{ $t("smseagleTo") }}</option> <option value="smseagle-to" selected>{{ $t("smseagleTo") }}</option>
<option value="smseagle-group">{{ $t("smseagleGroup") }}</option> <option value="smseagle-group">{{ $t("smseagleGroup") }}</option>
<option value="smseagle-contact">{{ $t("smseagleContact") }}</option> <option value="smseagle-contact">{{ $t("smseagleContact") }}</option>
@ -33,28 +37,34 @@
<label for="smseagle-priority" class="form-label">{{ $t("smseaglePriority") }}</label> <label for="smseagle-priority" class="form-label">{{ $t("smseaglePriority") }}</label>
<input id="smseagle-priority" v-model="$parent.notification.smseaglePriority" type="number" class="form-control" min="0" max="9" step="1" placeholder="0"> <input id="smseagle-priority" v-model="$parent.notification.smseaglePriority" type="number" class="form-control" min="0" max="9" step="1" placeholder="0">
</div> </div>
<div v-if="$parent.notification.smseagleMsgType === 'smseagle-sms' <div
|| $parent.notification.smseagleRecipientType !== 'smseagle-to'" class="mb-3 form-check form-switch"> v-if="$parent.notification.smseagleMsgType === 'smseagle-sms'
|| $parent.notification.smseagleRecipientType !== 'smseagle-to'" class="mb-3 form-check form-switch"
>
<label for="smseagle-encoding" class="form-label">{{ $t("smseagleEncoding") }}</label> <label for="smseagle-encoding" class="form-label">{{ $t("smseagleEncoding") }}</label>
<input id="smseagle-encoding" v-model="$parent.notification.smseagleEncoding" type="checkbox" class="form-check-input"> <input id="smseagle-encoding" v-model="$parent.notification.smseagleEncoding" type="checkbox" class="form-check-input">
</div> </div>
<div v-if="$parent.notification.smseagleRecipientType === 'smseagle-to'" class="mb-3"> <div v-if="$parent.notification.smseagleRecipientType === 'smseagle-to'" class="mb-3">
<label for="smseagle-msg-type" class="form-label">{{ $t("smseagleMsgType") }} </label> <div class="mb-3">
<select id="smseagle-msg-type" v-model="$parent.notification.smseagleMsgType" class="form-select"> <label for="smseagle-msg-type" class="form-label">{{ $t("smseagleMsgType") }} </label>
<option value="smseagle-sms" selected>{{ $t("smseagleMsgSms") }} </option> <select id="smseagle-msg-type" v-model="$parent.notification.smseagleMsgType" class="form-select">
<option value="smseagle-ring">{{ $t("smseagleMsgRing") }} </option> <option value="smseagle-sms" selected>{{ $t("smseagleMsgSms") }} </option>
<option value="smseagle-tts">{{ $t("smseagleMsgTts") }} </option> <option value="smseagle-ring">{{ $t("smseagleMsgRing") }} </option>
<option value="smseagle-tts-advanced">{{ $t("smseagleMsgTtsAdvanced") }} </option> <option value="smseagle-tts">{{ $t("smseagleMsgTts") }} </option>
</select> <option value="smseagle-tts-advanced">{{ $t("smseagleMsgTtsAdvanced") }} </option>
<div v-if="$parent.notification.smseagleMsgType === 'smseagle-ring' </select>
|| $parent.notification.smseagleMsgType === 'smseagle-tts' </div>
|| $parent.notification.smseagleMsgType === 'smseagle-tts-advanced'" class="mb-3"> <div
v-if="$parent.notification.smseagleMsgType === 'smseagle-ring'
|| $parent.notification.smseagleMsgType === 'smseagle-tts'
|| $parent.notification.smseagleMsgType === 'smseagle-tts-advanced'" class="mb-3"
>
<label for="smseagle-duration" class="form-label">{{ $t("smseagleDuration") }}</label> <label for="smseagle-duration" class="form-label">{{ $t("smseagleDuration") }}</label>
<input id="smseagle-duration" v-model="$parent.notification.smseagleDuration" type="number" class="form-control" min="0" max="30" step="1" placeholder="10"> <input id="smseagle-duration" v-model="$parent.notification.smseagleDuration" type="number" class="form-control" min="0" max="30" step="1" placeholder="10">
</div> </div>
<div v-if="$parent.notification.smseagleMsgType === 'smseagle-tts-advanced'" class="mb-3"> <div v-if="$parent.notification.smseagleMsgType === 'smseagle-tts-advanced'" class="mb-3">
<label for="smseagle-tts-model" class="form-label">{{ $t("smseagleTtsModel") }} </label> <label for="smseagle-tts-model" class="form-label">{{ $t("smseagleTtsModel") }} </label>
<input id="smseagle-tts-model" v-model="$parent.notification.smseagleTtsModel" type="number" class="form-control" placeholder="1" required> <input id="smseagle-tts-model" v-model="$parent.notification.smseagleTtsModel" type="number" class="form-control" placeholder="1" required>
</div> </div>
</div> </div>
</div> </div>
@ -92,13 +102,13 @@
<option value="smseagle-tts-advanced">{{ $t("smseagleMsgTtsAdvanced") }} </option> <option value="smseagle-tts-advanced">{{ $t("smseagleMsgTtsAdvanced") }} </option>
</select> </select>
</div> </div>
<div v-if="$parent.notification.smseagleMsgType && $parent.notification.smseagleMsgType !== 'smseagle-sms'" class="mb-3"> <div v-if="$parent.notification.smseagleMsgType && $parent.notification.smseagleMsgType !== 'smseagle-sms'" class="mb-3">
<label for="smseagle-duration" class="form-label">{{ $t("smseagleDuration") }}</label> <label for="smseagle-duration" class="form-label">{{ $t("smseagleDuration") }}</label>
<input id="smseagle-duration" v-model="$parent.notification.smseagleDuration" type="number" class="form-control" min="0" max="30" step="1" placeholder="10"> <input id="smseagle-duration" v-model="$parent.notification.smseagleDuration" type="number" class="form-control" min="0" max="30" step="1" placeholder="10">
</div> </div>
<div v-if="$parent.notification.smseagleMsgType === 'smseagle-tts-advanced'" class="mb-3"> <div v-if="$parent.notification.smseagleMsgType === 'smseagle-tts-advanced'" class="mb-3">
<label for="smseagle-tts-model" class="form-label">{{ $t("smseagleTtsModel") }} </label> <label for="smseagle-tts-model" class="form-label">{{ $t("smseagleTtsModel") }} </label>
<input id="smseagle-tts-model" v-model="$parent.notification.smseagleTtsModel" type="number" class="form-control" placeholder="1" required> <input id="smseagle-tts-model" v-model="$parent.notification.smseagleTtsModel" type="number" class="form-control" placeholder="1" required>
</div> </div>
</div> </div>
</template> </template>
@ -112,13 +122,13 @@ export default {
}, },
mounted() { mounted() {
if (!this.$parent.notification.smseagleApiType) { if (!this.$parent.notification.smseagleApiType) {
this.$parent.notification.smseagleApiType = 'smseagle-apiv1'; this.$parent.notification.smseagleApiType = "smseagle-apiv1";
} }
if (!this.$parent.notification.smseagleMsgType) { if (!this.$parent.notification.smseagleMsgType) {
this.$parent.notification.smseagleMsgType = 'smseagle-sms'; this.$parent.notification.smseagleMsgType = "smseagle-sms";
} }
if (!this.$parent.notification.smseagleRecipientType) { if (!this.$parent.notification.smseagleRecipientType) {
this.$parent.notification.smseagleRecipientType = 'smseagle-to'; this.$parent.notification.smseagleRecipientType = "smseagle-to";
} }
} }
}; };

View file

@ -363,8 +363,8 @@
"serwersmsSenderName": "Nazwa nadawcy (zatwierdzona w panelu klienta)", "serwersmsSenderName": "Nazwa nadawcy (zatwierdzona w panelu klienta)",
"smseagle": "SMSEagle", "smseagle": "SMSEagle",
"smseagleTo": "Numer/y telefonu", "smseagleTo": "Numer/y telefonu",
"smseagleGroup": "Grupa/y z Książki adresowej", "smseagleGroup": "Grupa/y z Książki adresowej - nazwa",
"smseagleContact": "Kontakt/y z Książki adresowej", "smseagleContact": "Kontakt/y z Książki adresowej - nazwa",
"smseagleGroupV2": "Grupa/y z Książki adresowej - ID", "smseagleGroupV2": "Grupa/y z Książki adresowej - ID",
"smseagleContactV2": "Kontakt/y z Książki adresowej - ID", "smseagleContactV2": "Kontakt/y z Książki adresowej - ID",
"smseagleRecipientType": "Typ odbiorcy", "smseagleRecipientType": "Typ odbiorcy",
@ -380,7 +380,7 @@
"smseagleMsgTtsAdvanced": "Połączenie text-to-speech (zaawansowane)", "smseagleMsgTtsAdvanced": "Połączenie text-to-speech (zaawansowane)",
"smseagleDuration": "Czas trwania (domyślnie=10)", "smseagleDuration": "Czas trwania (domyślnie=10)",
"smseagleTtsModel": "ID modelu głosowego TTS", "smseagleTtsModel": "ID modelu głosowego TTS",
"smseagleApiType": "wersja API", "smseagleApiType": "Wersja API",
"smseagleApiv1": "APIv1 (dla istniejących projektów)", "smseagleApiv1": "APIv1 (dla istniejących projektów)",
"smseagleApiv2": "APIv2 (zalecane dla nowych integracji)", "smseagleApiv2": "APIv2 (zalecane dla nowych integracji)",
"stackfield": "Stackfield", "stackfield": "Stackfield",