summaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
authorJonas Dellinger <jonas@dellinger.dev>2023-05-29 18:29:36 +0200
committerGitHub <noreply@github.com>2023-05-29 09:29:36 -0700
commit010feddf36646fb9695106bd64eab41e47e962fe (patch)
tree4619a5c0fc1b2c9ca475ce644cce18464c77ca3e /backend
parent5114bb57112bf8bbad30768ffd26803d464b19a2 (diff)
downloaddecky-loader-010feddf36646fb9695106bd64eab41e47e962fe.tar.gz
decky-loader-010feddf36646fb9695106bd64eab41e47e962fe.zip
Add update all button to plugin list (#466)
Diffstat (limited to 'backend')
-rw-r--r--backend/browser.py28
-rw-r--r--backend/locales/en-US.json26
-rw-r--r--backend/utilities.py8
3 files changed, 52 insertions, 10 deletions
diff --git a/backend/browser.py b/backend/browser.py
index db3d2f50..388a01e3 100644
--- a/backend/browser.py
+++ b/backend/browser.py
@@ -49,7 +49,7 @@ class PluginBrowser:
logger.error(f"chown/chmod exited with a non-zero exit code")
return False
return True
-
+
async def _download_remote_binaries_for_plugin_with_name(self, pluginBasePath):
rv = False
try:
@@ -63,10 +63,8 @@ class PluginBrowser:
# create bin directory if needed.
chmod(pluginBasePath, 777)
if access(pluginBasePath, W_OK):
-
if not path.exists(pluginBinPath):
mkdir(pluginBinPath)
-
if not access(pluginBinPath, W_OK):
chmod(pluginBinPath, 777)
@@ -85,7 +83,7 @@ class PluginBrowser:
else:
rv = True
logger.debug(f"No Remote Binaries to Download")
-
+
except Exception as e:
rv = False
logger.debug(str(e))
@@ -174,7 +172,7 @@ class PluginBrowser:
if res_zip is None:
logger.fatal(f"Could not fetch {artifact}")
return
-
+
# If plugin is installed, uninstall it
if isInstalled:
try:
@@ -196,7 +194,7 @@ class PluginBrowser:
self.loader.plugins[name].stop()
self.loader.plugins.pop(name, None)
await sleep(1)
-
+
current_plugin_order = self.settings.getSetting("pluginOrder")
current_plugin_order.append(name)
self.settings.setSetting("pluginOrder", current_plugin_order)
@@ -216,9 +214,23 @@ class PluginBrowser:
await tab.open_websocket()
await tab.evaluate_js(f"DeckyPluginLoader.addPluginInstallPrompt('{name}', '{version}', '{request_id}', '{hash}', {install_type})")
+ async def request_multiple_plugin_installs(self, requests):
+ request_id = str(time())
+ self.install_requests[request_id] = [PluginInstallContext(req['artifact'], req['name'], req['version'], req['hash']) for req in requests]
+ js_requests_parameter = ','.join([
+ f"{{ name: '{req['name']}', version: '{req['version']}', hash: '{req['hash']}', install_type: {req['install_type']}}}" for req in requests
+ ])
+
+ tab = await get_gamepadui_tab()
+ await tab.open_websocket()
+ await tab.evaluate_js(f"DeckyPluginLoader.addMultiplePluginsInstallPrompt('{request_id}', [{js_requests_parameter}])")
+
async def confirm_plugin_install(self, request_id):
- request = self.install_requests.pop(request_id)
- await self._install(request.artifact, request.name, request.version, request.hash)
+ requestOrRequests = self.install_requests.pop(request_id)
+ if isinstance(requestOrRequests, list):
+ [await self._install(req.artifact, req.name, req.version, req.hash) for req in requestOrRequests]
+ else:
+ await self._install(requestOrRequests.artifact, requestOrRequests.name, requestOrRequests.version, requestOrRequests.hash)
def cancel_plugin_install(self, request_id):
self.install_requests.pop(request_id)
diff --git a/backend/locales/en-US.json b/backend/locales/en-US.json
index c442b7c0..fce3850b 100644
--- a/backend/locales/en-US.json
+++ b/backend/locales/en-US.json
@@ -44,13 +44,37 @@
"title": "Update {{artifact}}"
}
},
+ "MultiplePluginsInstallModal": {
+ "title": {
+ "mixed_one": "Modify 1 plugin",
+ "mixed_other": "Modify {{count}} plugins",
+ "update_one": "Update 1 plugin",
+ "update_other": "Update {{count}} plugins",
+ "reinstall_one": "Reinstall 1 plugin",
+ "reinstall_other": "Reinstall {{count}} plugins",
+ "install_one": "Install 1 plugin",
+ "install_other": "Install {{count}} plugins"
+ },
+ "ok_button": {
+ "idle": "Confirm",
+ "loading": "Working"
+ },
+ "confirm": "Are you sure you want to make the following modifications?",
+ "description": {
+ "install": "Install {{name}} {{version}}",
+ "update": "Update {{name}} to {{version}}",
+ "reinstall": "Reinstall {{name}} {{version}}"
+ }
+ },
"PluginListIndex": {
"no_plugin": "No plugins installed!",
"plugin_actions": "Plugin Actions",
"reinstall": "Reinstall",
"reload": "Reload",
"uninstall": "Uninstall",
- "update_to": "Update to {{name}}"
+ "update_to": "Update to {{name}}",
+ "update_all_one": "Update 1 plugin",
+ "update_all_other": "Update {{count}} plugins"
},
"PluginLoader": {
"decky_title": "Decky",
diff --git a/backend/utilities.py b/backend/utilities.py
index d3db51c9..94f5e26b 100644
--- a/backend/utilities.py
+++ b/backend/utilities.py
@@ -19,6 +19,7 @@ class Utilities:
"ping": self.ping,
"http_request": self.http_request,
"install_plugin": self.install_plugin,
+ "install_plugins": self.install_plugins,
"cancel_plugin_install": self.cancel_plugin_install,
"confirm_plugin_install": self.confirm_plugin_install,
"uninstall_plugin": self.uninstall_plugin,
@@ -70,6 +71,11 @@ class Utilities:
install_type=install_type
)
+ async def install_plugins(self, requests):
+ return await self.context.plugin_browser.request_multiple_plugin_installs(
+ requests=requests
+ )
+
async def confirm_plugin_install(self, request_id):
return await self.context.plugin_browser.confirm_plugin_install(request_id)
@@ -266,7 +272,7 @@ class Utilities:
await close_old_tabs()
result = await tab.reload_and_evaluate(script)
self.logger.info(result)
-
+
except Exception:
self.logger.error("Failed to connect to React DevTools")
self.logger.error(format_exc())