Merge pull request #992 from tidusjar/dev

Dev
pull/1028/head
Jamie 8 years ago committed by GitHub
commit ef4546091f

@ -114,9 +114,13 @@ namespace Ombi.Core
}
// could be a local user
var localName = session[SessionKeys.UsernameKey];
var hasSessionKey = session[SessionKeys.UsernameKey] != null;
if (hasSessionKey)
{
return (string)session[SessionKeys.UsernameKey];
}
return localName as string;
return string.Empty;
}

@ -25,6 +25,7 @@
// ************************************************************************/
#endregion
using Newtonsoft.Json;
using Ombi.Helpers;
using Ombi.Helpers.Permissions;
@ -38,5 +39,8 @@ namespace Ombi.Core.Users
public Features Features { get; set; }
public string EmailAddress { get; set; }
public UserType Type { get; set; }
[JsonIgnore]
public string UsernameOrAlias => string.IsNullOrEmpty(UserAlias) ? Username : UserAlias;
}
}

@ -152,8 +152,18 @@ namespace Ombi.Services.Notification
var users = UserHelper.GetUsersWithFeature(Features.RequestAddedNotification).ToList();
Log.Debug("Notifying Users Count {0}", users.Count);
var selectedUsers = users.Select(x => x.Username).Intersect(model.RequestedUsers, StringComparer.CurrentCultureIgnoreCase);
foreach (var user in selectedUsers)
// Get the usernames or alias depending if they have an alias
var userNamesWithFeature = users.Select(x => x.UsernameOrAlias).ToList();
var usersToNotify = userNamesWithFeature.Intersect(model.AllUsers, StringComparer.CurrentCultureIgnoreCase).ToList();
if (!usersToNotify.Any())
{
Log.Debug("Could not find any users after the .Intersect()");
}
Log.Debug("Users being notified for this request count {0}", users.Count);
foreach (var user in usersToNotify)
{
Log.Info("Notifying user {0}", user);
if (user.Equals(adminUsername, StringComparison.CurrentCultureIgnoreCase))

@ -26,6 +26,7 @@
#endregion
using Dapper.Contrib.Extensions;
using Newtonsoft.Json;
namespace Ombi.Store.Models
{

@ -65,7 +65,7 @@ namespace Ombi.Store
u.Add(RequestedBy);
}
if (RequestedUsers.Any())
if (RequestedUsers != null && RequestedUsers.Any())
{
u.AddRange(RequestedUsers.Where(requestedUser => requestedUser != RequestedBy));
}

@ -199,7 +199,7 @@ namespace Ombi.UI.Helpers
var assetLocation = GetBaseUrl();
var content = GetContentUrl(assetLocation);
sb.AppendLine($"<script src=\"{content}/Content/wizard.js?v={Assembly}\" type=\"text/javascript\"></script>");
return helper.Raw(sb.ToString());
@ -226,9 +226,9 @@ namespace Ombi.UI.Helpers
sb.Append($"<script src=\"{content}/Content/app/userManagement/userManagementService.js?v={Assembly}\" type=\"text/javascript\"></script>");
sb.Append($"<script src=\"{content}/Content/app/userManagement/Directives/userManagementDirective.js?v={Assembly}\" type=\"text/javascript\"></script>");
sb.Append($"<script src=\"{content}/Content/moment.min.js\"></script>");
sb.Append($"<script src=\"{content}/Content/spin.min.js\"></script>");
sb.Append($"<script src=\"{content}/Content/Angular/angular-spinner.min.js\"></script>");
sb.Append($"<script src=\"{content}/Content/Angular/angular-loading-spinner.js\"></script>");
sb.Append($"<script src=\"{content}/Content/spin.min.js\"></script>");
sb.Append($"<script src=\"{content}/Content/Angular/angular-spinner.min.js\"></script>");
sb.Append($"<script src=\"{content}/Content/Angular/angular-loading-spinner.js\"></script>");
return helper.Raw(sb.ToString());
}
@ -290,17 +290,19 @@ namespace Ombi.UI.Helpers
return helper.Raw(asset);
}
public static IHtmlString GetSidebarUrl(this HtmlHelpers helper, NancyContext context, string url, string title, bool dropdown = false)
public static IHtmlString GetSidebarUrl(this HtmlHelpers helper, NancyContext context, string url, string title, string icon = null)
{
var content = GetLinkUrl(GetBaseUrl());
if (!string.IsNullOrEmpty(content))
{
url = $"/{content}{url}";
}
var dropdownClass = dropdown ? "list-group-item-dropdown" : string.Empty;
var returnString = context.Request.Path == url
? $"<a class=\"list-group-item {dropdownClass} active\" href=\"{url}\">{title}</a>"
: $"<a class=\"list-group-item {dropdownClass}\" href=\"{url}\">{title}</a>";
var iconHtml = string.IsNullOrEmpty(icon) ? "" : $"<span style=\"font-size:16px; \" class=\"pull-right hidden-xs showopacity {icon}\"></span>";
var returnString = context.Request.Path == url
? $"<a class=\"list-group-item active\" href=\"{url}\">{title} {iconHtml}</a>"
: $"<a class=\"list-group-item\" href=\"{url}\">{title} {iconHtml}</a>";
return helper.Raw(returnString);
}
@ -312,8 +314,8 @@ namespace Ombi.UI.Helpers
{
url = $"/{content}{url}";
}
var returnString = context.Request.Path == url ?
$"<li class=\"active\"><a href=\"{url}\"><i class=\"fa fa-{fontIcon}\"></i> {title}</a></li>"
var returnString = context.Request.Path == url ?
$"<li class=\"active\"><a href=\"{url}\"><i class=\"fa fa-{fontIcon}\"></i> {title}</a></li>"
: $"<li><a href=\"{url}\"><i class=\"fa fa-{fontIcon}\"></i> {title}</a></li>";
return helper.Raw(returnString);
@ -327,8 +329,8 @@ namespace Ombi.UI.Helpers
url = $"/{content}{url}";
}
var returnString = context.Request.Path == url
? $"<li class=\"active\"><a href=\"{url}\"><i class=\"fa fa-{fontIcon}\"></i> {title} {extraHtml}</a></li>"
var returnString = context.Request.Path == url
? $"<li class=\"active\"><a href=\"{url}\"><i class=\"fa fa-{fontIcon}\"></i> {title} {extraHtml}</a></li>"
: $"<li><a href=\"{url}\"><i class=\"fa fa-{fontIcon}\"></i> {title} {extraHtml}</a></li>";
return helper.Raw(returnString);

