📖 Overview
This document provides a comprehensive list of all TypeScript functions in the Whitelabel module, including detailed descriptions, parameters, return types, and usage information for white-label theme management, branding configuration, and customization functionality.
🧩 Components Overview
🎨 WhitelabelComponent
File: src/app/whitelabel/whitelabel/whitelabel.component.ts
Purpose: Main component for white-label theme management providing comprehensive branding configuration, theme customization, and asset management functionality.
Extends: AppComponentClass<whitelabel, whitelabelForm>
📋 Class Properties
themeForm: FormGroup; // Reactive form for theme configuration
submitted: boolean = false; // Form submission state
responseMessage: string = ""; // Success/error message display
idTheme: any; // Current theme ID for editing
imagePreview: any; // Preview of uploaded logo image
🔄 Component Lifecycle Functions
🚀 ngOnInit(): void
Purpose: Component initialization and theme data loading
Parameters: None
Returns: void
ngOnInit(): void {
// Component lifecycle initialization
// Subscribes to route parameters to get theme ID
// Loads existing theme data for editing
// Sets up form with existing theme values
// Configures jQuery color selector handlers for UI elements
}
Key Features:
- Route parameter handling for edit mode
- Theme data pre-population
- Color selector UI enhancement
- Form initialization with validation
Implementation Details:
- Uses ActivatedRoute.paramMap to get theme ID
- Calls getTheme() service method to fetch theme data
- Pre-fills form with existing theme configuration
- Sets up jQuery event handlers for color selection dropdowns
📁 File Upload Functions
🖼️ onImagePicked(event: Event): void
Purpose: Handle logo image file selection and preview
Parameters:
event: Event- File input change event
Returns: void
onImagePicked(event: Event): void {
// Processes selected image file from file input
// Updates form with selected file
// Generates image preview using FileReader
// Validates image selection and updates form state
}
Key Features:
- File selection handling
- Image preview generation
- Form validation update
- FileReader integration
Implementation Details:
- Extracts file from HTMLInputElement
- Updates form control with selected file
- Uses FileReader to generate base64 preview
- Triggers form validation update
💾 Data Management Functions
✅ onTheme(): boolean | void
Purpose: Handle theme form submission for create/update operations
Parameters: None
Returns: boolean | void - Returns false if form is invalid, void otherwise
onTheme(): boolean | void {
// Validates form before submission
// Calls update theme service with form data and logo
// Handles success response and navigation
// Resets form after successful submission
// Shows success message with timeout
}
Key Features:
- Form validation before submission
- File upload with form data
- Success message handling
- Navigation after save
- Form reset functionality
Business Logic:
- Always performs update operation (no create mode)
- Includes logo file upload with theme data
- Automatic redirection to details view
🗑️ onDeleteTheme(id: any): void
Purpose: Handle theme deletion (placeholder implementation)
Parameters:
id: any- Theme ID to delete
Returns: void
onDeleteTheme(id: any): void {
// Currently a placeholder function for theme deletion
// Logs the theme ID to console
// Not fully implemented in current version
}
Note: This function is incomplete and only logs the ID
📋 WhitelabeldetailsComponent
File: src/app/whitelabel/whitelabeldetails/whitelabeldetails.component.ts
Purpose: Component for displaying white-label theme details in a tabular format with listing and management capabilities.
Extends: AppComponentClass<whitelabeldetails, whitelabeldetailsForm>
📋 Class Properties
filtre: string; // Filter string for search
searchText = { count: 0 }; // Search text object with count
p: number = 1; // Current page number
page = 1; // Page number for pagination
count = 0; // Total count of items
tableSize = 50; // Items per page
tableSizes = [50, 100, 150]; // Available page size options
filterTerm: string; // Filter term for data filtering
theme: any = []; // Array of theme data
🔄 Component Lifecycle Functions
🚀 ngOnInit(): void
Purpose: Initialize component and load theme data
Parameters: None
Returns: void
ngOnInit(): void {
// Component initialization
// Loads all theme data for listing
// Sets up pagination configuration
// Initializes filter and search functionality
}
Key Features:
- Theme data loading on initialization
- Pagination setup
- Search and filter initialization
- Table configuration
📊 Data Management Functions
📥 onTableDataChange(event: any): void
Purpose: Handle pagination changes for theme data table
Parameters:
event: any- Pagination event object
Returns: void
onTableDataChange(event: any): void {
// Updates current page number
// Loads data for the new page
// Handles pagination state management
}
Implementation:
- Updates page property with new page number
- Triggers data reload for pagination
- Maintains pagination state consistency
📏 onTableSizeChange(event: any): void
Purpose: Handle table page size changes
Parameters:
event: any- Page size change event
Returns: void
onTableSizeChange(event: any): void {
// Updates table size (items per page)
// Resets to first page
// Triggers data reload with new page size
}
Implementation:
- Updates tableSize with selected value
- Resets page to 1
- Reloads data with new pagination settings
⚙️ Service Functions
🔧 WhitelabelService
File: src/app/whitelabel/whitelabel.service.ts
Purpose: Core service for white-label theme operations, API communication, and data management
📥 getTheme(): Observable<any>
Purpose: Retrieve theme configuration data
Parameters: None
Returns: Observable<any> - Theme data from API
getTheme(): Observable<any> {
// Makes HTTP GET request to retrieve theme data
// Returns observable with theme configuration
// Handles API communication for theme retrieval
}
💾 updateTheme(themeData: any, logoFile: File): Observable<any>
Purpose: Update theme configuration with new data and logo
Parameters:
themeData: any- Theme configuration datalogoFile: File- Logo image file for upload
Returns: Observable<any> - Update operation result
updateTheme(themeData: any, logoFile: File): Observable<any> {
// Creates FormData for multipart upload
// Includes theme data and logo file
// Makes HTTP POST/PUT request to update theme
// Returns observable with operation result
}
Key Features:
- Multipart form data handling
- File upload integration
- Theme data serialization
- API communication management
🔄 Integration & Usage
🔗 Component Integration
The Whitelabel module integrates with several core application features:
- AppComponentClass: Extends base component functionality for form handling and lifecycle management
- Angular Forms: Uses reactive forms for theme configuration and validation
- Angular Router: Handles navigation between theme listing and editing
- File Upload: Supports logo image upload and preview functionality
- jQuery Integration: Enhances UI with color selector functionality
💼 Business Logic
- Theme Management: Complete CRUD operations for white-label themes
- Branding Control: Color scheme and logo customization
- Asset Management: File upload and preview for theme assets
- User Experience: Real-time preview and validation
🔧 Technical Features
- Reactive Forms: Form validation and state management
- File Handling: Image upload with preview functionality
- Pagination: Efficient data loading and display
- Search & Filter: Real-time data filtering capabilities
- Responsive Design: Mobile-friendly interface
📚 Usage Guidelines
👨💼 For Brand Managers
- Theme Configuration: Set up brand identity elements and color schemes
- Asset Upload: Upload brand logos and visual assets
- Preview & Test: Use preview functionality to verify theme appearance
- Theme Management: Edit and update existing themes as needed
👨💻 For Developers
- Component Extension: Extend functionality through AppComponentClass inheritance
- Service Integration: Use WhitelabelService for all API operations
- Form Handling: Follow reactive form patterns for new features
- Error Management: Implement proper error handling and user feedback
🔧 Best Practices
- Always validate theme data before submission
- Use proper file type validation for logo uploads
- Implement proper error handling for API operations
- Maintain consistent UI patterns across theme management interfaces
- Follow accessibility guidelines for color contrast and UI elements