Skip to content

Commit bd68103

Browse files
authored
fix(edit-monitor): several issues in the edit page (louislam#7011)
1 parent 1de2760 commit bd68103

File tree

6 files changed

+79
-146
lines changed

6 files changed

+79
-146
lines changed

extra/update-language-files/.gitignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

extra/update-language-files/index.js

Lines changed: 0 additions & 105 deletions
This file was deleted.

extra/update-language-files/package.json

Lines changed: 0 additions & 12 deletions
This file was deleted.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
"simple-mongo": "docker run --rm -p 27017:27017 mongo",
5555
"simple-postgres": "docker run --rm -p 5432:5432 -e POSTGRES_PASSWORD=postgres postgres",
5656
"simple-mariadb": "docker run --rm -p 3306:3306 -e MYSQL_ROOT_PASSWORD=mariadb# mariadb",
57-
"update-language-files": "cd extra/update-language-files && node index.js && cross-env-shell eslint ../../src/languages/$npm_config_language.js --fix",
5857
"release-final": "node ./extra/release/final.mjs",
5958
"release-beta": "node ./extra/release/beta.mjs",
6059
"release-nightly": "node ./extra/release/nightly.mjs",

src/lang/en.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
"General Monitor Type": "General Monitor Type",
4040
"Passive Monitor Type": "Passive Monitor Type",
4141
"Specific Monitor Type": "Specific Monitor Type",
42+
"monitorTypeGameServer": "Game Server",
43+
"monitorTypeDatabase": "Database Monitor Type",
44+
"monitorTypeSpecial": "Special",
4245
"markdownSupported": "Markdown syntax supported. If using HTML, avoid leading spaces to prevent formatting issues.",
4346
"pauseDashboardHome": "Pause",
4447
"Pause": "Pause",

src/pages/EditMonitor.vue

Lines changed: 76 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,12 @@
3535
class="form-select"
3636
data-testid="monitor-type-select"
3737
>
38+
<!-- Unsorted, since HTTP is commonly used -->
3839
<optgroup :label="$t('General Monitor Type')">
39-
<option value="group">
40-
{{ $t("Group") }}
41-
</option>
4240
<option value="http">HTTP(s)</option>
41+
<option value="keyword">HTTP(s) - {{ $t("Keyword") }}</option>
4342
<option value="port">TCP Port</option>
4443
<option value="ping">Ping</option>
45-
<option value="smtp">SMTP</option>
46-
<option value="snmp">SNMP</option>
47-
<option value="keyword">HTTP(s) - {{ $t("Keyword") }}</option>
48-
<option value="json-query">HTTP(s) - {{ $t("Json Query") }}</option>
49-
<option value="grpc-keyword">gRPC(s) - {{ $t("Keyword") }}</option>
5044
<option value="dns">DNS</option>
5145
<option value="docker">
5246
{{ $t("Docker Container") }}
@@ -63,7 +57,12 @@
6357
<option value="real-browser">
6458
HTTP(s) - Browser Engine (Chrome/Chromium) (Beta)
6559
</option>
66-
<option value="websocket-upgrade">Websocket Upgrade</option>
60+
</optgroup>
61+
62+
<optgroup :label="$t('monitorTypeSpecial')">
63+
<option value="group">
64+
{{ $t("Group") }}
65+
</option>
6766
</optgroup>
6867

6968
<optgroup :label="$t('Passive Monitor Type')">
@@ -73,29 +72,43 @@
7372
</option>
7473
</optgroup>
7574

75+
<!-- Should sort from A to Z in this category -->
7676
<optgroup :label="$t('Specific Monitor Type')">
7777
<option value="globalping">
7878
{{ $t("Globalping - Access global monitoring probes") }}
7979
</option>
80-
<option value="steam">
81-
{{ $t("Steam Game Server") }}
82-
</option>
83-
<option value="gamedig">GameDig</option>
80+
<option value="grpc-keyword">gRPC(s) - {{ $t("Keyword") }}</option>
81+
<option value="json-query">HTTP(s) - {{ $t("Json Query") }}</option>
82+
<option value="kafka-producer">Kafka Producer</option>
8483
<option value="mqtt">MQTT</option>
8584
<option value="rabbitmq">RabbitMQ</option>
86-
<option value="kafka-producer">Kafka Producer</option>
87-
<option value="sqlserver">Microsoft SQL Server</option>
88-
<option value="postgres">PostgreSQL</option>
89-
<option value="mysql">MySQL/MariaDB</option>
90-
<option value="mongodb">MongoDB</option>
91-
<option value="radius">Radius</option>
92-
<option value="redis">Redis</option>
9385
<option v-if="!$root.info.isContainer" value="sip-options">
9486
SIP Options Ping
9587
</option>
88+
<option value="smtp">SMTP</option>
89+
<option value="snmp">SNMP</option>
9690
<option v-if="!$root.info.isContainer" value="tailscale-ping">
9791
Tailscale Ping
9892
</option>
93+
<option value="websocket-upgrade">Websocket Upgrade</option>
94+
</optgroup>
95+
96+
<!-- Should sort from A to Z in this category -->
97+
<optgroup :label="$t('monitorTypeDatabase')">
98+
<option value="sqlserver">Microsoft SQL Server</option>
99+
<option value="mongodb">MongoDB</option>
100+
<option value="mysql">MySQL/MariaDB</option>
101+
<option value="postgres">PostgreSQL</option>
102+
<option value="radius">Radius</option>
103+
<option value="redis">Redis</option>
104+
</optgroup>
105+
106+
<!-- Should sort from A to Z in this category -->
107+
<optgroup :label="$t('monitorTypeGameServer')">
108+
<option value="gamedig">GameDig</option>
109+
<option value="steam">
110+
{{ $t("Steam Game Server") }}
111+
</option>
99112
</optgroup>
100113
</select>
101114
<i18n-t
@@ -2820,11 +2833,22 @@ const toast = useToast();
28202833
28212834
const pushTokenLength = 32;
28222835
2836+
const defaultValueList = {
2837+
http: {
2838+
url: "https://",
2839+
accepted_statuscodes: ["200-299"],
2840+
},
2841+
"websocket-upgrade": {
2842+
url: "wss://",
2843+
accepted_statuscodes: ["1000"],
2844+
},
2845+
};
2846+
28232847
const monitorDefaults = {
28242848
type: "http",
28252849
name: "",
28262850
parent: null,
2827-
url: "https://",
2851+
url: defaultValueList.http.url,
28282852
wsSubprotocol: "",
28292853
method: "GET",
28302854
protocol: null,
@@ -2842,7 +2866,7 @@ const monitorDefaults = {
28422866
expiryNotification: false,
28432867
domainExpiryNotification: false,
28442868
maxredirects: 10,
2845-
accepted_statuscodes: ["200-299"],
2869+
accepted_statuscodes: defaultValueList.http.accepted_statuscodes,
28462870
saveResponse: false,
28472871
saveErrorResponse: true,
28482872
responseMaxLength: 1024,
@@ -3298,9 +3322,36 @@ message HealthCheckResponse {
32983322
this.monitor.dns_resolve_server = "1.1.1.1";
32993323
}
33003324
3301-
if (oldType && this.monitor.type === "websocket-upgrade") {
3302-
this.monitor.url = "wss://";
3303-
this.monitor.accepted_statuscodes = ["1000"];
3325+
// Change to websocket-upgrade (override http defaults)
3326+
if (newType === "websocket-upgrade") {
3327+
if (!this.monitor.url || this.monitor.url === defaultValueList.http.url) {
3328+
this.monitor.url = defaultValueList["websocket-upgrade"].url;
3329+
}
3330+
3331+
if (
3332+
!this.monitor.accepted_statuscodes ||
3333+
(this.monitor.accepted_statuscodes.length === 1 &&
3334+
this.monitor.accepted_statuscodes[0] === defaultValueList.http.accepted_statuscodes)
3335+
) {
3336+
this.monitor.accepted_statuscodes = defaultValueList["websocket-upgrade"].accepted_statuscodes;
3337+
}
3338+
}
3339+
3340+
// Change to http (override websocket-upgrade defaults)
3341+
// Because user may see wss:// and default to http code 1000, which is strange for http monitor.
3342+
if (["http", "keyword", "real-browser"].includes(newType)) {
3343+
if (!this.monitor.url || this.monitor.url === defaultValueList["websocket-upgrade"].url) {
3344+
this.monitor.url = defaultValueList.http.url;
3345+
}
3346+
3347+
if (
3348+
!this.monitor.accepted_statuscodes ||
3349+
(this.monitor.accepted_statuscodes.length === 1 &&
3350+
this.monitor.accepted_statuscodes[0] ===
3351+
defaultValueList["websocket-upgrade"].accepted_statuscodes)
3352+
) {
3353+
this.monitor.accepted_statuscodes = defaultValueList.http.accepted_statuscodes;
3354+
}
33043355
}
33053356
33063357
if (this.monitor.type === "push") {

0 commit comments

Comments
 (0)