applied patch

This commit is contained in:
Lewis Larsen 2022-11-02 09:37:51 +00:00
parent aa145a7b33
commit f09acf1e8d
11 changed files with 117 additions and 110 deletions

View File

@ -98,8 +98,8 @@ impl Component for App {
let link = self.link.clone(); let link = self.link.clone();
let is_admin = self.is_admin(); let is_admin = self.is_admin();
html! { html! {
<div> <div>
{self.view_banner()} {self.view_banner()}
<div class="container py-3 bg-kug"> <div class="container py-3 bg-kug">
<div class="row justify-content-center" style="padding-bottom: 80px;"> <div class="row justify-content-center" style="padding-bottom: 80px;">
<div class="py-3" style="max-width: 1000px"> <div class="py-3" style="max-width: 1000px">
@ -109,8 +109,8 @@ impl Component for App {
</div> </div>
</div> </div>
{self.view_footer()} {self.view_footer()}
</div>
</div> </div>
</div>
} }
} }
} }
@ -174,9 +174,9 @@ impl App {
<div> <div>
<UserTable /> <UserTable />
<NavButton classes="btn btn-primary" route=AppRoute::CreateUser> <NavButton classes="btn btn-primary" route=AppRoute::CreateUser>
<i class="bi-person-plus me-2"></i> <i class="bi-person-plus me-2"></i>
{"Create a user"} {"Create a user"}
</NavButton> </NavButton>
</div> </div>
}, },
AppRoute::CreateGroup => html! { AppRoute::CreateGroup => html! {
@ -186,9 +186,9 @@ impl App {
<div> <div>
<GroupTable /> <GroupTable />
<NavButton classes="btn btn-primary" route=AppRoute::CreateGroup> <NavButton classes="btn btn-primary" route=AppRoute::CreateGroup>
<i class="bi-plus-circle me-2"></i> <i class="bi-plus-circle me-2"></i>
{"Create a group"} {"Create a group"}
</NavButton> </NavButton>
</div> </div>
}, },
AppRoute::GroupDetails(group_id) => html! { AppRoute::GroupDetails(group_id) => html! {
@ -225,7 +225,7 @@ impl App {
<Link <Link
classes="nav-link px-2 link-dark h6" classes="nav-link px-2 link-dark h6"
route=AppRoute::ListUsers> route=AppRoute::ListUsers>
<i class="bi-people me-2"></i> <i class="bi-people me-2"></i>
{"Users"} {"Users"}
</Link> </Link>
</li> </li>
@ -233,7 +233,7 @@ impl App {
<Link <Link
classes="nav-link px-2 link-dark h6" classes="nav-link px-2 link-dark h6"
route=AppRoute::ListGroups> route=AppRoute::ListGroups>
<i class="bi-collection me-2"></i> <i class="bi-collection me-2"></i>
{"Groups"} {"Groups"}
</Link> </Link>
</li> </li>
@ -256,15 +256,15 @@ impl App {
<path d="M11 6a3 3 0 1 1-6 0 3 3 0 0 1 6 0z"/> <path d="M11 6a3 3 0 1 1-6 0 3 3 0 0 1 6 0z"/>
<path fill-rule="evenodd" d="M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8zm8-7a7 7 0 0 0-5.468 11.37C3.242 11.226 4.805 10 8 10s4.757 1.225 5.468 2.37A7 7 0 0 0 8 1z"/> <path fill-rule="evenodd" d="M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8zm8-7a7 7 0 0 0-5.468 11.37C3.242 11.226 4.805 10 8 10s4.757 1.225 5.468 2.37A7 7 0 0 0 8 1z"/>
</svg> </svg>
// show user id {
{if let Some((user_id, _)) = &self.user_info { html! { if let Some((user_id, _)) = &self.user_info {
<span class="ms-2"> html! {
{user_id} <span class="ms-2">
</span> {user_id}
} </span>
} else { html!{} } }
} } else { html!{} }
// end show user id }
</a> </a>
{if let Some((user_id, _)) = &self.user_info { html! { {if let Some((user_id, _)) = &self.user_info { html! {
<ul <ul

View File

@ -220,8 +220,13 @@ impl Component for ChangePasswordForm {
type Field = yew_form::Field<FormModel>; type Field = yew_form::Field<FormModel>;
html! { html! {
<> <>
<div class="mb-2 mt-2"><h5 class="fw-bold">{"Change password"}</h5></div> <div class="mb-2 mt-2">
{ if let Some(e) = &self.common.error { <h5 class="fw-bold">
{"Change password"}
</h5>
</div>
{
if let Some(e) = &self.common.error {
html! { html! {
<div class="alert alert-danger mt-3 mb-3"> <div class="alert alert-danger mt-3 mb-3">
{e.to_string() } {e.to_string() }
@ -256,8 +261,8 @@ impl Component for ChangePasswordForm {
<label for="new_password" <label for="new_password"
class="form-label col-sm-2 col-form-label"> class="form-label col-sm-2 col-form-label">
{"New Password"} {"New Password"}
<span class="text-danger">{"*"}</span> <span class="text-danger">{"*"}</span>
{":"} {":"}
</label> </label>
<div class="col-sm-10"> <div class="col-sm-10">
<Field <Field
@ -277,9 +282,9 @@ impl Component for ChangePasswordForm {
<div class="form-group row mb-3"> <div class="form-group row mb-3">
<label for="confirm_password" <label for="confirm_password"
class="form-label col-sm-2 col-form-label"> class="form-label col-sm-2 col-form-label">
{"Confirm Password"} {"Confirm Password"}
<span class="text-danger">{"*"}</span> <span class="text-danger">{"*"}</span>
{":"} {":"}
</label> </label>
<div class="col-sm-10"> <div class="col-sm-10">
<Field <Field
@ -296,21 +301,21 @@ impl Component for ChangePasswordForm {
</div> </div>
</div> </div>
</div> </div>
<div class="form-group row justify-content-center"> <div class="form-group row justify-content-center">
<button <button
class="btn btn-primary col-auto col-form-label" class="btn btn-primary col-auto col-form-label"
type="submit" type="submit"
disabled=self.common.is_task_running() disabled=self.common.is_task_running()
onclick=self.common.callback(|e: MouseEvent| {e.prevent_default(); Msg::Submit})> onclick=self.common.callback(|e: MouseEvent| {e.prevent_default(); Msg::Submit})>
<i class="bi-save me-2"></i> <i class="bi-save me-2"></i>
{"Save changes"} {"Save changes"}
</button> </button>
<NavButton <NavButton
classes="btn btn-secondary ms-2 col-auto col-form-label" classes="btn btn-secondary ms-2 col-auto col-form-label"
route=AppRoute::UserDetails(self.common.username.clone())> route=AppRoute::UserDetails(self.common.username.clone())>
<i class="bi-arrow-return-left me-2"></i> <i class="bi-arrow-return-left me-2"></i>
{"Back"} {"Back"}
</NavButton> </NavButton>
</div> </div>
</form> </form>
</> </>

View File

@ -107,10 +107,10 @@ impl Component for CreateGroupForm {
<div class="form-group row mb-3"> <div class="form-group row mb-3">
<label for="groupname" <label for="groupname"
class="form-label col-4 col-form-label"> class="form-label col-4 col-form-label">
{"Group name"} {"Group name"}
<span class="text-danger">{"*"}</span> <span class="text-danger">{"*"}</span>
{":"} {":"}
</label> </label>
<div class="col-8"> <div class="col-8">
<Field <Field
form=&self.form form=&self.form
@ -131,8 +131,8 @@ impl Component for CreateGroupForm {
type="submit" type="submit"
disabled=self.common.is_task_running() disabled=self.common.is_task_running()
onclick=self.common.callback(|e: MouseEvent| {e.prevent_default(); Msg::SubmitForm})> onclick=self.common.callback(|e: MouseEvent| {e.prevent_default(); Msg::SubmitForm})>
<i class="bi-save me-2"></i> <i class="bi-save me-2"></i>
{"Save changes"} {"Submit"}
</button> </button>
</div> </div>
</form> </form>

View File

@ -19,10 +19,10 @@ use yew_router::{
#[derive(GraphQLQuery)] #[derive(GraphQLQuery)]
#[graphql( #[graphql(
schema_path = "../schema.graphql", schema_path = "../schema.graphql",
query_path = "queries/create_user.graphql", query_path = "queries/create_user.graphql",
response_derives = "Debug", response_derives = "Debug",
custom_scalars_module = "crate::infra::graphql" custom_scalars_module = "crate::infra::graphql"
)] )]
pub struct CreateUser; pub struct CreateUser;
@ -43,8 +43,8 @@ pub struct CreateUserModel {
first_name: String, first_name: String,
last_name: String, last_name: String,
#[validate(custom( #[validate(custom(
function = "empty_or_long", function = "empty_or_long",
message = "Password should be longer than 8 characters (or left empty)" message = "Password should be longer than 8 characters (or left empty)"
))] ))]
password: String, password: String,
#[validate(must_match(other = "password", message = "Passwords must match"))] #[validate(must_match(other = "password", message = "Passwords must match"))]
@ -201,9 +201,9 @@ impl Component for CreateUserForm {
<div class="form-group row mb-3"> <div class="form-group row mb-3">
<label for="username" <label for="username"
class="form-label col-4 col-form-label"> class="form-label col-4 col-form-label">
{"User name"} {"User name"}
<span class="text-danger">{"*"}</span> <span class="text-danger">{"*"}</span>
{":"} {":"}
</label> </label>
<div class="col-8"> <div class="col-8">
<Field <Field
@ -223,8 +223,8 @@ impl Component for CreateUserForm {
<label for="email" <label for="email"
class="form-label col-4 col-form-label"> class="form-label col-4 col-form-label">
{"Email"} {"Email"}
<span class="text-danger">{"*"}</span> <span class="text-danger">{"*"}</span>
{":"} {":"}
</label> </label>
<div class="col-8"> <div class="col-8">
<Field <Field
@ -244,9 +244,9 @@ impl Component for CreateUserForm {
<div class="form-group row mb-3"> <div class="form-group row mb-3">
<label for="display-name" <label for="display-name"
class="form-label col-4 col-form-label"> class="form-label col-4 col-form-label">
{"Display name"} {"Display name"}
<span class="text-danger">{"*"}</span> <span class="text-danger">{"*"}</span>
{":"} {":"}
</label> </label>
<div class="col-8"> <div class="col-8">
<Field <Field
@ -346,12 +346,13 @@ impl Component for CreateUserForm {
disabled=self.common.is_task_running() disabled=self.common.is_task_running()
type="submit" type="submit"
onclick=self.common.callback(|e: MouseEvent| {e.prevent_default(); Msg::SubmitForm})> onclick=self.common.callback(|e: MouseEvent| {e.prevent_default(); Msg::SubmitForm})>
<i class="bi-save me-2"></i> <i class="bi-save me-2"></i>
{"Save changes"} {"Submit"}
</button> </button>
</div> </div>
</form> </form>
{ if let Some(e) = &self.common.error { {
if let Some(e) = &self.common.error {
html! { html! {
<div class="alert alert-danger"> <div class="alert alert-danger">
{e.to_string() } {e.to_string() }

View File

@ -154,16 +154,16 @@ impl DeleteGroup {
type="button" type="button"
class="btn btn-secondary" class="btn btn-secondary"
onclick=self.common.callback(|_| Msg::DismissModal)> onclick=self.common.callback(|_| Msg::DismissModal)>
<i class="bi-x-circle me-2"></i> <i class="bi-x-circle me-2"></i>
{"Cancel"} {"Cancel"}
</button> </button>
<button <button
type="button" type="button"
onclick=self.common.callback(|_| Msg::ConfirmDeleteGroup) onclick=self.common.callback(|_| Msg::ConfirmDeleteGroup)
class="btn btn-danger"> class="btn btn-danger">
<i class="bi-check-circle me-2"></i> <i class="bi-check-circle me-2"></i>
{"Yes, I'm sure"} {"Yes, I'm sure"}
</button> </button>
</div> </div>
</div> </div>
</div> </div>

View File

@ -152,16 +152,16 @@ impl DeleteUser {
type="button" type="button"
class="btn btn-secondary" class="btn btn-secondary"
onclick=self.common.callback(|_| Msg::DismissModal)> onclick=self.common.callback(|_| Msg::DismissModal)>
<i class="bi-x-circle me-2"></i> <i class="bi-x-circle me-2"></i>
{"Cancel"} {"Cancel"}
</button> </button>
<button <button
type="button" type="button"
onclick=self.common.callback(|_| Msg::ConfirmDeleteUser) onclick=self.common.callback(|_| Msg::ConfirmDeleteUser)
class="btn btn-danger"> class="btn btn-danger">
<i class="bi-check-circle me-2"></i> <i class="bi-check-circle me-2"></i>
{"Yes, I'm sure"} {"Yes, I'm sure"}
</button> </button>
</div> </div>
</div> </div>
</div> </div>

View File

@ -145,7 +145,7 @@ impl GroupDetails {
{if g.users.is_empty() { {if g.users.is_empty() {
html! { html! {
<tr key="EmptyRow"> <tr key="EmptyRow">
<td>{"There are currently no users in this group."}</td> <td>{"There are no users in this group."}</td>
<td/> <td/>
</tr> </tr>
} }

View File

@ -195,7 +195,7 @@ impl Component for LoginForm {
class="btn btn-primary" class="btn btn-primary"
disabled=self.common.is_task_running() disabled=self.common.is_task_running()
onclick=self.common.callback(|e: MouseEvent| {e.prevent_default(); Msg::Submit})> onclick=self.common.callback(|e: MouseEvent| {e.prevent_default(); Msg::Submit})>
<i class="bi-box-arrow-in-right me-2"/> <i class="bi-box-arrow-in-right me-2"/>
{"Login"} {"Login"}
</button> </button>
<NavButton <NavButton

View File

@ -113,7 +113,7 @@ impl Component for ResetPasswordStep1Form {
class="btn btn-primary" class="btn btn-primary"
disabled=self.common.is_task_running() disabled=self.common.is_task_running()
onclick=self.common.callback(|e: MouseEvent| {e.prevent_default(); Msg::Submit})> onclick=self.common.callback(|e: MouseEvent| {e.prevent_default(); Msg::Submit})>
<i class="bi-check-circle me-2"/> <i class="bi-check-circle me-2"/>
{"Reset password"} {"Reset password"}
</button> </button>
<NavButton <NavButton

View File

@ -201,12 +201,12 @@ impl Component for UserDetails {
<NavButton <NavButton
route=AppRoute::ChangePassword(u.id.clone()) route=AppRoute::ChangePassword(u.id.clone())
classes="btn btn-secondary"> classes="btn btn-secondary">
<i class="bi-key me-2"></i> <i class="bi-key me-2"></i>
{"Modify password"} {"Modify password"}
</NavButton> </NavButton>
</div> </div>
<div> <div>
<h5 class="row m-3 fw-bold">{"User details"}</h5> <h5 class="row m-3 fw-bold">{"User details"}</h5>
</div> </div>
<UserDetailsForm <UserDetailsForm
user=u.clone() /> user=u.clone() />

View File

@ -52,11 +52,11 @@ pub struct UserModel {
/// The GraphQL query sent to the server to update the user details. /// The GraphQL query sent to the server to update the user details.
#[derive(GraphQLQuery)] #[derive(GraphQLQuery)]
#[graphql( #[graphql(
schema_path = "../schema.graphql", schema_path = "../schema.graphql",
query_path = "queries/update_user.graphql", query_path = "queries/update_user.graphql",
response_derives = "Debug", response_derives = "Debug",
variables_derives = "Clone,PartialEq,Eq", variables_derives = "Clone,PartialEq,Eq",
custom_scalars_module = "crate::infra::graphql" custom_scalars_module = "crate::infra::graphql"
)] )]
pub struct UpdateUser; pub struct UpdateUser;
@ -180,7 +180,7 @@ impl Component for UserDetailsForm {
html! { html! {
<div class="py-3"> <div class="py-3">
<form class="form"> <form class="form">
<div class="form-group row mb-3"> <div class="form-group row mb-3">
<label for="userId" <label for="userId"
class="form-label col-4 col-form-label"> class="form-label col-4 col-form-label">
{"User ID: "} {"User ID: "}
@ -189,10 +189,10 @@ impl Component for UserDetailsForm {
<span id="userId" class="form-control-static"><i>{&self.common.user.id}</i></span> <span id="userId" class="form-control-static"><i>{&self.common.user.id}</i></span>
</div> </div>
</div> </div>
<div class="form-group row mb-3"> <div class="form-group row mb-3">
<label for="creationDate" <label for="creationDate"
class="form-label col-4 col-form-label"> class="form-label col-4 col-form-label">
{"Creation date: "} {"Creation date: "}
</label> </label>
<div class="col-8"> <div class="col-8">
<span id="creationDate" class="form-control-static">{&self.common.user.creation_date.date().naive_local()}</span> <span id="creationDate" class="form-control-static">{&self.common.user.creation_date.date().naive_local()}</span>
@ -200,8 +200,8 @@ impl Component for UserDetailsForm {
</div> </div>
<div class="form-group row mb-3"> <div class="form-group row mb-3">
<label for="uuid" <label for="uuid"
class="form-label col-4 col-form-label"> class="form-label col-4 col-form-label">
{"UUID: "} {"UUID: "}
</label> </label>
<div class="col-8"> <div class="col-8">
<span id="creationDate" class="form-control-static">{&self.common.user.uuid}</span> <span id="creationDate" class="form-control-static">{&self.common.user.uuid}</span>
@ -210,9 +210,9 @@ impl Component for UserDetailsForm {
<div class="form-group row mb-3"> <div class="form-group row mb-3">
<label for="email" <label for="email"
class="form-label col-4 col-form-label"> class="form-label col-4 col-form-label">
{"Email"} {"Email"}
<span class="text-danger">{"*"}</span> <span class="text-danger">{"*"}</span>
{":"} {":"}
</label> </label>
<div class="col-8"> <div class="col-8">
<Field <Field
@ -232,8 +232,8 @@ impl Component for UserDetailsForm {
<label for="display_name" <label for="display_name"
class="form-label col-4 col-form-label"> class="form-label col-4 col-form-label">
{"Display Name"} {"Display Name"}
<span class="text-danger">{"*"}</span> <span class="text-danger">{"*"}</span>
{":"} {":"}
</label> </label>
<div class="col-8"> <div class="col-8">
<Field <Field
@ -283,30 +283,30 @@ impl Component for UserDetailsForm {
</div> </div>
</div> </div>
</div> </div>
<div class="form-group row align-items-center mb-3"> <div class="form-group row align-items-center mb-3">
<label for="avatar" <label for="avatar"
class="form-label col-4 col-form-label"> class="form-label col-4 col-form-label">
{"Avatar: "} {"Avatar: "}
</label> </label>
<div class="col-8"> <div class="col-8">
<div class="row align-items-center"> <div class="row align-items-center">
<div class="col-8"> <div class="col-8">
<input <input
class="form-control" class="form-control"
id="avatarInput" id="avatarInput"
type="file" type="file"
accept="image/jpeg" accept="image/jpeg"
oninput=self.common.callback(|_| Msg::Update) /> oninput=self.common.callback(|_| Msg::Update) />
</div> </div>
<div class="col-4"> <div class="col-4">
<img <img
id="avatarDisplay" id="avatarDisplay"
src={format!("data:image/jpeg;base64, {}", avatar_string)} src={format!("data:image/jpeg;base64, {}", avatar_string)}
style="max-height:128px;max-width:128px;height:auto;width:auto;" style="max-height:128px;max-width:128px;height:auto;width:auto;"
alt="Avatar" /> alt="Avatar" />
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="form-group row justify-content-center mt-3"> <div class="form-group row justify-content-center mt-3">
<button <button
@ -314,12 +314,13 @@ impl Component for UserDetailsForm {
class="btn btn-primary col-auto col-form-label" class="btn btn-primary col-auto col-form-label"
disabled=self.common.is_task_running() disabled=self.common.is_task_running()
onclick=self.common.callback(|e: MouseEvent| {e.prevent_default(); Msg::SubmitClicked})> onclick=self.common.callback(|e: MouseEvent| {e.prevent_default(); Msg::SubmitClicked})>
<i class="bi-save me-2"></i> <i class="bi-save me-2"></i>
{"Save changes"} {"Save changes"}
</button> </button>
</div> </div>
</form> </form>
{ if let Some(e) = &self.common.error { {
if let Some(e) = &self.common.error {
html! { html! {
<div class="alert alert-danger"> <div class="alert alert-danger">
{e.to_string() } {e.to_string() }