Commit 16dd8aca authored by Franco Fichtner's avatar Franco Fichtner

firmware: move reboot kerfuffle down into API call

While there, clean up messages for clarity and grammatical correctness.
parent a46014d1
......@@ -45,31 +45,40 @@ class FirmwareController extends ApiControllerBase
{
$this->sessionClose(); // long running action, close session
$backend = new Backend();
$response = json_decode(trim($backend->configdRun("firmware pkgstatus")), true);
$response = json_decode(trim($backend->configdRun('firmware pkgstatus')), true);
if ($response != null) {
if (array_key_exists("connection", $response) && $response["connection"]=="error") {
$response["status"] = "error";
$response["status_msg"] = "Connection Error";
} elseif (array_key_exists("repository", $response) && $response["repository"]=="error") {
$response["status"] = "error";
$response["status_msg"] = "Repository Problem";
} elseif (array_key_exists("updates", $response) && $response['updates'] == 0) {
$response["status"] = "none";
$response["status_msg"] = "No updates found";
} elseif (array_key_exists(0, $response["upgrade_packages"]) &&
$response["upgrade_packages"][0]["name"] == "pkg") {
$response["status"] = "ok";
$response["status_upgrade_action"] = "pkg";
$response["status_msg"] = "There is a mandatory update for the package manager. ".
"Please install and check for updates again.";
} elseif (array_key_exists("updates", $response)) {
$response["status"] = "ok";
$response["status_upgrade_action"] = "all";
$response["status_msg"] = sprintf("A total of %s update(s) are available.", $response["updates"]);
if (array_key_exists('connection', $response) && $response['connection'] == 'error') {
$response['status_msg'] = 'Connection error.';
$response['status'] = 'error';
} elseif (array_key_exists('repository', $response) && $response['repository'] == 'error') {
$response['status_msg'] = 'Repository problem.';
$response['status'] = 'error';
} elseif (array_key_exists('updates', $response) && $response['updates'] == 0) {
$response['status_msg'] = 'There are no updates available.';
$response['status'] = 'none';
} elseif (array_key_exists(0, $response['upgrade_packages']) &&
$response['upgrade_packages'][0]['name'] == 'pkg') {
$response['status_upgrade_action'] = 'pkg';
$response['status'] = 'ok';
$response['status_msg'] =
'There is a mandatory update for the package manager available. ' .
'Please install and fetch updates again.';
} elseif (array_key_exists('updates', $response)) {
$response['status_upgrade_action'] = 'all';
$response['status'] = 'ok';
if ($response['updates'] == 1) {
/* keep this dynamic for template translation even though %s is always '1' */
$response['status_msg'] = sprintf('There is %s update available.', $response['updates']);
} else {
$response['status_msg'] = sprintf('There are %s updates available.', $response['updates']);
}
if ($response['upgrade_needs_reboot'] == 1) {
$response['status_msg'] += ' ' . 'This update requires a reboot.';
}
}
} else {
$response = array("status" => "unknown","status_msg" => "Current status is unknown");
$response = array('status' => 'unknown', 'status_msg' => 'Current status is unknown.');
}
return $response;
......
......@@ -40,12 +40,8 @@ POSSIBILITY OF SUCH DAMAGE.
// request status
ajaxGet('/api/core/firmware/status',{},function(data,status){
status_msg = data['status_msg'];
if (data['upgrade_needs_reboot'] == "1") {
status_msg = status_msg + " This update requires a reboot.";
}
$("#checkupdate_progress").removeClass("fa fa-spinner fa-pulse");
$('#updatestatus').html(status_msg);
$('#updatestatus').html(data['status_msg']);
if (data['status'] == "ok") {
$.upgrade_action = data['status_upgrade_action'];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment