From 407468ff143e247738fc11dcef12732ca9cbfa4b Mon Sep 17 00:00:00 2001 From: Mason Coloretti Date: Fri, 12 Jul 2024 21:00:28 -0600 Subject: [PATCH 1/6] added all functionallity for incident history --- db/kuma.db | Bin 61440 -> 0 bytes package.json | 2 +- server/server.js | 11 ++++- src/layouts/Layout.vue | 6 +++ src/pages/ListIncidents.vue | 81 ++++++++++++++++++++++++++++++++++++ src/router.js | 5 +++ 6 files changed, 103 insertions(+), 2 deletions(-) delete mode 100644 db/kuma.db create mode 100644 src/pages/ListIncidents.vue diff --git a/db/kuma.db b/db/kuma.db deleted file mode 100644 index 6e02ccc01fefc1d40029c18cbec08a6039cf723f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 61440 zcmeI)-EPxX0Kjp(?UFW-X4=Fe(MdJY5V2sREvlwznzqmymMu+7nob}TMWHdpT9cH- z;bW5~6_|K{UGHY^u&X`8?x#J)B)Dhi*vF3Dw1c)tBj{h0HaTBD=XXA>Sgc)rsQC-^b3pq#&aIFM-61iA&jw7xkw0ugVYZ!<|Si7W_)wx1Fs!?x3LH+6!}YUI}+PJvUzc zg~dg$`a7NOAfGIMvuih8yIF6F-{Pvp6>Gg(SXq-%-`fxGce+9+FbE21H6Co6c*1D0G&PHLQx>_uYZdtL)Rav1cs}-wwwd|(|)J&sdU9l=w zdC6KgJj}`eCh3+i}IB;{Vw* zCR8XRVdO_bNe+&UwPiWsmkR4kg=H&c?&j0UY++H~-E!JZ`+@51db{H~x1G&~>vY=n z17oJu@=+`=Ti1=72WPIOQ{vkDCaC4pDPs`jG;0?OFC<=tX3ad2)4mad*72&NW`eq8 zI$jYKS(6P8E?Udq41&$di9~jGR_}WyIW0Nm8*TTF-RQcv#AH7iFD*>qmlq}zB@Uv@ zjZ`9gW>$X~!*ZHo>J#xo11r&9ua;ptQEDX4e6%u^%q}kKPrmS`Zx9v5*)J@muI4Z7 zVTsXf3SL$qSllD4QMhcY-Uu!dO&+djk;N#ul*AEz7FmzfkQ*L^2lRJXt9>sMZ^W|NPp3!2W@2BE^(WsZW#TM|rigL@T8L{2MAMBf*_HAct-za}Str`EZ zpZaA4!+QwM-2F7+t@n>Ce-E%-*J*F{{6EQfQ&s3;TB$lv?1qsB%*~l$>y3?a@!E!^ z(up0uA5{=3RgB!qqeYnJ$H_#tFr#bUtP;l)asI70`fkVjTvv6i&#O0+(;w=;cpKaM z(b=NLZX(`L6?&M4h7AgaY^*!I1CZYpNAI)fRFWM!Jdf1AzRzl|Y84!#2J?uJ`B{S_Rip#uk*btQ$R4@t^_Uu>dpgA5KEflR zTp@BQiGS=+*>YmLYKv1o~mK*$A|Myqt}zCz&-6g z6!+MdX~Z2tw3)O?)OlXAEGx#pD_ZdBo$u~<1b!|>zuz+huNc-;#I zo*F9RZelP#!x0~yPvMMzyG`L+b<;}gg>E{Ol1Q0*~0R#|0009ILKmY**-eLjo z%l*uAE%Q9{XXX$2?=5aDO+x?y1Q0*~0R#|0009ILKw$I)GJk9D>CvairZWF%r*-w* z(wO*=*45()r~TG_FzG#wozll=CRGgI|BqhBQ)2`WKmY**5I_I{1Q0*~0R#>!kdhgA z{{OISq(=Y&1Q0*~0R#|0009ILKwzWEe|8Hi$P%8uwKmY**5I_I{1Q0*~0R&#B0RR8r>(rzy Y1Q0*~0R#|0009ILKmY**-b{gi0iFvt9RL6T diff --git a/package.json b/package.json index 31a89a7c7..44f9b59cf 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "build-docker-nightly-local": "npm run build && docker build -f docker/dockerfile -t louislam/uptime-kuma:nightly2 --target nightly .", "build-docker-pr-test": "docker buildx build -f docker/dockerfile --platform linux/amd64,linux/arm64 -t louislam/uptime-kuma:pr-test2 --target pr-test2 . --push", "upload-artifacts": "docker buildx build -f docker/dockerfile --platform linux/amd64 -t louislam/uptime-kuma:upload-artifact --build-arg VERSION --build-arg GITHUB_TOKEN --target upload-artifact . --progress plain", - "setup": "git checkout 1.23.13 && npm ci --production && npm run download-dist", + "setup": "npm ci --production && npm run download-dist", "download-dist": "node extra/download-dist.js", "mark-as-nightly": "node extra/mark-as-nightly.js", "reset-password": "node extra/reset-password.js", diff --git a/server/server.js b/server/server.js index 38158c546..ce0e6a2b5 100644 --- a/server/server.js +++ b/server/server.js @@ -283,6 +283,16 @@ let needSetup = false; const statusPageRouter = require("./routers/status-page-router"); app.use(statusPageRouter); + app.get("/api/incident-reports", async (req, res) => { + try { + const incidentReports = await R.findAll("incident"); + res.json(incidentReports); + } catch (error) { + console.error(error); + res.status(500).json({ error: "Failed to fetch incident reports" }); + } + }); + // Universal Route Handler, must be at the end of all express routes. app.get("*", async (_request, response) => { if (_request.originalUrl.startsWith("/upload/")) { @@ -358,7 +368,6 @@ let needSetup = false; } }); - socket.on("login", async (data, callback) => { const clientIP = await server.getClientIP(socket); diff --git a/src/layouts/Layout.vue b/src/layouts/Layout.vue index 9faedf589..2c3f0d556 100644 --- a/src/layouts/Layout.vue +++ b/src/layouts/Layout.vue @@ -57,6 +57,12 @@ +
  • + + {{ $t("Incident History") }} + +
  • +
  • {{ $t("Settings") }} diff --git a/src/pages/ListIncidents.vue b/src/pages/ListIncidents.vue new file mode 100644 index 000000000..02a169f96 --- /dev/null +++ b/src/pages/ListIncidents.vue @@ -0,0 +1,81 @@ + + + + + diff --git a/src/router.js b/src/router.js index 36cdeadae..2a0f62276 100644 --- a/src/router.js +++ b/src/router.js @@ -7,6 +7,7 @@ import DashboardHome from "./pages/DashboardHome.vue"; import Details from "./pages/Details.vue"; import EditMonitor from "./pages/EditMonitor.vue"; import EditMaintenance from "./pages/EditMaintenance.vue"; +import ListIncidents from "./pages/ListIncidents.vue"; import List from "./pages/List.vue"; const Settings = () => import("./pages/Settings.vue"); import Setup from "./pages/Setup.vue"; @@ -160,6 +161,10 @@ const routes = [ path: "/maintenance/edit/:id", component: EditMaintenance, }, + { + path: "/incident-history", + component: ListIncidents, + }, ], }, ], From fa1fa87391039c0592016a7fc8c14b5603b85fb5 Mon Sep 17 00:00:00 2001 From: Mason Coloretti Date: Fri, 12 Jul 2024 21:39:52 -0600 Subject: [PATCH 2/6] fixed reports list sorting --- src/pages/ListIncidents.vue | 93 +++++++++++++++++++------------------ 1 file changed, 47 insertions(+), 46 deletions(-) diff --git a/src/pages/ListIncidents.vue b/src/pages/ListIncidents.vue index 02a169f96..ca6de3c3e 100644 --- a/src/pages/ListIncidents.vue +++ b/src/pages/ListIncidents.vue @@ -1,60 +1,61 @@ - + From cad43c82a07b911a06f56d9ca44fc25881bff532 Mon Sep 17 00:00:00 2001 From: Mason Coloretti Date: Sun, 14 Jul 2024 18:51:18 -0600 Subject: [PATCH 5/6] fixed lint format --- src/pages/ListIncidents.vue | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/pages/ListIncidents.vue b/src/pages/ListIncidents.vue index 87294a901..0763871c4 100644 --- a/src/pages/ListIncidents.vue +++ b/src/pages/ListIncidents.vue @@ -29,6 +29,18 @@ export default { error: null, }; }, + computed: { + filteredReports() { + return this.incidentReports + .slice() // Create a copy to avoid mutating the original array + .sort( + (a, b) => + new Date(b._createdDate) - new Date(a._createdDate), + ) + .slice(-25); // Get the last 25 sorted reports + }, + }, + mounted() { this.fetchIncidentReports(); }, @@ -55,17 +67,6 @@ export default { }); }, }, - computed: { - filteredReports() { - return this.incidentReports - .slice() // Create a copy to avoid mutating the original array - .sort( - (a, b) => - new Date(b._createdDate) - new Date(a._createdDate), - ) - .slice(-25); // Get the last 25 sorted reports - }, - }, };