3.9 KiB
3.9 KiB
IntelliSense Feature for Library Management
Overview
This feature enhances the library management experience by providing an intelligent folder selection interface when adding new libraries. It lists directories under /mnt and allows users to easily navigate and select folders, while preventing the addition of duplicate libraries.
Features Implemented
1. IntelliSense API Endpoint
- Location:
/api/libraries/intellisense - Functionality:
- Lists directories under a specified base path (default:
/mnt) - Identifies which directories are already added as libraries
- Provides structured JSON response with directory information
- Supports navigation through directory hierarchy
- Includes file metadata (size, modification date)
- Lists directories under a specified base path (default:
2. Enhanced Settings UI
- Browse Button: Added a "Browse" button next to the library path input field
- Modal Interface: Opens a modal dialog for folder selection when "Browse" is clicked
- Navigation: Allows users to navigate through directory structure by clicking on folders
- Visual Indicators: Greys out and disables selection of folders already added as libraries
- Path Display: Shows the current path being explored
- Separate Selection: Each folder item has a dedicated "Select" button to choose it as a library root
- Current Path Selection: Option to select the currently displayed directory as a library
3. Library Conflict Prevention
- Automatically detects if a folder is already added as a library
- Prevents re-adding existing libraries through the UI
- Clearly indicates which folders are already libraries
Technical Implementation
API Endpoint
The IntelliSense API endpoint (/api/libraries/intellisense) accepts the following query parameters:
basePath: The base directory to explore (default:/mnt)subPath: A subdirectory path to explore within the base path
The response includes:
path: The current directory path being exploredparentPath: The parent directory path (null if at root)items: An array of directory items with:name: Directory namepath: Full directory pathisDirectory: Boolean indicating if the item is a directoryisAlreadyLibrary: Boolean indicating if the directory is already added as a librarysize: Size of the directorymodified: Last modification date
Frontend Integration
The settings page was modified to include:
- State management for IntelliSense items and UI visibility
- Functions to fetch and display directory listings
- Modal dialog for folder selection with navigation capabilities
- Dedicated "Select" buttons for each folder item
- Integration with existing library management functionality
Usage Instructions
- Navigate to the Settings page
- In the "Media Libraries" section, click the "Browse" button next to the library path input
- A modal dialog will appear showing directories under
/mnt - To navigate into a folder, click on the folder name
- To select a folder as a library root:
- Click the "Select" button next to the folder name, OR
- Click "Select as Library" next to the current path display
- The selected path will be populated in the library path input field
- Click "Add" to add the library
Navigation Features
- Folder Navigation: Click on any folder name to navigate into that directory
- Parent Navigation: Use the ".." entry or the "Back to /mnt" button to navigate up
- Current Directory Selection: Use the "Select as Library" button next to the path display to select the currently viewed directory
- Direct Selection: Each folder has a dedicated "Select" button to choose it as a library root without navigating into it
Testing
The feature has been thoroughly tested with:
- Directory listing functionality
- Library conflict detection
- UI interaction and navigation
- Edge cases and error handling
- Navigation through directory hierarchy
All tests pass successfully, confirming that the IntelliSense feature works as expected.