Skip to content

Commit

Permalink
#747 add a test page for new table with data - server side
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidBlaa committed Mar 14, 2024
1 parent 47bb203 commit a73ef51
Show file tree
Hide file tree
Showing 17 changed files with 196 additions and 180 deletions.
17 changes: 13 additions & 4 deletions Console/BExIS.Web.Shell.Svelte/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Console/BExIS.Web.Shell.Svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
},
"type": "module",
"dependencies": {
"@bexis2/bexis2-core-ui": "0.4.0",
"@bexis2/bexis2-core-ui": "0.4.2",
"@sveltejs/adapter-static": "^3.0.1",
"patch-package": "^8.0.0",
"svelte-collapsible": "^0.3.0",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
},
"type": "module",
"dependencies": {
"@bexis2/bexis2-core-ui": "0.4.0",
"@bexis2/bexis2-core-ui": "0.4.2",
"@bexis2/bexis2-rpm-ui": "^0.1.3",
"@floating-ui/dom": "^1.6.3",
"@fortawesome/free-solid-svg-icons": "^6.5.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
%sveltekit.head%
</head>
<body data-theme="bexis2theme" >
<div id="edit" dataset="11" version="0" >
<div id="test" dataset="1">
<div id="edit" dataset="3" version="0" >
<div id="datastructure" dataset="2" version="0" file="Plants Species Interactions.csv">
<div id="view" dataset="1" version="0">
<div style="display: contents" class="h-full overflow-hidden">%sveltekit.body%</div>
</div>
</div>
</div>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
{/if}
<div class="h-full w-full">
{#if !wait}
<slot name="view" {errorHandler} {successHandler} {warningHandler} {dateHandler}
<slot {errorHandler} {successHandler} {warningHandler} {dateHandler}
>render view</slot
>
{:else}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
function errorHandler(e) {
console.log('error event in data');
}
</script>

{#if hooks}
Expand All @@ -62,8 +64,8 @@
</div>
</HookContainer>

<HookContainer {...dataDescriptionHook} let:errorHandler let:dateHandler>
<div slot="view">
<HookContainer {...dataDescriptionHook} let:dateHandler >
<div>
<DataDescription
{id}
{version}
Expand All @@ -81,7 +83,7 @@
let:warningHandler
let:dateHandler
>
<div slot="view">
<div >
<FileUpload
{id}
{version}
Expand All @@ -95,13 +97,13 @@
</HookContainer>

<HookContainer {...validationHook}>
<div slot="view">
<div >
<Validation {id} {version} {...validationHook} />
</div>
</HookContainer>

<HookContainer {...submitHook} let:errorHandler let:successHandler let:warningHandler>
<div slot="view">
<div >
<Submit
{id}
{version}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<!-- if hooks list is loaded render hooks -->

<HookContainer {...attachmentHook} let:errorHandler let:successHandler color={hookColor}>
<div slot="view">
<div >
<Attachments
{id}
{version}
Expand All @@ -50,7 +50,7 @@

{#each addtionalhooks as hook}
<HookContainer {...hook} color={hookColor}>
<div slot="view">
<div >
<Hook {id} {version} {...hook} />
</div>
</HookContainer>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { setApiConfig } from '@bexis2/bexis2-core-ui';

/** @type {import('./$types').PageLoad} */
export function load() {
if (import.meta.env.DEV) {
console.log('dev');
setApiConfig('https://localhost:44345', 'davidschoene', '123456');
}

return {};
}
Original file line number Diff line number Diff line change
@@ -1,30 +1,52 @@
<script lang="ts">
import { SlideToggle } from '@skeletonlabs/skeleton';
import type { fileInfoType } from '@bexis2/bexis2-core-ui';
import { Api } from '@bexis2/bexis2-core-ui';
import { setApiConfig } from '@bexis2/bexis2-core-ui';
import { onMount } from 'svelte';
onMount(async () => {
console.log('start entity template');
// setApiConfig("https://localhost:44345","davidschoene","123456");
try {
const response = await Api.get('/dcm/entitytemplates/Load');
console.log('data', response.data);
} catch (error) {
console.error(error);
import { Page, Table, type TableConfig } from '@bexis2/bexis2-core-ui';
import { host, username, password } from '@bexis2/bexis2-core-ui';
import { writable } from 'svelte/store';
import { getToken } from '$services/BaseCaller';
// load attributes from div
let container;
let id:number|undefined = undefined;
type ServerTableType = {
id: number;
name: string;
};
let serverTableConfig: TableConfig<ServerTableType>;
$:serverTableConfig;
let t:string = "";
load();
async function load() {
// get data from parent
container = document.getElementById('test');
id = Number(container?.getAttribute('dataset'));
const tableStore = writable<any[]>([]);
const url = host+"/api/datatable/"
t = await getToken();
serverTableConfig = {
id: 'serverTable', // a unique id for the table
entityId: id, // dataset ID
versionId: -1, // vesion ID
data: tableStore, // store to hold and retrieve data
serverSide: true, // serverSide needs to be set to true
// URL for the table to be fetched from
URL: url,
token: t // API token to access the datasets
};
console.log(url,t,id, serverTableConfig)
}
});
$: toggle = false;
</script>

<h1>Test with layout</h1>

<SlideToggle name="david" bind:checked={toggle} />
<br />
<Page>

{#if serverTableConfig}
<Table config={serverTableConfig} />
{/if}

<b>toggle : {toggle}</b>
</Page>
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,16 @@ export const goTo = async (url, intern = true) => {
window.open(url, '_blank')?.focus();
}
};


import { Api } from '@bexis2/bexis2-core-ui';

export const getToken = async () => {
try {
const response = await Api.get('/tokens/get');
return response.data;
} catch (error) {
console.error(error);
throw error;
}
};
Loading

0 comments on commit a73ef51

Please sign in to comment.