nextav/docs/active/fixes-enhancements/LIBRARY_INTELLISENSE_FEATUR...

85 lines
3.9 KiB
Markdown

# 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)
### 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 explored
- `parentPath`: The parent directory path (null if at root)
- `items`: An array of directory items with:
- `name`: Directory name
- `path`: Full directory path
- `isDirectory`: Boolean indicating if the item is a directory
- `isAlreadyLibrary`: Boolean indicating if the directory is already added as a library
- `size`: Size of the directory
- `modified`: 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
1. Navigate to the Settings page
2. In the "Media Libraries" section, click the "Browse" button next to the library path input
3. A modal dialog will appear showing directories under `/mnt`
4. To navigate into a folder, click on the folder name
5. 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
6. The selected path will be populated in the library path input field
7. 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.