Skip to content

Commit 0a503e0

Browse files
authored
Merge pull request #20 from visagang/main
Add improvement to user profile
2 parents 9f2239a + 13386ab commit 0a503e0

File tree

7 files changed

+36
-9
lines changed

7 files changed

+36
-9
lines changed

.env

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ PUBLIC_BRAND_NAME=BotSharp
1111
PUBLIC_ADMIN_USERNAME=admin@gmail.com
1212
PUBLIC_ADMIN_PASSWORD=123456
1313
PUBLIC_COMPANY_NAME=SciSharp STACK
14-
PUBLIC_PLUGIN_DEFAULT_ICON=https://avatars.githubusercontent.com/u/44989469?s=200&v=4
14+
PUBLIC_PLUGIN_DEFAULT_ICON=https://avatars.githubusercontent.com/u/44989469?s=200&v=4
15+
PUBLIC_ALLOW_SIGNUP=false

src/lib/common/Loader.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<script>
22
import { Circle } from 'svelte-loading-spinners';
3+
export let size=100
34
</script>
45

56
<div class="loader">
6-
<Circle size="100" color="#6F42C1" unit="px" duration="1s" />
7+
<Circle {size} color="var(--bs-primary)" unit="px" duration="1s" />
78
</div>

src/lib/common/ProfileDropdown.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
export let user;
99
function logout() {
1010
if (browser){
11-
localStorage.removeItem('authUser');
11+
localStorage.removeItem('user');
1212
}
1313
goto('/');
1414
};
@@ -27,7 +27,7 @@
2727
</DropdownToggle>
2828
<DropdownMenu end>
2929
<!-- item-->
30-
<DropdownItem href="/page/myProfile"
30+
<DropdownItem href="/page/user/me"
3131
><i class="bx bx-user font-size-16 align-middle me-1" />
3232
<span>Profile</span>
3333
</DropdownItem>

src/routes/(authentication)/login/+page.svelte

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,36 @@
2222
PUBLIC_BRAND_NAME,
2323
PUBLIC_ADMIN_USERNAME,
2424
PUBLIC_ADMIN_PASSWORD,
25-
PUBLIC_COMPANY_NAME
25+
PUBLIC_COMPANY_NAME,
26+
PUBLIC_ALLOW_SIGNUP
2627
} from '$env/static/public';
28+
import { onMount } from 'svelte';
2729
2830
let username = PUBLIC_ADMIN_USERNAME;
2931
let password = PUBLIC_ADMIN_PASSWORD;
3032
let isOpen = false;
3133
let msg = '';
3234
let status = '';
3335
let isSubmitting = false;
36+
let isRememberMe = false;
37+
onMount(() => {
38+
const userName = localStorage.getItem('user_name');
39+
isRememberMe = userName !== null;
40+
if(isRememberMe){
41+
username = userName;
42+
}
43+
});
44+
function handleRememberMe(){
45+
if(isRememberMe){
46+
localStorage.setItem("user_name", username);
47+
}
48+
else {
49+
localStorage.removeItem("user_name");
50+
}
51+
}
3452
async function onSubmit(e) {
3553
isSubmitting = true;
54+
handleRememberMe();
3655
e.preventDefault();
3756
await getToken(username, password, () => {
3857
isOpen = true;
@@ -62,7 +81,7 @@
6281
<Container>
6382
<Row class="justify-content-center">
6483
{#if isSubmitting}
65-
<Loader />
84+
<Loader size={50} />
6685
{/if}
6786
<Col md={8} lg={6} xl={5}>
6887
<Card class="overflow-hidden">
@@ -133,7 +152,12 @@
133152
</div>
134153

135154
<div class="form-check">
136-
<input class="form-check-input" type="checkbox" id="remember-check" />
155+
<input
156+
class="form-check-input"
157+
type="checkbox"
158+
id="remember-check"
159+
bind:checked={isRememberMe}
160+
/>
137161
<Label class="form-check-label" for="remember-check">Remember me</Label>
138162
</div>
139163

@@ -178,7 +202,7 @@
178202
</CardBody>
179203
</Card>
180204
<div class="mt-5 text-center">
181-
<p>
205+
<p hidden={!(PUBLIC_ALLOW_SIGNUP === 'true')}>
182206
Don&apos;t have an account ?
183207
<Link href="/register" class="fw-medium text-primary">Signup now</Link>
184208
</p>

src/routes/page/dashboard/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
</Col>
8787
</Row>
8888
<div class="mt-4">
89-
<Link href="/page/myProfile" class="btn btn-primary waves-effect waves-light btn-sm">
89+
<Link href="/page/user/me" class="btn btn-primary waves-effect waves-light btn-sm">
9090
View Profile <i class="mdi mdi-arrow-right ms-1" />
9191
</Link>
9292
</div>
File renamed without changes.

svelte.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const config = {
4949
"/page/plugin/[pluginId]",
5050
"/page/setting",
5151
"/page/mongodb",
52+
"/page/user/me",
5253
"/chat",
5354
"/chat/[agentId]",
5455
"/chat/[agentId]/[conversationId]",

0 commit comments

Comments
 (0)