From 07888e43f1141d623a11b7b8d3ce3a6a3bbf3b37 Mon Sep 17 00:00:00 2001 From: Matthew Nickson Date: Sun, 24 Apr 2022 13:45:05 +0100 Subject: [PATCH 1/9] [empty commit] pull request for JSDoc src/* From d939d03690b38ced23261b49cc010d76ef75d267 Mon Sep 17 00:00:00 2001 From: Matthew Nickson Date: Wed, 1 Jun 2022 23:44:10 +0100 Subject: [PATCH 2/9] Added JSDoc for src/components/settings/* Signed-off-by: Matthew Nickson --- src/components/settings/Backup.vue | 9 +++++++++ src/components/settings/General.vue | 2 ++ src/components/settings/MonitorHistory.vue | 4 ++++ src/components/settings/ReverseProxy.vue | 3 +++ src/components/settings/Security.vue | 3 +++ 5 files changed, 21 insertions(+) diff --git a/src/components/settings/Backup.vue b/src/components/settings/Backup.vue index ba0f92f0e..685a4c6ba 100644 --- a/src/components/settings/Backup.vue +++ b/src/components/settings/Backup.vue @@ -133,10 +133,15 @@ export default { }, methods: { + /** + * Show the confimation dialog confirming the configuration + * be imported + */ confirmImport() { this.$refs.confirmImport.show(); }, + /** Download a backup of the configuration */ downloadBackup() { let time = dayjs().format("YYYY_MM_DD-hh_mm_ss"); let fileName = `Uptime_Kuma_Backup_${time}.json`; @@ -157,6 +162,10 @@ export default { downloadItem.click(); }, + /** + * Import the specified backup file + * @returns {?string} + */ importBackup() { this.processing = true; let uploadItem = document.getElementById("import-backend").files; diff --git a/src/components/settings/General.vue b/src/components/settings/General.vue index a175988b9..19dc8077e 100644 --- a/src/components/settings/General.vue +++ b/src/components/settings/General.vue @@ -178,10 +178,12 @@ export default { }, methods: { + /** Save the settings */ saveGeneral() { localStorage.timezone = this.$root.userTimezone; this.saveSettings(); }, + /** Get the base URL of the application */ autoGetPrimaryBaseURL() { this.settings.primaryBaseURL = location.protocol + "//" + location.host; }, diff --git a/src/components/settings/MonitorHistory.vue b/src/components/settings/MonitorHistory.vue index 0092727f4..c78c6aaf7 100644 --- a/src/components/settings/MonitorHistory.vue +++ b/src/components/settings/MonitorHistory.vue @@ -90,6 +90,7 @@ export default { }, methods: { + /** Get the current size of the database */ loadDatabaseSize() { log.debug("monitorhistory", "load database size"); this.$root.getSocket().emit("getDatabaseSize", (res) => { @@ -102,6 +103,7 @@ export default { }); }, + /** Request that the database is shrunk */ shrinkDatabase() { this.$root.getSocket().emit("shrinkDatabase", (res) => { if (res.ok) { @@ -113,10 +115,12 @@ export default { }); }, + /** Show the dialog to confirm clearing stats */ confirmClearStatistics() { this.$refs.confirmClearStatistics.show(); }, + /** Send the request to clear stats */ clearStatistics() { this.$root.clearStatistics((res) => { if (res.ok) { diff --git a/src/components/settings/ReverseProxy.vue b/src/components/settings/ReverseProxy.vue index 97db4d597..e93bd0ef2 100644 --- a/src/components/settings/ReverseProxy.vue +++ b/src/components/settings/ReverseProxy.vue @@ -120,14 +120,17 @@ export default { this.$root.getSocket().emit(prefix + "leave"); }, methods: { + /** Start the Cloudflare tunnel */ start() { this.$root.getSocket().emit(prefix + "start", this.cloudflareTunnelToken); }, + /** Stop the Cloudflare tunnel */ stop() { this.$root.getSocket().emit(prefix + "stop", this.currentPassword, (res) => { this.$root.toastRes(res); }); }, + /** Remove the token for the Cloudflare tunnel */ removeToken() { this.$root.getSocket().emit(prefix + "removeToken"); this.cloudflareTunnelToken = ""; diff --git a/src/components/settings/Security.vue b/src/components/settings/Security.vue index a5d42f82b..60e72bda2 100644 --- a/src/components/settings/Security.vue +++ b/src/components/settings/Security.vue @@ -303,6 +303,7 @@ export default { }, methods: { + /** Check new passwords match before saving them */ savePassword() { if (this.password.newPassword !== this.password.repeatNewPassword) { this.invalidPassword = true; @@ -320,6 +321,7 @@ export default { } }, + /** Disable authentication for web app access */ disableAuth() { this.settings.disableAuth = true; @@ -332,6 +334,7 @@ export default { }, this.password.currentPassword); }, + /** Enable authentication for web app access */ enableAuth() { this.settings.disableAuth = false; this.saveSettings(); From 2b42c3c828b4292fd64f0428c9a676c1bc4d6df7 Mon Sep 17 00:00:00 2001 From: Matthew Nickson Date: Thu, 2 Jun 2022 00:32:05 +0100 Subject: [PATCH 3/9] Added JSDoc for src/components/* Signed-off-by: Matthew Nickson --- src/components/CertificateInfo.vue | 2 ++ src/components/CertificateInfoRow.vue | 7 +++++ src/components/Confirm.vue | 7 +++++ src/components/CopyableInput.vue | 15 ++++++++++ src/components/CountUp.vue | 6 ++-- src/components/Datetime.vue | 2 ++ src/components/HeartbeatBar.vue | 9 ++++++ src/components/HiddenInput.vue | 8 ++++++ src/components/Login.vue | 1 + src/components/MonitorList.vue | 8 ++++++ src/components/NotificationDialog.vue | 9 ++++++ src/components/PingChart.vue | 1 + src/components/ProxyDialog.vue | 7 +++++ src/components/PublicGroupList.vue | 12 ++++++++ src/components/Status.vue | 1 + src/components/Tag.vue | 6 ++++ src/components/TagsManager.vue | 41 +++++++++++++++++++++++++++ src/components/ToggleSection.vue | 2 ++ src/components/TwoFADialog.vue | 8 ++++++ src/components/Uptime.vue | 3 ++ 20 files changed, 152 insertions(+), 3 deletions(-) diff --git a/src/components/CertificateInfo.vue b/src/components/CertificateInfo.vue index bb10f158d..cb1a82917 100644 --- a/src/components/CertificateInfo.vue +++ b/src/components/CertificateInfo.vue @@ -25,10 +25,12 @@ export default { CertificateInfoRow, }, props: { + /** Object representing certificate */ certInfo: { type: Object, required: true, }, + /** Is the TLS certificate valid? */ valid: { type: Boolean, required: true, diff --git a/src/components/CertificateInfoRow.vue b/src/components/CertificateInfoRow.vue index 3ac22f3b6..f02d1d7b9 100644 --- a/src/components/CertificateInfoRow.vue +++ b/src/components/CertificateInfoRow.vue @@ -56,12 +56,19 @@ export default { Datetime, }, props: { + /** Object representing certificate */ cert: { type: Object, required: true, }, }, methods: { + /** + * Format the subject of the certificate + * @param {Object} subject Object representing the certificates + * subject + * @returns {string} + */ formatSubject(subject) { if (subject.O && subject.CN && subject.C) { return `${subject.CN} - ${subject.O} (${subject.C})`; diff --git a/src/components/Confirm.vue b/src/components/Confirm.vue index 1bfe7fe4a..d369e0b5b 100644 --- a/src/components/Confirm.vue +++ b/src/components/Confirm.vue @@ -29,14 +29,17 @@ import { Modal } from "bootstrap"; export default { props: { + /** Style of button */ btnStyle: { type: String, default: "btn-primary", }, + /** Text to use as yes */ yesText: { type: String, default: "Yes", // TODO: No idea what to translate this }, + /** Text to use as no */ noText: { type: String, default: "No", @@ -50,9 +53,13 @@ export default { this.modal = new Modal(this.$refs.modal); }, methods: { + /** Show the confirm dialog */ show() { this.modal.show(); }, + /** + * @emits string A string that simply says "yes" + */ yes() { this.$emit("yes"); }, diff --git a/src/components/CopyableInput.vue b/src/components/CopyableInput.vue index 1bccfa2ce..2e1dee766 100644 --- a/src/components/CopyableInput.vue +++ b/src/components/CopyableInput.vue @@ -25,33 +25,41 @@ let timeout; export default { props: { + /** ID of this input */ id: { type: String, default: "" }, + /** Type of input */ type: { type: String, default: "text" }, + /** The value of the input */ modelValue: { type: String, default: "" }, + /** A placeholder to use */ placeholder: { type: String, default: "" }, + /** Should the field auto complete */ autocomplete: { type: String, default: undefined, }, + /** Is the input required? */ required: { type: Boolean }, + /** Should the input be read only? */ readonly: { type: String, default: undefined, }, + /** Is the input disabled? */ disabled: { type: String, default: undefined, @@ -79,14 +87,21 @@ export default { }, methods: { + /** Show the input */ showInput() { this.visibility = "text"; }, + /** Hide the input */ hideInput() { this.visibility = "password"; }, + /** + * Copy the provided text to the users clipboard + * @param {string} textToCopy + * @returns {Promise} + */ copyToClipboard(textToCopy) { this.icon = "check"; diff --git a/src/components/CountUp.vue b/src/components/CountUp.vue index df1d1ac6c..9ce68507f 100644 --- a/src/components/CountUp.vue +++ b/src/components/CountUp.vue @@ -10,6 +10,7 @@ import { sleep } from "../util.ts"; export default { props: { + /** Value to count */ value: { type: [ String, Number ], default: 0, @@ -18,6 +19,7 @@ export default { type: Number, default: 0.3, }, + /** Unit of the value */ unit: { type: String, default: "ms", @@ -43,9 +45,7 @@ export default { let frames = 12; let step = Math.floor(diff / frames); - if (isNaN(step) || ! this.isNum || (diff > 0 && step < 1) || (diff < 0 && step > 1) || diff === 0) { - // Lazy to NOT this condition, hahaha. - } else { + if (! (isNaN(step) || ! this.isNum || (diff > 0 && step < 1) || (diff < 0 && step > 1) || diff === 0)) { for (let i = 1; i < frames; i++) { this.output += step; await sleep(15); diff --git a/src/components/Datetime.vue b/src/components/Datetime.vue index fa68d02c7..3c66f5d6e 100644 --- a/src/components/Datetime.vue +++ b/src/components/Datetime.vue @@ -13,10 +13,12 @@ dayjs.extend(relativeTime); export default { props: { + /** Value of data time */ value: { type: String, default: null, }, + /** Should only the date be displayed? */ dateOnly: { type: Boolean, default: false, diff --git a/src/components/HeartbeatBar.vue b/src/components/HeartbeatBar.vue index ce888a989..83923dd23 100644 --- a/src/components/HeartbeatBar.vue +++ b/src/components/HeartbeatBar.vue @@ -17,14 +17,17 @@ export default { props: { + /** Size of the heart beat bar */ size: { type: String, default: "big", }, + /** ID of the monitor */ monitorId: { type: Number, required: true, }, + /** Array of the monitors heart beats */ heartbeatList: { type: Array, default: null, @@ -160,12 +163,18 @@ export default { this.resize(); }, methods: { + /** Resize the heartbeat bar */ resize() { if (this.$refs.wrap) { this.maxBeat = Math.floor(this.$refs.wrap.clientWidth / (this.beatWidth + this.beatMargin * 2)); } }, + /** + * Get the title of the beat + * @param {Object} beat Beat to get title from + * @returns {string} + */ getBeatTitle(beat) { return `${this.$root.datetime(beat.time)}` + ((beat.msg) ? ` - ${beat.msg}` : ""); }, diff --git a/src/components/HiddenInput.vue b/src/components/HiddenInput.vue index d2327b9df..8fd68d4c4 100644 --- a/src/components/HiddenInput.vue +++ b/src/components/HiddenInput.vue @@ -24,25 +24,31 @@