Skip to content

Commit

Permalink
Merge pull request #10 from davewalker5/MC-58-Catalogue-Export-From-UI
Browse files Browse the repository at this point in the history
MC-58 Catalogue export from UI
  • Loading branch information
davewalker5 authored Oct 29, 2023
2 parents f9145d5 + b6d9af5 commit 3cd4dd6
Show file tree
Hide file tree
Showing 47 changed files with 1,371 additions and 103 deletions.
37 changes: 26 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,12 @@
### CSV File Format

- The first row in the CSV file is expected to contain headers and is ignored
- All fields in the CSV file must be double-quoted and may not contain ","
- Durations should be specified in MM:SS format, e.g. "03:10" for 3 minutes and 10 seconds
- The following is an example, illustrating the format for the headers and for the rows containing data:

```
Artist,Album,Genre,Released,Cover Url,Track Number,Track,Duration
"Nat King Cole","After Midnight","Jazz","1957","","1","Just You Just Me","03:00"
Duke Ellington,Ellington Indigoes,Jazz,1958,,1,Solitude,04:43
```

### Example - Album Lookup
Expand Down Expand Up @@ -167,9 +166,24 @@ MusicCatalogue.LookupTool --lookup "John Coltrane" "Blue Train"
- The album lookup facility uses the algorithm described under "Album Lookup", below
- Consequently, searching for an album that's not currently in the catalogue will add it to the local database

### Data Import and Export
### Data Import

- These are scheduled for implementation in a future iteration of the UI
- This is scheduled for implementation in a future iteration of the UI

### Data Export

- To export the music catalogue, click on the "Export" menu bar item:

<img src="diagrams/catalogue-export.png" alt="Music Catalogue Export" width="600">

- Enter the file name, without a path, and click on the "Export" button to request an export
- A request is sent to the web service to perform an export of the catalogue in the background
- The "export" page is updated when the request has been sent:

<img src="diagrams/catalogue-export-requested.png" alt="Music Catalogue Export" width="600">

- Once the export is complete, the file will appear in the folder indicated by the "CatalogueExportPath" configuration setting (see below)
- The exported format is based on the file extension for the supplied file path, as per the command-line tool (see above)

[^ top](#musiccatalogue)

Expand Down Expand Up @@ -230,13 +244,14 @@ Task.Run(() => factory.Users.AddAsync(userName, password)).Wait();

- The appsettings.json file in the console application project contains the following keys for controlling the application:

| Section | Key | Purpose |
| ------------------- | ---------------- | ----------------------------------------------------------------------- |
| ApplicationSettings | LogFile | Path and name of the log file. If this is blank, no log file is created |
| ApplicationSettings | MinimumLogLevel | Minimum message severity to log (Debug, Info, Warning or Error) |
| ApplicationSettings | ApiEndpoints | Set of endpoint definitions for external APIs |
| ApplicationSettings | ApiServiceKeys | Set of API key definitions for external APIs |
| ConnectionStrings | MusicCatalogueDB | SQLite connection string for the database |
| Section | Key | Purpose |
| ------------------- | ------------------- | ----------------------------------------------------------------------- |
| ApplicationSettings | LogFile | Path and name of the log file. If this is blank, no log file is created |
| ApplicationSettings | MinimumLogLevel | Minimum message severity to log (Debug, Info, Warning or Error) |
| ApplicationSettings | CatalogueExportPath | Path to the folder where music catalogue exports are written |
| ApplicationSettings | ApiEndpoints | Set of endpoint definitions for external APIs |
| ApplicationSettings | ApiServiceKeys | Set of API key definitions for external APIs |
| ConnectionStrings | MusicCatalogueDB | SQLite connection string for the database |

### External API Configuration

Expand Down
Binary file added diagrams/catalogue-export-requested.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added diagrams/catalogue-export.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docker/api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/core/aspnet:latest
COPY musiccatalogue.api-1.5.0.0 /opt/musiccatalogue.api-1.5.0.0
WORKDIR /opt/musiccatalogue.api-1.5.0.0/bin
COPY musiccatalogue.api-1.6.0.0 /opt/musiccatalogue.api-1.6.0.0
WORKDIR /opt/musiccatalogue.api-1.6.0.0/bin
ENTRYPOINT [ "./MusicCatalogue.Api" ]
4 changes: 2 additions & 2 deletions docker/ui/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM node:20-alpine
COPY musiccatalogue.ui-1.5.0.0 /opt/musiccatalogue.ui-1.5.0.0
WORKDIR /opt/musiccatalogue.ui-1.5.0.0
COPY musiccatalogue.ui-1.6.0.0 /opt/musiccatalogue.ui-1.6.0.0
WORKDIR /opt/musiccatalogue.ui-1.6.0.0
RUN npm install
RUN npm run build
ENTRYPOINT [ "npm", "start" ]
33 changes: 33 additions & 0 deletions src/MusicCatalogue.Api/Controllers/ExportController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using MusicCatalogue.Api.Entities;
using MusicCatalogue.Api.Interfaces;

namespace MusicCatalogue.Api.Controllers
{
[Authorize]
[ApiController]
[ApiConventionType(typeof(DefaultApiConventions))]
[Route("[controller]")]
public class ExportController : Controller
{
private readonly IBackgroundQueue<CatalogueExportWorkItem> _catalogueQueue;

public ExportController(IBackgroundQueue<CatalogueExportWorkItem> catalogueQueue)
{
_catalogueQueue = catalogueQueue;
}

[HttpPost]
[Route("catalogue")]
public IActionResult ExportSightings([FromBody] CatalogueExportWorkItem item)
{
// Set the job name used in the job status record
item.JobName = "Catalogue Export";

// Queue the work item
_catalogueQueue.Enqueue(item);
return Accepted();
}
}
}
15 changes: 15 additions & 0 deletions src/MusicCatalogue.Api/Entities/BackgroundWorkItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.Diagnostics.CodeAnalysis;

namespace MusicCatalogue.Api.Entities
{
[ExcludeFromCodeCoverage]
public class BackgroundWorkItem
{
public string JobName { get; set; } = "";

public override string ToString()
{
return $"JobName = {JobName}";
}
}
}
15 changes: 15 additions & 0 deletions src/MusicCatalogue.Api/Entities/CatalogueExportWorkItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.Diagnostics.CodeAnalysis;

namespace MusicCatalogue.Api.Entities
{
[ExcludeFromCodeCoverage]
public class CatalogueExportWorkItem : BackgroundWorkItem
{
public string FileName { get; set; } = "";

public override string ToString()
{
return $"{base.ToString()}, FileName = {FileName}";
}
}
}
Loading

0 comments on commit 3cd4dd6

Please sign in to comment.