mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 11:16:30 +00:00
fix image save, ui small fixes
This commit is contained in:
@@ -5,7 +5,7 @@ namespace Azaion.Common;
|
||||
|
||||
public class Constants
|
||||
{
|
||||
public const string SECURE_RESOURCE_CACHE = "SecureResourceCache";
|
||||
public const string JPG_EXT = ".jpg";
|
||||
|
||||
#region DirectoriesConfig
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ public class DetectionClass
|
||||
public string Name { get; set; } = null!;
|
||||
public string ShortName { get; set; } = null!;
|
||||
|
||||
[JsonIgnore]
|
||||
public string UIName
|
||||
{
|
||||
get
|
||||
|
||||
@@ -68,7 +68,7 @@ public class AnnotationService : INotificationHandler<AnnotationsDeletedEvent>
|
||||
{
|
||||
Reference = _hardwareService.GetHardware().Hash,
|
||||
OffsetSpec = new OffsetTypeOffset(offset + 1),
|
||||
MessageHandler = async (stream, consumer, context, message) =>
|
||||
MessageHandler = async (_, _, context, message) =>
|
||||
{
|
||||
var msg = MessagePackSerializer.Deserialize<AnnotationCreatedMessage>(message.Data.Contents);
|
||||
await _dbFactory.Run(async db => await db.QueueOffsets
|
||||
@@ -89,7 +89,6 @@ public class AnnotationService : INotificationHandler<AnnotationsDeletedEvent>
|
||||
msg.CreatedDate,
|
||||
msg.OriginalMediaName,
|
||||
msg.Time,
|
||||
msg.ImageExtension,
|
||||
JsonConvert.DeserializeObject<List<Detection>>(msg.Detections) ?? [],
|
||||
msg.Source,
|
||||
new MemoryStream(msg.Image),
|
||||
@@ -105,23 +104,23 @@ public class AnnotationService : INotificationHandler<AnnotationsDeletedEvent>
|
||||
public async Task<Annotation> SaveAnnotation(AnnotationImage a, CancellationToken cancellationToken = default)
|
||||
{
|
||||
a.Time = TimeSpan.FromMilliseconds(a.Milliseconds);
|
||||
return await SaveAnnotationInner(DateTime.Now, a.OriginalMediaName, a.Time, ".jpg", a.Detections.ToList(),
|
||||
return await SaveAnnotationInner(DateTime.Now, a.OriginalMediaName, a.Time, a.Detections.ToList(),
|
||||
a.Source, new MemoryStream(a.Image), _authProvider.CurrentUser.Role, _authProvider.CurrentUser.Email, generateThumbnail: true, cancellationToken);
|
||||
}
|
||||
|
||||
//Manual
|
||||
public async Task<Annotation> SaveAnnotation(string originalMediaName, TimeSpan time, string imageExtension, List<Detection> detections, SourceEnum source, Stream? stream = null, CancellationToken token = default) =>
|
||||
await SaveAnnotationInner(DateTime.UtcNow, originalMediaName, time, imageExtension, detections, source, stream,
|
||||
public async Task<Annotation> SaveAnnotation(string originalMediaName, TimeSpan time, List<Detection> detections, SourceEnum source, Stream? stream = null, CancellationToken token = default) =>
|
||||
await SaveAnnotationInner(DateTime.UtcNow, originalMediaName, time, detections, source, stream,
|
||||
_authProvider.CurrentUser.Role, _authProvider.CurrentUser.Email, generateThumbnail: true, token);
|
||||
|
||||
//Manual Validate existing
|
||||
public async Task ValidateAnnotation(Annotation annotation, CancellationToken token = default) =>
|
||||
await SaveAnnotationInner(DateTime.UtcNow, annotation.OriginalMediaName, annotation.Time, annotation.ImageExtension, annotation.Detections.ToList(), SourceEnum.Manual, null,
|
||||
await SaveAnnotationInner(DateTime.UtcNow, annotation.OriginalMediaName, annotation.Time, annotation.Detections.ToList(), SourceEnum.Manual, null,
|
||||
_authProvider.CurrentUser.Role, _authProvider.CurrentUser.Email, generateThumbnail: false, token);
|
||||
|
||||
// Manual save from Validators -> Validated -> stream: azaion-annotations-confirm
|
||||
// AI, Manual save from Operators -> Created -> stream: azaion-annotations
|
||||
private async Task<Annotation> SaveAnnotationInner(DateTime createdDate, string originalMediaName, TimeSpan time, string imageExtension, List<Detection> detections, SourceEnum source, Stream? stream,
|
||||
private async Task<Annotation> SaveAnnotationInner(DateTime createdDate, string originalMediaName, TimeSpan time, List<Detection> detections, SourceEnum source, Stream? stream,
|
||||
RoleEnum userRole,
|
||||
string createdEmail,
|
||||
bool generateThumbnail = false,
|
||||
@@ -156,7 +155,7 @@ public class AnnotationService : INotificationHandler<AnnotationsDeletedEvent>
|
||||
Name = fName,
|
||||
OriginalMediaName = originalMediaName,
|
||||
Time = time,
|
||||
ImageExtension = imageExtension,
|
||||
ImageExtension = Constants.JPG_EXT,
|
||||
CreatedEmail = createdEmail,
|
||||
CreatedRole = userRole,
|
||||
AnnotationStatus = status,
|
||||
|
||||
Reference in New Issue
Block a user