mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 21:33:15 -07:00
Consolodated the usermanagement stuff, still a !wip but it's a start
This commit is contained in:
parent
bcb193f321
commit
2886f6e6fa
7 changed files with 235 additions and 238 deletions
|
@ -1,79 +0,0 @@
|
|||
|
||||
<h3>Create User</h3>
|
||||
<button type="button" class="btn btn-primary-outline" style="float:right;" [routerLink]="['/usermanagement/']">Back</button>
|
||||
|
||||
<div class="modal-body" style="margin-top: 45px;">
|
||||
<div class="col-md-6">
|
||||
<h4>User Details</h4>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<h4>Roles</h4>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="username" class="control-label">Username</label>
|
||||
<div>
|
||||
<input type="text" [(ngModel)]="user.userName" class="form-control form-control-custom " id="username" name="username" value="{{user?.userName}}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="alias" class="control-label">Alias</label>
|
||||
<div>
|
||||
<input type="text" [(ngModel)]="user.alias" class="form-control form-control-custom " id="alias" name="alias" value="{{user?.alias}}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="emailAddress" class="control-label">Email Address</label>
|
||||
<div>
|
||||
<input type="text" [(ngModel)]="user.emailAddress" class="form-control form-control-custom " id="emailAddress" name="emailAddress" value="{{user?.emailAddress}}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="password" class="control-label">Password</label>
|
||||
<div>
|
||||
<input type="password" [(ngModel)]="user.password" class="form-control form-control-custom " id="password" name="password">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="confirmPass" class="control-label">Confirm Password</label>
|
||||
<div>
|
||||
<input type="password" [(ngModel)]="confirmPass" class="form-control form-control-custom " id="confirmPass" name="confirmPass">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<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)]="user.movieRequestLimit" class="form-control form-small form-control-custom " id="movieRequestLimit" name="movieRequestLimit" value="{{user?.movieRequestLimit}}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="episodeRequestLimit" class="control-label">Episode Request Limit</label>
|
||||
<div>
|
||||
<input type="text" [(ngModel)]="user.episodeRequestLimit" class="form-control form-small form-control-custom " id="episodeRequestLimit" name="episodeRequestLimit" value="{{user?.episodeRequestLimit}}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<button type="button" class="btn btn-danger-outline" (click)="create()">Create</button>
|
||||
|
||||
</div>
|
||||
</div>
|
|
@ -1,70 +0,0 @@
|
|||
import { Component, OnInit } from "@angular/core";
|
||||
import { Router } from "@angular/router";
|
||||
|
||||
import { ICheckbox, IUser, UserType } from "../interfaces";
|
||||
import { IdentityService, NotificationService } from "../services";
|
||||
|
||||
@Component({
|
||||
templateUrl: "./usermanagement-add.component.html",
|
||||
})
|
||||
export class UserManagementAddComponent implements OnInit {
|
||||
public user: IUser;
|
||||
public availableClaims: ICheckbox[];
|
||||
public confirmPass: "";
|
||||
|
||||
constructor(private identityService: IdentityService,
|
||||
private notificationSerivce: NotificationService,
|
||||
private router: Router) { }
|
||||
|
||||
public ngOnInit() {
|
||||
this.identityService.getAllAvailableClaims().subscribe(x => this.availableClaims = x);
|
||||
this.user = {
|
||||
alias: "",
|
||||
claims: [],
|
||||
emailAddress: "",
|
||||
id: "",
|
||||
password: "",
|
||||
userName: "",
|
||||
userType: UserType.LocalUser,
|
||||
checked: false,
|
||||
hasLoggedIn: false,
|
||||
lastLoggedIn: new Date(),
|
||||
episodeRequestLimit: 0,
|
||||
movieRequestLimit: 0,
|
||||
userAccessToken: "",
|
||||
};
|
||||
}
|
||||
|
||||
public create() {
|
||||
this.user.claims = this.availableClaims;
|
||||
|
||||
if (this.user.password) {
|
||||
if (this.user.password !== this.confirmPass) {
|
||||
this.notificationSerivce.error("Passwords do not match");
|
||||
return;
|
||||
}
|
||||
}
|
||||
const hasClaims = this.availableClaims.some((item) => {
|
||||
if (item.enabled) { return true; }
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
if (!hasClaims) {
|
||||
this.notificationSerivce.error("Please assign a role");
|
||||
return;
|
||||
}
|
||||
|
||||
this.identityService.createUser(this.user).subscribe(x => {
|
||||
if (x.successful) {
|
||||
this.notificationSerivce.success(`The user ${this.user.userName} has been created successfully`);
|
||||
this.router.navigate(["usermanagement"]);
|
||||
} else {
|
||||
x.errors.forEach((val) => {
|
||||
this.notificationSerivce.error(val);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
<div *ngIf="user">
|
||||
<div class="user-details">
|
||||
<h3>User: {{user.userName}}</h3>
|
||||
<button type="button" class="btn btn-primary-outline" style="float:right;" [routerLink]="['/usermanagement/']">Back</button>
|
||||
|
||||
|
||||
<p-confirmDialog></p-confirmDialog>
|
||||
|
||||
<div class="modal-body" style="margin-top: 45px;">
|
||||
<div class="col-md-6">
|
||||
<h4>User Details</h4>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<h4>Roles</h4>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="username" class="control-label">Username</label>
|
||||
<div>
|
||||
<input type="text" [(ngModel)]="user.userName" [readonly]="true" class="form-control form-control-custom " id="username" name="username" value="{{user?.userName}}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="alias" class="control-label">Alias</label>
|
||||
<div>
|
||||
<input type="text" [(ngModel)]="user.alias" class="form-control form-control-custom " id="alias" name="alias" value="{{user?.alias}}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="emailAddress" class="control-label">Email Address</label>
|
||||
<div>
|
||||
<input type="text" [(ngModel)]="user.emailAddress" class="form-control form-control-custom " id="emailAddress" name="emailAddress" value="{{user?.emailAddress}}" [disabled]="user?.userType == 2">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<div *ngFor="let c of user.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 | humanize}}</label>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="movieRequestLimit" class="control-label">Movie Request Limit</label>
|
||||
<div>
|
||||
<input type="text" [(ngModel)]="user.movieRequestLimit" class="form-control form-small form-control-custom " id="movieRequestLimit" name="movieRequestLimit" value="{{user?.movieRequestLimit}}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="episodeRequestLimit" class="control-label">Episode Request Limit</label>
|
||||
<div>
|
||||
<input type="text" [(ngModel)]="user.episodeRequestLimit" class="form-control form-small form-control-custom " id="episodeRequestLimit" name="episodeRequestLimit" value="{{user?.episodeRequestLimit}}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<button type="button" class="btn btn-primary-outline" (click)="update()">Update</button>
|
||||
<button type="button" class="btn btn-danger-outline" (click)="delete()">Delete</button>
|
||||
<button type="button" style="float:right;" class="btn btn-info-outline" (click)="resetPassword()" pTooltip="You need your SMTP settings setup">Send Reset Password Link</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,154 @@
|
|||
<div *ngIf="!edit">
|
||||
<h3 >Create User</h3>
|
||||
<button type="button" class="btn btn-primary-outline" style="float:right;" [routerLink]="['/usermanagement/']">Back</button>
|
||||
|
||||
<div class="modal-body" style="margin-top: 45px;">
|
||||
<div class="col-md-6">
|
||||
<h4>User Details</h4>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<h4>Roles</h4>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="username" class="control-label">Username</label>
|
||||
<div>
|
||||
<input type="text" [(ngModel)]="user.userName" class="form-control form-control-custom " id="username" name="username" value="{{user?.userName}}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="alias" class="control-label">Alias</label>
|
||||
<div>
|
||||
<input type="text" [(ngModel)]="user.alias" class="form-control form-control-custom " id="alias" name="alias" value="{{user?.alias}}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="emailAddress" class="control-label">Email Address</label>
|
||||
<div>
|
||||
<input type="text" [(ngModel)]="user.emailAddress" class="form-control form-control-custom " id="emailAddress" name="emailAddress" value="{{user?.emailAddress}}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="password" class="control-label">Password</label>
|
||||
<div>
|
||||
<input type="password" [(ngModel)]="user.password" class="form-control form-control-custom " id="password" name="password">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="confirmPass" class="control-label">Confirm Password</label>
|
||||
<div>
|
||||
<input type="password" [(ngModel)]="confirmPass" class="form-control form-control-custom " id="confirmPass" name="confirmPass">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<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)]="user.movieRequestLimit" class="form-control form-small form-control-custom " id="movieRequestLimit" name="movieRequestLimit" value="{{user?.movieRequestLimit}}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="episodeRequestLimit" class="control-label">Episode Request Limit</label>
|
||||
<div>
|
||||
<input type="text" [(ngModel)]="user.episodeRequestLimit" class="form-control form-small form-control-custom " id="episodeRequestLimit" name="episodeRequestLimit" value="{{user?.episodeRequestLimit}}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<button type="button" class="btn btn-danger-outline" (click)="create()">Create</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div *ngIf="edit">
|
||||
|
||||
<div *ngIf="user">
|
||||
<div class="user-details">
|
||||
<h3>User: {{user.userName}}</h3>
|
||||
<button type="button" class="btn btn-primary-outline" style="float:right;" [routerLink]="['/usermanagement/']">Back</button>
|
||||
|
||||
|
||||
<p-confirmDialog></p-confirmDialog>
|
||||
|
||||
<div class="modal-body" style="margin-top: 45px;">
|
||||
<div class="col-md-6">
|
||||
<h4>User Details</h4>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<h4>Roles</h4>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="username" class="control-label">Username</label>
|
||||
<div>
|
||||
<input type="text" [(ngModel)]="user.userName" [readonly]="true" class="form-control form-control-custom " id="username" name="username" value="{{user?.userName}}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="alias" class="control-label">Alias</label>
|
||||
<div>
|
||||
<input type="text" [(ngModel)]="user.alias" class="form-control form-control-custom " id="alias" name="alias" value="{{user?.alias}}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="emailAddress" class="control-label">Email Address</label>
|
||||
<div>
|
||||
<input type="text" [(ngModel)]="user.emailAddress" class="form-control form-control-custom " id="emailAddress" name="emailAddress" value="{{user?.emailAddress}}" [disabled]="user?.userType == 2">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<div *ngFor="let c of user.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 | humanize}}</label>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="movieRequestLimit" class="control-label">Movie Request Limit</label>
|
||||
<div>
|
||||
<input type="text" [(ngModel)]="user.movieRequestLimit" class="form-control form-small form-control-custom " id="movieRequestLimit" name="movieRequestLimit" value="{{user?.movieRequestLimit}}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="episodeRequestLimit" class="control-label">Episode Request Limit</label>
|
||||
<div>
|
||||
<input type="text" [(ngModel)]="user.episodeRequestLimit" class="form-control form-small form-control-custom " id="episodeRequestLimit" name="episodeRequestLimit" value="{{user?.episodeRequestLimit}}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<button type="button" class="btn btn-primary-outline" (click)="update()">Update</button>
|
||||
<button type="button" class="btn btn-danger-outline" (click)="delete()">Delete</button>
|
||||
<button type="button" style="float:right;" class="btn btn-info-outline" (click)="resetPassword()" pTooltip="You need your SMTP settings setup">Send Reset Password Link</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -1,32 +1,92 @@
|
|||
import { Component } from "@angular/core";
|
||||
import { Router } from "@angular/router";
|
||||
import { Component, OnInit } from "@angular/core";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
|
||||
import { ICheckbox, IUser, UserType } from "../interfaces";
|
||||
import { IdentityService, NotificationService } from "../services";
|
||||
|
||||
import { ConfirmationService } from "primeng/primeng";
|
||||
|
||||
import { ActivatedRoute } from "@angular/router";
|
||||
import { IUser } from "../interfaces";
|
||||
import { IdentityService } from "../services";
|
||||
import { NotificationService } from "../services";
|
||||
|
||||
@Component({
|
||||
templateUrl: "./usermanagement-edit.component.html",
|
||||
templateUrl: "./usermanagement-user.component.html",
|
||||
})
|
||||
export class UserManagementEditComponent {
|
||||
export class UserManagementUserComponent implements OnInit {
|
||||
|
||||
public user: IUser;
|
||||
public userId: string;
|
||||
public availableClaims: ICheckbox[];
|
||||
public confirmPass: "";
|
||||
|
||||
public edit: boolean;
|
||||
|
||||
constructor(private identityService: IdentityService,
|
||||
private route: ActivatedRoute,
|
||||
private notificationService: NotificationService,
|
||||
private router: Router,
|
||||
private route: ActivatedRoute,
|
||||
private confirmationService: ConfirmationService) {
|
||||
this.route.params
|
||||
this.route.params
|
||||
.subscribe((params: any) => {
|
||||
this.userId = params.id;
|
||||
|
||||
this.identityService.getUserById(this.userId).subscribe(x => {
|
||||
this.user = x;
|
||||
});
|
||||
if(params.id) {
|
||||
this.userId = params.id;
|
||||
this.edit = true;
|
||||
this.identityService.getUserById(this.userId).subscribe(x => {
|
||||
this.user = x;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public ngOnInit() {
|
||||
this.identityService.getAllAvailableClaims().subscribe(x => this.availableClaims = x);
|
||||
if(!this.edit) {
|
||||
this.user = {
|
||||
alias: "",
|
||||
claims: [],
|
||||
emailAddress: "",
|
||||
id: "",
|
||||
password: "",
|
||||
userName: "",
|
||||
userType: UserType.LocalUser,
|
||||
checked: false,
|
||||
hasLoggedIn: false,
|
||||
lastLoggedIn: new Date(),
|
||||
episodeRequestLimit: 0,
|
||||
movieRequestLimit: 0,
|
||||
userAccessToken: "",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public create() {
|
||||
this.user.claims = this.availableClaims;
|
||||
|
||||
if (this.user.password) {
|
||||
if (this.user.password !== this.confirmPass) {
|
||||
this.notificationService.error("Passwords do not match");
|
||||
return;
|
||||
}
|
||||
}
|
||||
const hasClaims = this.availableClaims.some((item) => {
|
||||
if (item.enabled) { return true; }
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
if (!hasClaims) {
|
||||
this.notificationService.error("Please assign a role");
|
||||
return;
|
||||
}
|
||||
|
||||
this.identityService.createUser(this.user).subscribe(x => {
|
||||
if (x.successful) {
|
||||
this.notificationService.success(`The user ${this.user.userName} has been created successfully`);
|
||||
this.router.navigate(["usermanagement"]);
|
||||
} else {
|
||||
x.errors.forEach((val) => {
|
||||
this.notificationService.error(val);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public delete() {
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
|
||||
|
||||
<button type="button" class="btn btn-success-outline" [routerLink]="['/usermanagement/add']">Add User To Ombi</button>
|
||||
<button type="button" class="btn btn-success-outline" [routerLink]="['/usermanagement/user']">Add User To Ombi</button>
|
||||
|
||||
<button type="button" style="float:right;" class="btn btn-primary-outline"(click)="showBulkEdit = !showBulkEdit" [disabled]="!hasChecked()">Bulk Edit</button>
|
||||
<div *ngIf="plexEnabled">
|
||||
|
@ -94,7 +94,7 @@
|
|||
<span *ngIf="u.userType === 3">Emby User</span>
|
||||
</td>
|
||||
<td>
|
||||
<a [routerLink]="['/usermanagement/edit/' + u.id]" class="btn btn-sm btn-info-outline">Details/Edit</a>
|
||||
<a [routerLink]="['/usermanagement/user/' + u.id]" class="btn btn-sm btn-info-outline">Details/Edit</a>
|
||||
</td>
|
||||
<td *ngIf="customizationSettings">
|
||||
<button *ngIf="!u.hasLoggedIn" (click)="welcomeEmail(u)" [disabled]="!customizationSettings.applicationUrl" class="btn btn-sm btn-info-outline">Send Welcome Email</button>
|
||||
|
|
|
@ -10,6 +10,7 @@ import { UpdateDetailsComponent } from "./updatedetails.component";
|
|||
import { UserManagementAddComponent } from "./usermanagement-add.component";
|
||||
import { UserManagementEditComponent } from "./usermanagement-edit.component";
|
||||
import { UserManagementComponent } from "./usermanagement.component";
|
||||
import { UserManagementUserComponent } from "./usermanagement-user.component";
|
||||
|
||||
import { PipeModule } from "../pipes/pipe.module";
|
||||
import { IdentityService, PlexService } from "../services";
|
||||
|
@ -22,7 +23,7 @@ import { AddPlexUserComponent } from "./addplexuser.component";
|
|||
const routes: Routes = [
|
||||
{ path: "", component: UserManagementComponent, canActivate: [AuthGuard] },
|
||||
{ path: "add", component: UserManagementAddComponent, canActivate: [AuthGuard] },
|
||||
{ path: "edit/:id", component: UserManagementEditComponent, canActivate: [AuthGuard] },
|
||||
{ path: "user", component: UserManagementUserComponent, canActivate: [AuthGuard] },
|
||||
{ path: "updatedetails", component: UpdateDetailsComponent, canActivate: [AuthGuard] },
|
||||
];
|
||||
|
||||
|
@ -46,6 +47,7 @@ const routes: Routes = [
|
|||
UserManagementEditComponent,
|
||||
UpdateDetailsComponent,
|
||||
AddPlexUserComponent,
|
||||
UserManagementUserComponent,
|
||||
],
|
||||
entryComponents:[
|
||||
AddPlexUserComponent,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue