This is a library with client side helper classed to be used with dataease server.
PageTools that is bare minimum to be used to manipulate html and do calls to a server. It is instead of libraries like jquery and is made as small an light weigth as possible, but still have most of what you need.
GuiTools is a extention of PageTools with a few extra gui helpers for doing more like errors and dynamically change colors etc. Some part of this class will need some bootstrap modals and use bootstrap classes for gui changes that need to be set in the class.
ServerConnect is a extention of GuiTools that can connect to server and manipulate data and dql in a easy manner.
Install newest version from server
npm install https://download.2imply.com/deserver/deserver-1.0.4.tgz
When installing a npm and using it in a browser, there are several issues of how to get it to work depending on how old browser you want to support.
The easiest is to find out where the dist directory in node_modules for this module is and just load it as a normal javascript deserver.bundle.js or deserver.bundle.min.js file. The deserver.bundle.js is human readble iife version of all the libraries added as deserver gobal varialble. The deserver.bundle.min.js is a minfied version of the same library, and should be the one you used in deployed software.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>PageTools test</title>
<script src="./node_modules/deserver/dist/deserver.bundle.min.js"></script>
</head>
<body>
<div id="myelement">Initial greeting</div>
<script>
const me = new deserver.PageTools();
me.ready(() => {
let el = me.elm("myelement");
el.innerHTML= "Hello world";
me.htlm("myelement", "Hope for a better world");
});
</script>
</body>
</html>
GuiTools are dependent of both PageTools and some bootstrap.Modal. The easies way if you just want to use GuiTools as is, is to use the bundle that packes both PageTools and GuiTools in the same package for you and install bootstrap into the same app with npm.
npm install bootstrap@latest
Then you need to load both bootstrap and GuiTools bundle.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>GuiTools test</title>
<link href="./node_modules/botstrap/dist/css/bootstrap.min.css">
<script src="/node_modules/botstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="./node_modules/deserver/dist/deserver.bundle.min.js"></script>
</head>
<body>
<div id="myelement" class="text-primary">Initial greeting</div>
<script>
const me = new deserver.GuiTools();
me.setbootstrap(bootstrap); // set a bootstrap instance the are needed for some metods in guitools
me.ready(() => {
let el = me.elm("myelement");
me.htlm(el, "Hello world");
//remove initial blue color and add green instead
me.textremovethenadd(el, undefined, 'success', "Hope for a even better world");
});
</script>
</body>
</html>
If you want to extend GuiTools into our own class, you should use the dist version in a module script or file. If you are coding in TypeScript, you can use include the ts files from the root of the package and build your own bundles.
ServerConnect is a extention of GuiTools that can connect to server and manipulate data and dql in a easy manner. You can use if in the same manner by loading the deserver.bundle.min.js file.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>GuiTools test</title>
<link href="./node_modules/botstrap/dist/css/bootstrap.min.css">
<script src="/node_modules/botstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="./node_modules/deserver/dist/deserver.bundle.min.js"></script>
</head>
<body>
<div>Greetingins <span id="lookupname"></span></div>
<script>
const me = new deserver.ServerConnect();
me.setbootstrap(bootstrap);
// will read the server and port in use from where this page is loaded from
me.me.setupwhere(location.port, `${location.protocol}//${location.hostname}`);
me.ready(async () => {
const tname = 'Customer'; // the table to read data from
const query = 'ID=01010'; // the query as you would write it in DataEase
let jdata = await me.recordget(tname, query);
if (jdata.result == 'ok){
let rec = jdata.recorddata;
me.htlm('lookupname', rec.Name); // set the name found on customer with id 01010
} else {
me.htlm('lookupname', 'stranger'); // no customer found with this id, no access or error
}
});
</script>
</body>
</html>
Set up and run vite, tauri or a bundler.
import {PageTools} from 'deserver';
const me = new PageTools();
me.ready(() => {
let el = me.elm("myelement");
el.innerHTML= "Hello world";
me.htlm("myelement", "Hope for a better world");
});
This needs bootstrap for a few things, so that have to be installed first.
npm install bootstrap@latest
Then you just import it as for PageTools.
import { GuiTools } from "deserver/guitools";
const me = new GuiTools();
me.ready(() => {
let el = me.elm("myelement");
me.htlm(el, "Hello world");
me.textremovethenadd(el, undefined, 'success', "Hope for a even better world");
});
ServerConnect is a extention of GuiTools that can connect to server and manipulate data and dql in a easy manner.
import { ServerConnect } from "deserver/serverconnect";
const me = new ServerConnect();
me.setupwhere(location.port, `${location.protocol}//${location.hostname}`);
let jdata = await me.recordget('Document', 'PageSlug="inforpage"');
if (jdata.result == 'ok'){
me.html('docbody',jdata.recorddata.Body);
} else {
me.html('message', jdata.result + ': ' + jdata.message);
}
Install the following packages global as they differ between x32 and x64 version of node.
npm -g install typescript
npm -g install typedoc
npm -g install @types/node
npm -g install npm-run-all
First update version in package.json, then open a terminal at root of project and run
tsc
npx typedoc index.ts
./node_modules/.bin/rolldown -c .\rolldown.config.ts
npm pack
Now this package can be uploaded to download server and installed by running
Open a terminal at root of project and run
tsc
npx typedoc index.ts
./node_modules/.bin/rolldown -c .\rolldown.config.ts
npm link
Now you can use this project in a local project by opening a terminal in that project and run
npm link deserver