automatay update feature

This commit is contained in:
dongpd 2021-01-19 14:27:28 +07:00
parent 8cb9cd30bc
commit 74135e96de
4 changed files with 42 additions and 4 deletions

View File

@ -419,4 +419,12 @@ class ApiController extends Controller {
} }
} }
public function actionReGenFeature() {
if (Yii::$app->request->isAjax) {
$updating = \app\models\SyncUrl::findOne(['key_config' => 'updating']);
$updating->data = "false";
return $updating->save();
}
}
} }

View File

@ -63,7 +63,15 @@ class ListManagementController extends Controller {
// if (!is_object($last)) // if (!is_object($last))
// $last = (object) ['id' => 0]; // $last = (object) ['id' => 0];
// $idAuto = $data['data']['box_id'] . "_" . ($last->id + 1); // $idAuto = $data['data']['box_id'] . "_" . ($last->id + 1);
$updating = \app\models\SyncUrl::findOne(['key_config' => 'updating']);
if (!$updating) {
$model = new \app\models\SyncUrl();
$model->create([
'key_config' => "updating",
'data' => "false"
]);
$updating = \app\models\SyncUrl::findOne(['key_config' => 'updating']);
}
return $this->render('index', [ return $this->render('index', [
'searchModel' => $searchModel, 'searchModel' => $searchModel,
'dataProvider' => $dataProvider, 'dataProvider' => $dataProvider,
@ -73,6 +81,7 @@ class ListManagementController extends Controller {
'genderArray' => ListManagement::$genderArray, 'genderArray' => ListManagement::$genderArray,
// 'idAuto' => $idAuto, // 'idAuto' => $idAuto,
"staffArray" => ListManagement::staffArray(), "staffArray" => ListManagement::staffArray(),
"updating" => $updating
]); ]);
} }

View File

@ -201,13 +201,20 @@
<tr> <tr>
<td>Đặc trưng 1</td> <td>Đặc trưng 1</td>
<td class="text-right" id="total128"> <td class="text-right" id="total128">
{* <b class="text-red">{$statistics.128}</b>/<b>{$statistics.img}</b>*} {* <b class="text-red">{$statistics.128}</b>/<b>{$statistics.img}</b>*}
</td> </td>
</tr> </tr>
<tr> <tr>
<td>Đặc trưng 2</td> <td>
Đặc trưng 2
<label class="label label-danger {if $updating->data==="false"}hidden{/if}" id="updating-label">Đang cập nhật ...</label>
<a href="{Url::to(['/api/re-gen-feature'])}" class="{if $updating->data==="true"}hidden{/if}" onclick="reGenFeature(this);
return false;" data-toggle="tooltip" title="Cập nhật lại đặc trưng">
<i class="fa fa-refresh"></i>
</a>
</td>
<td class="text-right" id="total512"> <td class="text-right" id="total512">
{* <b class="text-red">{$statistics.512}</b>/<b>{$statistics.img}</b>*} {* <b class="text-red">{$statistics.512}</b>/<b>{$statistics.img}</b>*}
</td> </td>
</tr> </tr>
</table> </table>

View File

@ -616,4 +616,18 @@ function getTotalFeature() {
error: function (jqXHR, textStatus, errorThrown) { error: function (jqXHR, textStatus, errorThrown) {
} }
}); });
}
function reGenFeature(e) {
$.ajax({
url: $(e).attr("href"),
type: 'POST',
success: function (data) {
// window.location.reload(true);
$("#updating-label").removeClass("hidden");
$(e).addClass("hidden");
},
error: function (jqXHR, textStatus, errorThrown) {
}
});
} }