@ -121,7 +121,7 @@ namespace Ombi.UI.Modules
}
catch (Exception)
{
return string.Empty;
return "Unknown User Error";
}
}
return _username;
@ -149,9 +149,10 @@ namespace Ombi.UI.Modules
protected bool LoggedIn => Context?.CurrentUser != null;
protected string Culture { get; set; }
private string Culture { get; set; }
protected const string CultureCookieName = "_culture";
protected Response SetCookie()
private Response SetCookie()
{
try
{

@ -564,7 +564,7 @@ namespace Ombi.UI.Modules
UserLogins.Insert(new UserLogins { UserId = userId, Type = UserType.PlexUser, LastLoggedIn = DateTime.UtcNow });
Log.Debug("We are authenticated! Setting session.");
// Add to the session (Used in the BaseModules)
Session[SessionKeys.UsernameKey] = (string)username;
Session[SessionKeys.UsernameKey] = username;
Session[SessionKeys.ClientDateTimeOffsetKey] = dateTimeOffset;
var plexLocal = plexLocalUsers.FirstOrDefault(x => x.Username == username);

@ -2,34 +2,62 @@
@Html.LoadSettingsAssets()
<div class="col-lg-3 col-md-3 col-sm-4">
<div class="list-group table-of-contents">
@Html.GetSidebarUrl(Context, "/admin/about", "About")
@Html.GetSidebarUrl(Context, "/admin", "Ombi Configuration")
@Html.GetSidebarUrl(Context, "/admin/customization", "Customization")
@Html.GetSidebarUrl(Context, "/admin/landingpage", "Landing Page")
@Html.GetSidebarUrl(Context, "/admin/authentication", "Authentication")
@Html.GetSidebarUrl(Context, "/admin/usermanagementsettings", "User Management Settings")
@Html.GetSidebarUrl(Context, "/admin/plex", "Plex")
@Html.GetSidebarUrl(Context, "/admin/couchpotato", "CouchPotato")
@Html.GetSidebarUrl(Context, "/admin/watcher", "Watcher (beta)")
@Html.GetSidebarUrl(Context, "/admin/radarr", "Radarr (beta)")
@Html.GetSidebarUrl(Context, "/admin/sonarr", "Sonarr")
@Html.GetSidebarUrl(Context, "/admin/sickrage", "SickRage")
@Html.GetSidebarUrl(Context, "/admin/headphones", "Headphones (beta)")
@Html.GetSidebarUrl(Context, "/admin/newsletter", "Newsletter Settings")
<div class="dropdown">
<a href="#" class="dropdown-toggle list-group-item " data-toggle="dropdown">Notifications <span class="caret"></span><span style="font-size:16px;" class="pull-right hidden-xs showopacity glyphicon glyphicon-envelope"></span></a>
<ul class="dropdown-menu" role="menu">
@Html.GetSidebarUrl(Context, "/admin/about", "About", "glyphicon glyphicon-info-sign")
@Html.GetSidebarUrl(Context, "/admin", "Ombi Configuration", "glyphicon glyphicon-ok-sign")
@Html.GetSidebarUrl(Context, "/admin/customization", "Customization", "glyphicon glyphicon-tasks")
@Html.GetSidebarUrl(Context, "/admin/landingpage", "Landing Page", "glyphicon glyphicon-dashboard")
@Html.GetSidebarUrl(Context, "/admin/authentication", "Authentication", "glyphicon glyphicon-lock")
@Html.GetSidebarUrl(Context, "/admin/usermanagementsettings", "User Management Settings", "glyphicon glyphicon-user")
@Html.GetSidebarUrl(Context, "/admin/plex", "Plex", "glyphicon glyphicon-play-circle")
@Html.GetSidebarUrl(Context, "/admin/couchpotato", "CouchPotato", "glyphicon glyphicon-film")
@Html.GetSidebarUrl(Context, "/admin/watcher", "Watcher (beta)", "glyphicon glyphicon-film")
@Html.GetSidebarUrl(Context, "/admin/radarr", "Radarr (beta)", "glyphicon glyphicon-film")
@Html.GetSidebarUrl(Context, "/admin/sonarr", "Sonarr", "fa fa-tv")
@Html.GetSidebarUrl(Context, "/admin/sickrage", "SickRage", "fa fa-tv")
@Html.GetSidebarUrl(Context, "/admin/headphones", "Headphones (beta)", "glyphicon glyphicon-headphones")
@Html.GetSidebarUrl(Context, "/admin/newsletter", "Newsletter Settings", "fa fa-newspaper-o")
<div id="sidebar" >
<a href="#notifications" class="list-group-item" data-parent="#sidebar">
Notifications <span class="caret"></span><span style="font-size:16px;" class="pull-right hidden-xs showopacity glyphicon glyphicon-envelope"></span>
</a>
<div id="notifications" class="list-group subitem collapse">
@Html.GetSidebarUrl(Context, "/admin/emailnotification", "Email Notifications")
@Html.GetSidebarUrl(Context, "/admin/pushbulletnotification", "Pushbullet Notifications")
@Html.GetSidebarUrl(Context, "/admin/pushovernotification", "Pushover Notifications")
@Html.GetSidebarUrl(Context, "/admin/slacknotification", "Slack Notifications")
@Html.GetSidebarUrl(Context, "/admin/discordnotification", "Discord Notifications")
</ul>
@Html.GetSidebarUrl(Context, "/admin/pushbulletnotification", "Pushbullet Notifications","fa fa-bell-o")
@Html.GetSidebarUrl(Context, "/admin/pushovernotification", "Pushover Notifications", "fa fa-bell-o")
@Html.GetSidebarUrl(Context, "/admin/slacknotification", "Slack Notifications", "fa fa-slack")
@Html.GetSidebarUrl(Context, "/admin/discordnotification", "Discord Notifications", "fa fa-bell-o")
</div>
</div>
@Html.GetSidebarUrl(Context, "/admin/logs", "Logs")
@Html.GetSidebarUrl(Context, "/admin/status", "Status")
@Html.GetSidebarUrl(Context, "/admin/scheduledjobs", "Scheduled Jobs")
@Html.GetSidebarUrl(Context, "/admin/faultqueue", "Request Fault Queue")
@Html.GetSidebarUrl(Context, "/admin/logs", "Logs", "fa fa-edit")
@Html.GetSidebarUrl(Context, "/admin/status", "Status", "fa fa-dashboard")
@Html.GetSidebarUrl(Context, "/admin/scheduledjobs", "Scheduled Jobs", "fa fa-hand-spock-o")
@Html.GetSidebarUrl(Context, "/admin/faultqueue", "Request Fault Queue", "fa fa-history")
</div>
</div>
</div>
<script>
$('#sidebar > a').on('click', function (e) {
e.preventDefault();
if (!$(this).hasClass("active")) {
var lastActive = $(this).closest("#sidebar").children(".active");
lastActive.removeClass("active");
lastActive.next('div').collapse('hide');
$(this).addClass("active");
$(this).next('div').collapse('show');
}
});
</script>
Loading…
Cancel
Save