|
|
@ -1,8 +1,8 @@
|
|
|
|
import { Component, OnInit } from "@angular/core";
|
|
|
|
import { Component, OnInit } from "@angular/core";
|
|
|
|
|
|
|
|
|
|
|
|
import { ICheckbox, IUserManagementSettings } from "../../interfaces";
|
|
|
|
import { ICheckbox, IUserManagementSettings } from "../../interfaces";
|
|
|
|
import { IPlexFriends } from "../../interfaces/IPlex";
|
|
|
|
import { IUsersModel } from "../../interfaces";
|
|
|
|
import { IdentityService, JobService, NotificationService, PlexService, SettingsService } from "../../services";
|
|
|
|
import { EmbyService, IdentityService, JobService, NotificationService, PlexService, SettingsService } from "../../services";
|
|
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
@Component({
|
|
|
|
templateUrl: "./usermanagement.component.html",
|
|
|
|
templateUrl: "./usermanagement.component.html",
|
|
|
@ -14,16 +14,20 @@ export class UserManagementComponent implements OnInit {
|
|
|
|
public settings: IUserManagementSettings;
|
|
|
|
public settings: IUserManagementSettings;
|
|
|
|
public claims: ICheckbox[];
|
|
|
|
public claims: ICheckbox[];
|
|
|
|
|
|
|
|
|
|
|
|
public plexUsers: IPlexFriends[];
|
|
|
|
public plexUsers: IUsersModel[];
|
|
|
|
public filteredPlexUsers: IPlexFriends[];
|
|
|
|
public filteredPlexUsers: IUsersModel[];
|
|
|
|
public bannedPlexUsers: IPlexFriends[] = [];
|
|
|
|
public bannedPlexUsers: IUsersModel[] = [];
|
|
|
|
|
|
|
|
|
|
|
|
constructor(private settingsService: SettingsService,
|
|
|
|
public embyUsers: IUsersModel[];
|
|
|
|
private notificationService: NotificationService,
|
|
|
|
public filteredEmbyUsers: IUsersModel[];
|
|
|
|
private identityService: IdentityService,
|
|
|
|
public bannedEmbyUsers: IUsersModel[] = [];
|
|
|
|
private plexService: PlexService,
|
|
|
|
|
|
|
|
private jobService: JobService) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
constructor(private readonly settingsService: SettingsService,
|
|
|
|
|
|
|
|
private readonly notificationService: NotificationService,
|
|
|
|
|
|
|
|
private readonly identityService: IdentityService,
|
|
|
|
|
|
|
|
private readonly plexService: PlexService,
|
|
|
|
|
|
|
|
private readonly jobService: JobService,
|
|
|
|
|
|
|
|
private readonly embyService: EmbyService) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public ngOnInit(): void {
|
|
|
|
public ngOnInit(): void {
|
|
|
@ -42,6 +46,18 @@ export class UserManagementComponent implements OnInit {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.embyService.getUsers().subscribe(f => {
|
|
|
|
|
|
|
|
this.embyUsers = f;
|
|
|
|
|
|
|
|
this.embyUsers.forEach((emby) => {
|
|
|
|
|
|
|
|
const isExcluded = this.settings.bannedPlexUserIds.some((val) => {
|
|
|
|
|
|
|
|
return emby.id === val;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
if (isExcluded) {
|
|
|
|
|
|
|
|
this.bannedEmbyUsers.push(emby);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
this.identityService.getAllAvailableClaims().subscribe(c => {
|
|
|
|
this.identityService.getAllAvailableClaims().subscribe(c => {
|
|
|
|
|
|
|
|
|
|
|
|
this.claims = c;
|
|
|
|
this.claims = c;
|
|
|
@ -65,6 +81,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.settings.bannedEmbyUserIds = this.bannedEmbyUsers.map((u) => u.id);
|
|
|
|
|
|
|
|
|
|
|
|
this.settingsService.saveUserManagementSettings(this.settings).subscribe(x => {
|
|
|
|
this.settingsService.saveUserManagementSettings(this.settings).subscribe(x => {
|
|
|
|
if (x === true) {
|
|
|
|
if (x === true) {
|
|
|
@ -75,15 +92,19 @@ export class UserManagementComponent implements OnInit {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public filterUserList(event: any) {
|
|
|
|
public filterPlexList(event: any) {
|
|
|
|
this.filteredPlexUsers = this.filter(event.query, this.plexUsers);
|
|
|
|
this.filteredPlexUsers = this.filter(event.query, this.plexUsers);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public filterEmbyList(event: any) {
|
|
|
|
|
|
|
|
this.filteredEmbyUsers = this.filter(event.query, this.embyUsers);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public runImporter(): void {
|
|
|
|
public runImporter(): void {
|
|
|
|
this.jobService.runPlexImporter().subscribe();
|
|
|
|
this.jobService.runPlexImporter().subscribe();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private filter(query: string, users: IPlexFriends[]): IPlexFriends[] {
|
|
|
|
private filter(query: string, users: IUsersModel[]): IUsersModel[] {
|
|
|
|
return users.filter((val) => {
|
|
|
|
return users.filter((val) => {
|
|
|
|
return val.username.toLowerCase().indexOf(query.toLowerCase()) === 0;
|
|
|
|
return val.username.toLowerCase().indexOf(query.toLowerCase()) === 0;
|
|
|
|
});
|
|
|
|
});
|
|
|
|