Skip to content

Commit

Permalink
- Clicking a visit should always select+display the first recording i…
Browse files Browse the repository at this point in the history
…n the visit with a track matching the visit classification.
  • Loading branch information
hardiesoft committed Oct 7, 2024
1 parent 1f11886 commit 735ea29
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 12 deletions.
2 changes: 1 addition & 1 deletion browse-next/src/components/VisitsDailyBreakdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ const isStillProcessing = computed<boolean>(() => {
<b-spinner
v-if="classification === 'unclassified'"
small
variant="secondary"
variant="light"
class="mx-1"
/>
<span :class="{ 'me-1': classification === 'unclassified' }">{{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ class CptvDecoderInterface {
};
this.response = await fetch(
`${apiRoot}/api/v1/recordings/raw/${id}`,
// eslint-disable-next-line no-undef
request as RequestInit
);
if (this.response.status === 200) {
Expand Down
32 changes: 28 additions & 4 deletions browse-next/src/views/ActivitySearchView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1688,12 +1688,36 @@ watch(
recId,
tracks,
}));
const visitClassification = visit.classification || "";
let firstRec = visit.recordings[0];
let firstTrack =
(firstRec.tracks &&
firstRec.tracks.length !== 0 &&
firstRec.tracks[0]) ||
undefined;
if (visitClassification !== "") {
// Make sure we set the first recording as one that contains the visit classification.
const firstRecordingWithVisitClassification = visit.recordings.find(
(rec) =>
rec.tracks.some(
(track) =>
track.tag === visit.classification ||
(!track.tag && track.aiTag === visit.classification)
)
);
if (firstRecordingWithVisitClassification) {
firstRec = firstRecordingWithVisitClassification;
firstTrack = firstRec.tracks.find(
(track) =>
track.tag === visit.classification ||
(!track.tag && track.aiTag === visit.classification)
);
}
}
const params: Record<string, string> = {
visitLabel: visit.classification || "",
currentRecordingId: recordingIds[0].recId.toString(),
trackId: (recordingIds[0].tracks &&
recordingIds[0].tracks.length &&
recordingIds[0].tracks[0].id.toString()) as string,
currentRecordingId: firstRec.recId.toString(),
trackId: (firstTrack && firstTrack.id.toString()) as string,
};
if (recordingIds.length) {
params.recordingIds = recordingIds.map(({ recId }) => recId).join(",");
Expand Down
45 changes: 38 additions & 7 deletions browse-next/src/views/DashboardView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -165,18 +165,49 @@ watch(
(visit: ApiVisitResponse | null, prevVisit: ApiVisitResponse | null) => {
if (visit && !prevVisit) {
// Set route so that modal shows up
const recordingIds = visit.recordings.map(({ recId }) => recId);
const params = {
visitLabel: visit.classification,
currentRecordingId: recordingIds[0].toString(),
const recordingIds = visit.recordings.map(({ recId, tracks }) => ({
recId,
tracks,
}));
const visitClassification = visit.classification || "";
let firstRec = visit.recordings[0];
let firstTrack =
(firstRec.tracks &&
firstRec.tracks.length !== 0 &&
firstRec.tracks[0]) ||
undefined;
if (visitClassification !== "") {
// Make sure we set the first recording as one that contains the visit classification.
const firstRecordingWithVisitClassification = visit.recordings.find(
(rec) =>
rec.tracks.some(
(track) =>
track.tag === visit.classification ||
(!track.tag && track.aiTag === visit.classification)
)
);
if (firstRecordingWithVisitClassification) {
firstRec = firstRecordingWithVisitClassification;
firstTrack = firstRec.tracks.find(
(track) =>
track.tag === visit.classification ||
(!track.tag && track.aiTag === visit.classification)
);
}
}
const params: Record<string, string> = {
visitLabel: visit.classification || "",
currentRecordingId: firstRec.recId.toString(),
trackId: (firstTrack && firstTrack.id.toString()) as string,
};
if (recordingIds.length > 1) {
(params as Record<string, string>).recordingIds =
recordingIds.join(",");
if (recordingIds.length) {
params.recordingIds = recordingIds.map(({ recId }) => recId).join(",");
}
router.push({
name: "dashboard-visit",
params,
query: route.query,
});
} else if (!visit && prevVisit) {
// We've stopped having a selected visit modal
Expand Down

0 comments on commit 735ea29

Please sign in to comment.