Install & upgrade plugins, update indices
This commit is contained in:
parent
cb7edcea61
commit
23abb818eb
@ -51,12 +51,14 @@ async def home() -> str:
|
||||
|
||||
@app.get("/plugin/store")
|
||||
async def plugin_store() -> str:
|
||||
installed_plugins = tutorclient.Client.installed_plugins()
|
||||
plugins: list[dict[str, str]] = [
|
||||
{
|
||||
"name": p.name,
|
||||
"url": p.url,
|
||||
"index": p.index,
|
||||
"description": markdown(p.description),
|
||||
"is_installed": p.name in installed_plugins,
|
||||
}
|
||||
for p in tutorclient.Client.plugins_in_store()
|
||||
]
|
||||
@ -84,7 +86,7 @@ async def plugin(name: str) -> str:
|
||||
|
||||
|
||||
@app.post("/plugin/<name>/toggle")
|
||||
async def toggle_plugin(name: str) -> WerkzeugResponse:
|
||||
async def plugin_toggle(name: str) -> WerkzeugResponse:
|
||||
# TODO check plugin exists
|
||||
form = await request.form
|
||||
enable_plugin = form.get("enabled") == "on"
|
||||
@ -94,6 +96,22 @@ async def toggle_plugin(name: str) -> WerkzeugResponse:
|
||||
return redirect(url_for("plugin", name=name))
|
||||
|
||||
|
||||
@app.post("/plugin/<name>/install")
|
||||
async def plugin_install(name: str) -> WerkzeugResponse:
|
||||
tutorclient.CliPool.run_parallel(app, ["plugins", "install", name])
|
||||
return redirect(url_for("cli_logs"))
|
||||
|
||||
|
||||
@app.post("/plugin/<name>/upgrade")
|
||||
async def plugin_upgrade(name: str) -> WerkzeugResponse:
|
||||
tutorclient.CliPool.run_parallel(app, ["plugins", "upgrade", name])
|
||||
return redirect(url_for("cli_logs"))
|
||||
|
||||
@app.post("/plugins/update")
|
||||
async def plugins_update() -> WerkzeugResponse:
|
||||
tutorclient.CliPool.run_parallel(app, ["plugins", "update"])
|
||||
return redirect(url_for("cli_logs"))
|
||||
|
||||
@app.post("/config/<name>/set")
|
||||
async def config_set(name: str) -> WerkzeugResponse:
|
||||
form = await request.form
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
{% block workspace_header %}{{ plugin_name }}{% endblock %}
|
||||
|
||||
{% block workspace_content %}
|
||||
Enabled: <form method="POST" action="{{ url_for('toggle_plugin', name=plugin_name) }}">
|
||||
Enabled: <form method="POST" action="{{ url_for('plugin_toggle', name=plugin_name) }}">
|
||||
<input type="checkbox" name="enabled" onchange="this.form.submit()" {% if is_enabled %}checked{% endif %} />
|
||||
</form>
|
||||
|
||||
|
||||
@ -3,8 +3,17 @@
|
||||
{% block workspace_header %}Plugin store{% endblock %}
|
||||
|
||||
{% block workspace_content %}
|
||||
<form action="{{ url_for('plugins_update') }}" method="POST">
|
||||
<button type="submit">Refresh</button>
|
||||
</form>
|
||||
|
||||
{% for plugin in plugins %}
|
||||
<h2>{{ plugin.name }}</h2>
|
||||
{% if plugin.is_installed %}
|
||||
<p>Installed: ✅ <form action="{{ url_for('plugin_upgrade', name=plugin.name) }}" method="POST"><button type="submit">Upgrade</button></form></p>
|
||||
{% else %}
|
||||
<p><form action="{{ url_for('plugin_upgrade', name=plugin.name) }}" method="POST"><button type="submit">Install</button></form></p>
|
||||
{% endif %}
|
||||
<p{{ plugin.short_description }}></p>
|
||||
<!-- TODO is that actually safe? -->
|
||||
<p>{{ plugin.description|safe }}</p>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user