@mytec: iter9 ready for test

This commit is contained in:
2026-01-30 14:47:32 +02:00
parent 7fe5f7068c
commit b932607521
7 changed files with 629 additions and 143 deletions

View File

@@ -38,6 +38,8 @@ interface SitesState {
clearSelection: () => void;
batchUpdateHeight: (adjustment: number) => Promise<void>;
batchSetHeight: (height: number) => Promise<void>;
batchAdjustAzimuth: (delta: number) => Promise<void>;
batchSetAzimuth: (azimuth: number) => Promise<void>;
}
export const useSitesStore = create<SitesState>((set, get) => ({
@@ -276,4 +278,62 @@ export const useSitesStore = create<SitesState>((set, get) => ({
set({ sites: updatedSites });
},
batchAdjustAzimuth: async (delta: number) => {
const { sites, selectedSiteIds } = get();
const selectedSet = new Set(selectedSiteIds);
const now = new Date();
const updatedSites = sites.map((site) => {
if (!selectedSet.has(site.id)) return site;
const current = site.azimuth ?? 0;
return {
...site,
azimuth: ((current + delta) % 360 + 360) % 360,
updatedAt: now,
};
});
const toUpdate = updatedSites.filter((s) => selectedSet.has(s.id));
for (const site of toUpdate) {
await db.sites.put({
id: site.id,
data: JSON.stringify(site),
createdAt: site.createdAt.getTime(),
updatedAt: now.getTime(),
});
}
set({ sites: updatedSites });
useCoverageStore.getState().clearCoverage();
},
batchSetAzimuth: async (azimuth: number) => {
const { sites, selectedSiteIds } = get();
const selectedSet = new Set(selectedSiteIds);
const clamped = ((azimuth % 360) + 360) % 360;
const now = new Date();
const updatedSites = sites.map((site) => {
if (!selectedSet.has(site.id)) return site;
return {
...site,
azimuth: clamped,
updatedAt: now,
};
});
const toUpdate = updatedSites.filter((s) => selectedSet.has(s.id));
for (const site of toUpdate) {
await db.sites.put({
id: site.id,
data: JSON.stringify(site),
createdAt: site.createdAt.getTime(),
updatedAt: now.getTime(),
});
}
set({ sites: updatedSites });
useCoverageStore.getState().clearCoverage();
},
}));