Integrate GF3 SARscape flood workflow
This commit is contained in:
+16
-2
@@ -1358,12 +1358,27 @@ function App() {
|
||||
}
|
||||
}, []);
|
||||
|
||||
const updateRadarPreviewVisibility = useCallback((item, shouldBeVisible) => {
|
||||
const updateRadarPreviewVisibility = useCallback(async (item, shouldBeVisible) => {
|
||||
if (!item || !mapRef.current) return;
|
||||
const itemId = item.id;
|
||||
const layer = radarPreviewLayersRef.current[itemId];
|
||||
|
||||
if (shouldBeVisible) {
|
||||
const refreshedStatus = await fetchRadarPreviewStatus(itemId, { silent: true });
|
||||
if (refreshedStatus) {
|
||||
item = {
|
||||
...item,
|
||||
previewStatus: normalizePreviewStatus(refreshedStatus.status),
|
||||
previewFallbackInUse: !!refreshedStatus.fallback_in_use,
|
||||
previewHasGeoCache: !!refreshedStatus.has_geo_cache,
|
||||
previewHasRawCache: !!refreshedStatus.has_raw_cache,
|
||||
previewSourceFound: !!refreshedStatus.source_found,
|
||||
previewMessage: refreshedStatus.message || '',
|
||||
previewError: refreshedStatus.error || '',
|
||||
previewCacheKey: refreshedStatus.cache_updated_at || item.previewCacheKey || `${Date.now()}-${itemId}`,
|
||||
};
|
||||
}
|
||||
|
||||
if (layer) {
|
||||
if (!mapRef.current.hasLayer(layer)) {
|
||||
layer.addTo(mapRef.current);
|
||||
@@ -1393,7 +1408,6 @@ function App() {
|
||||
|
||||
radarPreviewLayersRef.current[itemId] = previewLayer;
|
||||
previewLayer.addTo(mapRef.current);
|
||||
fetchRadarPreviewStatus(itemId, { silent: true });
|
||||
} else if (layer) {
|
||||
layer.remove();
|
||||
delete radarPreviewLayersRef.current[itemId];
|
||||
|
||||
@@ -132,6 +132,7 @@ export default function AssetInventoryPanel({ readOnly = false, onTaskStart }) {
|
||||
<option value="all">全部卫星族</option>
|
||||
<option value="S1">Sentinel-1</option>
|
||||
<option value="LT1">LT-1</option>
|
||||
<option value="GF3">GF3</option>
|
||||
</select>
|
||||
<button type="button" onClick={() => refresh()} disabled={loading}>刷新</button>
|
||||
<button type="button" onClick={handleScan} disabled={readOnly || scanLoading}>扫描资产</button>
|
||||
|
||||
@@ -9,7 +9,14 @@ const DEFAULT_MONITOR_CONFIG = {
|
||||
dinsar_dirs: [],
|
||||
gf3_archive_source_dirs: [],
|
||||
gf3_source_dirs: [],
|
||||
gf3_sarscape_native_dirs: [],
|
||||
gf3_storage_dirs: [],
|
||||
gf3_sarscape_wrapper_exe: '',
|
||||
gf3_sarscape_idlrt_path: '',
|
||||
gf3_sarscape_dem_path: '',
|
||||
gf3_sarscape_polarizations: 'HH,HV',
|
||||
gf3_sarscape_auto_standardize: true,
|
||||
gf3_sarscape_clean_after_success: true,
|
||||
s1_source_dirs: [],
|
||||
s1_storage_dirs: [],
|
||||
s1_orbit_dirs: [],
|
||||
@@ -68,6 +75,9 @@ const DataMonitorPanel = ({ apiEndpoint, onTaskStart, readOnly = false, enabled
|
||||
const [s1Message, setS1Message] = useState('');
|
||||
const [gf3UnpackLoading, setGf3UnpackLoading] = useState(false);
|
||||
const [gf3ProcessLoading, setGf3ProcessLoading] = useState(false);
|
||||
const [gf3SarscapeProduceLoading, setGf3SarscapeProduceLoading] = useState(false);
|
||||
const [gf3SarscapeSyncLoading, setGf3SarscapeSyncLoading] = useState(false);
|
||||
const [gf3SarscapeCleanLoading, setGf3SarscapeCleanLoading] = useState(false);
|
||||
const [gf3ScanLoading, setGf3ScanLoading] = useState(false);
|
||||
const [gf3Message, setGf3Message] = useState('');
|
||||
const logEndRef = useRef(null);
|
||||
@@ -87,7 +97,7 @@ const DataMonitorPanel = ({ apiEndpoint, onTaskStart, readOnly = false, enabled
|
||||
);
|
||||
const s1ActiveTask = displayActiveTasks.find((task) => task.task_type === 'UNPACK_SENTINEL1');
|
||||
const gf3ActiveTask = displayActiveTasks.find((task) =>
|
||||
['GF3_UNPACK', 'GF3_BATCH_PROCESS'].includes(task.task_type)
|
||||
['GF3_UNPACK', 'GF3_BATCH_PROCESS', 'GF3_SARSCAPE_PRODUCE', 'GF3_SARSCAPE_SYNC', 'GF3_SARSCAPE_CLEAN'].includes(task.task_type)
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -120,6 +130,7 @@ const DataMonitorPanel = ({ apiEndpoint, onTaskStart, readOnly = false, enabled
|
||||
s1_orbit_dirs: toArray(data?.s1_orbit_dirs),
|
||||
gf3_archive_source_dirs: toArray(data?.gf3_archive_source_dirs),
|
||||
gf3_source_dirs: toArray(data?.gf3_source_dirs),
|
||||
gf3_sarscape_native_dirs: toArray(data?.gf3_sarscape_native_dirs),
|
||||
gf3_storage_dirs: toArray(data?.gf3_storage_dirs),
|
||||
});
|
||||
setConfigLoaded(true);
|
||||
@@ -289,7 +300,10 @@ const DataMonitorPanel = ({ apiEndpoint, onTaskStart, readOnly = false, enabled
|
||||
const hasS1OrbitDirs = config.s1_orbit_dirs.length > 0;
|
||||
const hasGf3ArchiveSourceDirs = config.gf3_archive_source_dirs.length > 0;
|
||||
const hasGf3SourceDirs = config.gf3_source_dirs.length > 0;
|
||||
const hasGf3SarscapeNativeDirs = config.gf3_sarscape_native_dirs.length > 0;
|
||||
const hasGf3StorageDirs = config.gf3_storage_dirs.length > 0;
|
||||
const hasGf3SarscapeWrapper = typeof config.gf3_sarscape_wrapper_exe === 'string' && config.gf3_sarscape_wrapper_exe.trim() !== '';
|
||||
const hasGf3SarscapeDem = typeof config.gf3_sarscape_dem_path === 'string' && config.gf3_sarscape_dem_path.trim() !== '';
|
||||
|
||||
const canRunRadar = !readOnly && configLoaded && hasRadarDirs;
|
||||
const canRunOrbit = !readOnly && configLoaded && hasOrbitDir;
|
||||
@@ -299,6 +313,9 @@ const DataMonitorPanel = ({ apiEndpoint, onTaskStart, readOnly = false, enabled
|
||||
const canRunGf3Scan = !readOnly && configLoaded && hasGf3StorageDirs;
|
||||
const canRunGf3Unpack = !readOnly && configLoaded && hasGf3ArchiveSourceDirs && hasGf3SourceDirs;
|
||||
const canRunGf3Process = !readOnly && configLoaded && hasGf3SourceDirs;
|
||||
const canRunGf3SarscapeProduce = !readOnly && configLoaded && hasGf3ArchiveSourceDirs && hasGf3SarscapeNativeDirs && hasGf3StorageDirs && hasGf3SarscapeWrapper && hasGf3SarscapeDem;
|
||||
const canRunGf3SarscapeSync = !readOnly && configLoaded && hasGf3SarscapeNativeDirs && hasGf3StorageDirs;
|
||||
const canRunGf3SarscapeClean = !readOnly && configLoaded && hasGf3SarscapeNativeDirs && hasGf3StorageDirs;
|
||||
const canOpenUnpackDialog = !readOnly && unpackConfig.source_dirs.length > 0;
|
||||
|
||||
const handleS1Run = async () => {
|
||||
@@ -452,6 +469,111 @@ const DataMonitorPanel = ({ apiEndpoint, onTaskStart, readOnly = false, enabled
|
||||
}
|
||||
};
|
||||
|
||||
const handleGf3SarscapeProduce = async () => {
|
||||
if (readOnly) {
|
||||
setGf3Message('当前账户为只读模式,无法触发 GF3 SARscape 生产。');
|
||||
return;
|
||||
}
|
||||
setGf3SarscapeProduceLoading(true);
|
||||
setGf3Message('GF3 SARscape 生产链路启动中...');
|
||||
try {
|
||||
const res = await fetch(`${apiEndpoint}/monitor/gf3-sarscape-produce`, {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({}),
|
||||
});
|
||||
const data = await parseJsonSafe(res, {});
|
||||
if (res.ok) {
|
||||
setGf3Message(data.message || 'GF3 SARscape 生产任务已启动');
|
||||
if (onTaskStart) {
|
||||
onTaskStart(data.task_id, 'GF3 SARscape 生产链路已启动。', {
|
||||
nonBlocking: true,
|
||||
taskType: 'GF3_SARSCAPE_PRODUCE',
|
||||
});
|
||||
}
|
||||
} else {
|
||||
setGf3Message(`失败:${data.detail || '未知错误'}`);
|
||||
}
|
||||
} catch (err) {
|
||||
setGf3Message(`失败:${err.message || '未知错误'}`);
|
||||
} finally {
|
||||
setGf3SarscapeProduceLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleGf3SarscapeSync = async () => {
|
||||
if (readOnly) {
|
||||
setGf3Message('当前账户为只读模式,无法触发 GF3 SARscape 标准化。');
|
||||
return;
|
||||
}
|
||||
setGf3SarscapeSyncLoading(true);
|
||||
setGf3Message('GF3 SARscape 原生结果标准化启动中...');
|
||||
try {
|
||||
const res = await fetch(`${apiEndpoint}/monitor/gf3-sarscape-sync`, {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({}),
|
||||
});
|
||||
const data = await parseJsonSafe(res, {});
|
||||
if (res.ok) {
|
||||
setGf3Message(data.message || 'GF3 SARscape 标准化任务已启动');
|
||||
if (onTaskStart) {
|
||||
onTaskStart(data.task_id, 'GF3 SARscape 原生结果标准化已启动。', {
|
||||
nonBlocking: true,
|
||||
taskType: 'GF3_SARSCAPE_SYNC',
|
||||
});
|
||||
}
|
||||
} else {
|
||||
setGf3Message(`失败:${data.detail || '未知错误'}`);
|
||||
}
|
||||
} catch (err) {
|
||||
setGf3Message(`失败:${err.message || '未知错误'}`);
|
||||
} finally {
|
||||
setGf3SarscapeSyncLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleGf3SarscapeClean = async () => {
|
||||
if (readOnly) {
|
||||
setGf3Message('当前账户为只读模式,无法触发 GF3 SARscape 清理。');
|
||||
return;
|
||||
}
|
||||
setGf3SarscapeCleanLoading(true);
|
||||
setGf3Message('GF3 SARscape 中间数据清理启动中...');
|
||||
try {
|
||||
const res = await fetch(`${apiEndpoint}/monitor/gf3-sarscape-clean`, {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ dry_run: false, require_standardized: true }),
|
||||
});
|
||||
const data = await parseJsonSafe(res, {});
|
||||
if (res.ok) {
|
||||
setGf3Message(data.message || 'GF3 SARscape 清理任务已启动');
|
||||
if (onTaskStart) {
|
||||
onTaskStart(data.task_id, 'GF3 SARscape 中间数据清理已启动。', {
|
||||
nonBlocking: true,
|
||||
taskType: 'GF3_SARSCAPE_CLEAN',
|
||||
});
|
||||
}
|
||||
} else {
|
||||
setGf3Message(`失败:${data.detail || '未知错误'}`);
|
||||
}
|
||||
} catch (err) {
|
||||
setGf3Message(`失败:${err.message || '未知错误'}`);
|
||||
} finally {
|
||||
setGf3SarscapeCleanLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleOpenUnpackDialog = () => {
|
||||
if (readOnly) {
|
||||
setUnpackMessage('当前账户为只读模式,无法触发解包任务。');
|
||||
@@ -676,6 +798,7 @@ const DataMonitorPanel = ({ apiEndpoint, onTaskStart, readOnly = false, enabled
|
||||
<div style={rowStyle}><span style={labelStyle}>S1 精轨</span><span style={{ wordBreak: 'break-all' }}>{formatList(config.s1_orbit_dirs)}</span></div>
|
||||
<div style={rowStyle}><span style={labelStyle}>GF3 压缩包</span><span style={{ wordBreak: 'break-all' }}>{formatList(config.gf3_archive_source_dirs)}</span></div>
|
||||
<div style={rowStyle}><span style={labelStyle}>GF3 来源</span><span style={{ wordBreak: 'break-all' }}>{formatList(config.gf3_source_dirs)}</span></div>
|
||||
<div style={rowStyle}><span style={labelStyle}>GF3 原生</span><span style={{ wordBreak: 'break-all' }}>{formatList(config.gf3_sarscape_native_dirs)}</span></div>
|
||||
<div style={rowStyle}><span style={labelStyle}>GF3 存储</span><span style={{ wordBreak: 'break-all' }}>{formatList(config.gf3_storage_dirs)}</span></div>
|
||||
<div style={rowStyle}><span style={labelStyle}>D-InSAR 结果</span><span style={{ wordBreak: 'break-all' }}>{formatList(config.dinsar_dirs)}</span></div>
|
||||
</div>
|
||||
@@ -769,7 +892,11 @@ const DataMonitorPanel = ({ apiEndpoint, onTaskStart, readOnly = false, enabled
|
||||
<div style={{ ...gridStyle, marginBottom: '8px' }}>
|
||||
<div style={rowStyle}><span style={labelStyle}>压缩包来源</span><span style={{ wordBreak: 'break-all' }}>{formatList(config.gf3_archive_source_dirs)}</span></div>
|
||||
<div style={rowStyle}><span style={labelStyle}>L1A 来源</span><span style={{ wordBreak: 'break-all' }}>{formatList(config.gf3_source_dirs)}</span></div>
|
||||
<div style={rowStyle}><span style={labelStyle}>SARscape 原生</span><span style={{ wordBreak: 'break-all' }}>{formatList(config.gf3_sarscape_native_dirs)}</span></div>
|
||||
<div style={rowStyle}><span style={labelStyle}>L2 存储</span><span style={{ wordBreak: 'break-all' }}>{formatList(config.gf3_storage_dirs)}</span></div>
|
||||
<div style={rowStyle}><span style={labelStyle}>Wrapper</span><span style={{ wordBreak: 'break-all' }}>{config.gf3_sarscape_wrapper_exe || '未配置'}</span></div>
|
||||
<div style={rowStyle}><span style={labelStyle}>SARscape DEM</span><span style={{ wordBreak: 'break-all' }}>{config.gf3_sarscape_dem_path || '未配置'}</span></div>
|
||||
<div style={rowStyle}><span style={labelStyle}>极化</span><span>{config.gf3_sarscape_polarizations || 'HH,HV'}</span></div>
|
||||
</div>
|
||||
<div style={{ display: 'flex', gap: '10px', flexWrap: 'wrap' }}>
|
||||
<button
|
||||
@@ -786,6 +913,27 @@ const DataMonitorPanel = ({ apiEndpoint, onTaskStart, readOnly = false, enabled
|
||||
>
|
||||
{gf3ProcessLoading ? '运行中...' : (readOnly ? '只读模式' : 'GF3 预处理')}
|
||||
</button>
|
||||
<button
|
||||
onClick={handleGf3SarscapeProduce}
|
||||
disabled={gf3SarscapeProduceLoading || readOnly || !canRunGf3SarscapeProduce}
|
||||
style={actionBtnStyle(gf3SarscapeProduceLoading, readOnly || !canRunGf3SarscapeProduce)}
|
||||
>
|
||||
{gf3SarscapeProduceLoading ? '运行中...' : (readOnly ? '只读模式' : 'GF3 SARscape 生产')}
|
||||
</button>
|
||||
<button
|
||||
onClick={handleGf3SarscapeSync}
|
||||
disabled={gf3SarscapeSyncLoading || readOnly || !canRunGf3SarscapeSync}
|
||||
style={actionBtnStyle(gf3SarscapeSyncLoading, readOnly || !canRunGf3SarscapeSync)}
|
||||
>
|
||||
{gf3SarscapeSyncLoading ? '运行中...' : (readOnly ? '只读模式' : 'GF3 SARscape 入库')}
|
||||
</button>
|
||||
<button
|
||||
onClick={handleGf3SarscapeClean}
|
||||
disabled={gf3SarscapeCleanLoading || readOnly || !canRunGf3SarscapeClean}
|
||||
style={actionBtnStyle(gf3SarscapeCleanLoading, readOnly || !canRunGf3SarscapeClean)}
|
||||
>
|
||||
{gf3SarscapeCleanLoading ? '运行中...' : (readOnly ? '只读模式' : '清理 GF3 中间')}
|
||||
</button>
|
||||
<button
|
||||
onClick={handleGf3Scan}
|
||||
disabled={gf3ScanLoading || readOnly || !canRunGf3Scan}
|
||||
|
||||
@@ -26,6 +26,12 @@ const getTaskTypeLabel = (taskType) => {
|
||||
return 'GF3 解包';
|
||||
case 'GF3_BATCH_PROCESS':
|
||||
return 'GF3 预处理';
|
||||
case 'GF3_SARSCAPE_PRODUCE':
|
||||
return 'GF3 SARscape 生产';
|
||||
case 'GF3_SARSCAPE_SYNC':
|
||||
return 'GF3 SARscape 入库';
|
||||
case 'GF3_SARSCAPE_CLEAN':
|
||||
return 'GF3 中间清理';
|
||||
case 'SCAN_ASSET_INVENTORY':
|
||||
return '资产库存扫描';
|
||||
case 'IDL_IMPORT':
|
||||
|
||||
@@ -11,7 +11,7 @@ import { normalizePagePayload } from '../utils/appHelpers';
|
||||
import { normalizeTaskStatus } from '../utils/appUiHelpers';
|
||||
import { DEFAULT_LIST_PAGE_SIZE } from '../config/appConstants';
|
||||
|
||||
const NON_BLOCKING_TASK_TYPES = new Set(['UNPACK_ARCHIVES', 'UNPACK_SENTINEL1', 'GF3_UNPACK', 'SCAN_ASSET_INVENTORY', 'COPY_DATA']);
|
||||
const NON_BLOCKING_TASK_TYPES = new Set(['UNPACK_ARCHIVES', 'UNPACK_SENTINEL1', 'GF3_UNPACK', 'GF3_SARSCAPE_PRODUCE', 'GF3_SARSCAPE_SYNC', 'GF3_SARSCAPE_CLEAN', 'SCAN_ASSET_INVENTORY', 'COPY_DATA']);
|
||||
|
||||
export default function useDinsarOperations({
|
||||
onCleanupDinsarLayers,
|
||||
@@ -235,6 +235,28 @@ export default function useDinsarOperations({
|
||||
} else if (taskStatus === 'FAILED') {
|
||||
addLog('error', `GF3 解包失败: ${taskInfo.message || '未知错误'}`);
|
||||
}
|
||||
} else if (taskInfo.task_type === 'GF3_SARSCAPE_PRODUCE') {
|
||||
if (taskStatus === 'COMPLETED') {
|
||||
addLog('success', taskInfo.message || 'GF3 SARscape 生产链完成。');
|
||||
addLog('info', '正在同步 GF3 生产后的数据视图...');
|
||||
void syncRadarViewsAfterUnpack();
|
||||
} else if (taskStatus === 'FAILED') {
|
||||
addLog('error', `GF3 SARscape 生产失败: ${taskInfo.message || '未知错误'}`);
|
||||
}
|
||||
} else if (taskInfo.task_type === 'GF3_SARSCAPE_SYNC') {
|
||||
if (taskStatus === 'COMPLETED') {
|
||||
addLog('success', taskInfo.message || 'GF3 SARscape 标准化完成。');
|
||||
addLog('info', '正在同步 GF3 标准化后的数据视图...');
|
||||
void syncRadarViewsAfterUnpack();
|
||||
} else if (taskStatus === 'FAILED') {
|
||||
addLog('error', `GF3 SARscape 标准化失败: ${taskInfo.message || '未知错误'}`);
|
||||
}
|
||||
} else if (taskInfo.task_type === 'GF3_SARSCAPE_CLEAN') {
|
||||
if (taskStatus === 'COMPLETED') {
|
||||
addLog('success', taskInfo.message || 'GF3 SARscape 中间数据清理完成。');
|
||||
} else if (taskStatus === 'FAILED') {
|
||||
addLog('error', `GF3 SARscape 中间数据清理失败: ${taskInfo.message || '未知错误'}`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import apiClient from '../api/client';
|
||||
import { normalizeTaskStatus } from '../utils/appUiHelpers';
|
||||
|
||||
const NON_BLOCKING_TASK_TYPES = new Set(['UNPACK_ARCHIVES', 'UNPACK_SENTINEL1', 'GF3_UNPACK', 'SCAN_ASSET_INVENTORY', 'COPY_DATA']);
|
||||
const NON_BLOCKING_TASK_TYPES = new Set(['UNPACK_ARCHIVES', 'UNPACK_SENTINEL1', 'GF3_UNPACK', 'GF3_SARSCAPE_PRODUCE', 'GF3_SARSCAPE_SYNC', 'GF3_SARSCAPE_CLEAN', 'SCAN_ASSET_INVENTORY', 'COPY_DATA']);
|
||||
|
||||
const isTaskNonBlocking = (taskId, taskType, nonBlockingTaskIds = []) => (
|
||||
NON_BLOCKING_TASK_TYPES.has(String(taskType || '').toUpperCase())
|
||||
|
||||
@@ -72,6 +72,11 @@ export default function useRadarSearch({
|
||||
);
|
||||
};
|
||||
|
||||
const getSatelliteFallbackForGroup = (groupKey) => {
|
||||
const group = SATELLITE_GROUPS.find((item) => item.key === groupKey);
|
||||
return Array.isArray(group?.prefixes) && group.prefixes.length > 0 ? group.prefixes[0] : '';
|
||||
};
|
||||
|
||||
const fetchRadarImagingDates = useCallback(async () => {
|
||||
try {
|
||||
const response = await apiClient.get('/radar-data/imaging-dates');
|
||||
@@ -132,33 +137,6 @@ export default function useRadarSearch({
|
||||
}
|
||||
}, [setRadarSearchOptions, setRadarSearchOptionsLoading]);
|
||||
|
||||
const changeSatelliteGroup = useCallback((groupKey) => {
|
||||
setSelectedSatelliteGroup(groupKey);
|
||||
// Clear sub-filters that may be invalid for the new satellite group
|
||||
setRadarSearchDraft((prev) => ({
|
||||
...prev,
|
||||
satellite: '',
|
||||
imaging_mode: '',
|
||||
polarization: '',
|
||||
satellite_mode: '',
|
||||
receiving_station: '',
|
||||
orbit_circle: '',
|
||||
acquisition_time_utc: '',
|
||||
product_type: '',
|
||||
product_level: '',
|
||||
product_unique_id: '',
|
||||
orbit_direction: '',
|
||||
}));
|
||||
if (groupKey === 'all') {
|
||||
fetchRadarSearchOptions([]);
|
||||
} else {
|
||||
const matched = getSatellitesForGroup(groupKey);
|
||||
if (matched.length > 0) {
|
||||
fetchRadarSearchOptions(matched);
|
||||
}
|
||||
}
|
||||
}, [setSelectedSatelliteGroup, setRadarSearchDraft, fetchRadarSearchOptions]);
|
||||
|
||||
const processAndSetAllData = useCallback((data) => {
|
||||
const nameCounts = {};
|
||||
const dataWithDisplayNames = data.map(item => {
|
||||
@@ -294,6 +272,8 @@ export default function useRadarSearch({
|
||||
const matched = getSatellitesForGroup(selectedSatelliteGroup);
|
||||
if (matched.length > 0) {
|
||||
draftWithSatelliteGroup.satellite = matched.join(',');
|
||||
} else {
|
||||
draftWithSatelliteGroup.satellite = getSatelliteFallbackForGroup(selectedSatelliteGroup);
|
||||
}
|
||||
}
|
||||
const normalizedCriteria = normalizeRadarSearchCriteria(draftWithSatelliteGroup, RADAR_SEARCH_DEFAULTS);
|
||||
@@ -354,6 +334,78 @@ export default function useRadarSearch({
|
||||
clearRadarSearchResults, fetchAllData,
|
||||
]);
|
||||
|
||||
const changeSatelliteGroup = useCallback(async (groupKey) => {
|
||||
const nextGroupKey = groupKey || 'all';
|
||||
setSelectedSatelliteGroup(nextGroupKey);
|
||||
const clearedDraft = {
|
||||
...radarSearchDraft,
|
||||
satellite: '',
|
||||
imaging_mode: '',
|
||||
polarization: '',
|
||||
satellite_mode: '',
|
||||
receiving_station: '',
|
||||
orbit_circle: '',
|
||||
acquisition_time_utc: '',
|
||||
product_type: '',
|
||||
product_level: '',
|
||||
product_unique_id: '',
|
||||
orbit_direction: '',
|
||||
};
|
||||
setRadarSearchDraft(clearedDraft);
|
||||
|
||||
let matched = [];
|
||||
let satelliteFilter = '';
|
||||
if (nextGroupKey === 'all') {
|
||||
fetchRadarSearchOptions([]);
|
||||
} else {
|
||||
matched = getSatellitesForGroup(nextGroupKey);
|
||||
satelliteFilter = matched.length > 0
|
||||
? matched.join(',')
|
||||
: getSatelliteFallbackForGroup(nextGroupKey);
|
||||
if (matched.length > 0) {
|
||||
fetchRadarSearchOptions(matched);
|
||||
}
|
||||
}
|
||||
|
||||
const normalizedCriteria = normalizeRadarSearchCriteria(
|
||||
{
|
||||
...clearedDraft,
|
||||
satellite: nextGroupKey === 'all' ? '' : satelliteFilter,
|
||||
},
|
||||
RADAR_SEARCH_DEFAULTS
|
||||
);
|
||||
const requestId = radarSearchRequestSeqRef.current + 1;
|
||||
radarSearchRequestSeqRef.current = requestId;
|
||||
setRadarSearchApplied(normalizedCriteria);
|
||||
setRadarSearchAppliedAoiMode('none');
|
||||
setRadarSearchAppliedRegionTreeId('');
|
||||
setRadarSearchAoiMode('none');
|
||||
setRadarSearchAoiToken('');
|
||||
setHasRadarSearched(true);
|
||||
setIsLoading(true);
|
||||
clearRadarSearchResults({ limit: radarPagination.limit });
|
||||
try {
|
||||
await fetchAllData({
|
||||
limit: radarPagination.limit,
|
||||
offset: 0,
|
||||
criteria: normalizedCriteria,
|
||||
aoiMode: 'none',
|
||||
regionTreeId: '',
|
||||
files: null,
|
||||
aoiToken: '',
|
||||
requestId,
|
||||
});
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
}, [
|
||||
radarSearchDraft, radarPagination.limit, radarSearchRequestSeqRef,
|
||||
setSelectedSatelliteGroup, setRadarSearchDraft, setRadarSearchApplied,
|
||||
setRadarSearchAppliedAoiMode, setRadarSearchAppliedRegionTreeId,
|
||||
setRadarSearchAoiMode, setRadarSearchAoiToken, setHasRadarSearched,
|
||||
setIsLoading, clearRadarSearchResults, fetchAllData, fetchRadarSearchOptions,
|
||||
]);
|
||||
|
||||
const resetRadarSearch = useCallback(() => {
|
||||
setRadarSearchDraft(RADAR_SEARCH_DEFAULTS);
|
||||
setRadarSearchApplied(RADAR_SEARCH_DEFAULTS);
|
||||
|
||||
Reference in New Issue
Block a user