#114 first pass at choosing quality profile when approving + focus search input by default and when switching tabs

pull/140/head
Drewster727 9 years ago
commit 08b14d0164

@ -25,11 +25,13 @@
// ************************************************************************/ // ************************************************************************/
#endregion #endregion
using System; using System;
using PlexRequests.Api.Models.Music;
namespace PlexRequests.Api.Interfaces namespace PlexRequests.Api.Interfaces
{ {
public interface IHeadphonesApi public interface IHeadphonesApi
{ {
bool AddAlbum(string apiKey, Uri baseUrl, string albumId); bool AddAlbum(string apiKey, Uri baseUrl, string albumId);
HeadphonesVersion GetVersion(string apiKey, Uri baseUrl);
} }
} }

@ -0,0 +1,37 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2016 Jamie Rees
// File: HeadphonesVersion.cs
// Created By: Jamie Rees
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ************************************************************************/
#endregion
namespace PlexRequests.Api.Models.Music
{
public class HeadphonesVersion
{
public string install_type { get; set; }
public object current_version { get; set; }
public string git_path { get; set; }
public string latest_version { get; set; }
public int commits_behind { get; set; }
}
}

@ -59,7 +59,7 @@ namespace PlexRequests.Api.Models.Music
public string disambiguation { get; set; } public string disambiguation { get; set; }
[JsonProperty(PropertyName = "release-events")] [JsonProperty(PropertyName = "release-events")]
public List<ReleaseEvent> ReleaseRvents { get; set; } public List<ReleaseEvent> ReleaseEvents { get; set; }
public string id { get; set; } public string id { get; set; }
} }

@ -50,6 +50,7 @@
<Compile Include="Movie\CouchPotatoStatus.cs" /> <Compile Include="Movie\CouchPotatoStatus.cs" />
<Compile Include="Music\HeadphonesAlbumSearchResult.cs" /> <Compile Include="Music\HeadphonesAlbumSearchResult.cs" />
<Compile Include="Music\HeadphonesArtistSearchResult.cs" /> <Compile Include="Music\HeadphonesArtistSearchResult.cs" />
<Compile Include="Music\HeadphonesVersion.cs" />
<Compile Include="Music\MusicBrainzCoverArt.cs" /> <Compile Include="Music\MusicBrainzCoverArt.cs" />
<Compile Include="Music\MusicBrainzReleaseInfo.cs" /> <Compile Include="Music\MusicBrainzReleaseInfo.cs" />
<Compile Include="Music\MusicBrainzSearchResults.cs" /> <Compile Include="Music\MusicBrainzSearchResults.cs" />

@ -70,5 +70,27 @@ namespace PlexRequests.Api
return false; // If there is no matching result we do not get returned a JSON string, it just returns "false". return false; // If there is no matching result we do not get returned a JSON string, it just returns "false".
} }
} }
public HeadphonesVersion GetVersion(string apiKey, Uri baseUrl)
{
var request = new RestRequest
{
Resource = "/api",
Method = Method.GET
};
request.AddQueryParameter("apikey", apiKey);
request.AddQueryParameter("cmd", "getVersion");
try
{
return Api.ExecuteJson<HeadphonesVersion>(request, baseUrl);
}
catch (JsonSerializationException jse)
{
Log.Warn(jse);
return new HeadphonesVersion(); // If there is no matching result we do not get returned a JSON string, it just returns "false".
}
}
} }
} }

