-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use IDA MQTT message to update inspection view
- Loading branch information
1 parent
faa27d6
commit b0a0159
Showing
17 changed files
with
188 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Api.Mqtt.MessageModels | ||
{ | ||
#nullable disable | ||
public class IdaInspectionResultMessage : MqttMessage | ||
{ | ||
[JsonPropertyName("inspection_id")] | ||
public string InspectionId { get; set; } | ||
|
||
[JsonPropertyName("storageAccount")] | ||
public required string StorageAccount { get; set; } | ||
|
||
[JsonPropertyName("blobContainer")] | ||
public required string BlobContainer { get; set; } | ||
|
||
[JsonPropertyName("blobName")] | ||
public required string BlobName { get; set; } | ||
} | ||
|
||
public class InspectionResultMessage | ||
{ | ||
[JsonPropertyName("inspectionId")] | ||
public string InspectionId { get; set; } | ||
|
||
[JsonPropertyName("storageAccount")] | ||
public required string StorageAccount { get; set; } | ||
|
||
[JsonPropertyName("blobContainer")] | ||
public required string BlobContainer { get; set; } | ||
|
||
[JsonPropertyName("blobName")] | ||
public required string BlobName { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 4 additions & 21 deletions
25
frontend/src/components/Pages/InspectionReportPage/InspectionReportUtilities.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,9 @@ | ||
import { useQuery } from '@tanstack/react-query' | ||
import { BackendAPICaller } from 'api/ApiCaller' | ||
import { Task, TaskStatus } from 'models/Task' | ||
import { useInspectionsContext } from 'components/Contexts/InpectionsContext' | ||
import { Task } from 'models/Task' | ||
import { StyledInspectionImage } from './InspectionStyles' | ||
|
||
export const fetchImageData = (task: Task) => { | ||
const data = useQuery({ | ||
queryKey: ['fetchInspectionData', task.isarTaskId], | ||
queryFn: async () => { | ||
const imageBlob = await BackendAPICaller.getInspection(task.inspection.isarInspectionId) | ||
return URL.createObjectURL(imageBlob) | ||
}, | ||
retryDelay: 60 * 1000, // Waits 1 min before retrying, regardless of how many retries | ||
staleTime: 10 * 60 * 1000, // If data is received, stale time is 10 min before making new API call | ||
enabled: | ||
task.status === TaskStatus.Successful && | ||
task.isarTaskId !== undefined && | ||
task.inspection.isarInspectionId !== undefined, | ||
}) | ||
return data | ||
} | ||
|
||
export const GetInspectionImage = ({ task }: { task: Task }) => { | ||
const { data } = fetchImageData(task) | ||
const { fetchImageData } = useInspectionsContext() | ||
const { data } = fetchImageData(task.inspection.isarInspectionId) | ||
return <>{data !== undefined && <StyledInspectionImage src={data} />}</> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters