GithubHelp home page GithubHelp logo

creative-connections / bodylight.js-components Goto Github PK

View Code? Open in Web Editor NEW
7.0 6.0 1.0 215.04 MB

Web components for Bodylight technology - to support in-browser simulators capable to execute models via standard FMI api, visualise using common chart libraries (chartjs, plotly, dygraph) and Adobe Animate components (exported as createjs components).

Home Page: https://bodylight.physiome.cz/aurelia-bodylight-plugin

License: MIT License

JavaScript 94.87% HTML 1.55% Shell 0.04% CSS 3.45% Python 0.09%
web-simulator fmu bodylight-components webassembly

bodylight.js-components's Introduction

Bodylight.js-Components

stability-beta Version Zenodo Published on webcomponents.org Maintainability Codacy Badge

Web components of the Bodylight library. For full documentation see https://bodylight.physiome.cz/Bodylight-docs/reference/. Project portal with links to samples at https://bodylight.physiome.cz/

Bodylight.js web components is a suite of custom elements enhancing HTML web documents with

  • FMU component able to be execute in browser. Modelica model is exported to FMU using FMI standard and Bodylight FMU Compiler can convert FMU with source codes and solver into WebAssembly script.
  • Adobe-Animate and Gif-Animate component able to control animation exported from Adobe-Animate or animated GIF and bind them to variables of model simulation.
  • ChartJS and DygraphJS components to visualise model variables in different chart types.
  • Following Web components standard.

All bodylight web components are registered with a bdl- prefix. Components are defined in source code without the prefix, which may be used to build application internally in an Aurelia framework https://aurelia.io This repository contains wrapper code for aurelia-bodylight-plugin registering all Aurelia[2] components as standard (framework agnostic) web components [1].

This plugin is part of broader tools to enable in-browser simulation using modern web technologies: Web Assembly, HTML, Javascript (ECMAScript6).

Usage

To build web simulator:

  1. You need to export Modelica model into FMU with source codes including source codes for solver (Dymola exports CVODE, OpenModelica 1.14.x exports Euler and 1.16.x is declared to support CVODE export too).
  2. Then you need to convert the FMU into WebAssembly - using Bodylight FMU Compiler
  3. the exported ZIP contains JS file - to be reffered from bdl-fmi component, and modelDescription.xml - standard FMU description with variable references.
  4. optional - export Adobe Animate animation into CreateJS library usable by bdl-adobe component.
  5. use the Bodylight components, This plugin is distributed in 2 different way: 1) as standard web components or 2) as aurelia components.
    • 1. Standard web components - distribution recommended to build web simulator using enhanced HTML or Markdown.
    • 2. Aurelia web components - recommended for more complex web application

Live demo and tutorial

https://bodylight.physiome.cz/Bodylight-docs/tutorial/#basic.md

