feat: handleKueFirmwareUpdate
This commit is contained in:
@@ -6,6 +6,6 @@ NEXT_PUBLIC_USE_MOCK_BACKEND_LOOP_START=false
|
|||||||
NEXT_PUBLIC_EXPORT_STATIC=false
|
NEXT_PUBLIC_EXPORT_STATIC=false
|
||||||
NEXT_PUBLIC_USE_CGI=false
|
NEXT_PUBLIC_USE_CGI=false
|
||||||
# App-Versionsnummer
|
# App-Versionsnummer
|
||||||
NEXT_PUBLIC_APP_VERSION=1.6.507
|
NEXT_PUBLIC_APP_VERSION=1.6.509
|
||||||
NEXT_PUBLIC_CPL_MODE=json # json (Entwicklungsumgebung) oder jsSimulatedProd (CPL ->CGI-Interface-Simulator) oder production (CPL-> CGI-Interface Platzhalter)
|
NEXT_PUBLIC_CPL_MODE=json # json (Entwicklungsumgebung) oder jsSimulatedProd (CPL ->CGI-Interface-Simulator) oder production (CPL-> CGI-Interface Platzhalter)
|
||||||
|
|
||||||
|
|||||||
@@ -5,5 +5,5 @@ NEXT_PUBLIC_CPL_API_PATH=/CPL
|
|||||||
NEXT_PUBLIC_EXPORT_STATIC=true
|
NEXT_PUBLIC_EXPORT_STATIC=true
|
||||||
NEXT_PUBLIC_USE_CGI=true
|
NEXT_PUBLIC_USE_CGI=true
|
||||||
# App-Versionsnummer
|
# App-Versionsnummer
|
||||||
NEXT_PUBLIC_APP_VERSION=1.6.507
|
NEXT_PUBLIC_APP_VERSION=1.6.509
|
||||||
NEXT_PUBLIC_CPL_MODE=production
|
NEXT_PUBLIC_CPL_MODE=production
|
||||||
10
CHANGELOG.md
10
CHANGELOG.md
@@ -1,3 +1,13 @@
|
|||||||
|
## [1.6.509] – 2025-06-30
|
||||||
|
|
||||||
|
- feat: 1und 0 in Status in dashboard
|
||||||
|
|
||||||
|
---
|
||||||
|
## [1.6.508] – 2025-06-30
|
||||||
|
|
||||||
|
- feat: 1und 0 in Status in dashboard
|
||||||
|
|
||||||
|
---
|
||||||
## [1.6.507] – 2025-06-30
|
## [1.6.507] – 2025-06-30
|
||||||
|
|
||||||
- feat: Dashboard Meldungen Status 1 oder 0
|
- feat: Dashboard Meldungen Status 1 oder 0
|
||||||
|
|||||||
@@ -11,12 +11,14 @@ import { useDispatch } from "react-redux";
|
|||||||
import { AppDispatch } from "../../../redux/store";
|
import { AppDispatch } from "../../../redux/store";
|
||||||
import { getSystemSettingsThunk } from "../../../redux/thunks/getSystemSettingsThunk";
|
import { getSystemSettingsThunk } from "../../../redux/thunks/getSystemSettingsThunk";
|
||||||
import handleGeneralSubmit from "./handlers/handleGeneralSubmit";
|
import handleGeneralSubmit from "./handlers/handleGeneralSubmit";
|
||||||
|
import handleKueFirmwareUpdate from "@/components/main/settingsPageComponents/handlers/handleKueFirmwareUpdate";
|
||||||
|
|
||||||
const GeneralSettings: React.FC = () => {
|
const GeneralSettings: React.FC = () => {
|
||||||
const dispatch = useDispatch<AppDispatch>();
|
const dispatch = useDispatch<AppDispatch>();
|
||||||
const systemSettings = useSelector(
|
const systemSettings = useSelector(
|
||||||
(state: RootState) => state.systemSettingsSlice
|
(state: RootState) => state.systemSettingsSlice
|
||||||
);
|
);
|
||||||
|
const isAdmin = useSelector((state: RootState) => state.authSlice?.isAdmin);
|
||||||
|
|
||||||
// const [error, setError] = useState("");
|
// const [error, setError] = useState("");
|
||||||
|
|
||||||
@@ -192,6 +194,15 @@ const GeneralSettings: React.FC = () => {
|
|||||||
>
|
>
|
||||||
Neustart CPL
|
Neustart CPL
|
||||||
</button>
|
</button>
|
||||||
|
{isAdmin && (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="bg-red-600 text-white px-4 py-2 h-8 text-xs rounded whitespace-nowrap"
|
||||||
|
onClick={handleKueFirmwareUpdate}
|
||||||
|
>
|
||||||
|
Firmwareupdate alle KÜ-Module
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
// components/main/settingsPageComponents/handlers/handleKueFirmwareUpdate.ts
|
||||||
|
const handleKueFirmwareUpdate = async () => {
|
||||||
|
try {
|
||||||
|
const isDev =
|
||||||
|
typeof window !== "undefined" && window.location.hostname === "localhost";
|
||||||
|
const url = isDev
|
||||||
|
? "/api/cpl/kueFirmwareUpdateMock" // optional, falls du eine Mock-API hast
|
||||||
|
: "/CPL?Service/ae.ACP&KSU99=1";
|
||||||
|
|
||||||
|
const res = await fetch(url);
|
||||||
|
const result = await res.text();
|
||||||
|
|
||||||
|
console.log("Firmwareupdate gesendet:", result);
|
||||||
|
alert("Firmwareupdate wurde an alle KÜ-Module gesendet.");
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Fehler beim Firmwareupdate:", error);
|
||||||
|
alert("Fehler beim Firmwareupdate.");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default handleKueFirmwareUpdate;
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"timestamp": "2025-06-30T13:30:18.185Z",
|
||||||
|
"command": "&KSU99=1",
|
||||||
|
"message": "Firmwareupdate an alle KÜ-Module ausgelöst (Mock)"
|
||||||
|
}
|
||||||
|
]
|
||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "cpl-v4",
|
"name": "cpl-v4",
|
||||||
"version": "1.6.507",
|
"version": "1.6.509",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "cpl-v4",
|
"name": "cpl-v4",
|
||||||
"version": "1.6.507",
|
"version": "1.6.509",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fontsource/roboto": "^5.1.0",
|
"@fontsource/roboto": "^5.1.0",
|
||||||
"@iconify-icons/ri": "^1.2.10",
|
"@iconify-icons/ri": "^1.2.10",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "cpl-v4",
|
"name": "cpl-v4",
|
||||||
"version": "1.6.507",
|
"version": "1.6.509",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev",
|
"dev": "next dev",
|
||||||
|
|||||||
43
pages/api/cpl/kueFirmwareUpdateMock.ts
Normal file
43
pages/api/cpl/kueFirmwareUpdateMock.ts
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
import type { NextApiRequest, NextApiResponse } from "next";
|
||||||
|
import fs from "fs";
|
||||||
|
import path from "path";
|
||||||
|
|
||||||
|
export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||||
|
try {
|
||||||
|
const logFilePath = path.join(
|
||||||
|
process.cwd(),
|
||||||
|
"mocks/device-cgi-simulator/settings/kueFirmwareUpdateLog.json"
|
||||||
|
);
|
||||||
|
|
||||||
|
const timestamp = new Date().toISOString();
|
||||||
|
const logEntry = {
|
||||||
|
timestamp,
|
||||||
|
command: "&KSU99=1",
|
||||||
|
message: "Firmwareupdate an alle KÜ-Module ausgelöst (Mock)",
|
||||||
|
};
|
||||||
|
|
||||||
|
let existingLog = [];
|
||||||
|
if (fs.existsSync(logFilePath)) {
|
||||||
|
const fileContent = fs.readFileSync(logFilePath, "utf-8");
|
||||||
|
existingLog = JSON.parse(fileContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Letzten 50 Einträge speichern
|
||||||
|
const updatedLog = [logEntry, ...existingLog].slice(0, 50);
|
||||||
|
|
||||||
|
fs.writeFileSync(logFilePath, JSON.stringify(updatedLog, null, 2), "utf-8");
|
||||||
|
|
||||||
|
res.status(200).json({
|
||||||
|
status: "success",
|
||||||
|
log: logEntry,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Fehler beim Firmwareupdate-Mock:", error);
|
||||||
|
res
|
||||||
|
.status(500)
|
||||||
|
.json({
|
||||||
|
status: "error",
|
||||||
|
message: "Fehler beim Speichern des Firmwareupdates",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user