phan trang dong bo du lieu
This commit is contained in:
parent
b26814bb97
commit
22f3a3f650
|
@ -115,8 +115,8 @@ class ApiController extends Controller {
|
|||
}
|
||||
}
|
||||
|
||||
public function actionGetAllFeatures() {
|
||||
$listManagement = ListManagement::find()->all();
|
||||
public function actionGetAllFeatures($offset = 0, $limit = 10) {
|
||||
$listManagement = ListManagement::find()->limit($limit)->offset($offset)->all();
|
||||
$allFeatures = [];
|
||||
foreach ($listManagement as $key => $value) {
|
||||
$features = json_decode($value->image, true);
|
||||
|
|
|
@ -516,7 +516,7 @@ class ListManagementController extends Controller {
|
|||
public function actionUpdateFeature() {
|
||||
if (Yii::$app->request->isAjax) {
|
||||
Yii::$app->response->format = "json";
|
||||
file_get_contents("http://localhost:2305/update-feature");
|
||||
file_get_contents("http://localhost:2305/update-feature?total=" . ListManagement::find()->count());
|
||||
return ["status" => true];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -425,12 +425,10 @@ function _syncFromServer() {
|
|||
$("#progress-totals").html(lists.length);
|
||||
$("#progress-form").removeClass("hidden");
|
||||
totals = lists.length;
|
||||
for (var i = 0; i < lists.length; i++) {
|
||||
syncFeature(lists[i]);
|
||||
}
|
||||
syncFeature(lists[0], lists);
|
||||
}
|
||||
|
||||
function syncFeature(id) {
|
||||
function syncFeature(id, fullData) {
|
||||
$.ajax({
|
||||
url: $("input[name='sync_feature_url']").val(),
|
||||
type: 'POST',
|
||||
|
@ -438,6 +436,7 @@ function syncFeature(id) {
|
|||
id: id
|
||||
},
|
||||
success: function (data) {
|
||||
console.log(data, progress);
|
||||
progress++;
|
||||
$("#progress-current").html(parseInt($("#progress-current").html()) + 1);
|
||||
var percent = parseInt(progress / totals * 100);
|
||||
|
@ -448,6 +447,8 @@ function syncFeature(id) {
|
|||
common.modalBlock(false);
|
||||
updateFeature();
|
||||
progress = 0;
|
||||
} else {
|
||||
syncFeature(fullData[progress], fullData);
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
|
@ -521,12 +522,10 @@ function _syncToServer() {
|
|||
$("#progress-totals").html(lists.length);
|
||||
$("#progress-form").removeClass("hidden");
|
||||
totalsToServer = lists.length;
|
||||
for (var i = 0; i < lists.length; i++) {
|
||||
syncFeatureToServer(lists[i]);
|
||||
}
|
||||
syncFeatureToServer(lists[0], lists);
|
||||
}
|
||||
var error = 0;
|
||||
function syncFeatureToServer(id) {
|
||||
function syncFeatureToServer(id, fullData) {
|
||||
$.ajax({
|
||||
url: $("input[name='sync_feature_to_server_url']").val(),
|
||||
type: 'POST',
|
||||
|
@ -550,6 +549,8 @@ function syncFeatureToServer(id) {
|
|||
alert("Đồng bộ dữ liệu hoàn thành");
|
||||
window.location.reload(true);
|
||||
}, 2000)
|
||||
} else {
|
||||
syncFeature(fullData[progressToServer], fullData);
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user