update config

This commit is contained in:
2020-12-10 17:04:41 +07:00
parent 94215e4e80
commit 483e0fa349
9 changed files with 189 additions and 15 deletions

View File

@@ -34,7 +34,7 @@ class ConfigController extends Controller {
}
public $config_json = [
"lang" => "vi",
"lang" => "vi",
"camera" => [
"auto_check" => 1,
"num_cam" => 2,
@@ -162,7 +162,7 @@ class ConfigController extends Controller {
* @return mixed
*/
public function actionIndex() {
$this->view->title = "Cấu hình thiết bị";
$this->view->title = "Cấu hình máy chủ";
$options = [
'http' => [
'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;
}
}
}

View File

@@ -270,12 +270,21 @@ class ListManagementController extends Controller {
public function actionSyncFromServer() {
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' => [
'header' => "Content-Type: application/json",
'method' => "POST",
'content' => json_encode([
"id_camera" => 209,
"id_camera" => $id_camera,
"ids_staff" => []
])
]
@@ -293,12 +302,20 @@ class ListManagementController extends Controller {
public function actionSyncFeature() {
if (Yii::$app->request->post()) {
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' => [
'header' => "Content-Type: application/json",
'method' => "POST",
'content' => json_encode([
"id_camera" => 209,
"id_camera" => $id_camera,
"ids_staff" => [strval(Yii::$app->request->post("id"))]
])
]