Compare commits

...

13 commits

Author SHA1 Message Date
broodroosterdev e8f6a99033
Merge 2192bfa42b into cd5644d6d2 2024-07-31 15:58:28 +00:00
taisei cd5644d6d2
Remove markdown with meta tags (#4968)
Some checks failed
Auto Test / check-linters (push) Has been cancelled
CodeQL / Analyze (go) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
Merge Conflict Labeler / Labeling (push) Has been cancelled
json-yaml-validate / json-yaml-validate (push) Has been cancelled
Auto Test / auto-test (18, ARM64) (push) Has been cancelled
Auto Test / auto-test (18, macos-latest) (push) Has been cancelled
Auto Test / auto-test (18, ubuntu-latest) (push) Has been cancelled
Auto Test / auto-test (18, windows-latest) (push) Has been cancelled
Auto Test / auto-test (20.5, ARM64) (push) Has been cancelled
Auto Test / auto-test (20.5, macos-latest) (push) Has been cancelled
Auto Test / auto-test (20.5, ubuntu-latest) (push) Has been cancelled
Auto Test / auto-test (20.5, windows-latest) (push) Has been cancelled
Auto Test / armv7-simple-test (18, ARMv7) (push) Has been cancelled
Auto Test / armv7-simple-test (20, ARMv7) (push) Has been cancelled
Auto Test / e2e-test (push) Has been cancelled
Co-authored-by: Frank Elsinga <frank@elsinga.de>
2024-07-31 17:58:13 +02:00
broodroosterdev 2192bfa42b
Merge branch 'master' into hide-uptime-percentage 2024-04-12 15:37:32 +02:00
Bas Wieringa fb50d5f77c Change to show last heartbeat 2024-04-12 15:32:50 +02:00
broodroosterdev f381d64fce
Use v-else instead of negative v-if
Co-authored-by: Frank Elsinga <frank@elsinga.de>
2024-04-12 15:12:53 +02:00
broodroosterdev 75f2c69ac5
Merge branch 'master' into hide-uptime-percentage 2024-03-21 21:14:37 +01:00
Bas Wieringa 629b15c56e Add required newline to end of migration file 2024-03-15 17:09:53 +01:00
Bas Wieringa 612581a5d5 Refactor migration to new knex migrations 2024-03-15 17:07:57 +01:00
Bas Wieringa e539e5aa73 Final linting fix 2024-03-15 16:47:49 +01:00
Bas Wieringa a34ca83844 Remove spaces to fix lint error 2024-03-15 16:43:20 +01:00
Bas Wieringa 488504c3fd Fix input of the statusOfLastHeartbeat function 2024-03-15 16:18:34 +01:00
Bas Wieringa 26e234c132 Remove import that is no longer used 2024-03-15 16:03:32 +01:00
Bas Wieringa 201ac9245b Add toggle to hide the uptime percentage on a statuspage 2024-03-15 15:54:29 +01:00
6 changed files with 53 additions and 4 deletions

View file

@ -0,0 +1,16 @@
exports.up = function (knex) {
// Add new column status_page.show_last_heartbeat
return knex.schema
.alterTable("status_page", function (table) {
table.boolean("show_last_heartbeat").notNullable().defaultTo(false);
});
};
exports.down = function (knex) {
// Drop column status_page.show_last_heartbeat
return knex.schema
.alterTable("status_page", function (table) {
table.dropColumn("show_last_heartbeat");
});
};

View file

@ -4,6 +4,7 @@ const cheerio = require("cheerio");
const { UptimeKumaServer } = require("../uptime-kuma-server");
const jsesc = require("jsesc");
const googleAnalytics = require("../google-analytics");
const { marked } = require("marked");
class StatusPage extends BeanModel {
@ -46,7 +47,11 @@ class StatusPage extends BeanModel {
*/
static async renderHTML(indexHTML, statusPage) {
const $ = cheerio.load(indexHTML);
const description155 = statusPage.description?.substring(0, 155) ?? "";
const description155 = marked(statusPage.description ?? "")
.replace(/<[^>]+>/gm, "")
.trim()
.substring(0, 155);
$("title").text(statusPage.title);
$("meta[name=description]").attr("content", description155);
@ -247,6 +252,7 @@ class StatusPage extends BeanModel {
showPoweredBy: !!this.show_powered_by,
googleAnalyticsId: this.google_analytics_tag_id,
showCertificateExpiry: !!this.show_certificate_expiry,
showLastHeartbeat: !!this.show_last_heartbeat
};
}
@ -270,6 +276,7 @@ class StatusPage extends BeanModel {
showPoweredBy: !!this.show_powered_by,
googleAnalyticsId: this.google_analytics_tag_id,
showCertificateExpiry: !!this.show_certificate_expiry,
showLastHeartbeat: !!this.show_last_heartbeat
};
}

View file

@ -164,6 +164,7 @@ module.exports.statusPageSocketHandler = (socket) => {
statusPage.footer_text = config.footerText;
statusPage.custom_css = config.customCSS;
statusPage.show_powered_by = config.showPoweredBy;
statusPage.show_last_heartbeat = config.showLastHeartbeat;
statusPage.show_certificate_expiry = config.showCertificateExpiry;
statusPage.modified_date = R.isoDateTime();
statusPage.google_analytics_tag_id = config.googleAnalyticsId;

View file

@ -38,7 +38,8 @@
<font-awesome-icon v-if="editMode" icon="arrows-alt-v" class="action drag me-3" />
<font-awesome-icon v-if="editMode" icon="times" class="action remove me-3" @click="removeMonitor(group.index, monitor.index)" />
<Uptime :monitor="monitor.element" type="24" :pill="true" />
<Status v-if="showLastHeartbeat" :status="statusOfLastHeartbeat(monitor.element.id)" />
<Uptime v-else :monitor="monitor.element" type="24" :pill="true" />
<a
v-if="showLink(monitor)"
:href="monitor.element.url"
@ -90,6 +91,7 @@ import Draggable from "vuedraggable";
import HeartbeatBar from "./HeartbeatBar.vue";
import Uptime from "./Uptime.vue";
import Tag from "./Tag.vue";
import Status from "./Status.vue";
export default {
components: {
@ -98,6 +100,7 @@ export default {
HeartbeatBar,
Uptime,
Tag,
Status,
},
props: {
/** Are we in edit mode? */
@ -112,7 +115,11 @@ export default {
/** Should expiry be shown? */
showCertificateExpiry: {
type: Boolean,
}
},
/** Should only the last heartbeat be shown? */
showLastHeartbeat: {
type: Boolean,
},
},
data() {
return {
@ -181,6 +188,17 @@ export default {
}
},
/**
* Returns the status of the last heartbeat
* @param {number} monitorId Id of the monitor to get status for
* @returns {number} Status of the last heartbeat
*/
statusOfLastHeartbeat(monitorId) {
let heartbeats = this.$root.heartbeatList[monitorId] ?? [];
let lastHeartbeat = heartbeats[heartbeats.length - 1];
return lastHeartbeat?.status;
},
/**
* Returns certificate expiry color based on days remaining
* @param {object} monitor Monitor to show expiry for

View file

@ -875,6 +875,7 @@
"nostrRecipients": "Recipients Public Keys (npub)",
"nostrRecipientsHelp": "npub format, one per line",
"showCertificateExpiry": "Show Certificate Expiry",
"showLastHeartbeat": "Show Last Heartbeat Only",
"noOrBadCertificate": "No/Bad Certificate",
"gamedigGuessPort": "Gamedig: Guess Port",
"gamedigGuessPortDescription": "The port used by Valve Server Query Protocol may be different from the client port. Try this if the monitor cannot connect to your server.",

View file

@ -68,6 +68,12 @@
<label class="form-check-label" for="show-certificate-expiry">{{ $t("showCertificateExpiry") }}</label>
</div>
<!-- Show last heartbeat -->
<div class="my-3 form-check form-switch">
<input id="show-last-heartbeat" v-model="config.showLastHeartbeat" class="form-check-input" type="checkbox">
<label class="form-check-label" for="show-last-heartbeat">{{ $t("showLastHeartbeat") }}</label>
</div>
<div v-if="false" class="my-3">
<label for="password" class="form-label">{{ $t("Password") }} <sup>{{ $t("Coming Soon") }}</sup></label>
<input id="password" v-model="config.password" disabled type="password" autocomplete="new-password" class="form-control">
@ -327,7 +333,7 @@
👀 {{ $t("statusPageNothing") }}
</div>
<PublicGroupList :edit-mode="enableEditMode" :show-tags="config.showTags" :show-certificate-expiry="config.showCertificateExpiry" />
<PublicGroupList :edit-mode="enableEditMode" :show-tags="config.showTags" :show-certificate-expiry="config.showCertificateExpiry" :show-last-heartbeat="config.showLastHeartbeat" />
</div>
<footer class="mt-5 mb-4">