mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-12-19 04:34:33 -05:00
Added JSDoc for src/
Signed-off-by: Matthew Nickson <mnickson@sidingsmedia.com>
This commit is contained in:
parent
caff9ca736
commit
dc8289df12
@ -91,11 +91,16 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
||||||
|
/** Confirm deletion of docker host */
|
||||||
deleteConfirm() {
|
deleteConfirm() {
|
||||||
this.modal.hide();
|
this.modal.hide();
|
||||||
this.$refs.confirmDelete.show();
|
this.$refs.confirmDelete.show();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show specified docker host
|
||||||
|
* @param {number} dockerHostID
|
||||||
|
*/
|
||||||
show(dockerHostID) {
|
show(dockerHostID) {
|
||||||
if (dockerHostID) {
|
if (dockerHostID) {
|
||||||
let found = false;
|
let found = false;
|
||||||
@ -126,6 +131,7 @@ export default {
|
|||||||
this.modal.show();
|
this.modal.show();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/** Add docker host */
|
||||||
submit() {
|
submit() {
|
||||||
this.processing = true;
|
this.processing = true;
|
||||||
this.$root.getSocket().emit("addDockerHost", this.dockerHost, this.id, (res) => {
|
this.$root.getSocket().emit("addDockerHost", this.dockerHost, this.id, (res) => {
|
||||||
@ -144,6 +150,7 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/** Test the docker host */
|
||||||
test() {
|
test() {
|
||||||
this.processing = true;
|
this.processing = true;
|
||||||
this.$root.getSocket().emit("testDockerHost", this.dockerHost, (res) => {
|
this.$root.getSocket().emit("testDockerHost", this.dockerHost, (res) => {
|
||||||
@ -152,6 +159,7 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/** Delete this docker host */
|
||||||
deleteDockerHost() {
|
deleteDockerHost() {
|
||||||
this.processing = true;
|
this.processing = true;
|
||||||
this.$root.getSocket().emit("deleteDockerHost", this.id, (res) => {
|
this.$root.getSocket().emit("deleteDockerHost", this.id, (res) => {
|
||||||
|
@ -42,6 +42,11 @@ export default {
|
|||||||
HiddenInput,
|
HiddenInput,
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
/**
|
||||||
|
* Get the URL for telegram updates
|
||||||
|
* @param {string} [mode=masked] Should the token be masked?
|
||||||
|
* @returns {string} formatted URL
|
||||||
|
*/
|
||||||
telegramGetUpdatesURL(mode = "masked") {
|
telegramGetUpdatesURL(mode = "masked") {
|
||||||
let token = `<${this.$t("YOUR BOT TOKEN HERE")}>`;
|
let token = `<${this.$t("YOUR BOT TOKEN HERE")}>`;
|
||||||
|
|
||||||
@ -55,6 +60,8 @@ export default {
|
|||||||
|
|
||||||
return `https://api.telegram.org/bot${token}/getUpdates`;
|
return `https://api.telegram.org/bot${token}/getUpdates`;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/** Get the telegram chat ID */
|
||||||
async autoGetTelegramChatID() {
|
async autoGetTelegramChatID() {
|
||||||
try {
|
try {
|
||||||
let res = await axios.get(this.telegramGetUpdatesURL("withToken"));
|
let res = await axios.get(this.telegramGetUpdatesURL("withToken"));
|
||||||
|
@ -191,6 +191,7 @@ export default {
|
|||||||
location.reload();
|
location.reload();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/** Show confirmation dialog for disable auth */
|
||||||
confirmDisableAuth() {
|
confirmDisableAuth() {
|
||||||
this.$refs.confirmDisableAuth.show();
|
this.$refs.confirmDisableAuth.show();
|
||||||
},
|
},
|
||||||
|
@ -12,6 +12,11 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
/**
|
||||||
|
* Convert value to UTC
|
||||||
|
* @param {string | number | Date | dayjs.Dayjs} value
|
||||||
|
* @returns {dayjs.Dayjs}
|
||||||
|
*/
|
||||||
toUTC(value) {
|
toUTC(value) {
|
||||||
return dayjs.tz(value, this.timezone).utc().format();
|
return dayjs.tz(value, this.timezone).utc().format();
|
||||||
},
|
},
|
||||||
@ -34,6 +39,11 @@ export default {
|
|||||||
return this.datetimeFormat(value, "YYYY-MM-DD HH:mm:ss");
|
return this.datetimeFormat(value, "YYYY-MM-DD HH:mm:ss");
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get time for maintenance
|
||||||
|
* @param {string | number | Date | dayjs.Dayjs} value
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
datetimeMaintenance(value) {
|
datetimeMaintenance(value) {
|
||||||
const inputDate = new Date(value);
|
const inputDate = new Date(value);
|
||||||
const now = new Date(Date.now());
|
const now = new Date(Date.now());
|
||||||
|
@ -454,6 +454,10 @@ export default {
|
|||||||
socket.emit("getMonitorList", callback);
|
socket.emit("getMonitorList", callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get list of maintenances
|
||||||
|
* @param {socketCB} callback
|
||||||
|
*/
|
||||||
getMaintenanceList(callback) {
|
getMaintenanceList(callback) {
|
||||||
if (! callback) {
|
if (! callback) {
|
||||||
callback = () => { };
|
callback = () => { };
|
||||||
@ -470,22 +474,49 @@ export default {
|
|||||||
socket.emit("add", monitor, callback);
|
socket.emit("add", monitor, callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a maintenace
|
||||||
|
* @param {Object} maintenance
|
||||||
|
* @param {socketCB} callback
|
||||||
|
*/
|
||||||
addMaintenance(maintenance, callback) {
|
addMaintenance(maintenance, callback) {
|
||||||
socket.emit("addMaintenance", maintenance, callback);
|
socket.emit("addMaintenance", maintenance, callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add monitors to maintenance
|
||||||
|
* @param {number} maintenanceID
|
||||||
|
* @param {number[]} monitors
|
||||||
|
* @param {socketCB} callback
|
||||||
|
*/
|
||||||
addMonitorMaintenance(maintenanceID, monitors, callback) {
|
addMonitorMaintenance(maintenanceID, monitors, callback) {
|
||||||
socket.emit("addMonitorMaintenance", maintenanceID, monitors, callback);
|
socket.emit("addMonitorMaintenance", maintenanceID, monitors, callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add status page to maintenance
|
||||||
|
* @param {number} maintenanceID
|
||||||
|
* @param {number} statusPages
|
||||||
|
* @param {socketCB} callback
|
||||||
|
*/
|
||||||
addMaintenanceStatusPage(maintenanceID, statusPages, callback) {
|
addMaintenanceStatusPage(maintenanceID, statusPages, callback) {
|
||||||
socket.emit("addMaintenanceStatusPage", maintenanceID, statusPages, callback);
|
socket.emit("addMaintenanceStatusPage", maintenanceID, statusPages, callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get monitors affected by maintenance
|
||||||
|
* @param {number} maintenanceID
|
||||||
|
* @param {socketCB} callback
|
||||||
|
*/
|
||||||
getMonitorMaintenance(maintenanceID, callback) {
|
getMonitorMaintenance(maintenanceID, callback) {
|
||||||
socket.emit("getMonitorMaintenance", maintenanceID, callback);
|
socket.emit("getMonitorMaintenance", maintenanceID, callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get status pages where maintenance is shown
|
||||||
|
* @param {number} maintenanceID
|
||||||
|
* @param {socketCB} callback
|
||||||
|
*/
|
||||||
getMaintenanceStatusPage(maintenanceID, callback) {
|
getMaintenanceStatusPage(maintenanceID, callback) {
|
||||||
socket.emit("getMaintenanceStatusPage", maintenanceID, callback);
|
socket.emit("getMaintenanceStatusPage", maintenanceID, callback);
|
||||||
},
|
},
|
||||||
@ -499,6 +530,11 @@ export default {
|
|||||||
socket.emit("deleteMonitor", monitorID, callback);
|
socket.emit("deleteMonitor", monitorID, callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete specified maintenance
|
||||||
|
* @param {number} maintenanceID
|
||||||
|
* @param {socketCB} callback
|
||||||
|
*/
|
||||||
deleteMaintenance(maintenanceID, callback) {
|
deleteMaintenance(maintenanceID, callback) {
|
||||||
socket.emit("deleteMaintenance", maintenanceID, callback);
|
socket.emit("deleteMaintenance", maintenanceID, callback);
|
||||||
},
|
},
|
||||||
|
@ -356,6 +356,7 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
/** Initialise page */
|
||||||
init() {
|
init() {
|
||||||
this.affectedMonitors = [];
|
this.affectedMonitors = [];
|
||||||
this.selectedStatusPages = [];
|
this.selectedStatusPages = [];
|
||||||
@ -414,6 +415,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/** Create new maintenance */
|
||||||
async submit() {
|
async submit() {
|
||||||
this.processing = true;
|
this.processing = true;
|
||||||
|
|
||||||
@ -458,6 +460,11 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add monitor to maintenance
|
||||||
|
* @param {number} maintenanceID
|
||||||
|
* @param {socketCB} callback
|
||||||
|
*/
|
||||||
async addMonitorMaintenance(maintenanceID, callback) {
|
async addMonitorMaintenance(maintenanceID, callback) {
|
||||||
await this.$root.addMonitorMaintenance(maintenanceID, this.affectedMonitors, async (res) => {
|
await this.$root.addMonitorMaintenance(maintenanceID, this.affectedMonitors, async (res) => {
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
@ -470,6 +477,11 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add status page to maintenance
|
||||||
|
* @param {number} maintenanceID
|
||||||
|
* @param {socketCB} callback
|
||||||
|
*/
|
||||||
async addMaintenanceStatusPage(maintenanceID, callback) {
|
async addMaintenanceStatusPage(maintenanceID, callback) {
|
||||||
await this.$root.addMaintenanceStatusPage(maintenanceID, (this.showOnAllPages) ? this.selectedStatusPagesOptions : this.selectedStatusPages, async (res) => {
|
await this.$root.addMaintenanceStatusPage(maintenanceID, (this.showOnAllPages) ? this.selectedStatusPagesOptions : this.selectedStatusPages, async (res) => {
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
|
@ -65,6 +65,7 @@ export default {
|
|||||||
this.init();
|
this.init();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
/** Initialise page */
|
||||||
init() {
|
init() {
|
||||||
this.$root.getSocket().emit("getMonitorMaintenance", this.$route.params.id, (res) => {
|
this.$root.getSocket().emit("getMonitorMaintenance", this.$route.params.id, (res) => {
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
@ -83,10 +84,12 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/** Confirm deletion */
|
||||||
deleteDialog() {
|
deleteDialog() {
|
||||||
this.$refs.confirmDelete.show();
|
this.$refs.confirmDelete.show();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/** Delete maintenance after showing confirmation */
|
||||||
deleteMaintenance() {
|
deleteMaintenance() {
|
||||||
this.$root.deleteMaintenance(this.maintenance.id, (res) => {
|
this.$root.deleteMaintenance(this.maintenance.id, (res) => {
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
|
@ -133,15 +133,25 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get maintenance URL
|
||||||
|
* @param {number} id
|
||||||
|
* @returns {string} Relative URL
|
||||||
|
*/
|
||||||
maintenanceURL(id) {
|
maintenanceURL(id) {
|
||||||
return getMaintenanceRelativeURL(id);
|
return getMaintenanceRelativeURL(id);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show delete confirmation
|
||||||
|
* @param {number} maintenanceID
|
||||||
|
*/
|
||||||
deleteDialog(maintenanceID) {
|
deleteDialog(maintenanceID) {
|
||||||
this.selectedMaintenanceID = maintenanceID;
|
this.selectedMaintenanceID = maintenanceID;
|
||||||
this.$refs.confirmDelete.show();
|
this.$refs.confirmDelete.show();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/** Delete maintenance after showing confirmation dialog */
|
||||||
deleteMaintenance() {
|
deleteMaintenance() {
|
||||||
this.$root.deleteMaintenance(this.selectedMaintenanceID, (res) => {
|
this.$root.deleteMaintenance(this.selectedMaintenanceID, (res) => {
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
|
16
src/util.js
16
src/util.js
@ -315,6 +315,11 @@ function getMonitorRelativeURL(id) {
|
|||||||
return "/dashboard/" + id;
|
return "/dashboard/" + id;
|
||||||
}
|
}
|
||||||
exports.getMonitorRelativeURL = getMonitorRelativeURL;
|
exports.getMonitorRelativeURL = getMonitorRelativeURL;
|
||||||
|
/**
|
||||||
|
* Get relative path for maintenance
|
||||||
|
* @param id ID of maintenance
|
||||||
|
* @returns Formatted relative path
|
||||||
|
*/
|
||||||
function getMaintenanceRelativeURL(id) {
|
function getMaintenanceRelativeURL(id) {
|
||||||
return "/maintenance/" + id;
|
return "/maintenance/" + id;
|
||||||
}
|
}
|
||||||
@ -361,6 +366,11 @@ function parseTimeFromTimeObject(obj) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
exports.parseTimeFromTimeObject = parseTimeFromTimeObject;
|
exports.parseTimeFromTimeObject = parseTimeFromTimeObject;
|
||||||
|
/**
|
||||||
|
* Convert ISO date to UTC
|
||||||
|
* @param input Date
|
||||||
|
* @returns ISO Date time
|
||||||
|
*/
|
||||||
function isoToUTCDateTime(input) {
|
function isoToUTCDateTime(input) {
|
||||||
return dayjs(input).utc().format(exports.SQL_DATETIME_FORMAT);
|
return dayjs(input).utc().format(exports.SQL_DATETIME_FORMAT);
|
||||||
}
|
}
|
||||||
@ -379,6 +389,12 @@ function utcToLocal(input, format = exports.SQL_DATETIME_FORMAT) {
|
|||||||
return dayjs.utc(input).local().format(format);
|
return dayjs.utc(input).local().format(format);
|
||||||
}
|
}
|
||||||
exports.utcToLocal = utcToLocal;
|
exports.utcToLocal = utcToLocal;
|
||||||
|
/**
|
||||||
|
* Convert local datetime to UTC
|
||||||
|
* @param input Local date
|
||||||
|
* @param format Format to return
|
||||||
|
* @returns Date in requested format
|
||||||
|
*/
|
||||||
function localToUTC(input, format = exports.SQL_DATETIME_FORMAT) {
|
function localToUTC(input, format = exports.SQL_DATETIME_FORMAT) {
|
||||||
return dayjs(input).utc().format(format);
|
return dayjs(input).utc().format(format);
|
||||||
}
|
}
|
||||||
|
17
src/util.ts
17
src/util.ts
@ -352,6 +352,11 @@ export function getMonitorRelativeURL(id: string) {
|
|||||||
return "/dashboard/" + id;
|
return "/dashboard/" + id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get relative path for maintenance
|
||||||
|
* @param id ID of maintenance
|
||||||
|
* @returns Formatted relative path
|
||||||
|
*/
|
||||||
export function getMaintenanceRelativeURL(id: string) {
|
export function getMaintenanceRelativeURL(id: string) {
|
||||||
return "/maintenance/" + id;
|
return "/maintenance/" + id;
|
||||||
}
|
}
|
||||||
@ -405,7 +410,11 @@ export function parseTimeFromTimeObject(obj : any) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert ISO date to UTC
|
||||||
|
* @param input Date
|
||||||
|
* @returns ISO Date time
|
||||||
|
*/
|
||||||
export function isoToUTCDateTime(input : string) {
|
export function isoToUTCDateTime(input : string) {
|
||||||
return dayjs(input).utc().format(SQL_DATETIME_FORMAT);
|
return dayjs(input).utc().format(SQL_DATETIME_FORMAT);
|
||||||
}
|
}
|
||||||
@ -424,6 +433,12 @@ export function utcToLocal(input : string, format = SQL_DATETIME_FORMAT) {
|
|||||||
return dayjs.utc(input).local().format(format);
|
return dayjs.utc(input).local().format(format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert local datetime to UTC
|
||||||
|
* @param input Local date
|
||||||
|
* @param format Format to return
|
||||||
|
* @returns Date in requested format
|
||||||
|
*/
|
||||||
export function localToUTC(input : string, format = SQL_DATETIME_FORMAT) {
|
export function localToUTC(input : string, format = SQL_DATETIME_FORMAT) {
|
||||||
return dayjs(input).utc().format(format);
|
return dayjs(input).utc().format(format);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user