mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-09-16 00:21:52 +08:00
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:
@@ -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) {
|
||||
|
Reference in New Issue
Block a user