Skip to content

Conversation

@conservationtimothy
Copy link
Contributor

@conservationtimothy conservationtimothy commented Dec 30, 2025

Goal

Add a simple UI to test the annotated collections/incidents API endpoints in the Alerts Dashboard. Closes #190

Screenshots

Screenshot 2025-12-30 at 17 27 29 Screenshot 2025-12-30 at 16 38 42 Ctrl + click i.e. Multi select 👆🏿 Screenshot 2025-12-31 at 12 49 00 Screenshot 2025-12-31 at 12 47 35 Screenshot 2025-12-31 at 12 47 29

Bounding box 👆🏿

What I changed and why

Added a simple UI to AlertsDashboard.vue for testing the annotated collections/incidents API. Includes three control buttons (View Incidents, Multi-select, Bounding Box) at 50% screen height, an IncidentsSidebar component for viewing/creating incidents, and multi-select (Ctrl+click) and bounding box which is WIP (Ctrl (Command)+drag) functionality to add map features to collections.

Also Merged main into feat/annotated-collections-feature-branch and ran database migrations to ensure tables exist.

What I'm not doing here

This is a minimal testing UI so stuff can be more comprehensive

LLM use disclosure

Used LLM (Auto/Cursor) for code generation of the incidents UI components minor things like placing 50% of the screen as well as bounding box research

@conservationtimothy

This comment was marked as outdated.

@conservationtimothy conservationtimothy changed the title WIP: Build Simple UI to be able to visually test new API for Incidents Build Simple UI to be able to visually test new API for Incidents Dec 31, 2025
@conservationtimothy
Copy link
Contributor Author

Note: this is WIP as i am not through with the bounding box implementation, right now it does not do what I want it to do. It draws the box but it zooms to the nearest element instead of selecting it. However it is mostly done where there is some merit in reviewing if you wish.

Ok this is ready : )

Copy link
Contributor

@IamJeffG IamJeffG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally very good code. I am very concerned about the length of AlertsDashboard.vue but would not block merge solely on that.

I am marking "request changes" but what I actually want is more context from you to help me review server/database/annotatedCollections.ts. I did not really review that file, am not clear what's in-scope or what's going on there.

SELECT * FROM ${sql.identifier(entry.source_table)} WHERE _id = ${entry.source_id} OR id = ${entry.source_id} LIMIT 1
// Fetch source data from warehouse database (source tables use _id as primary key)
const sourceResult = await warehouseDb.execute(sql`
SELECT * FROM ${sql.identifier(entry.source_table)} WHERE _id = ${entry.source_id} LIMIT 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know why the OR id=... was there before? I agree that it seems risky to have had it, but maybe there was a reason it was there?

Or is this more related to changing the database and that's why it's justified? Please help me understand the changes in this file -- and is it actually related to the new UI or should it be its own PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initially, assumed id was the primary key for all warehouse tables. During testing, I found that most tables (e.g., fake_alerts, bcmform_responses) use _id as the primary key, while mapeo_data uses id. We have now updated the code to select the column by table name: id for mapeo_data, _id for all others. This ensures correct queries when fetching source data for collection entries. This fix belongs in the same PR as the annotated collections migration because it’s part of the same feature (querying warehouse data when creating incidents), the issue only surfaces when creating incidents with mapeo features, and it’s a small, related correctness improvement.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rudokemper does this match your understanding & intent?

{{
showIncidentsSidebar
? "Hide incidents sidebar"
: "View saved incidents and create new ones"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok leaving i18n out of this PR. 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but let's add a sub-issue to the epic to handle i18n.

});
incidents.value = response.incidents;
} catch (error) {
console.error("Error fetching incidents:", error);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably want to surface these API failures to the user, but I'm ok keeping that as a TODO. Same for in createIncident

@rudokemper
Copy link
Member

Great work, Osa!

Some feedback on the UI, not code review:


When I am in the process of selecting records to be part of a new incident, the sidebar UI is a little confusing. I think that this state should no longer show "Saved Incidents". Maybe it is enough to remove that, and keep the button to add a new one, like so:

image

I think there should be a "Clear" control that deselects all of the records that I have selected until now. I didn't see a way to deselect anything outside of the "Clear All" button in the Incident sidebar - I intuited that I might be able to by ctrl-clicking, or drawing a bounding box over, already selected features, but that doesn't work.


I didn't see a way to "activate", open, or otherwise interact with existing saved incidents. Just making sure that this was out of scope for this PR, but forthcoming in another one?

@conservationtimothy
Copy link
Contributor Author

I didn't see a way to "activate", open, or otherwise interact with existing saved incidents. Just making sure that this was out of scope for this PR, but forthcoming in another one?

Yes it is out of scope but will be added in a new PR.

otherwise great feedback and will implement.

@conservationtimothy
Copy link
Contributor Author

I have updated the incidents UI:

  1. hide "Saved Incidents" when creating a new incident or when sources are selected (the "+ New Incident" button remains visible).
  2. Made Ctrl+click and bounding box selection toggle: clicking or selecting an already-selected feature deselects it and removes the highlight. Added unhighlightSelectedSource to remove highlights on deselect. The "Clear All" button in the sidebar actually clears all.
Screenshot 2026-01-06 at 13 39 05 Screenshot 2026-01-06 at 13 38 56 Screenshot 2026-01-06 at 13 38 45

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants