
* Fixed a case where when setting up initial rates for scrobbling, Kavita would log a user without a token set had no rate. * Migrated the whole app to use just the directive instead of whole transloco module. * Migrated the whole app to use just the directive instead of whole transloco module. Fixed prod mode breaking localization & fixed broken minification for language files. * Time Ago pipe will now show Never if there is a null date. Changed the wording of Last Added To -> Last Item Added for volume/series info screen. * Fixed Tachiyomi DTOs and bumped sonar to use Java 17 * One more GA thing * GA junk * Bump versions by dotnet-bump-version. * Weblate Changes (#2189) * Added translation using Weblate (Turkish) * Translated using Weblate (Thai) Currently translated at 100.0% (158 of 158 strings) Translation: Kavita/backend Translate-URL: https://hosted.weblate.org/projects/kavita/backend/th/ * Translated using Weblate (Thai) Currently translated at 15.2% (218 of 1426 strings) Translation: Kavita/ui Translate-URL: https://hosted.weblate.org/projects/kavita/ui/th/ * Translated using Weblate (Turkish) Currently translated at 7.7% (110 of 1426 strings) Translation: Kavita/ui Translate-URL: https://hosted.weblate.org/projects/kavita/ui/tr/ * Translated using Weblate (Portuguese) Currently translated at 17.5% (250 of 1426 strings) Translation: Kavita/ui Translate-URL: https://hosted.weblate.org/projects/kavita/ui/pt/ * Translated using Weblate (Russian) Currently translated at 1.2% (2 of 158 strings) Translation: Kavita/backend Translate-URL: https://hosted.weblate.org/projects/kavita/backend/ru/ * Translated using Weblate (Russian) Currently translated at 4.9% (71 of 1426 strings) Translation: Kavita/ui Translate-URL: https://hosted.weblate.org/projects/kavita/ui/ru/ * Translated using Weblate (Italian) Currently translated at 6.7% (96 of 1426 strings) Translation: Kavita/ui Translate-URL: https://hosted.weblate.org/projects/kavita/ui/it/ * Translated using Weblate (Turkish) Currently translated at 8.8% (14 of 158 strings) Translation: Kavita/backend Translate-URL: https://hosted.weblate.org/projects/kavita/backend/tr/ --------- Co-authored-by: akoray420 <akoray420@gmail.com> Co-authored-by: AlienHack <the4got10@windowslive.com> Co-authored-by: Duarte Silva <smallflake@protonmail.com> Co-authored-by: Blezz Rot <markus.jenya04@yandex.ru> Co-authored-by: Tomas Battistini <tomas.battistini@gmail.com> --------- Co-authored-by: Weblate (bot) <hosted@weblate.org> Co-authored-by: akoray420 <akoray420@gmail.com> Co-authored-by: AlienHack <the4got10@windowslive.com> Co-authored-by: Duarte Silva <smallflake@protonmail.com> Co-authored-by: Blezz Rot <markus.jenya04@yandex.ru> Co-authored-by: Tomas Battistini <tomas.battistini@gmail.com>
101 lines
4.4 KiB
TypeScript
101 lines
4.4 KiB
TypeScript
import {ChangeDetectionStrategy, ChangeDetectorRef, Component, inject, OnInit} from '@angular/core';
|
|
import {FormControl, FormGroup, ReactiveFormsModule, Validators} from '@angular/forms';
|
|
import {ToastrService} from 'ngx-toastr';
|
|
import {take} from 'rxjs';
|
|
import {SettingsService} from '../settings.service';
|
|
import {ServerSettings} from '../_models/server-settings';
|
|
import {DirectoryPickerComponent, DirectoryPickerResult} from '../_modals/directory-picker/directory-picker.component';
|
|
import {
|
|
NgbAccordionBody,
|
|
NgbAccordionButton,
|
|
NgbAccordionCollapse,
|
|
NgbAccordionDirective,
|
|
NgbAccordionHeader,
|
|
NgbAccordionItem,
|
|
NgbAccordionToggle,
|
|
NgbCollapse,
|
|
NgbModal,
|
|
NgbTooltip
|
|
} from '@ng-bootstrap/ng-bootstrap';
|
|
import {EncodeFormats} from '../_models/encode-format';
|
|
import {ManageScrobbleErrorsComponent} from '../manage-scrobble-errors/manage-scrobble-errors.component';
|
|
import {ManageAlertsComponent} from '../manage-alerts/manage-alerts.component';
|
|
import {NgFor, NgIf, NgTemplateOutlet} from '@angular/common';
|
|
import {TranslocoDirective, TranslocoService} from "@ngneat/transloco";
|
|
|
|
@Component({
|
|
selector: 'app-manage-media-settings',
|
|
templateUrl: './manage-media-settings.component.html',
|
|
styleUrls: ['./manage-media-settings.component.scss'],
|
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
standalone: true,
|
|
imports: [NgIf, ReactiveFormsModule, NgbTooltip, NgTemplateOutlet, NgFor, NgbAccordionDirective, NgbAccordionItem, NgbAccordionHeader, NgbAccordionToggle, NgbAccordionButton, NgbCollapse, NgbAccordionCollapse, NgbAccordionBody, ManageAlertsComponent, ManageScrobbleErrorsComponent, TranslocoDirective]
|
|
})
|
|
export class ManageMediaSettingsComponent implements OnInit {
|
|
|
|
serverSettings!: ServerSettings;
|
|
settingsForm: FormGroup = new FormGroup({});
|
|
|
|
alertCount: number = 0;
|
|
scrobbleCount: number = 0;
|
|
|
|
private readonly translocoService = inject(TranslocoService);
|
|
private readonly cdRef = inject(ChangeDetectorRef);
|
|
|
|
get EncodeFormats() { return EncodeFormats; }
|
|
|
|
constructor(private settingsService: SettingsService, private toastr: ToastrService, private modalService: NgbModal, ) { }
|
|
|
|
ngOnInit(): void {
|
|
this.settingsService.getServerSettings().pipe(take(1)).subscribe((settings: ServerSettings) => {
|
|
this.serverSettings = settings;
|
|
this.settingsForm.addControl('encodeMediaAs', new FormControl(this.serverSettings.encodeMediaAs, [Validators.required]));
|
|
this.settingsForm.addControl('bookmarksDirectory', new FormControl(this.serverSettings.bookmarksDirectory, [Validators.required]));
|
|
this.cdRef.markForCheck();
|
|
});
|
|
}
|
|
|
|
resetForm() {
|
|
this.settingsForm.get('encodeMediaAs')?.setValue(this.serverSettings.encodeMediaAs);
|
|
this.settingsForm.get('bookmarksDirectory')?.setValue(this.serverSettings.bookmarksDirectory);
|
|
this.settingsForm.markAsPristine();
|
|
this.cdRef.markForCheck();
|
|
}
|
|
|
|
saveSettings() {
|
|
const modelSettings = Object.assign({}, this.serverSettings);
|
|
modelSettings.encodeMediaAs = parseInt(this.settingsForm.get('encodeMediaAs')?.value, 10);
|
|
modelSettings.bookmarksDirectory = this.settingsForm.get('bookmarksDirectory')?.value;
|
|
|
|
this.settingsService.updateServerSettings(modelSettings).pipe(take(1)).subscribe(async (settings: ServerSettings) => {
|
|
this.serverSettings = settings;
|
|
this.resetForm();
|
|
this.toastr.success(this.translocoService.translate('toasts.server-settings-updated'));
|
|
}, (err: any) => {
|
|
console.error('error: ', err);
|
|
});
|
|
}
|
|
|
|
resetToDefaults() {
|
|
this.settingsService.resetServerSettings().pipe(take(1)).subscribe((settings: ServerSettings) => {
|
|
this.serverSettings = settings;
|
|
this.resetForm();
|
|
this.toastr.success(this.translocoService.translate('toasts.server-settings-updated'));
|
|
}, (err: any) => {
|
|
console.error('error: ', err);
|
|
});
|
|
}
|
|
|
|
openDirectoryChooser(existingDirectory: string, formControl: string) {
|
|
const modalRef = this.modalService.open(DirectoryPickerComponent, { scrollable: true, size: 'lg' });
|
|
modalRef.componentInstance.startingFolder = existingDirectory || '';
|
|
modalRef.componentInstance.helpUrl = '';
|
|
modalRef.closed.subscribe((closeResult: DirectoryPickerResult) => {
|
|
if (closeResult.success && closeResult.folderPath !== '') {
|
|
this.settingsForm.get(formControl)?.setValue(closeResult.folderPath);
|
|
this.settingsForm.markAsDirty();
|
|
this.cdRef.markForCheck();
|
|
}
|
|
});
|
|
}
|
|
}
|