mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-19 21:03:17 -07:00
!wip #1456
This commit is contained in:
parent
f986e8d132
commit
53a717aa8a
10 changed files with 131 additions and 12 deletions
|
@ -34,7 +34,7 @@ namespace Ombi.Schedule.Jobs.Plex
|
|||
public async Task Start()
|
||||
{
|
||||
var userManagementSettings = await _userManagementSettings.GetSettingsAsync();
|
||||
if (!userManagementSettings.ImportMediaServerUsers)
|
||||
if (!userManagementSettings.ImportPlexUsers)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,8 @@ namespace Ombi.Settings.Settings.Models
|
|||
{
|
||||
public class UserManagementSettings : Settings
|
||||
{
|
||||
public bool ImportMediaServerUsers { get; set; }
|
||||
public bool ImportPlexUsers { get; set; }
|
||||
public bool ImportEmbyUsers { get; set; }
|
||||
public List<string> DefaultRoles { get; set; }
|
||||
}
|
||||
}
|
|
@ -16,3 +16,8 @@ export interface IQuality {
|
|||
id: number;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface ICheckbox {
|
||||
value: string;
|
||||
enabled: boolean;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { ISettings } from "./ICommon";
|
||||
import { ICheckbox } from "./index";
|
||||
|
||||
export interface IExternalSettings extends ISettings {
|
||||
ssl: boolean;
|
||||
|
@ -102,6 +103,12 @@ export interface IAuthenticationSettings extends ISettings {
|
|||
requireUppercase: boolean;
|
||||
}
|
||||
|
||||
export interface IUserManagementSettings extends ISettings {
|
||||
importPlexUsers: boolean;
|
||||
importEmbyUsers: boolean;
|
||||
defaultClaims: ICheckbox[];
|
||||
}
|
||||
|
||||
export interface IAbout {
|
||||
version: string;
|
||||
branch: string;
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
export interface IUser {
|
||||
import { ICheckbox } from "./index";
|
||||
|
||||
export interface IUser {
|
||||
id: string;
|
||||
username: string;
|
||||
alias: string;
|
||||
|
@ -17,11 +19,6 @@ export enum UserType {
|
|||
EmbyUser = 3,
|
||||
}
|
||||
|
||||
export interface ICheckbox {
|
||||
value: string;
|
||||
enabled: boolean;
|
||||
}
|
||||
|
||||
export interface IIdentityResult {
|
||||
errors: string[];
|
||||
successful: boolean;
|
||||
|
|
|
@ -20,6 +20,7 @@ import {
|
|||
ISlackNotificationSettings,
|
||||
ISonarrSettings,
|
||||
IUpdateSettings,
|
||||
IUserManagementSettings,
|
||||
} from "../interfaces";
|
||||
|
||||
import { ServiceAuthHelpers } from "./service.helpers";
|
||||
|
@ -182,4 +183,14 @@ export class SettingsService extends ServiceAuthHelpers {
|
|||
.post(`${this.url}/update`, JSON.stringify(settings), { headers: this.headers })
|
||||
.map(this.extractData).catch(this.handleError);
|
||||
}
|
||||
|
||||
public getUserManagementSettings(): Observable<IUserManagementSettings> {
|
||||
return this.httpAuth.get(`${this.url}/UserManagement`).map(this.extractData).catch(this.handleError);
|
||||
}
|
||||
|
||||
public saveUserManagementSettings(settings: IUserManagementSettings): Observable<boolean> {
|
||||
return this.httpAuth
|
||||
.post(`${this.url}/UserManagement`, JSON.stringify(settings), { headers: this.headers })
|
||||
.map(this.extractData).catch(this.handleError);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +1,43 @@
|
|||
<settings-menu></settings-menu>
|
||||
<fieldset>
|
||||
<legend>User Management Settings</legend>
|
||||
|
||||
<div class="col-md-6">
|
||||
<div *ngIf="plexEnabled">
|
||||
|
||||
<div class="form-group">
|
||||
<div class="checkbox">
|
||||
<input type="checkbox" id="importPlex" formControlName="importPlexUsers">
|
||||
<label for="importPlexUsers">Import Plex Users</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div *ngIf="embyEnabled">
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<div class="checkbox">
|
||||
<input type="checkbox" id="importEmbyUsers" formControlName="importEmbyUsers">
|
||||
<label for="importEmbyUsers">Import Emby Users</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6" >
|
||||
<h4>Default Roles</h4>
|
||||
|
||||
<div *ngFor="let c of claims">
|
||||
<div class="form-group">
|
||||
<div class="checkbox">
|
||||
<input type="checkbox" [(ngModel)]="c.enabled" [value]="c.value" id="create{{c.value}}" [attr.name]="'create' + c.value" ng-checked="c.enabled">
|
||||
<label for="create{{c.value}}">{{c.value}}</label>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</fieldset>
|
|
@ -1,6 +1,42 @@
|
|||
import { Component } from "@angular/core";
|
||||
import { Component, OnInit } from "@angular/core";
|
||||
|
||||
import { ICheckbox, IUserManagementSettings } from "../../interfaces";
|
||||
import { IdentityService, SettingsService } from "../../services";
|
||||
|
||||
@Component({
|
||||
templateUrl: "./usermanagement.component.html",
|
||||
})
|
||||
export class UserManagementComponent { }
|
||||
export class UserManagementComponent implements OnInit {
|
||||
|
||||
public plexEnabled: boolean;
|
||||
public embyEnabled: boolean;
|
||||
public settings: IUserManagementSettings;
|
||||
public claims: ICheckbox[];
|
||||
|
||||
constructor(private settingsService: SettingsService,
|
||||
//private notificationService: NotificationService,
|
||||
private identityService: IdentityService) {
|
||||
|
||||
}
|
||||
|
||||
public ngOnInit(): void {
|
||||
this.settingsService.getUserManagementSettings().subscribe(x => {
|
||||
this.settings = x;
|
||||
this.identityService.getAllAvailableClaims().subscribe(c => {
|
||||
|
||||
this.claims = c;
|
||||
this.claims.forEach((claim) => {
|
||||
if (this.settings.defaultClaims) {
|
||||
const hasClaim = this.settings.defaultClaims.some((item) => {
|
||||
return item.value === claim.value && item.enabled;
|
||||
});
|
||||
claim.enabled = hasClaim;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
this.settingsService.getPlex().subscribe(x => this.plexEnabled = x.enable);
|
||||
this.settingsService.getEmby().subscribe(x => this.embyEnabled = x.enable);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
import { Router } from "@angular/router";
|
||||
|
||||
import { ICheckbox, IUser, UserType } from "../interfaces";
|
||||
import { IdentityService } from "../services";
|
||||
import { NotificationService } from "../services";
|
||||
import { IdentityService, NotificationService } from "../services";
|
||||
|
||||
@Component({
|
||||
templateUrl: "./usermanagement-add.component.html",
|
||||
|
|
|
@ -306,6 +306,27 @@ namespace Ombi.Controllers
|
|||
return await Save(settings);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the UserManagement Settings.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("UserManagement")]
|
||||
public async Task<UserManagementSettings> UserManagementSettings()
|
||||
{
|
||||
return await Get<UserManagementSettings>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Save the UserManagement settings.
|
||||
/// </summary>
|
||||
/// <param name="settings">The settings.</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("UserManagement")]
|
||||
public async Task<bool> UserManagementSettings([FromBody]UserManagementSettings settings)
|
||||
{
|
||||
return await Save(settings);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Update Settings.
|
||||
/// </summary>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue