devices_weebi 1.0.5+1
devices_weebi: ^1.0.5+1 copied to clipboard
Comprehensive device management package for Weebi POS system with CRUD operations based on ChainRights permissions.
Devices Weebi #
Comprehensive device management package for Weebi POS system with CRUD operations based on ChainRights permissions.
Overview #
This package provides complete device management functionality for the Weebi ecosystem, including:
- Device Chaining: Link new POS devices to boutiques during initial setup
- Device Management: Full CRUD operations for existing devices
- Permission-based Access: All operations respect ChainRights permissions
- Intuitive UI: Ready-to-use widgets with modern Material Design
Features #
π Device Chaining #
- Generate pairing codes for new device enrollment
- Select from accessible boutiques (server-filtered)
- Support for multi-chain organizations
- Real-time code generation with copy-to-clipboard
π± Device Management #
- List all devices across accessible chains
- Search and filter devices by name or hardware info
- Update device passwords
- Delete devices with confirmation
- Group devices by boutique for better organization
π Permission System #
Based on ChainRights with granular control:
- Create (
Right.create): Generate pairing codes - Read (
Right.read): View device lists - Update (
Right.update): Modify device settings - Delete (
Right.delete): Remove devices
π¨ UI Components #
DeviceChainingWidget: Standalone device chaining interfaceDeviceManagementWidget: Complete device management with tabs- Responsive design with search, filtering, and grouping
- Error handling and loading states
Quick Start #
1. Add to your app #
dependencies:
devices_weebi:
path: ../packages/devices
2. Setup providers #
MultiProvider(
providers: [
ChangeNotifierProvider(create: (_) => AccessTokenProvider()),
ChangeNotifierProvider(create: (_) => BoutiqueProvider(fenceServiceClient)),
ChangeNotifierProvider(create: (_) => DeviceProvider(fenceServiceClient)),
],
child: MyApp(),
)
3. Use the widgets #
Device Chaining (for new device setup)
DeviceChainingWidget(
onDeviceChained: (boutique, code) {
// Handle successful chaining
print('Device chained to ${boutique.displayName} with code: $code');
},
onCancel: () => Navigator.pop(context),
)
Full Device Management
DeviceManagementWidget() // That's it! Handles everything automatically
Architecture #
DeviceProvider #
Central state management for all device operations:
// Permission checks
bool get canCreateDevice;
bool get canReadDevices;
bool get canUpdateDevice;
bool get canDeleteDevice;
// CRUD operations
Future<String?> generatePairingCode(String chainId, String boutiqueId);
Future<void> loadDevices(String chainId);
Future<bool> updateDevicePassword(Device device, String password);
Future<bool> deleteDevice(Device device);
// Utility methods
List<Device> searchDevices(String query);
List<Device> getDevicesForBoutique(String boutiqueId);
List<Device> get activeDevices;
Permission Requirements #
| Operation | Required Permission | Description |
|---|---|---|
| Generate pairing code | ChainRight.create |
Create new device enrollment codes |
| View devices | ChainRight.read |
List and search existing devices |
| Update password | ChainRight.update |
Modify device settings |
| Delete device | ChainRight.delete |
Permanently remove devices |
Backend Integration #
The package integrates with these gRPC endpoints:
generateCodeForPairingDevice- Create pairing codescreateDevice- Complete device enrollmentreadDevices- List devices for a chainupdateDevicePassword- Update device credentialsdeleteOneDevice- Remove devices
Examples #
See example/device_management_example.dart for complete implementation examples including:
- Full app setup with providers
- Standalone device chaining
- Direct DeviceProvider usage
- Permission handling
Dependencies #
flutter: UI frameworkprovider: State managementprotos_weebi: gRPC protocol definitionsauth_weebi: Authentication and permissionsboutiques_weebi: Boutique and chain data
Notes #
Future Enhancements #
- Device Movement: Transfer devices between boutiques (currently shows "contact support")
- Device Status Toggle: Enable/disable devices (currently shows "contact support")
- Batch Operations: Select and operate on multiple devices
- Device Analytics: Usage statistics and health monitoring
Security #
- All operations require appropriate ChainRights
- Server validates permissions on every request
- Sensitive operations (delete) require confirmation
- Pairing codes expire automatically
Support #
For issues or questions:
- Check the example implementation
- Verify your ChainRights permissions
- Ensure proper provider setup
- Contact the Weebi development team