diff --git a/automation/Scopes/HallScope.php b/automation/Scopes/HallScope.php index 62c16cc..70b11d1 100644 --- a/automation/Scopes/HallScope.php +++ b/automation/Scopes/HallScope.php @@ -33,12 +33,14 @@ "icon" => '', "description" => "Открыть люк в мансарду", "author" => "Eugene Sukhodolskiy", + "danger_level" => "cautious", ]); $this -> add_hatch_action("hatch_close", "Закрыть люк", "hatch_motor", "close", 100, [ "icon" => '', "description" => "Закрыть люк в мансарду", "author" => "Eugene Sukhodolskiy", + "danger_level" => "cautious", ]); } diff --git a/server/SHServ/Middleware/ControlScripts.php b/server/SHServ/Middleware/ControlScripts.php index 7b94e21..3649019 100644 --- a/server/SHServ/Middleware/ControlScripts.php +++ b/server/SHServ/Middleware/ControlScripts.php @@ -165,11 +165,18 @@ $attributes["filename"] = $path_info["basename"]; $attributes["author"] = $attributes["author"] ?? "Unknown author"; + $dangerLevel = $attributes["danger_level"] ?? "safe"; + if(!in_array($dangerLevel, ["safe", "cautious", "dangerous"], true)) { + $dangerLevel = "safe"; + } + $attributes["danger_level"] = $dangerLevel; + $reg ->actions[$attributes["alias"]] = [ "attributes" => $attributes, "code" => $this -> get_source_code($script), "script" => $script, - "params_schema" => $attributes["params_schema"] ?? null + "params_schema" => $attributes["params_schema"] ?? null, + "danger_level" => $dangerLevel, ]; return true; diff --git a/server/SHServ/Models/Scripts.php b/server/SHServ/Models/Scripts.php index abfe9e6..35d1fa9 100644 --- a/server/SHServ/Models/Scripts.php +++ b/server/SHServ/Models/Scripts.php @@ -162,6 +162,7 @@ "path" => $script_from_control["attributes"]["path"], "created_by" => $script_from_control["attributes"]["author"], "scope" => isset($script_from_control["attributes"]["classname"]) ? substr(strrchr($script_from_control["attributes"]["classname"], "\\"), 1) : null, + "danger_level" => $script_from_control["attributes"]["danger_level"] ?? "safe", ]; // params_schema: runtime (registry) имеет приоритет над DB diff --git a/webclient/src/components/script/ActionScriptsGrid.vue b/webclient/src/components/script/ActionScriptsGrid.vue index a18f22e..a643f46 100644 --- a/webclient/src/components/script/ActionScriptsGrid.vue +++ b/webclient/src/components/script/ActionScriptsGrid.vue @@ -4,6 +4,7 @@ v-for="script in scripts" :key="script.alias" :title="script.name" + :class="cardClass(script)" @click="goToDetail(script.alias)" >