raspberrydisplay v2 init

This commit is contained in:
Luca Haid
2026-02-03 15:52:55 +01:00
parent 0cdb2140a9
commit 68e86f74f8
4 changed files with 241 additions and 232 deletions

View File

@@ -114,11 +114,10 @@ class RaspberryDisplayModel
}
}
// Set defaults
if ($model->group_order === null) {
$model->group_order = 0;
}
if ($model->monitor_size === null) {
if (!in_array($model->monitor_size, ['27', '42', '55', '65'])) {
$model->monitor_size = '27';
}
if ($model->hdmi_port === null) {
@@ -166,15 +165,30 @@ class RaspberryDisplayModel
{
$db = FronkDB::singleton();
$data = $model->data;
$data = [
'display_label' => $model->display_label,
'hostname' => $model->hostname,
'ip_address' => $model->ip_address,
'display_url' => $model->display_url,
'group_name' => $model->group_name,
'group_order' => (int)$model->group_order,
'monitor_size' => in_array($model->monitor_size, ['27', '42', '55', '65']) ? $model->monitor_size : '27',
'hdmi_port' => (int)$model->hdmi_port,
'agent_port' => (int)$model->agent_port,
'custom_style' => $model->custom_style,
'create_by' => $model->create_by,
'edit_by' => $model->edit_by,
];
$forceStr = ['monitor_size'];
if ($model->id) {
$data['edit'] = time();
$db->update("RaspberryDisplay", $data, "id=" . (int)$model->id);
$db->update("RaspberryDisplay", $data, "id=" . (int)$model->id, $forceStr);
} else {
$data['create'] = time();
$data['edit'] = time();
$model->id = $db->insert("RaspberryDisplay", $data);
$model->id = $db->insert("RaspberryDisplay", $data, $forceStr);
}
return $model;