fix: hide Firmware update button if admin not loged in
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.510
|
NEXT_PUBLIC_APP_VERSION=1.6.511
|
||||||
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.510
|
NEXT_PUBLIC_APP_VERSION=1.6.511
|
||||||
NEXT_PUBLIC_CPL_MODE=production
|
NEXT_PUBLIC_CPL_MODE=production
|
||||||
@@ -1,3 +1,8 @@
|
|||||||
|
## [1.6.511] – 2025-07-01
|
||||||
|
|
||||||
|
- feat: alle KÜs Firmware update
|
||||||
|
|
||||||
|
---
|
||||||
## [1.6.510] – 2025-06-30
|
## [1.6.510] – 2025-06-30
|
||||||
|
|
||||||
- feat: handleKueFirmwareUpdate
|
- feat: handleKueFirmwareUpdate
|
||||||
|
|||||||
@@ -1,16 +1,24 @@
|
|||||||
|
// /komponents/main/kabelueberwachung/kue705FO/handlers/firmwareUpdate.ts
|
||||||
const firmwareUpdate = (slot: number) => {
|
const firmwareUpdate = (slot: number) => {
|
||||||
const url = `${window.location.origin}/CPL?/kabelueberwachung.html&KSU${slot}=1`;
|
const isDev =
|
||||||
|
typeof window !== "undefined" && window.location.hostname === "localhost";
|
||||||
|
const url = isDev
|
||||||
|
? `${window.location.origin}/api/cpl/kueSingleModuleUpdateMock?slot=${
|
||||||
|
slot + 1
|
||||||
|
}`
|
||||||
|
: `${window.location.origin}/CPL?/kabelueberwachung.html&KSU${slot}=1`;
|
||||||
|
|
||||||
fetch(url, { method: "GET" })
|
fetch(url, { method: "GET" })
|
||||||
.then((response) => {
|
.then((response) => response.json())
|
||||||
if (response.ok) {
|
.then((data) => {
|
||||||
alert(`Update an ${slot + 1} erfolgreich gestartet!`);
|
alert(
|
||||||
} else {
|
data.message || `Update an Slot ${slot + 1} erfolgreich gestartet!`
|
||||||
alert("Fehler beim Update!");
|
);
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error("Fehler:", error);
|
console.error("Fehler:", error);
|
||||||
alert("Fehler beim Update!");
|
alert("Fehler beim Update!");
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export default firmwareUpdate;
|
export default firmwareUpdate;
|
||||||
|
|||||||
@@ -246,7 +246,15 @@ export default function KueEinstellung({
|
|||||||
<div className="flex justify-end gap-2 p-0 rounded">
|
<div className="flex justify-end gap-2 p-0 rounded">
|
||||||
{isAdminLoggedIn && (
|
{isAdminLoggedIn && (
|
||||||
<button
|
<button
|
||||||
onClick={() => firmwareUpdate(slot)}
|
onClick={() => {
|
||||||
|
if (
|
||||||
|
window.confirm(
|
||||||
|
"Warnung: Das Firmware-Update kann einige Minuten dauern und das Gerät neu starten.\nMöchten Sie wirklich fortfahren?"
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
firmwareUpdate(slot);
|
||||||
|
}
|
||||||
|
}}
|
||||||
className="bg-littwin-blue text-white px-4 py-2 rounded flex items-center"
|
className="bg-littwin-blue text-white px-4 py-2 rounded flex items-center"
|
||||||
>
|
>
|
||||||
Firmware Update
|
Firmware Update
|
||||||
|
|||||||
@@ -12,15 +12,15 @@ 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";
|
import handleKueFirmwareUpdate from "@/components/main/settingsPageComponents/handlers/handleKueFirmwareUpdate";
|
||||||
|
import { useAdminAuth } from "@/components/main/settingsPageComponents/hooks/useAdminAuth";
|
||||||
|
|
||||||
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?.isAdminLoggedIn
|
const { isAdminLoggedIn } = useAdminAuth(true);
|
||||||
);
|
|
||||||
|
|
||||||
// const [error, setError] = useState("");
|
// const [error, setError] = useState("");
|
||||||
|
|
||||||
@@ -196,10 +196,10 @@ const GeneralSettings: React.FC = () => {
|
|||||||
>
|
>
|
||||||
Neustart CPL
|
Neustart CPL
|
||||||
</button>
|
</button>
|
||||||
{isAdmin && (
|
{isAdminLoggedIn && (
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="bg-red-600 text-white px-4 py-2 h-8 text-xs rounded whitespace-nowrap"
|
className="bg-littwin-blue text-white px-4 py-2 h-8 text-xs rounded whitespace-nowrap"
|
||||||
onClick={handleKueFirmwareUpdate}
|
onClick={handleKueFirmwareUpdate}
|
||||||
>
|
>
|
||||||
Firmwareupdate alle KÜ-Module
|
Firmwareupdate alle KÜ-Module
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"message": "Update erfolgreich gestartet für Slot X"
|
||||||
|
}
|
||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "cpl-v4",
|
"name": "cpl-v4",
|
||||||
"version": "1.6.510",
|
"version": "1.6.511",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "cpl-v4",
|
"name": "cpl-v4",
|
||||||
"version": "1.6.510",
|
"version": "1.6.511",
|
||||||
"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.510",
|
"version": "1.6.511",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev",
|
"dev": "next dev",
|
||||||
|
|||||||
25
pages/api/cpl/kueSingleModuleUpdateMock.ts
Normal file
25
pages/api/cpl/kueSingleModuleUpdateMock.ts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
// /pages/api/cpl/kueSingleModuleUpdateMock.ts
|
||||||
|
import type { NextApiRequest, NextApiResponse } from "next";
|
||||||
|
import fs from "fs";
|
||||||
|
import path from "path";
|
||||||
|
|
||||||
|
export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||||
|
const filePath = path.join(
|
||||||
|
process.cwd(),
|
||||||
|
"mocks/device-cgi-simulator/firmwareUpdate/singleModuleUpdateResponse.json"
|
||||||
|
);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const fileContents = fs.readFileSync(filePath, "utf-8");
|
||||||
|
const responseData = JSON.parse(fileContents);
|
||||||
|
|
||||||
|
// Optional: slot aus query übernehmen
|
||||||
|
const slot = req.query.slot ?? "X";
|
||||||
|
responseData.message = `Update erfolgreich gestartet für Slot ${slot}`;
|
||||||
|
|
||||||
|
res.status(200).json(responseData);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Fehler beim Lesen der Mock-Datei:", error);
|
||||||
|
res.status(500).json({ error: "Fehler beim Mock-Update" });
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user