mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-16 02:02:55 -07:00
Got most of the UI done for the voting feature !wip
This commit is contained in:
parent
3f7eb80470
commit
660df99123
17 changed files with 1551 additions and 23 deletions
|
@ -40,7 +40,7 @@ namespace Ombi.Core.Engine
|
||||||
{
|
{
|
||||||
var vm = new List<VoteViewModel>();
|
var vm = new List<VoteViewModel>();
|
||||||
var movieRequests = await _movieRequestEngine.GetRequests();
|
var movieRequests = await _movieRequestEngine.GetRequests();
|
||||||
var tvRequestsTask = _tvRequestEngine.GetRequestsLite();
|
var tvRequestsTask = _tvRequestEngine.GetRequests();
|
||||||
var musicRequestsTask = _musicRequestEngine.GetRequests();
|
var musicRequestsTask = _musicRequestEngine.GetRequests();
|
||||||
foreach (var r in movieRequests)
|
foreach (var r in movieRequests)
|
||||||
{
|
{
|
||||||
|
@ -55,8 +55,8 @@ namespace Ombi.Core.Engine
|
||||||
RequestId = r.Id,
|
RequestId = r.Id,
|
||||||
RequestType = RequestType.Movie,
|
RequestType = RequestType.Movie,
|
||||||
Title = r.Title,
|
Title = r.Title,
|
||||||
Image = r.PosterPath,
|
Image = $"https://image.tmdb.org/t/p/w500/{r.PosterPath}",
|
||||||
Background = r.Background,
|
Background = $"https://image.tmdb.org/t/p/w1280{r.Background}",
|
||||||
Description = r.Overview
|
Description = r.Overview
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ namespace Ombi.Core.Engine
|
||||||
foreach (var r in await musicRequestsTask)
|
foreach (var r in await musicRequestsTask)
|
||||||
{
|
{
|
||||||
// Make model
|
// Make model
|
||||||
var votes = GetVotes(r.Id, RequestType.Movie);
|
var votes = GetVotes(r.Id, RequestType.Album);
|
||||||
var upVotes = await votes.Where(x => x.VoteType == VoteType.Upvote).CountAsync();
|
var upVotes = await votes.Where(x => x.VoteType == VoteType.Upvote).CountAsync();
|
||||||
var downVotes = await votes.Where(x => x.VoteType == VoteType.Downvote).CountAsync();
|
var downVotes = await votes.Where(x => x.VoteType == VoteType.Downvote).CountAsync();
|
||||||
vm.Add(new VoteViewModel
|
vm.Add(new VoteViewModel
|
||||||
|
@ -72,9 +72,9 @@ namespace Ombi.Core.Engine
|
||||||
Upvotes = upVotes,
|
Upvotes = upVotes,
|
||||||
Downvotes = downVotes,
|
Downvotes = downVotes,
|
||||||
RequestId = r.Id,
|
RequestId = r.Id,
|
||||||
RequestType = RequestType.Movie,
|
RequestType = RequestType.Album,
|
||||||
Title = r.Title,
|
Title = r.Title,
|
||||||
Image = r.Disk,
|
Image = r.Cover,
|
||||||
Background = r.Cover,
|
Background = r.Cover,
|
||||||
Description = r.ArtistName
|
Description = r.ArtistName
|
||||||
});
|
});
|
||||||
|
@ -83,7 +83,7 @@ namespace Ombi.Core.Engine
|
||||||
foreach (var r in await tvRequestsTask)
|
foreach (var r in await tvRequestsTask)
|
||||||
{
|
{
|
||||||
// Make model
|
// Make model
|
||||||
var votes = GetVotes(r.Id, RequestType.Movie);
|
var votes = GetVotes(r.Id, RequestType.TvShow);
|
||||||
var upVotes = await votes.Where(x => x.VoteType == VoteType.Upvote).CountAsync();
|
var upVotes = await votes.Where(x => x.VoteType == VoteType.Upvote).CountAsync();
|
||||||
var downVotes = await votes.Where(x => x.VoteType == VoteType.Downvote).CountAsync();
|
var downVotes = await votes.Where(x => x.VoteType == VoteType.Downvote).CountAsync();
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ namespace Ombi.Core.Engine
|
||||||
Upvotes = upVotes,
|
Upvotes = upVotes,
|
||||||
Downvotes = downVotes,
|
Downvotes = downVotes,
|
||||||
RequestId = r.Id,
|
RequestId = r.Id,
|
||||||
RequestType = RequestType.Movie,
|
RequestType = RequestType.TvShow,
|
||||||
Title = r.Title,
|
Title = r.Title,
|
||||||
Image = r.PosterPath,
|
Image = r.PosterPath,
|
||||||
Background = r.Background,
|
Background = r.Background,
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Moq;
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using Ombi.Core.Settings;
|
using static Ombi.Schedule.Jobs.Ombi.NewsletterJob;
|
||||||
using Ombi.Schedule.Jobs.Ombi;
|
|
||||||
using Ombi.Settings.Settings.Models;
|
|
||||||
using Ombi.Settings.Settings.Models.Notifications;
|
|
||||||
using Ombi.Store.Entities;
|
|
||||||
|
|
||||||
namespace Ombi.Schedule.Tests
|
namespace Ombi.Schedule.Tests
|
||||||
{
|
{
|
||||||
|
@ -15,17 +10,12 @@ namespace Ombi.Schedule.Tests
|
||||||
[TestCaseSource(nameof(EpisodeListData))]
|
[TestCaseSource(nameof(EpisodeListData))]
|
||||||
public string BuildEpisodeListTest(List<int> episodes)
|
public string BuildEpisodeListTest(List<int> episodes)
|
||||||
{
|
{
|
||||||
var emailSettings = new Mock<ISettingsService<EmailNotificationSettings>>();
|
|
||||||
var customziation = new Mock<ISettingsService<CustomizationSettings>>();
|
|
||||||
var newsletterSettings = new Mock<ISettingsService<NewsletterSettings>>();
|
|
||||||
var newsletter = new NewsletterJob(null, null, null, null, null, null, customziation.Object, emailSettings.Object, null, null, newsletterSettings.Object, null, null, null, null);
|
|
||||||
|
|
||||||
var ep = new List<int>();
|
var ep = new List<int>();
|
||||||
foreach (var i in episodes)
|
foreach (var i in episodes)
|
||||||
{
|
{
|
||||||
ep.Add(i);
|
ep.Add(i);
|
||||||
}
|
}
|
||||||
var result = newsletter.BuildEpisodeList(ep);
|
var result = BuildEpisodeList(ep);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
1182
src/Ombi.Store/Migrations/20180928201334_Votes.Designer.cs
generated
Normal file
1182
src/Ombi.Store/Migrations/20180928201334_Votes.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
46
src/Ombi.Store/Migrations/20180928201334_Votes.cs
Normal file
46
src/Ombi.Store/Migrations/20180928201334_Votes.cs
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
namespace Ombi.Store.Migrations
|
||||||
|
{
|
||||||
|
public partial class Votes : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Votes",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(nullable: false)
|
||||||
|
.Annotation("Sqlite:Autoincrement", true),
|
||||||
|
RequestId = table.Column<int>(nullable: false),
|
||||||
|
VoteType = table.Column<int>(nullable: false),
|
||||||
|
RequestType = table.Column<int>(nullable: false),
|
||||||
|
UserId = table.Column<string>(nullable: true),
|
||||||
|
Date = table.Column<DateTime>(nullable: false),
|
||||||
|
Deleted = table.Column<bool>(nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Votes", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Votes_AspNetUsers_UserId",
|
||||||
|
column: x => x.UserId,
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Votes_UserId",
|
||||||
|
table: "Votes",
|
||||||
|
column: "UserId");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Votes");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -916,6 +916,30 @@ namespace Ombi.Store.Migrations
|
||||||
b.ToTable("UserQualityProfiles");
|
b.ToTable("UserQualityProfiles");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Ombi.Store.Entities.Votes", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b.Property<DateTime>("Date");
|
||||||
|
|
||||||
|
b.Property<bool>("Deleted");
|
||||||
|
|
||||||
|
b.Property<int>("RequestId");
|
||||||
|
|
||||||
|
b.Property<int>("RequestType");
|
||||||
|
|
||||||
|
b.Property<string>("UserId");
|
||||||
|
|
||||||
|
b.Property<int>("VoteType");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("Votes");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Ombi.Store.Repository.Requests.EpisodeRequests", b =>
|
modelBuilder.Entity("Ombi.Store.Repository.Requests.EpisodeRequests", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
|
@ -1128,6 +1152,13 @@ namespace Ombi.Store.Migrations
|
||||||
.HasForeignKey("UserId");
|
.HasForeignKey("UserId");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Ombi.Store.Entities.Votes", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Ombi.Store.Entities.OmbiUser", "User")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Ombi.Store.Repository.Requests.EpisodeRequests", b =>
|
modelBuilder.Entity("Ombi.Store.Repository.Requests.EpisodeRequests", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("Ombi.Store.Repository.Requests.SeasonRequests", "Season")
|
b.HasOne("Ombi.Store.Repository.Requests.SeasonRequests", "Season")
|
||||||
|
|
|
@ -15,7 +15,7 @@ import { TranslateLoader, TranslateModule } from "@ngx-translate/core";
|
||||||
import { TranslateHttpLoader } from "@ngx-translate/http-loader";
|
import { TranslateHttpLoader } from "@ngx-translate/http-loader";
|
||||||
import { CookieService } from "ng2-cookies";
|
import { CookieService } from "ng2-cookies";
|
||||||
import { GrowlModule } from "primeng/components/growl/growl";
|
import { GrowlModule } from "primeng/components/growl/growl";
|
||||||
import { ButtonModule, CaptchaModule, ConfirmationService, ConfirmDialogModule, DataTableModule, DialogModule, SharedModule, SidebarModule, TooltipModule } from "primeng/primeng";
|
import { ButtonModule, CaptchaModule, ConfirmationService, ConfirmDialogModule, DataTableModule, DialogModule, OverlayPanelModule, SharedModule, SidebarModule, TooltipModule } from "primeng/primeng";
|
||||||
|
|
||||||
// Components
|
// Components
|
||||||
import { AppComponent } from "./app.component";
|
import { AppComponent } from "./app.component";
|
||||||
|
@ -55,6 +55,7 @@ const routes: Routes = [
|
||||||
{ loadChildren: "./requests/requests.module#RequestsModule", path: "requests" },
|
{ loadChildren: "./requests/requests.module#RequestsModule", path: "requests" },
|
||||||
{ loadChildren: "./search/search.module#SearchModule", path: "search" },
|
{ loadChildren: "./search/search.module#SearchModule", path: "search" },
|
||||||
{ loadChildren: "./recentlyAdded/recentlyAdded.module#RecentlyAddedModule", path: "recentlyadded" },
|
{ loadChildren: "./recentlyAdded/recentlyAdded.module#RecentlyAddedModule", path: "recentlyadded" },
|
||||||
|
{ loadChildren: "./vote/vote.module#VoteModule", path: "vote" },
|
||||||
];
|
];
|
||||||
|
|
||||||
// AoT requires an exported function for factories
|
// AoT requires an exported function for factories
|
||||||
|
@ -97,6 +98,7 @@ export function JwtTokenGetter() {
|
||||||
CaptchaModule,
|
CaptchaModule,
|
||||||
TooltipModule,
|
TooltipModule,
|
||||||
ConfirmDialogModule,
|
ConfirmDialogModule,
|
||||||
|
OverlayPanelModule,
|
||||||
CommonModule,
|
CommonModule,
|
||||||
JwtModule.forRoot({
|
JwtModule.forRoot({
|
||||||
config: {
|
config: {
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
export enum RequestType {
|
export enum RequestType {
|
||||||
movie = 1,
|
movie = 1,
|
||||||
tvShow = 2,
|
tvShow = 2,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NEW WORLD
|
// NEW WORLD
|
||||||
|
|
23
src/Ombi/ClientApp/app/interfaces/IVote.ts
Normal file
23
src/Ombi/ClientApp/app/interfaces/IVote.ts
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
export interface IVoteViewModel {
|
||||||
|
requestId: number;
|
||||||
|
requestType: RequestTypes;
|
||||||
|
image: string;
|
||||||
|
background: string;
|
||||||
|
upvotes: number;
|
||||||
|
downvotes: number;
|
||||||
|
title: string;
|
||||||
|
description: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IVoteEngineResult {
|
||||||
|
result: boolean;
|
||||||
|
message: string;
|
||||||
|
isError: boolean;
|
||||||
|
errorMessage: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum RequestTypes {
|
||||||
|
TvShow = 0,
|
||||||
|
Movie = 1,
|
||||||
|
Album = 2,
|
||||||
|
}
|
|
@ -16,3 +16,4 @@ export * from "./IIssues";
|
||||||
export * from "./IRecentlyAdded";
|
export * from "./IRecentlyAdded";
|
||||||
export * from "./ILidarr";
|
export * from "./ILidarr";
|
||||||
export * from "./ISearchMusicResult";
|
export * from "./ISearchMusicResult";
|
||||||
|
export * from "./IVote";
|
||||||
|
|
|
@ -14,3 +14,4 @@ export * from "./issues.service";
|
||||||
export * from "./mobile.service";
|
export * from "./mobile.service";
|
||||||
export * from "./notificationMessage.service";
|
export * from "./notificationMessage.service";
|
||||||
export * from "./recentlyAdded.service";
|
export * from "./recentlyAdded.service";
|
||||||
|
export * from "./vote.service";
|
||||||
|
|
36
src/Ombi/ClientApp/app/services/vote.service.ts
Normal file
36
src/Ombi/ClientApp/app/services/vote.service.ts
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
import { PlatformLocation } from "@angular/common";
|
||||||
|
import { HttpClient } from "@angular/common/http";
|
||||||
|
import { Injectable } from "@angular/core";
|
||||||
|
|
||||||
|
import { IVoteEngineResult, IVoteViewModel } from "../interfaces";
|
||||||
|
import { ServiceHelpers } from "./service.helpers";
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class VoteService extends ServiceHelpers {
|
||||||
|
constructor(public http: HttpClient, public platformLocation: PlatformLocation) {
|
||||||
|
super(http, "/api/v1/Vote/", platformLocation);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getModel(): Promise<IVoteViewModel[]> {
|
||||||
|
return await this.http.get<IVoteViewModel[]>(`${this.url}`, {headers: this.headers}).toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async upvoteMovie(requestId: number): Promise<IVoteEngineResult> {
|
||||||
|
return await this.http.post<IVoteEngineResult>(`${this.url}up/movie/${requestId}`, {headers: this.headers}).toPromise();
|
||||||
|
}
|
||||||
|
public async upvoteTv(requestId: number): Promise<IVoteEngineResult> {
|
||||||
|
return await this.http.post<IVoteEngineResult>(`${this.url}up/tv/${requestId}`, {headers: this.headers}).toPromise();
|
||||||
|
}
|
||||||
|
public async upvoteAlbum(requestId: number): Promise<IVoteEngineResult> {
|
||||||
|
return await this.http.post<IVoteEngineResult>(`${this.url}up/album/${requestId}`, {headers: this.headers}).toPromise();
|
||||||
|
}
|
||||||
|
public async downvoteMovie(requestId: number): Promise<IVoteEngineResult> {
|
||||||
|
return await this.http.post<IVoteEngineResult>(`${this.url}down/movie/${requestId}`, {headers: this.headers}).toPromise();
|
||||||
|
}
|
||||||
|
public async downvoteTv(requestId: number): Promise<IVoteEngineResult> {
|
||||||
|
return await this.http.post<IVoteEngineResult>(`${this.url}down/tv/${requestId}`, {headers: this.headers}).toPromise();
|
||||||
|
}
|
||||||
|
public async downvoteAlbum(requestId: number): Promise<IVoteEngineResult> {
|
||||||
|
return await this.http.post<IVoteEngineResult>(`${this.url}down/album/${requestId}`, {headers: this.headers}).toPromise();
|
||||||
|
}
|
||||||
|
}
|
35
src/Ombi/ClientApp/app/vote/vote.component.html
Normal file
35
src/Ombi/ClientApp/app/vote/vote.component.html
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
<h1>Vote</h1>
|
||||||
|
|
||||||
|
<div *ngIf="viewModel">
|
||||||
|
|
||||||
|
<table class="table table-striped table-hover table-responsive table-condensed">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td>Title</td>
|
||||||
|
<td>Description</td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr *ngFor="let vm of viewModel">
|
||||||
|
<td class="vcenter">
|
||||||
|
<button class="btn btn-info-outline" (click)="upvote(vm)"><i class="fa fa-arrow-up" aria-hidden="true"></i></button>
|
||||||
|
<button class="btn btn-info-outline" (click)="downvote(vm)"><i class="fa fa-arrow-down" aria-hidden="true"></i></button>
|
||||||
|
</td>
|
||||||
|
<td style="width: 10%"> <img *ngIf="vm.image" class="img-responsive poster" style="max-width: 100%;
|
||||||
|
height: auto;
|
||||||
|
width: 100%;"
|
||||||
|
(click)="toggle($event, vm.image)" src="{{vm.image}}" alt="poster"></td>
|
||||||
|
<td class="vcenter">{{vm.title}}</td>
|
||||||
|
<td class="vcenter" [innerHTML]="vm.description"></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p-overlayPanel #op [dismissable]="true" [styleClass]="'hideBackground'">
|
||||||
|
<img class="img-responsive poster" width="70%" src="{{panelImage}}" alt="poster">
|
||||||
|
</p-overlayPanel>
|
12
src/Ombi/ClientApp/app/vote/vote.component.scss
Normal file
12
src/Ombi/ClientApp/app/vote/vote.component.scss
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
.vcenter {
|
||||||
|
vertical-align: middle;
|
||||||
|
float: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hideBackground {
|
||||||
|
border: 0px solid transparent !important;
|
||||||
|
background: transparent !important;
|
||||||
|
-webkit-box-shadow: 0 0px 0px 0 transparent !important;
|
||||||
|
-moz-box-shadow: 0 0px 0px 0 transparent !important;
|
||||||
|
box-shadow: 0 0px 0px 0 transparent !important;
|
||||||
|
}
|
70
src/Ombi/ClientApp/app/vote/vote.component.ts
Normal file
70
src/Ombi/ClientApp/app/vote/vote.component.ts
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
import { Component, OnInit, ViewChild } from "@angular/core";
|
||||||
|
|
||||||
|
import { OverlayPanel } from "primeng/primeng";
|
||||||
|
import { NotificationService, VoteService } from "../services";
|
||||||
|
|
||||||
|
import { IVoteEngineResult, IVoteViewModel, RequestTypes } from "../interfaces";
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
templateUrl: "vote.component.html",
|
||||||
|
styleUrls: ["vote.component.scss"],
|
||||||
|
})
|
||||||
|
export class VoteComponent implements OnInit {
|
||||||
|
|
||||||
|
public viewModel: IVoteViewModel[];
|
||||||
|
public panelImage: string;
|
||||||
|
@ViewChild("op") public overlayPanel: OverlayPanel;
|
||||||
|
|
||||||
|
constructor(private voteService: VoteService, private notificationSerivce: NotificationService) { }
|
||||||
|
|
||||||
|
public async ngOnInit() {
|
||||||
|
this.viewModel = await this.voteService.getModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
public toggle(event: any, image: string) {
|
||||||
|
this.panelImage = image;
|
||||||
|
this.overlayPanel.toggle(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async upvote(vm: IVoteViewModel) {
|
||||||
|
let result: IVoteEngineResult = {errorMessage:"", isError: false, message:"",result:false};
|
||||||
|
switch(vm.requestType) {
|
||||||
|
case RequestTypes.Album:
|
||||||
|
result = await this.voteService.upvoteAlbum(vm.requestId);
|
||||||
|
break;
|
||||||
|
case RequestTypes.Movie:
|
||||||
|
result = await this.voteService.upvoteMovie(vm.requestId);
|
||||||
|
break;
|
||||||
|
case RequestTypes.TvShow:
|
||||||
|
result = await this.voteService.upvoteTv(vm.requestId);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(result.isError) {
|
||||||
|
this.notificationSerivce.error(result.errorMessage);
|
||||||
|
} else {
|
||||||
|
this.notificationSerivce.success("Voted!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async downvote(vm: IVoteViewModel) {
|
||||||
|
let result: IVoteEngineResult = {errorMessage:"", isError: false, message:"",result:false};
|
||||||
|
switch(vm.requestType) {
|
||||||
|
case RequestTypes.Album:
|
||||||
|
result = await this.voteService.downvoteAlbum(vm.requestId);
|
||||||
|
break;
|
||||||
|
case RequestTypes.Movie:
|
||||||
|
result = await this.voteService.downvoteMovie(vm.requestId);
|
||||||
|
break;
|
||||||
|
case RequestTypes.TvShow:
|
||||||
|
result = await this.voteService.downvoteTv(vm.requestId);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(result.isError) {
|
||||||
|
this.notificationSerivce.error(result.errorMessage);
|
||||||
|
} else {
|
||||||
|
this.notificationSerivce.success("Voted!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
41
src/Ombi/ClientApp/app/vote/vote.module.ts
Normal file
41
src/Ombi/ClientApp/app/vote/vote.module.ts
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
import { NgModule } from "@angular/core";
|
||||||
|
import { RouterModule, Routes } from "@angular/router";
|
||||||
|
|
||||||
|
import { NgbModule } from "@ng-bootstrap/ng-bootstrap";
|
||||||
|
import { OrderModule } from "ngx-order-pipe";
|
||||||
|
import { OverlayPanelModule, SharedModule, TabViewModule } from "primeng/primeng";
|
||||||
|
|
||||||
|
import { VoteService } from "../services";
|
||||||
|
|
||||||
|
import { AuthGuard } from "../auth/auth.guard";
|
||||||
|
|
||||||
|
import { SharedModule as OmbiShared } from "../shared/shared.module";
|
||||||
|
|
||||||
|
import { VoteComponent } from "./vote.component";
|
||||||
|
|
||||||
|
const routes: Routes = [
|
||||||
|
{ path: "", component: VoteComponent, canActivate: [AuthGuard] },
|
||||||
|
];
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [
|
||||||
|
RouterModule.forChild(routes),
|
||||||
|
NgbModule.forRoot(),
|
||||||
|
SharedModule,
|
||||||
|
OrderModule,
|
||||||
|
OmbiShared,
|
||||||
|
TabViewModule,
|
||||||
|
OverlayPanelModule,
|
||||||
|
],
|
||||||
|
declarations: [
|
||||||
|
VoteComponent,
|
||||||
|
],
|
||||||
|
exports: [
|
||||||
|
RouterModule,
|
||||||
|
],
|
||||||
|
providers: [
|
||||||
|
VoteService,
|
||||||
|
],
|
||||||
|
|
||||||
|
})
|
||||||
|
export class VoteModule { }
|
|
@ -1007,5 +1007,4 @@ a > h4:hover {
|
||||||
|
|
||||||
.album-cover {
|
.album-cover {
|
||||||
width:300px;
|
width:300px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Mvc;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Ombi.Core.Engine;
|
using Ombi.Core.Engine;
|
||||||
|
using Ombi.Core.Models;
|
||||||
using Ombi.Core.Models.UI;
|
using Ombi.Core.Models.UI;
|
||||||
using Ombi.Store.Entities;
|
using Ombi.Store.Entities;
|
||||||
|
|
||||||
|
@ -21,12 +22,69 @@ namespace Ombi.Controllers
|
||||||
|
|
||||||
private readonly IVoteEngine _engine;
|
private readonly IVoteEngine _engine;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the viewmodel to render on the UI
|
||||||
|
/// </summary>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public Task<List<VoteViewModel>> GetView()
|
public Task<List<VoteViewModel>> GetView()
|
||||||
{
|
{
|
||||||
return _engine.GetMovieViewModel();
|
return _engine.GetMovieViewModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Upvotes a movie
|
||||||
|
/// </summary>
|
||||||
|
[HttpPost("up/movie/{requestId:int}")]
|
||||||
|
public Task<VoteEngineResult> UpvoteMovie(int requestId)
|
||||||
|
{
|
||||||
|
return _engine.UpVote(requestId, RequestType.Movie);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Upvotes a tv show
|
||||||
|
/// </summary>
|
||||||
|
[HttpPost("up/tv/{requestId:int}")]
|
||||||
|
public Task<VoteEngineResult> UpvoteTv(int requestId)
|
||||||
|
{
|
||||||
|
return _engine.UpVote(requestId, RequestType.TvShow);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Upvotes a album
|
||||||
|
/// </summary>
|
||||||
|
[HttpPost("up/album/{requestId:int}")]
|
||||||
|
public Task<VoteEngineResult> UpvoteAlbum(int requestId)
|
||||||
|
{
|
||||||
|
return _engine.UpVote(requestId, RequestType.Album);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Downvotes a movie
|
||||||
|
/// </summary>
|
||||||
|
[HttpPost("down/movie/{requestId:int}")]
|
||||||
|
public Task<VoteEngineResult> DownvoteMovie(int requestId)
|
||||||
|
{
|
||||||
|
return _engine.DownVote(requestId, RequestType.Movie);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Downvotes a tv show
|
||||||
|
/// </summary>
|
||||||
|
[HttpPost("down/tv/{requestId:int}")]
|
||||||
|
public Task<VoteEngineResult> DownvoteTv(int requestId)
|
||||||
|
{
|
||||||
|
return _engine.DownVote(requestId, RequestType.TvShow);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Downvotes a album
|
||||||
|
/// </summary>
|
||||||
|
[HttpPost("down/album/{requestId:int}")]
|
||||||
|
public Task<VoteEngineResult> DownvoteAlbum(int requestId)
|
||||||
|
{
|
||||||
|
return _engine.DownVote(requestId, RequestType.Album);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get's all the votes for the request id
|
/// Get's all the votes for the request id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue