Added JSDoc to ESLint (#3529)

* Added JSDoc to eslint rules

Signed-off-by: Matthew Nickson <mnickson@sidingsmedia.com>

* Fixed JSDoc eslint errors

Signed-off-by: Matthew Nickson <mnickson@sidingsmedia.com>

* Update the check-linters workflow to Node.js 20

---------

Signed-off-by: Matthew Nickson <mnickson@sidingsmedia.com>
Co-authored-by: Louis Lam <louislam@users.noreply.github.com>
This commit is contained in:
Matthew Nickson
2023-08-11 09:46:41 +02:00
committed by GitHub
parent da4f4e3d76
commit 8a92054c2b
153 changed files with 1505 additions and 574 deletions

View File

@@ -126,6 +126,7 @@ export default {
methods: {
/**
* Show modal
* @returns {void}
*/
show() {
this.id = null;
@@ -138,7 +139,10 @@ export default {
this.keyaddmodal.show();
},
/** Submit data to server */
/**
* Submit data to server
* @returns {Promise<void>}
*/
async submit() {
this.processing = true;
@@ -159,7 +163,10 @@ export default {
});
},
/** Clear Form inputs */
/**
* Clear Form inputs
* @returns {void}
*/
clearForm() {
this.key = {
name: "",

View File

@@ -279,8 +279,9 @@ export default {
methods: {
/**
* Setting monitor
* @param {number} monitorId ID of monitor
* @param {string} monitorName Name of monitor
* @param {number} monitorId ID of monitor
* @param {string} monitorName Name of monitor
* @returns {void}
*/
show(monitorId, monitorName) {
this.monitor = {

View File

@@ -65,9 +65,9 @@ export default {
methods: {
/**
* Format the subject of the certificate
* @param {Object} subject Object representing the certificates
* @param {object} subject Object representing the certificates
* subject
* @returns {string}
* @returns {string} Certificate subject
*/
formatSubject(subject) {
if (subject.O && subject.CN && subject.C) {

View File

@@ -58,18 +58,23 @@ export default {
this.modal = new Modal(this.$refs.modal);
},
methods: {
/** Show the confirm dialog */
/**
* Show the confirm dialog
* @returns {void}
*/
show() {
this.modal.show();
},
/**
* @emits string "yes" Notify the parent when Yes is pressed
* @fires string "yes" Notify the parent when Yes is pressed
* @returns {void}
*/
yes() {
this.$emit("yes");
},
/**
* @emits string "no" Notify the parent when No is pressed
* @fires string "no" Notify the parent when No is pressed
* @returns {void}
*/
no() {
this.$emit("no");

View File

@@ -90,19 +90,25 @@ export default {
},
methods: {
/** Show the input */
/**
* Show the input
* @returns {void}
*/
showInput() {
this.visibility = "text";
},
/** Hide the input */
/**
* Hide the input
* @returns {void}
*/
hideInput() {
this.visibility = "password";
},
/**
* Copy the provided text to the users clipboard
* @param {string} textToCopy
* @param {string} textToCopy Text to copy to clipboard
* @returns {Promise<void>}
*/
copyToClipboard(textToCopy) {

View File

@@ -43,10 +43,17 @@ export default {
this.modal = new Modal(this.$refs.modal);
},
methods: {
/** Show the confirm dialog */
/**
* Show the confirm dialog
* @returns {void}
*/
show() {
this.modal.show();
},
/**
* Dialog confirmed
* @returns {void}
*/
confirm() {
this.$emit("added", this.groupName);
this.modal.hide();

View File

@@ -91,7 +91,10 @@ export default {
},
methods: {
/** Confirm deletion of docker host */
/**
* Confirm deletion of docker host
* @returns {void}
*/
deleteConfirm() {
this.modal.hide();
this.$refs.confirmDelete.show();
@@ -99,7 +102,8 @@ export default {
/**
* Show specified docker host
* @param {number} dockerHostID
* @param {number} dockerHostID ID of host to show
* @returns {void}
*/
show(dockerHostID) {
if (dockerHostID) {
@@ -131,7 +135,10 @@ export default {
this.modal.show();
},
/** Add docker host */
/**
* Add docker host
* @returns {void}
*/
submit() {
this.processing = true;
this.$root.getSocket().emit("addDockerHost", this.dockerHost, this.id, (res) => {
@@ -150,7 +157,10 @@ export default {
});
},
/** Test the docker host */
/**
* Test the docker host
* @returns {void}
*/
test() {
this.processing = true;
this.$root.getSocket().emit("testDockerHost", this.dockerHost, (res) => {
@@ -159,7 +169,10 @@ export default {
});
},
/** Delete this docker host */
/**
* Delete this docker host
* @returns {void}
*/
deleteDockerHost() {
this.processing = true;
this.$root.getSocket().emit("deleteDockerHost", this.id, (res) => {

View File

@@ -56,6 +56,7 @@ export default {
/**
* If heartbeatList is null, get it from $root.heartbeatList
* @returns {object} Heartbeat list
*/
beatList() {
if (this.heartbeatList === null) {
@@ -241,7 +242,10 @@ export default {
this.resize();
},
methods: {
/** Resize the heartbeat bar */
/**
* Resize the heartbeat bar
* @returns {void}
*/
resize() {
if (this.$refs.wrap) {
this.maxBeat = Math.floor(this.$refs.wrap.clientWidth / (this.beatWidth + this.beatMargin * 2));
@@ -251,8 +255,8 @@ export default {
/**
* Get the title of the beat.
* Used as the hover tooltip on the heartbeat bar.
* @param {Object} beat Beat to get title from
* @returns {string}
* @param {object} beat Beat to get title from
* @returns {string} Beat title
*/
getBeatTitle(beat) {
return `${this.$root.datetime(beat.time)}` + ((beat.msg) ? ` - ${beat.msg}` : "");

View File

@@ -74,11 +74,17 @@ export default {
},
methods: {
/** Show users input in plain text */
/**
* Show users input in plain text
* @returns {void}
*/
showInput() {
this.visibility = "text";
},
/** Censor users input */
/**
* Censor users input
* @returns {void}
*/
hideInput() {
this.visibility = "password";
},

View File

@@ -64,7 +64,10 @@ export default {
},
methods: {
/** Submit the user details and attempt to log in */
/**
* Submit the user details and attempt to log in
* @returns {void}
*/
submit() {
this.processing = true;

View File

@@ -103,6 +103,7 @@ export default {
* Improve the sticky appearance of the list by increasing its
* height as user scrolls down.
* Not used on mobile.
* @returns {object} Style for monitor list
*/
boxStyle() {
if (window.innerWidth > 550) {
@@ -267,7 +268,10 @@ export default {
window.removeEventListener("scroll", this.onScroll);
},
methods: {
/** Handle user scroll */
/**
* Handle user scroll
* @returns {void}
*/
onScroll() {
if (window.top.scrollY <= 133) {
this.windowTop = window.top.scrollY;
@@ -283,13 +287,17 @@ export default {
monitorURL(id) {
return getMonitorRelativeURL(id);
},
/** Clear the search bar */
/**
* Clear the search bar
* @returns {void}
*/
clearSearchText() {
this.searchText = "";
},
/**
* Update the MonitorList Filter
* @param {object} newFilter Object with new filter
* @returns {void}
*/
updateFilter(newFilter) {
this.filterState = newFilter;
@@ -297,6 +305,7 @@ export default {
/**
* Deselect a monitor
* @param {number} id ID of monitor
* @returns {void}
*/
deselect(id) {
delete this.selectedMonitors[id];
@@ -304,6 +313,7 @@ export default {
/**
* Select a monitor
* @param {number} id ID of monitor
* @returns {void}
*/
select(id) {
this.selectedMonitors[id] = true;
@@ -311,21 +321,30 @@ export default {
/**
* Determine if monitor is selected
* @param {number} id ID of monitor
* @returns {bool}
* @returns {bool} Is the monitor selected?
*/
isSelected(id) {
return id in this.selectedMonitors;
},
/** Disable select mode and reset selection */
/**
* Disable select mode and reset selection
* @returns {void}
*/
cancelSelectMode() {
this.selectMode = false;
this.selectedMonitors = {};
},
/** Show dialog to confirm pause */
/**
* Show dialog to confirm pause
* @returns {void}
*/
pauseDialog() {
this.$refs.confirmPause.show();
},
/** Pause each selected monitor */
/**
* Pause each selected monitor
* @returns {void}
*/
pauseSelected() {
Object.keys(this.selectedMonitors)
.filter(id => this.$root.monitorList[id].active)
@@ -333,7 +352,10 @@ export default {
this.cancelSelectMode();
},
/** Resume each selected monitor */
/**
* Resume each selected monitor
* @returns {void}
*/
resumeSelected() {
Object.keys(this.selectedMonitors)
.filter(id => !this.$root.monitorList[id].active)

View File

@@ -189,7 +189,9 @@ export default {
},
methods: {
/**
* Changes the collapsed value of the current monitor and saves it to local storage
* Changes the collapsed value of the current monitor and saves
* it to local storage
* @returns {void}
*/
changeCollapsed() {
this.isCollapsed = !this.isCollapsed;
@@ -214,6 +216,7 @@ export default {
},
/**
* Toggle selection of monitor
* @returns {void}
*/
toggleSelection() {
if (this.isSelected(this.monitor.id)) {

View File

@@ -67,8 +67,9 @@ export default {
methods: {
/**
* Setting monitor
* @param {Object} group Data of monitor
* @param {Object} monitor Data of monitor
* @param {object} group Data of monitor
* @param {object} monitor Data of monitor
* @returns {void}
*/
show(group, monitor) {
this.monitor = {
@@ -86,6 +87,7 @@ export default {
* Toggle the value of sendUrl
* @param {number} groupIndex Index of group monitor is member of
* @param {number} index Index of monitor within group
* @returns {void}
*/
toggleLink(groupIndex, index) {
this.$root.publicGroupList[groupIndex].monitorList[index].sendUrl = !this.$root.publicGroupList[groupIndex].monitorList[index].sendUrl;
@@ -95,10 +97,10 @@ export default {
* Should a link to the monitor be shown?
* Attempts to guess if a link should be shown based upon if
* sendUrl is set and if the URL is default or not.
* @param {Object} monitor Monitor to check
* @param {boolean} [ignoreSendUrl=false] Should the presence of the sendUrl
* @param {object} monitor Monitor to check
* @param {boolean} ignoreSendUrl Should the presence of the sendUrl
* property be ignored. This will only work in edit mode.
* @returns {boolean}
* @returns {boolean} Should the link be shown?
*/
showLink(monitor, ignoreSendUrl = false) {
// We must check if there are any elements in monitorList to

View File

@@ -218,7 +218,10 @@ export default {
},
methods: {
/** Show dialog to confirm deletion */
/**
* Show dialog to confirm deletion
* @returns {void}
*/
deleteConfirm() {
this.modal.hide();
this.$refs.confirmDelete.show();
@@ -227,6 +230,7 @@ export default {
/**
* Show settings for specified notification
* @param {number} notificationID ID of notification to show
* @returns {void}
*/
show(notificationID) {
if (notificationID) {
@@ -250,7 +254,10 @@ export default {
this.modal.show();
},
/** Submit the form to the server */
/**
* Submit the form to the server
* @returns {void}
*/
submit() {
this.processing = true;
this.$root.getSocket().emit("addNotification", this.notification, this.id, (res) => {
@@ -269,7 +276,10 @@ export default {
});
},
/** Test the notification endpoint */
/**
* Test the notification endpoint
* @returns {void}
*/
test() {
this.processing = true;
this.$root.getSocket().emit("testNotification", this.notification, (res) => {
@@ -278,7 +288,10 @@ export default {
});
},
/** Delete the notification endpoint */
/**
* Delete the notification endpoint
* @returns {void}
*/
deleteNotification() {
this.processing = true;
this.$root.getSocket().emit("deleteNotification", this.id, (res) => {
@@ -293,7 +306,8 @@ export default {
/**
* Get a unique default name for the notification
* @param {keyof NotificationFormList} notificationKey
* @return {string}
* Notification to retrieve
* @returns {string} Default name
*/
getUniqueDefaultName(notificationKey) {

View File

@@ -131,7 +131,10 @@ export default {
},
methods: {
/** Show dialog to confirm deletion */
/**
* Show dialog to confirm deletion
* @returns {void}
*/
deleteConfirm() {
this.modal.hide();
this.$refs.confirmDelete.show();
@@ -140,6 +143,7 @@ export default {
/**
* Show settings for specified proxy
* @param {number} proxyID ID of proxy to show
* @returns {void}
*/
show(proxyID) {
if (proxyID) {
@@ -169,7 +173,10 @@ export default {
this.modal.show();
},
/** Submit form data for saving */
/**
* Submit form data for saving
* @returns {void}
*/
submit() {
this.processing = true;
this.$root.getSocket().emit("addProxy", this.proxy, this.id, (res) => {
@@ -187,7 +194,10 @@ export default {
});
},
/** Delete this proxy */
/**
* Delete this proxy
* @returns {void}
*/
deleteProxy() {
this.processing = true;
this.$root.getSocket().emit("deleteProxy", this.id, (res) => {

View File

@@ -131,6 +131,7 @@ export default {
/**
* Remove the specified group
* @param {number} index Index of group to remove
* @returns {void}
*/
removeGroup(index) {
this.$root.publicGroupList.splice(index, 1);
@@ -141,6 +142,7 @@ export default {
* @param {number} groupIndex Index of group to remove monitor
* from
* @param {number} index Index of monitor to remove
* @returns {void}
*/
removeMonitor(groupIndex, index) {
this.$root.publicGroupList[groupIndex].monitorList.splice(index, 1);
@@ -150,10 +152,10 @@ export default {
* Should a link to the monitor be shown?
* Attempts to guess if a link should be shown based upon if
* sendUrl is set and if the URL is default or not.
* @param {Object} monitor Monitor to check
* @param {boolean} [ignoreSendUrl=false] Should the presence of the sendUrl
* @param {object} monitor Monitor to check
* @param {boolean} ignoreSendUrl Should the presence of the sendUrl
* property be ignored. This will only work in edit mode.
* @returns {boolean}
* @returns {boolean} Should the link be shown
*/
showLink(monitor, ignoreSendUrl = false) {
// We must check if there are any elements in monitorList to
@@ -166,8 +168,8 @@ export default {
/**
* Returns formatted certificate expiry or Bad cert message
* @param {Object} monitor Monitor to show expiry for
* @returns {string}
* @param {object} monitor Monitor to show expiry for
* @returns {string} Certificate expiry message
*/
formattedCertExpiryMessage(monitor) {
if (monitor?.element?.validCert && monitor?.element?.certExpiryDaysRemaining) {
@@ -180,9 +182,9 @@ export default {
},
/**
* Returns certificate expiry based on days remaining
* @param {Object} monitor Monitor to show expiry for
* @returns {string}
* Returns certificate expiry color based on days remaining
* @param {object} monitor Monitor to show expiry for
* @returns {string} Color for certificate expiry
*/
certExpiryColor(monitor) {
if (monitor?.element?.validCert && monitor.element.certExpiryDaysRemaining > 7) {

View File

@@ -19,12 +19,13 @@
<script>
/**
* @typedef {import('./TagsManager.vue').Tag} Tag
*/
* @typedef {import('./TagsManager.vue').Tag} Tag
*/
export default {
props: {
/** Object representing tag
/**
* Object representing tag
* @type {Tag}
*/
item: {

View File

@@ -207,6 +207,8 @@ export default {
},
/**
* Selected a monitor and add to the list.
* @param {object} monitor Monitor to add
* @returns {void}
*/
selectedAddMonitor(monitor) {
if (monitor) {
@@ -227,6 +229,7 @@ export default {
methods: {
/**
* Show confirmation for deleting a tag
* @returns {void}
*/
deleteConfirm() {
this.$refs.confirmDelete.show();
@@ -234,6 +237,7 @@ export default {
/**
* Reset the editTag form
* @returns {void}
*/
reset() {
this.selectedColor = null;
@@ -263,7 +267,7 @@ export default {
/**
* Load tag information for display in the edit dialog
* @param {Object} tag tag object to edit
* @param {object} tag tag object to edit
* @returns {void}
*/
show(tag) {
@@ -377,7 +381,7 @@ export default {
/**
* Get monitors which has a specific tag locally
* @param {number} tagId id of the tag to filter
* @returns {Object[]} list of monitors which has a specific tag
* @returns {object[]} list of monitors which has a specific tag
*/
monitorsByTag(tagId) {
return Object.values(this.$root.monitorList).filter((monitor) => {
@@ -396,7 +400,7 @@ export default {
/**
* Add a tag asynchronously
* @param {Object} newTag Object representing new tag to add
* @param {object} newTag Object representing new tag to add
* @returns {Promise<void>}
*/
addTagAsync(newTag) {

View File

@@ -137,13 +137,14 @@ const toast = useToast();
/**
* @typedef Tag
* @type {object}
* @property {number | undefined} id
* @property {number | undefined} monitor_id
* @property {number | undefined} tag_id
* @property {string} value
* @property {string} name
* @property {string} color
* @property {boolean | undefined} new
* @property {number | undefined} id ID of tag assignment
* @property {number | undefined} monitor_id ID of monitor tag is
* assigned to
* @property {number | undefined} tag_id ID of tag
* @property {string} value Value given to tag
* @property {string} name Name of tag
* @property {string} color Colour of tag
* @property {boolean | undefined} new Should a new tag be created?
*/
export default {
@@ -152,7 +153,8 @@ export default {
VueMultiselect,
},
props: {
/** Array of tags to be pre-selected
/**
* Array of tags to be pre-selected
* @type {Tag[]}
*/
preSelectedTags: {
@@ -244,11 +246,17 @@ export default {
this.getExistingTags();
},
methods: {
/** Show the add tag dialog */
/**
* Show the add tag dialog
* @returns {void}
*/
showAddDialog() {
this.modal.show();
},
/** Get all existing tags */
/**
* Get all existing tags
* @returns {void}
*/
getExistingTags() {
this.$root.getSocket().emit("getTags", (res) => {
if (res.ok) {
@@ -260,7 +268,8 @@ export default {
},
/**
* Delete the specified tag
* @param {Object} tag Object representing tag to delete
* @param {object} item Object representing tag to delete
* @returns {void}
*/
deleteTag(item) {
if (item.new) {
@@ -273,10 +282,10 @@ export default {
},
/**
* Get colour of text inside the tag
* @param {Object} option The tag that needs to be displayed.
* @param {object} option The tag that needs to be displayed.
* Defaults to "white" unless the tag has no color, which will
* then return the body color (based on application theme)
* @returns string
* @returns {string} Text color
*/
textColor(option) {
if (option.color) {
@@ -285,7 +294,10 @@ export default {
return this.$root.theme === "light" ? "var(--bs-body-color)" : "inherit";
}
},
/** Add a draft tag */
/**
* Add a draft tag
* @returns {void}
*/
addDraftTag() {
console.log("Adding Draft Tag: ", this.newDraftTag);
if (this.newDraftTag.select != null) {
@@ -313,7 +325,10 @@ export default {
}
this.clearDraftTag();
},
/** Remove a draft tag */
/**
* Remove a draft tag
* @returns {void}
*/
clearDraftTag() {
this.newDraftTag = {
name: null,
@@ -327,7 +342,7 @@ export default {
},
/**
* Add a tag asynchronously
* @param {Object} newTag Object representing new tag to add
* @param {object} newTag Object representing new tag to add
* @returns {Promise<void>}
*/
addTagAsync(newTag) {
@@ -359,7 +374,10 @@ export default {
this.$root.getSocket().emit("deleteMonitorTag", tagId, monitorId, value, resolve);
});
},
/** Handle pressing Enter key when inside the modal */
/**
* Handle pressing Enter key when inside the modal
* @returns {void}
*/
onEnter() {
if (!this.validateDraftTag.invalid) {
this.addDraftTag();

View File

@@ -100,22 +100,34 @@ export default {
this.getStatus();
},
methods: {
/** Show the dialog */
/**
* Show the dialog
* @returns {void}
*/
show() {
this.modal.show();
},
/** Show dialog to confirm enabling 2FA */
/**
* Show dialog to confirm enabling 2FA
* @returns {void}
*/
confirmEnableTwoFA() {
this.$refs.confirmEnableTwoFA.show();
},
/** Show dialog to confirm disabling 2FA */
/**
* Show dialog to confirm disabling 2FA
* @returns {void}
*/
confirmDisableTwoFA() {
this.$refs.confirmDisableTwoFA.show();
},
/** Prepare 2FA configuration */
/**
* Prepare 2FA configuration
* @returns {void}
*/
prepare2FA() {
this.processing = true;
@@ -130,7 +142,10 @@ export default {
});
},
/** Save the current 2FA configuration */
/**
* Save the current 2FA configuration
* @returns {void}
*/
save2FA() {
this.processing = true;
@@ -148,7 +163,10 @@ export default {
});
},
/** Disable 2FA for this user */
/**
* Disable 2FA for this user
* @returns {void}
*/
disable2FA() {
this.processing = true;
@@ -166,7 +184,10 @@ export default {
});
},
/** Verify the token generated by the user */
/**
* Verify the token generated by the user
* @returns {void}
*/
verifyToken() {
this.$root.getSocket().emit("verifyToken", this.token, this.currentPassword, (res) => {
if (res.ok) {
@@ -177,7 +198,10 @@ export default {
});
},
/** Get current status of 2FA */
/**
* Get current status of 2FA
* @returns {void}
*/
getStatus() {
this.$root.getSocket().emit("twoFAStatus", (res) => {
if (res.ok) {

View File

@@ -68,7 +68,7 @@ export default {
methods: {
/**
* Get the URL for telegram updates
* @param {string} [mode=masked] Should the token be masked?
* @param {string} mode Should the token be masked?
* @returns {string} formatted URL
*/
telegramGetUpdatesURL(mode = "masked") {
@@ -85,7 +85,11 @@ export default {
return `https://api.telegram.org/bot${token}/getUpdates`;
},
/** Get the telegram chat ID */
/**
* Get the telegram chat ID
* @returns {void}
* @throws The chat ID could not be found
*/
async autoGetTelegramChatID() {
try {
let res = await axios.get(this.telegramGetUpdatesURL("withToken"));

View File

@@ -54,7 +54,6 @@ import Splunk from "./Splunk.vue";
/**
* Manage all notification form.
*
* @type { Record<string, any> }
*/
const NotificationFormList = {

View File

@@ -96,6 +96,7 @@ export default {
/**
* Show dialog to confirm deletion
* @param {number} keyID ID of monitor that is being deleted
* @returns {void}
*/
deleteDialog(keyID) {
this.selectedKeyID = keyID;
@@ -104,6 +105,7 @@ export default {
/**
* Delete a key
* @returns {void}
*/
deleteKey() {
this.$root.deleteAPIKey(this.selectedKeyID, (res) => {
@@ -117,6 +119,8 @@ export default {
/**
* Show dialog to confirm pause
* @param {number} keyID ID of key to pause
* @returns {void}
*/
disableDialog(keyID) {
this.selectedKeyID = keyID;
@@ -124,7 +128,8 @@ export default {
},
/**
* Pause maintenance
* Pause API key
* @returns {void}
*/
disableKey() {
this.$root.getSocket().emit("disableAPIKey", this.selectedKeyID, (res) => {
@@ -133,7 +138,9 @@ export default {
},
/**
* Resume maintenance
* Resume API key
* @param {number} id Key to resume
* @returns {void}
*/
enableKey(id) {
this.$root.getSocket().emit("enableAPIKey", id, (res) => {

View File

@@ -142,12 +142,16 @@ export default {
/**
* Show the confimation dialog confirming the configuration
* be imported
* @returns {void}
*/
confirmImport() {
this.$refs.confirmImport.show();
},
/** Download a backup of the configuration */
/**
* Download a backup of the configuration
* @returns {void}
*/
downloadBackup() {
let time = dayjs().format("YYYY_MM_DD-hh_mm_ss");
let fileName = `Uptime_Kuma_Backup_${time}.json`;
@@ -170,7 +174,7 @@ export default {
/**
* Import the specified backup file
* @returns {?string}
* @returns {string|void} Error message
*/
importBackup() {
this.processing = true;

View File

@@ -256,16 +256,25 @@ export default {
},
methods: {
/** Save the settings */
/**
* Save the settings
* @returns {void}
*/
saveGeneral() {
localStorage.timezone = this.$root.userTimezone;
this.saveSettings();
},
/** Get the base URL of the application */
/**
* Get the base URL of the application
* @returns {void}
*/
autoGetPrimaryBaseURL() {
this.settings.primaryBaseURL = location.protocol + "//" + location.host;
},
/**
* Test the chrome executable
* @returns {void}
*/
testChrome() {
this.$root.getSocket().emit("testChrome", this.settings.chromeExecutable, (res) => {
this.$root.toastRes(res);

View File

@@ -94,7 +94,10 @@ export default {
},
methods: {
/** Get the current size of the database */
/**
* Get the current size of the database
* @returns {void}
*/
loadDatabaseSize() {
log.debug("monitorhistory", "load database size");
this.$root.getSocket().emit("getDatabaseSize", (res) => {
@@ -107,7 +110,10 @@ export default {
});
},
/** Request that the database is shrunk */
/**
* Request that the database is shrunk
* @returns {void}
*/
shrinkDatabase() {
this.$root.getSocket().emit("shrinkDatabase", (res) => {
if (res.ok) {
@@ -119,12 +125,18 @@ export default {
});
},
/** Show the dialog to confirm clearing stats */
/**
* Show the dialog to confirm clearing stats
* @returns {void}
*/
confirmClearStatistics() {
this.$refs.confirmClearStatistics.show();
},
/** Send the request to clear stats */
/**
* Send the request to clear stats
* @returns {void}
*/
clearStatistics() {
this.$root.clearStatistics((res) => {
if (res.ok) {

View File

@@ -81,6 +81,7 @@ export default {
/**
* Remove a day from expiry notification days.
* @param {number} day The day to remove.
* @returns {void}
*/
removeExpiryNotifDay(day) {
this.settings.tlsExpiryNotifyDays = this.settings.tlsExpiryNotifyDays.filter(d => d !== day);
@@ -93,6 +94,7 @@ export default {
* - day is > 0.
* - The day is not already in the list.
* @param {number} day The day number to add.
* @returns {void}
*/
addExpiryNotifDay(day) {
if (day != null && day !== "") {

View File

@@ -175,17 +175,26 @@ export default {
this.$root.getSocket().emit(prefix + "leave");
},
methods: {
/** Start the Cloudflare tunnel */
/**
* Start the Cloudflare tunnel
* @returns {void}
*/
start() {
this.$root.getSocket().emit(prefix + "start", this.cloudflareTunnelToken);
},
/** Stop the Cloudflare tunnel */
/**
* Stop the Cloudflare tunnel
* @returns {void}
*/
stop() {
this.$root.getSocket().emit(prefix + "stop", this.currentPassword, (res) => {
this.$root.toastRes(res);
});
},
/** Remove the token for the Cloudflare tunnel */
/**
* Remove the token for the Cloudflare tunnel
* @returns {void}
*/
removeToken() {
this.$root.getSocket().emit(prefix + "removeToken");
this.cloudflareTunnelToken = "";

View File

@@ -152,7 +152,10 @@ export default {
},
methods: {
/** Check new passwords match before saving them */
/**
* Check new passwords match before saving them
* @returns {void}
*/
savePassword() {
if (this.password.newPassword !== this.password.repeatNewPassword) {
this.invalidPassword = true;
@@ -170,7 +173,10 @@ export default {
}
},
/** Disable authentication for web app access */
/**
* Disable authentication for web app access
* @returns {void}
*/
disableAuth() {
this.settings.disableAuth = true;
@@ -183,7 +189,10 @@ export default {
}, this.password.currentPassword);
},
/** Enable authentication for web app access */
/**
* Enable authentication for web app access
* @returns {void}
*/
enableAuth() {
this.settings.disableAuth = false;
this.saveSettings();
@@ -191,7 +200,10 @@ export default {
location.reload();
},
/** Show confirmation dialog for disable auth */
/**
* Show confirmation dialog for disable auth
* @returns {void}
*/
confirmDisableAuth() {
this.$refs.confirmDisableAuth.show();
},

View File

@@ -138,7 +138,7 @@ export default {
/**
* Get monitors which has a specific tag locally
* @param {number} tagId id of the tag to filter
* @returns {Object[]} list of monitors which has a specific tag
* @returns {object[]} list of monitors which has a specific tag
*/
monitorsByTag(tagId) {
return Object.values(this.$root.monitorList).filter((monitor) => {

View File

@@ -14,8 +14,9 @@ export default {
methods: {
/**
* Convert value to UTC
* @param {string | number | Date | dayjs.Dayjs} value
* @returns {dayjs.Dayjs}
* @param {string | number | Date | dayjs.Dayjs} value Time
* value to convert
* @returns {dayjs.Dayjs} Converted time
*/
toUTC(value) {
return dayjs.tz(value, this.timezone).utc().format();
@@ -23,8 +24,9 @@ export default {
/**
* Used for <input type="datetime" />
* @param value
* @returns {string}
* @param {string | number | Date | dayjs.Dayjs} value Value to
* convert
* @returns {string} Datetime string
*/
toDateTimeInputFormat(value) {
return this.datetimeFormat(value, "YYYY-MM-DDTHH:mm");
@@ -33,7 +35,7 @@ export default {
/**
* Return a given value in the format YYYY-MM-DD HH:mm:ss
* @param {any} value Value to format as date time
* @returns {string}
* @returns {string} Formatted string
*/
datetime(value) {
return this.datetimeFormat(value, "YYYY-MM-DD HH:mm:ss");
@@ -41,8 +43,9 @@ export default {
/**
* Get time for maintenance
* @param {string | number | Date | dayjs.Dayjs} value
* @returns {string}
* @param {string | number | Date | dayjs.Dayjs} value Time to
* format
* @returns {string} Formatted string
*/
datetimeMaintenance(value) {
const inputDate = new Date(value);
@@ -58,7 +61,7 @@ export default {
/**
* Return a given value in the format YYYY-MM-DD
* @param {any} value Value to format as date
* @returns {string}
* @returns {string} Formatted string
*/
date(value) {
return this.datetimeFormat(value, "YYYY-MM-DD");
@@ -69,7 +72,7 @@ export default {
* to true, HH:mm:ss
* @param {any} value Value to format
* @param {boolean} second Should seconds be included?
* @returns {string}
* @returns {string} Formatted string
*/
time(value, second = true) {
let secondString;
@@ -85,7 +88,7 @@ export default {
* Return a value in a custom format
* @param {any} value Value to format
* @param {any} format Format to return value in
* @returns {string}
* @returns {string} Formatted string
*/
datetimeFormat(value, format) {
if (value !== undefined && value !== "") {

View File

@@ -22,7 +22,11 @@ export default {
},
methods: {
/** Change the application language */
/**
* Change the application language
* @param {string} lang Language code to switch to
* @returns {Promise<void>}
*/
async changeLang(lang) {
let message = (await langModules["../lang/" + lang + ".json"]()).default;
this.$i18n.setLocaleMessage(lang, message);

View File

@@ -12,13 +12,19 @@ export default {
},
methods: {
/** Handle screen resize */
/**
* Handle screen resize
* @returns {void}
*/
onResize() {
this.windowWidth = window.innerWidth;
this.updateBody();
},
/** Add css-class "mobile" to body if needed */
/**
* Add css-class "mobile" to body if needed
* @returns {void}
*/
updateBody() {
if (this.isMobile) {
document.body.classList.add("mobile");

View File

@@ -70,9 +70,9 @@ export default {
/**
* Initialize connection to socket server
* @param {boolean} [bypass = false] Should the check for if we
* @param {boolean} bypass Should the check for if we
* are on a status page be bypassed?
* @returns {(void|null)}
* @returns {void}
*/
initSocketIO(bypass = false) {
// No need to re-init
@@ -297,7 +297,7 @@ export default {
/**
* The storage currently in use
* @returns {Storage}
* @returns {Storage} Current storage
*/
storage() {
return (this.remember) ? localStorage : sessionStorage;
@@ -305,7 +305,7 @@ export default {
/**
* Get payload of JWT cookie
* @returns {(Object|undefined)}
* @returns {(object | undefined)} JWT payload
*/
getJWTPayload() {
const jwtToken = this.$root.storage().token;
@@ -318,7 +318,7 @@ export default {
/**
* Get current socket
* @returns {Socket}
* @returns {Socket} Current socket
*/
getSocket() {
return socket;
@@ -326,7 +326,8 @@ export default {
/**
* Show success or error toast dependant on response status code
* @param {Object} res Response object
* @param {object} res Response object
* @returns {void}
*/
toastRes(res) {
if (res.ok) {
@@ -339,6 +340,7 @@ export default {
/**
* Show a success toast
* @param {string} msg Message to show
* @returns {void}
*/
toastSuccess(msg) {
toast.success(msg);
@@ -347,6 +349,7 @@ export default {
/**
* Show an error toast
* @param {string} msg Message to show
* @returns {void}
*/
toastError(msg) {
toast.error(msg);
@@ -355,7 +358,7 @@ export default {
/**
* Callback for login
* @callback loginCB
* @param {Object} res Response object
* @param {object} res Response object
*/
/**
@@ -364,6 +367,7 @@ export default {
* @param {string} password Password to log in with
* @param {string} token User token
* @param {loginCB} callback Callback to call with result
* @returns {void}
*/
login(username, password, token, callback) {
socket.emit("login", {
@@ -392,6 +396,7 @@ export default {
/**
* Log in using a token
* @param {string} token Token to log in with
* @returns {void}
*/
loginByToken(token) {
socket.emit("loginByToken", token, (res) => {
@@ -406,7 +411,10 @@ export default {
});
},
/** Log out of the web application */
/**
* Log out of the web application
* @returns {void}
*/
logout() {
socket.emit("logout", () => { });
this.storage().removeItem("token");
@@ -419,9 +427,13 @@ export default {
/**
* Callback for general socket requests
* @callback socketCB
* @param {Object} res Result of operation
* @param {object} res Result of operation
*/
/**
* Prepare 2FA configuration
* @param {socketCB} callback Callback for socket response
* @returns {void}
*/
/** Prepare 2FA configuration */
prepare2FA(callback) {
socket.emit("prepare2FA", callback);
},
@@ -429,7 +441,8 @@ export default {
/**
* Save the current 2FA configuration
* @param {any} secret Unused
* @param {socketCB} callback
* @param {socketCB} callback Callback for socket response
* @returns {void}
*/
save2FA(secret, callback) {
socket.emit("save2FA", callback);
@@ -437,7 +450,8 @@ export default {
/**
* Disable 2FA for this user
* @param {socketCB} callback
* @param {socketCB} callback Callback for socket response
* @returns {void}
*/
disable2FA(callback) {
socket.emit("disable2FA", callback);
@@ -446,7 +460,8 @@ export default {
/**
* Verify the provided 2FA token
* @param {string} token Token to verify
* @param {socketCB} callback
* @param {socketCB} callback Callback for socket response
* @returns {void}
*/
verifyToken(token, callback) {
socket.emit("verifyToken", token, callback);
@@ -454,7 +469,8 @@ export default {
/**
* Get current 2FA status
* @param {socketCB} callback
* @param {socketCB} callback Callback for socket response
* @returns {void}
*/
twoFAStatus(callback) {
socket.emit("twoFAStatus", callback);
@@ -462,7 +478,8 @@ export default {
/**
* Get list of monitors
* @param {socketCB} callback
* @param {socketCB} callback Callback for socket response
* @returns {void}
*/
getMonitorList(callback) {
if (! callback) {
@@ -473,7 +490,8 @@ export default {
/**
* Get list of maintenances
* @param {socketCB} callback
* @param {socketCB} callback Callback for socket response
* @returns {void}
*/
getMaintenanceList(callback) {
if (! callback) {
@@ -484,7 +502,8 @@ export default {
/**
* Send list of API keys
* @param {socketCB} callback
* @param {socketCB} callback Callback for socket response
* @returns {void}
*/
getAPIKeyList(callback) {
if (!callback) {
@@ -495,17 +514,19 @@ export default {
/**
* Add a monitor
* @param {Object} monitor Object representing monitor to add
* @param {socketCB} callback
* @param {object} monitor Object representing monitor to add
* @param {socketCB} callback Callback for socket response
* @returns {void}
*/
add(monitor, callback) {
socket.emit("add", monitor, callback);
},
/**
* Adds a maintenace
* @param {Object} maintenance
* @param {socketCB} callback
* Adds a maintenance
* @param {object} maintenance Maintenance to add
* @param {socketCB} callback Callback for socket response
* @returns {void}
*/
addMaintenance(maintenance, callback) {
socket.emit("addMaintenance", maintenance, callback);
@@ -513,9 +534,10 @@ export default {
/**
* Add monitors to maintenance
* @param {number} maintenanceID
* @param {number[]} monitors
* @param {socketCB} callback
* @param {number} maintenanceID Maintenance to modify
* @param {number[]} monitors IDs of monitors to add
* @param {socketCB} callback Callback for socket response
* @returns {void}
*/
addMonitorMaintenance(maintenanceID, monitors, callback) {
socket.emit("addMonitorMaintenance", maintenanceID, monitors, callback);
@@ -523,9 +545,10 @@ export default {
/**
* Add status page to maintenance
* @param {number} maintenanceID
* @param {number} statusPages
* @param {socketCB} callback
* @param {number} maintenanceID Maintenance to modify
* @param {number} statusPages ID of status page to add
* @param {socketCB} callback Callback for socket response
* @returns {void}
*/
addMaintenanceStatusPage(maintenanceID, statusPages, callback) {
socket.emit("addMaintenanceStatusPage", maintenanceID, statusPages, callback);
@@ -533,8 +556,9 @@ export default {
/**
* Get monitors affected by maintenance
* @param {number} maintenanceID
* @param {socketCB} callback
* @param {number} maintenanceID Maintenance to read
* @param {socketCB} callback Callback for socket response
* @returns {void}
*/
getMonitorMaintenance(maintenanceID, callback) {
socket.emit("getMonitorMaintenance", maintenanceID, callback);
@@ -542,8 +566,9 @@ export default {
/**
* Get status pages where maintenance is shown
* @param {number} maintenanceID
* @param {socketCB} callback
* @param {number} maintenanceID Maintenance to read
* @param {socketCB} callback Callback for socket response
* @returns {void}
*/
getMaintenanceStatusPage(maintenanceID, callback) {
socket.emit("getMaintenanceStatusPage", maintenanceID, callback);
@@ -552,7 +577,8 @@ export default {
/**
* Delete monitor by ID
* @param {number} monitorID ID of monitor to delete
* @param {socketCB} callback
* @param {socketCB} callback Callback for socket response
* @returns {void}
*/
deleteMonitor(monitorID, callback) {
socket.emit("deleteMonitor", monitorID, callback);
@@ -560,8 +586,9 @@ export default {
/**
* Delete specified maintenance
* @param {number} maintenanceID
* @param {socketCB} callback
* @param {number} maintenanceID Maintenance to delete
* @param {socketCB} callback Callback for socket response
* @returns {void}
*/
deleteMaintenance(maintenanceID, callback) {
socket.emit("deleteMaintenance", maintenanceID, callback);
@@ -569,8 +596,9 @@ export default {
/**
* Add an API key
* @param {Object} key API key to add
* @param {socketCB} callback
* @param {object} key API key to add
* @param {socketCB} callback Callback for socket response
* @returns {void}
*/
addAPIKey(key, callback) {
socket.emit("addAPIKey", key, callback);
@@ -579,13 +607,17 @@ export default {
/**
* Delete specified API key
* @param {int} keyID ID of key to delete
* @param {socketCB} callback
* @param {socketCB} callback Callback for socket response
* @returns {void}
*/
deleteAPIKey(keyID, callback) {
socket.emit("deleteAPIKey", keyID, callback);
},
/** Clear the hearbeat list */
/**
* Clear the hearbeat list
* @returns {void}
*/
clearData() {
console.log("reset heartbeat list");
this.heartbeatList = {};
@@ -597,7 +629,8 @@ export default {
* @param {string} uploadedJSON JSON to upload
* @param {string} importHandle Type of import. If set to
* most data in database will be replaced
* @param {socketCB} callback
* @param {socketCB} callback Callback for socket response
* @returns {void}
*/
uploadBackup(uploadedJSON, importHandle, callback) {
socket.emit("uploadBackup", uploadedJSON, importHandle, callback);
@@ -606,7 +639,8 @@ export default {
/**
* Clear events for a specified monitor
* @param {number} monitorID ID of monitor to clear
* @param {socketCB} callback
* @param {socketCB} callback Callback for socket response
* @returns {void}
*/
clearEvents(monitorID, callback) {
socket.emit("clearEvents", monitorID, callback);
@@ -615,7 +649,8 @@ export default {
/**
* Clear the heartbeats of a specified monitor
* @param {number} monitorID Id of monitor to clear
* @param {socketCB} callback
* @param {socketCB} callback Callback for socket response
* @returns {void}
*/
clearHeartbeats(monitorID, callback) {
socket.emit("clearHeartbeats", monitorID, callback);
@@ -623,7 +658,8 @@ export default {
/**
* Clear all statistics
* @param {socketCB} callback
* @param {socketCB} callback Callback for socket response
* @returns {void}
*/
clearStatistics(callback) {
socket.emit("clearStatistics", callback);
@@ -633,7 +669,8 @@ export default {
* Get monitor beats for a specific monitor in a time range
* @param {number} monitorID ID of monitor to fetch
* @param {number} period Time in hours from now
* @param {socketCB} callback
* @param {socketCB} callback Callback for socket response
* @returns {void}
*/
getMonitorBeats(monitorID, period, callback) {
socket.emit("getMonitorBeats", monitorID, period, callback);
@@ -744,7 +781,7 @@ export default {
* Frontend Version
* It should be compiled to a static value while building the frontend.
* Please see ./config/vite.config.js, it is defined via vite.js
* @returns {string}
* @returns {string} Current version
*/
frontendVersion() {
// eslint-disable-next-line no-undef
@@ -753,7 +790,7 @@ export default {
/**
* Are both frontend and backend in the same version?
* @returns {boolean}
* @returns {boolean} The frontend and backend match?
*/
isFrontendBackendVersionMatched() {
if (!this.info.version) {

View File

@@ -95,7 +95,10 @@ export default {
},
methods: {
/** Update the theme color meta tag */
/**
* Update the theme color meta tag
* @returns {void}
*/
updateThemeColorMeta() {
if (this.theme === "dark") {
document.querySelector("#theme-color").setAttribute("content", "#161B22");

View File

@@ -51,7 +51,10 @@ export default {
};
},
methods: {
/** Submit form data to add new status page */
/**
* Submit form data to add new status page
* @returns {Promise<void>}
*/
async submit() {
this.processing = true;

View File

@@ -359,47 +359,71 @@ export default {
},
methods: {
getResBaseURL,
/** Request a test notification be sent for this monitor */
/**
* Request a test notification be sent for this monitor
* @returns {void}
*/
testNotification() {
this.$root.getSocket().emit("testNotification", this.monitor.id);
toast.success("Test notification is requested.");
},
/** Show dialog to confirm pause */
/**
* Show dialog to confirm pause
* @returns {void}
*/
pauseDialog() {
this.$refs.confirmPause.show();
},
/** Resume this monitor */
/**
* Resume this monitor
* @returns {void}
*/
resumeMonitor() {
this.$root.getSocket().emit("resumeMonitor", this.monitor.id, (res) => {
this.$root.toastRes(res);
});
},
/** Request that this monitor is paused */
/**
* Request that this monitor is paused
* @returns {void}
*/
pauseMonitor() {
this.$root.getSocket().emit("pauseMonitor", this.monitor.id, (res) => {
this.$root.toastRes(res);
});
},
/** Show dialog to confirm deletion */
/**
* Show dialog to confirm deletion
* @returns {void}
*/
deleteDialog() {
this.$refs.confirmDelete.show();
},
/** Show dialog to confirm clearing events */
/**
* Show dialog to confirm clearing events
* @returns {void}
*/
clearEventsDialog() {
this.$refs.confirmClearEvents.show();
},
/** Show dialog to confirm clearing heartbeats */
/**
* Show dialog to confirm clearing heartbeats
* @returns {void}
*/
clearHeartbeatsDialog() {
this.$refs.confirmClearHeartbeats.show();
},
/** Request that this monitor is deleted */
/**
* Request that this monitor is deleted
* @returns {void}
*/
deleteMonitor() {
this.$root.deleteMonitor(this.monitor.id, (res) => {
if (res.ok) {
@@ -411,7 +435,10 @@ export default {
});
},
/** Request that this monitors events are cleared */
/**
* Request that this monitors events are cleared
* @returns {void}
*/
clearEvents() {
this.$root.clearEvents(this.monitor.id, (res) => {
if (! res.ok) {
@@ -420,7 +447,10 @@ export default {
});
},
/** Request that this monitors heartbeats are cleared */
/**
* Request that this monitors heartbeats are cleared
* @returns {void}
*/
clearHeartbeats() {
this.$root.clearHeartbeats(this.monitor.id, (res) => {
if (! res.ok) {
@@ -431,8 +461,8 @@ export default {
/**
* Return the correct title for the ping stat
* @param {boolean} [average=false] Is the statistic an average?
* @returns {string} Title formated dependant on monitor type
* @param {boolean} average Is the statistic an average?
* @returns {string} Title formatted dependant on monitor type
*/
pingTitle(average = false) {
let translationPrefix = "";
@@ -456,7 +486,11 @@ export default {
return getMonitorRelativeURL(id);
},
/** Filter and hide password in URL for display */
/**
* Filter and hide password in URL for display
* @param {string} urlString URL to censor
* @returns {string} Censored URL
*/
filterPassword(urlString) {
try {
let parsedUrl = new URL(urlString);

View File

@@ -417,7 +417,10 @@ export default {
});
},
methods: {
/** Initialise page */
/**
* Initialise page
* @returns {void}
*/
init() {
this.affectedMonitors = [];
this.selectedStatusPages = [];
@@ -479,7 +482,10 @@ export default {
}
},
/** Create new maintenance */
/**
* Create new maintenance
* @returns {Promise<void>}
*/
async submit() {
this.processing = true;
@@ -526,8 +532,9 @@ export default {
/**
* Add monitor to maintenance
* @param {number} maintenanceID
* @param {socketCB} callback
* @param {number} maintenanceID ID of maintenance to modify
* @param {socketCB} callback Callback for socket response
* @returns {Promise<void>}
*/
async addMonitorMaintenance(maintenanceID, callback) {
await this.$root.addMonitorMaintenance(maintenanceID, this.affectedMonitors, async (res) => {
@@ -543,8 +550,9 @@ export default {
/**
* Add status page to maintenance
* @param {number} maintenanceID
* @param {socketCB} callback
* @param {number} maintenanceID ID of maintenance to modify
* @param {socketCB} callback Callback for socket response
* @returns {void}
*/
async addMaintenanceStatusPage(maintenanceID, callback) {
await this.$root.addMaintenanceStatusPage(maintenanceID, (this.showOnAllPages) ? this.selectedStatusPagesOptions : this.selectedStatusPages, async (res) => {

View File

@@ -1069,8 +1069,7 @@ message HealthCheckResponse {
/**
* Generates the parent monitor options list based on the sorted group monitor list and draft group name.
*
* @return {Array} The parent monitor options list.
* @returns {Array} The parent monitor options list.
*/
parentMonitorOptionsList() {
let list = [];
@@ -1234,7 +1233,10 @@ message HealthCheckResponse {
this.kafkaSaslMechanismOptions = kafkaSaslMechanismOptions;
},
methods: {
/** Initialize the edit monitor form */
/**
* Initialize the edit monitor form
* @returns {void}
*/
init() {
if (this.isAdd) {
@@ -1447,6 +1449,7 @@ message HealthCheckResponse {
* Added a Notification Event
* Enable it if the notification is added in EditMonitor.vue
* @param {number} id ID of notification to add
* @returns {void}
*/
addedNotification(id) {
this.monitor.notificationIDList[id] = true;
@@ -1456,21 +1459,26 @@ message HealthCheckResponse {
* Added a Proxy Event
* Enable it if the proxy is added in EditMonitor.vue
* @param {number} id ID of proxy to add
* @returns {void}
*/
addedProxy(id) {
this.monitor.proxyId = id;
},
// Added a Docker Host Event
// Enable it if the Docker Host is added in EditMonitor.vue
/**
* Added a Docker Host Event
* Enable it if the Docker Host is added in EditMonitor.vue
* @param {number} id ID of docker host
* @returns {void}
*/
addedDockerHost(id) {
this.monitor.docker_host = id;
},
/**
* Adds a draft group.
*
* @param {string} draftGroupName - The name of the draft group.
* @param {string} draftGroupName The name of the draft group.
* @returns {void}
*/
addedDraftGroup(draftGroupName) {
this.draftGroupName = draftGroupName;

View File

@@ -65,7 +65,10 @@ export default {
this.init();
},
methods: {
/** Initialise page */
/**
* Initialise page
* @returns {void}
*/
init() {
this.$root.getSocket().emit("getMonitorMaintenance", this.$route.params.id, (res) => {
if (res.ok) {
@@ -84,12 +87,18 @@ export default {
});
},
/** Confirm deletion */
/**
* Confirm deletion
* @returns {void}
*/
deleteDialog() {
this.$refs.confirmDelete.show();
},
/** Delete maintenance after showing confirmation */
/**
* Delete maintenance after showing confirmation
* @returns {void}
*/
deleteMaintenance() {
this.$root.deleteMaintenance(this.maintenance.id, (res) => {
if (res.ok) {

View File

@@ -135,7 +135,7 @@ export default {
/**
* Get maintenance URL
* @param {number} id
* @param {number} id ID of maintenance to read
* @returns {string} Relative URL
*/
maintenanceURL(id) {
@@ -144,14 +144,19 @@ export default {
/**
* Show delete confirmation
* @param {number} maintenanceID
* @param {number} maintenanceID ID of maintenance to show delete
* confirmation for.
* @returns {void}
*/
deleteDialog(maintenanceID) {
this.selectedMaintenanceID = maintenanceID;
this.$refs.confirmDelete.show();
},
/** Delete maintenance after showing confirmation dialog */
/**
* Delete maintenance after showing confirmation dialog
* @returns {void}
*/
deleteMaintenance() {
this.$root.deleteMaintenance(this.selectedMaintenanceID, (res) => {
if (res.ok) {
@@ -165,6 +170,9 @@ export default {
/**
* Show dialog to confirm pause
* @param {number} maintenanceID ID of maintenance to confirm
* pause.
* @returns {void}
*/
pauseDialog(maintenanceID) {
this.selectedMaintenanceID = maintenanceID;
@@ -173,6 +181,7 @@ export default {
/**
* Pause maintenance
* @returns {void}
*/
pauseMaintenance() {
this.$root.getSocket().emit("pauseMaintenance", this.selectedMaintenanceID, (res) => {
@@ -182,6 +191,8 @@ export default {
/**
* Resume maintenance
* @param {number} id ID of maintenance to resume
* @returns {void}
*/
resumeMaintenance(id) {
this.$root.getSocket().emit("resumeMaintenance", id, (res) => {

View File

@@ -45,7 +45,10 @@ export default {
},
methods: {
/** Go back 1 in browser history */
/**
* Go back 1 in browser history
* @returns {void}
*/
goBack() {
history.back();
}

View File

@@ -139,6 +139,7 @@ export default {
/**
* Load the general settings page
* For desktop only, on mobile do nothing
* @returns {void}
*/
loadGeneralPage() {
if (!this.currentPage && !this.$root.isMobile) {
@@ -146,7 +147,10 @@ export default {
}
},
/** Load settings from server */
/**
* Load settings from server
* @returns {void}
*/
loadSettings() {
this.$root.getSocket().emit("getSettings", (res) => {
this.settings = res.data;
@@ -186,13 +190,15 @@ export default {
/**
* Callback for saving settings
* @callback saveSettingsCB
* @param {Object} res Result of operation
* @param {object} res Result of operation
* @returns {void}
*/
/**
* Save Settings
* @param {saveSettingsCB} [callback]
* @param {string} [currentPassword] Only need for disableAuth to true
* @param {saveSettingsCB} callback Callback for socket response
* @param {string} currentPassword Only need for disableAuth to true
* @returns {void}
*/
saveSettings(callback, currentPassword) {
let valid = this.validateSettings();
@@ -212,7 +218,7 @@ export default {
/**
* Ensure settings are valid
* @returns {Object} Contains success state and error msg
* @returns {object} Contains success state and error msg
*/
validateSettings() {
if (this.settings.keepDataPeriodDays < 0) {

View File

@@ -452,6 +452,7 @@ export default {
/**
* If the monitor is added to public list, which will not be in this list.
* @returns {object[]} List of monitors
*/
sortedMonitorList() {
let result = [];
@@ -596,7 +597,8 @@ export default {
/**
* If connected to the socket and logged in, request private data of this statusPage
* @param connected
* @param {boolean} loggedIn Is the client logged in?
* @returns {void}
*/
"$root.loggedIn"(loggedIn) {
if (loggedIn) {
@@ -619,6 +621,8 @@ export default {
/**
* Selected a monitor and add to the list.
* @param {object} monitor Monitor to add
* @returns {void}
*/
selectedMonitor(monitor) {
if (monitor) {
@@ -723,7 +727,7 @@ export default {
/**
* Get status page data
* It should be preloaded in window.preloadData
* @returns {Promise<any>}
* @returns {Promise<any>} Status page data
*/
getData: function () {
if (window.preloadData) {
@@ -738,13 +742,16 @@ export default {
/**
* Provide syntax highlighting for CSS
* @param {string} code Text to highlight
* @returns {string}
* @returns {string} Highlighted HTML
*/
highlighter(code) {
return highlight(code, languages.css);
},
/** Update the heartbeat list and update favicon if neccessary */
/**
* Update the heartbeat list and update favicon if necessary
* @returns {void}
*/
updateHeartbeatList() {
// If editMode, it will use the data from websocket.
if (! this.editMode) {
@@ -792,7 +799,10 @@ export default {
}, 1000);
},
/** Enable editing mode */
/**
* Enable editing mode
* @returns {void}
*/
edit() {
if (this.hasToken) {
this.$root.initSocketIO(true);
@@ -804,7 +814,10 @@ export default {
}
},
/** Save the status page */
/**
* Save the status page
* @returns {void}
*/
save() {
let startTime = new Date();
this.config.slug = this.config.slug.trim().toLowerCase();
@@ -832,12 +845,18 @@ export default {
});
},
/** Show dialog confirming deletion */
/**
* Show dialog confirming deletion
* @returns {void}
*/
deleteDialog() {
this.$refs.confirmDelete.show();
},
/** Request deletion of this status page */
/**
* Request deletion of this status page
* @returns {void}
*/
deleteStatusPage() {
this.$root.getSocket().emit("deleteStatusPage", this.slug, (res) => {
if (res.ok) {
@@ -850,15 +869,18 @@ export default {
},
/**
* Returns label for a specifed monitor
* @param {Object} monitor Object representing monitor
* @returns {string}
* Returns label for a specified monitor
* @param {object} monitor Object representing monitor
* @returns {string} Monitor label
*/
monitorSelectorLabel(monitor) {
return `${monitor.name}`;
},
/** Add a group to the status page */
/**
* Add a group to the status page
* @returns {void}
*/
addGroup() {
let groupName = this.$t("Untitled Group");
@@ -872,12 +894,18 @@ export default {
});
},
/** Add a domain to the status page */
/**
* Add a domain to the status page
* @returns {void}
*/
addDomainField() {
this.config.domainNameList.push("");
},
/** Discard changes to status page */
/**
* Discard changes to status page
* @returns {void}
*/
discard() {
location.href = "/status/" + this.slug;
},
@@ -885,19 +913,26 @@ export default {
/**
* Set URL of new image after successful crop operation
* @param {string} imgDataUrl URL of image in data:// format
* @returns {void}
*/
cropSuccess(imgDataUrl) {
this.imgDataUrl = imgDataUrl;
},
/** Show image crop dialog if in edit mode */
/**
* Show image crop dialog if in edit mode
* @returns {void}
*/
showImageCropUploadMethod() {
if (this.editMode) {
this.showImageCropUpload = true;
}
},
/** Create an incident for this status page */
/**
* Create an incident for this status page
* @returns {void}
*/
createIncident() {
this.enableEditIncidentMode = true;
@@ -912,7 +947,10 @@ export default {
};
},
/** Post the incident to the status page */
/**
* Post the incident to the status page
* @returns {void}
*/
postIncident() {
if (this.incident.title === "" || this.incident.content === "") {
toast.error(this.$t("Please input title and content"));
@@ -932,13 +970,19 @@ export default {
},
/** Click Edit Button */
/**
* Click Edit Button
* @returns {void}
*/
editIncident() {
this.enableEditIncidentMode = true;
this.previousIncident = Object.assign({}, this.incident);
},
/** Cancel creation or editing of incident */
/**
* Cancel creation or editing of incident
* @returns {void}
*/
cancelIncident() {
this.enableEditIncidentMode = false;
@@ -948,7 +992,10 @@ export default {
}
},
/** Unpin the incident */
/**
* Unpin the incident
* @returns {void}
*/
unpinIncident() {
this.$root.getSocket().emit("unpinIncident", this.slug, () => {
this.incident = null;
@@ -957,7 +1004,8 @@ export default {
/**
* Get the relative time difference of a date from now
* @returns {string}
* @param {any} date Date to get time difference
* @returns {string} Time difference
*/
dateFromNow(date) {
return dayjs.utc(date).fromNow();
@@ -966,6 +1014,7 @@ export default {
/**
* Remove a domain from the status page
* @param {number} index Index of domain to remove
* @returns {void}
*/
removeDomain(index) {
this.config.domainNameList.splice(index, 1);
@@ -973,7 +1022,7 @@ export default {
/**
* Generate sanitized HTML from maintenance description
* @param {string} description
* @param {string} description Text to sanitize
* @returns {string} Sanitized HTML
*/
maintenanceHTML(description) {

View File

@@ -4,6 +4,7 @@ import { localeDirection, currentLocale } from "./i18n";
/**
* Returns the offset from UTC in hours for the current locale.
* @param {string} timeZone Timezone to get offset for
* @returns {number} The offset from UTC in hours.
*
* Generated by Trelent
@@ -20,12 +21,11 @@ function getTimezoneOffset(timeZone) {
}
/**
* Returns a list of timezones sorted by their offset from UTC.
* @param {Object[]} timezones An array of timezone objects.
* @returns {Object[]} A list of the given timezones sorted by their offset from UTC.
*
* Generated by Trelent
*/
* Returns a list of timezones sorted by their offset from UTC.
* @returns {object[]} A list of the given timezones sorted by their offset from UTC.
*
* Generated by Trelent
*/
export function timezoneList() {
let result = [];
@@ -58,7 +58,10 @@ export function timezoneList() {
return result;
}
/** Set the locale of the HTML page */
/**
* Set the locale of the HTML page
* @returns {void}
*/
export function setPageLocale() {
const html = document.documentElement;
html.setAttribute("lang", currentLocale() );
@@ -68,7 +71,7 @@ export function setPageLocale() {
/**
* Get the base URL
* Mainly used for dev, because the backend and the frontend are in different ports.
* @returns {string}
* @returns {string} Base URL
*/
export function getResBaseURL() {
const env = process.env.NODE_ENV;
@@ -81,6 +84,10 @@ export function getResBaseURL() {
}
}
/**
* Are we currently running in a dev container?
* @returns {boolean} Running in dev container?
*/
export function isDevContainer() {
// eslint-disable-next-line no-undef
return (typeof DEVCONTAINER === "string" && DEVCONTAINER === "1");
@@ -88,6 +95,7 @@ export function isDevContainer() {
/**
* Supports GitHub Codespaces only currently
* @returns {string} Dev container server hostname
*/
export function getDevContainerServerHostname() {
if (!isDevContainer()) {
@@ -99,9 +107,10 @@ export function getDevContainerServerHostname() {
}
/**
*
* @param {} mqtt wheather or not the regex should take into account the fact that it is an mqtt uri
* @returns RegExp The requested regex
* Regex pattern fr identifying hostnames and IP addresses
* @param {boolean} mqtt whether or not the regex should take into
* account the fact that it is an mqtt uri
* @returns {RegExp} The requested regex
*/
export function hostNameRegexPattern(mqtt = false) {
// mqtt, mqtts, ws and wss schemes accepted by mqtt.js (https://github.com/mqttjs/MQTT.js/#connect)
@@ -117,7 +126,8 @@ export function hostNameRegexPattern(mqtt = false) {
/**
* Get the tag color options
* Shared between components
* @returns {Object[]}
* @param {any} self Component
* @returns {object[]} Colour options
*/
export function colorOptions(self) {
return [