Skip to content

Commit

Permalink
Uninstalling plugins will now show progress
Browse files Browse the repository at this point in the history
  • Loading branch information
darylc committed Jan 4, 2025
1 parent 85dd7bd commit 77d78f8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 23 deletions.
2 changes: 1 addition & 1 deletion scripts/uninstall_plugin
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ then
exit 1
fi

logOutput
teeOutput

if [ -x "${PLUGINDIR}/$1/scripts/fpp_uninstall.sh" ]
then
Expand Down
15 changes: 12 additions & 3 deletions www/api/controllers/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,9 @@ function GetPluginInfo()
// DELETE /api/plugin/:RepoName
function UninstallPlugin()
{
global $settings, $fppDir, $SUDO;
global $settings, $fppDir, $SUDO, $_REQUEST;
$result = Array();
$stream = $_REQUEST['stream'];

$plugin = params('RepoName');

Expand All @@ -152,11 +153,19 @@ function UninstallPlugin()
exec("rm " . $settings['pluginDirectory'] . "/" . $data['linkName'], $output, $return_val);
}

exec("export SUDO=\"" . $SUDO . "\"; export PLUGINDIR=\"" . $settings['pluginDirectory'] ."\"; $fppDir/scripts/uninstall_plugin $plugin", $output, $return_val);
unset($output);
if (isset($stream) && $stream != "false") {
DisableOutputBuffering();
system("$fppDir/scripts/uninstall_plugin $plugin", $return_val);
} else {
exec("export SUDO=\"" . $SUDO . "\"; export PLUGINDIR=\"" . $settings['pluginDirectory'] ."\"; $fppDir/scripts/uninstall_plugin $plugin", $output, $return_val);
unset($output);
}

if ($return_val == 0)
{
if (isset($stream) && $stream != "false") {
return "\nDone\n";
}
$result['Status'] = 'OK';
$result['Message'] = '';
}
Expand Down
23 changes: 4 additions & 19 deletions www/plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,24 +111,9 @@ function InstallPlugin(plugin, branch, sha) {
}

function UninstallPlugin(plugin) {
var url = 'api/plugin/' + plugin;
$('html,body').css('cursor', 'wait');
$.ajax({
url: url,
type: 'DELETE',
dataType: 'json',
success: function (data) {
$('html,body').css('cursor', 'auto');
if (data.Status == 'OK')
location.reload(true);
else
alert('ERROR: ' + data.Message);
},
error: function () {
$('html,body').css('cursor', 'auto');
alert('Error, API call to uninstall plugin failed');
}
});
var url = 'api/plugin/' + plugin + '?stream=true'; // Assuming your API supports streaming for uninstall
DisplayProgressDialog("pluginsProgressPopup", "Uninstall Plugin");
StreamURL(url, 'pluginsProgressPopupText', 'PluginProgressDialogDone', 'PluginProgressDialogDone', 'DELETE');
}

function ShowUninstallPluginPopup(plugin, pluginName) {
Expand Down Expand Up @@ -550,4 +535,4 @@ class="form-control form-control-lg form-control-rounded has-shadow"

</body>

</html>
</html>

0 comments on commit 77d78f8

Please sign in to comment.