diff --git a/controllers/ConfigController.php b/controllers/ConfigController.php
index e309875b..d481a3b5 100644
--- a/controllers/ConfigController.php
+++ b/controllers/ConfigController.php
@@ -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' => ''])
]);
}
}
diff --git a/views/config/cau-hinh-nhan-dien.tpl b/views/config/cau-hinh-nhan-dien.tpl
deleted file mode 100644
index 39bd52da..00000000
--- a/views/config/cau-hinh-nhan-dien.tpl
+++ /dev/null
@@ -1,732 +0,0 @@
-{extends file=$smarty.current_dir|cat:'/../extends.tpl'}
-{use class="yii\helpers\Url"}
-{use class="yii\grid\GridView"}
-{use class="app\assets\ConfigAsset"}
-{ConfigAsset::register($this)|void}
-{block name='content'}
-
-
-
-
-
-
-
-
-
1
-
- Cấu hình máy chủ
-
-
Server config
-
-
-
2
-
- Cấu hình nhận diện
-
-
Engine config
-
-
-
-
-
-
-
-
- {$username=Yii::$app->user->identity->username}
-
-
-
-
-
-
-
-{/block}
\ No newline at end of file
diff --git a/views/config/config.tpl b/views/config/config.tpl
new file mode 100644
index 00000000..df42e07a
--- /dev/null
+++ b/views/config/config.tpl
@@ -0,0 +1,178 @@
+{extends file=$smarty.current_dir|cat:'/../extends.tpl'}
+{use class="yii\helpers\Url"}
+{use class="yii\grid\GridView"}
+{use class="app\assets\ConfigAsset"}
+{ConfigAsset::register($this)|void}
+{block name='content'}
+
+
+
+
+
+
+
+
+
1
+
+ Cấu hình máy chủ
+
+
Server config
+
+
+
2
+
+ Cấu hình nhận diện
+
+
Engine config
+
+
+
+
+
+
+
+
+ {$config_json}
+
+
+
+
+
+
+{/block}
\ No newline at end of file
diff --git a/web/js/config.js b/web/js/config.js
index e9b3a25e..75ee6176 100644
--- a/web/js/config.js
+++ b/web/js/config.js
@@ -57,134 +57,21 @@ function saveStep1(e) {
});
}
function saveStep2(e) {
- var config_json = {
- "camera": {
- "auto_check": parseInt($("#text-c11").html()),
- "num_cam": parseInt($("#text-c12").html()),
- "rgb": {
- "url": $("#text-c131").html(),
- "type": $("#text-c132").html(),
- "rotate": parseInt($("#text-c133").html()),
- "config": {
- "enable": parseInt($("#text-c1341").html()),
- "brightness": parseInt($("#text-c1342").html()),
- "gain": parseInt($("#text-c1343").html()),
- "saturation": parseInt($("#text-c1344").html()),
- "sharpness": parseInt($("#text-c1345").html())
- }
- },
- "ir": {
- "url": $("#text-c141").html(),
- "type": $("#text-c142").html(),
- "rotate": parseInt($("#text-c143").html()),
- "translate_x": parseInt($("#text-c144").html()),
- "translate_y": parseInt($("#text-c145").html()),
- "ir_scale": parseFloat($("#text-c146").html()),
- "config": {
- "enable": parseInt($("#text-c1471").html())
- }
- },
- "max_queue_size": parseInt($("#text-c15").html()),
- "count_frame_to_skip": parseInt($("#text-c16").html()),
- "fps": parseInt($("#text-c17").html()),
- "merge_queue_pause": parseInt($("#text-c18").html()),
- "raw_resolution": {
- "width": parseInt($("#text-c191").html()),
- "height": parseInt($("#text-c192").html())
- },
- "video_resize": {
- "width": parseInt($("#text-c1101").html()),
- "height": parseInt($("#text-c1102").html())
- },
- "crop_frame": {
- "x": parseInt($("#text-c1111").html()),
- "y": parseInt($("#text-c1112").html()),
- "width": parseInt($("#text-c1113").html()),
- "height": parseInt($("#text-c1114").html())
- }
- },
- "face_verify": {
- "show_fake_label": parseInt($("#text-c21").html()),
- "debug": parseInt($("#text-c22").html()),
- "max_fake_time": parseInt($("#text-c23").html()),
- "min_real_time": parseInt($("#text-c24").html()),
- "saturation": {
- "enable": parseInt($("#text-c251").html()),
- "min_std_thresh": parseInt($("#text-c252").html()),
- "min_mean_thresh": parseInt($("#text-c253").html())
- },
- "mtcnn": {
- "enable": parseInt($("#text-c261").html()),
- "size": parseInt($("#text-c262").html()),
- "num_thread": parseInt($("#text-c263").html())
- },
- "ir_face_verify": {
- "enable": parseInt($("#text-c271").html()),
- "ir_scale": parseFloat($("#text-c272").html()),
- "ir_neighbor": parseInt($("#text-c273").html())
- }
- },
- "ultraface": {
- "enable": parseInt($("#text-c_101").html()),
- "translate_x": parseInt($("#text-c_102").html()),
- "translate_y": parseInt($("#text-c_103").html()),
- "width": parseInt($("#text-c_104").html()),
- "height": parseInt($("#text-c_105").html()),
- "threshold": parseFloat($("#text-c_106").html()),
- "min_size": parseInt($("#text-c_107").html()),
- "thread_use": parseInt($("#text-c_108").html()),
- "max_ratio": parseFloat($("#text-c_109").html())
- },
- "haarcascade": {
- "enable": parseInt($("#text-c31").html()),
- "show_time_detect": parseInt($("#text-c32").html()),
- "min_size": parseInt($("#text-c33").html()),
- "max_size": parseInt($("#text-c34").html()),
- "scale": parseFloat($("#text-c35").html()),
- "neighbor": parseInt($("#text-c36").html())
- },
- "engine": {
- "max_fps": parseInt($("#text-c41").html()),
- "cam_id": parseInt($("#text-c42").html()),
- "server_authen": $("#text-c43").html()
- },
- "recognition": {
- "enable": parseInt($("#text-c51").html()),
- "accuracy": parseFloat($("#text-c52").html()),
- "server_recog": $("#text-c53").html(),
- "request_timeout": parseInt($("#text-c54").html()),
- "num_face_recog": parseInt($("#text-c55").html()),
- "first_time_recog": parseInt($("#text-c56").html()),
- "next_time_recog": parseInt($("#text-c57").html())
- },
- "screen": {
- "show_video": parseInt($("#text-c61").html()),
- "full_screen": parseInt($("#text-c62").html()),
- "width": parseInt($("#text-c63").html()),
- "height": parseInt($("#text-c64").html()),
- "banner": $("#text-c65").html(),
- "bb_color_rgb": {
- "detect": [parseInt($("#text-c6611").html()), parseInt($("#text-c6612").html()), parseInt($("#text-c6613").html())],
- "recog": [parseInt($("#text-c6621").html()), parseInt($("#text-c6622").html()), parseInt($("#text-c6623").html())]
- }
- },
- "id_city": parseInt($("#text-c7").html()),
- "open_door": {
- "enable": parseInt($("#text-c81").html()),
- "port_name": $("#text-c82").html()
- },
- "log": {
- "path": $("#text-c91").html(),
- "limit": parseInt($("#text-c92").html()),
- "clear_line": parseInt($("#text-c93").html())
- }
- };
+ var cfgLists = $(".editform");
+ var cfg = [];
+ for (var i = 0; i < cfgLists.length; i++) {
+ cfg.push({
+ parent: $(cfgLists[i]).data("parent"),
+ key: $(cfgLists[i]).data("key"),
+ data: $(cfgLists[i]).html()
+ });
+ }
common.modalBlock(true);
$.ajax({
url: $(e).attr("data-href"),
type: 'POST',
data: {
- config: JSON.stringify(config_json)
+ config: cfg
},
success: function (data) {
if (data) {
diff --git a/widgets/ConfigTree.php b/widgets/ConfigTree.php
new file mode 100644
index 00000000..fe7b85f1
--- /dev/null
+++ b/widgets/ConfigTree.php
@@ -0,0 +1,33 @@
+render("config-tree", [
+ "configLists" => $this->configLists,
+ "isRoot" => $this->isRoot,
+ "parent_id" => $this->parent_id,
+ "parent_key" => $this->parent_key,
+ "public_root" => $public_root,
+ "public_cfg" => $public_cfg
+ ]);
+ }
+
+}
diff --git a/widgets/views/config-tree.tpl b/widgets/views/config-tree.tpl
new file mode 100644
index 00000000..8d9087a2
--- /dev/null
+++ b/widgets/views/config-tree.tpl
@@ -0,0 +1,34 @@
+{$username=Yii::$app->user->identity->username}
+
\ No newline at end of file