mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-20 03:16:12 +00:00
(firmware) glue reinstall action into UI
This commit is contained in:
parent
6fb2f2555a
commit
f132a541a5
@ -116,6 +116,34 @@ class FirmwareController extends ApiControllerBase
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* reinstall package
|
||||
* @param string $pkg_name package name to reinstall
|
||||
* @return array status
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function reinstallAction($pkg_name)
|
||||
{
|
||||
$backend = new Backend();
|
||||
$response =array();
|
||||
|
||||
if ($this->request->isPost()) {
|
||||
$response['status'] = 'ok';
|
||||
// sanitize package name
|
||||
$filter = new \Phalcon\Filter();
|
||||
$filter->add('pkgname', function($value) {
|
||||
return preg_replace('/[^0-9a-zA-Z-_]/', '', $value);
|
||||
});
|
||||
$pkg_name = $filter->sanitize($pkg_name, "pkgname");
|
||||
// execute action
|
||||
$response['msg_uuid'] = trim($backend->configdpRun("firmware reinstall", array($pkg_name), true));
|
||||
} else {
|
||||
$response['status'] = 'failure';
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* retrieve upgrade status (and log file of current process)
|
||||
*/
|
||||
|
||||
@ -91,6 +91,20 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* perform package reinstall, install poller to update status
|
||||
*/
|
||||
function reinstall(pkg_name)
|
||||
{
|
||||
$('#progresstab > a').tab('show');
|
||||
$('#updatestatus').html("{{ lang._('Reinstalling... (do not leave this page while reinstall is in progress)') }}");
|
||||
|
||||
ajaxCall('/api/core/firmware/reinstall/'+pkg_name,{},function() {
|
||||
$('#updatelist').empty();
|
||||
setTimeout(trackStatus, 500);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* check if a reboot is required, warn user or just upgrade
|
||||
*/
|
||||
@ -190,7 +204,10 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
'<td>' + row['version'] + '</td>' +
|
||||
'<td>' + row['flatsize'] + '</td>' +
|
||||
'<td>' + row['comment'] + '</td>' +
|
||||
'<td>reinstall, ' + (row['locked'] === '1' ? 'unlock' : 'lock') +'</td>' +
|
||||
'<td>' +
|
||||
'<button class="btn btn-default btn-xs act_reinstall" data-package="' + row['name'] + '">reinstall</button>'+
|
||||
', ' + (row['locked'] === '1' ? 'unlock' : 'lock') +
|
||||
'</td>' +
|
||||
'</tr>'
|
||||
);
|
||||
if (!row['name'].match(/^os-/g)) {
|
||||
@ -198,6 +215,13 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
}
|
||||
installed[row['name']] = row;
|
||||
});
|
||||
|
||||
// link reinstall buttons to action
|
||||
$(".act_reinstall").click(function(event){
|
||||
event.preventDefault();
|
||||
reinstall($(this).data('package'));
|
||||
});
|
||||
|
||||
$.each(data['remote'], function(index, row) {
|
||||
if (!row['name'].match(/^os-/g)) {
|
||||
return 1;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user