@ -1,4 +1,5 @@
using System; using System;
using System.Globalization;
using System.Linq; using System.Linq;
namespace PlexRequests.Helpers namespace PlexRequests.Helpers
@ -17,6 +18,21 @@ namespace PlexRequests.Helpers
return new DateTimeOffset(newDate.Ticks, utcOffset); return new DateTimeOffset(newDate.Ticks, utcOffset);
} }
public static void CustomParse(string date, out DateTime dt)
{
// Try and parse it
if (DateTime.TryParse(date, out dt))
{
return;
}
// Maybe it's only a year?
if (DateTime.TryParseExact(date, "yyyy", CultureInfo.CurrentCulture, DateTimeStyles.None, out dt))
{
return;
}
}
private static TimeZoneInfo FindTimeZoneFromOffset(int minuteOffset) private static TimeZoneInfo FindTimeZoneFromOffset(int minuteOffset)
{ {
var tzc = TimeZoneInfo.GetSystemTimeZones(); var tzc = TimeZoneInfo.GetSystemTimeZones();

@ -38,6 +38,7 @@ namespace PlexRequests.Store
public string SeasonsRequested { get; set; } public string SeasonsRequested { get; set; }
public string MusicBrainzId { get; set; } public string MusicBrainzId { get; set; }
public List<string> RequestedUsers { get; set; } public List<string> RequestedUsers { get; set; }
public string Artist { get; set; }
[JsonIgnore] [JsonIgnore]
public List<string> AllUsers public List<string> AllUsers

@ -485,7 +485,7 @@ function albumLoad() {
if (results.length > 0) { if (results.length > 0) {
results.forEach(function (result) { results.forEach(function (result) {
var context = buildRequestContext(result, "album"); var context = buildRequestContext(result, "album");
var html = searchTemplate(context); var html = albumTemplate(context);
$albumL.append(html); $albumL.append(html);
}); });
} }
@ -522,6 +522,9 @@ function buildRequestContext(result, type) {
seriesRequested: result.tvSeriesRequestType, seriesRequested: result.tvSeriesRequestType,
coverArtUrl: result.coverArtUrl, coverArtUrl: result.coverArtUrl,
qualities: result.qualities, qualities: result.qualities,
hasQualities: result.qualities && result.qualities.length > 0,
coverArtUrl: result.coverArtUrl,
qualities: result.qualities,
hasQualities: result.qualities && result.qualities.length > 0 hasQualities: result.qualities && result.qualities.length > 0
}; };

@ -43,7 +43,7 @@ namespace PlexRequests.UI.Modules
{ {
public ApplicationTesterModule(ICouchPotatoApi cpApi, ISonarrApi sonarrApi, IPlexApi plexApi, public ApplicationTesterModule(ICouchPotatoApi cpApi, ISonarrApi sonarrApi, IPlexApi plexApi,
ISettingsService<AuthenticationSettings> authSettings, ISickRageApi srApi) : base("test") ISettingsService<AuthenticationSettings> authSettings, ISickRageApi srApi, IHeadphonesApi hpApi) : base("test")
{ {
this.RequiresAuthentication(); this.RequiresAuthentication();
@ -52,6 +52,7 @@ namespace PlexRequests.UI.Modules
PlexApi = plexApi; PlexApi = plexApi;
AuthSettings = authSettings; AuthSettings = authSettings;
SickRageApi = srApi; SickRageApi = srApi;
HeadphonesApi = hpApi;
Post["/cp"] = _ => CouchPotatoTest(); Post["/cp"] = _ => CouchPotatoTest();
Post["/sonarr"] = _ => SonarrTest(); Post["/sonarr"] = _ => SonarrTest();
@ -66,6 +67,7 @@ namespace PlexRequests.UI.Modules
private ICouchPotatoApi CpApi { get; } private ICouchPotatoApi CpApi { get; }
private IPlexApi PlexApi { get; } private IPlexApi PlexApi { get; }
private ISickRageApi SickRageApi { get; } private ISickRageApi SickRageApi { get; }
private IHeadphonesApi HeadphonesApi { get; }
private ISettingsService<AuthenticationSettings> AuthSettings { get; } private ISettingsService<AuthenticationSettings> AuthSettings { get; }
private Response CouchPotatoTest() private Response CouchPotatoTest()
@ -172,7 +174,32 @@ namespace PlexRequests.UI.Modules
private Response HeadphonesTest() private Response HeadphonesTest()
{ {
throw new NotImplementedException(); //TODO var settings = this.Bind<HeadphonesSettings>();
try
{
var result = HeadphonesApi.GetVersion(settings.ApiKey, settings.FullUri);
if (!string.IsNullOrEmpty(result.latest_version))
{
return
Response.AsJson(new JsonResponseModel
{
Result = true,
Message = "Connected to Headphones successfully!"
});
}
return Response.AsJson(new JsonResponseModel { Result = false, Message = "Could not connect to Headphones, please check your settings." });
}
catch (ApplicationException e)
{
Log.Warn("Exception thrown when attempting to get Headphones's status: ");
Log.Warn(e);
var message = $"Could not connect to Headphones, please check your settings. <strong>Exception Message:</strong> {e.Message}";
if (e.InnerException != null)
{
message = $"Could not connect to Headphones, please check your settings. <strong>Exception Message:</strong> {e.InnerException.Message}";
}
return Response.AsJson(new JsonResponseModel { Result = false, Message = message }); ;
}
} }
} }
} }

@ -503,6 +503,9 @@ namespace PlexRequests.UI.Modules
Log.Trace("CoverArt Details:"); Log.Trace("CoverArt Details:");
Log.Trace(img.DumpJson()); Log.Trace(img.DumpJson());
DateTime release;
DateTimeHelper.CustomParse(albumInfo.ReleaseEvents?.FirstOrDefault()?.date, out release);
var model = new RequestedModel var model = new RequestedModel
{ {
Title = albumInfo.title, Title = albumInfo.title,
@ -513,7 +516,10 @@ namespace PlexRequests.UI.Modules
ProviderId = 0, ProviderId = 0,
RequestedUsers = new List<string>() { Username }, RequestedUsers = new List<string>() { Username },
Status = albumInfo.status, Status = albumInfo.status,
Issues = IssueState.None Issues = IssueState.None,
RequestedDate = DateTime.UtcNow,
ReleaseDate = release,
// Artist = albumInfo.
}; };

@ -3,7 +3,7 @@
int port; int port;
if (Model.Port == 0) if (Model.Port == 0)
{ {
port = 8081; port = 8181;
} }
else else
{ {
@ -72,13 +72,6 @@
</div> </div>
<div class="form-group">
<div>
<button type="submit" id="getProfiles" class="btn btn-primary-outline">Get Quality Profiles</button>
</div>
</div>
<div class="form-group"> <div class="form-group">
<div> <div>
<button id="testHeadphones" type="submit" class="btn btn-primary-outline">Test Connectivity</button> <button id="testHeadphones" type="submit" class="btn btn-primary-outline">Test Connectivity</button>
@ -86,8 +79,6 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<div> <div>
<button id="save" type="submit" class="btn btn-primary-outline">Submit</button> <button id="save" type="submit" class="btn btn-primary-outline">Submit</button>
@ -115,7 +106,6 @@
console.log(response); console.log(response);
if (response.result === true) { if (response.result === true) {
generateNotify(response.message, "success"); generateNotify(response.message, "success");
$('#authToken').val(response.authToken);
} else { } else {
generateNotify(response.message, "warning"); generateNotify(response.message, "warning");
} }

@ -252,8 +252,8 @@
<div id="{{requestId}}Template" class="mix available-{{available}} approved-{{approved}}" data-requestorder="{{requestedDateTicks}}" data-releaseorder="{{releaseDateTicks}}"> <div id="{{requestId}}Template" class="mix available-{{available}} approved-{{approved}}" data-requestorder="{{requestedDateTicks}}" data-releaseorder="{{releaseDateTicks}}">
<div class="row"> <div class="row">
<div class="col-sm-2"> <div class="col-sm-2">
{{#if coverArtUrl}} {{#if posterPath}}
<img class="img-responsive" src="{{coverArtUrl}}" width="150" alt="poster"> <img class="img-responsive" src="{{posterPath}}" width="150" alt="poster">
{{/if}} {{/if}}
</div> </div>
<div class="col-sm-5 "> <div class="col-sm-5 ">

@ -17,7 +17,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
ProjectSection(SolutionItems) = preProject ProjectSection(SolutionItems) = preProject
.travis.yml = .travis.yml .travis.yml = .travis.yml
appveyor.yml = appveyor.yml appveyor.yml = appveyor.yml
.github\ISSUE_TEMPLATE.md = .github\ISSUE_TEMPLATE.md
LICENSE = LICENSE LICENSE = LICENSE
README.md = README.md README.md = README.md
EndProjectSection EndProjectSection
@ -32,10 +31,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlexRequests.Services", "Pl
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlexRequests.Api.Models", "PlexRequests.Api.Models\PlexRequests.Api.Models.csproj", "{CB37A5F8-6DFC-4554-99D3-A42B502E4591}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlexRequests.Api.Models", "PlexRequests.Api.Models\PlexRequests.Api.Models.csproj", "{CB37A5F8-6DFC-4554-99D3-A42B502E4591}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlexRequests.Services.Tests", "PlexRequests.Services.Tests\PlexRequests.Services.Tests.csproj", "{EAADB4AC-064F-4D3A-AFF9-64A33131A9A7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlexRequests.Helpers.Tests", "PlexRequests.Helpers.Tests\PlexRequests.Helpers.Tests.csproj", "{0E6395D3-B074-49E8-898D-0EB99E507E0E}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -82,14 +77,6 @@ Global
{CB37A5F8-6DFC-4554-99D3-A42B502E4591}.Debug|Any CPU.Build.0 = Debug|Any CPU {CB37A5F8-6DFC-4554-99D3-A42B502E4591}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CB37A5F8-6DFC-4554-99D3-A42B502E4591}.Release|Any CPU.ActiveCfg = Release|Any CPU {CB37A5F8-6DFC-4554-99D3-A42B502E4591}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CB37A5F8-6DFC-4554-99D3-A42B502E4591}.Release|Any CPU.Build.0 = Release|Any CPU {CB37A5F8-6DFC-4554-99D3-A42B502E4591}.Release|Any CPU.Build.0 = Release|Any CPU
{EAADB4AC-064F-4D3A-AFF9-64A33131A9A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EAADB4AC-064F-4D3A-AFF9-64A33131A9A7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EAADB4AC-064F-4D3A-AFF9-64A33131A9A7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EAADB4AC-064F-4D3A-AFF9-64A33131A9A7}.Release|Any CPU.Build.0 = Release|Any CPU
{0E6395D3-B074-49E8-898D-0EB99E507E0E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0E6395D3-B074-49E8-898D-0EB99E507E0E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0E6395D3-B074-49E8-898D-0EB99E507E0E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0E6395D3-B074-49E8-898D-0EB99E507E0E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

Loading…
Cancel
Save