mirror of
https://github.com/sphildreth/roadie
synced 2024-11-22 12:13:10 +00:00
Additions for roadie-vuejs
This commit is contained in:
parent
f689436bfb
commit
d0ce983150
6 changed files with 41 additions and 46 deletions
|
@ -79,8 +79,10 @@ namespace Roadie.Api.Controllers
|
|||
Username = user.UserName,
|
||||
user.Email,
|
||||
user.LastLogin,
|
||||
avatarUrl = avatarUrl,
|
||||
Token = t
|
||||
avatarUrl,
|
||||
Token = t,
|
||||
user.Timeformat,
|
||||
user.Timezone
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
@ -100,6 +100,7 @@ namespace Roadie.Api.Services
|
|||
}
|
||||
var result = artist.Adapt<Artist>();
|
||||
result.Thumbnail = base.MakeArtistThumbnailImage(id);
|
||||
result.MediumThumbnail = base.MakeThumbnailImage(id, "artist", this.Configuration.MediumImageSize.Width, this.Configuration.MediumImageSize.Height);
|
||||
result.Genres = artist.Genres.Select(x => new DataToken { Text = x.Genre.Name, Value = x.Genre.RoadieId.ToString() });
|
||||
if (includes != null && includes.Any())
|
||||
{
|
||||
|
@ -183,25 +184,28 @@ namespace Roadie.Api.Services
|
|||
}
|
||||
if (includes.Contains("associatedartists"))
|
||||
{
|
||||
result.AssociatedWithArtists = (from aa in this.DbContext.ArtistAssociations
|
||||
var associatedWithArtists = (from aa in this.DbContext.ArtistAssociations
|
||||
join a in this.DbContext.Artists on aa.AssociatedArtistId equals a.Id
|
||||
where aa.ArtistId == artist.Id
|
||||
orderby a.Name
|
||||
select new DataToken
|
||||
{
|
||||
Text = a.Name,
|
||||
Value = a.RoadieId.ToString()
|
||||
Value = a.RoadieId.ToString(),
|
||||
Data = this.MakeArtistThumbnailImage(a.RoadieId).Url
|
||||
}).ToArray();
|
||||
|
||||
result.AssociatedArtists = (from aa in this.DbContext.ArtistAssociations
|
||||
join a in this.DbContext.Artists on aa.ArtistId equals a.Id
|
||||
where aa.AssociatedArtistId == artist.Id
|
||||
orderby a.Name
|
||||
select new DataToken
|
||||
{
|
||||
Text = a.Name,
|
||||
Value = a.RoadieId.ToString()
|
||||
}).ToArray();
|
||||
var associatedArtists = (from aa in this.DbContext.ArtistAssociations
|
||||
join a in this.DbContext.Artists on aa.ArtistId equals a.Id
|
||||
where aa.AssociatedArtistId == artist.Id
|
||||
select new DataToken
|
||||
{
|
||||
Text = a.Name,
|
||||
Value = a.RoadieId.ToString(),
|
||||
Data = this.MakeArtistThumbnailImage(a.RoadieId).Url
|
||||
}).ToArray();
|
||||
|
||||
result.AssociatedArtists = associatedArtists.Union(associatedWithArtists).OrderBy(x => x.Text);
|
||||
|
||||
}
|
||||
if (includes.Contains("collections"))
|
||||
{
|
||||
|
@ -228,9 +232,13 @@ namespace Roadie.Api.Services
|
|||
{
|
||||
result.ArtistContributionReleases = (from t in this.DbContext.Tracks
|
||||
join rm in this.DbContext.ReleaseMedias on t.ReleaseMediaId equals rm.Id
|
||||
join r in this.DbContext.Releases on rm.ReleaseId equals r.Id
|
||||
join r in this.DbContext.Releases.Include(x => x.Artist) on rm.ReleaseId equals r.Id
|
||||
where t.ArtistId == artist.Id
|
||||
select new ReleaseList
|
||||
group r by r.Id into rr
|
||||
select rr)
|
||||
.ToArray()
|
||||
.Select(rr => rr.First())
|
||||
.Select(r => new ReleaseList
|
||||
{
|
||||
Release = new DataToken
|
||||
{
|
||||
|
@ -244,20 +252,17 @@ namespace Roadie.Api.Services
|
|||
},
|
||||
ArtistThumbnail = MakeArtistThumbnailImage(r.Artist.RoadieId),
|
||||
Rating = r.Rating,
|
||||
Duration = r.Duration,
|
||||
ReleasePlayUrl = $"{ this.HttpContext.BaseUrl }/play/release/{ r.RoadieId}",
|
||||
LibraryStatus = r.LibraryStatus ?? LibraryStatus.Incomplete,
|
||||
ReleaseDateDateTime = r.ReleaseDate,
|
||||
TrackCount = r.TrackCount,
|
||||
CreatedDate = r.CreatedDate,
|
||||
LastUpdated = r.LastUpdated,
|
||||
TrackPlayedCount = (from ut in this.DbContext.UserTracks
|
||||
join t in this.DbContext.Tracks on ut.TrackId equals t.Id
|
||||
join rm in this.DbContext.ReleaseMedias on t.ReleaseMediaId equals rm.Id
|
||||
join rl in this.DbContext.Releases on rm.ReleaseId equals rl.Id
|
||||
where rl.Id == r.Id
|
||||
select ut.PlayedCount ?? 0).Sum(),
|
||||
TrackPlayedCount = r.PlayedCount,
|
||||
LastPlayed = r.LastPlayed,
|
||||
Thumbnail = MakeReleaseThumbnailImage(r.RoadieId)
|
||||
}).ToArray().GroupBy(x => x.Release.Value).Select(x => x.First()).OrderBy(x => x.Release.Text).ToArray();
|
||||
}).ToArray().OrderBy(x => x.Release.Text).ToArray();
|
||||
result.ArtistContributionReleases = result.ArtistContributionReleases.Any() ? result.ArtistContributionReleases : null;
|
||||
}
|
||||
if (includes.Contains("labels"))
|
||||
|
|
|
@ -523,9 +523,9 @@ namespace Roadie.Api.Services
|
|||
return new Image($"{this.HttpContext.ImageBaseUrl }/{type}/{id}");
|
||||
}
|
||||
|
||||
private Image MakeThumbnailImage(Guid id, string type)
|
||||
public Image MakeThumbnailImage(Guid id, string type, int? width = null, int? height = null)
|
||||
{
|
||||
return this.MakeImage(id, type, this.Configuration.ThumbnailImageSize.Width, this.Configuration.ThumbnailImageSize.Height);
|
||||
return this.MakeImage(id, type, width ?? this.Configuration.ThumbnailImageSize.Width, height ?? this.Configuration.ThumbnailImageSize.Height);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -75,11 +75,7 @@ namespace Roadie.Api
|
|||
{
|
||||
routes.MapHub<PlayActivityHub>("/playActivityHub");
|
||||
});
|
||||
app.UseMvc(b =>
|
||||
{
|
||||
b.Select().Expand().Filter().OrderBy().MaxTop(100).Count();
|
||||
b.MapODataServiceRoute("odata", "odata", GetEdmModel());
|
||||
});
|
||||
app.UseMvc();
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
|
@ -139,7 +135,7 @@ namespace Roadie.Api
|
|||
settings.ConnectionString = this._configuration.GetConnectionString("RoadieDatabaseConnection");
|
||||
return settings;
|
||||
});
|
||||
|
||||
services.AddSingleton<IActionContextAccessor, ActionContextAccessor>();
|
||||
services.AddSingleton<IDefaultNotFoundImages, DefaultNotFoundImages>();
|
||||
services.AddScoped<IStatisticsService, StatisticsService>();
|
||||
services.AddScoped<ICollectionService, CollectionService>();
|
||||
|
@ -188,8 +184,6 @@ namespace Roadie.Api
|
|||
// });
|
||||
//});
|
||||
|
||||
services.AddOData();
|
||||
|
||||
services.AddSignalR();
|
||||
|
||||
services.AddMvc(options =>
|
||||
|
@ -214,13 +208,5 @@ namespace Roadie.Api
|
|||
});
|
||||
}
|
||||
|
||||
private static IEdmModel GetEdmModel()
|
||||
{
|
||||
ODataConventionModelBuilder builder = new ODataConventionModelBuilder();
|
||||
builder.EntitySet<models.Artist>("Artist");
|
||||
builder.EntitySet<models.Label>("Label");
|
||||
builder.EntitySet<models.Releases.Release>("Release");
|
||||
return builder.GetEdmModel();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -63,7 +63,7 @@ namespace Roadie.Library.Data
|
|||
.Property(e => e.LibraryStatus)
|
||||
.HasConversion(
|
||||
v => v.ToString(),
|
||||
v => (LibraryStatus)Enum.Parse(typeof(LibraryStatus), v))
|
||||
v => string.IsNullOrEmpty(v) ? LibraryStatus.Incomplete : (LibraryStatus)Enum.Parse(typeof(LibraryStatus), v))
|
||||
.HasDefaultValue(LibraryStatus.Incomplete);
|
||||
|
||||
builder
|
||||
|
@ -71,15 +71,15 @@ namespace Roadie.Library.Data
|
|||
.Property(e => e.CollectionType)
|
||||
.HasConversion(
|
||||
v => v.ToString(),
|
||||
v => (CollectionType)Enum.Parse(typeof(CollectionType), v))
|
||||
v => string.IsNullOrEmpty(v) ? CollectionType.Unknown : (CollectionType)Enum.Parse(typeof(CollectionType), v))
|
||||
.HasDefaultValue(CollectionType.Unknown);
|
||||
|
||||
builder
|
||||
.Entity<Bookmark>()
|
||||
.Property(e => e.BookmarkType)
|
||||
.HasConversion(
|
||||
v => v,
|
||||
v => (BookmarkType)Enum.Parse(typeof(BookmarkType), v.ToString()))
|
||||
v => v.ToString(),
|
||||
v => string.IsNullOrEmpty(v) ? BookmarkType.Unknown : (BookmarkType)Enum.Parse(typeof(BookmarkType), v))
|
||||
.HasDefaultValue(BookmarkType.Unknown);
|
||||
|
||||
builder.Entity<ReleaseLabel>()
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace Roadie.Library.Models
|
|||
public string ArtistType { get; set; }
|
||||
|
||||
public IEnumerable<DataToken> AssociatedArtists { get; set; }
|
||||
public IEnumerable<DataToken> AssociatedWithArtists { get; set; }
|
||||
|
||||
public string BandStatus { get; set; }
|
||||
|
||||
[MaxLength(65535)]
|
||||
|
@ -83,6 +83,8 @@ namespace Roadie.Library.Models
|
|||
public CollectionStatistics Statistics { get; set; }
|
||||
public Image Thumbnail { get; set; }
|
||||
|
||||
public Image MediumThumbnail { get; set; }
|
||||
|
||||
public string Tooltip
|
||||
{
|
||||
get
|
||||
|
|
Loading…
Reference in a new issue