mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-21 05:43:19 -07:00
#1519 !wip fixed the user management settings
This commit is contained in:
parent
97d63f13d3
commit
fab5dd413a
7 changed files with 37 additions and 14 deletions
|
@ -9,4 +9,4 @@ export * from "./search.service";
|
||||||
export * from "./service.helpers";
|
export * from "./service.helpers";
|
||||||
export * from "./settings.service";
|
export * from "./settings.service";
|
||||||
export * from "./status.service";
|
export * from "./status.service";
|
||||||
export * from "./update.service";
|
export * from "./job.service";
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { Observable } from "rxjs/Rx";
|
||||||
import { ServiceAuthHelpers } from "./service.helpers";
|
import { ServiceAuthHelpers } from "./service.helpers";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class UpdateService extends ServiceAuthHelpers {
|
export class JobService extends ServiceAuthHelpers {
|
||||||
constructor(http: AuthHttp) {
|
constructor(http: AuthHttp) {
|
||||||
super(http, "/api/v1/Job/");
|
super(http, "/api/v1/Job/");
|
||||||
}
|
}
|
||||||
|
@ -16,4 +16,8 @@ export class UpdateService extends ServiceAuthHelpers {
|
||||||
public checkForNewUpdate(): Observable<boolean> {
|
public checkForNewUpdate(): Observable<boolean> {
|
||||||
return this.http.get(`${this.url}update/`).map(this.extractData);
|
return this.http.get(`${this.url}update/`).map(this.extractData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public runPlexImporter(): Observable<boolean> {
|
||||||
|
return this.http.post(`${this.url}plexUserImporter/`, { headers: this.headers }).map(this.extractData);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -8,7 +8,7 @@ import { ClipboardModule } from "ngx-clipboard/dist";
|
||||||
import { AuthGuard } from "../auth/auth.guard";
|
import { AuthGuard } from "../auth/auth.guard";
|
||||||
import { AuthModule } from "../auth/auth.module";
|
import { AuthModule } from "../auth/auth.module";
|
||||||
import { AuthService } from "../auth/auth.service";
|
import { AuthService } from "../auth/auth.service";
|
||||||
import { RadarrService, SonarrService, TesterService, UpdateService, ValidationService } from "../services";
|
import { JobService, RadarrService, SonarrService, TesterService, ValidationService } from "../services";
|
||||||
|
|
||||||
import { PipeModule } from "../pipes/pipe.module";
|
import { PipeModule } from "../pipes/pipe.module";
|
||||||
import { AboutComponent } from "./about/about.component";
|
import { AboutComponent } from "./about/about.component";
|
||||||
|
@ -100,7 +100,7 @@ const routes: Routes = [
|
||||||
AuthGuard,
|
AuthGuard,
|
||||||
ValidationService,
|
ValidationService,
|
||||||
TesterService,
|
TesterService,
|
||||||
UpdateService,
|
JobService,
|
||||||
],
|
],
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
import { FormBuilder, FormGroup } from "@angular/forms";
|
import { FormBuilder, FormGroup } from "@angular/forms";
|
||||||
|
|
||||||
import { NotificationService } from "../../services";
|
import { NotificationService } from "../../services";
|
||||||
import { SettingsService, UpdateService } from "../../services";
|
import { JobService, SettingsService } from "../../services";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
templateUrl: "./update.component.html",
|
templateUrl: "./update.component.html",
|
||||||
|
@ -14,7 +14,7 @@ export class UpdateComponent implements OnInit {
|
||||||
|
|
||||||
constructor(private settingsService: SettingsService,
|
constructor(private settingsService: SettingsService,
|
||||||
private notificationService: NotificationService,
|
private notificationService: NotificationService,
|
||||||
private updateService: UpdateService,
|
private updateService: JobService,
|
||||||
private fb: FormBuilder) { }
|
private fb: FormBuilder) { }
|
||||||
|
|
||||||
public ngOnInit() {
|
public ngOnInit() {
|
||||||
|
|
|
@ -7,14 +7,14 @@
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="checkbox">
|
<div class="checkbox">
|
||||||
<input type="checkbox" id="importPlex" [(ngModel)]="importPlexUsers">
|
<input type="checkbox" id="importPlex" [(ngModel)]="settings.importPlexUsers">
|
||||||
<label for="importPlexUsers">Import Plex Users</label>
|
<label for="importPlex">Import Plex Users</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="plexUsers">
|
<div *ngIf="plexUsers">
|
||||||
<p>Plex Users exclude from Import</p>
|
<p>Plex Users exclude from Import</p>
|
||||||
|
|
||||||
<p-autoComplete [(ngModel)]="bannedPlexUsers" [suggestions]="filteredPlexUsers" [multiple]="true" field="username" (completeMethod)="filterCountryMultiple($event)"></p-autoComplete>
|
<p-autoComplete [(ngModel)]="bannedPlexUsers" [suggestions]="filteredPlexUsers" [multiple]="true" field="username" (completeMethod)="filterUserList($event)"></p-autoComplete>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="checkbox">
|
<div class="checkbox">
|
||||||
<input type="checkbox" id="importEmbyUsers" [(ngModel)]="importEmbyUsers">
|
<input type="checkbox" id="importEmbyUsers" [(ngModel)]="settings.importPlexUsers">
|
||||||
<label for="importEmbyUsers">Import Emby Users</label>
|
<label for="importEmbyUsers">Import Emby Users</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -46,6 +46,9 @@
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<button type="submit" id="save" (click)="submit()" class="btn btn-primary-outline">Submit</button>
|
<button type="submit" id="save" (click)="submit()" class="btn btn-primary-outline">Submit</button>
|
||||||
|
<button type="button" (click)="runImporter()" class="btn btn-info-outline">Run Importer</button>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
import { ICheckbox, IUserManagementSettings } from "../../interfaces";
|
import { ICheckbox, IUserManagementSettings } from "../../interfaces";
|
||||||
import { IPlexFriends } from "../../interfaces/IPlex";
|
import { IPlexFriends } from "../../interfaces/IPlex";
|
||||||
import { IdentityService, NotificationService, PlexService, SettingsService } from "../../services";
|
import { IdentityService, JobService, NotificationService, PlexService, SettingsService } from "../../services";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
templateUrl: "./usermanagement.component.html",
|
templateUrl: "./usermanagement.component.html",
|
||||||
|
@ -21,7 +21,8 @@ export class UserManagementComponent implements OnInit {
|
||||||
constructor(private settingsService: SettingsService,
|
constructor(private settingsService: SettingsService,
|
||||||
private notificationService: NotificationService,
|
private notificationService: NotificationService,
|
||||||
private identityService: IdentityService,
|
private identityService: IdentityService,
|
||||||
private plexService: PlexService) {
|
private plexService: PlexService,
|
||||||
|
private jobService: JobService) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,6 +65,7 @@ export class UserManagementComponent implements OnInit {
|
||||||
});
|
});
|
||||||
this.settings.defaultRoles = enabledClaims.map((claim) => claim.value);
|
this.settings.defaultRoles = enabledClaims.map((claim) => claim.value);
|
||||||
this.settings.bannedPlexUserIds = this.bannedPlexUsers.map((u) => u.id);
|
this.settings.bannedPlexUserIds = this.bannedPlexUsers.map((u) => u.id);
|
||||||
|
|
||||||
this.settingsService.saveUserManagementSettings(this.settings).subscribe(x => {
|
this.settingsService.saveUserManagementSettings(this.settings).subscribe(x => {
|
||||||
if (x === true) {
|
if (x === true) {
|
||||||
this.notificationService.success("Saved", "Successfully saved the User Management Settings");
|
this.notificationService.success("Saved", "Successfully saved the User Management Settings");
|
||||||
|
@ -73,10 +75,14 @@ export class UserManagementComponent implements OnInit {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public filterCountryMultiple(event: any) {
|
public filterUserList(event: any) {
|
||||||
this.filteredPlexUsers = this.filter(event.query, this.plexUsers);
|
this.filteredPlexUsers = this.filter(event.query, this.plexUsers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public runImporter(): void {
|
||||||
|
this.jobService.runPlexImporter().subscribe();
|
||||||
|
}
|
||||||
|
|
||||||
private filter(query: string, users: IPlexFriends[]): IPlexFriends[] {
|
private filter(query: string, users: IPlexFriends[]): IPlexFriends[] {
|
||||||
return users.filter((val) => {
|
return users.filter((val) => {
|
||||||
return val.username.toLowerCase().indexOf(query.toLowerCase()) === 0;
|
return val.username.toLowerCase().indexOf(query.toLowerCase()) === 0;
|
||||||
|
|
|
@ -3,6 +3,7 @@ using Hangfire;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Ombi.Api.Service;
|
using Ombi.Api.Service;
|
||||||
using Ombi.Attributes;
|
using Ombi.Attributes;
|
||||||
|
using Ombi.Schedule.Jobs.Plex;
|
||||||
using Ombi.Schedule.Ombi;
|
using Ombi.Schedule.Ombi;
|
||||||
|
|
||||||
namespace Ombi.Controllers
|
namespace Ombi.Controllers
|
||||||
|
@ -12,12 +13,14 @@ namespace Ombi.Controllers
|
||||||
[Produces("application/json")]
|
[Produces("application/json")]
|
||||||
public class JobController : Controller
|
public class JobController : Controller
|
||||||
{
|
{
|
||||||
public JobController(IOmbiAutomaticUpdater updater)
|
public JobController(IOmbiAutomaticUpdater updater, IPlexUserImporter userImporter)
|
||||||
{
|
{
|
||||||
_updater = updater;
|
_updater = updater;
|
||||||
|
_plexUserImporter = userImporter;
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly IOmbiAutomaticUpdater _updater;
|
private readonly IOmbiAutomaticUpdater _updater;
|
||||||
|
private readonly IPlexUserImporter _plexUserImporter;
|
||||||
|
|
||||||
[HttpPost("update")]
|
[HttpPost("update")]
|
||||||
public bool ForceUpdate()
|
public bool ForceUpdate()
|
||||||
|
@ -36,5 +39,12 @@ namespace Ombi.Controllers
|
||||||
|
|
||||||
return updateAvailable;
|
return updateAvailable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost("plexuserimporter")]
|
||||||
|
public bool PlexUserImporter()
|
||||||
|
{
|
||||||
|
BackgroundJob.Enqueue(() => _plexUserImporter.Start());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue