From 2b42c3c828b4292fd64f0428c9a676c1bc4d6df7 Mon Sep 17 00:00:00 2001 From: Matthew Nickson Date: Thu, 2 Jun 2022 00:32:05 +0100 Subject: [PATCH] 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 @@