Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
flatsiedatsie authored Jan 7, 2024
1 parent 5145fdb commit c4f9b08
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 7 deletions.
39 changes: 39 additions & 0 deletions js/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -3384,6 +3384,9 @@
}
let attached_list_el = document.getElementById('extension-power-settings-attached-devices-list-container');

if(attached_list_el){

}
var real_usb_devices_count = 0;
if(attached_list_el){

Expand Down Expand Up @@ -3471,7 +3474,43 @@
}


// User partition expanded
if(typeof body.user_partition_expanded != 'undefined'){
if(body.user_partition_expanded == false){
if(this.debug){
console.log("power settings: user partition not yet expanded");
}
if(document.getElementById('extension-power-settings-user-partition-expansion-hint') != null){
document.getElementById('extension-power-settings-user-partition-expansion-hint').style.display = 'block';
}
}
else{
if(this.debug){
console.log("power settings: user partition seems to be fully expanded");
}
if(document.getElementById('extension-power-settings-user-partition-expansion-hint') != null){
document.getElementById('extension-power-settings-user-partition-expansion-hint').style.display = 'none';
}
}
}

// Show user_partition_expansion_failed
if(typeof body['user_partition_expansion_failed'] != 'undefined'){
let partition_expansion_failed_el = document.getElementById('extension-power-settings-partition-expansion-failed');
if(partition_expansion_failed_el){
if(body['user_partition_expansion_failed'] == true){
partition_expansion_failed_el.style.display = 'block';
document.getElementById('extension-power-settings-user-partition-expansion-hint').style.display = 'block';
document.getElementById('extension-power-settings-user-partition-expansion-button').style.display = 'block';
document.getElementById('extension-power-settings-busy-expanding-user-partition').style.display = 'none';
}
else{
partition_expansion_failed_el.style.display = 'none';
}
}
}




// Show low voltage warning
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
}
},
"short_name": "Power",
"version": "3.6.7",
"version": "3.6.8",
"web_accessible_resources": [
"css/*.css",
"images/*.svg",
Expand Down
28 changes: 22 additions & 6 deletions pkg/power_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ def __init__(self, verbose=False):

# User partition expansion
self.user_partition_expanded = True
self.user_partition_expansion_failed = False
#if os.path.exists(self.boot_path + '/candle_user_partition_expanded.txt'):
# self.user_partition_expanded = True

Expand Down Expand Up @@ -1486,7 +1487,10 @@ def handle_request(self, request):
return APIResponse(
status=200,
content_type='application/json',
content=json.dumps({'state':state}),
content=json.dumps({
'state':state,
'user_partition_expansion_failed': self.user_partition_expansion_failed,
}),
)


Expand Down Expand Up @@ -1769,7 +1773,8 @@ def handle_request(self, request):
'dmesg':dmesg_lines,
'system_update_in_progress':self.system_update_in_progress,
'ro_exists':self.ro_exists,
'old_overlay_active':self.old_overlay_active
'old_overlay_active':self.old_overlay_active,
'user_partition_expansion_failed': self.user_partition_expansion_failed,
}),
)

Expand Down Expand Up @@ -2092,7 +2097,9 @@ def handle_request(self, request):
'has_cups':self.has_cups,
'printing_allowed':self.printing_allowed,
'connected_printers':self.connected_printers,
'attached_cameras':self.attached_cameras
'attached_cameras':self.attached_cameras,
'user_partition_expanded': self.user_partition_expanded,
'user_partition_expansion_failed': self.user_partition_expansion_failed
})
)

Expand Down Expand Up @@ -2217,6 +2224,7 @@ def handle_request(self, request):
'device_linux':self.device_linux.rstrip(),
'device_sd_card_size':self.device_sd_card_size,
'has_cups':self.has_cups,
'user_partition_expansion_failed': self.user_partition_expansion_failed,
'debug':self.DEBUG
}

Expand Down Expand Up @@ -3103,7 +3111,7 @@ def expand_user_partition(self):

#if not os.path.exists(self.boot_path + '/candle_user_partition_expanded.txt'):
if self.user_partition_expanded == False:
self.user_partition_expanded = True


# save information to candle_log.txt
date_string = run_command('date')
Expand Down Expand Up @@ -3132,8 +3140,16 @@ def expand_user_partition(self):
print("resize2fs_output: " + str(resize2fs_output))
print("rebooting...")

os.system('sudo touch ' + str(self.boot_path) + '/candle_user_partition_expanded.txt')
os.system('sudo reboot')

new_unused_space = int(run_command("sudo parted /dev/mmcblk0 unit B print free | grep 'Free Space' | tail -n1 | awk '{print $3}' | tr -d 'B\n'"))
#print("unused_volume_space: " + str(self.unused_volume_space))

if new_unused_space < 1000000000:
self.user_partition_expanded = True
os.system('sudo touch ' + str(self.boot_path) + '/candle_user_partition_expanded.txt')
os.system('sudo reboot')
else:
self.user_partition_expansion_failed = True

return True

Expand Down
4 changes: 4 additions & 0 deletions views/settings_pages.html
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,10 @@ <h3 id="extension-power-settings-display2-name">Display 2</h3>
<div class="extension-power-settings-spinner"><div></div><div></div><div></div><div></div></div>
<p style="text-align:center">Increasing space</p>
</div>
<div id="extension-power-settings-partition-expansion-failed" class="extension-power-settings-low-warning extension-power-settings-vlak" style="display:none">
<p style="text-align:center">Increasing space failed</p>
</div>


</div>
</div>
Expand Down

0 comments on commit c4f9b08

Please sign in to comment.