mirror of
				https://github.com/nitnelave/lldap.git
				synced 2023-04-12 14:25:13 +00:00 
			
		
		
		
	api: add the rest of the fields to User
This commit is contained in:
		
							parent
							
								
									ee21c2f5fc
								
							
						
					
					
						commit
						0cf7b76c1c
					
				| @ -2,8 +2,9 @@ query ListUsersQuery($filters: RequestFilter) { | ||||
|   users(filters: $filters) { | ||||
|     id | ||||
|     email | ||||
|     groups { | ||||
|       id | ||||
|     } | ||||
|     displayName | ||||
|     firstName | ||||
|     lastName | ||||
|     creationDate | ||||
|   } | ||||
| } | ||||
|  | ||||
| @ -1,8 +0,0 @@ | ||||
| use graphql_client::GraphQLQuery; | ||||
| 
 | ||||
| #[derive(GraphQLQuery)] | ||||
| #[graphql(
 | ||||
|     schema_path = "../schema.graphql", | ||||
|     query_path = "queries/list_users.graphql" | ||||
| )] | ||||
| pub struct ListUsersQuery; | ||||
| @ -4,7 +4,6 @@ mod api; | ||||
| mod app; | ||||
| mod cookies; | ||||
| mod create_user; | ||||
| mod graphql_api; | ||||
| mod login; | ||||
| mod logout; | ||||
| mod user_details; | ||||
|  | ||||
| @ -1,19 +1,24 @@ | ||||
| use crate::{ | ||||
|     api::HostService, | ||||
|     graphql_api::{ | ||||
|         list_users_query::{self, RequestFilter, ResponseData}, | ||||
|         ListUsersQuery, | ||||
|     }, | ||||
| }; | ||||
| use crate::api::HostService; | ||||
| use anyhow::{anyhow, Result}; | ||||
| use lldap_model::*; | ||||
| use graphql_client::GraphQLQuery; | ||||
| use yew::format::Json; | ||||
| use yew::prelude::*; | ||||
| use yew::services::{fetch::FetchTask, ConsoleService}; | ||||
| 
 | ||||
| #[derive(GraphQLQuery)] | ||||
| #[graphql(
 | ||||
|     schema_path = "../schema.graphql", | ||||
|     query_path = "queries/list_users.graphql", | ||||
|     response_derives = "Debug", | ||||
|     custom_scalars_module = "chrono" | ||||
| )] | ||||
| pub struct ListUsersQuery; | ||||
| 
 | ||||
| use list_users_query::{RequestFilter, ResponseData}; | ||||
| 
 | ||||
| pub struct UserTable { | ||||
|     link: ComponentLink<Self>, | ||||
|     users: Option<Result<Vec<User>>>, | ||||
|     users: Option<Result<Vec<list_users_query::ListUsersQueryUsers>>>, | ||||
|     // Used to keep the request alive long enough.
 | ||||
|     _task: Option<FetchTask>, | ||||
| } | ||||
| @ -54,15 +59,7 @@ impl Component for UserTable { | ||||
|     fn update(&mut self, msg: Self::Message) -> ShouldRender { | ||||
|         match msg { | ||||
|             Msg::ListUsersResponse(Ok(users)) => { | ||||
|                 self.users = Some(Ok(users | ||||
|                     .users | ||||
|                     .into_iter() | ||||
|                     .map(|u| User { | ||||
|                         user_id: u.id, | ||||
|                         email: u.email, | ||||
|                         ..Default::default() | ||||
|                     }) | ||||
|                     .collect())); | ||||
|                 self.users = Some(Ok(users.users.into_iter().collect())); | ||||
|                 ConsoleService::log(format!("Response: {:?}", Json(&self.users)).as_str()); | ||||
|                 true | ||||
|             } | ||||
| @ -87,7 +84,7 @@ impl Component for UserTable { | ||||
|                     .map(|u| { | ||||
|                         html! { | ||||
|                             <tr> | ||||
|                                 <td>{&u.user_id}</td> | ||||
|                                 <td>{&u.id}</td> | ||||
|                                 <td>{&u.email}</td> | ||||
|                                 <td>{&u.display_name.as_ref().unwrap_or(&String::new())}</td> | ||||
|                                 <td>{&u.first_name.as_ref().unwrap_or(&String::new())}</td> | ||||
|  | ||||
| @ -26,9 +26,16 @@ type Query { | ||||
|   users(filters: RequestFilter): [User!]! | ||||
| } | ||||
| 
 | ||||
| "NaiveDateTime" | ||||
| scalar NaiveDateTime | ||||
| 
 | ||||
| type User { | ||||
|   id: String! | ||||
|   email: String! | ||||
|   displayName: String | ||||
|   firstName: String | ||||
|   lastName: String | ||||
|   creationDate: NaiveDateTime! | ||||
|   "The groups to which this user belongs." | ||||
|   groups: [Group!]! | ||||
| } | ||||
|  | ||||
| @ -145,6 +145,22 @@ impl<Handler: BackendHandler + Sync> User<Handler> { | ||||
|         &self.user.email | ||||
|     } | ||||
| 
 | ||||
|     fn display_name(&self) -> Option<&String> { | ||||
|         self.user.display_name.as_ref() | ||||
|     } | ||||
| 
 | ||||
|     fn first_name(&self) -> Option<&String> { | ||||
|         self.user.first_name.as_ref() | ||||
|     } | ||||
| 
 | ||||
|     fn last_name(&self) -> Option<&String> { | ||||
|         self.user.last_name.as_ref() | ||||
|     } | ||||
| 
 | ||||
|     fn creation_date(&self) -> chrono::NaiveDateTime { | ||||
|         self.user.creation_date | ||||
|     } | ||||
| 
 | ||||
|     /// The groups to which this user belongs.
 | ||||
|     async fn groups(&self, context: &Context<Handler>) -> FieldResult<Vec<Group<Handler>>> { | ||||
|         Ok(context | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Valentin Tolmer
						Valentin Tolmer