dashjoin / platform

Dashjoin Is an Open Source & Cloud Native Low Code Development and Integration Platform that helps teams deliver applications faster 🚀 Uses a data-driven approach inspired by Linked Data to make use of your existing assets
https://dashjoin.com
GNU Affero General Public License v3.0
89 stars 7 forks source link

Define standard variables like base_url, database, etc. or have them in the context #364

Closed pgrill79 closed 3 weeks ago

pgrill79 commented 1 month ago

Would be good if there are some standard variables or context values, like

base_url or database

In our case we often build some URLs dynamically. In the context we have the href, but then we have to cut of everything after the base URL first.

Also would be good to define a kind of database variables - you have the name of the database in the context $.database if you are on a record page. But if you have a Dashboard. and want to use the $ query function you have to hardcode the database as the $.database is not available.

The actual workaround is to define a function e.g. "getDatabase", which can be called from everywere which returns the name of the database. If the database then changes i only have to change it once in the Function.

aeberhart commented 3 weeks ago

Regarding the base_url, you do have the browser href available in the context. From our conversation, I remember discussing to add functions that allow the standardized processing of URLs (e.g. https://developer.mozilla.org/en-US/docs/Web/API/URL)

Not sure I understand the issue regarding the DB name. I guess you could just hard-code the name. The only problem of this approach would be that it cannot be changed easily.

An alternative would be to use setVariable("db", ...) to make the value available via variable.db. There are many places where setVariable could be called from. The best on in this case would probably be the on-login hook: https://dashjoin.github.io/platform/latest/administration/#ui-customizations

This example sets the login time first instance:

image
pgrill79 commented 3 weeks ago

Regarding the Href:

Yes , in the context i have e.g the

href: http://localhost:19010/#/wooltest/client/97561525-1488-47ea-ace1-d7824657c28a

but i want to show a link to e.g. an animal - so i need to a function that gives me the substring until the first single / (which returns "http://localhost:19010" and then i append the subpath to the animal. This is not a big deal, but maybe to get the base url "http://localhost:19010" also in the context it would be good.

I also tried to set the baseurl and call this funciton in the on-login, but it seems that there is no href available at this time.

(But this is not a big issue - as i have a simple workaround parsing the href).

The tip with setting the database in the on-login worked fine. Good idea.

Only that the Expression field in the "on-login" is very small again. ;)

aeberhart commented 3 weeks ago

TODOs: