Initial commit
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
<p-stepper>
|
||||
<p-stepperPanel header="Library Name">
|
||||
<ng-template pTemplate="content" let-nextCallback="nextCallback" let-index="index">
|
||||
<div class="flex flex-column h-21rem">
|
||||
<div
|
||||
class="border-2 border-dashed surface-border border-round surface-ground flex-auto flex justify-content-center align-items-center font-medium">
|
||||
<input
|
||||
type="text"
|
||||
pInputText
|
||||
[(ngModel)]="value"
|
||||
placeholder="Enter library name..."/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex pt-4 justify-content-end">
|
||||
<p-button
|
||||
label="Next"
|
||||
icon="pi pi-arrow-right"
|
||||
iconPos="right"
|
||||
(onClick)="nextCallback.emit()"/>
|
||||
</div>
|
||||
</ng-template>
|
||||
</p-stepperPanel>
|
||||
<p-stepperPanel header="Media Location">
|
||||
<ng-template pTemplate="content" let-prevCallback="prevCallback" let-index="index">
|
||||
<div class="flex flex-column">
|
||||
<div
|
||||
class="border-2 border-dashed surface-border border-round surface-ground flex-auto flex align-items-start"
|
||||
style="padding-top: 2.5rem;">
|
||||
<div class="flex flex-column justify-content-center align-items-center w-100">
|
||||
<p-button
|
||||
severity="secondary"
|
||||
label="Browse for media folders"
|
||||
(onClick)="show()">
|
||||
</p-button>
|
||||
<p-table [value]="folders" styleClass="p-datatable-striped" class="p-table-custom mt-3">
|
||||
<ng-template pTemplate="body" let-folder let-i="rowIndex">
|
||||
<tr>
|
||||
<td class="tr-custom">{{ folder }}</td>
|
||||
<td class="tr-custom td-x-custom">
|
||||
<p-button
|
||||
icon="pi pi-times"
|
||||
[rounded]="true"
|
||||
[text]="true"
|
||||
severity="danger"
|
||||
(onClick)="removeFolder(i)"
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
</ng-template>
|
||||
</p-table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex pt-4 justify-content-between">
|
||||
<p-button label="Back" icon="pi pi-arrow-left" (onClick)="prevCallback.emit()"/>
|
||||
<p-button severity="success" label="Save" icon="pi pi-save" (onClick)="addLibrary()"></p-button>
|
||||
</div>
|
||||
</ng-template>
|
||||
</p-stepperPanel>
|
||||
</p-stepper>
|
||||
@@ -0,0 +1,44 @@
|
||||
.container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
position: relative;
|
||||
height: 100%; /* Fills the parent container */
|
||||
}
|
||||
|
||||
.textbox {
|
||||
padding: 10px;
|
||||
margin-bottom: 20px; /* Space between textbox and button */
|
||||
}
|
||||
|
||||
.button {
|
||||
position: absolute;
|
||||
bottom: 10px;
|
||||
left: 10px;
|
||||
}
|
||||
|
||||
.tr-custom {
|
||||
padding: 0.25rem 0.5rem !important;
|
||||
border: 0px !important;
|
||||
}
|
||||
|
||||
.p-table-custom {
|
||||
margin: 1.5rem !important;
|
||||
min-width: 35rem !important;
|
||||
max-height: 11.25rem !important;
|
||||
overflow: scroll;
|
||||
}
|
||||
|
||||
.td-x-custom {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.mt-3 {
|
||||
margin-top: 1rem; /* Adds spacing between the button and the table */
|
||||
}
|
||||
|
||||
.w-100 {
|
||||
width: 100%; /* Ensures full-width alignment for consistent layout */
|
||||
}
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
import {Component} from '@angular/core';
|
||||
import {DialogService, DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {DirectoryPickerComponent} from '../directory-picker/directory-picker.component';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {LibraryService} from '../../service/library.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-library-creator',
|
||||
standalone: false,
|
||||
templateUrl: './library-creator.component.html',
|
||||
styleUrl: './library-creator.component.scss',
|
||||
providers: [MessageService]
|
||||
})
|
||||
export class LibraryCreatorComponent {
|
||||
value: string = '';
|
||||
folders: string[] = [];
|
||||
ref: DynamicDialogRef | undefined;
|
||||
|
||||
constructor(
|
||||
public dialogService: DialogService,
|
||||
private dynamicDialogRef: DynamicDialogRef,
|
||||
private messageService: MessageService,
|
||||
private libraryServiceV2: LibraryService
|
||||
) {}
|
||||
|
||||
show() {
|
||||
this.ref = this.dialogService.open(DirectoryPickerComponent, {
|
||||
header: 'Select Media Directory',
|
||||
modal: false,
|
||||
width: '50%',
|
||||
height: '75%',
|
||||
contentStyle: { overflow: 'auto' },
|
||||
baseZIndex: 10
|
||||
});
|
||||
|
||||
this.ref.onClose.subscribe((selectedFolder: string) => {
|
||||
if (selectedFolder) {
|
||||
this.addFolder(selectedFolder);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
addFolder(folder: string): void {
|
||||
this.folders.push(folder);
|
||||
}
|
||||
|
||||
removeFolder(index: number): void {
|
||||
this.folders.splice(index, 1);
|
||||
}
|
||||
|
||||
addLibrary() {
|
||||
const newLibrary = {
|
||||
name: this.value,
|
||||
paths: this.folders,
|
||||
};
|
||||
this.libraryServiceV2.createLibrary(newLibrary).subscribe({
|
||||
next: (createdLibrary) => {
|
||||
console.log('Library successfully created:', createdLibrary);
|
||||
},
|
||||
error: (err) => {
|
||||
console.error('Failed to create library:', err);
|
||||
}
|
||||
});
|
||||
this.dynamicDialogRef.close();
|
||||
}
|
||||
|
||||
validateLibraryNameAndProceed(nextCallback: any) {
|
||||
if (this.value.trim()) {
|
||||
this.libraryServiceV2.checkLibraryNameExists(this.value).subscribe(
|
||||
(response) => {
|
||||
const libraryExists = response && response.name === this.value;
|
||||
if (libraryExists) {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Library Name Exists',
|
||||
detail: 'This library name is already taken.',
|
||||
});
|
||||
} else {
|
||||
nextCallback.emit();
|
||||
}
|
||||
},
|
||||
(error) => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Error',
|
||||
detail: 'An error occurred while checking the library name.',
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user