Kavita is a fast, feature rich, cross platform reading server. Built with the goal of being a full solution for all your reading needs. Setup your own server and share your reading collection with your friends and family.
C# annotationscbzcomicinfocomicscomics-readercross-platformcsharpepubepub-readerfreelinuxmangamedia-servermetadataopdsopds-feedpdfself-hostedubooquitywindows
Misc Updates (#665)
Joseph Milazzo70f324669bac
diff --git a/API/Controllers/SettingsController.cs b/API/Controllers/SettingsController.csindex ef3fe8997..c8b3248ba 100644--- a/API/Controllers/SettingsController.cs+++ b/API/Controllers/SettingsController.cs@@ -140,7 +140,7 @@ namespace API.Controllers}}- if (!_unitOfWork.HasChanges()) return Ok("Nothing was updated");+ if (!_unitOfWork.HasChanges()) return Ok(updateSettingsDto);try{diff --git a/API/Data/Repositories/SettingsRepository.cs b/API/Data/Repositories/SettingsRepository.csindex 168b5a21e..4489cf3bd 100644--- a/API/Data/Repositories/SettingsRepository.cs+++ b/API/Data/Repositories/SettingsRepository.cs@@ -35,15 +35,6 @@ namespace API.Data.Repositoriesreturn _mapper.Map<ServerSettingDto>(settings);}- public ServerSettingDto GetSettingsDto()- {- var settings = _context.ServerSetting- .Select(x => x)- .AsNoTracking()- .ToList();- return _mapper.Map<ServerSettingDto>(settings);- }-public Task<ServerSetting> GetSettingAsync(ServerSettingKey key){return _context.ServerSetting.SingleOrDefaultAsync(x => x.Key == key);diff --git a/API/Interfaces/Repositories/ISettingsRepository.cs b/API/Interfaces/Repositories/ISettingsRepository.csindex 79014dce4..95178ea79 100644--- a/API/Interfaces/Repositories/ISettingsRepository.cs+++ b/API/Interfaces/Repositories/ISettingsRepository.cs@@ -10,7 +10,6 @@ namespace API.Interfaces.Repositories{void Update(ServerSetting settings);Task<ServerSettingDto> GetSettingsDtoAsync();- ServerSettingDto GetSettingsDto();Task<ServerSetting> GetSettingAsync(ServerSettingKey key);Task<IEnumerable<ServerSetting>> GetSettingsAsync();diff --git a/API/SignalR/Presence/PresenceTracker.cs b/API/SignalR/Presence/PresenceTracker.csindex ac9bb28d1..1453bd0f7 100644--- a/API/SignalR/Presence/PresenceTracker.cs+++ b/API/SignalR/Presence/PresenceTracker.cs@@ -1,4 +1,5 @@-using System.Collections.Generic;+using System;+using System.Collections.Generic;using System.Linq;using System.Threading.Tasks;using API.Interfaces;@@ -27,7 +28,7 @@ namespace API.SignalR.Presence_unitOfWork = unitOfWork;}- public Task UserConnected(string username, string connectionId)+ public async Task UserConnected(string username, string connectionId){lock (OnlineUsers){@@ -41,7 +42,10 @@ namespace API.SignalR.Presence}}- return Task.CompletedTask;+ // Update the last active for the user+ var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync(username);+ user.LastActive = DateTime.Now;+ await _unitOfWork.CommitAsync();}public Task UserDisconnected(string username, string connectionId)diff --git a/UI/Web/src/app/admin/settings.service.ts b/UI/Web/src/app/admin/settings.service.tsindex f3ab0c3f7..9f0de0b3f 100644--- a/UI/Web/src/app/admin/settings.service.ts+++ b/UI/Web/src/app/admin/settings.service.ts@@ -1,5 +1,6 @@import { HttpClient } from '@angular/common/http';import { Injectable } from '@angular/core';+import { map } from 'rxjs/operators';import { environment } from 'src/environments/environment';import { ServerSettings } from './_models/server-settings';@@ -37,6 +38,8 @@ export class SettingsService {}getAuthenticationEnabled() {- return this.http.get<boolean>(this.baseUrl + 'settings/authentication-enabled', {responseType: 'text' as 'json'});+ return this.http.get<string>(this.baseUrl + 'settings/authentication-enabled', {responseType: 'text' as 'json'}).pipe(map((res: string) => {+ return res === 'true';+ }));}}diff --git a/UI/Web/src/app/user-login/user-login.component.html b/UI/Web/src/app/user-login/user-login.component.htmlindex 9caa02e73..226b42057 100644--- a/UI/Web/src/app/user-login/user-login.component.html+++ b/UI/Web/src/app/user-login/user-login.component.html@@ -1,6 +1,6 @@<div class="mx-auto login">- <ng-container *ngIf="isLoaded">+ <ng-container *ngIf="isLoaded"><div class="display: inline-block" *ngIf="firstTimeFlow"><h3 class="card-title text-center">Create an Admin Account</h3><div class="card p-3">@@ -12,7 +12,7 @@<form [formGroup]="loginForm" (ngSubmit)="login()" novalidate class="needs-validation" *ngIf="!firstTimeFlow"><div class="row row-cols-4 row-cols-md-4 row-cols-sm-2 row-cols-xs-2"><ng-container *ngFor="let member of memberNames">- <div class="col align-self-center card p-3 m-3" style="width: 12rem;">+ <div class="col align-self-center card p-3 m-3" style="max-width: 12rem;"><span tabindex="0" (click)="select(member)" a11y-click="13,32"><div class="logo-container"><h3 class="card-title text-center">{{member | sentenceCase}}</h3>diff --git a/UI/Web/src/app/user-login/user-login.component.scss b/UI/Web/src/app/user-login/user-login.component.scssindex 85a3f61dc..1bc4e3eea 100644--- a/UI/Web/src/app/user-login/user-login.component.scss+++ b/UI/Web/src/app/user-login/user-login.component.scss@@ -8,6 +8,8 @@height: calc(100vh);min-height: 289px;position: relative;+ width: 100vw;+ max-width: 100vw;&::before {@@ -80,4 +82,5 @@input {background-color: #fff !important;+ color: black;}\ No newline at end of filediff --git a/UI/Web/src/app/user-login/user-login.component.ts b/UI/Web/src/app/user-login/user-login.component.tsindex c2458d7ce..7ca50dcec 100644--- a/UI/Web/src/app/user-login/user-login.component.ts+++ b/UI/Web/src/app/user-login/user-login.component.ts@@ -47,7 +47,7 @@ export class UserLoginComponent implements OnInit {this.settingsService.getAuthenticationEnabled().pipe(take(1)).subscribe((enabled: boolean) => {// There is a bug where this is coming back as a string not a boolean.- this.authDisabled = enabled + '' === 'false';+ this.authDisabled = !enabled;if (this.authDisabled) {this.loginForm.get('password')?.setValidators([]);diff --git a/UI/Web/src/app/user-settings/user-preferences/user-preferences.component.html b/UI/Web/src/app/user-settings/user-preferences/user-preferences.component.htmlindex 1a1dee3b3..2da355765 100644--- a/UI/Web/src/app/user-settings/user-preferences/user-preferences.component.html+++ b/UI/Web/src/app/user-settings/user-preferences/user-preferences.component.html@@ -175,37 +175,42 @@</div></ng-template><ng-template ngbPanelContent>- <p>Change your Password</p>- <div class="alert alert-danger" role="alert" *ngIf="resetPasswordErrors.length > 0">- <div *ngFor="let error of resetPasswordErrors">{{error}}</div>- </div>- <form [formGroup]="passwordChangeForm">- <div class="form-group">- <label for="new-password">New Password</label>- <input class="form-control" type="password" id="new-password" formControlName="password" required>- <div id="password-validations" class="invalid-feedback" *ngIf="passwordChangeForm.dirty || passwordChangeForm.touched">- <div *ngIf="password?.errors?.required">- This field is required- </div>- </div>+ <ng-container *ngIf="isAuthenticationEnabled || isAdmin; else authDisabled">+ <p>Change your Password</p>+ <div class="alert alert-danger" role="alert" *ngIf="resetPasswordErrors.length > 0">+ <div *ngFor="let error of resetPasswordErrors">{{error}}</div></div>- <div class="form-group">- <label for="confirm-password">Confirm Password</label>- <input class="form-control" type="password" id="confirm-password" formControlName="confirmPassword" aria-describedby="password-validations" required>- <div id="password-validations" class="invalid-feedback" *ngIf="passwordChangeForm.dirty || passwordChangeForm.touched">- <div *ngIf="!passwordsMatch">- Passwords must match+ <form [formGroup]="passwordChangeForm">+ <div class="form-group">+ <label for="new-password">New Password</label>+ <input class="form-control" type="password" id="new-password" formControlName="password" required>+ <div id="password-validations" class="invalid-feedback" *ngIf="passwordChangeForm.dirty || passwordChangeForm.touched">+ <div *ngIf="password?.errors?.required">+ This field is required+ </div></div>- <div *ngIf="confirmPassword?.errors?.required">- This field is required+ </div>+ <div class="form-group">+ <label for="confirm-password">Confirm Password</label>+ <input class="form-control" type="password" id="confirm-password" formControlName="confirmPassword" aria-describedby="password-validations" required>+ <div id="password-validations" class="invalid-feedback" *ngIf="passwordChangeForm.dirty || passwordChangeForm.touched">+ <div *ngIf="!passwordsMatch">+ Passwords must match+ </div>+ <div *ngIf="confirmPassword?.errors?.required">+ This field is required+ </div></div></div>- </div>- <div class="float-right mb-3">- <button type="button" class="btn btn-secondary mr-2" aria-describedby="password-panel" (click)="resetPasswordForm()">Reset</button>- <button type="submit" class="btn btn-primary" aria-describedby="password-panel" (click)="savePasswordForm()" [disabled]="!passwordChangeForm.valid || !(passwordChangeForm.dirty || passwordChangeForm.touched)">Save</button>- </div>- </form>+ <div class="float-right mb-3">+ <button type="button" class="btn btn-secondary mr-2" aria-describedby="password-panel" (click)="resetPasswordForm()">Reset</button>+ <button type="submit" class="btn btn-primary" aria-describedby="password-panel" (click)="savePasswordForm()" [disabled]="!passwordChangeForm.valid || !(passwordChangeForm.dirty || passwordChangeForm.touched)">Save</button>+ </div>+ </form>+ </ng-container>+ <ng-template #authDisabled>+ <p class="text-warning">Authentication is disabled on this server. A password is not required to authenticate.</p>+ </ng-template></ng-template></ngb-panel><ngb-panel id="api-panel" title="OPDS">diff --git a/UI/Web/src/app/user-settings/user-preferences/user-preferences.component.ts b/UI/Web/src/app/user-settings/user-preferences/user-preferences.component.tsindex ce3a8452b..ba4c17865 100644--- a/UI/Web/src/app/user-settings/user-preferences/user-preferences.component.ts+++ b/UI/Web/src/app/user-settings/user-preferences/user-preferences.component.ts@@ -11,8 +11,6 @@ import { AccountService } from 'src/app/_services/account.service';import { NavService } from 'src/app/_services/nav.service';import { ActivatedRoute } from '@angular/router';import { SettingsService } from 'src/app/admin/settings.service';-import { keyframes } from '@angular/animations';-import { environment } from 'src/environments/environment';@Component({selector: 'app-user-preferences',@@ -29,6 +27,8 @@ export class UserPreferencesComponent implements OnInit, OnDestroy {settingsForm: FormGroup = new FormGroup({});passwordChangeForm: FormGroup = new FormGroup({});user: User | undefined = undefined;+ isAdmin: boolean = false;+ isAuthenticationEnabled: boolean = true;passwordsMatch = false;resetPasswordErrors: string[] = [];@@ -75,7 +75,10 @@ export class UserPreferencesComponent implements OnInit, OnDestroy {this.settingsService.getOpdsEnabled().subscribe(res => {this.opdsEnabled = res;- })+ });+ this.settingsService.getAuthenticationEnabled().subscribe(res => {+ this.isAuthenticationEnabled = res;+ });}ngOnInit(): void {@@ -83,6 +86,7 @@ export class UserPreferencesComponent implements OnInit, OnDestroy {this.accountService.currentUser$.pipe(take(1)).subscribe((user: User) => {if (user) {this.user = user;+ this.isAdmin = this.accountService.hasAdminRole(user);if (this.fontFamilies.indexOf(this.user.preferences.bookReaderFontFamily) < 0) {this.user.preferences.bookReaderFontFamily = 'default';