2021-06-25 13:55:49 +00:00
|
|
|
<template>
|
2021-08-19 18:37:59 +00:00
|
|
|
<transition name="slide-fade" appear>
|
|
|
|
<div>
|
|
|
|
<h1 class="mb-3">{{ pageName }}</h1>
|
|
|
|
<form @submit.prevent="submit">
|
|
|
|
<div class="shadow-box">
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-6">
|
2021-08-24 10:26:44 +00:00
|
|
|
<h2 class="mb-2">{{ $t("General") }}</h2>
|
2021-08-19 18:37:59 +00:00
|
|
|
|
|
|
|
<div class="my-3">
|
2021-08-24 10:26:44 +00:00
|
|
|
<label for="type" class="form-label">{{ $t("Monitor Type") }}</label>
|
2021-09-09 13:24:29 +00:00
|
|
|
<select id="type" v-model="monitor.type" class="form-select">
|
2022-12-13 14:00:54 +00:00
|
|
|
<optgroup :label="$t('General Monitor Type')">
|
2022-06-13 10:14:47 +00:00
|
|
|
<option value="http">
|
|
|
|
HTTP(s)
|
|
|
|
</option>
|
|
|
|
<option value="port">
|
|
|
|
TCP Port
|
|
|
|
</option>
|
|
|
|
<option value="ping">
|
|
|
|
Ping
|
|
|
|
</option>
|
|
|
|
<option value="keyword">
|
|
|
|
HTTP(s) - {{ $t("Keyword") }}
|
|
|
|
</option>
|
2022-08-03 05:00:39 +00:00
|
|
|
<option value="grpc-keyword">
|
|
|
|
gRPC(s) - {{ $t("Keyword") }}
|
|
|
|
</option>
|
2022-06-13 10:14:47 +00:00
|
|
|
<option value="dns">
|
|
|
|
DNS
|
|
|
|
</option>
|
2022-06-15 09:33:00 +00:00
|
|
|
<option value="docker">
|
|
|
|
{{ $t("Docker Container") }}
|
|
|
|
</option>
|
2022-06-13 10:14:47 +00:00
|
|
|
</optgroup>
|
|
|
|
|
2022-12-13 14:00:54 +00:00
|
|
|
<optgroup :label="$t('Passive Monitor Type')">
|
2022-06-13 10:14:47 +00:00
|
|
|
<option value="push">
|
|
|
|
Push
|
|
|
|
</option>
|
|
|
|
</optgroup>
|
|
|
|
|
2022-12-13 14:00:54 +00:00
|
|
|
<optgroup :label="$t('Specific Monitor Type')">
|
2022-06-13 10:14:47 +00:00
|
|
|
<option value="steam">
|
|
|
|
{{ $t("Steam Game Server") }}
|
|
|
|
</option>
|
|
|
|
<option value="mqtt">
|
|
|
|
MQTT
|
|
|
|
</option>
|
|
|
|
<option value="sqlserver">
|
2022-10-01 20:35:33 +00:00
|
|
|
Microsoft SQL Server
|
2022-06-13 10:14:47 +00:00
|
|
|
</option>
|
2022-06-15 17:12:47 +00:00
|
|
|
<option value="postgres">
|
|
|
|
PostgreSQL
|
|
|
|
</option>
|
2022-10-02 00:52:53 +00:00
|
|
|
<option value="mysql">
|
|
|
|
MySQL/MariaDB
|
|
|
|
</option>
|
2022-08-11 13:08:06 +00:00
|
|
|
<option value="radius">
|
|
|
|
Radius
|
|
|
|
</option>
|
2022-06-13 10:14:47 +00:00
|
|
|
</optgroup>
|
2021-08-19 18:37:59 +00:00
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
|
2021-09-30 16:09:43 +00:00
|
|
|
<!-- Friendly Name -->
|
2021-08-19 18:37:59 +00:00
|
|
|
<div class="my-3">
|
2021-08-24 10:26:44 +00:00
|
|
|
<label for="name" class="form-label">{{ $t("Friendly Name") }}</label>
|
2021-08-19 18:37:59 +00:00
|
|
|
<input id="name" v-model="monitor.name" type="text" class="form-control" required>
|
|
|
|
</div>
|
|
|
|
|
2021-09-30 16:09:43 +00:00
|
|
|
<!-- URL -->
|
2021-08-19 18:37:59 +00:00
|
|
|
<div v-if="monitor.type === 'http' || monitor.type === 'keyword' " class="my-3">
|
2021-08-24 10:26:44 +00:00
|
|
|
<label for="url" class="form-label">{{ $t("URL") }}</label>
|
2021-08-19 18:37:59 +00:00
|
|
|
<input id="url" v-model="monitor.url" type="url" class="form-control" pattern="https?://.+" required>
|
|
|
|
</div>
|
|
|
|
|
2022-08-03 05:00:39 +00:00
|
|
|
<!-- gRPC URL -->
|
|
|
|
<div v-if="monitor.type === 'grpc-keyword' " class="my-3">
|
|
|
|
<label for="grpc-url" class="form-label">{{ $t("URL") }}</label>
|
|
|
|
<input id="grpc-url" v-model="monitor.grpcUrl" type="url" class="form-control" pattern="[^\:]+:[0-9]{5}" required>
|
|
|
|
</div>
|
|
|
|
|
2021-09-30 16:09:43 +00:00
|
|
|
<!-- Push URL -->
|
|
|
|
<div v-if="monitor.type === 'push' " class="my-3">
|
2021-10-05 07:20:24 +00:00
|
|
|
<label for="push-url" class="form-label">{{ $t("PushUrl") }}</label>
|
2021-09-30 16:09:43 +00:00
|
|
|
<CopyableInput id="push-url" v-model="pushURL" type="url" disabled="disabled" />
|
2021-10-01 08:43:11 +00:00
|
|
|
<div class="form-text">
|
2021-10-12 08:29:18 +00:00
|
|
|
{{ $t("needPushEvery", [monitor.interval]) }}<br />
|
2021-12-25 19:25:21 +00:00
|
|
|
{{ $t("pushOptionalParams", ["status, msg, ping"]) }}
|
2021-10-01 08:43:11 +00:00
|
|
|
</div>
|
2021-09-30 16:09:43 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- Keyword -->
|
2022-08-03 05:00:39 +00:00
|
|
|
<div v-if="monitor.type === 'keyword' || monitor.type === 'grpc-keyword' " class="my-3">
|
2021-08-24 10:26:44 +00:00
|
|
|
<label for="keyword" class="form-label">{{ $t("Keyword") }}</label>
|
2021-08-19 18:37:59 +00:00
|
|
|
<input id="keyword" v-model="monitor.keyword" type="text" class="form-control" required>
|
|
|
|
<div class="form-text">
|
2021-08-27 16:41:58 +00:00
|
|
|
{{ $t("keywordDescription") }}
|
2021-08-19 18:37:59 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2021-10-14 08:07:25 +00:00
|
|
|
<!-- Hostname -->
|
2022-05-12 09:48:38 +00:00
|
|
|
<!-- TCP Port / Ping / DNS / Steam / MQTT / Radius only -->
|
|
|
|
<div v-if="monitor.type === 'port' || monitor.type === 'ping' || monitor.type === 'dns' || monitor.type === 'steam' || monitor.type === 'mqtt' || monitor.type === 'radius'" class="my-3">
|
2021-08-24 10:26:44 +00:00
|
|
|
<label for="hostname" class="form-label">{{ $t("Hostname") }}</label>
|
2023-01-05 13:06:13 +00:00
|
|
|
<input id="hostname" v-model="monitor.hostname" type="text" class="form-control" :pattern="`${monitor.type === 'mqtt' ? mqttIpOrHostnameRegexPattern : ipOrHostnameRegexPattern}`" required>
|
2021-08-19 18:37:59 +00:00
|
|
|
</div>
|
|
|
|
|
2021-10-18 09:02:05 +00:00
|
|
|
<!-- Port -->
|
2022-10-12 16:32:05 +00:00
|
|
|
<!-- For TCP Port / Steam / MQTT / Radius Type -->
|
|
|
|
<div v-if="monitor.type === 'port' || monitor.type === 'steam' || monitor.type === 'mqtt' || monitor.type === 'radius'" class="my-3">
|
2021-08-24 10:26:44 +00:00
|
|
|
<label for="port" class="form-label">{{ $t("Port") }}</label>
|
2021-08-19 18:37:59 +00:00
|
|
|
<input id="port" v-model="monitor.port" type="number" class="form-control" required min="0" max="65535" step="1">
|
|
|
|
</div>
|
|
|
|
|
2021-10-18 09:02:05 +00:00
|
|
|
<!-- DNS Resolver Server -->
|
2021-08-28 03:46:26 +00:00
|
|
|
<!-- For DNS Type -->
|
|
|
|
<template v-if="monitor.type === 'dns'">
|
|
|
|
<div class="my-3">
|
|
|
|
<label for="dns_resolve_server" class="form-label">{{ $t("Resolver Server") }}</label>
|
|
|
|
<input id="dns_resolve_server" v-model="monitor.dns_resolve_server" type="text" class="form-control" :pattern="ipRegex" required>
|
|
|
|
<div class="form-text">
|
2022-01-14 18:06:21 +00:00
|
|
|
{{ $t("resolverserverDescription") }}
|
2021-08-28 03:46:26 +00:00
|
|
|
</div>
|
2021-08-22 22:05:48 +00:00
|
|
|
</div>
|
|
|
|
|
2022-04-13 20:02:19 +00:00
|
|
|
<!-- Port -->
|
|
|
|
<div class="my-3">
|
|
|
|
<label for="port" class="form-label">{{ $t("Port") }}</label>
|
|
|
|
<input id="port" v-model="monitor.port" type="number" class="form-control" required min="0" max="65535" step="1">
|
|
|
|
<div class="form-text">
|
|
|
|
{{ $t("dnsPortDescription") }}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2021-08-28 03:46:26 +00:00
|
|
|
<div class="my-3">
|
|
|
|
<label for="dns_resolve_type" class="form-label">{{ $t("Resource Record Type") }}</label>
|
|
|
|
|
|
|
|
<!-- :allow-empty="false" is not working, set a default value instead https://github.com/shentao/vue-multiselect/issues/336 -->
|
|
|
|
<VueMultiselect
|
|
|
|
id="dns_resolve_type"
|
|
|
|
v-model="monitor.dns_resolve_type"
|
|
|
|
:options="dnsresolvetypeOptions"
|
|
|
|
:multiple="false"
|
|
|
|
:close-on-select="true"
|
|
|
|
:clear-on-select="false"
|
|
|
|
:preserve-search="false"
|
2021-11-12 14:30:31 +00:00
|
|
|
:placeholder="$t('Pick a RR-Type...')"
|
2021-08-28 03:46:26 +00:00
|
|
|
:preselect-first="false"
|
|
|
|
:max-height="500"
|
|
|
|
:taggable="false"
|
|
|
|
></VueMultiselect>
|
|
|
|
|
|
|
|
<div class="form-text">
|
|
|
|
{{ $t("rrtypeDescription") }}
|
|
|
|
</div>
|
2021-08-22 22:05:48 +00:00
|
|
|
</div>
|
2021-08-28 03:46:26 +00:00
|
|
|
</template>
|
2021-08-22 22:05:48 +00:00
|
|
|
|
2022-01-13 16:17:07 +00:00
|
|
|
<!-- Docker Container Name / ID -->
|
|
|
|
<!-- For Docker Type -->
|
|
|
|
<div v-if="monitor.type === 'docker'" class="my-3">
|
|
|
|
<label for="docker_container" class="form-label">{{ $t("Container Name / ID") }}</label>
|
|
|
|
<input id="docker_container" v-model="monitor.docker_container" type="text" class="form-control" required>
|
|
|
|
</div>
|
|
|
|
|
2022-07-22 15:47:04 +00:00
|
|
|
<!-- Docker Host -->
|
2022-01-22 01:57:37 +00:00
|
|
|
<!-- For Docker Type -->
|
|
|
|
<div v-if="monitor.type === 'docker'" class="my-3">
|
2022-07-22 15:47:04 +00:00
|
|
|
<h2 class="mb-2">{{ $t("Docker Host") }}</h2>
|
|
|
|
<p v-if="$root.dockerHostList.length === 0">
|
|
|
|
{{ $t("Not available, please setup.") }}
|
|
|
|
</p>
|
2022-01-22 01:57:37 +00:00
|
|
|
|
2022-07-24 12:50:43 +00:00
|
|
|
<div v-else class="mb-3">
|
2022-07-22 15:47:04 +00:00
|
|
|
<label for="docker-host" class="form-label">{{ $t("Docker Host") }}</label>
|
|
|
|
<select id="docket-host" v-model="monitor.docker_host" class="form-select">
|
|
|
|
<option v-for="host in $root.dockerHostList" :key="host.id" :value="host.id">{{ host.name }}</option>
|
|
|
|
</select>
|
|
|
|
<a href="#" @click="$refs.dockerHostDialog.show(monitor.docker_host)">{{ $t("Edit") }}</a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<button class="btn btn-primary me-2" type="button" @click="$refs.dockerHostDialog.show()">
|
|
|
|
{{ $t("Setup Docker Host") }}
|
|
|
|
</button>
|
2022-01-13 16:17:07 +00:00
|
|
|
</div>
|
|
|
|
|
2021-11-04 01:46:43 +00:00
|
|
|
<!-- MQTT -->
|
|
|
|
<!-- For MQTT Type -->
|
|
|
|
<template v-if="monitor.type === 'mqtt'">
|
|
|
|
<div class="my-3">
|
2022-04-16 17:07:36 +00:00
|
|
|
<label for="mqttUsername" class="form-label">MQTT {{ $t("Username") }}</label>
|
2021-11-17 01:44:10 +00:00
|
|
|
<input id="mqttUsername" v-model="monitor.mqttUsername" type="text" class="form-control">
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="my-3">
|
2022-04-16 17:07:36 +00:00
|
|
|
<label for="mqttPassword" class="form-label">MQTT {{ $t("Password") }}</label>
|
|
|
|
<input id="mqttPassword" v-model="monitor.mqttPassword" type="password" class="form-control">
|
2021-11-17 01:44:10 +00:00
|
|
|
</div>
|
|
|
|
|
2021-11-04 01:46:43 +00:00
|
|
|
<div class="my-3">
|
2022-04-16 17:07:36 +00:00
|
|
|
<label for="mqttTopic" class="form-label">MQTT {{ $t("Topic") }}</label>
|
2021-11-17 01:44:10 +00:00
|
|
|
<input id="mqttTopic" v-model="monitor.mqttTopic" type="text" class="form-control" required>
|
2021-11-04 01:46:43 +00:00
|
|
|
<div class="form-text">
|
|
|
|
{{ $t("topicExplanation") }}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="my-3">
|
2022-04-16 17:07:36 +00:00
|
|
|
<label for="mqttSuccessMessage" class="form-label">MQTT {{ $t("successMessage") }}</label>
|
2022-04-18 05:04:55 +00:00
|
|
|
<input id="mqttSuccessMessage" v-model="monitor.mqttSuccessMessage" type="text" class="form-control">
|
2021-11-04 01:46:43 +00:00
|
|
|
<div class="form-text">
|
|
|
|
{{ $t("successMessageExplanation") }}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2022-05-12 09:48:38 +00:00
|
|
|
<template v-if="monitor.type === 'radius'">
|
|
|
|
<div class="my-3">
|
|
|
|
<label for="radius_username" class="form-label">Radius {{ $t("Username") }}</label>
|
|
|
|
<input id="radius_username" v-model="monitor.radiusUsername" type="text" class="form-control" required />
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="my-3">
|
|
|
|
<label for="radius_password" class="form-label">Radius {{ $t("Password") }}</label>
|
|
|
|
<input id="radius_password" v-model="monitor.radiusPassword" type="password" class="form-control" required />
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="my-3">
|
|
|
|
<label for="radius_secret" class="form-label">{{ $t("RadiusSecret") }}</label>
|
|
|
|
<input id="radius_secret" v-model="monitor.radiusSecret" type="password" class="form-control" required />
|
|
|
|
<div class="form-text"> {{ $t( "RadiusSecretDescription") }} </div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="my-3">
|
|
|
|
<label for="radius_called_station_id" class="form-label">{{ $t("RadiusCalledStationId") }}</label>
|
|
|
|
<input id="radius_called_station_id" v-model="monitor.radiusCalledStationId" type="text" class="form-control" required />
|
|
|
|
<div class="form-text"> {{ $t( "RadiusCalledStationIdDescription") }} </div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="my-3">
|
|
|
|
<label for="radius_calling_station_id" class="form-label">{{ $t("RadiusCallingStationId") }}</label>
|
|
|
|
<input id="radius_calling_station_id" v-model="monitor.radiusCallingStationId" type="text" class="form-control" required />
|
|
|
|
<div class="form-text"> {{ $t( "RadiusCallingStationIdDescription") }} </div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2022-10-02 00:52:53 +00:00
|
|
|
<!-- SQL Server / PostgreSQL / MySQL -->
|
|
|
|
<template v-if="monitor.type === 'sqlserver' || monitor.type === 'postgres' || monitor.type === 'mysql'">
|
2022-05-12 17:48:03 +00:00
|
|
|
<div class="my-3">
|
2022-06-15 17:12:47 +00:00
|
|
|
<label for="sqlConnectionString" class="form-label">{{ $t("Connection String") }}</label>
|
|
|
|
|
|
|
|
<template v-if="monitor.type === 'sqlserver'">
|
|
|
|
<input id="sqlConnectionString" v-model="monitor.databaseConnectionString" type="text" class="form-control" placeholder="Server=<hostname>,<port>;Database=<your database>;User Id=<your user id>;Password=<your password>;Encrypt=<true/false>;TrustServerCertificate=<Yes/No>;Connection Timeout=<int>">
|
|
|
|
</template>
|
|
|
|
<template v-if="monitor.type === 'postgres'">
|
2022-06-16 01:14:06 +00:00
|
|
|
<input id="sqlConnectionString" v-model="monitor.databaseConnectionString" type="text" class="form-control" placeholder="postgres://username:password@host:port/database">
|
2022-06-15 17:12:47 +00:00
|
|
|
</template>
|
2022-10-02 00:52:53 +00:00
|
|
|
<template v-if="monitor.type === 'mysql'">
|
|
|
|
<input id="sqlConnectionString" v-model="monitor.databaseConnectionString" type="text" class="form-control" placeholder="mysql://username:password@host:port/database">
|
|
|
|
</template>
|
2022-05-12 17:48:03 +00:00
|
|
|
</div>
|
|
|
|
<div class="my-3">
|
2022-06-15 17:12:47 +00:00
|
|
|
<label for="sqlQuery" class="form-label">{{ $t("Query") }}</label>
|
|
|
|
<textarea id="sqlQuery" v-model="monitor.databaseQuery" class="form-control" placeholder="Example: select getdate()"></textarea>
|
2022-05-12 17:48:03 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2021-10-01 08:43:11 +00:00
|
|
|
<!-- Interval -->
|
2021-08-19 18:37:59 +00:00
|
|
|
<div class="my-3">
|
2021-08-24 10:26:44 +00:00
|
|
|
<label for="interval" class="form-label">{{ $t("Heartbeat Interval") }} ({{ $t("checkEverySecond", [ monitor.interval ]) }})</label>
|
2022-12-08 15:21:55 +00:00
|
|
|
<input id="interval" v-model="monitor.interval" type="number" class="form-control" required :min="minInterval" step="1" :max="maxInterval">
|
2021-08-19 18:37:59 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="my-3">
|
2021-08-24 10:26:44 +00:00
|
|
|
<label for="maxRetries" class="form-label">{{ $t("Retries") }}</label>
|
2021-08-19 18:37:59 +00:00
|
|
|
<input id="maxRetries" v-model="monitor.maxretries" type="number" class="form-control" required min="0" step="1">
|
|
|
|
<div class="form-text">
|
2021-08-24 10:26:44 +00:00
|
|
|
{{ $t("retriesDescription") }}
|
2021-08-19 18:37:59 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2021-09-11 16:54:55 +00:00
|
|
|
<div class="my-3">
|
|
|
|
<label for="retry-interval" class="form-label">
|
2021-09-14 07:48:25 +00:00
|
|
|
{{ $t("Heartbeat Retry Interval") }}
|
2021-09-14 22:59:06 +00:00
|
|
|
<span>({{ $t("retryCheckEverySecond", [ monitor.retryInterval ]) }})</span>
|
2021-09-11 16:54:55 +00:00
|
|
|
</label>
|
2022-12-08 15:21:55 +00:00
|
|
|
<input id="retry-interval" v-model="monitor.retryInterval" type="number" class="form-control" required :min="minInterval" step="1">
|
2021-09-11 16:54:55 +00:00
|
|
|
</div>
|
|
|
|
|
2022-01-23 14:22:57 +00:00
|
|
|
<div class="my-3">
|
|
|
|
<label for="resend-interval" class="form-label">
|
2022-06-15 14:56:26 +00:00
|
|
|
{{ $t("Resend Notification if Down X times consequently") }}
|
|
|
|
<span v-if="monitor.resendInterval > 0">({{ $t("resendEveryXTimes", [ monitor.resendInterval ]) }})</span>
|
2022-01-24 21:20:38 +00:00
|
|
|
<span v-else>({{ $t("resendDisabled") }})</span>
|
2022-01-23 14:22:57 +00:00
|
|
|
</label>
|
2022-01-24 08:18:38 +00:00
|
|
|
<input id="resend-interval" v-model="monitor.resendInterval" type="number" class="form-control" required min="0" step="1">
|
2022-01-23 14:22:57 +00:00
|
|
|
</div>
|
|
|
|
|
2021-10-08 12:03:52 +00:00
|
|
|
<h2 v-if="monitor.type !== 'push'" class="mt-5 mb-2">{{ $t("Advanced") }}</h2>
|
2021-08-19 18:37:59 +00:00
|
|
|
|
2022-04-16 07:01:53 +00:00
|
|
|
<div v-if="monitor.type === 'http' || monitor.type === 'keyword' " class="my-3 form-check">
|
2022-04-05 13:27:50 +00:00
|
|
|
<input id="expiry-notification" v-model="monitor.expiryNotification" class="form-check-input" type="checkbox">
|
|
|
|
<label class="form-check-label" for="expiry-notification">
|
2022-04-25 00:25:06 +00:00
|
|
|
{{ $t("Certificate Expiry Notification") }}
|
2022-04-05 13:27:50 +00:00
|
|
|
</label>
|
|
|
|
<div class="form-text">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2021-08-19 18:37:59 +00:00
|
|
|
<div v-if="monitor.type === 'http' || monitor.type === 'keyword' " class="my-3 form-check">
|
|
|
|
<input id="ignore-tls" v-model="monitor.ignoreTls" class="form-check-input" type="checkbox" value="">
|
|
|
|
<label class="form-check-label" for="ignore-tls">
|
2021-08-24 10:26:44 +00:00
|
|
|
{{ $t("ignoreTLSError") }}
|
2021-08-19 18:37:59 +00:00
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
|
2021-10-14 14:32:15 +00:00
|
|
|
<div class="my-3 form-check">
|
2021-08-19 18:37:59 +00:00
|
|
|
<input id="upside-down" v-model="monitor.upsideDown" class="form-check-input" type="checkbox">
|
|
|
|
<label class="form-check-label" for="upside-down">
|
2021-08-24 10:26:44 +00:00
|
|
|
{{ $t("Upside Down Mode") }}
|
2021-08-19 18:37:59 +00:00
|
|
|
</label>
|
|
|
|
<div class="form-text">
|
2021-08-24 10:26:44 +00:00
|
|
|
{{ $t("upsideDownModeDescription") }}
|
2021-08-19 18:37:59 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2021-08-28 03:46:26 +00:00
|
|
|
<!-- HTTP / Keyword only -->
|
2022-08-03 05:00:39 +00:00
|
|
|
<template v-if="monitor.type === 'http' || monitor.type === 'keyword' || monitor.type === 'grpc-keyword' ">
|
2021-08-28 03:46:26 +00:00
|
|
|
<div class="my-3">
|
|
|
|
<label for="maxRedirects" class="form-label">{{ $t("Max. Redirects") }}</label>
|
|
|
|
<input id="maxRedirects" v-model="monitor.maxredirects" type="number" class="form-control" required min="0" step="1">
|
|
|
|
<div class="form-text">
|
|
|
|
{{ $t("maxRedirectDescription") }}
|
|
|
|
</div>
|
2021-08-19 18:37:59 +00:00
|
|
|
</div>
|
|
|
|
|
2021-08-28 03:46:26 +00:00
|
|
|
<div class="my-3">
|
|
|
|
<label for="acceptedStatusCodes" class="form-label">{{ $t("Accepted Status Codes") }}</label>
|
|
|
|
|
|
|
|
<VueMultiselect
|
|
|
|
id="acceptedStatusCodes"
|
|
|
|
v-model="monitor.accepted_statuscodes"
|
|
|
|
:options="acceptedStatusCodeOptions"
|
|
|
|
:multiple="true"
|
|
|
|
:close-on-select="false"
|
|
|
|
:clear-on-select="false"
|
|
|
|
:preserve-search="true"
|
2021-11-12 14:30:31 +00:00
|
|
|
:placeholder="$t('Pick Accepted Status Codes...')"
|
2021-08-28 03:46:26 +00:00
|
|
|
:preselect-first="false"
|
|
|
|
:max-height="600"
|
|
|
|
:taggable="true"
|
|
|
|
></VueMultiselect>
|
|
|
|
|
|
|
|
<div class="form-text">
|
|
|
|
{{ $t("acceptedStatusCodesDescription") }}
|
|
|
|
</div>
|
2021-08-19 18:37:59 +00:00
|
|
|
</div>
|
2021-08-28 03:46:26 +00:00
|
|
|
</template>
|
2021-08-19 18:37:59 +00:00
|
|
|
|
2021-08-26 10:55:19 +00:00
|
|
|
<div class="my-3">
|
|
|
|
<tags-manager ref="tagsManager" :pre-selected-tags="monitor.tags"></tags-manager>
|
|
|
|
</div>
|
|
|
|
|
2021-08-19 18:37:59 +00:00
|
|
|
<div class="mt-5 mb-1">
|
2021-11-04 15:19:31 +00:00
|
|
|
<button id="monitor-submit-btn" class="btn btn-primary" type="submit" :disabled="processing">{{ $t("Save") }}</button>
|
2021-08-19 18:37:59 +00:00
|
|
|
</div>
|
2021-07-27 17:47:13 +00:00
|
|
|
</div>
|
2021-07-19 16:23:06 +00:00
|
|
|
|
2021-08-19 18:37:59 +00:00
|
|
|
<div class="col-md-6">
|
|
|
|
<div v-if="$root.isMobile" class="mt-3" />
|
2021-07-29 17:09:14 +00:00
|
|
|
|
2021-10-15 10:36:40 +00:00
|
|
|
<!-- Notifications -->
|
2021-08-24 10:26:44 +00:00
|
|
|
<h2 class="mb-2">{{ $t("Notifications") }}</h2>
|
2021-08-19 18:37:59 +00:00
|
|
|
<p v-if="$root.notificationList.length === 0">
|
2021-08-24 10:26:44 +00:00
|
|
|
{{ $t("Not available, please setup.") }}
|
2021-08-19 18:37:59 +00:00
|
|
|
</p>
|
2021-07-29 17:09:14 +00:00
|
|
|
|
2021-08-19 18:37:59 +00:00
|
|
|
<div v-for="notification in $root.notificationList" :key="notification.id" class="form-check form-switch my-3">
|
|
|
|
<input :id=" 'notification' + notification.id" v-model="monitor.notificationIDList[notification.id]" class="form-check-input" type="checkbox">
|
2021-07-29 17:09:14 +00:00
|
|
|
|
2021-08-19 18:37:59 +00:00
|
|
|
<label class="form-check-label" :for=" 'notification' + notification.id">
|
|
|
|
{{ notification.name }}
|
2021-08-24 10:26:44 +00:00
|
|
|
<a href="#" @click="$refs.notificationDialog.show(notification.id)">{{ $t("Edit") }}</a>
|
2021-08-19 18:37:59 +00:00
|
|
|
</label>
|
2021-09-05 21:23:06 +00:00
|
|
|
|
2021-11-11 09:54:09 +00:00
|
|
|
<span v-if="notification.isDefault == true" class="badge bg-primary ms-2">{{ $t("Default") }}</span>
|
2021-08-19 18:37:59 +00:00
|
|
|
</div>
|
2021-08-05 11:04:38 +00:00
|
|
|
|
2021-08-19 18:37:59 +00:00
|
|
|
<button class="btn btn-primary me-2" type="button" @click="$refs.notificationDialog.show()">
|
2021-08-24 10:26:44 +00:00
|
|
|
{{ $t("Setup Notification") }}
|
2021-08-19 18:37:59 +00:00
|
|
|
</button>
|
2021-10-15 10:36:40 +00:00
|
|
|
|
2021-10-30 17:37:15 +00:00
|
|
|
<!-- Proxies -->
|
2022-04-07 06:37:33 +00:00
|
|
|
<div v-if="monitor.type === 'http' || monitor.type === 'keyword'">
|
|
|
|
<h2 class="mt-5 mb-2">{{ $t("Proxy") }}</h2>
|
|
|
|
<p v-if="$root.proxyList.length === 0">
|
|
|
|
{{ $t("Not available, please setup.") }}
|
|
|
|
</p>
|
|
|
|
|
2022-04-07 07:26:00 +00:00
|
|
|
<div v-if="$root.proxyList.length > 0" class="form-check my-3">
|
2022-04-07 06:37:33 +00:00
|
|
|
<input id="proxy-disable" v-model="monitor.proxyId" :value="null" name="proxy" class="form-check-input" type="radio">
|
|
|
|
<label class="form-check-label" for="proxy-disable">{{ $t("No Proxy") }}</label>
|
|
|
|
</div>
|
2021-10-30 17:37:15 +00:00
|
|
|
|
2022-04-07 07:26:00 +00:00
|
|
|
<div v-for="proxy in $root.proxyList" :key="proxy.id" class="form-check my-3">
|
2022-04-07 06:37:33 +00:00
|
|
|
<input :id="`proxy-${proxy.id}`" v-model="monitor.proxyId" :value="proxy.id" name="proxy" class="form-check-input" type="radio">
|
2021-10-30 17:37:15 +00:00
|
|
|
|
2022-04-07 06:37:33 +00:00
|
|
|
<label class="form-check-label" :for="`proxy-${proxy.id}`">
|
|
|
|
{{ proxy.host }}:{{ proxy.port }} ({{ proxy.protocol }})
|
|
|
|
<a href="#" @click="$refs.proxyDialog.show(proxy.id)">{{ $t("Edit") }}</a>
|
|
|
|
</label>
|
2021-10-30 17:37:15 +00:00
|
|
|
|
2022-04-07 06:37:33 +00:00
|
|
|
<span v-if="proxy.default === true" class="badge bg-primary ms-2">{{ $t("default") }}</span>
|
|
|
|
</div>
|
2021-10-30 17:37:15 +00:00
|
|
|
|
2022-04-07 06:37:33 +00:00
|
|
|
<button class="btn btn-primary me-2" type="button" @click="$refs.proxyDialog.show()">
|
|
|
|
{{ $t("Setup Proxy") }}
|
|
|
|
</button>
|
2021-10-30 17:37:15 +00:00
|
|
|
</div>
|
|
|
|
|
2021-10-15 10:36:40 +00:00
|
|
|
<!-- HTTP Options -->
|
|
|
|
<template v-if="monitor.type === 'http' || monitor.type === 'keyword' ">
|
|
|
|
<h2 class="mt-5 mb-2">{{ $t("HTTP Options") }}</h2>
|
|
|
|
|
|
|
|
<!-- Method -->
|
|
|
|
<div class="my-3">
|
|
|
|
<label for="method" class="form-label">{{ $t("Method") }}</label>
|
|
|
|
<select id="method" v-model="monitor.method" class="form-select">
|
|
|
|
<option value="GET">
|
|
|
|
GET
|
|
|
|
</option>
|
|
|
|
<option value="POST">
|
|
|
|
POST
|
|
|
|
</option>
|
|
|
|
<option value="PUT">
|
|
|
|
PUT
|
|
|
|
</option>
|
|
|
|
<option value="PATCH">
|
|
|
|
PATCH
|
|
|
|
</option>
|
|
|
|
<option value="DELETE">
|
|
|
|
DELETE
|
|
|
|
</option>
|
|
|
|
<option value="HEAD">
|
|
|
|
HEAD
|
|
|
|
</option>
|
|
|
|
<option value="OPTIONS">
|
|
|
|
OPTIONS
|
|
|
|
</option>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- Body -->
|
|
|
|
<div class="my-3">
|
|
|
|
<label for="body" class="form-label">{{ $t("Body") }}</label>
|
2021-11-29 11:40:53 +00:00
|
|
|
<textarea id="body" v-model="monitor.body" class="form-control" :placeholder="bodyPlaceholder"></textarea>
|
2021-10-15 10:36:40 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- Headers -->
|
|
|
|
<div class="my-3">
|
|
|
|
<label for="headers" class="form-label">{{ $t("Headers") }}</label>
|
2021-11-29 11:40:53 +00:00
|
|
|
<textarea id="headers" v-model="monitor.headers" class="form-control" :placeholder="headersPlaceholder"></textarea>
|
2021-10-15 10:36:40 +00:00
|
|
|
</div>
|
2021-11-02 11:30:44 +00:00
|
|
|
|
2022-05-13 12:22:52 +00:00
|
|
|
<!-- HTTP Auth -->
|
2022-06-15 14:00:47 +00:00
|
|
|
<h4 class="mt-5 mb-2">{{ $t("Authentication") }}</h4>
|
2021-11-23 11:20:55 +00:00
|
|
|
|
2022-05-13 12:22:52 +00:00
|
|
|
<!-- Method -->
|
2021-11-02 11:30:44 +00:00
|
|
|
<div class="my-3">
|
2022-05-13 12:22:52 +00:00
|
|
|
<label for="method" class="form-label">{{ $t("Method") }}</label>
|
|
|
|
<select id="method" v-model="monitor.authMethod" class="form-select">
|
2022-06-14 02:49:30 +00:00
|
|
|
<option :value="null">
|
2022-06-15 14:00:47 +00:00
|
|
|
{{ $t("None") }}
|
2022-05-13 17:58:23 +00:00
|
|
|
</option>
|
|
|
|
<option value="basic">
|
2022-06-15 14:00:47 +00:00
|
|
|
{{ $t("HTTP Basic Auth") }}
|
2022-05-13 12:22:52 +00:00
|
|
|
</option>
|
2022-05-13 17:58:23 +00:00
|
|
|
<option value="ntlm">
|
|
|
|
NTLM
|
2022-05-13 12:22:52 +00:00
|
|
|
</option>
|
|
|
|
</select>
|
2021-11-23 11:20:55 +00:00
|
|
|
</div>
|
2022-06-14 02:49:30 +00:00
|
|
|
<template v-if="monitor.authMethod && monitor.authMethod !== null ">
|
2022-05-13 17:58:23 +00:00
|
|
|
<div class="my-3">
|
|
|
|
<label for="basicauth" class="form-label">{{ $t("Username") }}</label>
|
|
|
|
<input id="basicauth-user" v-model="monitor.basic_auth_user" type="text" class="form-control" :placeholder="$t('Username')">
|
|
|
|
</div>
|
2021-11-23 11:20:55 +00:00
|
|
|
|
2022-05-13 17:58:23 +00:00
|
|
|
<div class="my-3">
|
|
|
|
<label for="basicauth" class="form-label">{{ $t("Password") }}</label>
|
|
|
|
<input id="basicauth-pass" v-model="monitor.basic_auth_pass" type="password" autocomplete="new-password" class="form-control" :placeholder="$t('Password')">
|
|
|
|
</div>
|
|
|
|
<template v-if="monitor.authMethod === 'ntlm' ">
|
|
|
|
<div class="my-3">
|
|
|
|
<label for="basicauth" class="form-label">{{ $t("Domain") }}</label>
|
|
|
|
<input id="basicauth-domain" v-model="monitor.authDomain" type="text" class="form-control" :placeholder="$t('Domain')">
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="my-3">
|
|
|
|
<label for="basicauth" class="form-label">{{ $t("Workstation") }}</label>
|
2022-06-14 12:45:04 +00:00
|
|
|
<input id="basicauth-workstation" v-model="monitor.authWorkstation" type="text" class="form-control" :placeholder="$t('Workstation')">
|
2022-05-13 17:58:23 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</template>
|
2021-10-15 10:36:40 +00:00
|
|
|
</template>
|
2022-08-03 05:00:39 +00:00
|
|
|
|
|
|
|
<!-- gRPC Options -->
|
|
|
|
<template v-if="monitor.type === 'grpc-keyword' ">
|
|
|
|
<!-- Proto service enable TLS -->
|
2022-08-03 06:39:31 +00:00
|
|
|
<h2 class="mt-5 mb-2">{{ $t("GRPC Options") }}</h2>
|
2022-08-03 05:00:39 +00:00
|
|
|
<div class="my-3 form-check">
|
2022-08-03 06:39:31 +00:00
|
|
|
<input id="grpc-enable-tls" v-model="monitor.grpcEnableTls" class="form-check-input" type="checkbox" value="">
|
|
|
|
<label class="form-check-label" for="grpc-enable-tls">
|
2022-08-03 05:00:39 +00:00
|
|
|
{{ $t("Enable TLS") }}
|
|
|
|
</label>
|
|
|
|
<div class="form-text">
|
|
|
|
{{ $t("enableGRPCTls") }}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<!-- Proto service name data -->
|
|
|
|
<div class="my-3">
|
|
|
|
<label for="protobuf" class="form-label">{{ $t("Proto Service Name") }}</label>
|
|
|
|
<input id="name" v-model="monitor.grpcServiceName" type="text" class="form-control" :placeholder="protoServicePlaceholder" required>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- Proto method data -->
|
|
|
|
<div class="my-3">
|
|
|
|
<label for="protobuf" class="form-label">{{ $t("Proto Method") }}</label>
|
|
|
|
<input id="name" v-model="monitor.grpcMethod" type="text" class="form-control" :placeholder="protoMethodPlaceholder" required>
|
|
|
|
<div class="form-text">
|
|
|
|
{{ $t("grpcMethodDescription") }}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- Proto data -->
|
|
|
|
<div class="my-3">
|
|
|
|
<label for="protobuf" class="form-label">{{ $t("Proto Content") }}</label>
|
|
|
|
<textarea id="protobuf" v-model="monitor.grpcProtobuf" class="form-control" :placeholder="protoBufDataPlaceholder"></textarea>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- Body -->
|
|
|
|
<div class="my-3">
|
|
|
|
<label for="body" class="form-label">{{ $t("Body") }}</label>
|
|
|
|
<textarea id="body" v-model="monitor.grpcBody" class="form-control" :placeholder="bodyPlaceholder"></textarea>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- Metadata: temporary disable waiting for next PR allow to send gRPC with metadata -->
|
|
|
|
<template v-if="false">
|
|
|
|
<div class="my-3">
|
|
|
|
<label for="metadata" class="form-label">{{ $t("Metadata") }}</label>
|
|
|
|
<textarea id="metadata" v-model="monitor.grpcMetadata" class="form-control" :placeholder="headersPlaceholder"></textarea>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</template>
|
2021-08-05 11:04:38 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-07-27 17:47:13 +00:00
|
|
|
</div>
|
2021-08-19 18:37:59 +00:00
|
|
|
</form>
|
2021-06-25 13:55:49 +00:00
|
|
|
|
2021-09-09 13:24:29 +00:00
|
|
|
<NotificationDialog ref="notificationDialog" @added="addedNotification" />
|
2022-07-22 15:47:04 +00:00
|
|
|
<DockerHostDialog ref="dockerHostDialog" @added="addedDockerHost" />
|
2021-10-30 17:37:15 +00:00
|
|
|
<ProxyDialog ref="proxyDialog" @added="addedProxy" />
|
2021-06-25 13:55:49 +00:00
|
|
|
</div>
|
2021-08-19 18:37:59 +00:00
|
|
|
</transition>
|
2021-06-25 13:55:49 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2022-04-25 23:26:57 +00:00
|
|
|
import VueMultiselect from "vue-multiselect";
|
|
|
|
import { useToast } from "vue-toastification";
|
|
|
|
import CopyableInput from "../components/CopyableInput.vue";
|
2021-06-29 08:06:20 +00:00
|
|
|
import NotificationDialog from "../components/NotificationDialog.vue";
|
2022-07-22 15:47:04 +00:00
|
|
|
import DockerHostDialog from "../components/DockerHostDialog.vue";
|
2021-10-30 17:37:15 +00:00
|
|
|
import ProxyDialog from "../components/ProxyDialog.vue";
|
2021-08-26 10:55:19 +00:00
|
|
|
import TagsManager from "../components/TagsManager.vue";
|
2022-12-08 15:21:55 +00:00
|
|
|
import { genSecret, isDev, MAX_INTERVAL_SECOND, MIN_INTERVAL_SECOND } from "../util.ts";
|
2021-09-30 16:09:43 +00:00
|
|
|
|
|
|
|
const toast = useToast();
|
2021-06-25 13:55:49 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
2021-10-30 17:37:15 +00:00
|
|
|
ProxyDialog,
|
2021-09-30 16:09:43 +00:00
|
|
|
CopyableInput,
|
2021-07-27 17:47:13 +00:00
|
|
|
NotificationDialog,
|
2022-07-22 15:47:04 +00:00
|
|
|
DockerHostDialog,
|
2021-08-26 10:55:19 +00:00
|
|
|
TagsManager,
|
2021-08-05 13:06:47 +00:00
|
|
|
VueMultiselect,
|
2021-06-25 13:55:49 +00:00
|
|
|
},
|
2021-08-08 13:14:29 +00:00
|
|
|
|
2021-06-25 13:55:49 +00:00
|
|
|
data() {
|
2023-01-05 13:06:13 +00:00
|
|
|
// Source: https://digitalfortress.tech/tips/top-15-commonly-used-regex/
|
|
|
|
const ipRegexPattern = "((^\\s*((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))\\s*$)|(^\\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:)))(%.+)?\\s*$))";
|
|
|
|
const hostnameRegexPattern = "^([a-zA-Z0-9])?(([a-zA-Z0-9_]|[a-zA-Z0-9_][a-zA-Z0-9\\-_]*[a-zA-Z0-9_])\\.)*([A-Za-z0-9_]|[A-Za-z0-9_][A-Za-z0-9\\-_]*[A-Za-z0-9_])$";
|
|
|
|
|
|
|
|
// Modified to accept mqtt, mqtts, ws and wss protocols accepted by mqtt.js (https://github.com/mqttjs/MQTT.js/#connect)
|
2023-01-05 13:23:05 +00:00
|
|
|
const mqttSchemePartialRegexPattern = "((mqtt|ws)s?:\\/\\/)?";
|
2023-01-05 13:06:13 +00:00
|
|
|
const mqttIpRegexPattern = `((^\\s*${mqttSchemePartialRegexPattern}((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))\\s*$)|(^\\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:)))(%.+)?\\s*$))`;
|
|
|
|
const mqttHostNameRegexPattern = `^${mqttSchemePartialRegexPattern}([a-zA-Z0-9])?(([a-zA-Z0-9_]|[a-zA-Z0-9_][a-zA-Z0-9\\-_]*[a-zA-Z0-9_])\\.)*([A-Za-z0-9_]|[A-Za-z0-9_][A-Za-z0-9\\-_]*[A-Za-z0-9_])$`;
|
|
|
|
|
2021-06-25 13:55:49 +00:00
|
|
|
return {
|
2022-12-08 15:21:55 +00:00
|
|
|
minInterval: MIN_INTERVAL_SECOND,
|
|
|
|
maxInterval: MAX_INTERVAL_SECOND,
|
2021-06-25 13:55:49 +00:00
|
|
|
processing: false,
|
2021-07-09 09:55:48 +00:00
|
|
|
monitor: {
|
|
|
|
notificationIDList: {},
|
2021-08-28 03:46:26 +00:00
|
|
|
// Do not add default value here, please check init() method
|
2021-07-09 09:55:48 +00:00
|
|
|
},
|
2021-08-08 13:14:29 +00:00
|
|
|
acceptedStatusCodeOptions: [],
|
2021-08-22 22:05:48 +00:00
|
|
|
dnsresolvetypeOptions: [],
|
2023-01-05 13:06:13 +00:00
|
|
|
ipOrHostnameRegexPattern: `${ipRegexPattern}|${hostnameRegexPattern}`,
|
|
|
|
mqttIpOrHostnameRegexPattern: `${mqttIpRegexPattern}|${mqttHostNameRegexPattern}`
|
2021-09-30 16:09:43 +00:00
|
|
|
};
|
2021-06-25 13:55:49 +00:00
|
|
|
},
|
2021-08-08 13:14:29 +00:00
|
|
|
|
2021-06-25 13:55:49 +00:00
|
|
|
computed: {
|
2021-08-25 17:50:27 +00:00
|
|
|
|
|
|
|
ipRegex() {
|
|
|
|
|
|
|
|
// Allow to test with simple dns server with port (127.0.0.1:5300)
|
|
|
|
if (! isDev) {
|
|
|
|
return this.ipRegexPattern;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
},
|
|
|
|
|
2021-06-25 13:55:49 +00:00
|
|
|
pageName() {
|
2021-08-24 10:26:44 +00:00
|
|
|
return this.$t((this.isAdd) ? "Add New Monitor" : "Edit");
|
2021-06-25 13:55:49 +00:00
|
|
|
},
|
2021-09-30 16:09:43 +00:00
|
|
|
|
2021-06-25 13:55:49 +00:00
|
|
|
isAdd() {
|
|
|
|
return this.$route.path === "/add";
|
2021-06-27 08:10:55 +00:00
|
|
|
},
|
2021-09-30 16:09:43 +00:00
|
|
|
|
2021-06-27 08:10:55 +00:00
|
|
|
isEdit() {
|
|
|
|
return this.$route.path.startsWith("/edit");
|
2021-07-27 17:47:13 +00:00
|
|
|
},
|
2021-09-30 16:09:43 +00:00
|
|
|
|
|
|
|
pushURL() {
|
2022-04-30 13:44:03 +00:00
|
|
|
return this.$root.baseURL + "/api/push/" + this.monitor.pushToken + "?status=up&msg=OK&ping=";
|
2021-10-02 14:48:27 +00:00
|
|
|
},
|
|
|
|
|
2022-08-03 05:00:39 +00:00
|
|
|
protoServicePlaceholder() {
|
|
|
|
return this.$t("Example:", [ "Health" ]);
|
|
|
|
},
|
|
|
|
|
|
|
|
protoMethodPlaceholder() {
|
|
|
|
return this.$t("Example:", [ "check" ]);
|
|
|
|
},
|
|
|
|
|
|
|
|
protoBufDataPlaceholder() {
|
|
|
|
return this.$t("Example:", [ `
|
|
|
|
syntax = "proto3";
|
|
|
|
|
|
|
|
package grpc.health.v1;
|
|
|
|
|
|
|
|
service Health {
|
|
|
|
rpc Check(HealthCheckRequest) returns (HealthCheckResponse);
|
|
|
|
rpc Watch(HealthCheckRequest) returns (stream HealthCheckResponse);
|
|
|
|
}
|
|
|
|
|
|
|
|
message HealthCheckRequest {
|
|
|
|
string service = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
message HealthCheckResponse {
|
|
|
|
enum ServingStatus {
|
|
|
|
UNKNOWN = 0;
|
|
|
|
SERVING = 1;
|
|
|
|
NOT_SERVING = 2;
|
|
|
|
SERVICE_UNKNOWN = 3; // Used only by the Watch method.
|
|
|
|
}
|
|
|
|
ServingStatus status = 1;
|
|
|
|
}
|
|
|
|
` ]);
|
|
|
|
},
|
2021-11-29 11:40:53 +00:00
|
|
|
bodyPlaceholder() {
|
2022-04-17 07:27:35 +00:00
|
|
|
return this.$t("Example:", [ `
|
2021-11-29 11:40:53 +00:00
|
|
|
{
|
|
|
|
"key": "value"
|
2022-04-17 07:27:35 +00:00
|
|
|
}` ]);
|
2021-11-29 11:40:53 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
headersPlaceholder() {
|
2022-04-17 07:27:35 +00:00
|
|
|
return this.$t("Example:", [ `
|
2021-11-29 11:40:53 +00:00
|
|
|
{
|
|
|
|
"HeaderName": "HeaderValue"
|
2022-04-17 07:27:35 +00:00
|
|
|
}` ]);
|
2021-11-29 11:40:53 +00:00
|
|
|
}
|
|
|
|
|
2021-07-27 17:47:13 +00:00
|
|
|
},
|
|
|
|
watch: {
|
2021-10-30 17:37:15 +00:00
|
|
|
"$root.proxyList"() {
|
|
|
|
if (this.isAdd) {
|
|
|
|
if (this.$root.proxyList && !this.monitor.proxyId) {
|
|
|
|
const proxy = this.$root.proxyList.find(proxy => proxy.default);
|
|
|
|
|
|
|
|
if (proxy) {
|
|
|
|
this.monitor.proxyId = proxy.id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2021-09-30 16:09:43 +00:00
|
|
|
|
2021-08-19 18:37:59 +00:00
|
|
|
"$route.fullPath"() {
|
2021-07-27 17:47:13 +00:00
|
|
|
this.init();
|
|
|
|
},
|
2021-09-30 16:09:43 +00:00
|
|
|
|
2021-09-14 07:48:25 +00:00
|
|
|
"monitor.interval"(value, oldValue) {
|
2021-10-02 14:48:27 +00:00
|
|
|
// Link interval and retryInterval if they are the same value.
|
2021-09-14 07:48:25 +00:00
|
|
|
if (this.monitor.retryInterval === oldValue) {
|
|
|
|
this.monitor.retryInterval = value;
|
|
|
|
}
|
2021-09-30 16:09:43 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
"monitor.type"() {
|
|
|
|
if (this.monitor.type === "push") {
|
|
|
|
if (! this.monitor.pushToken) {
|
|
|
|
this.monitor.pushToken = genSecret(10);
|
|
|
|
}
|
|
|
|
}
|
2022-04-13 20:02:19 +00:00
|
|
|
|
|
|
|
// Set default port for DNS if not already defined
|
2022-10-12 16:32:05 +00:00
|
|
|
if (! this.monitor.port || this.monitor.port === "53" || this.monitor.port === "1812") {
|
2022-04-13 20:02:19 +00:00
|
|
|
if (this.monitor.type === "dns") {
|
|
|
|
this.monitor.port = "53";
|
2022-10-12 16:32:05 +00:00
|
|
|
} else if (this.monitor.type === "radius") {
|
|
|
|
this.monitor.port = "1812";
|
2022-04-13 20:02:19 +00:00
|
|
|
} else {
|
2022-06-21 14:33:09 +00:00
|
|
|
this.monitor.port = undefined;
|
2022-04-13 20:02:19 +00:00
|
|
|
}
|
|
|
|
}
|
2021-09-14 07:48:25 +00:00
|
|
|
}
|
2021-09-30 16:09:43 +00:00
|
|
|
|
2021-07-27 17:47:13 +00:00
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.init();
|
2021-08-08 13:14:29 +00:00
|
|
|
|
|
|
|
let acceptedStatusCodeOptions = [
|
|
|
|
"100-199",
|
|
|
|
"200-299",
|
|
|
|
"300-399",
|
|
|
|
"400-499",
|
|
|
|
"500-599",
|
|
|
|
];
|
|
|
|
|
2021-08-22 22:05:48 +00:00
|
|
|
let dnsresolvetypeOptions = [
|
|
|
|
"A",
|
|
|
|
"AAAA",
|
|
|
|
"CAA",
|
|
|
|
"CNAME",
|
|
|
|
"MX",
|
|
|
|
"NS",
|
|
|
|
"PTR",
|
|
|
|
"SOA",
|
|
|
|
"SRV",
|
|
|
|
"TXT",
|
|
|
|
];
|
|
|
|
|
2021-08-08 13:14:29 +00:00
|
|
|
for (let i = 100; i <= 999; i++) {
|
|
|
|
acceptedStatusCodeOptions.push(i.toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
this.acceptedStatusCodeOptions = acceptedStatusCodeOptions;
|
2021-08-22 22:05:48 +00:00
|
|
|
this.dnsresolvetypeOptions = dnsresolvetypeOptions;
|
2021-06-25 13:55:49 +00:00
|
|
|
},
|
|
|
|
methods: {
|
2022-06-02 12:46:44 +00:00
|
|
|
/** Initialize the edit monitor form */
|
2021-06-27 08:10:55 +00:00
|
|
|
init() {
|
|
|
|
if (this.isAdd) {
|
2021-09-09 13:24:29 +00:00
|
|
|
|
2021-06-27 08:10:55 +00:00
|
|
|
this.monitor = {
|
|
|
|
type: "http",
|
|
|
|
name: "",
|
|
|
|
url: "https://",
|
2021-10-02 14:48:27 +00:00
|
|
|
method: "GET",
|
2021-06-27 08:10:55 +00:00
|
|
|
interval: 60,
|
2021-09-14 07:48:25 +00:00
|
|
|
retryInterval: this.interval,
|
2022-01-23 16:48:09 +00:00
|
|
|
resendInterval: 0,
|
2021-07-22 09:34:41 +00:00
|
|
|
maxretries: 0,
|
2021-07-09 09:55:48 +00:00
|
|
|
notificationIDList: {},
|
2021-07-30 11:18:26 +00:00
|
|
|
ignoreTls: false,
|
2021-07-29 17:09:14 +00:00
|
|
|
upsideDown: false,
|
2022-04-05 13:27:50 +00:00
|
|
|
expiryNotification: false,
|
2021-08-05 11:04:38 +00:00
|
|
|
maxredirects: 10,
|
2022-04-17 07:27:35 +00:00
|
|
|
accepted_statuscodes: [ "200-299" ],
|
2021-08-28 03:46:26 +00:00
|
|
|
dns_resolve_type: "A",
|
2021-08-22 22:05:48 +00:00
|
|
|
dns_resolve_server: "1.1.1.1",
|
2022-01-13 16:17:07 +00:00
|
|
|
docker_container: "",
|
2022-07-22 15:47:04 +00:00
|
|
|
docker_host: null,
|
2021-10-30 17:37:15 +00:00
|
|
|
proxyId: null,
|
2021-12-18 21:35:18 +00:00
|
|
|
mqttUsername: "",
|
|
|
|
mqttPassword: "",
|
|
|
|
mqttTopic: "",
|
|
|
|
mqttSuccessMessage: "",
|
2022-06-14 02:49:30 +00:00
|
|
|
authMethod: null,
|
2021-09-30 16:09:43 +00:00
|
|
|
};
|
2021-09-05 21:23:06 +00:00
|
|
|
|
2021-10-30 17:37:15 +00:00
|
|
|
if (this.$root.proxyList && !this.monitor.proxyId) {
|
|
|
|
const proxy = this.$root.proxyList.find(proxy => proxy.default);
|
|
|
|
|
|
|
|
if (proxy) {
|
|
|
|
this.monitor.proxyId = proxy.id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-05 21:23:06 +00:00
|
|
|
for (let i = 0; i < this.$root.notificationList.length; i++) {
|
2022-04-25 23:26:57 +00:00
|
|
|
if (this.$root.notificationList[i].isDefault === true) {
|
2021-09-05 21:23:06 +00:00
|
|
|
this.monitor.notificationIDList[this.$root.notificationList[i].id] = true;
|
|
|
|
}
|
|
|
|
}
|
2021-06-27 08:10:55 +00:00
|
|
|
} else if (this.isEdit) {
|
|
|
|
this.$root.getSocket().emit("getMonitor", this.$route.params.id, (res) => {
|
|
|
|
if (res.ok) {
|
|
|
|
this.monitor = res.monitor;
|
2021-09-20 10:23:53 +00:00
|
|
|
|
|
|
|
// Handling for monitors that are created before 1.7.0
|
|
|
|
if (this.monitor.retryInterval === 0) {
|
|
|
|
this.monitor.retryInterval = this.monitor.interval;
|
|
|
|
}
|
2021-06-27 08:10:55 +00:00
|
|
|
} else {
|
2021-09-30 16:09:43 +00:00
|
|
|
toast.error(res.msg);
|
2021-06-27 08:10:55 +00:00
|
|
|
}
|
2021-09-30 16:09:43 +00:00
|
|
|
});
|
2021-06-27 08:10:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
2022-06-02 12:46:44 +00:00
|
|
|
/**
|
|
|
|
* Validate form input
|
|
|
|
* @returns {boolean} Is the form input valid?
|
|
|
|
*/
|
2021-10-02 14:48:27 +00:00
|
|
|
isInputValid() {
|
|
|
|
if (this.monitor.body) {
|
|
|
|
try {
|
|
|
|
JSON.parse(this.monitor.body);
|
|
|
|
} catch (err) {
|
2021-10-05 07:20:24 +00:00
|
|
|
toast.error(this.$t("BodyInvalidFormat") + err.message);
|
2021-10-02 14:48:27 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (this.monitor.headers) {
|
2021-10-09 10:42:32 +00:00
|
|
|
try {
|
|
|
|
JSON.parse(this.monitor.headers);
|
|
|
|
} catch (err) {
|
|
|
|
toast.error(this.$t("HeadersInvalidFormat") + err.message);
|
2021-10-02 14:48:27 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
|
2022-06-02 12:46:44 +00:00
|
|
|
/**
|
|
|
|
* Submit the form data for processing
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2021-08-26 10:55:19 +00:00
|
|
|
async submit() {
|
2021-06-25 13:55:49 +00:00
|
|
|
this.processing = true;
|
|
|
|
|
2021-10-02 14:48:27 +00:00
|
|
|
if (!this.isInputValid()) {
|
|
|
|
this.processing = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-10-16 01:12:09 +00:00
|
|
|
// Beautify the JSON format
|
2021-10-15 10:57:27 +00:00
|
|
|
if (this.monitor.body) {
|
|
|
|
this.monitor.body = JSON.stringify(JSON.parse(this.monitor.body), null, 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.monitor.headers) {
|
|
|
|
this.monitor.headers = JSON.stringify(JSON.parse(this.monitor.headers), null, 4);
|
|
|
|
}
|
|
|
|
|
2021-06-25 13:55:49 +00:00
|
|
|
if (this.isAdd) {
|
2021-08-26 10:55:19 +00:00
|
|
|
this.$root.add(this.monitor, async (res) => {
|
2021-06-25 13:55:49 +00:00
|
|
|
|
|
|
|
if (res.ok) {
|
2021-08-26 10:55:19 +00:00
|
|
|
await this.$refs.tagsManager.submit(res.monitorID);
|
|
|
|
|
2021-06-25 13:55:49 +00:00
|
|
|
toast.success(res.msg);
|
2021-08-26 10:55:19 +00:00
|
|
|
this.processing = false;
|
|
|
|
this.$root.getMonitorList();
|
2021-09-30 16:09:43 +00:00
|
|
|
this.$router.push("/dashboard/" + res.monitorID);
|
2021-06-25 13:55:49 +00:00
|
|
|
} else {
|
|
|
|
toast.error(res.msg);
|
2021-08-26 10:55:19 +00:00
|
|
|
this.processing = false;
|
2021-06-25 13:55:49 +00:00
|
|
|
}
|
|
|
|
|
2021-09-30 16:09:43 +00:00
|
|
|
});
|
2021-06-25 13:55:49 +00:00
|
|
|
} else {
|
2021-08-26 10:55:19 +00:00
|
|
|
await this.$refs.tagsManager.submit(this.monitor.id);
|
|
|
|
|
2021-06-27 08:10:55 +00:00
|
|
|
this.$root.getSocket().emit("editMonitor", this.monitor, (res) => {
|
|
|
|
this.processing = false;
|
2021-09-10 03:53:11 +00:00
|
|
|
this.$root.toastRes(res);
|
|
|
|
this.init();
|
2021-09-30 16:09:43 +00:00
|
|
|
});
|
2021-06-25 13:55:49 +00:00
|
|
|
}
|
2021-07-27 17:47:13 +00:00
|
|
|
},
|
2021-09-09 13:24:29 +00:00
|
|
|
|
2022-06-02 12:46:44 +00:00
|
|
|
/**
|
|
|
|
* Added a Notification Event
|
|
|
|
* Enable it if the notification is added in EditMonitor.vue
|
|
|
|
* @param {number} id ID of notification to add
|
|
|
|
*/
|
2021-09-09 13:24:29 +00:00
|
|
|
addedNotification(id) {
|
|
|
|
this.monitor.notificationIDList[id] = true;
|
|
|
|
},
|
2021-10-30 17:37:15 +00:00
|
|
|
|
2022-06-02 12:46:44 +00:00
|
|
|
/**
|
|
|
|
* Added a Proxy Event
|
|
|
|
* Enable it if the proxy is added in EditMonitor.vue
|
|
|
|
* @param {number} id ID of proxy to add
|
|
|
|
*/
|
2021-10-30 17:37:15 +00:00
|
|
|
addedProxy(id) {
|
|
|
|
this.monitor.proxyId = id;
|
|
|
|
},
|
2022-07-22 15:47:04 +00:00
|
|
|
|
|
|
|
// Added a Docker Host Event
|
|
|
|
// Enable it if the Docker Host is added in EditMonitor.vue
|
|
|
|
addedDockerHost(id) {
|
|
|
|
this.monitor.docker_host = id;
|
|
|
|
}
|
2021-06-27 08:10:55 +00:00
|
|
|
},
|
2021-09-30 16:09:43 +00:00
|
|
|
};
|
2021-06-25 13:55:49 +00:00
|
|
|
</script>
|
|
|
|
|
2021-10-02 14:48:27 +00:00
|
|
|
<style lang="scss" scoped>
|
2021-06-25 13:55:49 +00:00
|
|
|
.shadow-box {
|
|
|
|
padding: 20px;
|
|
|
|
}
|
2021-10-02 14:48:27 +00:00
|
|
|
|
|
|
|
textarea {
|
|
|
|
min-height: 200px;
|
|
|
|
}
|
2021-06-25 13:55:49 +00:00
|
|
|
</style>
|