Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added Incident report History #4943

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
MasonColoretti marked this conversation as resolved.
Show resolved Hide resolved
"download-dist": "node extra/download-dist.js",
"mark-as-nightly": "node extra/mark-as-nightly.js",
"reset-password": "node extra/reset-password.js",
Expand Down
11 changes: 10 additions & 1 deletion server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/")) {
Expand Down Expand Up @@ -358,7 +368,6 @@ let needSetup = false;
}

});

socket.on("login", async (data, callback) => {
const clientIP = await server.getClientIP(socket);

Expand Down
6 changes: 6 additions & 0 deletions src/layouts/Layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@
</router-link>
</li>

<li>
<router-link to="/incident-history" class="dropdown-item" :class="{ active: $route.path.includes('manage-incident-history') }">
<font-awesome-icon icon="bullhorn" /> {{ $t("Incident History") }}
</router-link>
</li>

<li>
<router-link to="/settings/general" class="dropdown-item" :class="{ active: $route.path.includes('settings') }">
<font-awesome-icon icon="cog" /> {{ $t("Settings") }}
Expand Down
87 changes: 87 additions & 0 deletions src/pages/ListIncidents.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<template>
<div>
<h1>Incident Reports</h1>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, our transaltors could not translate this string.
Please use {{ $t("Incident Reports") }} instead and add this key to the en.json.

There are a few other cases of this as well

<div v-if="isLoading">Loading...</div>
<div v-else-if="filteredReports.length">
<div
v-for="report in filteredReports"
:key="report._id"
class="big-padding"
>
<h3>{{ formatDate(report._createdDate) }}</h3>
<hr />
<h4>{{ report._title }}</h4>
<p>{{ report._content }}</p>
<hr />
<br /><br />
</div>
</div>
<p v-else>No incident reports found or an error occurred.</p>
</div>
</template>

<script>
export default {
data() {
return {
incidentReports: [],
isLoading: false,
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();
},
methods: {
async fetchIncidentReports() {
this.isLoading = true;
try {
const response = await fetch("/api/incident-reports"); // Replace with your API endpoint
MasonColoretti marked this conversation as resolved.
Show resolved Hide resolved
const data = await response.json();
this.incidentReports = data;
} catch (error) {
this.error = error;
console.error("Error fetching incident reports:", error);
} finally {
this.isLoading = false;
}
},
formatDate(dateString) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const date = new Date(dateString);
return date.toLocaleDateString("en-US", {
year: "numeric",
month: "long",
day: "numeric",
});
},
},
};
</script>
<style>
.incident-report-container {
display: flex;
flex-direction: column;
gap: 10px; /* Adjust gap between boxes */
}

.incident-report {
background-color: #fff;
border-radius: 10px;
padding: 20px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

</style>

5 changes: 5 additions & 0 deletions src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -160,6 +161,10 @@ const routes = [
path: "/maintenance/edit/:id",
component: EditMaintenance,
},
{
path: "/incident-history",
component: ListIncidents,
},
],
},
],
Expand Down
Loading