Animierte Navbar-Anzeige für envelopeDto-Informationen hinzugefügt

This commit is contained in:
Developer 02 2024-04-04 17:35:43 +02:00
parent 29ae546d98
commit cbb03d77ba
9 changed files with 105 additions and 65 deletions

View File

@ -8,5 +8,7 @@ namespace EnvelopeGenerator.Application.Contracts
public interface IEnvelopeService : IBasicCRUDService<IEnvelopeRepository, EnvelopeDto, Envelope, int>
{
Task<IServiceResult<IEnumerable<EnvelopeDto>>> ReadAllWithAsync(bool documents = false, bool receivers = false, bool history = false);
Task<IServiceResult<EnvelopeDto>> ReadByUuidAsync(string uuid, bool withDocuments = false, bool withReceivers = false, bool withHistory = false);
}
}

View File

@ -18,8 +18,19 @@ namespace EnvelopeGenerator.Application.Services
public async Task<IServiceResult<IEnumerable<EnvelopeDto>>> ReadAllWithAsync(bool documents = false, bool receivers = false, bool history = false)
{
var entities = await _repository.ReadAllWithAsync(documents: documents, receivers: receivers, history: history);
var readDto = _mapper.MapOrThrow<IEnumerable<EnvelopeDto>>(entities);
var envelopes = await _repository.ReadAllWithAsync(documents: documents, receivers: receivers, history: history);
var readDto = _mapper.MapOrThrow<IEnumerable<EnvelopeDto>>(envelopes);
return Successful(readDto);
}
public async Task<IServiceResult<EnvelopeDto>> ReadByUuidAsync(string uuid, bool withDocuments = false, bool withReceivers = false, bool withHistory = false)
{
var envelope = await _repository.ReadByUuidAsync(uuid: uuid, withDocuments: withDocuments, withReceivers: withReceivers, withHistory: withHistory);
if (envelope is null)
return Failed<EnvelopeDto>();
var readDto = _mapper.MapOrThrow<EnvelopeDto>(envelope);
return Successful(readDto);
}
}

View File

@ -6,5 +6,7 @@ namespace EnvelopeGenerator.Infrastructure.Contracts
public interface IEnvelopeRepository : ICRUDRepository<Envelope, int>
{
Task<IEnumerable<Envelope>> ReadAllWithAsync(bool documents = false, bool receivers = false, bool history = false);
Task<Envelope?> ReadByUuidAsync(string uuid, bool withDocuments = false, bool withReceivers = false, bool withHistory = false);
}
}

View File

@ -27,5 +27,21 @@ namespace EnvelopeGenerator.Infrastructure.Repositories
return await query.ToListAsync();
}
public async Task<Envelope?> ReadByUuidAsync(string uuid, bool withDocuments = false, bool withReceivers = false, bool withHistory = false)
{
var query = _dbSet.Where(e => e.Uuid == uuid);
if (withDocuments)
query = query.Include(e => e.Documents);
if (withReceivers)
query = query.Include(e => e.Receivers);
if (withHistory)
query = query.Include(e => e.History);
return await query.FirstOrDefaultAsync();
}
}
}

View File

@ -1,4 +1,5 @@

