diff --git a/src/locales/de.json b/src/locales/de.json index 93e8b80ab42fc2a8c96ed32e1ddcf9629dd48a31..11ebcd73c16251a9c363fcf856ae664c1ef09647 100644 --- a/src/locales/de.json +++ b/src/locales/de.json @@ -504,6 +504,7 @@ "impersonating": "Betrachtet als", "incompatible_token": "Ihr Sitzungs-Token ist inkompatibel mit der aktuellen Version des NETVS. Bitte melden Sie sich ab und wieder an und löschen Sie ggf. alte Sitzungs-Tokens manuell aus Ihrem Account.", "incompatible_token_title": "Inkompatibles Sitzungs-Token", + "internal_error": "Internet (Netzwerk-)Fehler", "invalid_impersonate_user_event": "Der angegebene Account als den Sie sich ausgeben wollten existiert nicht. Sie agieren nun wieder im Kontext Ihres eigenen Accounts.", "invalid_impersonate_user_event_title": "Ungültiger Benutzername", "invalid_ipv6": "Ungültige IPv6-Adresse!", @@ -966,6 +967,7 @@ "ip_contact": { "description": "Dieses Formular erlaubt es Ihnen, die Adressbetreuer von einer angegebenen Adresse zu kontaktieren.", "failed": "Senden der Anfrage fehlgeschlagen! Fehlerursache: ", + "invalid_ip": "Ungültige IP-Adresse", "message": "Nachricht", "submit": "Absenden", "success": "E-Mail erfolgreich an die Adressbetreuer versendet!" diff --git a/src/locales/en.json b/src/locales/en.json index 181cea7d22ece5da994b812ae4a80139a3030ac1..810778e36663aad6a333aacbdae1fb795752442a 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -501,6 +501,7 @@ "impersonating": "Impersonating", "incompatible_token": "You session token is incompatible with the current version of NETVS. Please log out and log in again and delete old session tokens from your account.", "incompatible_token_title": "Incompatible session token", + "internal_error": "Internal (network-)error", "invalid_impersonate_user_event": "The account you tried to impersonate does not exist. Falling back to your own account.", "invalid_impersonate_user_event_title": "Invalid username", "invalid_ipv6": "Invalid IPv6 Address!", @@ -974,6 +975,7 @@ "ip_contact": { "description": "This form allows you to contact the network administrators of a given IP-address.", "failed": "Message could not be sent! Reason: ", + "invalid_ip": "Invalid ip-address", "message": "Message", "submit": "Send", "success": "E-Mail to BCD-administrators was sent successfully!" diff --git a/src/views/tools/IPContact.vue b/src/views/tools/IPContact.vue index 73d9698d638a93306464b6f9706adc502ead28c2..045c159b0ef3bdd172a50a2a2a3e490c27775988 100644 --- a/src/views/tools/IPContact.vue +++ b/src/views/tools/IPContact.vue @@ -17,10 +17,14 @@ variant="danger"> {{ $t('views.tools.ip_contact.failed') }}{{ failure_reason }} </b-alert> - + <b-alert + :show="check_cidr === false && show_ip_error" + variant="danger"> + {{ $t('views.tools.ip_contact.invalid_ip') }} + </b-alert> <b-form @submit="submitMessage"> <b-form-group :label="$t('system.ip_address_or_cidr') + ':'"> - <b-input required v-model="cidr" :placeholder="$t('system.ip_address_or_cidr')" :state="check_cidr"></b-input> + <b-input required v-model="cidr" :placeholder="$t('system.ip_address_or_cidr')" :state="check_cidr" @change="() => {if (cidr.length === 0) {show_ip_error = false}}"></b-input> </b-form-group> <b-textarea v-model="message" :placeholder="$t('views.tools.ip_contact.message')"> @@ -47,12 +51,20 @@ export default { message: '', message_pending: false, message_success: undefined, - failure_reason: '' + failure_reason: '', + show_ip_error: false, } }, methods: { async submitMessage(ev) { ev.preventDefault() + + if (!this.check_cidr) { + this.show_ip_error = true + return false + } + this.show_ip_error = false + this.message_success = undefined this.failure_reason = '' @@ -63,7 +75,9 @@ export default { this.message = '' setTimeout(() => { this.message_success = undefined }, 10_000) }).catch(e => { - if (e.response.status === 404) { + if (!e.response) { + this.failure_reason = this.$t('system.internal_error') + } else if (e.response.status === 404) { this.failure_reason = e.response.data.detail[this.$store.state.locale] || e.response.detail.en this.message_success = false } else {