diff --git a/db/knex_migrations/2024-03-23-0302_status-page-description.js b/db/knex_migrations/2024-03-23-0302_status-page-description.js new file mode 100644 index 000000000..36df8cc1e --- /dev/null +++ b/db/knex_migrations/2024-03-23-0302_status-page-description.js @@ -0,0 +1,27 @@ +/** + * @param { import("knex").Knex } knex Knex instance + * @returns { Promise } + */ +exports.up = function (knex) { + return knex.schema + .alterTable("status_page", function (table) { + table.boolean("show_descriptions").notNullable().defaultTo(false); + }) + .alterTable("monitor", function (table) { + table.boolean("show_description").notNullable().defaultTo(false); + }); +}; + +/** + * @param { import("knex").Knex } knex Knex instance + * @returns { Promise } + */ +exports.down = function (knex) { + return knex.schema + .alterTable("status_page", function (table) { + table.dropColumn("show_descriptions"); + }) + .alterTable("monitor", function (table) { + table.dropColumn("show_description"); + }); +}; diff --git a/server/model/group.js b/server/model/group.js index 16c482759..1be511120 100644 --- a/server/model/group.js +++ b/server/model/group.js @@ -8,15 +8,16 @@ class Group extends BeanModel { * necessary data to public * @param {boolean} showTags Should the JSON include monitor tags * @param {boolean} certExpiry Should JSON include info about + * @param {boolean} showDescriptions Include description in JSON * certificate expiry? * @returns {Promise} Object ready to parse */ - async toPublicJSON(showTags = false, certExpiry = false) { + async toPublicJSON(showTags = false, certExpiry = false, showDescriptions = false) { let monitorBeanList = await this.getMonitorList(); let monitorList = []; for (let bean of monitorBeanList) { - monitorList.push(await bean.toPublicJSON(showTags, certExpiry)); + monitorList.push(await bean.toPublicJSON(showTags, certExpiry, showDescriptions)); } return { diff --git a/server/model/monitor.js b/server/model/monitor.js index 08d666b78..87ed15dda 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -41,10 +41,11 @@ class Monitor extends BeanModel { * necessary data to public * @param {boolean} showTags Include tags in JSON * @param {boolean} certExpiry Include certificate expiry info in + * @param {boolean} showDescriptions Include description in JSON * JSON * @returns {Promise} Object ready to parse */ - async toPublicJSON(showTags = false, certExpiry = false) { + async toPublicJSON(showTags = false, certExpiry = false, showDescriptions = false) { let obj = { id: this.id, name: this.name, @@ -60,6 +61,10 @@ class Monitor extends BeanModel { obj.tags = await this.getTags(); } + if (showDescriptions && !!this.show_description) { + obj.description = this.description; + } + if (certExpiry && (this.type === "http" || this.type === "keyword" || this.type === "json-query") && this.getURLProtocol() === "https:") { const { certExpiryDaysRemaining, validCert } = await this.getCertExpiry(this.id); obj.certExpiryDaysRemaining = certExpiryDaysRemaining; @@ -91,6 +96,7 @@ class Monitor extends BeanModel { id: this.id, name: this.name, description: this.description, + show_description: !!this.show_description, path, pathName, parent: this.parent, diff --git a/server/model/status_page.js b/server/model/status_page.js index 38f548ebb..6d1d933a2 100644 --- a/server/model/status_page.js +++ b/server/model/status_page.js @@ -277,13 +277,14 @@ class StatusPage extends BeanModel { // Public Group List const publicGroupList = []; const showTags = !!statusPage.show_tags; + const showDescriptions = !!statusPage.show_descriptions; const list = await R.find("group", " public = 1 AND status_page_id = ? ORDER BY weight ", [ statusPage.id ]); for (let groupBean of list) { - let monitorGroup = await groupBean.toPublicJSON(showTags, config?.showCertificateExpiry); + let monitorGroup = await groupBean.toPublicJSON(showTags, config?.showCertificateExpiry, showDescriptions); publicGroupList.push(monitorGroup); } @@ -403,6 +404,7 @@ class StatusPage extends BeanModel { autoRefreshInterval: this.autoRefreshInterval, published: !!this.published, showTags: !!this.show_tags, + showDescriptions: !!this.show_descriptions, domainNameList: this.getDomainNameList(), customCSS: this.custom_css, footerText: this.footer_text, @@ -427,6 +429,7 @@ class StatusPage extends BeanModel { theme: this.theme, published: !!this.published, showTags: !!this.show_tags, + showDescriptions: !!this.show_descriptions, customCSS: this.custom_css, footerText: this.footer_text, showPoweredBy: !!this.show_powered_by, diff --git a/server/server.js b/server/server.js index 476ef644b..4e17a9d78 100644 --- a/server/server.js +++ b/server/server.js @@ -787,6 +787,7 @@ let needSetup = false; bean.name = monitor.name; bean.description = monitor.description; + bean.show_description = monitor.show_description; bean.parent = monitor.parent; bean.type = monitor.type; bean.url = monitor.url; diff --git a/server/socket-handlers/status-page-socket-handler.js b/server/socket-handlers/status-page-socket-handler.js index 952ec2fa7..be02ef731 100644 --- a/server/socket-handlers/status-page-socket-handler.js +++ b/server/socket-handlers/status-page-socket-handler.js @@ -160,6 +160,7 @@ module.exports.statusPageSocketHandler = (socket) => { //statusPage.published = ; //statusPage.search_engine_index = ; statusPage.show_tags = config.showTags; + statusPage.showDescriptions = config.showDescriptions; //statusPage.password = null; statusPage.footer_text = config.footerText; statusPage.custom_css = config.customCSS; diff --git a/src/components/PublicGroupList.vue b/src/components/PublicGroupList.vue index cb97ecdcd..296778637 100644 --- a/src/components/PublicGroupList.vue +++ b/src/components/PublicGroupList.vue @@ -64,11 +64,14 @@
-
- -
-
- +

{{ monitor.element.description }}

+
+
+ +
+
+ +
@@ -111,6 +114,10 @@ export default { showTags: { type: Boolean, }, + /** Should descriptions be shown? */ + showDescriptions: { + type: Boolean + }, /** Should expiry be shown? */ showCertificateExpiry: { type: Boolean, @@ -202,10 +209,13 @@ export default { @import "../assets/vars"; .extra-info { - display: flex; margin-bottom: 0.5rem; } +.extra-info .tags { + display: flex; +} + .extra-info > div > div:first-child { margin-left: 0 !important; } diff --git a/src/pages/EditMonitor.vue b/src/pages/EditMonitor.vue index bf4e6889d..9084f06bb 100644 --- a/src/pages/EditMonitor.vue +++ b/src/pages/EditMonitor.vue @@ -734,6 +734,11 @@ +
+ + +
+
diff --git a/src/pages/StatusPage.vue b/src/pages/StatusPage.vue index 116968282..e5842a199 100644 --- a/src/pages/StatusPage.vue +++ b/src/pages/StatusPage.vue @@ -56,6 +56,11 @@ +
+ + +
+
@@ -328,7 +333,7 @@ 👀 {{ $t("statusPageNothing") }}
- +