Send To Device Support (#1557)

* Tweaked the logging output

* Started implementing some basic idea for devices

* Updated Email Service with new API routes

* Implemented basic DB structure and some APIs to prep for the UI and flows.

* Added an abstract class to make Unit testing easier.

* Removed dependency we don't need

* Updated the UI to be able to show devices and add new devices. Email field will update the platform if the user hasn't interacted with it already.

* Added ability to delete a device as well

* Basic ability to send files to devices works

* Refactored Action code to pass ActionItem back and allow for dynamic children based on an Observable (api).

Hooked in ability to send a chapter to a device. There is no logic in the FE to validate type.

* Fixed a broken unit test

* Implemented the ability to edit a device

* Code cleanup

* Fixed a bad success message

* Fixed broken unit test from updating mock layer
This commit is contained in:
Joseph Milazzo 2022-09-23 17:41:29 -05:00 committed by GitHub
parent ab0f13ef74
commit 9d7476a367
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
79 changed files with 3026 additions and 157 deletions

View file

@ -16,6 +16,9 @@ public class AppUser : IdentityUser<int>, IHasConcurrencyToken
public ICollection<AppUserProgress> Progresses { get; set; }
public ICollection<AppUserRating> Ratings { get; set; }
public AppUserPreferences UserPreferences { get; set; }
/// <summary>
/// Bookmarks associated with this User
/// </summary>
public ICollection<AppUserBookmark> Bookmarks { get; set; }
/// <summary>
/// Reading lists associated with this user
@ -26,6 +29,10 @@ public class AppUser : IdentityUser<int>, IHasConcurrencyToken
/// </summary>
public ICollection<Series> WantToRead { get; set; }
/// <summary>
/// A list of Devices which allows the user to send files to
/// </summary>
public ICollection<Device> Devices { get; set; }
/// <summary>
/// An API Key to interact with external services, like OPDS
/// </summary>
public string ApiKey { get; set; }

49
API/Entities/Device.cs Normal file
View file

@ -0,0 +1,49 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Net;
using API.Entities.Enums.Device;
using API.Entities.Interfaces;
namespace API.Entities;
/// <summary>
/// A Device is an entity that can receive data from Kavita (kindle)
/// </summary>
public class Device : IEntityDate
{
public int Id { get; set; }
/// <summary>
/// Last Seen IP Address of the device
/// </summary>
public string IpAddress { get; set; }
/// <summary>
/// A name given to this device
/// </summary>
/// <remarks>If this device is web, this will be the browser name</remarks>
/// <example>Pixel 3a, John's Kindle</example>
public string Name { get; set; }
/// <summary>
/// An email address associated with the device (ie Kindle). Will be used with Send to functionality
/// </summary>
public string EmailAddress { get; set; }
/// <summary>
/// Platform (ie) Windows 10
/// </summary>
public DevicePlatform Platform { get; set; }
//public ICollection<string> SupportedExtensions { get; set; } // TODO: This requires some sort of information at mangaFile level (unless i repack)
public int AppUserId { get; set; }
public AppUser AppUser { get; set; }
/// <summary>
/// Last time this device was used to send a file
/// </summary>
public DateTime LastUsed { get; set; }
public DateTime Created { get; set; }
public DateTime LastModified { get; set; }
}

View file

@ -0,0 +1,25 @@
using System.ComponentModel;
namespace API.Entities.Enums.Device;
public enum DevicePlatform
{
[Description("Custom")]
Custom = 0,
/// <summary>
/// PocketBook device, email ends in @pbsync.com
/// </summary>
[Description("PocketBook")]
PocketBook = 1,
/// <summary>
/// Kindle device, email ends in @kindle.com
/// </summary>
[Description("Kindle")]
Kindle = 2,
/// <summary>
/// Kobo device,
/// </summary>
[Description("Kobo")]
Kobo = 3,
}

View file

@ -8,18 +8,18 @@ namespace API.Entities.Metadata;
/// A relation flows between one series and another.
/// Series ---kind---> target
/// </summary>
public class SeriesRelation
public sealed class SeriesRelation
{
public int Id { get; set; }
public RelationKind RelationKind { get; set; }
public virtual Series TargetSeries { get; set; }
public Series TargetSeries { get; set; }
/// <summary>
/// A is Sequel to B. In this example, TargetSeries is A. B will hold the foreign key.
/// </summary>
public int TargetSeriesId { get; set; }
// Relationships
public virtual Series Series { get; set; }
public Series Series { get; set; }
public int SeriesId { get; set; }
}