-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New inspections view #1880
Merged
mrica-equinor
merged 1 commit into
equinor:main
from
mrica-equinor:new-inspections-view
Dec 13, 2024
Merged
New inspections view #1880
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
using Api.Controllers.Models; | ||
using System.Globalization; | ||
using Api.Controllers.Models; | ||
using Api.Database.Models; | ||
|
||
using Api.Services; | ||
using Api.Services.MissionLoaders; | ||
using Api.Services.Models; | ||
|
@@ -11,7 +14,8 @@ namespace Api.Controllers | |
[Route("inspection")] | ||
public class InspectionController( | ||
ILogger<InspectionController> logger, | ||
IEchoService echoService | ||
IEchoService echoService, | ||
IInspectionService inspectionService | ||
) : ControllerBase | ||
{ | ||
/// <summary> | ||
|
@@ -49,5 +53,56 @@ public async Task<ActionResult<TagInspectionMetadata>> Create([FromRoute] string | |
throw; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Lookup the inspection image for task with specified isarTaskId | ||
/// </summary> | ||
/// <remarks> | ||
/// </remarks> | ||
[HttpGet] | ||
[Authorize(Roles = Role.User)] | ||
[Route("{installationCode}/{taskId}/taskId")] | ||
[ProducesResponseType(typeof(Inspection), StatusCodes.Status200OK)] | ||
[ProducesResponseType(StatusCodes.Status400BadRequest)] | ||
[ProducesResponseType(StatusCodes.Status409Conflict)] | ||
[ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||
[ProducesResponseType(StatusCodes.Status403Forbidden)] | ||
[ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||
public async Task<ActionResult<Inspection>> GetInspectionImageById([FromRoute] string installationCode, string taskId) | ||
{ | ||
Inspection? inspection; | ||
try | ||
{ | ||
inspection = await inspectionService.ReadByIsarTaskId(taskId, readOnly: true); | ||
if (inspection == null) return NotFound($"Could not find inspection for task with Id {taskId}."); | ||
|
||
} | ||
catch (Exception e) | ||
{ | ||
logger.LogError(e, $"Error while finding an inspection with task Id {taskId}"); | ||
return StatusCode(StatusCodes.Status500InternalServerError); | ||
} | ||
|
||
if (inspection.Id == null) return NotFound($"Could not find Id for Inspection with task ID {taskId}."); | ||
|
||
var inspectionData = await inspectionService.GetInspectionStorageInfo(inspection.Id); | ||
|
||
if (inspectionData == null) return NotFound($"Could not find inspection data for inspection with Id {inspection.Id}."); | ||
|
||
if (!inspectionData.BlobContainer.ToLower(CultureInfo.CurrentCulture).Equals(installationCode.ToLower(CultureInfo.CurrentCulture), StringComparison.Ordinal)) | ||
{ | ||
return NotFound($"Could not find inspection data for inspection with Id {inspection.Id} because blob name {inspectionData.BlobName} does not match installation {installationCode}."); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider moving the checks into the InspectionService |
||
|
||
try | ||
{ | ||
byte[] inspectionStream = await inspectionService.FetchInpectionImage(inspectionData.BlobName, inspectionData.BlobContainer, inspectionData.StorageAccount); | ||
return File(inspectionStream, "image/png"); | ||
} | ||
catch (Azure.RequestFailedException) | ||
{ | ||
return NotFound($"Could not find inspection blob {inspectionData.BlobName} in container {inspectionData.BlobContainer} and storage account {inspectionData.StorageAccount}."); | ||
} | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Api.Services.Models | ||
{ | ||
public class IDAInspectionDataResponse | ||
{ | ||
[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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -430,4 +430,12 @@ export class BackendAPICaller { | |
}) | ||
return result.content | ||
} | ||
|
||
static async getInspection(installationCode: string, taskId: string): Promise<Blob> { | ||
const path: string = 'inspection/' + installationCode + '/' + taskId + '/taskId' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider querying by inspectionId instead of taskId |
||
|
||
return BackendAPICaller.GET<Blob>(path, 'image/png') | ||
.then((response) => response.content) | ||
.catch(BackendAPICaller.handleError('GET', path)) | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider querying the inspection by the inspectionID instead of the taskID