mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-10-27 08:16:41 +01:00
new and improve admin async upgrade process
This commit is contained in:
@@ -870,9 +870,17 @@ class AdminController extends AdminBaseController
|
||||
'decisions' => isset($post['decisions']) && is_array($post['decisions']) ? $post['decisions'] : [],
|
||||
];
|
||||
|
||||
$result = $this->getSafeUpgradeManager()->run($options);
|
||||
$manager = $this->getSafeUpgradeManager();
|
||||
$result = $manager->queue($options);
|
||||
$status = $result['status'] ?? 'error';
|
||||
|
||||
if ($status === 'error') {
|
||||
$manager->clearJobContext();
|
||||
$result = $manager->run($options);
|
||||
$status = $result['status'] ?? 'error';
|
||||
$result['fallback'] = true;
|
||||
}
|
||||
|
||||
$response = [
|
||||
'status' => $status === 'error' ? 'error' : 'success',
|
||||
'data' => $result,
|
||||
@@ -905,11 +913,21 @@ class AdminController extends AdminBaseController
|
||||
return false;
|
||||
}
|
||||
|
||||
$progress = $this->getSafeUpgradeManager()->getProgress();
|
||||
$manager = $this->getSafeUpgradeManager();
|
||||
$jobId = isset($_GET['job']) ? (string)$_GET['job'] : '';
|
||||
|
||||
if ($jobId !== '') {
|
||||
$data = $manager->getJobStatus($jobId);
|
||||
} else {
|
||||
$data = [
|
||||
'job' => null,
|
||||
'progress' => $manager->getProgress(),
|
||||
];
|
||||
}
|
||||
|
||||
$this->sendJsonResponse([
|
||||
'status' => 'success',
|
||||
'data' => $progress,
|
||||
'data' => $data,
|
||||
]);
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user