add features

* feat: autojoin toggle
* feat: auto add devices
* feat: proxy feature
* feat: support puppeteer in docker
* feat: toggle to activate cloud proxy
* feat: relay device information
* feat: relay logs to cloud
* feat: migrate on start
* feat: calculate battery state, wifi signal
* feat: eye candy for configure view
* feat: update via api
This commit is contained in:
Benjamin Nussbaum 2025-02-26 09:33:54 +01:00
parent d4eb832186
commit 715e6a2562
53 changed files with 1459 additions and 460 deletions

View file

@ -10,4 +10,44 @@ class Device extends Model
use HasFactory;
protected $guarded = ['id'];
protected $casts = [
'proxy_cloud' => 'boolean',
'last_log_request' => 'json',
];
public function getBatteryPercentAttribute()
{
$volts = $this->last_battery_voltage;
// Define min and max voltage for Li-ion battery (3.0V empty, 4.2V full)
$min_volt = 3.0;
$max_volt = 4.2;
// Ensure the voltage is within range
if ($volts <= $min_volt) {
return 0;
} elseif ($volts >= $max_volt) {
return 100;
}
// Calculate percentage
$percent = (($volts - $min_volt) / ($max_volt - $min_volt)) * 100;
return round($percent);
}
public function getWifiStrenghAttribute()
{
$rssi = $this->last_rssi_level;
if ($rssi >= 0) {
return 0; // No signal (0 bars)
} elseif ($rssi <= -80) {
return 1; // Weak signal (1 bar)
} elseif ($rssi <= -60) {
return 2; // Moderate signal (2 bars)
} else {
return 3; // Strong signal (3 bars)
}
}
}

View file

@ -24,6 +24,7 @@ class User extends Authenticatable // implements MustVerifyEmail
'name',
'email',
'password',
'assign_new_devices',
];
/**
@ -46,6 +47,7 @@ class User extends Authenticatable // implements MustVerifyEmail
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
'assign_new_devices' => 'boolean',
];
}