The project contains template code for creating external web report widgets for Polyanalyst 6.5 distribution. External widgets allow developers to create thier own visualizations and integrate them into Polyanalyst 6.5 Web Reports.
The project consist of:
- scripts for generating widget code;
- script for creating a widget archive;
- configuration for the webpack.
Install a required version of Node.js from the link above.
There are two ways to install yarn on your local machine:
- using the
corepack enablecommand; - using the
npm install yarn globalcommand.
- Clone repository with
git clone https://github.com/Megaputer/external-widget-template.gitcommand; - Go to directory with
cd external-widget-templatecommand; - Run the following
yarn installcommand to install required packages.
To create a widget run the yarn create:widget command and specify a widget name.
For example, you can write Example and the example directory will be created in the src folder. The folder will contain the following files: model.tsx, view.tsx, info.json, styles.css.
Structure of the directory example:
└───example
info.json
model.tsx
styles.css
view.tsx
There are three commands for bundling code:
yarn prodcreates anexample.jsfile with code minification without sourcemap inside thebuildfolder. It also copies theinfo.jsonfile as anexample.jsonfile into thebuildfolder.yarn devcreates anexample.jsfile and anexample.js.mapfile containing the source code inside thebuildfolder. It also copies theinfo.jsonfile as anexample.jsonfile into thebuildfolder.yarn dev:watchdoes the same thing as thedevcommand, but watch the files and recompile whenever they change.
For ease of development, you can specify the --output-path parameter to set the output location of the package file.
Example: yarn prod --output-path="C:/Megaputer Intelligence/PolyAnalyst 6.5 Server 64-bit/data/externals.
In the externals folder a folder named by the GUID of the external widget will be created. The folder will contain the following files: model.tsx, view.tsx, info.json, styles.css.
To upload an external widget through the administration panel, you need to create an archive with extension zip.
To create an archive use the yarn archive command. After the command starts, the build folder will contain an archive with the name of the project directory.