mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-05-20 14:02:34 +02:00
fix suggestion
This commit is contained in:
parent
7b9bad1953
commit
6d7b8c3bb3
4 changed files with 8 additions and 46 deletions
|
@ -1,11 +0,0 @@
|
||||||
exports.up = function (knex) {
|
|
||||||
return knex.schema.alterTable("notification", function (table) {
|
|
||||||
table.boolean("disable_url").defaultTo(false).notNullable().comment("Disable URL in Discord notifications");
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.down = function (knex) {
|
|
||||||
return knex.schema.alterTable("notification", function (table) {
|
|
||||||
table.dropColumn("disable_url");
|
|
||||||
});
|
|
||||||
};
|
|
|
@ -46,10 +46,10 @@ class Discord extends NotificationProvider {
|
||||||
name: "Service Name",
|
name: "Service Name",
|
||||||
value: monitorJSON["name"],
|
value: monitorJSON["name"],
|
||||||
},
|
},
|
||||||
{
|
...(!notification.disableUrl ? [{
|
||||||
name: monitorJSON["type"] === "push" ? "Service Type" : "Service URL",
|
name: monitorJSON["type"] === "push" ? "Service Type" : "Service URL",
|
||||||
value: notification.disableUrl ? "Hidden" : this.extractAddress(monitorJSON),
|
value: this.extractAddress(monitorJSON),
|
||||||
},
|
}] : []),
|
||||||
{
|
{
|
||||||
name: `Time (${heartbeatJSON["timezone"]})`,
|
name: `Time (${heartbeatJSON["timezone"]})`,
|
||||||
value: heartbeatJSON["localDateTime"],
|
value: heartbeatJSON["localDateTime"],
|
||||||
|
@ -83,10 +83,10 @@ class Discord extends NotificationProvider {
|
||||||
name: "Service Name",
|
name: "Service Name",
|
||||||
value: monitorJSON["name"],
|
value: monitorJSON["name"],
|
||||||
},
|
},
|
||||||
{
|
...(!notification.disableUrl ? [{
|
||||||
name: monitorJSON["type"] === "push" ? "Service Type" : "Service URL",
|
name: monitorJSON["type"] === "push" ? "Service Type" : "Service URL",
|
||||||
value: notification.disableUrl ? "Hidden" : this.extractAddress(monitorJSON),
|
value: this.extractAddress(monitorJSON),
|
||||||
},
|
}] : []),
|
||||||
{
|
{
|
||||||
name: `Time (${heartbeatJSON["timezone"]})`,
|
name: `Time (${heartbeatJSON["timezone"]})`,
|
||||||
value: heartbeatJSON["localDateTime"],
|
value: heartbeatJSON["localDateTime"],
|
||||||
|
|
|
@ -313,32 +313,6 @@ let needSetup = false;
|
||||||
const statusPageRouter = require("./routers/status-page-router");
|
const statusPageRouter = require("./routers/status-page-router");
|
||||||
app.use(statusPageRouter);
|
app.use(statusPageRouter);
|
||||||
|
|
||||||
// Update notification
|
|
||||||
app.put("/notification/:id", async (req, res) => {
|
|
||||||
try {
|
|
||||||
await R.exec("UPDATE notification SET disableUrl = ? WHERE id = ?", [
|
|
||||||
req.body.disableUrl || false,
|
|
||||||
req.params.id,
|
|
||||||
]);
|
|
||||||
|
|
||||||
res.status(200).send({ message: "Notification updated successfully" });
|
|
||||||
} catch (error) {
|
|
||||||
res.status(500).send({ error: "Failed to update notification" });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Get notification
|
|
||||||
app.get("/notification/:id", async (req, res) => {
|
|
||||||
try {
|
|
||||||
const notification = await R.findOne("notification", " id = ? ", [ req.params.id ]);
|
|
||||||
res.json({
|
|
||||||
disableUrl: notification.disableUrl,
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
res.status(500).send({ error: "Failed to retrieve notification" });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Universal Route Handler, must be at the end of all express routes.
|
// Universal Route Handler, must be at the end of all express routes.
|
||||||
app.get("*", async (_request, response) => {
|
app.get("*", async (_request, response) => {
|
||||||
if (_request.originalUrl.startsWith("/upload/")) {
|
if (_request.originalUrl.startsWith("/upload/")) {
|
||||||
|
|
|
@ -55,10 +55,9 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="discord-disable-url" class="form-label">{{ $t("Disable URL in Notification") }}</label>
|
|
||||||
<div class="form-check form-switch">
|
<div class="form-check form-switch">
|
||||||
<input id="discord-disable-url" v-model="$parent.notification.disableUrl" class="form-check-input" type="checkbox">
|
<input id="discord-disable-url" v-model="$parent.notification.disableUrl" class="form-check-input" type="checkbox" role="switch">
|
||||||
<label class="form-check-label" for="discord-disable-url">{{ $t("Disable URL") }}</label>
|
<label class="form-check-label" for="discord-disable-url">{{ $t("Disable URL in Notification") }}</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
Loading…
Add table
Reference in a new issue