|
|
|
@ -6,6 +6,7 @@ class StatusPage extends BeanModel {
|
|
|
|
|
static domainMappingList = { };
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Loads domain mapping from DB
|
|
|
|
|
* Return object like this: { "test-uptime.kuma.pet": "default" }
|
|
|
|
|
* @returns {Promise<void>}
|
|
|
|
|
*/
|
|
|
|
@ -17,6 +18,12 @@ class StatusPage extends BeanModel {
|
|
|
|
|
`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Send status page list to client
|
|
|
|
|
* @param {Server} io io Socket server instance
|
|
|
|
|
* @param {Socket} socket Socket.io instance
|
|
|
|
|
* @returns {Promise<Bean[]>}
|
|
|
|
|
*/
|
|
|
|
|
static async sendStatusPageList(io, socket) {
|
|
|
|
|
let result = {};
|
|
|
|
|
|
|
|
|
@ -30,6 +37,11 @@ class StatusPage extends BeanModel {
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Update list of domain names
|
|
|
|
|
* @param {Array<string>} domainNameList
|
|
|
|
|
* @returns {Promise<void>}
|
|
|
|
|
*/
|
|
|
|
|
async updateDomainNameList(domainNameList) {
|
|
|
|
|
|
|
|
|
|
if (!Array.isArray(domainNameList)) {
|
|
|
|
@ -69,6 +81,10 @@ class StatusPage extends BeanModel {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get list of domain names
|
|
|
|
|
* @returns {Array<Object>}
|
|
|
|
|
*/
|
|
|
|
|
getDomainNameList() {
|
|
|
|
|
let domainList = [];
|
|
|
|
|
for (let domain in StatusPage.domainMappingList) {
|
|
|
|
@ -81,6 +97,10 @@ class StatusPage extends BeanModel {
|
|
|
|
|
return domainList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Return a object that ready to parse to JSON
|
|
|
|
|
* @returns {Object}
|
|
|
|
|
*/
|
|
|
|
|
async toJSON() {
|
|
|
|
|
return {
|
|
|
|
|
id: this.id,
|
|
|
|
@ -98,6 +118,11 @@ class StatusPage extends BeanModel {
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Return a object that ready to parse to JSON for public
|
|
|
|
|
* Only show necessary data to public
|
|
|
|
|
* @returns {Object}
|
|
|
|
|
*/
|
|
|
|
|
async toPublicJSON() {
|
|
|
|
|
return {
|
|
|
|
|
slug: this.slug,
|
|
|
|
@ -113,12 +138,20 @@ class StatusPage extends BeanModel {
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Convert slug to status page ID
|
|
|
|
|
* @param {string} slug
|
|
|
|
|
*/
|
|
|
|
|
static async slugToID(slug) {
|
|
|
|
|
return await R.getCell("SELECT id FROM status_page WHERE slug = ? ", [
|
|
|
|
|
slug
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get path to the icon for the page
|
|
|
|
|
* @returns {string}
|
|
|
|
|
*/
|
|
|
|
|
getIcon() {
|
|
|
|
|
if (!this.icon) {
|
|
|
|
|
return "/icon.svg";
|
|
|
|
|