dynamic config
This commit is contained in:
@@ -139,7 +139,7 @@ class ConfigController extends Controller {
|
||||
"width" => 1920,
|
||||
"height" => 1080,
|
||||
"banner" => "Have a nice day!",
|
||||
"bb_color_rgb" => [
|
||||
"bb_color_rgb" => [
|
||||
"detect" => [0, 250, 150],
|
||||
"recog" => [255, 0, 0]
|
||||
]
|
||||
@@ -203,6 +203,34 @@ class ConfigController extends Controller {
|
||||
if (Yii::$app->request->post()) {
|
||||
$post = Yii::$app->request->post();
|
||||
Yii::$app->response->format = "json";
|
||||
$cfgData = $post['config'];
|
||||
$config_json = [];
|
||||
foreach ($cfgData as $key => $value) {
|
||||
if (is_numeric($value['data'])) {
|
||||
$value['data'] = floatval($value['data']);
|
||||
}
|
||||
|
||||
$pr = explode("|", $value['parent']);
|
||||
if (count($pr) == 1) {
|
||||
if ($pr[0] === "")
|
||||
$config_json[$value['key']] = $value['data'];
|
||||
else
|
||||
$config_json[$pr[0]][$value['key']] = $value['data'];
|
||||
}
|
||||
if (count($pr) == 2) {
|
||||
$config_json[$pr[0]][$pr[1]][$value['key']] = $value['data'];
|
||||
}
|
||||
if (count($pr) == 3) {
|
||||
$config_json[$pr[0]][$pr[1]][$pr[2]][$value['key']] = $value['data'];
|
||||
}
|
||||
if (count($pr) == 4) {
|
||||
$config_json[$pr[0]][$pr[1]][$pr[2]][$pr[3]][$value['key']] = $value['data'];
|
||||
}
|
||||
if (count($pr) == 5) {
|
||||
$config_json[$pr[0]][$pr[1]][$pr[2]][$pr[3]][$pr[4]][$value['key']] = $value['data'];
|
||||
}
|
||||
}
|
||||
|
||||
$options = [
|
||||
'http' => [
|
||||
'header' => "Content-Type: application/json",
|
||||
@@ -224,7 +252,7 @@ class ConfigController extends Controller {
|
||||
'content' => json_encode([
|
||||
'path' => $engineConfig['data']['engines'][0]['path'],
|
||||
'config' => $engineConfig,
|
||||
'configEngine' => $post['config']
|
||||
'configEngine' => $config_json
|
||||
])
|
||||
]
|
||||
]));
|
||||
@@ -261,8 +289,8 @@ class ConfigController extends Controller {
|
||||
if ($checkConfig['status'])
|
||||
$config_json = json_decode($checkConfig['data'], true);
|
||||
|
||||
return $this->render('cau-hinh-nhan-dien', [
|
||||
"config_json" => $config_json
|
||||
return $this->render('config', [
|
||||
"config_json" => \app\widgets\ConfigTree::widget(['configLists' => $config_json, 'isRoot' => true, 'parent_id' => 'node', 'parent_key' => ''])
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user