addressed issues and changes requested

This commit is contained in:
Mason Coloretti 2024-08-17 00:30:08 -06:00
parent 2fa6d6725a
commit 7ae2f1bb31
5 changed files with 69 additions and 44 deletions

16
package-lock.json generated
View file

@ -11299,22 +11299,6 @@
"smart-buffer": "^4.1.0" "smart-buffer": "^4.1.0"
} }
}, },
"node_modules/node-abi": {
"version": "3.62.0",
"resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.62.0.tgz",
"integrity": "sha512-CPMcGa+y33xuL1E0TcNIu4YyaZCxnnvkVaEXrsosR3FxN+fV8xvb7Mzpb7IgKler10qeMkE6+Dp8qJhpzdq35g==",
"dependencies": {
"semver": "^7.3.5"
},
"engines": {
"node": ">=10"
}
},
"node_modules/node-abort-controller": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/node-abort-controller/-/node-abort-controller-3.1.1.tgz",
"integrity": "sha512-AGK2yQKIjRuqnc6VkX2Xj5d+QW8xZ87pa1UK6yA6ouUyuxfHuMP6umE5QK7UmTeOAymo+Zx1Fxiuw9rVx8taHQ=="
},
"node_modules/node-cloudflared-tunnel": { "node_modules/node-cloudflared-tunnel": {
"version": "1.0.10", "version": "1.0.10",
"resolved": "https://registry.npmjs.org/node-cloudflared-tunnel/-/node-cloudflared-tunnel-1.0.10.tgz", "resolved": "https://registry.npmjs.org/node-cloudflared-tunnel/-/node-cloudflared-tunnel-1.0.10.tgz",

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-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", "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", "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": "npm ci --production && npm run download-dist", "setup": "git checkout 1.23.13 && npm ci --production && npm run download-dist",
"download-dist": "node extra/download-dist.js", "download-dist": "node extra/download-dist.js",
"mark-as-nightly": "node extra/mark-as-nightly.js", "mark-as-nightly": "node extra/mark-as-nightly.js",
"reset-password": "node extra/reset-password.js", "reset-password": "node extra/reset-password.js",

View file

@ -283,16 +283,6 @@ let needSetup = false;
const statusPageRouter = require("./routers/status-page-router"); const statusPageRouter = require("./routers/status-page-router");
app.use(statusPageRouter); 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. // Universal Route Handler, must be at the end of all express routes.
app.get("*", async (_request, response) => { app.get("*", async (_request, response) => {
if (_request.originalUrl.startsWith("/upload/")) { if (_request.originalUrl.startsWith("/upload/")) {
@ -672,6 +662,16 @@ let needSetup = false;
} }
}); });
socket.on("fetchIncidentReports", async () => {
try {
const incidentReports = await R.findAll("incident");
socket.emit("incidentReports", incidentReports);
} catch (error) {
console.error(error);
socket.emit("incidentReportsError", { error: "Failed to fetch incident reports" });
}
});
// *************************** // ***************************
// Auth Only API // Auth Only API
// *************************** // ***************************
@ -729,7 +729,9 @@ let needSetup = false;
}); });
} }
}); });
socket.on("incidentReports", async (monitor,callback) => {
});
// Edit a monitor // Edit a monitor
socket.on("editMonitor", async (monitor, callback) => { socket.on("editMonitor", async (monitor, callback) => {
try { try {

View file

@ -1,6 +1,6 @@
<template> <template>
<div> <div>
<h1>Incident Reports</h1> <h1>{{ $t("Incident Reports") }}</h1>
<div v-if="isLoading">Loading...</div> <div v-if="isLoading">Loading...</div>
<div v-else-if="filteredReports.length"> <div v-else-if="filteredReports.length">
<div <div
@ -8,7 +8,7 @@
:key="report._id" :key="report._id"
class="big-padding" class="big-padding"
> >
<h3>{{ formatDate(report._createdDate) }}</h3> <h3>{{ datetimeFormat(report._createdDate) }}</h3>
<hr /> <hr />
<h4>{{ report._title }}</h4> <h4>{{ report._title }}</h4>
<p>{{ report._content }}</p> <p>{{ report._content }}</p>
@ -58,14 +58,6 @@ export default {
this.isLoading = false; this.isLoading = false;
} }
}, },
formatDate(dateString) {
const date = new Date(dateString);
return date.toLocaleDateString("en-US", {
year: "numeric",
month: "long",
day: "numeric",
});
},
}, },
}; };
</script> </script>

View file

