Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement account functions #34

Merged
merged 34 commits into from
Jul 14, 2024
Merged
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
4976505
add basic account page style
cbh778899 Jul 11, 2024
a6c619e
scroll to bottom when switch session
cbh778899 Jul 11, 2024
c4b817b
rename type: out->user; in->assistant
cbh778899 Jul 11, 2024
126a931
add functions to manage cookies
cbh778899 Jul 12, 2024
68aef6c
use different session title
cbh778899 Jul 12, 2024
2a1d1e0
implement user page
cbh778899 Jul 12, 2024
3997d58
add custom hook to manage user information
cbh778899 Jul 12, 2024
2af9a45
update style so it won't looks strange
cbh778899 Jul 12, 2024
d3a088d
update request function to directly return json on demand
cbh778899 Jul 12, 2024
b08a924
update isRegister to false after login
cbh778899 Jul 12, 2024
c956ea6
rename type to role
cbh778899 Jul 12, 2024
3188608
can normally save/load history now
cbh778899 Jul 12, 2024
d12f8d3
fix url
cbh778899 Jul 12, 2024
bf6dc17
fix history & conversation page switch when login/logout
cbh778899 Jul 12, 2024
f165986
add header Content-Type: application/json to patch request as well
cbh778899 Jul 13, 2024
89d2d50
implement updateuserinfo
cbh778899 Jul 13, 2024
8387b01
update login page style
cbh778899 Jul 13, 2024
23f8e38
implement show message
cbh778899 Jul 13, 2024
1432c9d
handle request HTTP error
cbh778899 Jul 13, 2024
6ab47c7
return to check if need to show message
cbh778899 Jul 13, 2024
c85f594
update style
cbh778899 Jul 13, 2024
d8977fb
implement change user info
cbh778899 Jul 13, 2024
8e1bd88
fix bugs user cannot click
cbh778899 Jul 13, 2024
40574ee
updateall after update info
cbh778899 Jul 13, 2024
4fc0f14
fix bugs when user switched page and cannot toggle sidebar expand
cbh778899 Jul 13, 2024
c7571c9
update style
cbh778899 Jul 13, 2024
b632a9f
implement save user info to local
cbh778899 Jul 13, 2024
6d29b7f
update message background
cbh778899 Jul 13, 2024
23d0860
add function to create a fake dialog, so we make sure messages showes…
cbh778899 Jul 14, 2024
e3581a6
implement createDialog to replace dialogs
cbh778899 Jul 14, 2024
4ac162e
remove dialog global styles
cbh778899 Jul 14, 2024
fb780c8
update dialog style
cbh778899 Jul 14, 2024
f2ebefe
update version
cbh778899 Jul 14, 2024
67333e3
fix event propagation bug
cbh778899 Jul 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update login page style
Signed-off-by: cbh778899 <[email protected]>
cbh778899 committed Jul 13, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 8387b01d8f25804dee80d892d1e834a2d04e3149
31 changes: 28 additions & 3 deletions components/account-page/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import capitalizeFirstLetter from "../../tools/capitalizeFirstLetter.js";
import useUser from '../../global/useUser.js'
import capitalizeFirstLetter from "../../tools/capitalizeFirstLetter.js";
import getSVG from "../../tools/svgs.js";

let account_dialog = null, input_details_main = null;
let current_user = {}, isRegister = false;
@@ -108,7 +109,9 @@ function submitDetails(evt) {
const new_password = evt.target['new-password'].value;
const repeat_new_password = evt.target['repeat-new-password'].value;
const submit_values = {}
if(email) submit_values.email = email;
if(email && email !== current_user.email) {
submit_values.email = email;
}
if(new_password) {
if(repeat_new_password !== new_password) {
evt.target['repeat-new-password'].classList.add('error');
@@ -178,13 +181,35 @@ function createAccountInputFields({
input.type = type || 'text';
input.name = index;
input.value = value;
input.placeholder = ' '
input.autocomplete = 'off'
if(readonly) input.readOnly = 'true';

field_container.onclick = () => input.focus();
field_container.appendChild(title_element);
field_container.appendChild(input);

if(type === 'password') {
// TODO
let show_password = false;

const eye_icon = document.createElement('div');
eye_icon.className = 'password-eye-icon clickable';

const toggleShowPassword = () => {
if(!show_password) {
input.type = 'password';
eye_icon.innerHTML = getSVG('eye');
eye_icon.title = 'Show Password';
} else {
input.type = 'text';
eye_icon.innerHTML = getSVG('eye-slash');
eye_icon.title = 'Hide Password';
}
show_password = !show_password;
}
toggleShowPassword();
eye_icon.onclick = toggleShowPassword;
field_container.appendChild(eye_icon);
}

return field_container;
66 changes: 49 additions & 17 deletions styles/account_page.css
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@

.account-main .input-details-main {
--item-width: 230px;
--item-height: 40px;
--item-height: 45px;

position: absolute;
width: calc(var(--details-width) - 20px);
@@ -45,38 +45,70 @@
}

.input-details-main .account-field-container {
width: fit-content;
height: fit-content;
width: var(--item-width);
height: var(--item-height);
position: relative;
margin-bottom: 10px;
margin-bottom: 15px;
max-width: 100%;
border: 1px solid gray;
border-radius: 5px;
}
.input-details-main .account-field-container:hover {
cursor: text;
}

.input-details-main .account-field-container:has(input:focus) {
border-color: dodgerblue;
}

.input-details-main .account-field-container .title {
position: absolute;
color: gray;
font-size: 18px;
margin-bottom: 5px;
font-weight: bold;
position: relative;
max-width: 100%;
width: 100%;
height: 100%;
line-height: var(--item-height);
left: 10px;
top: 0px;
transition-duration: .5s;
transform-origin: top left;
user-select: none;
}

.input-details-main .account-field-container:has(input:focus) .title,
.input-details-main .account-field-container:has(input:not(:placeholder-shown)) .title
{
transform: scale(0.6);
}
.input-details-main .account-field-container:has(input:focus) .title {
color: dodgerblue;
}

.input-details-main .account-field-container input {
width: var(--item-width);
height: var(--item-height);
border: 1px solid gray;
border-radius: 5px;
width: 100%;
height: 30%;
border: none;
box-sizing: border-box;
padding: 0px 15px;
font-size: 16px;
position: relative;
position: absolute;
max-width: 100%;
bottom: 5px;
background-color: transparent;
}
.input-details-main .account-field-container input:focus {
outline: none;
}
.input-details-main .account-field-container input.error {
border-color: red;

.password-eye-icon {
position: absolute;
height: var(--item-height);
width: var(--item-height);
display: flex;
align-items: center;
right: 0;
}
.password-eye-icon svg { margin: auto; }

.input-details-main hr {
width: var(--item-width);
@@ -89,15 +121,15 @@

.input-details-main .function-btn {
width: var(--item-width);
height: calc(var(--item-height) + 5px);
height: calc(var(--item-height) - 3px);
border-radius: 16px;
background-color: dodgerblue;
color: white;
box-sizing: border-box;
border: none;
font-size: 18px;
font-weight: bold;
margin-top: 20px;
margin-top: 17px;
display: block;
position: relative;
max-width: 100%;