Components & Directives
Reusable Angular components and directives for storage management
Storage Components & Directives
๐ฏ Overview
Our storage system includes a comprehensive set of reusable Angular components and directives that make it incredibly easy to add advanced storage functionality to any application.
Key Features
- โ Right-Click Configuration: Instant storage setup with UX Portal integration
- โ Modular Components: Break down complex storage UIs into manageable pieces
- โ Enterprise-Grade: Professional data visualization and management tools
- โ Zero Configuration: Works out of the box with intelligent defaults
- โ TypeScript Ready: Full type safety with Angular 20 standalone APIs
๐ฏ Storage Configuration Directive
Quick Start
The uxStorageConfig directive provides instant right-click storage configuration for any element:
import { StorageConfigDirective } from '@storage/angular';
@Component({
imports: [StorageConfigDirective],
template: `
<!-- Right-click to configure storage -->
<div uxStorageConfig="user/profile">
User profile content
</div>
<!-- With custom options -->
<div uxStorageConfig="app/settings"
[storageOptions]="{
autoSync: true,
collection: 'app-data',
database: 'g-space-db-ent',
strategy: 'durable',
enableFirebase: true
}">
Application settings
</div>
`
})
export class MyComponent {}
Configuration Options
interface StorageOptions {
autoSync?: boolean; // Enable automatic cloud sync
collection?: string; // Firebase collection name
database?: 'g-space-db-standard' | 'g-space-db-ent';
namespace?: string; // Storage namespace
strategy?: 'speed' | 'balanced' | 'durable';
enableFirebase?: boolean; // Enable Firebase integration
}
Portal Features
When you right-click on an element with the directive, you get:
- ๐ Current Data Preview: See the current stored data for the key
- โ๏ธ Strategy Selection: Choose Speed, Balanced, or Durable strategies
- ๐ฅ Firebase Configuration: Enable/disable cloud sync with collection settings
- ๐พ Quick Operations: Load, Save, Delete, and Clear data operations
- ๐ Storage Statistics: Real-time adapter, strategy, and namespace info
๐ Data Visualization Components
Collection Data Visualizer
Professional data visualization with multiple view formats:
import { CollectionDataVisualizerComponent } from '@storage/angular';
@Component({
imports: [CollectionDataVisualizerComponent],
template: `
<ux-collection-data-visualizer
[collectionName]="collectionName"
[collectionData]="collectionData"
[collectionStats]="collectionStats"
[isLoading]="isLoading"
(importData)="onImportData()"
(exportData)="onExportData()"
(clearData)="onClearData()"
(viewDocument)="onViewDocument($event)"
(editDocument)="onEditDocument($event)"
(deleteDocument)="onDeleteDocument($event)">
</ux-collection-data-visualizer>
`
})
export class DataManagementComponent {
collectionName = signal('user-data');
collectionData = signal<CollectionDocument[]>([]);
collectionStats = signal<CollectionStats | null>(null);
isLoading = signal(false);
}
View Formats
- ๐ Table View: Professional data table with sortable columns and row selection
- ๐ JSON View: Clean, syntax-highlighted JSON formatting
- ๐ณ Tree View: Hierarchical display for nested document structures
- ๐ Advanced Search: Real-time filtering across all document content
Features
- โ Document Selection: Multi-select with checkboxes
- โ Real-time Statistics: Document count, total size, last updated
- โ Export Functionality: Download data as JSON with metadata
- โ Individual Actions: View, edit, delete specific documents
๐๏ธ Collection Management Components
Collection Manager
Easy collection selection and management:
import { CollectionManagerComponent } from '@storage/angular';
@Component({
imports: [CollectionManagerComponent],
template: `
<ux-collection-manager
[availableCollections]="availableCollections"
[selectedCollection]="selectedCollection"
[selectedDatabase]="selectedDatabase"
[isDiscoveringCollections]="isDiscovering"
(databaseChange)="onDatabaseChange($event)"
(collectionChange)="onCollectionChange($event)"
(discoverCollections)="onDiscoverCollections()"
(createNewCollection)="onCreateNewCollection($event)"
(switchToCollection)="onSwitchToCollection($event)"
(loadAllData)="onLoadAllData()"
(analyzeSchema)="onAnalyzeSchema()">
</ux-collection-manager>
`
})
export class CollectionComponent {}
Features
- โ Database Switching: Switch between Standard and Enterprise databases
- โ Auto-Discovery: Find existing collections automatically
- โ One-Click Creation: Create new collections with welcome messages
- โ Connection Status: Real-time connection and operation feedback
๐ ๏ธ Advanced Collection Tools
Advanced Tools Component
Enterprise-grade data management tools:
import { AdvancedCollectionToolsComponent } from '@storage/angular';
@Component({
imports: [AdvancedCollectionToolsComponent],
template: `
<ux-advanced-collection-tools
[collectionName]="collectionName"
[selectedDocuments]="selectedDocuments"
(inspectSchema)="onInspectSchema()"
(executeBulkOperation)="onExecuteBulkOperation($event)"
(compareCollections)="onCompareCollections($event)"
(analyzePerformance)="onAnalyzePerformance()"
(openMigrationTool)="onOpenMigrationTool($event)"
(toggleRealtimeMonitoring)="onToggleRealtimeMonitoring($event)">
</ux-advanced-collection-tools>
`
})
export class AdvancedDataComponent {}
Tool Categories
๐ Schema Inspector
- Field Type Analysis: Identify all field types across documents
- Common Field Detection: Find fields present in most documents
- Data Quality Issues: Detect inconsistencies and mixed types
- Coverage Analysis: See which fields are consistently populated
- Recommendations: Get actionable insights for schema improvements
๐ฆ Bulk Operations
- Export Selected: Download multiple documents with metadata
- Delete Selected: Safe bulk deletion with confirmation
- Migrate Selected: Move documents between collections
- Progress Tracking: Monitor operation progress for large datasets
โ๏ธ Collection Comparison
- Document Count Comparison: Compare sizes between collections
- Schema Differences: Identify structural differences
- Content Analysis: Find similarities and differences in data
- Performance Comparison: Compare read/write performance
๐ Performance Analytics
- Real-time Metrics: Monitor read and write response times
- Success Rate Analysis: Track operation success rates
- Trend Analysis: Monitor performance changes over time
- Bottleneck Detection: Identify performance issues
๐ฎ Complete Integration Example
All Components Together
Here's how to use all components together for a complete storage management interface:
import { Component, signal } from '@angular/core';
import {
StorageConfigDirective,
CollectionDataVisualizerComponent,
CollectionManagerComponent,
AdvancedCollectionToolsComponent
} from '@storage/angular';
@Component({
selector: 'app-storage-dashboard',
imports: [
StorageConfigDirective,
CollectionDataVisualizerComponent,
CollectionManagerComponent,
AdvancedCollectionToolsComponent
],
template: `
<div class="storage-dashboard">
<!-- Right-click anywhere for storage config -->
<div uxStorageConfig="dashboard/main">
<!-- Collection Management -->
<ux-collection-manager
[availableCollections]="collections"
[selectedCollection]="selectedCollection"
(collectionChange)="onCollectionChange($event)">
</ux-collection-manager>
<!-- Data Visualization -->
<ux-collection-data-visualizer
[collectionName]="selectedCollection"
[collectionData]="collectionData"
(importData)="loadData()">
</ux-collection-data-visualizer>
<!-- Advanced Tools -->
<ux-advanced-collection-tools
[collectionName]="selectedCollection"
[selectedDocuments]="selectedDocs"
(analyzePerformance)="analyzePerformance()">
</ux-advanced-collection-tools>
</div>
</div>
`
})
export class StorageDashboardComponent {
collections = signal(['users', 'products', 'orders']);
selectedCollection = signal('users');
collectionData = signal([]);
selectedDocs = signal([]);
}
๐ Integration with Mock API
Storage Configuration Endpoints
Our Mock API integration includes comprehensive storage configuration endpoints:
import { enableStorageConfigEndpoints } from '@mock-api/storage';
// app.config.ts
providers: [
provideMockAPIService({
enabled: true,
mocks: {
...enableStorageConfigEndpoints(),
// Your other endpoints...
}
})
]
Available Endpoints
GET /api/storage/config: Get current storage configurationPUT /api/storage/config: Update storage configurationGET /api/storage/stats: Get performance statisticsGET /api/storage/data/:key: Get data by keyPUT /api/storage/data/:key: Save dataDELETE /api/storage/data/:key: Delete dataGET /api/storage/keys: List storage keysDELETE /api/storage/clear: Clear storage dataGET /api/storage/health: System health checkPOST /api/storage/firebase/sync: Firebase sync simulationGET /api/storage/analytics: Storage analytics
๐ฏ Best Practices
1. Component Organization
// โ
GOOD: Separate concerns with focused components
@Component({
template: `
<!-- Collection management -->
<ux-collection-manager></ux-collection-manager>
<!-- Data visualization -->
<ux-collection-data-visualizer></ux-collection-data-visualizer>
<!-- Advanced operations -->
<ux-advanced-collection-tools></ux-advanced-collection-tools>
`
})
// โ AVOID: One massive component handling everything
@Component({
template: `<div><!-- 2000+ lines of mixed functionality --></div>`
})
2. Right-Click Configuration
// โ
GOOD: Semantic storage keys with appropriate options
<div uxStorageConfig="user/preferences"
[storageOptions]="{ strategy: 'durable', enableFirebase: true }">
// โ
GOOD: Different strategies for different data types
<div uxStorageConfig="cache/temp-data"
[storageOptions]="{ strategy: 'speed', autoSync: false }">
// โ AVOID: Generic keys without context
<div uxStorageConfig="data1">
3. Event Handling
// โ
GOOD: Handle component events appropriately
onAnalyzePerformance(): void {
// Get real performance metrics
const stats = this.storage.getPerformanceStats();
const microStats = this.storage.getMicroCacheStats();
// Display results or update UI
this.showPerformanceResults(stats, microStats);
}
// โ AVOID: Ignoring component events
onAnalyzePerformance(): void {
// Do nothing - wastes user interaction
}
๐ Component API Reference
CollectionDataVisualizerComponent
Inputs
collectionName: Signal<string>- Name of the collection to visualizecollectionData: Signal<CollectionDocument[]>- Array of documents to displaycollectionStats: Signal<CollectionStats | null>- Collection statisticsisLoading: Signal<boolean>- Loading state indicator
Outputs
importData: EventEmitter<void>- Triggered when import is requestedexportData: EventEmitter<void>- Triggered when export is requestedclearData: EventEmitter<void>- Triggered when clear is requestedviewDocument: EventEmitter<CollectionDocument>- Document view requesteditDocument: EventEmitter<CollectionDocument>- Document edit requestdeleteDocument: EventEmitter<string>- Document deletion request
CollectionManagerComponent
Inputs
availableCollections: Signal<string[]>- List of available collectionsselectedCollection: Signal<string>- Currently selected collectionselectedDatabase: Signal<DatabaseType>- Currently selected databaseisDiscoveringCollections: Signal<boolean>- Discovery loading state
Outputs
databaseChange: EventEmitter<DatabaseType>- Database selection changecollectionChange: EventEmitter<string>- Collection selection changediscoverCollections: EventEmitter<void>- Discover collections requestcreateNewCollection: EventEmitter<string>- New collection creationswitchToCollection: EventEmitter<string>- Collection switch request
AdvancedCollectionToolsComponent
Inputs
collectionName: Signal<string>- Current collection nameselectedDocuments: Signal<string[]>- Selected document keys
Outputs
inspectSchema: EventEmitter<void>- Schema inspection requestexecuteBulkOperation: EventEmitter<BulkOperation>- Bulk operation requestcompareCollections: EventEmitter<CollectionComparison>- Comparison requestanalyzePerformance: EventEmitter<void>- Performance analysis request
๐จ Styling and Theming
CSS Custom Properties
Components use CSS custom properties for easy theming:
:root {
--storage-primary-color: #3b82f6;
--storage-success-color: #10b981;
--storage-warning-color: #f59e0b;
--storage-danger-color: #ef4444;
--storage-border-radius: 8px;
--storage-spacing: 1rem;
}
Component Classes
Each component includes semantic CSS classes for custom styling:
/* Collection Manager */
.collection-manager .collection-select { /* ... */ }
.collection-manager .btn-create { /* ... */ }
/* Data Visualizer */
.collection-data-visualizer .data-table { /* ... */ }
.collection-data-visualizer .json-view { /* ... */ }
/* Advanced Tools */
.advanced-collection-tools .tool-card { /* ... */ }
.advanced-collection-tools .bulk-controls { /* ... */ }
๐งช Testing Integration
Component Testing
// component.spec.ts
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { CollectionDataVisualizerComponent } from '@storage/angular';
describe('CollectionDataVisualizerComponent', () => {
let component: CollectionDataVisualizerComponent;
let fixture: ComponentFixture<CollectionDataVisualizerComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [CollectionDataVisualizerComponent]
}).compileComponents();
fixture = TestBed.createComponent(CollectionDataVisualizerComponent);
component = fixture.componentInstance;
});
it('should create', () => {
expect(component).toBeTruthy();
});
it('should emit importData event', () => {
spyOn(component.importData, 'emit');
component.onImportData();
expect(component.importData.emit).toHaveBeenCalled();
});
});
Directive Testing
// directive.spec.ts
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { StorageConfigDirective } from '@storage/angular';
@Component({
template: '<div uxStorageConfig="test/key">Test content</div>',
imports: [StorageConfigDirective]
})
class TestComponent {}
describe('StorageConfigDirective', () => {
let fixture: ComponentFixture<TestComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [TestComponent]
}).compileComponents();
fixture = TestBed.createComponent(TestComponent);
});
it('should respond to right-click', () => {
const divElement = fixture.nativeElement.querySelector('div');
const event = new MouseEvent('contextmenu', { bubbles: true });
divElement.dispatchEvent(event);
// Test portal opening logic
});
});
๐ Production Deployment
Library Build
# Build storage libraries with components
yarn nx build storage-core storage-angular
# Verify exports
yarn nx build ux-test --dry-run
App Integration
// app.config.ts - Complete setup
import {
provideGgStorage,
StorageConfigDirective,
CollectionDataVisualizerComponent,
CollectionManagerComponent,
AdvancedCollectionToolsComponent
} from '@storage/angular';
export const appConfig: ApplicationConfig = {
providers: [
// Storage system with all features
...provideGgStorage({
namespace: 'production-app',
strategy: 'balanced',
performance: {
adaptiveStrategy: true,
redundancy: true,
monitoring: true,
batchProcessing: true
}
}),
// Other providers...
]
};
// Import components in your modules
@Component({
imports: [
StorageConfigDirective,
CollectionDataVisualizerComponent,
CollectionManagerComponent,
AdvancedCollectionToolsComponent
]
})
export class ProductionComponent {}
๐ฏ Live Examples
Try the Components
Visit these live examples in the UX Test app:
- Storage Directive Demo - Right-click configuration
- Easy Integration Demo - Simple integration examples
- Complete Integration - All components working together
- Firebase Production Demo - Enterprise-grade Firebase management
- API Sync Demo - REST API integration
- Firestore Sync Demo - Real Firebase sync
What You Can Do
- โ Right-click any demo card to configure storage settings
- โ Test all view formats (Table, JSON, Tree) for data visualization
- โ Try bulk operations with document selection and export
- โ Analyze schemas to understand document structure and quality
- โ Monitor performance with real-time analytics and metrics
๐ Summary
Our storage components and directives provide:
๐ฏ For Developers
- Zero Configuration: Components work out of the box
- Full Customization: Every aspect can be configured
- Type Safety: Complete TypeScript support
- Modern Architecture: Angular 20 standalone components with signals
๐จ For Users
- Intuitive Interface: Right-click configuration feels natural
- Professional UI: Enterprise-grade visual design
- Real-time Feedback: Instant visual updates and status indicators
- Powerful Tools: Advanced data management capabilities
๐ข For Enterprise
- Production Ready: Battle-tested components with comprehensive error handling
- Scalable: Handles large datasets and complex operations
- Secure: Built-in data validation and safe operations
- Maintainable: Modular architecture with clear separation of concerns
Your storage system now includes world-class UI components that make data management intuitive, powerful, and enjoyable! ๐
Documentation updated: January 28, 2025
Components ready for production deployment โญ