@ -41,7 +41,6 @@
{{ $t("Refresh Interval Description", [config.autoRefreshInterval]) }} {{ $t("Refresh Interval Description", [config.autoRefreshInterval]) }}
</div> </div>
</div> </div>
<div class="my-3"> <div class="my-3">
<label for="switch-theme" class="form-label">{{ $t("Theme") }}</label> <label for="switch-theme" class="form-label">{{ $t("Theme") }}</label>
<select id="switch-theme" v-model="config.theme" class="form-select"> <select id="switch-theme" v-model="config.theme" class="form-select">
@ -326,7 +325,25 @@
<!-- 👀 Nothing here, please add a group or a monitor. --> <!-- 👀 Nothing here, please add a group or a monitor. -->
👀 {{ $t("statusPageNothing") }} 👀 {{ $t("statusPageNothing") }}
</div> </div>
<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>{{ (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>
<PublicGroupList :edit-mode="enableEditMode" :show-tags="config.showTags" :show-certificate-expiry="config.showCertificateExpiry" /> <PublicGroupList :edit-mode="enableEditMode" :show-tags="config.showTags" :show-certificate-expiry="config.showCertificateExpiry" />
</div> </div>
@ -378,12 +395,15 @@ import DOMPurify from "dompurify";
import Confirm from "../components/Confirm.vue"; import Confirm from "../components/Confirm.vue";
import PublicGroupList from "../components/PublicGroupList.vue"; import PublicGroupList from "../components/PublicGroupList.vue";
import MaintenanceTime from "../components/MaintenanceTime.vue"; import MaintenanceTime from "../components/MaintenanceTime.vue";
import dateTime from "../mixins/datetime.js";
import { getResBaseURL } from "../util-frontend"; import { getResBaseURL } from "../util-frontend";
import { STATUS_PAGE_ALL_DOWN, STATUS_PAGE_ALL_UP, STATUS_PAGE_MAINTENANCE, STATUS_PAGE_PARTIAL_DOWN, UP, MAINTENANCE } from "../util.ts"; import { STATUS_PAGE_ALL_DOWN, STATUS_PAGE_ALL_UP, STATUS_PAGE_MAINTENANCE, STATUS_PAGE_PARTIAL_DOWN, UP, MAINTENANCE } from "../util.ts";
import Tag from "../components/Tag.vue"; import Tag from "../components/Tag.vue";
import VueMultiselect from "vue-multiselect"; import VueMultiselect from "vue-multiselect";
import io from "socket.io-client";
const toast = useToast(); const toast = useToast();
dayjs.extend(duration); dayjs.extend(duration);
const leavePageMsg = "Do you really want to leave? you have unsaved changes!"; const leavePageMsg = "Do you really want to leave? you have unsaved changes!";
@ -406,7 +426,7 @@ export default {
Tag, Tag,
VueMultiselect VueMultiselect
}, },
mixins: [ dateTime ],
// Leave Page for vue route change // Leave Page for vue route change
beforeRouteLeave(to, from, next) { beforeRouteLeave(to, from, next) {
if (this.editMode) { if (this.editMode) {
@ -428,7 +448,6 @@ export default {
default: null, default: null,
}, },
}, },
data() { data() {
return { return {
slug: null, slug: null,
@ -450,10 +469,24 @@ export default {
updateCountdown: null, updateCountdown: null,
updateCountdownText: null, updateCountdownText: null,
loading: true, loading: true,
isLoading: false,
incidentReports: [],
error: null,
}; };
}, },
computed: { computed: {
filteredReports() {
for (let reports in this.incidentReports) {
this.datetime(reports._createdDate);
}
return this.incidentReports
.slice()
.sort(
(a, b) =>
new Date(b._createdDate) - new Date(a._createdDate),
)
.slice(-25);
},
logoURL() { logoURL() {
if (this.imgDataUrl.startsWith("data:")) { if (this.imgDataUrl.startsWith("data:")) {
return this.imgDataUrl; return this.imgDataUrl;
@ -461,7 +494,6 @@ export default {
return this.baseURL + this.imgDataUrl; return this.baseURL + this.imgDataUrl;
} }
}, },
/** /**
* If the monitor is added to public list, which will not be in this list. * If the monitor is added to public list, which will not be in this list.
* @returns {object[]} List of monitors * @returns {object[]} List of monitors
@ -730,7 +762,7 @@ export default {
}); });
this.updateHeartbeatList(); this.updateHeartbeatList();
this.fetchIncidentReports();
// Go to edit page if ?edit present // Go to edit page if ?edit present
// null means ?edit present, but no value // null means ?edit present, but no value
if (this.$route.query.edit || this.$route.query.edit === null) { if (this.$route.query.edit || this.$route.query.edit === null) {
@ -796,7 +828,22 @@ export default {
}); });
} }
}, },
async fetchIncidentReports() {
const socket = io();
this.isLoading = true;
socket.emit("fetchIncidentReports");
socket.on("incidentReports", (data) => {
this.incidentReports = data;
this.isLoading = false;
});
socket.on("incidentReportsError", (error) => {
this.error = error;
console.error("", error);
this.isLoading = false;
});
},
/** /**
* Setup timer to display countdown to refresh * Setup timer to display countdown to refresh
* @returns {void} * @returns {void}