Add software tool functionality with device connection and upgrade options

- Implemented the software tool page with user interface for connecting devices.
- Added functionality to display connection status and software upgrade options.
- Included a help modal with step-by-step instructions for users.
- Integrated error handling and user permission checks.
- Enhanced user experience with dynamic content updates and visual feedback.
This commit is contained in:
“VeLiTi”
2025-12-21 14:16:55 +01:00
parent e57e0edbc4
commit 653e33d7e9
34 changed files with 2915 additions and 169 deletions

View File

@@ -5191,4 +5191,101 @@ function updateSoftwareVersionStatus($pdo, $serialnumber = null) {
error_log('Database error in updateSoftwareVersionStatus: ' . $e->getMessage());
return false;
}
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Hardware Version Translation Functions
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
/**
* Translates hardware version to standardized format
* Examples:
* - r80, R80, 80 -> r08
* - r70, R70, 70 -> r07
* - r60, R60, 60 -> r06
* etc.
*
* @param string $hw_version - Input hardware version
* @return string - Standardized hardware version
*/
function translateHardwareVersion($hw_version) {
if (empty($hw_version) || $hw_version == '') {
return $hw_version;
}
// Remove any whitespace and convert to lowercase for processing
$hw_clean = strtolower(trim($hw_version));
// Treat all-zeros as invalid/empty hardware version
if (preg_match('/^0+$/', $hw_clean)) {
return '';
}
// Define translation mapping
$translation_map = [
// r80/R80/80 variants -> r08
'r80' => 'r08',
'80' => 'r08',
// r70/R70/70 variants -> r07
'r70' => 'r07',
'70' => 'r07',
// r60/R60/60 variants -> r06
'r60' => 'r06',
'60' => 'r06',
// Already correct format, just ensure lowercase
'r08' => 'r08',
'08' => 'r08',
'r07' => 'r07',
'07' => 'r07',
'r06' => 'r06',
'06' => 'r06',
];
// Check if we have a direct mapping
if (isset($translation_map[$hw_clean])) {
return $translation_map[$hw_clean];
}
// Handle pattern matching for other potential formats
// Extract numeric value from various formats (00000080, r90, 90, etc.)
if (preg_match('/^r?0*(\d{1,2})$/', $hw_clean, $matches)) {
$number = intval($matches[1]);
if ($number >= 10 && $number <= 99) {
// Convert to zero-padded format: 80 -> 08, 70 -> 07, etc.
// Take the tens digit and format as 0X: 80->08, 70->07, 60->06
$tensDigit = intval($number / 10);
$padded = '0' . $tensDigit;
return 'r' . $padded;
}
}
// If no translation found, return original input unchanged
return $hw_version;
}
/**
* Translates hardware version received from device/API to standardized DB format
* This should be called before storing hw_version in the database
*
* @param string $device_hw_version - Hardware version from device
* @return string - Standardized hardware version for database storage
*/
function translateDeviceHardwareVersion($device_hw_version) {
return translateHardwareVersion($device_hw_version);
}
/**
* Translates hardware version from database to match device format if needed
* This can be used for display or API responses
*
* @param string $db_hw_version - Hardware version from database
* @return string - Hardware version (currently returns same as input)
*/
function translateDbHardwareVersion($db_hw_version) {
// For now, we keep the standardized format from DB
// This function exists for future reverse translation if needed
return $db_hw_version;
}

1099
assets/softwaretool.js Normal file

File diff suppressed because it is too large Load Diff