update config
This commit is contained in:
parent
94215e4e80
commit
483e0fa349
|
@ -34,7 +34,7 @@ class ConfigController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
public $config_json = [
|
public $config_json = [
|
||||||
"lang" => "vi",
|
"lang" => "vi",
|
||||||
"camera" => [
|
"camera" => [
|
||||||
"auto_check" => 1,
|
"auto_check" => 1,
|
||||||
"num_cam" => 2,
|
"num_cam" => 2,
|
||||||
|
@ -162,7 +162,7 @@ class ConfigController extends Controller {
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function actionIndex() {
|
public function actionIndex() {
|
||||||
$this->view->title = "Cấu hình thiết bị";
|
$this->view->title = "Cấu hình máy chủ";
|
||||||
$options = [
|
$options = [
|
||||||
'http' => [
|
'http' => [
|
||||||
'header' => "Content-Type: application/json",
|
'header' => "Content-Type: application/json",
|
||||||
|
@ -368,4 +368,42 @@ class ConfigController extends Controller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function actionCauHinhThietBi() {
|
||||||
|
$this->view->title = "Cấu hình thiết bị";
|
||||||
|
return $this->render('device', [
|
||||||
|
"server_api" => \app\models\SyncUrl::findOne(['key_config' => 'server_api']),
|
||||||
|
"device_id" => \app\models\SyncUrl::findOne(['key_config' => 'device_id'])
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function actionSaveConfig() {
|
||||||
|
if (Yii::$app->request->post()) {
|
||||||
|
$post = Yii::$app->request->post();
|
||||||
|
$server_api = \app\models\SyncUrl::findOne(['key_config' => 'server_api']);
|
||||||
|
if ($server_api) {
|
||||||
|
$server_api->data = $post['server_api'];
|
||||||
|
$server_api->save();
|
||||||
|
} else {
|
||||||
|
$model = new \app\models\SyncUrl();
|
||||||
|
$model->create([
|
||||||
|
'key_config' => 'server_api',
|
||||||
|
'data' => $post['server_api']
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$device_id = \app\models\SyncUrl::findOne(['key_config' => 'device_id']);
|
||||||
|
if ($device_id) {
|
||||||
|
$device_id->data = $post['device_id'];
|
||||||
|
$device_id->save();
|
||||||
|
} else {
|
||||||
|
$model = new \app\models\SyncUrl();
|
||||||
|
$model->create([
|
||||||
|
'key_config' => 'device_id',
|
||||||
|
'data' => $post['device_id']
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -270,12 +270,21 @@ class ListManagementController extends Controller {
|
||||||
|
|
||||||
public function actionSyncFromServer() {
|
public function actionSyncFromServer() {
|
||||||
if (Yii::$app->request->isAjax) {
|
if (Yii::$app->request->isAjax) {
|
||||||
$datas = json_decode(file_get_contents("https://dev-dc.beetai.com/api/oem/get_all_image", false, stream_context_create([
|
$server_ip = \app\models\SyncUrl::findOne(['key_config' => 'server_api']);
|
||||||
|
$ip = "dev-dc.beetai.com";
|
||||||
|
if ($server_ip)
|
||||||
|
$ip = $server_ip->data;
|
||||||
|
$device_id = \app\models\SyncUrl::findOne(['key_config' => 'device_id']);
|
||||||
|
$id_camera = 209;
|
||||||
|
if ($device_id)
|
||||||
|
$id_camera = intval($device_id->data);
|
||||||
|
|
||||||
|
$datas = json_decode(file_get_contents("https://" . $ip . "/api/oem/get_all_image", false, stream_context_create([
|
||||||
'http' => [
|
'http' => [
|
||||||
'header' => "Content-Type: application/json",
|
'header' => "Content-Type: application/json",
|
||||||
'method' => "POST",
|
'method' => "POST",
|
||||||
'content' => json_encode([
|
'content' => json_encode([
|
||||||
"id_camera" => 209,
|
"id_camera" => $id_camera,
|
||||||
"ids_staff" => []
|
"ids_staff" => []
|
||||||
])
|
])
|
||||||
]
|
]
|
||||||
|
@ -293,12 +302,20 @@ class ListManagementController extends Controller {
|
||||||
public function actionSyncFeature() {
|
public function actionSyncFeature() {
|
||||||
if (Yii::$app->request->post()) {
|
if (Yii::$app->request->post()) {
|
||||||
Yii::$app->response->format = "json";
|
Yii::$app->response->format = "json";
|
||||||
$res = json_decode(file_get_contents("https://dev-dc.beetai.com/api/oem/get_all_image", false, stream_context_create([
|
$server_ip = \app\models\SyncUrl::findOne(['key_config' => 'server_api']);
|
||||||
|
$ip = "dev-dc.beetai.com";
|
||||||
|
if ($server_ip)
|
||||||
|
$ip = $server_ip->data;
|
||||||
|
$device_id = \app\models\SyncUrl::findOne(['key_config' => 'device_id']);
|
||||||
|
$id_camera = 209;
|
||||||
|
if ($device_id)
|
||||||
|
$id_camera = intval($device_id->data);
|
||||||
|
$res = json_decode(file_get_contents("https://" . $ip . "/api/oem/get_all_image", false, stream_context_create([
|
||||||
'http' => [
|
'http' => [
|
||||||
'header' => "Content-Type: application/json",
|
'header' => "Content-Type: application/json",
|
||||||
'method' => "POST",
|
'method' => "POST",
|
||||||
'content' => json_encode([
|
'content' => json_encode([
|
||||||
"id_camera" => 209,
|
"id_camera" => $id_camera,
|
||||||
"ids_staff" => [strval(Yii::$app->request->post("id"))]
|
"ids_staff" => [strval(Yii::$app->request->post("id"))]
|
||||||
])
|
])
|
||||||
]
|
]
|
||||||
|
|
|
@ -8,6 +8,7 @@ use Yii;
|
||||||
* This is the model class for table "sync_url".
|
* This is the model class for table "sync_url".
|
||||||
*
|
*
|
||||||
* @property int $id
|
* @property int $id
|
||||||
|
* @property string $key_config
|
||||||
* @property string $data
|
* @property string $data
|
||||||
*/
|
*/
|
||||||
class SyncUrl extends \yii\db\ActiveRecord {
|
class SyncUrl extends \yii\db\ActiveRecord {
|
||||||
|
@ -25,7 +26,7 @@ class SyncUrl extends \yii\db\ActiveRecord {
|
||||||
public function rules() {
|
public function rules() {
|
||||||
return [
|
return [
|
||||||
[['data'], 'required'],
|
[['data'], 'required'],
|
||||||
[['data'], 'string'],
|
[['data', 'key_config'], 'string'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,12 +37,14 @@ class SyncUrl extends \yii\db\ActiveRecord {
|
||||||
return [
|
return [
|
||||||
'id' => 'ID',
|
'id' => 'ID',
|
||||||
'data' => 'Data',
|
'data' => 'Data',
|
||||||
|
'key_config' => 'Key Config'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create($data) {
|
public function create($data) {
|
||||||
$r = $this->load([
|
$r = $this->load([
|
||||||
'data' => $data['url'],
|
'key_config' => $data['key_config'],
|
||||||
|
'data' => $data['data'],
|
||||||
], '');
|
], '');
|
||||||
if ($r) {
|
if ($r) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -37,7 +37,7 @@ use yii\widgets\ActiveForm;
|
||||||
<div class="collapse navbar-collapse pull-left" id="navbar-collapse">
|
<div class="collapse navbar-collapse pull-left" id="navbar-collapse">
|
||||||
<ul class="nav navbar-nav">
|
<ul class="nav navbar-nav">
|
||||||
<li class="<?php if (Yii::$app->controller->id == "config") echo "active"; ?>">
|
<li class="<?php if (Yii::$app->controller->id == "config") echo "active"; ?>">
|
||||||
<a href="<?php echo yii\helpers\Url::to(['/config']); ?>">
|
<a href="<?php echo yii\helpers\Url::to(['/config/cau-hinh-thiet-bi']); ?>">
|
||||||
<i class="fa fa-cogs"></i> Cấu hình
|
<i class="fa fa-cogs"></i> Cấu hình
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -142,17 +142,24 @@
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<br>
|
<br>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6">
|
<div class="col-md-8">
|
||||||
<div class="mt-element-step">
|
<div class="mt-element-step">
|
||||||
<div class="row step-thin">
|
<div class="row step-thin">
|
||||||
<div class="col-md-6 bg-grey mt-step-col active">
|
<div class="col-md-4 bg-grey mt-step-col">
|
||||||
<div class="mt-step-number bg-white font-grey">1</div>
|
<div class="mt-step-number bg-white font-grey">1</div>
|
||||||
|
<div class="mt-step-title uppercase font-grey-cascade" style="cursor: pointer;" onclick="window.location = '{Url::to(['/config/cau-hinh-thiet-bi'])}';">
|
||||||
|
Cấu hình thiết bị
|
||||||
|
</div>
|
||||||
|
<div class="mt-step-content font-grey-cascade">Device config</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4 bg-grey mt-step-col">
|
||||||
|
<div class="mt-step-number bg-white font-grey">2</div>
|
||||||
<div class="mt-step-title uppercase font-grey-cascade" style="cursor: pointer;" onclick="window.location = '{Url::to(['/config'])}';">
|
<div class="mt-step-title uppercase font-grey-cascade" style="cursor: pointer;" onclick="window.location = '{Url::to(['/config'])}';">
|
||||||
Cấu hình máy chủ
|
Cấu hình máy chủ
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-step-content font-grey-cascade">Server config</div>
|
<div class="mt-step-content font-grey-cascade">Server config</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6 bg-grey mt-step-col active">
|
<div class="col-md-4 bg-grey mt-step-col active">
|
||||||
<div class="mt-step-number bg-white font-grey">2</div>
|
<div class="mt-step-number bg-white font-grey">2</div>
|
||||||
<div class="mt-step-title uppercase font-grey-cascade" style="cursor: pointer;" onclick="window.location = '{Url::to(['/config/cau-hinh-nhan-dien'])}';">
|
<div class="mt-step-title uppercase font-grey-cascade" style="cursor: pointer;" onclick="window.location = '{Url::to(['/config/cau-hinh-nhan-dien'])}';">
|
||||||
Cấu hình nhận diện
|
Cấu hình nhận diện
|
||||||
|
|
71
views/config/device.tpl
Normal file
71
views/config/device.tpl
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
{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'}
|
||||||
|
<style>
|
||||||
|
.input-group-addon{
|
||||||
|
width: 100px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
.input-group{
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div class="container-fluid">
|
||||||
|
<br>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-8">
|
||||||
|
<div class="mt-element-step">
|
||||||
|
<div class="row step-thin">
|
||||||
|
<div class="col-md-4 bg-grey mt-step-col active">
|
||||||
|
<div class="mt-step-number bg-white font-grey">1</div>
|
||||||
|
<div class="mt-step-title uppercase font-grey-cascade" style="cursor: pointer;" onclick="window.location = '{Url::to(['/config/cau-hinh-thiet-bi'])}';">
|
||||||
|
Cấu hình thiết bị
|
||||||
|
</div>
|
||||||
|
<div class="mt-step-content font-grey-cascade">Device config</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4 bg-grey mt-step-col">
|
||||||
|
<div class="mt-step-number bg-white font-grey">2</div>
|
||||||
|
<div class="mt-step-title uppercase font-grey-cascade" style="cursor: pointer;" onclick="window.location = '{Url::to(['/config'])}';">
|
||||||
|
Cấu hình máy chủ
|
||||||
|
</div>
|
||||||
|
<div class="mt-step-content font-grey-cascade">Server config</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4 bg-grey mt-step-col">
|
||||||
|
<div class="mt-step-number bg-white font-grey">2</div>
|
||||||
|
<div class="mt-step-title uppercase font-grey-cascade" style="cursor: pointer;" onclick="window.location = '{Url::to(['/config/cau-hinh-nhan-dien'])}';">
|
||||||
|
Cấu hình nhận diện
|
||||||
|
</div>
|
||||||
|
<div class="mt-step-content font-grey-cascade">Engine config</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<br>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-4">
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-addon">Server API</div>
|
||||||
|
<input type="input" class="form-control" name="server_api" value="{$server_api->data|default:""}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-addon">Device ID</div>
|
||||||
|
<input type="input" class="form-control" name="device_id" value="{$device_id->data|default:""}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="text-center">
|
||||||
|
<button class="btn btn-primary" onclick="SaveConfigDevice(this);" data-href="{Url::to(['save-config'])}">
|
||||||
|
<i class="fa fa-floppy-o"></i> Lưu lại
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/block}
|
|
@ -16,17 +16,24 @@
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<br>
|
<br>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6">
|
<div class="col-md-8">
|
||||||
<div class="mt-element-step">
|
<div class="mt-element-step">
|
||||||
<div class="row step-thin">
|
<div class="row step-thin">
|
||||||
<div class="col-md-6 bg-grey mt-step-col active">
|
<div class="col-md-4 bg-grey mt-step-col">
|
||||||
<div class="mt-step-number bg-white font-grey">1</div>
|
<div class="mt-step-number bg-white font-grey">1</div>
|
||||||
|
<div class="mt-step-title uppercase font-grey-cascade" style="cursor: pointer;" onclick="window.location = '{Url::to(['/config/cau-hinh-thiet-bi'])}';">
|
||||||
|
Cấu hình thiết bị
|
||||||
|
</div>
|
||||||
|
<div class="mt-step-content font-grey-cascade">Device config</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4 bg-grey mt-step-col active">
|
||||||
|
<div class="mt-step-number bg-white font-grey">2</div>
|
||||||
<div class="mt-step-title uppercase font-grey-cascade" style="cursor: pointer;" onclick="window.location = '{Url::to(['/config'])}';">
|
<div class="mt-step-title uppercase font-grey-cascade" style="cursor: pointer;" onclick="window.location = '{Url::to(['/config'])}';">
|
||||||
Cấu hình máy chủ
|
Cấu hình máy chủ
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-step-content font-grey-cascade">Server config</div>
|
<div class="mt-step-content font-grey-cascade">Server config</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6 bg-grey mt-step-col">
|
<div class="col-md-4 bg-grey mt-step-col">
|
||||||
<div class="mt-step-number bg-white font-grey">2</div>
|
<div class="mt-step-number bg-white font-grey">2</div>
|
||||||
<div class="mt-step-title uppercase font-grey-cascade" style="cursor: pointer;" onclick="window.location = '{Url::to(['/config/cau-hinh-nhan-dien'])}';">
|
<div class="mt-step-title uppercase font-grey-cascade" style="cursor: pointer;" onclick="window.location = '{Url::to(['/config/cau-hinh-nhan-dien'])}';">
|
||||||
Cấu hình nhận diện
|
Cấu hình nhận diện
|
||||||
|
|
|
@ -56,6 +56,7 @@ function saveStep1(e) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveStep2(e) {
|
function saveStep2(e) {
|
||||||
var cfgLists = $(".editform");
|
var cfgLists = $(".editform");
|
||||||
var cfg = [];
|
var cfg = [];
|
||||||
|
@ -86,4 +87,34 @@ function saveStep2(e) {
|
||||||
common.ajaxError();
|
common.ajaxError();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function SaveConfigDevice(e) {
|
||||||
|
var server_api = $("input[name='server_api']").val();
|
||||||
|
var device_id = $("input[name='device_id']").val();
|
||||||
|
if (server_api === "" || device_id === "") {
|
||||||
|
alert("Hãy nhập đủ thông tin");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
common.modalBlock(true);
|
||||||
|
$.ajax({
|
||||||
|
url: $(e).attr("data-href"),
|
||||||
|
type: 'POST',
|
||||||
|
data: {
|
||||||
|
server_api: server_api,
|
||||||
|
device_id: device_id
|
||||||
|
},
|
||||||
|
success: function (data) {
|
||||||
|
if (data) {
|
||||||
|
notification.success("Đã lưu cấu hình!", 2000);
|
||||||
|
} else {
|
||||||
|
notification.success("Lưu cấu hình thất bại!", 2000);
|
||||||
|
}
|
||||||
|
common.modalBlock(false);
|
||||||
|
},
|
||||||
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
|
common.modalBlock(false);
|
||||||
|
common.ajaxError();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user