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))
// $last = (object) ['id' => 0];
// $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', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
@ -73,6 +81,7 @@ class ListManagementController extends Controller {
'genderArray' => ListManagement::$genderArray,
// 'idAuto' => $idAuto,
"staffArray" => ListManagement::staffArray(),
"updating" => $updating
]);
}

View File

@ -205,7 +205,14 @@
</td>
</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">
{* <b class="text-red">{$statistics.512}</b>/<b>{$statistics.img}</b>*}
</td>

View File

@ -617,3 +617,17 @@ function getTotalFeature() {
}
});
}
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) {
}
});
}