Some work on the requests page

pull/13/head
tidusjar 9 years ago
parent 8043cdd527
commit 48fd182e52

@ -47,7 +47,7 @@ function movieLoad() {
$.ajax("/requests/movies/").success(function (results) {
results.forEach(function (result) {
var context = buildMovieRequestContext(result);
var context = buildRequestContext(result, "movie");
var html = searchTemplate(context);
$("#movieList").append(html);
@ -60,40 +60,29 @@ function tvLoad() {
$.ajax("/requests/tvshows/").success(function (results) {
results.forEach(function (result) {
var context = buildTvShowRequestContext(result);
var context = buildRequestContext(result, "tv");
var html = searchTemplate(context);
$("#tvList").append(html);
});
});
};
function buildMovieRequestContext(result) {
var date = new Date(result.releaseDate);
var year = date.getFullYear();
var context = {
posterPath: result.posterPath,
id: result.tmdbid,
title: result.title,
overview: result.overview,
year: year,
type: "movie",
status: result.status
};
function buildRequestContext(result, type) {
return context;
}
function buildTvShowRequestContext(result) {
var date = new Date(result.releaseDate);
var year = date.getFullYear();
var context = {
posterPath: result.posterPath,
id: result.tmdbid,
title: result.title,
overview: result.overview,
year: year,
type: "tv",
status: result.status
year: result.releaseYear,
type: type,
status: result.status,
releaseDate: result.releaseDate,
approved: result.approved,
requestedBy: result.requestedBy,
requestedDate: result.requestedDate,
available: result.available
};
return context;
}

@ -0,0 +1,50 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2016 Jamie Rees
// File: RequestViewModel.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 System;
using RequestPlex.Store;
namespace RequestPlex.UI.Models
{
public class RequestViewModel
{
public int Id { get; set; }
public int Tmdbid { get; set; }
public string ImdbId { get; set; }
public string Overview { get; set; }
public string Title { get; set; }
public string PosterPath { get; set; }
public string ReleaseDate { get; set; }
public RequestType Type { get; set; }
public string Status { get; set; }
public bool Approved { get; set; }
public string RequestedBy { get; set; }
public string RequestedDate { get; set; }
public string ReleaseYear { get; set; }
public bool Available { get; set; }
}
}

@ -1,12 +1,39 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2016 Jamie Rees
// File: RequestsModule.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 System.Collections.Generic;
using System.Linq;
using Humanizer;
using Nancy;
using Nancy.Responses.Negotiation;
using RequestPlex.Api;
using RequestPlex.Core;
using RequestPlex.Core.SettingModels;
using RequestPlex.Store;
using RequestPlex.UI.Models;
namespace RequestPlex.UI.Modules
{
@ -36,13 +63,47 @@ namespace RequestPlex.UI.Modules
private Response GetMovies()
{
var dbMovies = Service.GetAll().Where(x => x.Type == RequestType.Movie);
return Response.AsJson(dbMovies);
var viewModel = dbMovies.Select(tv => new RequestViewModel
{
Tmdbid = tv.Tmdbid,
Type = tv.Type,
Status = tv.Status,
ImdbId = tv.ImdbId,
Id = tv.Id,
PosterPath = tv.PosterPath,
ReleaseDate = tv.ReleaseDate.Humanize(),
RequestedDate = tv.RequestedDate.Humanize(),
Approved = tv.Approved,
Title = tv.Title,
Overview = tv.Overview,
RequestedBy = tv.RequestedBy,
ReleaseYear = tv.ReleaseDate.Year.ToString()
}).ToList();
//TODO check if Available
return Response.AsJson(viewModel);
}
private Response GetTvShows()
{
var dbTv = Service.GetAll().Where(x => x.Type == RequestType.TvShow);
return Response.AsJson(dbTv);
var viewModel = dbTv.Select(tv => new RequestViewModel
{
Tmdbid = tv.Tmdbid,
Type = tv.Type,
Status = tv.Status,
ImdbId = tv.ImdbId,
Id = tv.Id,
PosterPath = tv.PosterPath,
ReleaseDate = tv.ReleaseDate.Humanize(),
RequestedDate = tv.RequestedDate.Humanize(),
Approved = tv.Approved,
Title = tv.Title,
Overview = tv.Overview,
RequestedBy = tv.RequestedBy,
ReleaseYear = tv.ReleaseDate.Year.ToString()
}).ToList();
//TODO check if Available
return Response.AsJson(viewModel);
}
private Response Delete(int tmdbId, RequestType type)

@ -48,13 +48,21 @@ namespace RequestPlex.UI
s.SetupDb();
var uri = GetStartupUri();
using (WebApp.Start<Startup>(uri))
try
{
using (WebApp.Start<Startup>(uri))
{
Console.WriteLine($"Request Plex is running on {uri}");
Console.WriteLine("Press any key to exit");
Console.ReadLine();
}
}
catch (Exception e)
{
Console.WriteLine($"Request Plex is running on {uri}");
Console.WriteLine("Press any key to exit");
Console.ReadLine();
throw;
}
}
private static void WriteOutVersion()

@ -54,6 +54,10 @@
</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="Humanizer, Version=2.0.1.0, Culture=neutral, PublicKeyToken=979442b78dfc278e, processorArchitecture=MSIL">
<HintPath>..\packages\Humanizer.Core.2.0.1\lib\dotnet\Humanizer.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Owin, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Owin.3.0.1\lib\net45\Microsoft.Owin.dll</HintPath>
<Private>True</Private>
@ -126,6 +130,7 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Compile Include="Models\PlexAuth.cs" />
<Compile Include="Models\RequestViewModel.cs" />
<Compile Include="Modules\AdminModule.cs" />
<Compile Include="Modules\IndexModule.cs" />
<Compile Include="Modules\LoginModule.cs" />

@ -1,4 +1,30 @@
using System;
#region Copyright
// /************************************************************************
// Copyright (c) 2016 Jamie Rees
// File: Startup.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 System;
using Owin;

@ -1,5 +1,6 @@
<div>
<h2>Requests</h2>
<h1>Requests</h1>
<h4>Below you can see yours and all other requests, as well as their download and approval status.</h4>
<!-- Nav tabs -->
<ul id="nav-tabs" class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"><a href="#MoviesTab" aria-controls="home" role="tab" data-toggle="tab">Movies</a></li>
@ -45,11 +46,32 @@
<a href="https://www.themoviedb.org/{{type}}/{{id}}">
<h4>{{title}} ({{year}})</h4>
</a>
<span class="label label-success">{{status}}</span>
</div>
<p>{{overview}}</p>
<br />
<p>Release Date: {{releaseDate}}</p>
<p>
Approved:
{{#if_eq approved false}}
<i class="fa fa-times"></i>
{{/if_eq}}
{{#if_eq approved true}}
<i class="fa fa-check"></i>
{{/if_eq}}
</p>
<p>
Available
{{#if_eq available false}}
<i class="fa fa-times"></i>
{{/if_eq}}
{{#if_eq available true}}
<i class="fa fa-check"></i>
{{/if_eq}}
</p>
<p>Requested By: {{requestedBy}}</p>
<p>Requested Date: {{requestedDate}}</p>
</div>
<div class="col-sm-2 col-sm-push-3">
<span class="label label-success">{{status}}</span>
<br />
<br />
<form method="POST" action="/requests/delete" id="form{{id}}">

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Humanizer.Core" version="2.0.1" targetFramework="net452" />
<package id="Microsoft.AspNet.Razor" version="2.0.30506.0" targetFramework="net45" />
<package id="Microsoft.Owin" version="3.0.1" targetFramework="net452" />
<package id="Microsoft.Owin.Host.HttpListener" version="3.0.1" targetFramework="net452" />
@ -12,5 +13,15 @@
<package id="Nancy.Viewengines.Razor" version="1.4.1" requireReinstallation="true" />
<package id="Owin" version="1.0" targetFramework="net452" />
<package id="RestSharp" version="105.2.3" targetFramework="net452" />
<package id="System.Collections" version="4.0.0" targetFramework="net452" />
<package id="System.Diagnostics.Debug" version="4.0.0" targetFramework="net452" />
<package id="System.Globalization" version="4.0.0" targetFramework="net452" />
<package id="System.Linq" version="4.0.0" targetFramework="net452" />
<package id="System.Reflection" version="4.0.0" targetFramework="net452" />
<package id="System.Reflection.Extensions" version="4.0.0" targetFramework="net452" />
<package id="System.Resources.ResourceManager" version="4.0.0" targetFramework="net452" />
<package id="System.Runtime" version="4.0.0" targetFramework="net452" />
<package id="System.Runtime.Extensions" version="4.0.0" targetFramework="net452" />
<package id="System.Text.RegularExpressions" version="4.0.0" targetFramework="net452" />
<package id="TMDbLib" version="0.9.0.0-alpha" targetFramework="net452" />
</packages>
Loading…
Cancel
Save