Repository: louislam/uptime-kuma
File: src/pages/EditMonitor.vue (Vue)

Code before:
                    // ideally this would require checking if the generated token is already used
                    // it's very unlikely to get a collision though (62^32 ~ 2.27265788 * 10^57 unique tokens)
                    this.monitor.pushToken = genSecret(pushTokenLength);
                }
            }

            // Set default port for DNS if not already defined
            if (! this.monitor.port || this.monitor.port === "53" || this.monitor.port === "1812") {
                if (this.monitor.type === "dns") {
                    this.monitor.port = "53";
                } else if (this.monitor.type === "radius") {
                    this.monitor.port = "1812";
                } else if (this.monitor.type === "snmp") {
                    this.monitor.port = "161";
                } else {
                    this.monitor.port = undefined;
                }
            }

            // Set a default timeout of 1 second for SNMP monitors when querying a single OID.
            // Since we're only querying a single OID, a shorter timeout is sufficient to ensure timely responses
            // without unnecessary delays. This helps keep the monitoring process lightweight and efficient.
            if (this.monitor.type === "snmp") {
                this.monitor.timeout = 1;
            } else {
                this.monitor.timeout = 48; // Default timeout for other monitor types
            }

            // Set default SNMP version
            if (!this.monitor.snmpVersion) {
                this.monitor.snmpVersion = "1";
            }

            // Get the game list from server
            if (this.monitor.type === "gamedig") {
                this.$root.getSocket().emit("getGameList", (res) => {
                    if (res.ok) {
                        this.gameList = res.gameList;
                    } else {
                        this.$root.toastError(res.msg);
                    }
                });
            }

            // Set default database connection string if empty or it is a template from another database monitor type
            for (let monitorType in this.connectionStringTemplates) {
                if (this.monitor.type === monitorType) {
                    let isTemplate = false;
                    for (let key in this.connectionStringTemplates) {
                        if (this.monitor.databaseConnectionString === this.connectionStringTemplates[key]) {
                            isTemplate = true;

Review comment (suggestion):
```suggestion
                this.monitor.timeout = 48;
```

Code after:

        "$route.fullPath"() {
            this.init();
        },

        "monitor.interval"(value, oldValue) {
            // Link interval and retryInterval if they are the same value.
            if (this.monitor.retryInterval === oldValue) {
                this.monitor.retryInterval = value;
            }
        },

        "monitor.timeout"(value, oldValue) {
            // keep timeout within 80% range
            if (value && value !== oldValue) {
                this.monitor.timeout = this.clampTimeout(value);
            }
        },

        "monitor.type"() {
            if (this.monitor.type === "push") {
                if (! this.monitor.pushToken) {
                    // ideally this would require checking if the generated token is already used
                    // it's very unlikely to get a collision though (62^32 ~ 2.27265788 * 10^57 unique tokens)
                    this.monitor.pushToken = genSecret(pushTokenLength);
                }
            }

            // Set default port for DNS if not already defined
            if (! this.monitor.port || this.monitor.port === "53" || this.monitor.port === "1812") {
                if (this.monitor.type === "dns") {
                    this.monitor.port = "53";
                } else if (this.monitor.type === "radius") {
                    this.monitor.port = "1812";
                } else if (this.monitor.type === "snmp") {
                    this.monitor.port = "161";
                } else {
                    this.monitor.port = undefined;
                }
            }

            if (this.monitor.type === "snmp") {
                // snmp is not expected to be executed via the internet => we can choose a lower default timeout
                this.monitor.timeout = 5;
            } else {
                this.monitor.timeout = 48;
            }

            // Set default SNMP version
            if (!this.monitor.snmpVersion) {
                this.monitor.snmpVersion = "2c";