7.0 KiB
Device Operations Specification
ADDED Requirements
Requirement: Reboot Device
The system SHALL provide the ability to reboot an IoT device via its IMEI.
Scenario: Successfully reboot device
- WHEN an authenticated user initiates a reboot operation on a device with valid IMEI
- THEN the system sends the reboot command to the device
- AND returns a success response with operation confirmation
Scenario: Reboot operation with confirmation
- WHEN a user clicks the reboot device button
- THEN the system prompts for confirmation with a warning message
- AND only proceeds if the user confirms the action
Scenario: Reboot with invalid IMEI
- WHEN a user attempts to reboot a device with invalid or non-existent IMEI
- THEN the system returns a 400 error with appropriate error message
Requirement: Reset Device to Factory Settings
The system SHALL provide the ability to reset an IoT device to factory settings via its IMEI.
Scenario: Successfully reset device
- WHEN an authenticated user initiates a factory reset operation on a device
- THEN the system sends the reset command to the device
- AND returns a success response
Scenario: Reset operation with strong confirmation
- WHEN a user clicks the factory reset button
- THEN the system displays a warning dialog explaining data loss
- AND requires user confirmation before proceeding
- AND only executes if the user explicitly confirms
Scenario: Insufficient permissions for reset
- WHEN a user without proper permissions attempts to reset a device
- THEN the system returns a 403 forbidden error
Requirement: Set Device Speed Limit
The system SHALL provide the ability to configure upload and download speed limits for an IoT device.
Scenario: Successfully set speed limit
- WHEN an authenticated user submits valid speed limit parameters
- THEN the system applies the upload and download speed limits to the device
- AND returns a success response
Scenario: Configure speed limits via dialog
- WHEN a user selects the speed limit option
- THEN the system displays a dialog with input fields for upload_speed and download_speed (KB/s)
- AND validates that both values are integers >= 1
Scenario: Invalid speed limit parameters
- WHEN a user submits speed limits less than 1 KB/s
- THEN the system returns a 400 parameter error
- AND displays validation error messages
Requirement: Switch Device SIM Card
The system SHALL provide the ability to switch the active SIM card on a multi-SIM device.
Scenario: Successfully switch to target card
- WHEN an authenticated user initiates a card switch with valid target ICCID
- THEN the system switches the device to use the specified card
- AND returns a success response
Scenario: Switch card via dialog
- WHEN a user selects the switch card option
- THEN the system displays a dialog prompting for target_iccid
- AND validates the ICCID format
Scenario: Switch to non-existent card
- WHEN a user attempts to switch to an ICCID that doesn't exist or isn't available
- THEN the system returns a 400 error with descriptive message
Requirement: Configure Device WiFi Settings
The system SHALL provide the ability to configure WiFi settings including SSID, password, and enabled status.
Scenario: Successfully configure WiFi
- WHEN an authenticated user submits valid WiFi configuration
- THEN the system applies the WiFi settings to the device
- AND returns a success response
Scenario: Configure WiFi via dialog
- WHEN a user selects the WiFi configuration option
- THEN the system displays a dialog with fields for:
- enabled (启用状态: 0=禁用, 1=启用)
- ssid (WiFi名称, 1-32 characters)
- password (WiFi密码, 8-63 characters)
- AND validates all field constraints
Scenario: Invalid WiFi parameters
- WHEN a user submits WiFi configuration with invalid parameters
- THEN the system returns a 400 error
- AND displays specific validation errors (e.g., "SSID too long", "Password too short")
Requirement: Device Management UI Integration
The system SHALL integrate device operations into the device management page at /asset-management/devices.
Scenario: Display primary operation button
- WHEN a user views the device management page
- THEN the system displays a "重启设备" (Reboot Device) button as the primary operation
Scenario: Display dropdown menu for additional operations
- WHEN a user views the device management page
- THEN the system displays a "更多操作" (More Operations) dropdown menu
- AND the dropdown contains: 恢复出厂, 设置限速, 切换SIM卡, 设置WiFi
Scenario: Show loading indicator during operations
- WHEN a device operation is in progress
- THEN the system displays a loading indicator
- AND disables the operation buttons to prevent duplicate requests
Requirement: Authentication and Authorization
The system SHALL enforce JWT-based authentication for all device operations.
Scenario: Access with valid JWT token
- WHEN a user makes a request with a valid Bearer token
- THEN the system processes the request normally
Scenario: Access with expired token
- WHEN a user makes a request with an expired JWT token
- THEN the system returns a 401 unauthorized error
- AND redirects to the login page
Requirement: Error Handling and User Feedback
The system SHALL provide clear error messages and success notifications for all operations.
Scenario: Display success message
- WHEN a device operation completes successfully
- THEN the system displays a success message notification
- AND automatically closes the operation dialog
Scenario: Handle network errors
- WHEN a network error occurs during a device operation
- THEN the system displays a user-friendly error message
- AND allows the user to retry the operation
Scenario: Handle server errors
- WHEN a 500 server error occurs
- THEN the system displays an error message with timestamp
- AND logs the error for debugging
Requirement: Operation Confirmation Dialogs
The system SHALL require user confirmation for destructive operations.
Scenario: Confirm reboot operation
- WHEN a user initiates a reboot
- THEN the system shows a confirmation dialog stating "确定要重启该设备吗?"
- AND requires explicit confirmation
Scenario: Confirm factory reset operation
- WHEN a user initiates a factory reset
- THEN the system shows a strong warning dialog stating "确定要恢复出厂设置吗?此操作将清除所有数据!"
- AND requires explicit confirmation
Scenario: No confirmation for query operations
- WHEN a user initiates speed limit, card switch, or WiFi configuration
- THEN the system displays input dialogs without confirmation prompts
- AND only executes after user submits valid parameters