diff --git a/server/model/monitor.js b/server/model/monitor.js index b2fed86f5..fbed48f94 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -96,11 +96,15 @@ class Monitor extends BeanModel { screenshot = "/screenshots/" + jwt.sign(this.id, UptimeKumaServer.getInstance().jwtSecret) + ".png"; } + const path = await this.getPath(); + const pathName = path.join(" / "); + let data = { id: this.id, name: this.name, description: this.description, - pathName: await this.getPathName(), + path, + pathName, parent: this.parent, childrenIDs: await Monitor.getAllChildrenIDs(this.id), url: this.url, @@ -1527,11 +1531,11 @@ class Monitor extends BeanModel { } /** - * Gets Full Path-Name (Groups and Name) - * @returns {Promise} Full path name of this monitor + * Gets the full path + * @returns {Promise} Full path (includes groups and the name) of the monitor */ - async getPathName() { - let path = this.name; + async getPath() { + const path = [ this.name ]; if (this.parent === null) { return path; @@ -1539,7 +1543,7 @@ class Monitor extends BeanModel { let parent = await Monitor.getParent(this.id); while (parent !== null) { - path = `${parent.name} / ${path}`; + path.unshift(parent.name); parent = await Monitor.getParent(parent.id); } diff --git a/src/pages/Details.vue b/src/pages/Details.vue index 1eb9a7f62..8582b82c2 100644 --- a/src/pages/Details.vue +++ b/src/pages/Details.vue @@ -390,10 +390,7 @@ export default { }, group() { - if (!this.monitor.pathName.includes("/")) { - return ""; - } - return this.monitor.pathName.substr(0, this.monitor.pathName.lastIndexOf("/")); + return this.monitor.path.slice(0, -1).join(" / "); }, pushURL() { diff --git a/src/pages/EditMonitor.vue b/src/pages/EditMonitor.vue index 666162991..72cb181e7 100644 --- a/src/pages/EditMonitor.vue +++ b/src/pages/EditMonitor.vue @@ -1395,6 +1395,7 @@ message HealthCheckResponse { // group monitor fields this.monitor.childrenIDs = undefined; this.monitor.forceInactive = undefined; + this.monitor.path = undefined; this.monitor.pathName = undefined; this.monitor.screenshot = undefined;