mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-08 14:10:50 -07:00
Some work on the requests page
This commit is contained in:
parent
8043cdd527
commit
48fd182e52
8 changed files with 209 additions and 37 deletions
|
@ -47,7 +47,7 @@ function movieLoad() {
|
||||||
|
|
||||||
$.ajax("/requests/movies/").success(function (results) {
|
$.ajax("/requests/movies/").success(function (results) {
|
||||||
results.forEach(function (result) {
|
results.forEach(function (result) {
|
||||||
var context = buildMovieRequestContext(result);
|
var context = buildRequestContext(result, "movie");
|
||||||
|
|
||||||
var html = searchTemplate(context);
|
var html = searchTemplate(context);
|
||||||
$("#movieList").append(html);
|
$("#movieList").append(html);
|
||||||
|
@ -60,40 +60,29 @@ function tvLoad() {
|
||||||
|
|
||||||
$.ajax("/requests/tvshows/").success(function (results) {
|
$.ajax("/requests/tvshows/").success(function (results) {
|
||||||
results.forEach(function (result) {
|
results.forEach(function (result) {
|
||||||
var context = buildTvShowRequestContext(result);
|
var context = buildRequestContext(result, "tv");
|
||||||
var html = searchTemplate(context);
|
var html = searchTemplate(context);
|
||||||
$("#tvList").append(html);
|
$("#tvList").append(html);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
function buildMovieRequestContext(result) {
|
function buildRequestContext(result, type) {
|
||||||
var date = new Date(result.releaseDate);
|
|
||||||
var year = date.getFullYear();
|
|
||||||
var context = {
|
var context = {
|
||||||
posterPath: result.posterPath,
|
posterPath: result.posterPath,
|
||||||
id: result.tmdbid,
|
id: result.tmdbid,
|
||||||
title: result.title,
|
title: result.title,
|
||||||
overview: result.overview,
|
overview: result.overview,
|
||||||
year: year,
|
year: result.releaseYear,
|
||||||
type: "movie",
|
type: type,
|
||||||
status: result.status
|
status: result.status,
|
||||||
|
releaseDate: result.releaseDate,
|
||||||
|
approved: result.approved,
|
||||||
|
requestedBy: result.requestedBy,
|
||||||
|
requestedDate: result.requestedDate,
|
||||||
|
available: result.available
|
||||||
};
|
};
|
||||||
|
|
||||||
return context;
|
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
|
|
||||||
};
|
|
||||||
return context;
|
|
||||||
}
|
|
||||||
|
|
50
RequestPlex.UI/Models/RequestViewModel.cs
Normal file
50
RequestPlex.UI/Models/RequestViewModel.cs
Normal file
|
@ -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 System.Linq;
|
||||||
|
|
||||||
|
using Humanizer;
|
||||||
|
|
||||||
using Nancy;
|
using Nancy;
|
||||||
using Nancy.Responses.Negotiation;
|
using Nancy.Responses.Negotiation;
|
||||||
|
|
||||||
using RequestPlex.Api;
|
|
||||||
using RequestPlex.Core;
|
|
||||||
using RequestPlex.Core.SettingModels;
|
|
||||||
using RequestPlex.Store;
|
using RequestPlex.Store;
|
||||||
|
using RequestPlex.UI.Models;
|
||||||
|
|
||||||
namespace RequestPlex.UI.Modules
|
namespace RequestPlex.UI.Modules
|
||||||
{
|
{
|
||||||
|
@ -36,13 +63,47 @@ namespace RequestPlex.UI.Modules
|
||||||
private Response GetMovies()
|
private Response GetMovies()
|
||||||
{
|
{
|
||||||
var dbMovies = Service.GetAll().Where(x => x.Type == RequestType.Movie);
|
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()
|
private Response GetTvShows()
|
||||||
{
|
{
|
||||||
var dbTv = Service.GetAll().Where(x => x.Type == RequestType.TvShow);
|
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)
|
private Response Delete(int tmdbId, RequestType type)
|
||||||
|
|
|
@ -48,7 +48,8 @@ namespace RequestPlex.UI
|
||||||
s.SetupDb();
|
s.SetupDb();
|
||||||
|
|
||||||
var uri = GetStartupUri();
|
var uri = GetStartupUri();
|
||||||
|
try
|
||||||
|
{
|
||||||
using (WebApp.Start<Startup>(uri))
|
using (WebApp.Start<Startup>(uri))
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Request Plex is running on {uri}");
|
Console.WriteLine($"Request Plex is running on {uri}");
|
||||||
|
@ -56,6 +57,13 @@ namespace RequestPlex.UI
|
||||||
Console.ReadLine();
|
Console.ReadLine();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private static void WriteOutVersion()
|
private static void WriteOutVersion()
|
||||||
{
|
{
|
||||||
|
|
|
@ -54,6 +54,10 @@
|
||||||
</StartupObject>
|
</StartupObject>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<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">
|
<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>
|
<HintPath>..\packages\Microsoft.Owin.3.0.1\lib\net45\Microsoft.Owin.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
|
@ -126,6 +130,7 @@
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Compile Include="Models\PlexAuth.cs" />
|
<Compile Include="Models\PlexAuth.cs" />
|
||||||
|
<Compile Include="Models\RequestViewModel.cs" />
|
||||||
<Compile Include="Modules\AdminModule.cs" />
|
<Compile Include="Modules\AdminModule.cs" />
|
||||||
<Compile Include="Modules\IndexModule.cs" />
|
<Compile Include="Modules\IndexModule.cs" />
|
||||||
<Compile Include="Modules\LoginModule.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;
|
using Owin;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<div>
|
<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 -->
|
<!-- Nav tabs -->
|
||||||
<ul id="nav-tabs" class="nav nav-tabs" role="tablist">
|
<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>
|
<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}}">
|
<a href="https://www.themoviedb.org/{{type}}/{{id}}">
|
||||||
<h4>{{title}} ({{year}})</h4>
|
<h4>{{title}} ({{year}})</h4>
|
||||||
</a>
|
</a>
|
||||||
|
<span class="label label-success">{{status}}</span>
|
||||||
</div>
|
</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>
|
||||||
<div class="col-sm-2 col-sm-push-3">
|
<div class="col-sm-2 col-sm-push-3">
|
||||||
<span class="label label-success">{{status}}</span>
|
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
<form method="POST" action="/requests/delete" id="form{{id}}">
|
<form method="POST" action="/requests/delete" id="form{{id}}">
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<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.AspNet.Razor" version="2.0.30506.0" targetFramework="net45" />
|
||||||
<package id="Microsoft.Owin" version="3.0.1" targetFramework="net452" />
|
<package id="Microsoft.Owin" version="3.0.1" targetFramework="net452" />
|
||||||
<package id="Microsoft.Owin.Host.HttpListener" 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="Nancy.Viewengines.Razor" version="1.4.1" requireReinstallation="true" />
|
||||||
<package id="Owin" version="1.0" targetFramework="net452" />
|
<package id="Owin" version="1.0" targetFramework="net452" />
|
||||||
<package id="RestSharp" version="105.2.3" 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" />
|
<package id="TMDbLib" version="0.9.0.0-alpha" targetFramework="net452" />
|
||||||
</packages>
|
</packages>
|
Loading…
Add table
Add a link
Reference in a new issue