feat(frontend): enforce RBAC and refine burst analysis
This commit is contained in:
@@ -29,6 +29,8 @@ import { FiSkipBack, FiSkipForward } from "react-icons/fi";
|
||||
import { useData } from "../MapComponent";
|
||||
import { config, NETWORK_NAME } from "@/config/config";
|
||||
import { apiFetch } from "@/lib/apiFetch";
|
||||
import { permissionCodes } from "@/lib/permissions";
|
||||
import { useAccessStore } from "@/store/accessStore";
|
||||
import { useMap } from "../MapComponent";
|
||||
import {
|
||||
formatTimelineTime,
|
||||
@@ -81,6 +83,9 @@ const Timeline: React.FC<TimelineProps> = ({
|
||||
schemeType = "burst_analysis",
|
||||
}) => {
|
||||
const data = useData();
|
||||
const canRunSimulation = useAccessStore((state) =>
|
||||
state.permissions.includes(permissionCodes.simulationRun),
|
||||
);
|
||||
const fallbackSelectedDateRef = useRef(new Date());
|
||||
const hasTimelineState =
|
||||
data &&
|
||||
@@ -926,35 +931,35 @@ const Timeline: React.FC<TimelineProps> = ({
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
</Box>
|
||||
<Box sx={{ display: "flex", gap: 1 }} className="ml-4">
|
||||
{/* 强制计算时间段 */}
|
||||
<FormControl size="small" sx={{ minWidth: 100 }}>
|
||||
<InputLabel>计算时间段</InputLabel>
|
||||
<Select
|
||||
value={calculatedInterval}
|
||||
label="强制计算时间段"
|
||||
onChange={handleCalculatedIntervalChange}
|
||||
>
|
||||
{resolvedCalculatedIntervalOptions.map((option) => (
|
||||
<MenuItem key={option.value} value={option.value}>
|
||||
{option.label}
|
||||
</MenuItem>
|
||||
))}
|
||||
</Select>
|
||||
</FormControl>
|
||||
{canRunSimulation && (
|
||||
<Box sx={{ display: "flex", gap: 1 }} className="ml-4">
|
||||
<FormControl size="small" sx={{ minWidth: 100 }}>
|
||||
<InputLabel>计算时间段</InputLabel>
|
||||
<Select
|
||||
value={calculatedInterval}
|
||||
label="强制计算时间段"
|
||||
onChange={handleCalculatedIntervalChange}
|
||||
>
|
||||
{resolvedCalculatedIntervalOptions.map((option) => (
|
||||
<MenuItem key={option.value} value={option.value}>
|
||||
{option.label}
|
||||
</MenuItem>
|
||||
))}
|
||||
</Select>
|
||||
</FormControl>
|
||||
|
||||
{/* 功能按钮 */}
|
||||
<Tooltip title="强制计算">
|
||||
<Button
|
||||
variant="outlined"
|
||||
startIcon={<Refresh />}
|
||||
onClick={handleForceCalculate}
|
||||
disabled={isCalculating}
|
||||
>
|
||||
强制计算
|
||||
</Button>
|
||||
</Tooltip>
|
||||
</Box>
|
||||
<Tooltip title="强制计算">
|
||||
<Button
|
||||
variant="outlined"
|
||||
startIcon={<Refresh />}
|
||||
onClick={handleForceCalculate}
|
||||
disabled={isCalculating}
|
||||
>
|
||||
强制计算
|
||||
</Button>
|
||||
</Tooltip>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{/* 当前时间显示 */}
|
||||
<Typography
|
||||
|
||||
@@ -29,6 +29,8 @@ import { useStyleEditor } from "./useStyleEditor";
|
||||
import { config, NETWORK_NAME } from "@/config/config";
|
||||
import { useProject } from "@/contexts/ProjectContext";
|
||||
import { apiFetch } from "@/lib/apiFetch";
|
||||
import { permissionCodes } from "@/lib/permissions";
|
||||
import { useAccessStore } from "@/store/accessStore";
|
||||
|
||||
// 添加接口定义隐藏按钮的props
|
||||
interface ToolbarProps {
|
||||
@@ -94,6 +96,9 @@ const Toolbar: React.FC<ToolbarProps> = ({
|
||||
const map = useMap();
|
||||
const data = useData();
|
||||
const project = useProject();
|
||||
const canEditNetwork = useAccessStore((state) =>
|
||||
state.permissions.includes(permissionCodes.webgisEdit),
|
||||
);
|
||||
const { open } = useNotification();
|
||||
const [activeTools, setActiveTools] = useState<string[]>([]);
|
||||
const [highlightFeatures, setHighlightFeatures] = useState<Feature[]>([]);
|
||||
@@ -119,6 +124,15 @@ const Toolbar: React.FC<ToolbarProps> = ({
|
||||
}
|
||||
}, [enableCompare, isCompareMode, toggleCompareMode]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!canEditNetwork) {
|
||||
setShowDrawPanel(false);
|
||||
setActiveTools((previous) =>
|
||||
previous.filter((tool) => tool !== "draw"),
|
||||
);
|
||||
}
|
||||
}, [canEditNetwork]);
|
||||
|
||||
// Chat tool action → direct featureInfos override (bypasses OL Feature lookup)
|
||||
const [chatPanelFeatureInfos, setChatPanelFeatureInfos] = useState<
|
||||
[string, string][] | null
|
||||
@@ -697,7 +711,7 @@ const Toolbar: React.FC<ToolbarProps> = ({
|
||||
buildFeatureProperties(
|
||||
selectedFeature,
|
||||
computedProperties,
|
||||
selectedValveId
|
||||
canEditNetwork && selectedValveId
|
||||
? {
|
||||
value: valveStatus,
|
||||
loading: isValveStatusLoading,
|
||||
@@ -705,7 +719,7 @@ const Toolbar: React.FC<ToolbarProps> = ({
|
||||
onSave: handleValveStatusSave,
|
||||
}
|
||||
: undefined,
|
||||
selectedValveId
|
||||
canEditNetwork && selectedValveId
|
||||
? {
|
||||
value: valveProperties.setting,
|
||||
vType: selectedValveType,
|
||||
@@ -719,6 +733,7 @@ const Toolbar: React.FC<ToolbarProps> = ({
|
||||
[
|
||||
selectedFeature,
|
||||
computedProperties,
|
||||
canEditNetwork,
|
||||
selectedValveId,
|
||||
valveStatus,
|
||||
valveProperties,
|
||||
@@ -755,7 +770,7 @@ const Toolbar: React.FC<ToolbarProps> = ({
|
||||
onClick={() => handleToolClick("history")}
|
||||
/>
|
||||
)}
|
||||
{!hiddenButtons?.includes("draw") && (
|
||||
{canEditNetwork && !hiddenButtons?.includes("draw") && (
|
||||
<ToolbarButton
|
||||
icon={<EditOutlinedIcon />}
|
||||
name="标记绘制"
|
||||
|
||||
Reference in New Issue
Block a user