feat: Charttitel in ChartSwitcher dynamisch an Slot-Typ angepasst via loopChartTypeSlice
- Neues Redux Slice erstellt zur Verwaltung des Titels - Dropdown-Auswahl in LoopChartActionBar aktualisiert Redux-Wert - ChartSwitcher verwendet dynamischen Titel statt statischem Text
This commit is contained in:
@@ -32,6 +32,9 @@ const ChartSwitcher: React.FC<ChartSwitcherProps> = ({
|
|||||||
slotIndex,
|
slotIndex,
|
||||||
}) => {
|
}) => {
|
||||||
const dispatch = useDispatch<AppDispatch>();
|
const dispatch = useDispatch<AppDispatch>();
|
||||||
|
const chartTitle = useSelector(
|
||||||
|
(state: RootState) => state.loopChartType.chartTitle
|
||||||
|
);
|
||||||
|
|
||||||
// **Redux-States für aktive Messkurve (TDR oder Schleife)**
|
// **Redux-States für aktive Messkurve (TDR oder Schleife)**
|
||||||
const activeMode = useSelector(
|
const activeMode = useSelector(
|
||||||
@@ -146,7 +149,7 @@ const ChartSwitcher: React.FC<ChartSwitcherProps> = ({
|
|||||||
>
|
>
|
||||||
{activeMode === "Schleife" ? (
|
{activeMode === "Schleife" ? (
|
||||||
<>
|
<>
|
||||||
<h3 className="text-lg font-semibold">Schleifenmessung</h3>
|
<h3 className="text-lg font-semibold">{chartTitle}</h3>
|
||||||
<LoopChartActionBar />
|
<LoopChartActionBar />
|
||||||
<div style={{ flex: 1, height: "90%" }}>
|
<div style={{ flex: 1, height: "90%" }}>
|
||||||
<LoopMeasurementChart />
|
<LoopMeasurementChart />
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
setChartOpen,
|
setChartOpen,
|
||||||
} from "../../../../../../redux/slices/kabelueberwachungChartSlice";
|
} from "../../../../../../redux/slices/kabelueberwachungChartSlice";
|
||||||
import { setBrushRange } from "../../../../../../redux/slices/brushSlice";
|
import { setBrushRange } from "../../../../../../redux/slices/brushSlice";
|
||||||
|
import { setChartTitle } from "../../../../../../redux/slices/loopChartTypeSlice";
|
||||||
|
|
||||||
const LoopChartActionBar: React.FC = () => {
|
const LoopChartActionBar: React.FC = () => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
@@ -154,13 +155,19 @@ const LoopChartActionBar: React.FC = () => {
|
|||||||
|
|
||||||
<select
|
<select
|
||||||
value={selectedSlotType}
|
value={selectedSlotType}
|
||||||
onChange={(e) =>
|
onChange={(e) => {
|
||||||
|
const value = e.target.value as
|
||||||
|
| "isolationswiderstand"
|
||||||
|
| "schleifenwiderstand";
|
||||||
|
dispatch(setSelectedSlotType(value));
|
||||||
dispatch(
|
dispatch(
|
||||||
setSelectedSlotType(
|
setChartTitle(
|
||||||
e.target.value as "isolationswiderstand" | "schleifenwiderstand"
|
value === "isolationswiderstand"
|
||||||
|
? "Isolationsmessung"
|
||||||
|
: "Schleifenmessung"
|
||||||
)
|
)
|
||||||
)
|
);
|
||||||
}
|
}}
|
||||||
className="px-3 py-1 bg-white border rounded text-sm"
|
className="px-3 py-1 bg-white border rounded text-sm"
|
||||||
>
|
>
|
||||||
<option value="schleifenwiderstand">Schleifenwiderstand</option>
|
<option value="schleifenwiderstand">Schleifenwiderstand</option>
|
||||||
|
|||||||
@@ -6,5 +6,5 @@
|
|||||||
2: Patch oder Hotfix (Bugfixes oder kleine Änderungen).
|
2: Patch oder Hotfix (Bugfixes oder kleine Änderungen).
|
||||||
|
|
||||||
*/
|
*/
|
||||||
const webVersion = "1.6.198";
|
const webVersion = "1.6.199";
|
||||||
export default webVersion;
|
export default webVersion;
|
||||||
|
|||||||
23
redux/slices/loopChartTypeSlice.ts
Normal file
23
redux/slices/loopChartTypeSlice.ts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
// redux/slices/loopChartTypeSlice.ts
|
||||||
|
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||||||
|
|
||||||
|
interface LoopChartTypeState {
|
||||||
|
chartTitle: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const initialState: LoopChartTypeState = {
|
||||||
|
chartTitle: "Schleifenmessung", // Standardwert
|
||||||
|
};
|
||||||
|
|
||||||
|
const loopChartTypeSlice = createSlice({
|
||||||
|
name: "loopChartType",
|
||||||
|
initialState,
|
||||||
|
reducers: {
|
||||||
|
setChartTitle: (state, action: PayloadAction<string>) => {
|
||||||
|
state.chartTitle = action.payload;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export const { setChartTitle } = loopChartTypeSlice.actions;
|
||||||
|
export default loopChartTypeSlice.reducer;
|
||||||
@@ -21,6 +21,7 @@ import kueDataReducer from "./slices/kueDataSlice";
|
|||||||
import selectedChartDataReducer from "./slices/selectedChartDataSlice";
|
import selectedChartDataReducer from "./slices/selectedChartDataSlice";
|
||||||
import tdmSingleChartReducer from "./slices/tdmSingleChartSlice";
|
import tdmSingleChartReducer from "./slices/tdmSingleChartSlice";
|
||||||
import tdrReferenceChartDataBySlotReducer from "./slices/tdrReferenceChartDataBySlotSlice";
|
import tdrReferenceChartDataBySlotReducer from "./slices/tdrReferenceChartDataBySlotSlice";
|
||||||
|
import loopChartTypeSlice from "./slices/loopChartTypeSlice";
|
||||||
|
|
||||||
const store = configureStore({
|
const store = configureStore({
|
||||||
reducer: {
|
reducer: {
|
||||||
@@ -44,6 +45,7 @@ const store = configureStore({
|
|||||||
selectedChartDataSlice: selectedChartDataReducer,
|
selectedChartDataSlice: selectedChartDataReducer,
|
||||||
tdmSingleChartSlice: tdmSingleChartReducer,
|
tdmSingleChartSlice: tdmSingleChartReducer,
|
||||||
tdrReferenceChartDataBySlotSlice: tdrReferenceChartDataBySlotReducer,
|
tdrReferenceChartDataBySlotSlice: tdrReferenceChartDataBySlotReducer,
|
||||||
|
loopChartType: loopChartTypeSlice,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user