Display the UUID on the user and group details

This commit is contained in:
Ivan Izaguirre 2022-07-15 17:58:08 +02:00
parent 25647eadc0
commit 18862010cc
6 changed files with 33 additions and 0 deletions

View File

@ -3,6 +3,7 @@ query GetGroupDetails($id: Int!) {
id id
displayName displayName
creationDate creationDate
uuid
users { users {
id id
displayName displayName

View File

@ -6,6 +6,7 @@ query GetUserDetails($id: String!) {
firstName firstName
lastName lastName
creationDate creationDate
uuid
groups { groups {
id id
displayName displayName

View File

@ -92,6 +92,15 @@ impl GroupDetails {
<span id="creationDate" class="form-constrol-static">{g.creation_date.date().naive_local()}</span> <span id="creationDate" class="form-constrol-static">{g.creation_date.date().naive_local()}</span>
</div> </div>
</div> </div>
<div class="form-group row mb-3">
<label for="uuid"
class="form-label col-4 col-form-label">
{"UUID: "}
</label>
<div class="col-8">
<span id="uuid" class="form-constrol-static">{g.uuid.to_string()}</span>
</div>
</div>
</form> </form>
</div> </div>
</> </>

View File

@ -195,6 +195,15 @@ impl Component for UserDetailsForm {
<span id="creationDate" class="form-constrol-static">{&self.common.user.creation_date.date().naive_local()}</span> <span id="creationDate" class="form-constrol-static">{&self.common.user.creation_date.date().naive_local()}</span>
</div> </div>
</div> </div>
<div class="form-group row mb-3">
<label for="uuid"
class="form-label col-4 col-form-label">
{"UUID: "}
</label>
<div class="col-8">
<span id="creationDate" class="form-constrol-static">{&self.common.user.uuid}</span>
</div>
</div>
<div class="form-group row justify-content-center"> <div class="form-group row justify-content-center">
<button <button
type="submit" type="submit"
@ -267,6 +276,7 @@ impl UserDetailsForm {
first_name: model.first_name, first_name: model.first_name,
last_name: model.last_name, last_name: model.last_name,
creation_date: self.common.user.creation_date, creation_date: self.common.user.creation_date,
uuid: self.common.user.uuid.clone(),
groups: self.common.user.groups.clone(), groups: self.common.user.groups.clone(),
}; };
self.just_updated = true; self.just_updated = true;

View File

@ -18,6 +18,7 @@ type Group {
id: Int! id: Int!
displayName: String! displayName: String!
creationDate: DateTimeUtc! creationDate: DateTimeUtc!
uuid: String!
"The groups to which this user belongs." "The groups to which this user belongs."
users: [User!]! users: [User!]!
} }
@ -68,6 +69,7 @@ type User {
firstName: String! firstName: String!
lastName: String! lastName: String!
creationDate: DateTimeUtc! creationDate: DateTimeUtc!
uuid: String!
"The groups to which this user belongs." "The groups to which this user belongs."
groups: [Group!]! groups: [Group!]!
} }

View File

@ -221,6 +221,10 @@ impl<Handler: BackendHandler + Sync> User<Handler> {
self.user.creation_date self.user.creation_date
} }
fn uuid(&self) -> &str {
self.user.uuid.as_str()
}
/// The groups to which this user belongs. /// The groups to which this user belongs.
async fn groups(&self, context: &Context<Handler>) -> FieldResult<Vec<Group<Handler>>> { async fn groups(&self, context: &Context<Handler>) -> FieldResult<Vec<Group<Handler>>> {
let span = debug_span!("[GraphQL query] user::groups"); let span = debug_span!("[GraphQL query] user::groups");
@ -260,6 +264,7 @@ pub struct Group<Handler: BackendHandler> {
group_id: i32, group_id: i32,
display_name: String, display_name: String,
creation_date: chrono::DateTime<chrono::Utc>, creation_date: chrono::DateTime<chrono::Utc>,
uuid: String,
members: Option<Vec<String>>, members: Option<Vec<String>>,
_phantom: std::marker::PhantomData<Box<Handler>>, _phantom: std::marker::PhantomData<Box<Handler>>,
} }
@ -275,6 +280,9 @@ impl<Handler: BackendHandler + Sync> Group<Handler> {
fn creation_date(&self) -> chrono::DateTime<chrono::Utc> { fn creation_date(&self) -> chrono::DateTime<chrono::Utc> {
self.creation_date self.creation_date
} }
fn uuid(&self) -> String {
self.uuid.clone()
}
/// The groups to which this user belongs. /// The groups to which this user belongs.
async fn users(&self, context: &Context<Handler>) -> FieldResult<Vec<User<Handler>>> { async fn users(&self, context: &Context<Handler>) -> FieldResult<Vec<User<Handler>>> {
let span = debug_span!("[GraphQL query] group::users"); let span = debug_span!("[GraphQL query] group::users");
@ -303,6 +311,7 @@ impl<Handler: BackendHandler> From<GroupDetails> for Group<Handler> {
group_id: group_details.group_id.0, group_id: group_details.group_id.0,
display_name: group_details.display_name, display_name: group_details.display_name,
creation_date: group_details.creation_date, creation_date: group_details.creation_date,
uuid: group_details.uuid.into_string(),
members: None, members: None,
_phantom: std::marker::PhantomData, _phantom: std::marker::PhantomData,
} }
@ -315,6 +324,7 @@ impl<Handler: BackendHandler> From<DomainGroup> for Group<Handler> {
group_id: group.id.0, group_id: group.id.0,
display_name: group.display_name, display_name: group.display_name,
creation_date: group.creation_date, creation_date: group.creation_date,
uuid: group.uuid.into_string(),
members: Some(group.users.into_iter().map(UserId::into_string).collect()), members: Some(group.users.into_iter().map(UserId::into_string).collect()),
_phantom: std::marker::PhantomData, _phantom: std::marker::PhantomData,
} }