Did the vote settings and frontend !wip

pull/2556/head
TidusJar 6 years ago
parent a93fdc66ac
commit 64a741a60d

@ -54,6 +54,12 @@
<i class="fa fa-user"></i> {{ 'NavigationBar.UserManagement' | translate }}</a>
</li>
</ul>
<ul *ngIf="voteEnabled" class="nav navbar-nav">
<li id="Vote" [routerLinkActive]="['active']">
<a [routerLink]="['/vote']">
<i class="fa fa-thumbs-o-up"></i> {{ 'NavigationBar.Vote' | translate }}</a>
</li>
</ul>
<ul *ngIf="hasRole('Admin') || hasRole('PowerUser')" class="nav navbar-nav donation">
<li>

@ -23,6 +23,7 @@ export class AppComponent implements OnInit {
public updateAvailable: boolean;
public currentUrl: string;
public userAccessToken: string;
public voteEnabled = false;
private checkedForUpdate: boolean;
@ -54,6 +55,7 @@ export class AppComponent implements OnInit {
this.settingsService.getCustomization().subscribe(x => this.customizationSettings = x);
this.settingsService.issueEnabled().subscribe(x => this.issuesEnabled = x);
this.settingsService.voteEnabled().subscribe(x => this.voteEnabled =x);
this.router.events.subscribe((event: NavigationStart) => {
this.currentUrl = event.url;

@ -231,3 +231,10 @@ export interface IJobSettingsViewModel {
result: boolean;
message: string;
}
export interface IVoteSettings extends ISettings {
enabled: boolean;
movieVoteMax: number;
musicVoteMax: number;
tvShowVoteMax: number;
}

@ -34,6 +34,7 @@ import {
IThemes,
IUpdateSettings,
IUserManagementSettings,
IVoteSettings,
} from "../interfaces";
import { ServiceHelpers } from "./service.helpers";
@ -284,6 +285,18 @@ export class SettingsService extends ServiceHelpers {
.post<boolean>(`${this.url}/issues`, JSON.stringify(settings), {headers: this.headers});
}
public getVoteSettings(): Observable<IVoteSettings> {
return this.http.get<IVoteSettings>(`${this.url}/vote`, {headers: this.headers});
}
public voteEnabled(): Observable<boolean> {
return this.http.get<boolean>(`${this.url}/voteenabled`, {headers: this.headers});
}
public saveVoteSettings(settings: IVoteSettings): Observable<boolean> {
return this.http.post<boolean>(`${this.url}/vote`, JSON.stringify(settings), {headers: this.headers});
}
public getNewsletterSettings(): Observable<INewsletterNotificationSettings> {
return this.http.get<INewsletterNotificationSettings>(`${this.url}/notifications/newsletter`, {headers: this.headers});
}

@ -41,6 +41,7 @@ import { SickRageComponent } from "./sickrage/sickrage.component";
import { SonarrComponent } from "./sonarr/sonarr.component";
import { UpdateComponent } from "./update/update.component";
import { UserManagementComponent } from "./usermanagement/usermanagement.component";
import { VoteComponent } from "./vote/vote.component";
import { WikiComponent } from "./wiki.component";
import { SettingsMenuComponent } from "./settingsmenu.component";
@ -75,6 +76,7 @@ const routes: Routes = [
{ path: "MassEmail", component: MassEmailComponent, canActivate: [AuthGuard] },
{ path: "Newsletter", component: NewsletterComponent, canActivate: [AuthGuard] },
{ path: "Lidarr", component: LidarrComponent, canActivate: [AuthGuard] },
{ path: "Vote", component: VoteComponent, canActivate: [AuthGuard] },
];
@NgModule({
@ -127,6 +129,7 @@ const routes: Routes = [
MassEmailComponent,
NewsletterComponent,
LidarrComponent,
VoteComponent,
],
exports: [
RouterModule,

@ -12,6 +12,7 @@
<li [routerLinkActive]="['active']"><a [routerLink]="['/Settings/Issues']">Issues</a></li>
<li [routerLinkActive]="['active']"><a [routerLink]="['/Settings/UserManagement']">User Importer</a></li>
<li [routerLinkActive]="['active']"><a [routerLink]="['/Settings/Authentication']">Authentication</a></li>
<li [routerLinkActive]="['active']"><a [routerLink]="['/Settings/Vote']">Vote</a></li>
</ul>
</li>

@ -0,0 +1,50 @@
<settings-menu></settings-menu>
<wiki [url]="'https://github.com/tidusjar/Ombi/wiki/Vote-Settings'"></wiki>
<fieldset>
<legend>Vote</legend>
<form *ngIf="form" novalidate [formGroup]="form" (ngSubmit)="onSubmit(form)" style="padding-top:5%;">
<div class="col-md-12">
<div class="form-group">
<div class="checkbox">
<input type="checkbox" id="enable" formControlName="enabled" ng-checked="form.enabled">
<label for="enable">Enable</label>
</div>
</div>
<p>Vote limits tell Ombi how many votes the request needs before approval.</p>
<p>e.g. If the Movie vote limit is 10, it requires 10 Upvotes from 10 different users before it will be approved.</p>
<div class="form-group">
<label for="movieVoteMax" class="control-label">Movie Vote Limit</label>
<input type="number" class="form-control form-control-custom form-small" min="1" id="movieVoteMax" [ngClass]="{'form-error': form.get('movieVoteMax').hasError('min')}"
formControlName="movieVoteMax" ng-checked="form.movieVoteMax">
<small *ngIf="form.get('movieVoteMax').hasError('min')" class="error-text">The limit needs to be greater than or equal to 1</small>
</div>
<div class="form-group">
<label for="musicVoteMax" class="control-label">Music Vote Limit</label>
<input type="number" class="form-control form-control-custom form-small" min="1" id="musicVoteMax" [ngClass]="{'form-error': form.get('movieVoteMax').hasError('min')}"
formControlName="musicVoteMax" ng-checked="form.musicVoteMax">
<small *ngIf="form.get('movieVoteMax').hasError('min')" class="error-text">The limit needs to be greater than or equal to 1</small>
</div>
<div class="form-group">
<label for="tvShowVoteMax" class="control-label">TV Show Vote Limit</label>
<input type="number" class="form-control form-control-custom form-small" min="1" id="tvShowVoteMax" [ngClass]="{'form-error': form.get('movieVoteMax').hasError('min')}"
formControlName="tvShowVoteMax" ng-checked="form.tvShowVoteMax">
<small *ngIf="form.get('movieVoteMax').hasError('min')" class="error-text">The limit needs to be greater than or equal to 1</small>
</div>
<div class="form-group">
<div>
<button type="submit" [disabled]="form.invalid" class="btn btn-primary-outline ">Submit</button>
</div>
</div>
</div>
</form>
</fieldset>

@ -0,0 +1,44 @@
import { Component, OnInit } from "@angular/core";
import { FormBuilder, FormGroup, Validators } from "@angular/forms";
import { NotificationService, SettingsService } from "../../services";
@Component({
templateUrl: "./vote.component.html",
})
export class VoteComponent implements OnInit {
public form: FormGroup;
constructor(private settingsService: SettingsService,
private readonly fb: FormBuilder,
private notificationService: NotificationService) { }
public ngOnInit() {
this.settingsService.getVoteSettings().subscribe(x => {
this.form = this.fb.group({
enabled: [x.enabled],
movieVoteMax: [x.movieVoteMax, Validators.min(1)],
musicVoteMax: [x.musicVoteMax, Validators.min(1)],
tvShowVoteMax: [x.tvShowVoteMax, Validators.min(1)],
});
});
}
public onSubmit(form: FormGroup) {
if (form.invalid) {
this.notificationService.error("Please check your entered values");
return;
}
const settings = form.value;
this.settingsService.saveVoteSettings(settings).subscribe(x => {
if (x) {
this.notificationService.success("Successfully saved the Vote settings");
} else {
this.notificationService.success("There was an error when saving the Vote settings");
}
});
}
}

@ -599,12 +599,11 @@ namespace Ombi.Controllers
/// <summary>
/// Save the Issues settings.
/// Save the Vote settings.
/// </summary>
/// <param name="settings">The settings.</param>
/// <returns></returns>
[HttpPost("Issues")]
[AllowAnonymous]
public async Task<bool> IssueSettings([FromBody]IssueSettings settings)
{
return await Save(settings);
@ -629,6 +628,35 @@ namespace Ombi.Controllers
return issues.Enabled;
}
/// <summary>
/// Save the Vote settings.
/// </summary>
/// <param name="settings">The settings.</param>
/// <returns></returns>
[HttpPost("vote")]
public async Task<bool> VoteSettings([FromBody]VoteSettings settings)
{
return await Save(settings);
}
/// <summary>
/// Gets the Vote Settings.
/// </summary>
/// <returns></returns>
[HttpGet("vote")]
public async Task<VoteSettings> VoteSettings()
{
return await Get<VoteSettings>();
}
[AllowAnonymous]
[HttpGet("voteenabled")]
public async Task<bool> VoteEnabled()
{
var vote = await Get<VoteSettings>();
return vote.Enabled;
}
/// <summary>
/// Saves the email notification settings.
/// </summary>

@ -172,8 +172,6 @@ namespace Ombi
{
// Generate a API Key
settings.ApiKey = Guid.NewGuid().ToString("N");
var userManager = app.ApplicationServices.GetService<OmbiUserManager>();
userManager.CreateAsync(new OmbiUser {UserName = "API User", UserType = UserType.LocalUser}).Wait();
ombiService.SaveSettings(settings);
}

@ -50,6 +50,7 @@
"Requests": "Requests",
"UserManagement": "User Management",
"Issues":"Issues",
"Vote":"Vote",
"Donate": "Donate!",
"DonateLibraryMaintainer": "Donate to Library Maintainer",
"DonateTooltip":

Loading…
Cancel
Save