Skip to content

Commit

Permalink
Rewrite with fetch + check updated version (#579)
Browse files Browse the repository at this point in the history
* Rewrite with fetch

* Check for file accessible

* Add global log

* Tidy

* Readability

* Drop jqeury completely

* Uncomment

* translations

* Fix cores + translations

* Remove sleep
  • Loading branch information
inverse committed Jul 15, 2022
1 parent db49b63 commit 46c481d
Show file tree
Hide file tree
Showing 6 changed files with 203 additions and 337 deletions.
4 changes: 2 additions & 2 deletions .docker/rootfs/etc/nginx/nginx-ssl.conf
Expand Up @@ -54,8 +54,8 @@ http {
fastcgi_buffer_size 512k;
fastcgi_buffers 16 512k;


location /data/tasmoadmin/firmwares {
location /data/firmwares {
add_header Access-Control-Allow-Origin *;
}

location /data/tasmoadmin/ {
Expand Down
3 changes: 2 additions & 1 deletion .docker/rootfs/etc/nginx/nginx.conf
Expand Up @@ -49,7 +49,8 @@ http {
fastcgi_buffers 16 512k;


location /data/tasmoadmin/firmwares {
location /data/firmwares {
add_header Access-Control-Allow-Origin *;
}

location /data/tasmoadmin/ {
Expand Down
11 changes: 11 additions & 0 deletions tasmoadmin/lang/lang_en.ini
Expand Up @@ -433,6 +433,15 @@ BLOCK_UPDATE_START = "Trigger device update..."
BLOCK_UPDATE_ERROR_MSG = "Could not trigger update! | MSG => "
BLOCK_UPDATE_SUCCESS = "Device update triggered"
BLOCK_UPDATE_CHECK_NO_RESPONSE_MSG = "ERROR: Device did not respond!"
BLOCK_UPDATE_FINISH_SUCCESS = "Device upgrade successful"
BLOCK_UPDATE_VERSION_IS = "Version is $1"
BLOCK_UPDATE_CURRENT_VERSION_IS = "Current version is $1"
BLOCK_UPDATE_CHECKING_VERSION = "Checking version..."
BLOCK_UPDATE_ERROR_OTA_NOT_ACCESSIBLE = "Unable to access OTA URL @ $1 - $2"
BLOCK_UPDATE_ERROR_FROM_BACKEND = "Error from backend - $1"
BLOCK_UPDATE_ERROR_VERSION_COMPARE = "Failed to match version from $1"
BLOCK_UPDATE_ERROR_VERSION_COMPARE_MISMATCH = "Failed to update to $1 version is $2"


BLOCK_GLOBAL = "GLOBAL"
BLOCK_GLOBAL_ID = "ID"
Expand All @@ -457,3 +466,5 @@ UPTIME_SHORT_MIN = "m"
UPTIME_SHORT_MINS = "Minutes"
UPTIME_SHORT_SEC = "s"
UPTIME_SHORT_SECS = "Seconds"

FETCH_ERROR = "Failed to load $1 returned $2"
12 changes: 10 additions & 2 deletions tasmoadmin/pages/device_update.php
Expand Up @@ -11,6 +11,9 @@
if (!empty($_REQUEST['new_firmware_path'])) {
$ota_new_firmware_url = $otaHelper->getFirmwareUrl($_REQUEST['new_firmware_path']);
}
if (!empty($_REQUEST['target_version'])) {
$target_version = ($_REQUEST['target_version']);
}

$device_ids = $_REQUEST["device_ids"] ?? FALSE;
?>
Expand All @@ -31,14 +34,19 @@
</button>
</div>
<?php else: ?>
<div id='progressbox' class='mt-3 border border-dark p-3 pre-scrollable'>
<div id='logGlobal' class='mt-3 border p-3'>

</div>

<div id='progressbox' class='mt-3 border border-dark p-3'>

</div>

<input type='hidden' id='ota_minimal_firmware_url' value='<?php echo $ota_minimal_firmware_url ?? ""; ?>'>
<input type='hidden' id='ota_new_firmware_url' value='<?php echo $ota_new_firmware_url ?? ""; ?>'>
<input type='hidden' id='target_version' value='<?php echo $target_version ?? ""; ?>'>
<script>
var device_ids = '<?php echo json_encode($device_ids); ?>';
const device_ids = '<?php echo json_encode($device_ids); ?>';
</script>
<script src="<?php echo UrlHelper::JS("device_update"); ?>"></script>
<?php endif; ?>
Expand Down
3 changes: 2 additions & 1 deletion tasmoadmin/pages/upload.php
Expand Up @@ -289,7 +289,8 @@ class=''
>
<input type='hidden' name='minimal_firmware_path' value='<?php echo $minimal_firmware_path; ?>'>
<input type='hidden' name='new_firmware_path' value='<?php echo $new_firmware_path; ?>'>

<input type='hidden' name='target_version' value='<?php echo $result->getTagName(); ?>'>

<div class='form-row mb-3'>
<div class='offset-1 col-auto col col-auto'>
<button type='submit' class='btn btn-success' name='submit' value='submit'>
Expand Down

0 comments on commit 46c481d

Please sign in to comment.