using EnvelopeGenerator.Application.Contracts;
using EnvelopeGenerator.Common;
using EnvelopeGenerator.Web.Services;
using Microsoft.AspNetCore.Mvc;
@ -9,17 +10,31 @@ namespace EnvelopeGenerator.Web.Controllers
{
private readonly EnvelopeOldService envelopeService;
private readonly ActionService? actionService;
private readonly IEnvelopeService _envelopeService;
public EnvelopeController(DatabaseService database, EnvelopeOldService envelope, ILogger<EnvelopeController> logger) : base(database, logger)
public EnvelopeController(DatabaseService database, EnvelopeOldService envelope, ILogger<EnvelopeController> logger, IEnvelopeService envService) : base(database, logger)
{
envelopeService = envelope;
actionService = database?.Services?.actionService;
_envelopeService = envService;
}
[HttpGet]
[Route("api/envelope/{envelopeKey}")]
[HttpGet("api/envelope/{envelopeKey}")]
public async Task<IActionResult> Get(string envelopeKey)
{
//_logger.LogInformation($"Loading Envelope by Key [{envelopeKey}]");
//Tuple<string, string> result = Helpers.DecodeEnvelopeReceiverId(envelopeKey);
//var envelopeUuid = result.Item1;
//var receiverSignature = result.Item2;
////var receiverId = receiverModel.GetReceiverIdBySignature(receiverSignature);
////_logger.LogInformation("Resolved receiver signature to receiverId [{0}]", receiverId);
//var envlopeServiceResult = await _envelopeService.ReadByUuidAsync(envelopeUuid, withDocuments:true, withReceivers:true, withHistory:true);
//_logger.LogInformation("Loading envelope..");
try
{
// Validate Envelope Key and load envelope
@ -40,8 +55,7 @@ namespace EnvelopeGenerator.Web.Controllers
}
}
[HttpPost]
[Route("api/envelope/{envelopeKey}")]
[HttpPost("api/envelope/{envelopeKey}")]
public async Task<IActionResult> Update(string envelopeKey, int index)
{
try

View File

@ -1,4 +1,6 @@
using EnvelopeGenerator.Common;
using EnvelopeGenerator.Application.Contracts;
using EnvelopeGenerator.Application.Services;
using EnvelopeGenerator.Common;
using EnvelopeGenerator.Web.Models;
using EnvelopeGenerator.Web.Services;
using Microsoft.AspNetCore.Mvc;
@ -9,24 +11,24 @@ namespace EnvelopeGenerator.Web.Controllers
{
public class HomeController : BaseController
{
private readonly EnvelopeOldService _envelopeService;
private readonly EnvelopeOldService envelopeOldService;
private readonly IConfiguration _config;
private readonly IEnvelopeService _envelopeService;
public HomeController(DatabaseService databaseService, EnvelopeOldService envelopeService, ILogger<HomeController> logger, IConfiguration configuration) : base(databaseService, logger)
public HomeController(DatabaseService databaseService, EnvelopeOldService envelopeOldService, ILogger<HomeController> logger, IConfiguration configuration, IEnvelopeService envelopeService) : base(databaseService, logger)
{
this.envelopeOldService = envelopeOldService;
_envelopeService = envelopeService;
_config = configuration;
}
[HttpGet]
[Route("/")]
[HttpGet("/")]
public IActionResult Index()
{
return View();
}
[HttpPost]
[Route("/")]
[HttpPost("/")]
public IActionResult DebugEnvelopes([FromForm] string password)
{
try
@ -51,7 +53,7 @@ namespace EnvelopeGenerator.Web.Controllers
return View("Index");
}
List<Envelope> envelopes = _envelopeService.LoadEnvelopes();
List<Envelope> envelopes = envelopeOldService.LoadEnvelopes();
return View(envelopes);
}
@ -62,11 +64,10 @@ namespace EnvelopeGenerator.Web.Controllers
}
}
[HttpGet]
[Route("/EnvelopeKey/{envelopeReceiverId}")]
[HttpGet("/EnvelopeKey/{envelopeReceiverId}")]
public async Task<IActionResult> ShowEnvelope([FromRoute] string envelopeReceiverId)
{
EnvelopeResponse response = await _envelopeService.LoadEnvelope(envelopeReceiverId);
EnvelopeResponse response = await envelopeOldService.LoadEnvelope(envelopeReceiverId);
if (response.Envelope.UseAccessCode)
{
@ -88,11 +89,10 @@ namespace EnvelopeGenerator.Web.Controllers
}
}
[HttpPost]
[Route("/EnvelopeKey/{envelopeReceiverId}/Locked")]
[HttpPost("/EnvelopeKey/{envelopeReceiverId}/Locked")]
public async Task<IActionResult> ShowEnvelopePost([FromRoute] string envelopeReceiverId, [FromForm] string access_code)
{
EnvelopeResponse response = await _envelopeService.LoadEnvelope(envelopeReceiverId);
EnvelopeResponse response = await envelopeOldService.LoadEnvelope(envelopeReceiverId);
string accessCode = response.Receiver.AccessCode;
if (string.IsNullOrEmpty(access_code))
@ -114,18 +114,21 @@ namespace EnvelopeGenerator.Web.Controllers
}
}
[HttpGet]
[Route("/EnvelopeKey/{envelopeReceiverId}/Locked")]
public IActionResult EnvelopeLocked([FromRoute] string envelopeReceiverId)
[HttpGet("/EnvelopeKey/{envelopeReceiverId}/Locked")]
public async Task<IActionResult> EnvelopeLocked([FromRoute] string envelopeReceiverId)
{
Tuple<string, string> decode = Common.Helpers.DecodeEnvelopeReceiverId(envelopeReceiverId);
var envelopeUuid = decode.Item1;
var envlopeServiceResult = await _envelopeService.ReadByUuidAsync(envelopeUuid, withDocuments: true, withReceivers: true, withHistory: true);
ViewData["Envelope"] = envlopeServiceResult.Data;
ViewData["EnvelopeKey"] = envelopeReceiverId;
return View();
}
[HttpGet]
[Route("/EnvelopeKey/{EnvelopeReceiverId}/Success")]
[HttpGet("/EnvelopeKey/{EnvelopeReceiverId}/Success")]
public IActionResult EnvelopeSigned()
{
ViewData["EnvelopeKey"] = HttpContext.Request.RouteValues["EnvelopeReceiverId"];
@ -133,7 +136,6 @@ namespace EnvelopeGenerator.Web.Controllers
return View();
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{

View File

@ -20,8 +20,21 @@ namespace EnvelopeGenerator.Web.Controllers
}
[HttpGet]
public virtual async Task<IActionResult> GetAll([FromQuery] bool withDocuments = false, [FromQuery] bool withReceivers = false, [FromQuery] bool withHistory = false)
public virtual async Task<IActionResult> GetAll([FromQuery] string? envelopeKey = default, [FromQuery] bool withDocuments = true, [FromQuery] bool withReceivers = true, [FromQuery] bool withHistory = true)
{
if(envelopeKey is not null)
{
Tuple<string, string> decode = Common.Helpers.DecodeEnvelopeReceiverId(envelopeKey);
var envelopeUuid = decode.Item1;
var envlopeServiceResult = await _service.ReadByUuidAsync(envelopeUuid, withDocuments: true, withReceivers: true, withHistory: true);
if (envlopeServiceResult.IsSuccess)
{
return Ok(envlopeServiceResult.Data);
}
return NotFound();
}
var result = await _service.ReadAllWithAsync(documents: withDocuments, receivers: withReceivers, history: withHistory);
if (result.IsSuccess)
{

View File

@ -1,42 +1,25 @@
@{
@using EnvelopeGenerator.Application.DTOs;
@{
ViewData["Title"] = "Dokument unterschreiben";
EnvelopeDto? envelopeDto = ViewData["envelope"] as EnvelopeDto;
}
<nav class="navbar navbar-expand-lg bg-body-tertiary">
@if(envelopeDto is not null)
{
<nav class="navbar navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarToggleExternalContent" aria-controls="navbarToggleExternalContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Dropdown
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Action</a></li>
<li><a class="dropdown-item" href="#">Another action</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="#">Something else here</a></li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link disabled" aria-disabled="true">Disabled</a>
</li>
</ul>
<form class="d-flex" role="search">
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success" type="submit">Search</button>
</form>
</div>
<div class="navbar-brand">Bitte prüfen Sie diese Dokumente und handeln Sie danach</div>
</div>
</nav>
<div class="collapse" id="navbarToggleExternalContent" data-bs-theme="light">
<div class="bg-light p-1">
<h5 class="text-body-emphasis h4">Collapsed content</h5>
<span class="text-body-secondary">Toggleable via the navbar brand.</span>
</div>
</div>
}
<script>
document.addEventListener("DOMContentLoaded", async () => {
const app = new App("#app", "@ViewData["EnvelopeKey"]");

View File

@ -14,8 +14,6 @@ class App {
this.container = container
this.envelopeKey = envelopeKey
// Initialize classes
console.debug('Initializing classes..')
this.UI = new UI()
this.Network = new Network()
this.Annotation = new Annotation()
@ -71,7 +69,6 @@ class App {
const arrayBuffer = documentResponse.data
// Load PSPDFKit
console.debug('Loading PSPDFKit..')
this.Instance = await this.UI.loadPSPDFKit(arrayBuffer, this.container)
this.UI.configurePSPDFKit(this.Instance, this.handleClick.bind(this))