Skip to content
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

Dev #62

Merged
merged 94 commits into from
Jul 6, 2020
Merged

Dev #62

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
8d6795b
remove duplicated items by bad merge
ivaneliasoo Jun 5, 2020
4b01ecb
add security tier
ivaneliasoo Jun 6, 2020
bed221d
change pass move token controller, change tokencontroller to authcont…
ivaneliasoo Jun 6, 2020
0f0b56b
Merge branch 'master' into dev
ivaneliasoo Jun 6, 2020
c389b3e
Corrige Bug al gueardar seeds
ivaneliasoo Jun 6, 2020
3c3351d
Merge branch 'dev' of https://github.com/ivaneliasoo/Inspections into…
ivaneliasoo Jun 6, 2020
f92da27
Backend CheckLists
ivaneliasoo Jun 9, 2020
f1ab44c
Backend Signatures, Report COnfiguration repository, queires checklis…
ivaneliasoo Jun 9, 2020
a792dd6
Uploads service & Storage helper class, paths on settings
ivaneliasoo Jun 9, 2020
fbd9226
Merge branch 'master' into dev
ivaneliasoo Jun 9, 2020
90cf2b0
solve typo in Shared proyect reference
ivaneliasoo Jun 9, 2020
0c534d8
Merge branch 'dev' of https://github.com/ivaneliasoo/Inspections into…
ivaneliasoo Jun 9, 2020
1d6fd4e
Fix Bug Querying CheckLists
ivaneliasoo Jun 9, 2020
3de5506
Ignore some local files
ivaneliasoo Jun 9, 2020
e3045e7
Optional items in query
ivaneliasoo Jun 9, 2020
1e83c1a
Merge branch 'master' into dev
ivaneliasoo Jun 9, 2020
531a621
update dev branch (#21)
ivaneliasoo Jun 10, 2020
0b218b3
Solves Signature add and update bug
ivaneliasoo Jun 10, 2020
dfadd53
Merge branch 'dev' of https://github.com/ivaneliasoo/Inspections into…
ivaneliasoo Jun 10, 2020
1003e18
simplify api routes
ivaneliasoo Jun 10, 2020
3e667d7
Quering and DTO mappin for signatures
ivaneliasoo Jun 10, 2020
388ed49
Backend Reports Configurations
ivaneliasoo Jun 10, 2020
42ed763
Backend Reports Config
ivaneliasoo Jun 10, 2020
b0651c9
Merge branch 'master' into dev
ivaneliasoo Jun 10, 2020
bb7d450
preparing project to deploy
ivaneliasoo Jun 10, 2020
e54294a
Merge branch 'dev' of https://github.com/ivaneliasoo/Inspections into…
ivaneliasoo Jun 10, 2020
ca9de49
updates composition api package version
ivaneliasoo Jun 10, 2020
8ca4e80
change to npm
ivaneliasoo Jun 10, 2020
05df401
disable husky
ivaneliasoo Jun 10, 2020
f7acee3
Merge branch 'master' into dev
ivaneliasoo Jun 11, 2020
02539a1
binds to 0.0.0.0
ivaneliasoo Jun 11, 2020
c4b55ae
Merge branch 'dev' of https://github.com/ivaneliasoo/Inspections into…
ivaneliasoo Jun 11, 2020
88ba996
Update dotnet-core.yml
ivaneliasoo Jun 11, 2020
baa97b5
delete web.config
ivaneliasoo Jun 11, 2020
28f4c04
Merge branch 'dev' of https://github.com/ivaneliasoo/Inspections into…
ivaneliasoo Jun 11, 2020
216039d
dispatch pipelines
ivaneliasoo Jun 11, 2020
e7f6deb
Merge branch 'master' into dev
ivaneliasoo Jun 11, 2020
fb1e3cd
solves vuetify failling in Production Stage
ivaneliasoo Jun 11, 2020
52c77ec
Merge branch 'dev' of https://github.com/ivaneliasoo/Inspections into…
ivaneliasoo Jun 11, 2020
3a2ca98
upload pending file
ivaneliasoo Jun 11, 2020
eab6455
Merge branch 'master' into dev
ivaneliasoo Jun 11, 2020
2b5aaa6
review indexjs
ivaneliasoo Jun 11, 2020
caf117f
Merge branch 'dev' of https://github.com/ivaneliasoo/Inspections into…
ivaneliasoo Jun 12, 2020
3fc3a14
updates dev branch from master (#40)
ivaneliasoo Jun 12, 2020
4b907b6
Merge branch 'dev' of https://github.com/ivaneliasoo/Inspections into…
ivaneliasoo Jun 12, 2020
0e4159b
adjustments call with jesus
ivaneliasoo Jun 13, 2020
48513a7
Merge branch 'master' into dev
ivaneliasoo Jun 13, 2020
ec2411f
update gitignore, configure containers
ivaneliasoo Jun 16, 2020
bc5a09d
Creating new REports based on selected configuration, add new fields …
ivaneliasoo Jun 16, 2020
26e58fa
New Project structure, adds login
ivaneliasoo Jun 17, 2020
9d9b38b
Maquetado app macro and menus
ivaneliasoo Jun 17, 2020
e6147f2
Pages titles
ivaneliasoo Jun 17, 2020
829e6e8
Grids Checklist & reports Configs, stores, creates types, Authenticat…
ivaneliasoo Jun 17, 2020
38eda04
remove title
ivaneliasoo Jun 17, 2020
dd4e0c0
Merge branch 'master' into dev
ivaneliasoo Jun 17, 2020
bf8767f
startup poge must reports
ivaneliasoo Jun 17, 2020
4947a5a
Merge branch 'dev' of https://github.com/ivaneliasoo/Inspections into…
ivaneliasoo Jun 17, 2020
e650fa8
Create pending types
ivaneliasoo Jun 18, 2020
e260703
Deletes duplicated type
ivaneliasoo Jun 18, 2020
89c38f0
resolve some warnings
ivaneliasoo Jun 18, 2020
05f0b5c
Backend Adjustments
ivaneliasoo Jun 18, 2020
5348153
New Grids: Signatures, reports, Create new Reports, all grids now can…
ivaneliasoo Jun 18, 2020
6f7e945
Resolve Conflicts
ivaneliasoo Jun 18, 2020
c768a2f
organize login view, adds logo in toolbar
ivaneliasoo Jun 18, 2020
33e1edb
organize code
ivaneliasoo Jun 18, 2020
783bf04
Include items in checks query
ivaneliasoo Jun 18, 2020
6b1a256
mostrar items de checks
ivaneliasoo Jun 18, 2020
6b99a4c
mostrar error al inciar sesion
ivaneliasoo Jun 18, 2020
4a76a33
Solver some bugs creating reports, add advanced filter to checkl;ists…
ivaneliasoo Jun 22, 2020
bf0449e
missing packages and delete reports
ivaneliasoo Jun 22, 2020
c55ce6c
delete signatures
ivaneliasoo Jun 23, 2020
8501543
Configura Forms Validations
ivaneliasoo Jun 24, 2020
082492b
AddEdit Signatures
ivaneliasoo Jun 24, 2020
a94bc92
update nuxt version, organize pages folder, change mode to spa
ivaneliasoo Jun 24, 2020
ea79385
cahnge redirection to options
ivaneliasoo Jun 24, 2020
b1d529a
add edit Checklist & itmes back and UI
ivaneliasoo Jun 25, 2020
57fc928
componentes for reports editing
ivaneliasoo Jun 25, 2020
ba83b53
reports checks tab
ivaneliasoo Jun 25, 2020
fc9e585
dynamic signatures in report, some stayles changes
ivaneliasoo Jun 25, 2020
870eeab
Resolves Conflicts with master
ivaneliasoo Jun 25, 2020
2b59e36
Recover DeleteReportCommand
ivaneliasoo Jun 25, 2020
e8a9b03
Resolve Conflict with master
ivaneliasoo Jun 25, 2020
a1ca5ef
Disable dropzone deployment error
ivaneliasoo Jun 25, 2020
7502a1a
Use Input for uploads and remove dropzone, back add/edit/update photos
ivaneliasoo Jun 28, 2020
9b5cb71
bugsfix, edit photos, update checklists from report, update signature…
ivaneliasoo Jul 3, 2020
881109b
Block edit report when closed
ivaneliasoo Jul 3, 2020
063a94d
Block signatures edition when completed, prevent delete reports and s…
ivaneliasoo Jul 3, 2020
33c363c
Completes Cruds Operation, Reports Configurations and Reports Generat…
ivaneliasoo Jul 3, 2020
a2a1cfa
Export Report as Pdf
ivaneliasoo Jul 4, 2020
5c63ee8
allow all CORS origin for pictures
ivaneliasoo Jul 5, 2020
b599601
Create PhotoRecords PDFs
ivaneliasoo Jul 5, 2020
a79f36c
Merge branch 'feature/photorecord-pdf' into dev
ivaneliasoo Jul 5, 2020
e87c277
Fixes Las Review Bugs
ivaneliasoo Jul 6, 2020
cb98c79
Merge branch 'master' into dev
ivaneliasoo Jul 6, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public DeletePhotoRecordCommandHandler(IReportsRepository reportsRepository)
}
public async Task<bool> Handle(DeletePhotoRecordCommand request, CancellationToken cancellationToken)
{
var report = await _reportsRepository.GetByIdAsync(request.Id).ConfigureAwait(false);
var report = await _reportsRepository.GetByIdAsync(request.ReportId).ConfigureAwait(false);

var photo = report.PhotoRecords.Where(n => n.Id == request.Id).FirstOrDefault();
report.RemovePhoto(photo);
Expand Down
41 changes: 32 additions & 9 deletions src/Backend/Inspections.API/Features/Reports/ReportsController.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Inspections.API.ApplicationServices;
using Inspections.API.Features.Inspections.Commands;
using Inspections.API.Features.Reports.Commands;
using Inspections.API.Models.Configuration;
using Inspections.Core.Domain.ReportsAggregate;
using Inspections.Core.Interfaces;
using Inspections.Infrastructure.Data;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
Expand All @@ -17,18 +19,22 @@

namespace Inspections.API.Features.Inspections
{
[Authorize]
[Authorize]
[Route("[controller]")]
[ApiController]
public class ReportsController : ControllerBase
{
private readonly IMediator _mediator;
private readonly IReportsRepository _reportsRepository;
private readonly InspectionsContext _context;
private readonly IOptions<ClientSettings> storageOptions;

public ReportsController(IMediator mediator, IReportsRepository reportsRepository)
public ReportsController(IMediator mediator, IReportsRepository reportsRepository, InspectionsContext context, IOptions<ClientSettings> storageOptions)
{
this._mediator = mediator ?? throw new ArgumentNullException(nameof(mediator));
this._reportsRepository = reportsRepository ?? throw new ArgumentNullException(nameof(reportsRepository));
_mediator = mediator ?? throw new ArgumentNullException(nameof(mediator));
_reportsRepository = reportsRepository ?? throw new ArgumentNullException(nameof(reportsRepository));
_context = context ?? throw new ArgumentNullException(nameof(context));
this.storageOptions = storageOptions ?? throw new ArgumentNullException(nameof(storageOptions));
}

[HttpPost]
Expand Down Expand Up @@ -81,6 +87,23 @@ public async Task<IActionResult> DeleteReport(int id)
return NoContent();
}

[HttpGet("{id:int}/photorecord")]
public IActionResult GetPhotoRecords(int id)
{
var photos = _context.Set<PhotoRecord>().Where(p => p.ReportId == id)
.Select(p => new { p.Label, p.FileName, Base64String = ToBase64String($"{Directory.GetCurrentDirectory()}{p.FileName.Replace("ReportsImages",storageOptions.Value.ReportsImagesFolder)}") });
if (photos!=null)
return Ok(photos);

return BadRequest();
}

private static string ToBase64String(string fileName)
{
byte[] fileBytes = System.IO.File.ReadAllBytes(fileName);
return "data:image/png;base64," + Convert.ToBase64String(fileBytes);
}

[HttpPost("{id:int}/photorecord")]
public async Task<IActionResult> AddPhotoRecord(int id, [FromForm] string label)
{
Expand All @@ -104,7 +127,7 @@ public async Task<IActionResult> AddNote(int id, [FromBody] AddNoteCommand note)
{

var result = await _mediator.Send(note).ConfigureAwait(false);
if (result>0)
if (result > 0)
return Ok(result);

return BadRequest();
Expand All @@ -129,7 +152,7 @@ public async Task<IActionResult> EditPhotoRecord(int id, int idPhoto, [FromBody]
if (photo.Id != idPhoto || photo.ReportId != id)
return BadRequest();

var result = await _mediator.Send(new EditPhotoRecordCommand(photo.ReportId,photo.Label,photo.Id)).ConfigureAwait(false);
var result = await _mediator.Send(new EditPhotoRecordCommand(photo.ReportId, photo.Label, photo.Id)).ConfigureAwait(false);
if (result)
return Ok();

Expand All @@ -139,7 +162,7 @@ public async Task<IActionResult> EditPhotoRecord(int id, int idPhoto, [FromBody]
[HttpDelete("{id:int}/photorecord/{idPhoto:int}")]
public async Task<IActionResult> DeletePhotoRecord(int id, int idPhoto)
{
var result = await _mediator.Send(new DeletePhotoRecordCommand(idPhoto,id)).ConfigureAwait(false);
var result = await _mediator.Send(new DeletePhotoRecordCommand(idPhoto, id)).ConfigureAwait(false);
if (result)
return Ok();

Expand All @@ -149,7 +172,7 @@ public async Task<IActionResult> DeletePhotoRecord(int id, int idPhoto)
[HttpDelete("{id:int}/note/{idNote:int}")]
public async Task<IActionResult> DeleteNote(int id, int idNote)
{
var result = await _mediator.Send(new DeleteNoteCommand(idNote,id)).ConfigureAwait(false);
var result = await _mediator.Send(new DeleteNoteCommand(idNote, id)).ConfigureAwait(false);
if (result)
return Ok();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Inspections.API.Features.ReportsConfiguration.Commands
{
public class AddReportConfigurationCommand : IRequest<bool>
public class AddReportConfigurationCommand : IRequest<int>
{
public AddReportConfigurationCommand(ReportType type,
string title,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

namespace Inspections.API.Features.ReportsConfiguration.Handlers
{
public class AddReportConfigurationCommandHandler : IRequestHandler<AddReportConfigurationCommand, bool>
public class AddReportConfigurationCommandHandler : IRequestHandler<AddReportConfigurationCommand, int>
{
private readonly IReportConfigurationsRepository _reportConfigurationsRepository;
private readonly InspectionsContext _context;
Expand All @@ -26,7 +26,7 @@ public AddReportConfigurationCommandHandler(IReportConfigurationsRepository repo
_context = context ?? throw new ArgumentNullException(nameof(context));
}

public async Task<bool> Handle(AddReportConfigurationCommand request, CancellationToken cancellationToken)
public async Task<int> Handle(AddReportConfigurationCommand request, CancellationToken cancellationToken)
{
Guard.Against.Null(request, nameof(request));

Expand Down Expand Up @@ -54,7 +54,27 @@ public async Task<bool> Handle(AddReportConfigurationCommand request, Cancellati

var result = await _reportConfigurationsRepository.AddAsync(repoConfig).ConfigureAwait(false);

return result.Id > 0;
return result.Id;
}

private List<CheckList> PrepareForConfiguration(List<CheckList> checks)
{
var result = new List<CheckList>();
foreach (CheckList check in checks)
{
result.Add(check.CloneForReportConfiguration());
}
return result;
}

private List<Signature> PrepareForConfiguration(List<Signature> signatures)
{
var result = new List<Signature>();
foreach (Signature signature in signatures)
{
result.Add(signature.PreparteForNewReportConfiguration());
}
return result;
}

private List<CheckList> PrepareForConfiguration(List<CheckList> checks)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ public ReportConfigurationController(IMediator mediator
public async Task<IActionResult> CreateReportConfig([FromBody] AddReportConfigurationCommand report)
{
var result = await _mediator.Send(report).ConfigureAwait(false);
if (!result)
if (result <= 0)
return Conflict();

return Ok();
return Ok(result);
}

[HttpPut("{id:int}")]
Expand Down
6 changes: 5 additions & 1 deletion src/Backend/Inspections.API/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,11 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), Configuration.GetValue<string>("ClientSettings:ReportsImagesFolder"))),
RequestPath = "/ReportsImages"
RequestPath = "/ReportsImages",
OnPrepareResponse = ctx =>
{
ctx.Context.Response.Headers["Access-Control-Allow-Origin"] = "*";
}
});

// Enable middleware to serve generated Swagger as a JSON endpoint.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class CheckList : Entity<int>, IAggregateRoot
public List<CheckListParam> TextParams { get; private set; } = new List<CheckListParam>();
public string Annotation { get; private set; }
public bool IsConfiguration { get; set; }
public bool Completed => !_checks.Any(c => c.Required && (c.Checked == CheckValue.False));
private readonly List<CheckListItem> _checks = new List<CheckListItem>();

public CheckList(string text, List<CheckListParam> textParams, string annotation, bool isConfiguration)
Expand All @@ -34,7 +35,6 @@ public CheckList(string text, List<CheckListParam> textParams, string annotation
private CheckList() { } //Required by EF

public IReadOnlyList<CheckListItem> Checks => _checks.AsReadOnly();
public bool Completed => !Checks.Any(c => c.Required && (c.Checked != CheckValue.False || c.Checked != CheckValue.NA));

public void Edit(string text, string annotation, bool isConfiguration)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void Edit(string name, string address, EMALicense license, DateTimeOffset
}

public IReadOnlyCollection<PhotoRecord> PhotoRecords => photoRecords;
public bool Completed => !checkList.Any(c => c.Completed);
public bool Completed => !checkList.Any(c => !c.Completed);

public void AddNote(Note note)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ public async Task<Report> AddAsync(Report entity)

public async Task<IEnumerable<Report>> GetAll(string filter)
{
// TODO: Change
return await _context.Reports
.Include(p => p.CheckList)
.ThenInclude(p=>p.Checks)
.Include(p=>p.Signatures)
.Include(p=>p.Notes)
.Include(p => p.PhotoRecords)
Expand Down
Loading