Add toggle to watch folders
This commit is contained in:
+1
@@ -19,4 +19,5 @@ public class CreateLibraryRequest {
|
|||||||
private String icon;
|
private String icon;
|
||||||
@NotEmpty
|
@NotEmpty
|
||||||
private List<LibraryPath> paths;
|
private List<LibraryPath> paths;
|
||||||
|
private boolean watch;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ public class LibraryService {
|
|||||||
LibraryEntity library = libraryRepository.findById(libraryId).orElseThrow(() -> ApiError.LIBRARY_NOT_FOUND.createException(libraryId));
|
LibraryEntity library = libraryRepository.findById(libraryId).orElseThrow(() -> ApiError.LIBRARY_NOT_FOUND.createException(libraryId));
|
||||||
library.setName(request.getName());
|
library.setName(request.getName());
|
||||||
library.setIcon(request.getIcon());
|
library.setIcon(request.getIcon());
|
||||||
|
library.setWatch(request.isWatch());
|
||||||
|
|
||||||
Set<String> currentPaths = library.getLibraryPaths().stream().map(LibraryPathEntity::getPath).collect(Collectors.toSet());
|
Set<String> currentPaths = library.getLibraryPaths().stream().map(LibraryPathEntity::getPath).collect(Collectors.toSet());
|
||||||
Set<String> updatedPaths = request.getPaths().stream().map(LibraryPath::getPath).collect(Collectors.toSet());
|
Set<String> updatedPaths = request.getPaths().stream().map(LibraryPath::getPath).collect(Collectors.toSet());
|
||||||
@@ -110,6 +111,7 @@ public class LibraryService {
|
|||||||
.collect(Collectors.toList())
|
.collect(Collectors.toList())
|
||||||
)
|
)
|
||||||
.icon(request.getIcon())
|
.icon(request.getIcon())
|
||||||
|
.watch(request.isWatch())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
libraryEntity = libraryRepository.save(libraryEntity);
|
libraryEntity = libraryRepository.save(libraryEntity);
|
||||||
|
|||||||
@@ -9,11 +9,11 @@
|
|||||||
<div class="flex flex-col w-[40rem] h-[25rem]">
|
<div class="flex flex-col w-[40rem] h-[25rem]">
|
||||||
<div class="flex flex-auto justify-center items-center font-medium border-[var(--border-color)] border-2 border-dashed">
|
<div class="flex flex-auto justify-center items-center font-medium border-[var(--border-color)] border-2 border-dashed">
|
||||||
<div class="flex flex-col gap-10">
|
<div class="flex flex-col gap-10">
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-8">
|
||||||
<p>Library Name: </p>
|
<p>Library Name: </p>
|
||||||
<input type="text" pInputText [(ngModel)]="chosenLibraryName" placeholder="Enter library name..."/>
|
<input type="text" pInputText [(ngModel)]="chosenLibraryName" placeholder="Enter library name..."/>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center gap-5">
|
<div class="flex items-center gap-11">
|
||||||
<p>Library Icon:</p>
|
<p>Library Icon:</p>
|
||||||
<div *ngIf="!selectedIcon">
|
<div *ngIf="!selectedIcon">
|
||||||
<p-button label="Select Icon" icon="pi pi-search" (onClick)="openIconPicker()"></p-button>
|
<p-button label="Select Icon" icon="pi pi-search" (onClick)="openIconPicker()"></p-button>
|
||||||
@@ -23,6 +23,10 @@
|
|||||||
<p-button icon="pi pi-times" (onClick)="clearSelectedIcon()" [rounded]="true" [text]="true" [outlined]="true" severity="danger"></p-button>
|
<p-button icon="pi pi-times" (onClick)="clearSelectedIcon()" [rounded]="true" [text]="true" [outlined]="true" severity="danger"></p-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
|
<p>Monitor Folders: </p>
|
||||||
|
<p-toggleswitch [(ngModel)]="watch" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<app-icon-picker (iconSelected)="onIconSelected($event)"></app-icon-picker>
|
<app-icon-picker (iconSelected)="onIconSelected($event)"></app-icon-picker>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -12,12 +12,13 @@ import {NgIf} from '@angular/common';
|
|||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {InputText} from 'primeng/inputtext';
|
import {InputText} from 'primeng/inputtext';
|
||||||
import {Library} from '../../model/library.model';
|
import {Library} from '../../model/library.model';
|
||||||
|
import {ToggleSwitch} from 'primeng/toggleswitch';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-library-creator',
|
selector: 'app-library-creator',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
templateUrl: './library-creator.component.html',
|
templateUrl: './library-creator.component.html',
|
||||||
imports: [Button, TableModule, StepPanel, IconPickerComponent, NgIf, FormsModule, InputText, Stepper, StepList, Step, StepPanels],
|
imports: [Button, TableModule, StepPanel, IconPickerComponent, NgIf, FormsModule, InputText, Stepper, StepList, Step, StepPanels, ToggleSwitch],
|
||||||
styleUrl: './library-creator.component.scss'
|
styleUrl: './library-creator.component.scss'
|
||||||
})
|
})
|
||||||
export class LibraryCreatorComponent implements OnInit {
|
export class LibraryCreatorComponent implements OnInit {
|
||||||
@@ -32,6 +33,7 @@ export class LibraryCreatorComponent implements OnInit {
|
|||||||
library!: Library | undefined;
|
library!: Library | undefined;
|
||||||
editModeLibraryName: string = '';
|
editModeLibraryName: string = '';
|
||||||
directoryPickerDialogRef!: DynamicDialogRef<DirectoryPickerComponent>;
|
directoryPickerDialogRef!: DynamicDialogRef<DirectoryPickerComponent>;
|
||||||
|
watch: boolean = false;
|
||||||
|
|
||||||
private dialogService = inject(DialogService);
|
private dialogService = inject(DialogService);
|
||||||
private dynamicDialogRef = inject(DynamicDialogRef);
|
private dynamicDialogRef = inject(DynamicDialogRef);
|
||||||
@@ -47,10 +49,11 @@ export class LibraryCreatorComponent implements OnInit {
|
|||||||
this.mode = data.mode;
|
this.mode = data.mode;
|
||||||
this.library = this.libraryService.findLibraryById(data.libraryId);
|
this.library = this.libraryService.findLibraryById(data.libraryId);
|
||||||
if (this.library) {
|
if (this.library) {
|
||||||
const {name, icon, paths} = this.library;
|
const {name, icon, paths, watch} = this.library;
|
||||||
this.chosenLibraryName = name;
|
this.chosenLibraryName = name;
|
||||||
this.editModeLibraryName = name;
|
this.editModeLibraryName = name;
|
||||||
this.selectedIcon = `pi pi-${icon}`;
|
this.selectedIcon = `pi pi-${icon}`;
|
||||||
|
this.watch = watch;
|
||||||
this.folders = paths.map(path => path.path);
|
this.folders = paths.map(path => path.path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -106,7 +109,8 @@ export class LibraryCreatorComponent implements OnInit {
|
|||||||
const library: Library = {
|
const library: Library = {
|
||||||
name: this.chosenLibraryName,
|
name: this.chosenLibraryName,
|
||||||
icon: this.selectedIcon?.replace('pi pi-', '') || 'heart',
|
icon: this.selectedIcon?.replace('pi pi-', '') || 'heart',
|
||||||
paths: this.folders.map(folder => ({path: folder}))
|
paths: this.folders.map(folder => ({path: folder})),
|
||||||
|
watch: this.watch
|
||||||
};
|
};
|
||||||
this.libraryService.updateLibrary(library, this.library?.id).subscribe({
|
this.libraryService.updateLibrary(library, this.library?.id).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
@@ -122,7 +126,8 @@ export class LibraryCreatorComponent implements OnInit {
|
|||||||
const library: Library = {
|
const library: Library = {
|
||||||
name: this.chosenLibraryName,
|
name: this.chosenLibraryName,
|
||||||
icon: this.selectedIcon?.replace('pi pi-', '') || 'heart',
|
icon: this.selectedIcon?.replace('pi pi-', '') || 'heart',
|
||||||
paths: this.folders.map(folder => ({path: folder}))
|
paths: this.folders.map(folder => ({path: folder})),
|
||||||
|
watch: this.watch
|
||||||
};
|
};
|
||||||
this.libraryService.createLibrary(library).subscribe({
|
this.libraryService.createLibrary(library).subscribe({
|
||||||
next: (createdLibrary) => {
|
next: (createdLibrary) => {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ export interface Library {
|
|||||||
id?: number;
|
id?: number;
|
||||||
name: string;
|
name: string;
|
||||||
icon: string;
|
icon: string;
|
||||||
|
watch: boolean;
|
||||||
sort?: SortOption;
|
sort?: SortOption;
|
||||||
paths: LibraryPath[];
|
paths: LibraryPath[];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user