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