fix: serialize native account form lists and refresh user grants
This commit is contained in:
1 parent
f58e0125cd
commit
8965a649d2
6 files changed
+130
-22
No files matched your search
+2
-2
@@ -16,7 +16,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "Button",
|
"type": "Button",
|
||||||
"caption": "Designer in der Konsole öffnen",
|
"caption": "Designer im Browser öffnen",
|
||||||
"onClick": "echo NFSC_OpenDesigner($id);",
|
"onClick": "echo NFSC_OpenDesigner($id);",
|
||||||
"link": true
|
"link": true
|
||||||
},
|
},
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
"caption": "Alle Anmeldungen beenden und Designer öffnen",
|
"caption": "Alle Anmeldungen beenden und Designer öffnen",
|
||||||
"onClick": "echo NFSC_RotateAccessToken($id);",
|
"onClick": "echo NFSC_RotateAccessToken($id);",
|
||||||
"link": true,
|
"link": true,
|
||||||
"confirm": "Alle Benutzer dieser Instanz werden abgemeldet. Der Konsolen-Designer wird anschließend neu geöffnet. Fortfahren?"
|
"confirm": "Alle Benutzer dieser Instanz werden abgemeldet. Der Designer wird anschließend im Browser neu geöffnet. Fortfahren?"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"status": [
|
"status": [
|
||||||
|
|||||||
@@ -12,17 +12,17 @@ trait NextFloorUsers
|
|||||||
$account = $this->accounts()[$id] ?? [];
|
$account = $this->accounts()[$id] ?? [];
|
||||||
$catalog = $this->accessCatalog();
|
$catalog = $this->accessCatalog();
|
||||||
$level = ['type' => 'Select', 'options' => [['caption' => 'Nur ansehen', 'value' => 'view'], ['caption' => 'Ansehen und bedienen', 'value' => 'control']]];
|
$level = ['type' => 'Select', 'options' => [['caption' => 'Nur ansehen', 'value' => 'view'], ['caption' => 'Ansehen und bedienen', 'value' => 'control']]];
|
||||||
$grants = static function (string $name, string $caption, array $options, array $values) use ($level): array {
|
$grants = function (string $name, string $caption, array $options, array $values): array {
|
||||||
foreach ($values as $v) if (!in_array($v['target'], array_column($options, 'value'), true)) $options[] = ['caption' => '(Nicht mehr im Plan) ' . $v['target'], 'value' => $v['target']];
|
|
||||||
return ['type' => 'List', 'name' => $name, 'caption' => $caption, 'rowCount' => 5, 'add' => true, 'delete' => true, 'values' => $values,
|
return ['type' => 'List', 'name' => $name, 'caption' => $caption, 'rowCount' => 5, 'add' => true, 'delete' => true, 'values' => $values,
|
||||||
'columns' => [['name' => 'target', 'caption' => 'Freigabe', 'width' => 'auto', 'add' => '', 'edit' => ['type' => 'Select', 'options' => [['caption' => 'Bitte auswählen', 'value' => ''], ...$options]]],
|
'columns' => $this->planGrantColumns($options, $values)];
|
||||||
['name' => 'access', 'caption' => 'Recht', 'width' => '190px', 'add' => 'view', 'edit' => $level]]];
|
|
||||||
};
|
};
|
||||||
$userForm = ['type' => 'ExpansionPanel', 'caption' => 'Benutzer und Zugriffsrechte', 'expanded' => true, 'items' => [
|
$userForm = ['type' => 'ExpansionPanel', 'caption' => 'Benutzer und Zugriffsrechte', 'expanded' => true, 'items' => [
|
||||||
['type' => 'ValidationTextBox', 'caption' => 'Direkter Zugang (an die Symcon-Adresse anhängen)', 'value' => '/hook/' . $this->hookPath() . '/', 'enabled' => false],
|
['type' => 'ValidationTextBox', 'caption' => 'Direkter Zugang (an die Symcon-Adresse anhängen)', 'value' => '/hook/' . $this->hookPath() . '/', 'enabled' => false],
|
||||||
['type' => 'Button', 'caption' => 'Anmeldeseite öffnen', 'link' => true, 'onClick' => 'echo NFSC_OpenLogin($id);'],
|
['type' => 'Button', 'caption' => 'Anmeldeseite öffnen', 'link' => true, 'onClick' => 'echo NFSC_OpenLogin($id);'],
|
||||||
['type' => 'Select', 'name' => 'AccountSelect', 'caption' => 'Benutzer auswählen', 'value' => $id, 'options' => $this->accountOptions(), 'onChange' => 'NFSC_SelectAccessUser($id, $AccountSelect);'],
|
['type' => 'Select', 'name' => 'AccountSelect', 'caption' => 'Benutzer auswählen', 'value' => $id, 'options' => $this->accountOptions(), 'onChange' => 'NFSC_SelectAccessUser($id, $AccountSelect);'],
|
||||||
['type' => 'ValidationTextBox', 'name' => 'AccountName', 'caption' => 'Benutzername', 'value' => $account['name'] ?? ''],
|
['type' => 'ValidationTextBox', 'name' => 'AccountName', 'caption' => 'Benutzername', 'value' => $account['name'] ?? ''],
|
||||||
|
['type' => 'PasswordTextBox', 'name' => 'AccountPassword', 'caption' => 'Neues Passwort (leer = bestehendes behalten)', 'value' => ''],
|
||||||
|
['type' => 'Button', 'name' => 'AccountReset', 'caption' => 'Passwort zurücksetzen', 'enabled' => $id !== '', 'onClick' => 'echo NFSC_ResetUserPassword($id, $AccountSelect, $AccountPassword);'],
|
||||||
['type' => 'CheckBox', 'name' => 'AccountEnabled', 'caption' => 'Zugang aktiv', 'value' => $account['enabled'] ?? true],
|
['type' => 'CheckBox', 'name' => 'AccountEnabled', 'caption' => 'Zugang aktiv', 'value' => $account['enabled'] ?? true],
|
||||||
['type' => 'Select', 'name' => 'AccountRole', 'caption' => 'Rolle', 'value' => $account['role'] ?? 'user', 'options' => [['caption' => 'Benutzer · Ansicht und freigegebene Bedienung', 'value' => 'user'], ['caption' => 'Admin · vollständiger Zugriff und Editor', 'value' => 'admin']]],
|
['type' => 'Select', 'name' => 'AccountRole', 'caption' => 'Rolle', 'value' => $account['role'] ?? 'user', 'options' => [['caption' => 'Benutzer · Ansicht und freigegebene Bedienung', 'value' => 'user'], ['caption' => 'Admin · vollständiger Zugriff und Editor', 'value' => 'admin']]],
|
||||||
['type' => 'CheckBox', 'name' => 'AccountViewAll', 'caption' => 'Alle Zustände ansehen', 'value' => $account['view_all'] ?? false],
|
['type' => 'CheckBox', 'name' => 'AccountViewAll', 'caption' => 'Alle Zustände ansehen', 'value' => $account['view_all'] ?? false],
|
||||||
@@ -32,12 +32,17 @@ trait NextFloorUsers
|
|||||||
['type' => 'List', 'name' => 'AccountObjects', 'caption' => 'Weitere Symcon-Geräte / Datenpunkte (optional)', 'rowCount' => 4, 'add' => true, 'delete' => true, 'values' => $account['objects'] ?? [],
|
['type' => 'List', 'name' => 'AccountObjects', 'caption' => 'Weitere Symcon-Geräte / Datenpunkte (optional)', 'rowCount' => 4, 'add' => true, 'delete' => true, 'values' => $account['objects'] ?? [],
|
||||||
'columns' => [['name' => 'target', 'caption' => 'Objekt aus dem Objektbaum', 'width' => 'auto', 'add' => 0, 'edit' => ['type' => 'SelectObject']],
|
'columns' => [['name' => 'target', 'caption' => 'Objekt aus dem Objektbaum', 'width' => 'auto', 'add' => 0, 'edit' => ['type' => 'SelectObject']],
|
||||||
['name' => 'access', 'caption' => 'Recht', 'width' => '190px', 'add' => 'view', 'edit' => $level]]],
|
['name' => 'access', 'caption' => 'Recht', 'width' => '190px', 'add' => 'view', 'edit' => $level]]],
|
||||||
['type' => 'PasswordTextBox', 'name' => 'AccountPassword', 'caption' => 'Neues Passwort (leer = bestehendes behalten)', 'value' => ''],
|
['type' => 'Button', 'caption' => 'Benutzer speichern', 'onClick' => [
|
||||||
['type' => 'Button', 'caption' => 'Benutzer speichern', 'onClick' => 'echo NFSC_SaveAccessUser($id, $AccountSelect, $AccountName, $AccountRole, $AccountEnabled, $AccountViewAll, $AccountControlAll, json_encode($AccountRooms), json_encode($AccountDevices), json_encode($AccountObjects), $AccountPassword);'],
|
// Native List variables implement iteration/ArrayAccess; direct JSON encoding does not serialize their rows.
|
||||||
['type' => 'Button', 'name' => 'AccountReset', 'caption' => 'Passwort zurücksetzen', 'enabled' => $id !== '', 'onClick' => 'echo NFSC_ResetUserPassword($id, $AccountSelect, $AccountPassword);'],
|
'$rooms = []; foreach ($AccountRooms as $row) { $rooms[] = ["target" => $row["target"], "access" => $row["access"]]; }',
|
||||||
|
'$devices = []; foreach ($AccountDevices as $row) { $devices[] = ["target" => $row["target"], "access" => $row["access"]]; }',
|
||||||
|
'$objects = []; foreach ($AccountObjects as $row) { $objects[] = ["target" => $row["target"], "access" => $row["access"]]; }',
|
||||||
|
'echo NFSC_SaveAccessUser($id, $AccountSelect, $AccountName, $AccountRole, $AccountEnabled, $AccountViewAll, $AccountControlAll, json_encode($rooms), json_encode($devices), json_encode($objects), $AccountPassword);',
|
||||||
|
]],
|
||||||
['type' => 'Button', 'name' => 'AccountRevoke', 'caption' => 'Benutzer abmelden', 'enabled' => $id !== '', 'onClick' => 'echo NFSC_RevokeUserSessions($id, $AccountSelect);'],
|
['type' => 'Button', 'name' => 'AccountRevoke', 'caption' => 'Benutzer abmelden', 'enabled' => $id !== '', 'onClick' => 'echo NFSC_RevokeUserSessions($id, $AccountSelect);'],
|
||||||
['type' => 'Button', 'name' => 'AccountDelete', 'caption' => 'Benutzer löschen', 'enabled' => $id !== '', 'confirm' => 'Diesen NextFloor-Benutzer einschließlich seiner Zugänge löschen?', 'onClick' => 'echo NFSC_DeleteAccessUser($id, $AccountSelect);'],
|
['type' => 'Button', 'name' => 'AccountDelete', 'caption' => 'Benutzer löschen', 'enabled' => $id !== '', 'confirm' => 'Diesen NextFloor-Benutzer einschließlich seiner Zugänge löschen?', 'onClick' => 'echo NFSC_DeleteAccessUser($id, $AccountSelect);'],
|
||||||
['type' => 'PopupButton', 'caption' => 'ⓘ Rechte und Passwörter', 'popup' => ['caption' => 'Zugriffsrechte', 'items' => [
|
['type' => 'PopupButton', 'caption' => 'ⓘ Rechte und Passwörter', 'popup' => ['caption' => 'Zugriffsrechte', 'items' => [
|
||||||
|
['type' => 'Label', 'caption' => 'Die Auswahl eines Benutzers lädt dessen Einstellungen und alle drei Freigabetabellen. Änderungen werden erst durch Benutzer speichern übernommen; beim Wechsel werden nicht gespeicherte Eingaben verworfen. Das Passwortfeld wird bei jedem Wechsel geleert.'],
|
||||||
['type' => 'Label', 'caption' => 'Admins dürfen den Editor und alle Geräte verwenden. Die Benutzerverwaltung bleibt ausschließlich in der Symcon-Konfiguration.'],
|
['type' => 'Label', 'caption' => 'Admins dürfen den Editor und alle Geräte verwenden. Die Benutzerverwaltung bleibt ausschließlich in der Symcon-Konfiguration.'],
|
||||||
['type' => 'Label', 'caption' => 'Alle Zustände ansehen ohne weitere Bedienfreigabe ist ein Zugang nur zum Lesen. Einzelne Raum- und Gerätefreigaben ergänzen diese Grundrechte. Ohne Freigabe bleibt das Gebäude sichtbar, seine Zustände werden nicht übertragen.'],
|
['type' => 'Label', 'caption' => 'Alle Zustände ansehen ohne weitere Bedienfreigabe ist ein Zugang nur zum Lesen. Einzelne Raum- und Gerätefreigaben ergänzen diese Grundrechte. Ohne Freigabe bleibt das Gebäude sichtbar, seine Zustände werden nicht übertragen.'],
|
||||||
['type' => 'Label', 'caption' => 'Eine Raumfreigabe umfasst seine verknüpften Werte, Geräte im Raum und die zugeordneten Bereichskategorien. Gerätefreigaben gelten für deren verknüpfte Datenpunkte. Bei automatischen Gerätezuordnungen die benötigten Symcon-Objekte zusätzlich auswählen oder feste Verknüpfungen im Editor setzen.'],
|
['type' => 'Label', 'caption' => 'Eine Raumfreigabe umfasst seine verknüpften Werte, Geräte im Raum und die zugeordneten Bereichskategorien. Gerätefreigaben gelten für deren verknüpfte Datenpunkte. Bei automatischen Gerätezuordnungen die benötigten Symcon-Objekte zusätzlich auswählen oder feste Verknüpfungen im Editor setzen.'],
|
||||||
@@ -57,15 +62,26 @@ trait NextFloorUsers
|
|||||||
return $options;
|
return $options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function planGrantColumns(array $options, array $values): array
|
||||||
|
{
|
||||||
|
foreach ($values as $v) if (!in_array($v['target'], array_column($options, 'value'), true)) $options[] = ['caption' => '(Nicht mehr im Plan) ' . $v['target'], 'value' => $v['target']];
|
||||||
|
return [['name' => 'target', 'caption' => 'Freigabe', 'width' => 'auto', 'add' => '', 'edit' => ['type' => 'Select', 'options' => [['caption' => 'Bitte auswählen', 'value' => ''], ...$options]]],
|
||||||
|
['name' => 'access', 'caption' => 'Recht', 'width' => '190px', 'add' => 'view', 'edit' => ['type' => 'Select', 'options' => [['caption' => 'Nur ansehen', 'value' => 'view'], ['caption' => 'Ansehen und bedienen', 'value' => 'control']]]]];
|
||||||
|
}
|
||||||
|
|
||||||
public function SelectAccessUser(string $UserID): void
|
public function SelectAccessUser(string $UserID): void
|
||||||
{
|
{
|
||||||
$a = $this->accounts()[$UserID] ?? [];
|
$a = $this->accounts()[$UserID] ?? [];
|
||||||
if (!$a) $UserID = '';
|
if (!$a) $UserID = '';
|
||||||
$this->WriteAttributeString('SelectedAccount', $UserID);
|
$this->WriteAttributeString('SelectedAccount', $UserID);
|
||||||
|
$catalog = $this->accessCatalog();
|
||||||
$this->UpdateFormField('AccountSelect', 'options', json_encode($this->accountOptions()));
|
$this->UpdateFormField('AccountSelect', 'options', json_encode($this->accountOptions()));
|
||||||
foreach (['AccountSelect' => $UserID, 'AccountName' => $a['name'] ?? '', 'AccountEnabled' => $a['enabled'] ?? true,
|
foreach (['AccountSelect' => $UserID, 'AccountName' => $a['name'] ?? '', 'AccountEnabled' => $a['enabled'] ?? true,
|
||||||
'AccountRole' => $a['role'] ?? 'user', 'AccountViewAll' => $a['view_all'] ?? false, 'AccountControlAll' => $a['control_all'] ?? false, 'AccountPassword' => ''] as $name => $value) $this->UpdateFormField($name, 'value', $value);
|
'AccountRole' => $a['role'] ?? 'user', 'AccountViewAll' => $a['view_all'] ?? false, 'AccountControlAll' => $a['control_all'] ?? false, 'AccountPassword' => ''] as $name => $value) $this->UpdateFormField($name, 'value', $value);
|
||||||
foreach (['AccountRooms' => 'rooms', 'AccountDevices' => 'devices', 'AccountObjects' => 'objects'] as $name => $key) $this->UpdateFormField($name, 'values', json_encode($a[$key] ?? []));
|
foreach (['AccountRooms' => 'rooms', 'AccountDevices' => 'devices', 'AccountObjects' => 'objects'] as $name => $key) {
|
||||||
|
if ($key !== 'objects') $this->UpdateFormField($name, 'columns', json_encode($this->planGrantColumns($catalog[$key], $a[$key] ?? [])));
|
||||||
|
$this->UpdateFormField($name, 'values', json_encode($a[$key] ?? []));
|
||||||
|
}
|
||||||
foreach (['AccountReset', 'AccountRevoke', 'AccountDelete'] as $name) $this->UpdateFormField($name, 'enabled', $UserID !== '');
|
foreach (['AccountReset', 'AccountRevoke', 'AccountDelete'] as $name) $this->UpdateFormField($name, 'enabled', $UserID !== '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ require_once __DIR__ . '/libs/Permissions.php';
|
|||||||
* NextFloor for IP-Symcon.
|
* NextFloor for IP-Symcon.
|
||||||
*
|
*
|
||||||
* One visualization instance owns a floor-plan project. Its protected WebHook serves the designer as
|
* One visualization instance owns a floor-plan project. Its protected WebHook serves the designer as
|
||||||
* a console tab and the same viewer in an HTML-SDK tile iframe. Admins receive the native object tree;
|
* a browser tab and the same viewer in an HTML-SDK tile iframe. Admins receive the native object tree;
|
||||||
* user sessions receive only authorized live bindings. Object selections always use named choices.
|
* user sessions receive only authorized live bindings. Object selections always use named choices.
|
||||||
*/
|
*/
|
||||||
class NextFloor extends IPSModuleStrict
|
class NextFloor extends IPSModuleStrict
|
||||||
@@ -88,7 +88,7 @@ class NextFloor extends IPSModuleStrict
|
|||||||
return 'WebHook registriert: /hook/' . $this->hookPath() . '. Jetzt den Designer öffnen.';
|
return 'WebHook registriert: /hook/' . $this->hookPath() . '. Jetzt den Designer öffnen.';
|
||||||
}
|
}
|
||||||
|
|
||||||
/** URL returned to the console form. It opens in a console tab, as IPSView does. */
|
/** Browser link returned to the console form; link: does not create a native Pro Console tab. */
|
||||||
public function OpenDesigner(): string
|
public function OpenDesigner(): string
|
||||||
{
|
{
|
||||||
$this->requireWebHook();
|
$this->requireWebHook();
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
# NextFloor für IP-Symcon 9.0
|
# NextFloor für IP-Symcon 9.0
|
||||||
|
|
||||||
Dieses Verzeichnis ist eine vollständige IP-Symcon-Bibliothek. Der gleiche NextFloor-Designer
|
Dieses Verzeichnis ist eine vollständige IP-Symcon-Bibliothek. NextFloor lässt sich
|
||||||
läuft damit in zwei Symcon-Oberflächen:
|
über den Designer und die Kachel-Visualisierung verwenden:
|
||||||
|
|
||||||
- **Designer:** Die Instanzkonfiguration öffnet den Designer per geschütztem WebHook in einem
|
- **Designer:** Die Instanzkonfiguration öffnet den Designer per geschütztem WebHook in einem
|
||||||
eigenen Konsolen-/Browser-Tab – derselbe Ansatz, den auch IPSView für seinen Designer nutzt.
|
Browser-Tab. Auch die installierte Pro-Konsole öffnet diesen Link im Standardbrowser.
|
||||||
|
IPSViews interner Designer-Tab ist speziell in Symcons Konsole integriert; die öffentliche
|
||||||
|
Modulschnittstelle von Symcon 9.0 bietet diesen Tab nicht für eigene Web-Oberflächen an.
|
||||||
- **Kachel-Visualisierung:** Die NextFloor-Instanz kann direkt in der Tile-Visualisierung als
|
- **Kachel-Visualisierung:** Die NextFloor-Instanz kann direkt in der Tile-Visualisierung als
|
||||||
HTML-SDK-Kachel abgelegt werden. Sie zeigt die 3D-Ansicht samt Bedienung.
|
HTML-SDK-Kachel abgelegt werden. Sie zeigt die 3D-Ansicht samt Bedienung.
|
||||||
|
|
||||||
@@ -16,7 +18,7 @@ In **Kerninstanzen → Modules** wird dieses Repository verwendet:
|
|||||||
|
|
||||||
Im Zahnrad des Eintrags den Branch **`symcon`** wählen und auf Aktualisierungen prüfen.
|
Im Zahnrad des Eintrags den Branch **`symcon`** wählen und auf Aktualisierungen prüfen.
|
||||||
`main` enthält die Quellen für die Entwicklung, `symcon` die installierbare Bibliothek.
|
`main` enthält die Quellen für die Entwicklung, `symcon` die installierbare Bibliothek.
|
||||||
Nach der Aktualisierung auf **0.3.1 / Build 35** die Konsole neu laden. Unter
|
Nach der Aktualisierung auf **0.3.2 / Build 36** die Konsole neu laden. Unter
|
||||||
**Instanz hinzufügen → Hersteller NextFloor** erscheint **„NextFloor Designer und 3D-Kachel“**.
|
**Instanz hinzufügen → Hersteller NextFloor** erscheint **„NextFloor Designer und 3D-Kachel“**.
|
||||||
|
|
||||||
### Für die Entwicklung
|
### Für die Entwicklung
|
||||||
@@ -65,8 +67,16 @@ Dieselbe Prüfung lässt sich separat mit `node symcon/tests/validate-package.mj
|
|||||||
Sie ist dauerhaft und enthält kein Zugangs-Token. Die Adresse steht außerdem
|
Sie ist dauerhaft und enthält kein Zugangs-Token. Die Adresse steht außerdem
|
||||||
im Formular: `/hook/nextfloor/<Instanz-ID>/` an der Symcon-Serveradresse.
|
im Formular: `/hook/nextfloor/<Instanz-ID>/` an der Symcon-Serveradresse.
|
||||||
|
|
||||||
|
Das Passwortfeld steht direkt unter dem Benutzernamen. Beim Benutzerwechsel werden
|
||||||
|
Rolle, Schalter und alle drei Freigabetabellen mit den gespeicherten Werten dieses
|
||||||
|
Benutzers neu befüllt; das Passwortfeld wird geleert. Die Auswahl **Neuen Benutzer
|
||||||
|
anlegen** leert die Tabellen. Änderungen werden erst mit **Benutzer speichern**
|
||||||
|
übernommen; ein Wechsel verwirft noch nicht gespeicherte Eingaben. Seit 0.3.2 werden
|
||||||
|
die nativen Formularlisten zeilenweise übertragen, auch wenn sie leer sind oder
|
||||||
|
gerade keine Zeile ausgewählt ist.
|
||||||
|
|
||||||
Die Konten gehören zur jeweiligen NextFloor-Instanz. Die Benutzerverwaltung
|
Die Konten gehören zur jeweiligen NextFloor-Instanz. Die Benutzerverwaltung
|
||||||
bleibt ausschließlich in der Symcon-Konfiguration. **Designer in der Konsole
|
bleibt ausschließlich in der Symcon-Konfiguration. **Designer im Browser
|
||||||
öffnen** ermöglicht dem Symcon-Administrator weiterhin den vollständigen Zugang,
|
öffnen** ermöglicht dem Symcon-Administrator weiterhin den vollständigen Zugang,
|
||||||
auch wenn kein NextFloor-Admin mehr angemeldet ist oder alle Konten gesperrt sind.
|
auch wenn kein NextFloor-Admin mehr angemeldet ist oder alle Konten gesperrt sind.
|
||||||
Der dabei erzeugte Konsolen-Link gilt 90 Sekunden und kann einmal verwendet werden.
|
Der dabei erzeugte Konsolen-Link gilt 90 Sekunden und kann einmal verwendet werden.
|
||||||
@@ -571,7 +581,7 @@ Nach dem Update den Designer neu laden, damit die neue Übertragung auf beiden S
|
|||||||
### Update bei „Hook not found“
|
### Update bei „Hook not found“
|
||||||
|
|
||||||
Das vollständige Modul auf 0.2.1 aktualisieren und die NextFloor-Instanzkonfiguration
|
Das vollständige Modul auf 0.2.1 aktualisieren und die NextFloor-Instanzkonfiguration
|
||||||
neu öffnen. Einmal **„WebHook reparieren“**, anschließend **„Designer in der Konsole öffnen“**
|
neu öffnen. Einmal **„WebHook reparieren“**, anschließend **„Designer im Browser öffnen“**
|
||||||
anklicken. Der Eintrag gehört unter **WebHook Control → Hooks (Intern)**; ein eigener
|
anklicken. Der Eintrag gehört unter **WebHook Control → Hooks (Intern)**; ein eigener
|
||||||
PHP-Skript-Hook unter „Benutzerdefiniert“ ist nicht erforderlich. Die bestehende Instanz
|
PHP-Skript-Hook unter „Benutzerdefiniert“ ist nicht erforderlich. Die bestehende Instanz
|
||||||
nicht neu anlegen, da ihr Plan in ihren Attributen gespeichert ist.
|
nicht neu anlegen, da ihr Plan in ihren Attributen gespeichert ist.
|
||||||
@@ -600,7 +610,7 @@ nicht neu anlegen, da ihr Plan in ihren Attributen gespeichert ist.
|
|||||||
## Einrichtung
|
## Einrichtung
|
||||||
|
|
||||||
1. Eine **NextFloor**-Instanz anlegen.
|
1. Eine **NextFloor**-Instanz anlegen.
|
||||||
2. In ihrer Konfiguration auf **„Designer in der Konsole öffnen“** klicken und den Grundriss
|
2. In ihrer Konfiguration auf **„Designer im Browser öffnen“** klicken und den Grundriss
|
||||||
anlegen.
|
anlegen.
|
||||||
3. Für die Anzeige in der Tile-Visualisierung die Instanz wie jede andere Visualisierungs-
|
3. Für die Anzeige in der Tile-Visualisierung die Instanz wie jede andere Visualisierungs-
|
||||||
Instanz als Kachel hinzufügen.
|
Instanz als Kachel hinzufügen.
|
||||||
|
|||||||
+3
-3
@@ -6,7 +6,7 @@
|
|||||||
"compatibility": {
|
"compatibility": {
|
||||||
"version": "9.0"
|
"version": "9.0"
|
||||||
},
|
},
|
||||||
"version": "0.3.1",
|
"version": "0.3.2",
|
||||||
"build": 35,
|
"build": 36,
|
||||||
"date": 1794787200
|
"date": 1794873600
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
require __DIR__ . '/support/access-runtime.php';
|
||||||
|
$module = new AccessFixtureModule(); initializeAccessFixture($module);
|
||||||
|
$method = static fn(string $name, mixed ...$args): mixed => (new ReflectionMethod($module, $name))->invoke($module, ...$args);
|
||||||
|
|
||||||
|
// Like a native List variable, this object is iterable/array-accessible but does not JSON-encode its rows.
|
||||||
|
final class NativeFormList implements IteratorAggregate, ArrayAccess
|
||||||
|
{
|
||||||
|
public function __construct(private array $rows) {}
|
||||||
|
public function getIterator(): Traversable { foreach ($this->rows as $row) yield new ArrayObject($row); }
|
||||||
|
public function offsetExists(mixed $offset): bool { return isset($this->rows[$offset]); }
|
||||||
|
public function offsetGet(mixed $offset): mixed { return $this->rows[$offset] ?? null; }
|
||||||
|
public function offsetSet(mixed $offset, mixed $value): void { throw new LogicException('Readonly fixture'); }
|
||||||
|
public function offsetUnset(mixed $offset): void { throw new LogicException('Readonly fixture'); }
|
||||||
|
}
|
||||||
|
function NFSC_SaveAccessUser(int $id, string $user, string $name, string $role, bool $enabled, bool $view, bool $control, string $rooms, string $devices, string $objects, string $password): string
|
||||||
|
{
|
||||||
|
global $module;
|
||||||
|
return $module->SaveAccessUser($user, $name, $role, $enabled, $view, $control, $rooms, $devices, $objects, $password);
|
||||||
|
}
|
||||||
|
function NFSC_SelectAccessUser(int $id, string $user): void { global $module; $module->SelectAccessUser($user); }
|
||||||
|
function formItems(): array
|
||||||
|
{
|
||||||
|
global $module;
|
||||||
|
$form = json_decode($module->GetConfigurationForm(), true, 512, JSON_THROW_ON_ERROR);
|
||||||
|
return array_values(array_filter($form['actions'], static fn(array $a): bool => ($a['type'] ?? '') === 'ExpansionPanel'))[0]['items'];
|
||||||
|
}
|
||||||
|
function clickSave(string $script, array $fields): string
|
||||||
|
{
|
||||||
|
extract($fields);
|
||||||
|
$id = 12345;
|
||||||
|
ob_start();
|
||||||
|
try { eval($script); return (string) ob_get_contents(); }
|
||||||
|
finally { ob_end_clean(); }
|
||||||
|
}
|
||||||
|
$items = formItems();
|
||||||
|
$names = array_column($items, 'name');
|
||||||
|
check(array_search('AccountPassword', $names, true) === array_search('AccountName', $names, true) + 1, 'Password belongs directly below the user name');
|
||||||
|
$save = array_values(array_filter($items, static fn(array $item): bool => ($item['caption'] ?? '') === 'Benutzer speichern'))[0]['onClick'];
|
||||||
|
$script = is_array($save) ? implode("\n", $save) : $save;
|
||||||
|
$fields = ['AccountSelect' => '', 'AccountName' => 'form-empty', 'AccountRole' => 'user', 'AccountEnabled' => true,
|
||||||
|
'AccountViewAll' => true, 'AccountControlAll' => false, 'AccountPassword' => 'form-test-password',
|
||||||
|
'AccountRooms' => new NativeFormList([]), 'AccountDevices' => new NativeFormList([]), 'AccountObjects' => new NativeFormList([])];
|
||||||
|
check(json_encode($fields['AccountRooms']) === '{}', 'Fixture reproduces the unsupported direct List serialization');
|
||||||
|
check(str_starts_with(clickSave($script, $fields), 'Benutzer gespeichert.'), 'The actual save button accepts empty native form lists');
|
||||||
|
$emptyID = $module->fields['AccountSelect']['value'];
|
||||||
|
$empty = $method('accounts')[$emptyID];
|
||||||
|
check($empty['rooms'] === [] && $empty['devices'] === [] && $empty['objects'] === [], 'Empty tables remain empty');
|
||||||
|
|
||||||
|
$rooms = [['target' => 'room:eg:office2', 'access' => 'view'], ['target' => 'room:old:removed', 'access' => 'control']];
|
||||||
|
$devices = [['target' => 'furniture:eg:wallbox', 'access' => 'control']];
|
||||||
|
$objects = [['target' => 900, 'access' => 'view'], ['target' => 104, 'access' => 'view']];
|
||||||
|
$fields = [...$fields, 'AccountName' => 'form-scoped', 'AccountViewAll' => false,
|
||||||
|
'AccountRooms' => new NativeFormList($rooms), 'AccountDevices' => new NativeFormList($devices), 'AccountObjects' => new NativeFormList($objects)];
|
||||||
|
check(str_starts_with(clickSave($script, $fields), 'Benutzer gespeichert.'), 'The actual save button serializes every row, including rows that are not selected');
|
||||||
|
$scopedID = $module->fields['AccountSelect']['value'];
|
||||||
|
$scoped = $method('accounts')[$scopedID];
|
||||||
|
check($scoped['rooms'] === $rooms && $scoped['devices'] === $devices && $scoped['objects'] === $objects, 'All three grant tables retain exact per-user rights');
|
||||||
|
|
||||||
|
$change = array_values(array_filter($items, static fn(array $item): bool => ($item['name'] ?? '') === 'AccountSelect'))[0]['onChange'];
|
||||||
|
$select = static function (string $selected) use ($change): void { $id = 12345; $AccountSelect = $selected; eval($change); };
|
||||||
|
$select($emptyID);
|
||||||
|
foreach (['AccountRooms', 'AccountDevices', 'AccountObjects'] as $name) check(json_decode($module->fields[$name]['values'], true) === [], 'Switching to an unrestricted reader clears the previous grants');
|
||||||
|
check($module->fields['AccountName']['value'] === 'form-empty' && $module->fields['AccountPassword']['value'] === '', 'User changes load the right name and clear the password field');
|
||||||
|
check(!in_array('room:old:removed', array_column(json_decode($module->fields['AccountRooms']['columns'], true)[0]['edit']['options'], 'value'), true), 'Stale target choices do not leak into another user');
|
||||||
|
$select($scopedID);
|
||||||
|
foreach (['AccountRooms' => $rooms, 'AccountDevices' => $devices, 'AccountObjects' => $objects] as $name => $expected) check(json_decode($module->fields[$name]['values'], true) === $expected, 'Each table restores the selected user');
|
||||||
|
check(in_array('room:old:removed', array_column(json_decode($module->fields['AccountRooms']['columns'], true)[0]['edit']['options'], 'value'), true), 'Previously linked missing plan targets remain visible when switching users');
|
||||||
|
$fields = [...$fields, 'AccountSelect' => $scopedID, 'AccountPassword' => ''];
|
||||||
|
check(str_starts_with(clickSave($script, $fields), 'Benutzer gespeichert.'), 'Saving an existing user permits an empty password');
|
||||||
|
check(password_verify('form-test-password', $method('accounts')[$scopedID]['password']), 'Empty password preserves the previous hash');
|
||||||
|
check(str_starts_with(clickSave($script, [...$fields, 'AccountSelect' => '', 'AccountName' => 'no-password']), 'Für neue Benutzer'), 'New accounts still require a password');
|
||||||
|
$select('');
|
||||||
|
foreach (['AccountRooms', 'AccountDevices', 'AccountObjects'] as $name) check(json_decode($module->fields[$name]['values'], true) === [], 'New user selection resets every grant table');
|
||||||
|
check(!$module->fields['AccountReset']['enabled'] && !$module->fields['AccountDelete']['enabled'], 'New user selection disables existing-account operations');
|
||||||
|
check($module->SaveAccessUser($emptyID, 'form-empty', 'user', true, true, false, '{"target":"room:eg:office2","access":"control"}', '[]', '[]', '') === 'Ungültige Freigabeliste.', 'A selected row cannot be mistaken for the complete grants list');
|
||||||
|
|
||||||
|
$form = json_decode($module->GetConfigurationForm(), true);
|
||||||
|
check($form['actions'][1]['caption'] === 'Designer im Browser öffnen' && $form['actions'][1]['link'] === true, 'The browser link does not promise a native Pro Console tab');
|
||||||
|
echo "OK: real form save with opaque iterable Lists; empty/multiple grants; user-switch reload/reset and missing-target choices; password position and preservation; honest browser action\n";
|
||||||
Reference in new issue
Block a user