- Improved the RetryHandler.

- Made the tester buttons on the settings pages a bit more robust and added an indication when it's testing (spinner)
This commit is contained in:
TidusJar 2016-05-15 20:32:59 -04:00
commit 741a4ae75c
20 changed files with 232 additions and 149 deletions

View file

@ -23,6 +23,10 @@
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ************************************************************************/
using System.Net;
using PlexRequests.Helpers.Exceptions;
#endregion
using System.Collections.Generic;
@ -273,18 +277,27 @@ namespace PlexRequests.UI.Modules
return Response.AsJson(string.Empty);
}
var users = PlexApi.GetUsers(token);
if (users == null)
{
return Response.AsJson(string.Empty);
}
if (users.User == null || users.User?.Length == 0)
{
return Response.AsJson(string.Empty);
}
try {
var users = PlexApi.GetUsers(token);
if (users == null)
{
return Response.AsJson(string.Empty);
}
if (users.User == null || users.User?.Length == 0)
{
return Response.AsJson(string.Empty);
}
var usernames = users.User.Select(x => x.Title);
return Response.AsJson(usernames);
var usernames = users.User.Select(x => x.Title);
return Response.AsJson(new {Result = true, Users = usernames});
} catch (Exception ex) {
Log.Error (ex);
if (ex is WebException || ex is ApiRequestException) {
return Response.AsJson (new { Result = false, Message ="Could not load the user list! We have connectivity problems connecting to Plex, Please ensure we can access Plex.Tv, The error has been logged." });
}
return Response.AsJson (new { Result = false, Message = ex.Message});
}
}
private Negotiator CouchPotato()

View file

@ -87,7 +87,7 @@ namespace PlexRequests.UI.Modules
: Response.AsJson(new JsonResponseModel { Result = false, Message = "Could not connect to CouchPotato, please check your settings." });
}
catch (ApplicationException e) // Exceptions are expected if we cannot connect so we will just log and swallow them.
catch (Exception e) // Exceptions are expected if we cannot connect so we will just log and swallow them.
{
Log.Warn("Exception thrown when attempting to get CP's status: ");
Log.Warn(e);
@ -116,7 +116,7 @@ namespace PlexRequests.UI.Modules
: Response.AsJson(new JsonResponseModel { Result = false, Message = "Could not connect to Sonarr, please check your settings." });
}
catch (ApplicationException e) // Exceptions are expected, if we cannot connect so we will just log and swallow them.
catch (Exception e) // Exceptions are expected, if we cannot connect so we will just log and swallow them.
{
Log.Warn("Exception thrown when attempting to get Sonarr's status: ");
Log.Warn(e);
@ -150,7 +150,7 @@ namespace PlexRequests.UI.Modules
: Response.AsJson(new JsonResponseModel { Result = false, Message = "Could not connect to Plex, please check your settings." });
}
catch (ApplicationException e) // Exceptions are expected, if we cannot connect so we will just log and swallow them.
catch (Exception e) // Exceptions are expected, if we cannot connect so we will just log and swallow them.
{
Log.Warn("Exception thrown when attempting to get Plex's status: ");
Log.Warn(e);
@ -179,7 +179,7 @@ namespace PlexRequests.UI.Modules
: Response.AsJson(new JsonResponseModel { Result = false, Message = "Could not connect to SickRage, please check your settings." });
}
catch (ApplicationException e) // Exceptions are expected, if we cannot connect so we will just log and swallow them.
catch (Exception e) // Exceptions are expected, if we cannot connect so we will just log and swallow them.
{
Log.Warn("Exception thrown when attempting to get SickRage's status: ");
Log.Warn(e);
@ -214,7 +214,7 @@ namespace PlexRequests.UI.Modules
}
return Response.AsJson(new JsonResponseModel { Result = false, Message = "Could not connect to Headphones, please check your settings." });
}
catch (ApplicationException e)
catch (Exception e)
{
Log.Warn("Exception thrown when attempting to get Headphones's status: ");
Log.Warn(e);

View file

@ -46,6 +46,7 @@ namespace PlexRequests.UI.Modules
{
{
dynamic model = new ExpandoObject();
model.Redirect = Request.Query.redirect.Value ?? string.Empty;
model.Errored = Request.Query.error.HasValue;
var adminCreated = UserMapper.DoUsersExist();
model.AdminExists = adminCreated;
@ -61,6 +62,7 @@ namespace PlexRequests.UI.Modules
var username = (string)Request.Form.Username;
var password = (string)Request.Form.Password;
var dtOffset = (int)Request.Form.DateTimeOffset;
var redirect = (string)Request.Form.Redirect;
var userId = UserMapper.ValidateUser(username, password);
@ -75,12 +77,8 @@ namespace PlexRequests.UI.Modules
}
Session[SessionKeys.UsernameKey] = username;
Session[SessionKeys.ClientDateTimeOffsetKey] = dtOffset;
if (!string.IsNullOrEmpty(BaseUrl))
{
return this.LoginAndRedirect(userId.Value, expiry, $"/{BaseUrl}");
}
return this.LoginAndRedirect(userId.Value, expiry);
return this.LoginAndRedirect(userId.Value, expiry, redirect);
};
Get["/register"] = x =>