From 25647eadc07ea9ef971861099cb1c2c3340e537c Mon Sep 17 00:00:00 2001 From: Ivan Izaguirre <ivanizag@gmail.com> Date: Fri, 15 Jul 2022 17:05:53 +0200 Subject: [PATCH] Display the creation date for groups --- app/queries/get_group_details.graphql | 1 + app/queries/get_group_list.graphql | 1 + app/src/components/group_details.rs | 32 ++++++++++++++++++++++++++- app/src/components/group_table.rs | 6 ++++- schema.graphql | 1 + server/src/infra/graphql/query.rs | 3 +++ 6 files changed, 42 insertions(+), 2 deletions(-) diff --git a/app/queries/get_group_details.graphql b/app/queries/get_group_details.graphql index b338527..e500f8d 100644 --- a/app/queries/get_group_details.graphql +++ b/app/queries/get_group_details.graphql @@ -2,6 +2,7 @@ query GetGroupDetails($id: Int!) { group(groupId: $id) { id displayName + creationDate users { id displayName diff --git a/app/queries/get_group_list.graphql b/app/queries/get_group_list.graphql index 28f56e4..54714c2 100644 --- a/app/queries/get_group_list.graphql +++ b/app/queries/get_group_list.graphql @@ -2,5 +2,6 @@ query GetGroupList { groups { id displayName + creationDate } } diff --git a/app/src/components/group_details.rs b/app/src/components/group_details.rs index 442fec5..a1e63f6 100644 --- a/app/src/components/group_details.rs +++ b/app/src/components/group_details.rs @@ -68,6 +68,36 @@ impl GroupDetails { } } + fn view_details(&self, g: &Group) -> Html { + html! { + <> + <h3>{g.display_name.to_string()}</h3> + <div class="py-3"> + <form class="form"> + <div class="form-group row mb-3"> + <label for="displayName" + class="form-label col-4 col-form-label"> + {"Group: "} + </label> + <div class="col-8"> + <span id="groupId" class="form-constrol-static">{g.display_name.to_string()}</span> + </div> + </div> + <div class="form-group row mb-3"> + <label for="creationDate" + class="form-label col-4 col-form-label"> + {"Creation date: "} + </label> + <div class="col-8"> + <span id="creationDate" class="form-constrol-static">{g.creation_date.date().naive_local()}</span> + </div> + </div> + </form> + </div> + </> + } + } + fn view_user_list(&self, g: &Group) -> Html { let make_user_row = |user: &User| { let user_id = user.id.clone(); @@ -92,7 +122,6 @@ impl GroupDetails { }; html! { <> - <h3>{g.display_name.to_string()}</h3> <h5 class="fw-bold">{"Members"}</h5> <div class="table-responsive"> <table class="table table-striped"> @@ -201,6 +230,7 @@ impl Component for GroupDetails { (Some(u), error) => { html! { <div> + {self.view_details(u)} {self.view_user_list(u)} {self.view_add_user_button(u)} {self.view_messages(error)} diff --git a/app/src/components/group_table.rs b/app/src/components/group_table.rs index e6c7a0e..206c084 100644 --- a/app/src/components/group_table.rs +++ b/app/src/components/group_table.rs @@ -97,7 +97,8 @@ impl GroupTable { <table class="table table-striped"> <thead> <tr> - <th>{"Groups"}</th> + <th>{"Group name"}</th> + <th>{"Creation date"}</th> <th>{"Delete"}</th> </tr> </thead> @@ -122,6 +123,9 @@ impl GroupTable { {&group.display_name} </Link> </td> + <td> + {&group.creation_date.date().naive_local()} + </td> <td> <DeleteGroup group=group.clone() diff --git a/schema.graphql b/schema.graphql index 71ae663..55b9f92 100644 --- a/schema.graphql +++ b/schema.graphql @@ -17,6 +17,7 @@ type Mutation { type Group { id: Int! displayName: String! + creationDate: DateTimeUtc! "The groups to which this user belongs." users: [User!]! } diff --git a/server/src/infra/graphql/query.rs b/server/src/infra/graphql/query.rs index 19d0b65..20f4ae6 100644 --- a/server/src/infra/graphql/query.rs +++ b/server/src/infra/graphql/query.rs @@ -272,6 +272,9 @@ impl<Handler: BackendHandler + Sync> Group<Handler> { fn display_name(&self) -> String { self.display_name.clone() } + fn creation_date(&self) -> chrono::DateTime<chrono::Utc> { + self.creation_date + } /// The groups to which this user belongs. async fn users(&self, context: &Context<Handler>) -> FieldResult<Vec<User<Handler>>> { let span = debug_span!("[GraphQL query] group::users");