use actix::Addr; use actix_web::{HttpResponse, Responder, web}; use askama::Template; use crate::actors::users_actor; use crate::actors::users_actor::UsersActor; use crate::controllers::settings_controller::BaseSettingsPage; use crate::data::client::{Client, ClientManager}; use crate::data::current_user::CurrentUser; use crate::data::user::User; #[derive(Template)] #[template(path = "settings/clients_list.html")] struct ClientsListTemplate { _parent: BaseSettingsPage, clients: Vec, } #[derive(Template)] #[template(path = "settings/users_list.html")] struct UsersListTemplate { _parent: BaseSettingsPage, users: Vec, } pub async fn clients_route(user: CurrentUser, clients: web::Data) -> impl Responder { HttpResponse::Ok().body(ClientsListTemplate { _parent: BaseSettingsPage::get( "Clients list", &user, None, None, ), clients: clients.cloned(), }.render().unwrap()) } pub async fn users_route(user: CurrentUser, users: web::Data>) -> impl Responder { let users = users.send(users_actor::GetAllUsersRequest).await.unwrap().0; HttpResponse::Ok().body(UsersListTemplate { _parent: BaseSettingsPage::get( "Users list", &user, None, None, ), users, }.render().unwrap()) }