Skip to content

Commit bcf25d1

Browse files
committed
BEXIS2/Core#1518 add a post fn for log off with __RequestVerificationToken
1 parent 785593d commit bcf25d1

File tree

8 files changed

+100
-12
lines changed

8 files changed

+100
-12
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
11
# bexis-core-ui
2+
## 0.4.11
3+
- Menu
4+
- fix log off
5+
6+
## 0.4.10
7+
- Table:
8+
- Fixes issue with sticky Tables not rendering the filters correctly.
9+
- Fixes issues related to date picker in Tables with date filters.
10+
- Updates default Table page sizes to [5, 10, 20, 50, 100].
11+
- Updates the structure of server-side configuration for Tables.
12+
- Adds new page size dropdown in Table for to fix contrast issues in the component.
13+
- Adds showing/hiding Table columns.
14+
15+
- Facets:
16+
- Adds Facets component.
17+
218
## 0.4.8
319
- page
420
- add notification if api call to backend faild

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@bexis2/bexis2-core-ui",
3-
"version": "0.4.8",
3+
"version": "0.4.10",
44
"private": false,
55
"scripts": {
66
"dev": "vite dev",

src/lib/components/page/menu/Menu.svelte

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<script lang="ts">
22
import { onMount } from 'svelte';
33
import { getMenuItems } from './MenuDataCaller';
4-
import { menuStore } from '$store/pageStores';
4+
import { menuStore } from "../../../stores/pageStores";
55
66
import MenuBar from './MenuBar.svelte';
7+
import MenuAccountBar from './MenuAccountBar.svelte';
78
import SettingsBar from './SettingsBar.svelte';
89
import Fa from 'svelte-fa';
910
import { faBars } from '@fortawesome/free-solid-svg-icons';
@@ -49,7 +50,7 @@
4950
<!-- </div> -->
5051
<!-- <div class="sm:flex items-center sm:gap-5 px-1 text-lg justify-end gap-2"> -->
5152
<div class="grid w-full sm:flex gap-2 justify-auto sm:justify-end">
52-
<MenuBar menuBar={$menuStore.AccountBar} />
53+
<MenuAccountBar menuBar={$menuStore.AccountBar} />
5354
<MenuBar menuBar={$menuStore.LaunchBar} />
5455
<SettingsBar menuBar={$menuStore.Settings} />
5556
<!-- </div> -->
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<script lang="ts">
2+
import { computePosition, autoUpdate, offset, shift, flip, arrow } from '@floating-ui/dom';
3+
import { storePopup } from '@skeletonlabs/skeleton';
4+
storePopup.set({ computePosition, autoUpdate, offset, shift, flip, arrow });
5+
6+
import type { menuItemType } from '../../../models/Page';
7+
import Item from './MenuItem.svelte';
8+
9+
export let menuBar: menuItemType[];
10+
11+
let comboboxValue: string;
12+
13+
</script>
14+
15+
{#if menuBar}
16+
<div class="h-full place-self-center sm:flex gap-2 w-full sm:w-auto">
17+
18+
{#each menuBar as menubarItem}
19+
20+
<Item {menubarItem} {comboboxValue} />
21+
22+
{/each}
23+
24+
</div>
25+
{/if}

src/lib/components/page/menu/MenuBar.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
import { storePopup } from '@skeletonlabs/skeleton';
44
storePopup.set({ computePosition, autoUpdate, offset, shift, flip, arrow });
55
6-
import type { MenuItem } from './menu';
6+
import type { menuItemType } from '../../../models/Page';
77
import Item from './MenuItem.svelte';
88
9-
export let menuBar: MenuItem[];
9+
export let menuBar: menuItemType[];
1010
1111
let comboboxValue: string;
1212
</script>

src/lib/components/page/menu/MenuItem.svelte

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
77
//types
88
import type { PopupSettings } from '@skeletonlabs/skeleton';
9-
import type { menuItemType } from '$models/Page';
9+
import type { menuItemType } from '../../../models/Page';
1010
11-
import { goTo } from '$services/BaseCaller';
11+
import { goTo } from '../../../services/BaseCaller';
1212
1313
export let menubarItem: menuItemType;
1414
export let comboboxValue;
@@ -40,7 +40,8 @@
4040
>
4141
<svelte:fragment slot="content"
4242
><MenuSublist {id} items={menubarItem.Items} /></svelte:fragment
43-
></AccordionItem
43+
>
44+
</AccordionItem
4445
>
4546
</div>
4647
<div class="hidden sm:block place-self-center" use:popup={popupCombobox}>

src/lib/components/page/menu/MenuSublist.svelte

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script lang="ts">
22
import { ListBox, ListBoxItem } from '@skeletonlabs/skeleton';
3-
import type { menuItemType } from '$models/Page';
4-
import { goTo } from '$services/BaseCaller';
3+
import type { menuItemType } from '../../../models/Page';
4+
import { goTo } from '../../../services/BaseCaller';
55
66
export let items: menuItemType[];
77
@@ -22,19 +22,64 @@
2222
return true;
2323
}
2424
}
25+
26+
function clickFn(item)
27+
{
28+
if(item.Title =="Logoff")
29+
{
30+
logOffFn();
31+
return;
32+
}
33+
else{
34+
goTo(item.Url)
35+
}
36+
}
37+
38+
39+
async function logOffFn() {
40+
41+
console.log('logoff');
42+
// Prepare the body content for the POST request
43+
44+
45+
let bodyContent = '__RequestVerificationToken='+ window.antiForgeryToken;
46+
47+
try {
48+
const response = await fetch('/Account/logoff', {
49+
method: 'POST',
50+
credentials: 'include', // Include cookies for authentication
51+
headers: {
52+
'Content-Type': 'application/x-www-form-urlencoded'
53+
},
54+
body:bodyContent
55+
});
56+
if (response.ok) {
57+
// Redirect to login page after logout
58+
window.location.href = '/Account/Login';
59+
} else {
60+
console.error('Logout failed');
61+
}
62+
} catch (error) {
63+
console.error('Error during logout:', error);
64+
}
65+
}
66+
67+
2568
</script>
2669

2770
<ListBox class="sm:bg-white sm:border overflow-y-auto max-h-[500px]">
2871
{#each items as item}
2972
{#if isNewModule(item.Module)}<hr class="text-surface-800" />{/if}
73+
3074
<ListBoxItem
3175
class="text-md sm:text-sm text-surface-800 py-1 hover:text-secondary-500 bg-transparent hover:bg-surface-200"
3276
bind:group={item.Title}
3377
name="medium"
3478
value={item.Title}
35-
on:click={() => goTo(item.Url)}
79+
on:click={() => clickFn(item)}
3680
>
3781
{item.Title}
3882
</ListBoxItem>
83+
3984
{/each}
4085
</ListBox>

src/routes/+layout.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export async function load({ fetch }) {
1111
if (import.meta.env.DEV) {
1212
console.log('dev');
1313

14-
setApiConfig('http://localhost:44345/', 'davidschoene', '123456');
14+
setApiConfig('http://localhost:44345/', 'admin', '123456');
1515

1616
} else if (import.meta.env.PROD) {
1717
console.log('PROD');

0 commit comments

Comments
 (0)