BaseUrl is finally finished! #72

pull/158/head
tidusjar 9 years ago
parent 47dc543b09
commit 67c968e886

@ -40,5 +40,7 @@ namespace PlexRequests.Core
public const string CouchPotatoQualityProfiles = "CouchPotatoQualityProfiles"; public const string CouchPotatoQualityProfiles = "CouchPotatoQualityProfiles";
public const string CouchPotatoQueued = "CouchPotatoQueued"; public const string CouchPotatoQueued = "CouchPotatoQueued";
public const string GetBaseUrl = "GetBaseUrl";
} }
} }

@ -11,7 +11,7 @@ var searchTemplate = Handlebars.compile(searchSource);
var albumTemplate = Handlebars.compile(albumSource); var albumTemplate = Handlebars.compile(albumSource);
var movieTimer = 0; var movieTimer = 0;
var tvimer = 0; var tvimer = 0;
var base = $('#baseUrl').val(); var base = $('#baseUrl').text();
var mixItUpDefault = { var mixItUpDefault = {
animation: { enable: true }, animation: { enable: true },
@ -381,16 +381,20 @@ $(document).on("click", ".change", function (e) {
generateNotify("Success! Availibility changed.", "info"); generateNotify("Success! Availibility changed.", "info");
var button = $("button[custom-availibility='" + buttonId + "']"); var button = $("button[custom-availibility='" + buttonId + "']");
var icon = $('#availableIcon' + buttonId); var icon = $('#availableIcon' + buttonId);
var approvedIcon = $("#"+buttonId + "notapproved");
if (response.available) { if (response.available) {
button.text("Mark Unavailable"); button.text("Mark Unavailable");
button.val("false"); button.val("false");
button.prop("class", "btn btn-sm btn-info-outline change"); button.prop("class", "btn btn-sm btn-info-outline change");
icon.prop("class", "fa fa-check"); icon.prop("class", "fa fa-check");
approvedIcon.prop("class", "fa fa-check");
} else { } else {
button.text("Mark Available"); button.text("Mark Available");
button.prop("class", "btn btn-sm btn-success-outline change"); button.prop("class", "btn btn-sm btn-success-outline change");
icon.prop("class", "fa fa-times"); icon.prop("class", "fa fa-times");
approvedIcon.prop("class", "fa fa-times");
button.val("true"); button.val("true");
} }
} }

@ -5,6 +5,8 @@
return opts.inverse(this); return opts.inverse(this);
}); });
$(function () { $(function () {
var searchSource = $("#search-template").html(); var searchSource = $("#search-template").html();
@ -12,6 +14,8 @@ $(function () {
var searchTemplate = Handlebars.compile(searchSource); var searchTemplate = Handlebars.compile(searchSource);
var musicTemplate = Handlebars.compile(musicSource); var musicTemplate = Handlebars.compile(musicSource);
var base = $('#baseUrl').text();
var searchTimer = 0; var searchTimer = 0;
// fix for selecting a default tab // fix for selecting a default tab
@ -21,7 +25,7 @@ $(function () {
} }
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) { $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
focusSearch($($(e.target).attr('href'))) focusSearch($($(e.target).attr('href')));
}); });
focusSearch($('li.active a', '#nav-tabs').first().attr('href')); focusSearch($('li.active a', '#nav-tabs').first().attr('href'));
@ -172,15 +176,18 @@ $(function () {
function movieSearch() { function movieSearch() {
var query = $("#movieSearchContent").val(); var query = $("#movieSearchContent").val();
query ? getMovies("/search/movie/" + query) : resetMovies(); var url = createBaseUrl(base, '/search/movie/');
query ? getMovies(url + query) : resetMovies();
} }
function moviesComingSoon() { function moviesComingSoon() {
getMovies("/search/movie/upcoming"); var url = createBaseUrl(base, '/search/movie/upcoming');
getMovies(url);
} }
function moviesInTheaters() { function moviesInTheaters() {
getMovies("/search/movie/playing"); var url = createBaseUrl(base, '/search/movie/playing');
getMovies(url);
} }
function getMovies(url) { function getMovies(url) {
@ -209,7 +216,9 @@ $(function () {
function tvSearch() { function tvSearch() {
var query = $("#tvSearchContent").val(); var query = $("#tvSearchContent").val();
query ? getTvShows("/search/tv/" + query) : resetTvShows();
var url = createBaseUrl(base, '/search/tv/');
query ? getTvShows(url + query) : resetTvShows();
} }
function getTvShows(url) { function getTvShows(url) {
@ -236,8 +245,9 @@ $(function () {
} }
function musicSearch() { function musicSearch() {
var url = createBaseUrl(base, '/search/music/');
var query = $("#musicSearchContent").val(); var query = $("#musicSearchContent").val();
query ? getMusic("/search/music/" + query) : resetMusic(); query ? getMusic(url + query) : resetMusic();
} }
function getMusic(url) { function getMusic(url) {
@ -266,7 +276,9 @@ $(function () {
} }
function getCoverArt(artistId) { function getCoverArt(artistId) {
$.ajax("/search/music/coverart/" + artistId).success(function (result) {
var url = createBaseUrl(base, '/search/music/coverart/');
$.ajax(url + artistId).success(function (result) {
if (result) { if (result) {
$('#' + artistId + "imageDiv").html(" <img class='img-responsive' src='" + result + "' width='150' alt='poster'>"); $('#' + artistId + "imageDiv").html(" <img class='img-responsive' src='" + result + "' width='150' alt='poster'>");
} }

@ -32,12 +32,20 @@ using Nancy.ViewEngines.Razor;
using PlexRequests.Core; using PlexRequests.Core;
using PlexRequests.Core.SettingModels; using PlexRequests.Core.SettingModels;
using PlexRequests.Helpers;
namespace PlexRequests.UI.Helpers namespace PlexRequests.UI.Helpers
{ {
public static class BaseUrlHelper public static class BaseUrlHelper
{ {
private static ServiceLocator Locator => ServiceLocator.Instance; static BaseUrlHelper()
{
Locator = ServiceLocator.Instance;
Cache = Locator.Resolve<ICacheProvider>();
}
private static ICacheProvider Cache { get; }
private static ServiceLocator Locator { get; }
public static IHtmlString LoadAssets(this HtmlHelpers helper) public static IHtmlString LoadAssets(this HtmlHelpers helper)
{ {
var sb = new StringBuilder(); var sb = new StringBuilder();
@ -117,6 +125,26 @@ namespace PlexRequests.UI.Helpers
returnString = $"<a class=\"list-group-item\" href=\"{url}\">{title}</a>"; returnString = $"<a class=\"list-group-item\" href=\"{url}\">{title}</a>";
} }
return helper.Raw(returnString);
}
public static IHtmlString GetNavbarUrl(this HtmlHelpers helper, NancyContext context, string url, string title, string fontIcon)
{
var returnString = string.Empty;
var content = GetLinkUrl(GetBaseUrl());
if (!string.IsNullOrEmpty(content))
{
url = $"/{content}{url}";
}
if (context.Request.Path == url)
{
returnString = $"<li class=\"active\"><a href=\"{url}\"><i class=\"fa fa-{fontIcon}\"></i> {title}</a></li>";
}
else
{
returnString = $"<li><a href=\"{url}\"><i class=\"fa fa-{fontIcon}\"></i> {title}</a></li>";
}
return helper.Raw(returnString); return helper.Raw(returnString);
} }
@ -125,11 +153,15 @@ namespace PlexRequests.UI.Helpers
return helper.Raw(GetBaseUrl()); return helper.Raw(GetBaseUrl());
} }
private static string GetBaseUrl() private static string GetBaseUrl()
{ {
var settings = Locator.Resolve<ISettingsService<PlexRequestSettings>>().GetSettings(); var returnValue = Cache.GetOrSet(CacheKeys.GetBaseUrl, () =>
var assetLocation = settings.BaseUrl; {
return assetLocation; var settings = Locator.Resolve<ISettingsService<PlexRequestSettings>>().GetSettings();
var assetLocation = settings.BaseUrl;
return assetLocation;
});
return returnValue;
} }
private static string GetLinkUrl(string assetLocation) private static string GetLinkUrl(string assetLocation)

@ -44,11 +44,7 @@ namespace PlexRequests.UI.Helpers
} }
public T Resolve<T>() where T : class public T Resolve<T>() where T : class
{ {
if (Container != null) return Container?.Resolve<T>();
{
return Container.Resolve<T>();
}
return null;
} }
} }
} }

@ -595,6 +595,11 @@ namespace PlexRequests.UI.Modules
private Response GetCpProfiles() private Response GetCpProfiles()
{ {
var settings = this.Bind<CouchPotatoSettings>(); var settings = this.Bind<CouchPotatoSettings>();
var valid = this.Validate(settings);
if (!valid.IsValid)
{
return Response.AsJson(valid.SendJsonError());
}
var profiles = CpApi.GetProfiles(settings.FullUri, settings.ApiKey); var profiles = CpApi.GetProfiles(settings.FullUri, settings.ApiKey);
// set the cache // set the cache

@ -29,12 +29,13 @@ using System;
using Nancy; using Nancy;
using Nancy.ModelBinding; using Nancy.ModelBinding;
using Nancy.Security; using Nancy.Security;
using Nancy.Validation;
using NLog; using NLog;
using PlexRequests.Api.Interfaces; using PlexRequests.Api.Interfaces;
using PlexRequests.Core; using PlexRequests.Core;
using PlexRequests.Core.SettingModels; using PlexRequests.Core.SettingModels;
using PlexRequests.UI.Helpers;
using PlexRequests.UI.Models; using PlexRequests.UI.Models;
namespace PlexRequests.UI.Modules namespace PlexRequests.UI.Modules
@ -73,6 +74,11 @@ namespace PlexRequests.UI.Modules
private Response CouchPotatoTest() private Response CouchPotatoTest()
{ {
var couchPotatoSettings = this.Bind<CouchPotatoSettings>(); var couchPotatoSettings = this.Bind<CouchPotatoSettings>();
var valid = this.Validate(couchPotatoSettings);
if (!valid.IsValid)
{
return Response.AsJson(valid.SendJsonError());
}
try try
{ {
var status = CpApi.GetStatus(couchPotatoSettings.FullUri, couchPotatoSettings.ApiKey); var status = CpApi.GetStatus(couchPotatoSettings.FullUri, couchPotatoSettings.ApiKey);
@ -97,6 +103,11 @@ namespace PlexRequests.UI.Modules
private Response SonarrTest() private Response SonarrTest()
{ {
var sonarrSettings = this.Bind<SonarrSettings>(); var sonarrSettings = this.Bind<SonarrSettings>();
var valid = this.Validate(sonarrSettings);
if (!valid.IsValid)
{
return Response.AsJson(valid.SendJsonError());
}
try try
{ {
var status = SonarrApi.SystemStatus(sonarrSettings.ApiKey, sonarrSettings.FullUri); var status = SonarrApi.SystemStatus(sonarrSettings.ApiKey, sonarrSettings.FullUri);
@ -121,6 +132,11 @@ namespace PlexRequests.UI.Modules
private Response PlexTest() private Response PlexTest()
{ {
var plexSettings = this.Bind<PlexSettings>(); var plexSettings = this.Bind<PlexSettings>();
var valid = this.Validate(plexSettings);
if (!valid.IsValid)
{
return Response.AsJson(valid.SendJsonError());
}
var settings = AuthSettings.GetSettings(); var settings = AuthSettings.GetSettings();
if (settings?.PlexAuthToken == null) if (settings?.PlexAuthToken == null)
{ {
@ -150,7 +166,11 @@ namespace PlexRequests.UI.Modules
private Response SickRageTest() private Response SickRageTest()
{ {
var sickRageSettings = this.Bind<SickRageSettings>(); var sickRageSettings = this.Bind<SickRageSettings>();
var valid = this.Validate(sickRageSettings);
if (!valid.IsValid)
{
return Response.AsJson(valid.SendJsonError());
}
try try
{ {
var status = SickRageApi.Ping(sickRageSettings.ApiKey, sickRageSettings.FullUri); var status = SickRageApi.Ping(sickRageSettings.ApiKey, sickRageSettings.FullUri);
@ -175,6 +195,11 @@ namespace PlexRequests.UI.Modules
private Response HeadphonesTest() private Response HeadphonesTest()
{ {
var settings = this.Bind<HeadphonesSettings>(); var settings = this.Bind<HeadphonesSettings>();
var valid = this.Validate(settings);
if (!valid.IsValid)
{
return Response.AsJson(valid.SendJsonError());
}
try try
{ {
var result = HeadphonesApi.GetVersion(settings.ApiKey, settings.FullUri); var result = HeadphonesApi.GetVersion(settings.ApiKey, settings.FullUri);

@ -75,6 +75,11 @@ namespace PlexRequests.UI.Modules
} }
Session[SessionKeys.UsernameKey] = username; Session[SessionKeys.UsernameKey] = username;
Session[SessionKeys.ClientDateTimeOffsetKey] = dtOffset; 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);
}; };

@ -178,6 +178,7 @@
<Compile Include="Models\SearchMusicViewModel.cs" /> <Compile Include="Models\SearchMusicViewModel.cs" />
<Compile Include="Models\SearchMovieViewModel.cs" /> <Compile Include="Models\SearchMovieViewModel.cs" />
<Compile Include="Modules\BaseModule.cs" /> <Compile Include="Modules\BaseModule.cs" />
<Compile Include="Validators\HeadphonesValidator.cs" />
<Compile Include="Validators\PushoverSettingsValidator.cs" /> <Compile Include="Validators\PushoverSettingsValidator.cs" />
<Compile Include="Validators\PushbulletSettingsValidator.cs" /> <Compile Include="Validators\PushbulletSettingsValidator.cs" />
<Compile Include="Validators\EmailNotificationSettingsValidator.cs" /> <Compile Include="Validators\EmailNotificationSettingsValidator.cs" />

@ -0,0 +1,42 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2016 Jamie Rees
// File: SonarrValidator.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
using FluentValidation;
using PlexRequests.Core.SettingModels;
namespace PlexRequests.UI.Validators
{
public class HeadphonesValidator : AbstractValidator<HeadphonesSettings>
{
public HeadphonesValidator()
{
RuleFor(request => request.Ip).NotEmpty().WithMessage("You must specify a IP/Host name.");
RuleFor(request => request.Port).NotEmpty().WithMessage("You must specify a Port.");
RuleFor(request => request.ApiKey).NotEmpty().WithMessage("You must specify a Api Key.");
}
}
}

@ -122,11 +122,11 @@
$('#requestToken').click(function (e) { $('#requestToken').click(function (e) {
e.preventDefault(); e.preventDefault();
var url = createBaseUrl(base, "admin/requestauth"); var url = createBaseUrl(base, "requestauth");
var $form = $("#mainForm"); var $form = $("#mainForm");
$.ajax({ $.ajax({
type: $form.prop("method"), type: $form.prop("method"),
url: url, url: "requestauth",
data: $form.serialize(), data: $form.serialize(),
dataType: "json", dataType: "json",
success: function (response) { success: function (response) {
@ -149,11 +149,11 @@
function loadUserList() { function loadUserList() {
$('#users').html(""); $('#users').html("");
var url = "admin/getusers"; var url = "getusers";
url = createBaseUrl(base, url); url = createBaseUrl(base, url);
$.ajax({ $.ajax({
type: "Get", type: "Get",
url: url, url: "getusers",
dataType: "json", dataType: "json",
success: function (response) { success: function (response) {
if (response.length > 1) { if (response.length > 1) {

@ -116,7 +116,7 @@
<text> <text>
var qualitySelected = '@Model.ProfileId'; var qualitySelected = '@Model.ProfileId';
var $form = $("#mainForm"); var $form = $("#mainForm");
var url = 'cpprofiles'; var url = '/admin/cpprofiles';
url = createBaseUrl(baseUrl, url); url = createBaseUrl(baseUrl, url);
$.ajax({ $.ajax({
type: $form.prop("method"), type: $form.prop("method"),
@ -144,14 +144,17 @@
$('#getProfiles').click(function (e) { $('#getProfiles').click(function (e) {
e.preventDefault(); e.preventDefault();
var $form = $("#mainForm"); var $form = $("#mainForm");
var url = "admin/cpprofiles"; var url = createBaseUrl(baseUrl, "/admin/cpprofiles");
url = createBaseUrl(baseUrl, url);
$.ajax({ $.ajax({
type: $form.prop("method"), type: $form.prop("method"),
data: $form.serialize(), data: $form.serialize(),
url: url, url: url,
dataType: "json", dataType: "json",
success: function (response) { success: function (response) {
if (response.message) {
generateNotify(response.message, "warning");
return;
}
response.list.forEach(function (result) { response.list.forEach(function (result) {
$("#select").append("<option value='" + result._id + "'>" + result.label + "</option>"); $("#select").append("<option value='" + result._id + "'>" + result.label + "</option>");
}); });
@ -167,7 +170,6 @@
e.preventDefault(); e.preventDefault();
var $form = $("#mainForm"); var $form = $("#mainForm");
var url = createBaseUrl(baseUrl,"/test/cp"); var url = createBaseUrl(baseUrl,"/test/cp");
url = createBaseUrl(baseUrl, url);
$.ajax({ $.ajax({
type: $form.prop("method"), type: $form.prop("method"),
url: url, url: url,

@ -148,13 +148,18 @@
$('#testSickRage').click(function (e) { $('#testSickRage').click(function (e) {
e.preventDefault(); e.preventDefault();
var qualityProfile = $("#profiles option:selected").val();
var $form = $("#mainForm"); var $form = $("#mainForm");
var data = $form.serialize();
data = data + "&qualityProfile=" + qualityProfile;
var url = createBaseUrl(base, '/test/sickrage'); var url = createBaseUrl(base, '/test/sickrage');
$.ajax({ $.ajax({
type: $form.prop("method"), type: $form.prop("method"),
url: url, url: url,
data: $form.serialize(), data: data,
dataType: "json", dataType: "json",
success: function (response) { success: function (response) {
console.log(response); console.log(response);

@ -224,16 +224,22 @@
} }
}); });
}); });
var base = '@Html.GetBaseUrl()'; var base = '@Html.GetBaseUrl()';
$('#testSonarr').click(function (e) { $('#testSonarr').click(function (e) {
e.preventDefault(); e.preventDefault();
var qualityProfile = $("#profiles option:selected").val();
var $form = $("#mainForm"); var $form = $("#mainForm");
var data = $form.serialize();
data = data + "&qualityProfile=" + qualityProfile;
var url = createBaseUrl(base, '/test/sonarr'); var url = createBaseUrl(base, '/test/sonarr');
$.ajax({ $.ajax({
type: $form.prop("method"), type: $form.prop("method"),
url: url, url: url,
data: $form.serialize(), data: data,
dataType: "json", dataType: "json",
success: function (response) { success: function (response) {
console.log(response); console.log(response);

@ -411,7 +411,6 @@
</div> </div>
</div> </div>
</div> </div>
<div id="baseUrl" value="@Html.GetBaseUrl()"></div>
@Html.LoadRequestAssets() @Html.LoadRequestAssets()

@ -1,4 +1,12 @@
@using PlexRequests.UI.Helpers @using PlexRequests.UI.Helpers
@{
var baseUrl = Html.GetBaseUrl();
var url = string.Empty;
if (!string.IsNullOrEmpty(baseUrl.ToHtmlString()))
{
url = "/" + baseUrl.ToHtmlString();
}
}
<div> <div>
<h1>Search</h1> <h1>Search</h1>
<h4>Want to watch something that is not currently on Plex?! No problem! Just search for it below and request it!</h4> <h4>Want to watch something that is not currently on Plex?! No problem! Just search for it below and request it!</h4>
@ -19,7 +27,7 @@
} }
</ul> </ul>
<!-- Tab panes --> <!-- Tab panes -->
<div class="tab-content"> <div class="tab-content">
@if (Model.SearchForMovies) @if (Model.SearchForMovies)
@ -123,7 +131,7 @@
<p>{{overview}}</p> <p>{{overview}}</p>
</div> </div>
<div class="col-sm-2 col-sm-push-3"> <div class="col-sm-2 col-sm-push-3">
<form method="POST" action="/search/request/{{type}}" id="form{{id}}"> <form method="POST" action="@url/search/request/{{type}}" id="form{{id}}">
<input name="{{type}}Id" type="text" value="{{id}}" hidden="hidden" /> <input name="{{type}}Id" type="text" value="{{id}}" hidden="hidden" />
{{#if_eq available true}} {{#if_eq available true}}
<button style="text-align: right" class="btn btn-success-outline disabled" disabled><i class="fa fa-check"></i> Available</button> <button style="text-align: right" class="btn btn-success-outline disabled" disabled><i class="fa fa-check"></i> Available</button>
@ -188,7 +196,7 @@
<p>{{overview}}</p> <p>{{overview}}</p>
</div> </div>
<div class="col-sm-2 col-sm-push-3"> <div class="col-sm-2 col-sm-push-3">
<form method="POST" action="/search/request/{{type}}" id="form{{id}}"> <form method="POST" action="@url/search/request/{{type}}" id="form{{id}}">
<input name="{{type}}Id" type="text" value="{{id}}" hidden="hidden" /> <input name="{{type}}Id" type="text" value="{{id}}" hidden="hidden" />
{{#if_eq available true}} {{#if_eq available true}}
<button style="text-align: right" class="btn btn-success-outline disabled" disabled><i class="fa fa-check"></i> Available</button> <button style="text-align: right" class="btn btn-success-outline disabled" disabled><i class="fa fa-check"></i> Available</button>

@ -3,11 +3,21 @@
@using PlexRequests.UI.Helpers @using PlexRequests.UI.Helpers
@using PlexRequests.UI.Models @using PlexRequests.UI.Models
@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase @inherits Nancy.ViewEngines.Razor.NancyRazorViewBase
@{
var baseUrl = Html.GetBaseUrl();
var url = string.Empty;
if (!string.IsNullOrEmpty(baseUrl.ToHtmlString()))
{
url = "/" + baseUrl.ToHtmlString();
}
}
<html> <html>
<div hidden="hidden" id="baseUrl">@baseUrl.ToHtmlString()</div>
<head> <head>
<title>Plex Requests</title> <title>Plex Requests</title>
<!-- Styles --> <!-- Styles -->
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
@Html.LoadAssets() @Html.LoadAssets()
</head> </head>
<body> <body>
@ -22,53 +32,36 @@
<span class="icon-bar"></span> <span class="icon-bar"></span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
</button> </button>
<a class="navbar-brand" href="/search">Plex Requests</a> <a class="navbar-brand" href="@url/search">Plex Requests</a>
</div> </div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">
@if (Context.Request.Path == "/search") @Html.GetNavbarUrl(Context, "/search", "Search", "search")
{ @Html.GetNavbarUrl(Context, "/requests", "Requests", "plus-circle")
<li class="active"><a href="/search"><i class="fa fa-search"></i> Search</a></li>
}
else
{
<li><a href="/search"><i class="fa fa-search"></i> Search</a></li>
}
@if (Context.Request.Path == "/requests")
{
<li class="active"><a href="/requests"><i class="fa fa-plus-circle"></i> Requests</a></li>
}
else
{
<li><a href="/requests"><i class="fa fa-plus-circle"></i> Requests</a></li>
}
</ul> </ul>
<ul class="nav navbar-nav navbar-right"> <ul class="nav navbar-nav navbar-right">
@if (!Context.CurrentUser.IsAuthenticated()) @if (!Context.CurrentUser.IsAuthenticated())
{ {
<li><a href="/login"><i class="fa fa-user"></i> Admin</a></li> <li><a href="@url/login"><i class="fa fa-user"></i> Admin</a></li>
} }
else else
{ {
<li class="dropdown"> <li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-user"></i> Admin <span class="caret"></span></a> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-user"></i> Admin <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu"> <ul class="dropdown-menu" role="menu">
<li><a href="/admin"><i class="fa fa-cog"></i> Settings</a></li> <li><a href="@url/admin"><i class="fa fa-cog"></i> Settings</a></li>
<li><a href="/changepassword"><i class="fa fa-key"></i> Change password</a></li> <li><a href="@url/changepassword"><i class="fa fa-key"></i> Change password</a></li>
<li class="divider"></li> <li class="divider"></li>
<li><a href="/logout"><i class="fa fa-sign-out"></i> Logout</a></li> <li><a href="@url/logout"><i class="fa fa-sign-out"></i> Logout</a></li>
</ul> </ul>
</li> </li>
} }
@if (Context.Request.Session[SessionKeys.UsernameKey] != null) @if (Context.Request.Session[SessionKeys.UsernameKey] != null)
{ {
<li><a href="/userlogin/logout"><i class="fa fa-sign-out"></i> Logout</a></li> <li><a href="@url/userlogin/logout"><i class="fa fa-sign-out"></i> Logout</a></li>
} }
</ul> </ul>
</div> </div>
@ -78,11 +71,11 @@
<div class="container"> <div class="container">
@RenderBody() @RenderBody()
</div> </div>
<div class="scroll-top-wrapper "> <div class="scroll-top-wrapper ">
<span class="scroll-top-inner"> <span class="scroll-top-inner">
<i class="fa fa-2x fa-arrow-circle-up"></i> <i class="fa fa-2x fa-arrow-circle-up"></i>
</span> </span>
</div> </div>
</body> </body>
</html> </html>
<script> <script>

Loading…
Cancel
Save