mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-14 02:26:55 -07:00
Added bulk editing (#1941)
This commit is contained in:
parent
f42b2938d2
commit
e2a4c4ec17
3 changed files with 77 additions and 2 deletions
|
@ -3,6 +3,7 @@
|
|||
|
||||
|
||||
<button type="button" class="btn btn-success-outline" [routerLink]="['/usermanagement/add']">Add User</button>
|
||||
<button type="button" style="float:right;" class="btn btn-primary-outline"(click)="showBulkEdit = !showBulkEdit" [disabled]="!hasChecked()">Bulk Edit</button>
|
||||
<!-- Table -->
|
||||
<table class="table table-striped table-hover table-responsive table-condensed table-usermanagement">
|
||||
<thead>
|
||||
|
@ -96,3 +97,33 @@
|
|||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
<p-sidebar [(visible)]="showBulkEdit" position="right" styleClass="ui-sidebar-md side-back">
|
||||
<h3>Bulk Edit</h3>
|
||||
<hr/>
|
||||
<div *ngFor="let c of availableClaims">
|
||||
<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 | humanize}}</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="movieRequestLimit" class="control-label">Movie Request Limit</label>
|
||||
<div>
|
||||
<input type="text" [(ngModel)]="bulkMovieLimit" class="form-control form-small form-control-custom " id="movieRequestLimit" name="movieRequestLimit" value="{{bulkMovieLimit}}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="episodeRequestLimit" class="control-label">Episode Request Limit</label>
|
||||
<div>
|
||||
<input type="text" [(ngModel)]="bulkEpisodeLimit" class="form-control form-small form-control-custom " id="episodeRequestLimit" name="episodeRequestLimit" value="{{bulkEpisodeLimit}}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="button" class="btn btn-success-outline" (click)="bulkUpdate()">Update Users</button>
|
||||
</p-sidebar>
|
|
@ -1,6 +1,6 @@
|
|||
import { Component, OnInit } from "@angular/core";
|
||||
|
||||
import { ICustomizationSettings, IEmailNotificationSettings, IUser } from "../interfaces";
|
||||
import { ICheckbox, ICustomizationSettings, IEmailNotificationSettings,IUser } from "../interfaces";
|
||||
import { IdentityService, NotificationService, SettingsService } from "../services";
|
||||
|
||||
@Component({
|
||||
|
@ -16,6 +16,11 @@ export class UserManagementComponent implements OnInit {
|
|||
public order: string = "u.userName";
|
||||
public reverse = false;
|
||||
|
||||
public showBulkEdit = false;
|
||||
public availableClaims: ICheckbox[];
|
||||
public bulkMovieLimit?: number;
|
||||
public bulkEpisodeLimit?: number;
|
||||
|
||||
constructor(private readonly identityService: IdentityService,
|
||||
private readonly settingsService: SettingsService,
|
||||
private readonly notificationService: NotificationService) { }
|
||||
|
@ -26,6 +31,7 @@ export class UserManagementComponent implements OnInit {
|
|||
this.users = x;
|
||||
});
|
||||
|
||||
this.identityService.getAllAvailableClaims().subscribe(x => this.availableClaims = x);
|
||||
this.settingsService.getCustomization().subscribe(x => this.customizationSettings = x);
|
||||
this.settingsService.getEmailNotificationSettings().subscribe(x => this.emailSettings = x);
|
||||
}
|
||||
|
@ -49,6 +55,43 @@ export class UserManagementComponent implements OnInit {
|
|||
user.checked = this.checkAll;
|
||||
});
|
||||
}
|
||||
|
||||
public hasChecked(): boolean {
|
||||
return this.users.some(x => {
|
||||
return x.checked;
|
||||
});
|
||||
}
|
||||
|
||||
public bulkUpdate() {
|
||||
const anyRoles = this.availableClaims.some(x => {
|
||||
return x.enabled;
|
||||
});
|
||||
|
||||
this.users.forEach(x => {
|
||||
if(!x.checked) {
|
||||
return;
|
||||
}
|
||||
if(anyRoles) {
|
||||
x.claims = this.availableClaims;
|
||||
}
|
||||
if(this.bulkEpisodeLimit && this.bulkEpisodeLimit > 0) {
|
||||
x.episodeRequestLimit = this.bulkEpisodeLimit;
|
||||
}
|
||||
if(this.bulkMovieLimit && this.bulkMovieLimit > 0) {
|
||||
x.movieRequestLimit = this.bulkMovieLimit;
|
||||
}
|
||||
this.identityService.updateUser(x).subscribe(y => {
|
||||
if(!y.successful) {
|
||||
this.notificationService.error(`Could not update user ${x.userName}. Reason ${y.errors[0]}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
this.notificationService.success(`Updated users`);
|
||||
this.showBulkEdit = false;
|
||||
this.bulkMovieLimit = undefined;
|
||||
this.bulkEpisodeLimit = undefined;
|
||||
}
|
||||
|
||||
public setOrder(value: string) {
|
||||
if (this.order === value) {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import { NgModule } from "@angular/core";
|
||||
import { FormsModule, ReactiveFormsModule } from "@angular/forms";
|
||||
import { RouterModule, Routes } from "@angular/router";
|
||||
import { ConfirmationService, ConfirmDialogModule, MultiSelectModule, TooltipModule } from "primeng/primeng";
|
||||
import { ConfirmationService, ConfirmDialogModule, MultiSelectModule, SidebarModule, TooltipModule } from "primeng/primeng";
|
||||
|
||||
import { NgbModule } from "@ng-bootstrap/ng-bootstrap";
|
||||
|
||||
|
@ -37,6 +37,7 @@ const routes: Routes = [
|
|||
ConfirmDialogModule,
|
||||
TooltipModule,
|
||||
OrderModule,
|
||||
SidebarModule,
|
||||
],
|
||||
declarations: [
|
||||
UserManagementComponent,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue