This commit is contained in:
Mason Coloretti 2024-07-31 15:58:31 +00:00 committed by GitHub
commit 045eb017de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 109 additions and 2 deletions

View file

@ -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",

View file

@ -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);

View file

@ -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") }}

View file

@ -0,0 +1,87 @@
<template>
<div>
<h1>Incident Reports</h1>
<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
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) {
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>

View file

@ -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,
},
],
},
],