1. Standard web components

  1. Use bodylight.bundle.js from :

    • from jsdelivr CDN:
      <script src="https://cdn.jsdelivr.net/npm/bodylight-components/dist/bodylight.bundle.js"></script>
    • OR install bundle by npm: npm i bodylight-components
    • OR download bodylight.bundle.js locally and refer it from your <script>:
        <script src="bodylight.bundle.js"></script>
  2. Add attribute aurelia-app="webcomponents" to div or body where web components will be located (note that web-components are distinguished by the prefix bdl- from other HTML elements:

index.html
...
<body aurelia-app="webcomponents">
  <bdl-range id="id1" min="40" max="180" default="60" title="Heart rate"></bdl-range>
  <bdl-fmi ...></bdl-fmi>
  <bdl-chartjs ...></bdl-chartjs>
</body>
  1. (optional) you may use any of bdl-markdown-* components to refer MD documents where you may use Bodylight webcomponents as well. E.g. doc/index.md contains main content and summary.md contains sidebar with links to other docs.
index.html
...
<body aurelia-app="webcomponents">
    <bdl-markdown-book index="doc/index.md" summary="doc/summary.md">
      <img src="docs/loading.gif"/>
    </bdl-markdown-book>
</body>
doc/index.md

# Introduction
Markdown syntax is interpretted. Syntax highlighting is enabled for source code. KATEX plugin is enabled to allow
basic equation e.g. $$e = m c^2$$

## bodylight web components
Use bodylight web components directly:
  <bdl-range id="id1" min="40" max="180" default="60" title="Heart rate"></bdl-range>
  <bdl-fmi ...></bdl-fmi>
  <bdl-chartjs ...></bdl-chartjs>
summary.md
| EN | [CZ](#doc/index.cs.md&summary=doc/summary.cs.md) |   
  * [First Page](#doc/index.md)
  * [Second Page](#doc/index2.md)
    * [Sub page of second page](#doc/index22.md)

Bodylight webcomponents in Moodle

  1. edit moodle page in HTML - use HTML source, click and then siwtch code - click
  2. add the bodylight script
    <script type="module" src="https://bodylight.physiome.cz/Bodylight.js-Components/bodylight.bundle.js"></script>
    <div aurelia-app="webcomponents"><br>
  3. add bodylight component, note that markdown component needs base to be specified so relative links are rendered correctly inside Moodle. For resources in github repo use cdn.jsdelivr.net/gh/ which is returning correct MIME Type.
    <bdl-markdown 
       src="https://cdn.jsdelivr.net/gh/creative-connections/Bodylight-Scenarios@master/hemodynamics/index.cs.md" 
       base="https://cdn.jsdelivr.net/gh/creative-connections/Bodylight-Scenarios@master/">
    bdl-markdown not supported
    </bdl-markdown>
    This allows FMI scripts and MD content to be loaded correctly.

Bodylight webcomponents in Adobe Captivate

Bodylight Web Components cannot be inserted directly into Adobe Captivate, however, content created in HTML or MD and hosted in some domain can be added using direct URL as Web Object. You may use the showmenu=false URL parameter, e.g.: https://bodylight.physiome.cz/Bodylight-Scenarios/#hemodynamics/hemo2.cs.md&showmenu=false

2. Aurelia web components

We recommend to use aurelia framework to build web application with Bodylight Web components. Follow Aurelia doc's how to prepare your project and install aurelia-bodylight-plugin by npm command-line:

npm i aurelia-bodylight-plugin

In your main.js file enable the plugin by aurelia.use.plugin(PLATFORM.moduleName('aurelia-bodylight-plugin')), so it may look like:

//main.js
import {PLATFORM} from 'aurelia-pal';

export function configure(aurelia) {
  aurelia.use
    .standardConfiguration()
    .plugin(PLATFORM.moduleName('aurelia-bodylight-plugin'))

  aurelia.start().then(() => {
    aurelia.setRoot(PLATFORM.moduleName('app'));
  });
}

Bodylight web components are available in any template, use them without bdl- prefix:

<template>
  <range id="id1" min="40" max="180" default="60" title="Heart rate"></range>
  <fmi ...></fmi>
  <chartjs ...></chartjs>
...
</template>

Developer's Guide

Download source code

  • git clone https://github.com/creative-connections/aurelia-bodylight-plugin.git
  • git clone https://github.com/creative-connections/Bodylight.js-Components.git

To develop

  • components sources at
  • cd aurelia-bodylight-plugin
  • npm i
  • au build - builds the plugin
  • build-all.sh - builds plugin and ../Bodylight.js-Components at once

To test

  • Either manually copy bodylight.bundle.js to /test directory
  • OR npm run build - this will copy bundle into /test dir
  • THEN serve http from /test folder

To publish

  • npm login - logs into npmjs
  • sudo npm i np -g - installs np tool globally
  • np - UI to publish bodylight-components into npm as package

bodylight.js-components's People

Contributors

dependabot[bot] avatar tomaskulhanek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

galactromeda

bodylight.js-components's Issues

Feedback, VS, sound, missing links

https://bodylight.physiome.cz/Bodylight.js-Components/#doc/index.md

  • Virtual body mi tam nefunguje, ale hádám, že to ještě nemá?
  • Hemo 1 - vypadá dobře. Co se týká textu, je tam jen malá drobnost (chybějící -e): Srdeční revoluce se skládá ze dvou základních fází. Graf běhá v pořádku, ale když se nad ním objevují popisky, jdou přes graf a špatně se čtou. Šlo by je nějak oddělit?
  • Ten zvuk srdečního tepu je hrozně hlasitý, stačilo by jeho hlasitost zmenšit na polovinu.
  • Nerozumím tomu, co zobrazuje ten kruhový graf. Možná by to taky chtělo popisky? Nebo to nějak barevně propojit s tím druhým grafem.
  • Hemo 2 - vše v pořádku, jen tam chybí mezera mezi slovem a pomlčkou: komorová systola -
  • Prošla jsem ten text a tady jsou nějaké úpravy: https://docs.google.com/document/d/1TP34poyWWIQmHKT9SALcwhxtscQ4Y9LsYgBXSCVPFzY/edit?usp=sharing

Support for interactive presentation master/slave

  • educator mode (separate.html) - may set 'hash' i.e. document to be viewed by students
  • student mode (index.html) - may view only one page, based on what educator set

  • firebase configuration component - bdl-fb-config
  • encrypt firebase configuration component -<bdl-fb-config api-str="...."></bdl-fb-config>
  • component to set state, present as button, educator mode will do it - <bdl-set-state title="State 1" value="state1.md">...
  • component to get state, present as hidden, student mode - <bdl-get-state tohash="true">...
  • firebase config to listen new state, via websockets - attribute listen="true"
  • option to hide nav icon - attribute showicon in markdown-

Navigace pro vyukovy material

  • cist obsah z indexu
  • renderovat obsah stranky
  • renderovat sipky vpred a zpet
  • umoznit zapnout rizenou navigaci, tj. povoleni jit vpred, pokud na strane je splnen nejaky ukol komponenta, povolit zpet vzdy, postup vzdy o jednu, WON'T
  • moznost renderovat sidebar nebo top down menu

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.