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} -
    -
  • - - -
      -
    • - - : -
      {$config_json.camera.auto_check}
      -
    • -
    • - - : -
      {$config_json.camera.num_cam}
      -
    • -
    • - - -
        -
      • - - : -
        {$config_json.camera.rgb.url}
        -
      • -
      • - - : -
        {$config_json.camera.rgb.type}
        -
      • -
      • - - : -
        {$config_json.camera.rgb.rotate}
        -
      • -
      • - - -
          -
        • - - : -
          {$config_json.camera.rgb.config.enable}
          -
        • -
        • - - : -
          {$config_json.camera.rgb.config.brightness}
          -
        • -
        • - - : -
          {$config_json.camera.rgb.config.gain}
          -
        • -
        • - - : -
          {$config_json.camera.rgb.config.saturation}
          -
        • -
        • - - : -
          {$config_json.camera.rgb.config.sharpness}
          -
        • -
        -
      • -
      -
    • -
    • - - -
        -
      • - - : -
        {$config_json.camera.ir.url}
        -
      • -
      • - - : -
        {$config_json.camera.ir.type}
        -
      • -
      • - - : -
        {$config_json.camera.ir.rotate}
        -
      • -
      • - - : -
        {$config_json.camera.ir.translate_x}
        -
      • -
      • - - : -
        {$config_json.camera.ir.translate_y}
        -
      • -
      • - - : -
        {$config_json.camera.ir.ir_scale}
        -
      • -
      • - - -
          -
        • - - : -
          {$config_json.camera.ir.config.enable}
          -
        • -
        -
      • -
      -
    • -
    • - - : -
      {$config_json.camera.max_queue_size}
      -
    • -
    • - - : -
      {$config_json.camera.count_frame_to_skip}
      -
    • -
    • - - : -
      {$config_json.camera.fps}
      -
    • -
    • - - : -
      {$config_json.camera.merge_queue_pause}
      -
    • -
    • - - -
        -
      • - - : -
        {$config_json.camera.raw_resolution.width}
        -
      • -
      • - - : -
        {$config_json.camera.raw_resolution.height}
        -
      • -
      -
    • -
    • - - -
        -
      • - - : -
        {$config_json.camera.video_resize.width}
        -
      • -
      • - - : -
        {$config_json.camera.video_resize.height}
        -
      • -
      -
    • -
    • - - -
        -
      • - - : -
        {$config_json.camera.crop_frame.x}
        -
      • -
      • - - : -
        {$config_json.camera.crop_frame.y}
        -
      • -
      • - - : -
        {$config_json.camera.crop_frame.width}
        -
      • -
      • - - : -
        {$config_json.camera.crop_frame.height}
        -
      • -
      -
    • -
    -
  • -
  • - - -
      -
    • - - : -
      {$config_json.face_verify.show_fake_label}
      -
    • -
    • - - : -
      {$config_json.face_verify.debug}
      -
    • -
    • - - : -
      {$config_json.face_verify.max_fake_time}
      -
    • -
    • - - : -
      {$config_json.face_verify.min_real_time}
      -
    • -
    • - - -
        -
      • - - : -
        {$config_json.face_verify.saturation.enable}
        -
      • -
      • - - : -
        {$config_json.face_verify.saturation.min_std_thresh}
        -
      • -
      • - - : -
        {$config_json.face_verify.saturation.min_mean_thresh}
        -
      • -
      -
    • -
    • - - -
        -
      • - - : -
        {$config_json.face_verify.mtcnn.enable}
        -
      • -
      • - - : -
        {$config_json.face_verify.mtcnn.size}
        -
      • -
      • - - : -
        {$config_json.face_verify.mtcnn.num_thread}
        -
      • -
      -
    • -
    • - - -
        -
      • - - : -
        {$config_json.face_verify.ir_face_verify.enable}
        -
      • -
      • - - : -
        {$config_json.face_verify.ir_face_verify.ir_scale}
        -
      • -
      • - - : -
        {$config_json.face_verify.ir_face_verify.ir_neighbor}
        -
      • -
      -
    • -
    -
  • -
  • - - -
      -
    • - - : -
      {$config_json.ultraface.enable|default:1}
      -
    • -
    • - - : -
      {$config_json.ultraface.translate_x|default:0}
      -
    • -
    • - - : -
      {$config_json.ultraface.translate_y|default:0}
      -
    • -
    • - - : -
      {$config_json.ultraface.width|default:160}
      -
    • -
    • - - : -
      {$config_json.ultraface.height|default:120}
      -
    • -
    • - - : -
      {$config_json.ultraface.threshold|default:0.7}
      -
    • -
    • - - : -
      {$config_json.ultraface.min_size|default:60}
      -
    • -
    • - - : -
      {$config_json.ultraface.thread_use|default:2}
      -
    • -
    • - - : -
      {$config_json.ultraface.max_ratio|default:1.5}
      -
    • -
    -
  • -
  • - - -
      -
    • - - : -
      {$config_json.haarcascade.enable}
      -
    • -
    • - - : -
      {$config_json.haarcascade.show_time_detect}
      -
    • -
    • - - : -
      {$config_json.haarcascade.min_size}
      -
    • -
    • - - : -
      {$config_json.haarcascade.max_size}
      -
    • -
    • - - : -
      {$config_json.haarcascade.scale}
      -
    • -
    • - - : -
      {$config_json.haarcascade.neighbor}
      -
    • -
    -
  • -
  • - - -
      -
    • - - : -
      {$config_json.engine.max_fps}
      -
    • -
    • - - : -
      {$config_json.engine.cam_id}
      -
    • -
    • - - : -
      {$config_json.engine.server_authen}
      -
    • -
    -
  • -
  • - - -
      -
    • - - : -
      {$config_json.recognition.enable}
      -
    • -
    • - - : -
      {$config_json.recognition.accuracy}
      -
    • -
    • - - : -
      {$config_json.recognition.server_recog}
      -
    • -
    • - - : -
      {$config_json.recognition.request_timeout}
      -
    • -
    • - - : -
      {$config_json.recognition.num_face_recog}
      -
    • -
    • - - : -
      {$config_json.recognition.first_time_recog}
      -
    • -
    • - - : -
      {$config_json.recognition.next_time_recog}
      -
    • -
    -
  • -
  • - - -
      -
    • - - : -
      {$config_json.screen.show_video}
      -
    • -
    • - - : -
      {$config_json.screen.full_screen}
      -
    • -
    • - - : -
      {$config_json.screen.width}
      -
    • -
    • - - : -
      {$config_json.screen.height}
      -
    • -
    • - - : -
      {$config_json.screen.banner}
      -
    • -
    • - - -
        -
      • - - -
          -
        • - - : -
          {$config_json.screen.bb_color_rgb.detect.0|default:0}
          -
        • -
        • - - : -
          {$config_json.screen.bb_color_rgb.detect.1|default:250}
          -
        • -
        • - - : -
          {$config_json.screen.bb_color_rgb.detect.2|default:150}
          -
        • -
        -
      • -
      • - - -
          -
        • - - : -
          {$config_json.screen.bb_color_rgb.detect.0|default:255}
          -
        • -
        • - - : -
          {$config_json.screen.bb_color_rgb.detect.1|default:0}
          -
        • -
        • - - : -
          {$config_json.screen.bb_color_rgb.detect.2|default:0}
          -
        • -
        -
      • -
      -
    • -
    -
  • -
  • - - -
    {$config_json.id_city}
    -
  • -
  • - - -
      -
    • - - : -
      {$config_json.open_door.enable}
      -
    • -
    • - - : -
      {$config_json.open_door.port_name}
      -
    • -
    -
  • -
  • - - -
      -
    • - - : -
      {$config_json.log.path}
      -
    • -
    • - - : -
      {$config_json.log.limit}
      -
    • -
    • - - : -
      {$config_json.log.clear_line}
      -
    • -
    -
  • -
-
- -
-
-
-
-{/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