Skip to content

Commit

Permalink
Merge branch 'piccolo-orm:master' into charts_support
Browse files Browse the repository at this point in the history
  • Loading branch information
sinisaos authored Jun 29, 2023
2 parents bc19e7c + 8731cad commit 6d8909a
Show file tree
Hide file tree
Showing 11 changed files with 99 additions and 30 deletions.
10 changes: 10 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
Changes
=======

0.51.0
------

Improved the UI for password inputs (e.g. on the change password page). Thanks
to @sinisaos for this.

Fixed a bug with nullable date fields.

-------------------------------------------------------------------------------

0.50.0
------

Expand Down
1 change: 1 addition & 0 deletions admin_ui/src/components/InputField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
noCalendar: format == 'time'
}"
v-bind:name="columnName"
v-bind:placeholder="placeholder"
v-model="localValue"
></flat-pickr>
</template>
Expand Down
50 changes: 50 additions & 0 deletions admin_ui/src/components/PasswordInput.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<template>
<div class="password_wrapper">
<input
name="password"
v-bind:value="value"
v-bind:type="showPassword ? 'text' : 'password'"
v-on:input="$emit('input', $event.target.value)"
/>
<span
class="viewer"
v-if="value"
v-on:click="showPassword = !showPassword"
>
<font-awesome-icon
v-if="!showPassword"
icon="eye"
title="Show password"
/>
<font-awesome-icon v-else icon="eye-slash" title="Hide password" />
</span>
</div>
</template>

<script lang="ts">
export default {
props: {
value: String
},
data() {
return {
showPassword: false
}
}
}
</script>

<style lang="less">
div.password_wrapper {
position: relative;
span.viewer {
color: #878787;
position: absolute;
top: 0.5rem;
right: 0.5rem;
z-index: 1;
cursor: pointer;
}
}
</style>
2 changes: 2 additions & 0 deletions admin_ui/src/fontawesome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
faQuestionCircle,
faSearch,
faSignOutAlt,
faEyeSlash,
faSort,
faSun,
faTable,
Expand Down Expand Up @@ -80,6 +81,7 @@ library.add(
faQuestionCircle,
faSearch,
faSignOutAlt,
faEyeSlash,
faSort,
faSun,
faTable,
Expand Down
2 changes: 2 additions & 0 deletions admin_ui/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ export function convertFormValue(params: {
value = null
} else if (schema?.properties[key].format == "date-time" && value == "") {
value = null
} else if (schema?.properties[key].format == "date" && value == "") {
value = null
} else if (schema?.properties[key].type == "integer" && value == "") {
value = null
} else if (schema?.properties[key].type == "number" && value == "") {
Expand Down
32 changes: 10 additions & 22 deletions admin_ui/src/views/ChangePassword.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,16 @@
<div id="change_password">
<div class="inner">
<BackButton />
<h1>{{ $t("Change password") }}</h1>
<div class="heading">
<h1>{{ $t("Change password") }}</h1>
</div>
<form v-on:submit.prevent="changePassword">
<label>{{ $t("Current password") }}</label>
<input
name="current_password"
type="password"
v-model="currentPassword"
/>

<PasswordInput v-model="currentPassword" />
<label>{{ $t("New password") }}</label>
<input
name="new_password"
type="password"
v-model="newPassword"
/>

<PasswordInput v-model="newPassword" />
<label>{{ $t("New password confirmation") }}</label>
<input
name="confirm_new_password"
type="password"
v-model="confirmNewPassword"
/>

<PasswordInput v-model="confirmNewPassword" />
<button>{{ $t("Change password") }}</button>
</form>
</div>
Expand All @@ -34,6 +21,7 @@
<script lang="ts">
import axios from "axios"
import BackButton from "../components/BackButton.vue"
import PasswordInput from "../components/PasswordInput.vue"
export default {
data() {
Expand All @@ -44,11 +32,11 @@ export default {
}
},
components: {
BackButton
BackButton,
PasswordInput
},
methods: {
async changePassword() {
console.log("Changing password")
const payload = {
current_password: this.currentPassword,
new_password: this.newPassword,
Expand All @@ -58,7 +46,7 @@ export default {
await axios.post(`./api/change-password/`, payload)
this.$store.commit("updateApiResponseMessage", {
contents: `Changed password successfully. You will be redirected
to the login page to log in with your new credentials.`,
to log in with your new credentials.`,
type: "success"
})
setTimeout(() => {
Expand Down
25 changes: 18 additions & 7 deletions admin_ui/src/views/Login.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<template>
<div id="login">
<div class="inner">
<h1>{{ siteName }}</h1>
<div class="heading">
<h1>{{ siteName }}</h1>
</div>
<form v-on:submit.prevent="login">
<label>{{ $t("Username") }}</label>
<input name="username" type="text" v-model="username" />

<label>{{ $t("Password") }}</label>
<input name="password" type="password" v-model="password" />

<PasswordInput v-model="password" />
<button data-uitest="login_button">{{ $t("Login") }}</button>
</form>
</div>
Expand All @@ -17,14 +18,18 @@

<script lang="ts">
import axios from "axios"
import PasswordInput from "../components/PasswordInput.vue"
export default {
data: function () {
data() {
return {
username: "",
password: ""
}
},
components: {
PasswordInput
},
computed: {
siteName() {
return this.$store.state.metaModule.siteName
Expand Down Expand Up @@ -68,10 +73,16 @@ div#login {
max-width: 30rem;
padding: 0 0.5rem;
h1 {
margin-top: 0;
padding-top: 4rem;
div.heading {
text-align: center;
h1 {
margin-top: 0;
padding-top: 4rem;
text-align: center;
border-bottom: 3px solid #009dff;
display: inline-block;
}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions e2e/test_null_columns.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,7 @@ def test_add_nullable_columns(page: Page, dev_server):
"numeric": None,
"uuid": None,
"email": None,
"timestamp": None,
"date": None,
}
]
2 changes: 2 additions & 0 deletions piccolo_admin/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ class NullableColumns(Table):
numeric = Numeric(null=True, default=None)
uuid = UUID(null=True, default=None)
email = Email(null=True, default=None)
timestamp = Timestamp(null=True, default=None)
date = Date(null=True, default=None)


class SortedColumns(Table):
Expand Down
2 changes: 1 addition & 1 deletion piccolo_admin/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.50.0
0.51.0
1 change: 1 addition & 0 deletions requirements/test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ pytest==7.3.1
pytest-cov==4.0.0
flake8==5.0.4
piccolo[postgres,sqlite]>=0.30.0
playwright==1.35.0
pytest-playwright==0.3.3
httpx>=0.20.0

0 comments on commit 6d8909a

Please sign in to comment.