pinakes-server: add GET /plugins/ui-pages endpoint
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: Id09d4dce060e0a79586251a16fb6bdbc6a6a6964
This commit is contained in:
parent
0525ea6c60
commit
29ba24ae01
3 changed files with 35 additions and 1 deletions
|
|
@ -4,7 +4,12 @@ use axum::{
|
|||
};
|
||||
|
||||
use crate::{
|
||||
dto::{InstallPluginRequest, PluginResponse, TogglePluginRequest},
|
||||
dto::{
|
||||
InstallPluginRequest,
|
||||
PluginResponse,
|
||||
PluginUiPageEntry,
|
||||
TogglePluginRequest,
|
||||
},
|
||||
error::ApiError,
|
||||
state::AppState,
|
||||
};
|
||||
|
|
@ -144,6 +149,24 @@ pub async fn toggle_plugin(
|
|||
})))
|
||||
}
|
||||
|
||||
/// List all UI pages provided by loaded plugins
|
||||
pub async fn list_plugin_ui_pages(
|
||||
State(state): State<AppState>,
|
||||
) -> Result<Json<Vec<PluginUiPageEntry>>, ApiError> {
|
||||
let plugin_manager = state.plugin_manager.as_ref().ok_or_else(|| {
|
||||
ApiError(pinakes_core::error::PinakesError::InvalidOperation(
|
||||
"Plugin system is not enabled".to_string(),
|
||||
))
|
||||
})?;
|
||||
|
||||
let pages = plugin_manager.list_ui_pages().await;
|
||||
let entries = pages
|
||||
.into_iter()
|
||||
.map(|(plugin_id, page)| PluginUiPageEntry { plugin_id, page })
|
||||
.collect();
|
||||
Ok(Json(entries))
|
||||
}
|
||||
|
||||
/// Reload a plugin (for development)
|
||||
pub async fn reload_plugin(
|
||||
State(state): State<AppState>,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue