|
|
@ -1,6 +1,6 @@
|
|
|
|
import { Component, OnInit } from "@angular/core";
|
|
|
|
import { Component, OnInit } from "@angular/core";
|
|
|
|
|
|
|
|
|
|
|
|
import { ICheckbox, ICustomizationSettings, IEmailNotificationSettings,IUser } from "../interfaces";
|
|
|
|
import { ICheckbox, ICustomizationSettings, IEmailNotificationSettings, IUser } from "../interfaces";
|
|
|
|
import { IdentityService, NotificationService, SettingsService } from "../services";
|
|
|
|
import { IdentityService, NotificationService, SettingsService } from "../services";
|
|
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
@Component({
|
|
|
@ -10,7 +10,7 @@ export class UserManagementComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
|
|
public users: IUser[];
|
|
|
|
public users: IUser[];
|
|
|
|
public checkAll = false;
|
|
|
|
public checkAll = false;
|
|
|
|
public emailSettings: IEmailNotificationSettings;
|
|
|
|
public emailSettings: IEmailNotificationSettings;
|
|
|
|
public customizationSettings: ICustomizationSettings;
|
|
|
|
public customizationSettings: ICustomizationSettings;
|
|
|
|
|
|
|
|
|
|
|
|
public order: string = "userName";
|
|
|
|
public order: string = "userName";
|
|
|
@ -21,9 +21,9 @@ export class UserManagementComponent implements OnInit {
|
|
|
|
public bulkMovieLimit?: number;
|
|
|
|
public bulkMovieLimit?: number;
|
|
|
|
public bulkEpisodeLimit?: number;
|
|
|
|
public bulkEpisodeLimit?: number;
|
|
|
|
|
|
|
|
|
|
|
|
constructor(private readonly identityService: IdentityService,
|
|
|
|
constructor(private identityService: IdentityService,
|
|
|
|
private readonly settingsService: SettingsService,
|
|
|
|
private settingsService: SettingsService,
|
|
|
|
private readonly notificationService: NotificationService) { }
|
|
|
|
private notificationService: NotificationService) { }
|
|
|
|
|
|
|
|
|
|
|
|
public ngOnInit() {
|
|
|
|
public ngOnInit() {
|
|
|
|
this.users = [];
|
|
|
|
this.users = [];
|
|
|
@ -37,7 +37,7 @@ export class UserManagementComponent implements OnInit {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public welcomeEmail(user: IUser) {
|
|
|
|
public welcomeEmail(user: IUser) {
|
|
|
|
if(!user.emailAddress) {
|
|
|
|
if (!user.emailAddress) {
|
|
|
|
this.notificationService.error("The user needs an email address.");
|
|
|
|
this.notificationService.error("The user needs an email address.");
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -45,13 +45,13 @@ export class UserManagementComponent implements OnInit {
|
|
|
|
this.notificationService.error("Email Notifications are not setup, cannot send welcome email");
|
|
|
|
this.notificationService.error("Email Notifications are not setup, cannot send welcome email");
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!this.emailSettings.notificationTemplates.some(x => {
|
|
|
|
if (!this.emailSettings.notificationTemplates.some(x => {
|
|
|
|
return x.enabled && x.notificationType === 8;
|
|
|
|
return x.enabled && x.notificationType === 8;
|
|
|
|
})) {
|
|
|
|
})) {
|
|
|
|
this.notificationService.error("The Welcome Email template is not enabled in the Email Setings");
|
|
|
|
this.notificationService.error("The Welcome Email template is not enabled in the Email Setings");
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.identityService.sendWelcomeEmail(user).subscribe();
|
|
|
|
this.identityService.sendWelcomeEmail(user).subscribe();
|
|
|
|
this.notificationService.success(`Sent a welcome email to ${user.emailAddress}`);
|
|
|
|
this.notificationService.success(`Sent a welcome email to ${user.emailAddress}`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -74,31 +74,31 @@ export class UserManagementComponent implements OnInit {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
this.users.forEach(x => {
|
|
|
|
this.users.forEach(x => {
|
|
|
|
if(!x.checked) {
|
|
|
|
if (!x.checked) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(anyRoles) {
|
|
|
|
if (anyRoles) {
|
|
|
|
x.claims = this.availableClaims;
|
|
|
|
x.claims = this.availableClaims;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(this.bulkEpisodeLimit) {
|
|
|
|
if (this.bulkEpisodeLimit) {
|
|
|
|
x.episodeRequestLimit = this.bulkEpisodeLimit;
|
|
|
|
x.episodeRequestLimit = this.bulkEpisodeLimit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(this.bulkMovieLimit) {
|
|
|
|
if (this.bulkMovieLimit) {
|
|
|
|
x.movieRequestLimit = this.bulkMovieLimit;
|
|
|
|
x.movieRequestLimit = this.bulkMovieLimit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.identityService.updateUser(x).subscribe(y => {
|
|
|
|
this.identityService.updateUser(x).subscribe(y => {
|
|
|
|
if(!y.successful) {
|
|
|
|
if (!y.successful) {
|
|
|
|
this.notificationService.error(`Could not update user ${x.userName}. Reason ${y.errors[0]}`);
|
|
|
|
this.notificationService.error(`Could not update user ${x.userName}. Reason ${y.errors[0]}`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
this.notificationService.success(`Updated users`);
|
|
|
|
this.notificationService.success(`Updated users`);
|
|
|
|
this.showBulkEdit = false;
|
|
|
|
this.showBulkEdit = false;
|
|
|
|
this.bulkMovieLimit = undefined;
|
|
|
|
this.bulkMovieLimit = undefined;
|
|
|
|
this.bulkEpisodeLimit = undefined;
|
|
|
|
this.bulkEpisodeLimit = undefined;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public setOrder(value: string, el: any) {
|
|
|
|
public setOrder(value: string, el: any) {
|
|
|
|
el = el.toElement || el.relatedTarget || el.target || el.srcElement;
|
|
|
|
el = el.toElement || el.relatedTarget || el.target || el.srcElement;
|
|
|
|
|
|
|
|
|
|
|
@ -115,7 +115,7 @@ export class UserManagementComponent implements OnInit {
|
|
|
|
previousFilter.className = "";
|
|
|
|
previousFilter.className = "";
|
|
|
|
el.className = "active";
|
|
|
|
el.className = "active";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.order = value;
|
|
|
|
this.order = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|