update config
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user