pwbi
Power BI
Provides tools to integrate Power BI into Drupal
What is it for?
These modules provide the tools to integrate Power BI into Drupal, with
the different modules you will be able to access the embed and RestAPI of PowerBi.
This is the process workflow and the role of each of the modules in it:
Dependencies
PowerBi Embed needs the PowerBi client from https://github.com/microsoft/PowerBI-JavaScript. There are three options to install it.
Preferred method:
PowerBi Embed provides a package.json to include the powerbi-client library. Make sure you have NPM of nodejs installed in your system and from the module folder, run `npm install`.
Alternatively, in your composer add the following script in your post-install-cmd scripts in order to install the
dependencies with each `composer install`.
{
"scripts": {
"post-install-cmd": [
"npm install -C [path to module]"
]
}
In the script above, it is assumed that the `pwbi` module is installed in the `web/modules/contrib` directory as
a relative path from the project root or where your `composer.json` is located. Adapt the path according to your installation.
Composer
You can use composer to download the powerbi js client by taking these steps:
1. Run the following command to ensure that you have the "composer/installers"
package installed:
composer require --prefer-dist composer/installers
2. Add the following to the "installer-paths" section of "composer.json":
"libraries/{$name}": ["type:drupal-library"],
3. Add the following to the "repositories" section of "composer.json":
{
"type": "package",
"package": {
"name": "microsoft/powerbi",
"version": "2.1.19",
"type": "drupal-library",
"dist": {
"url": "https://github.com/microsoft/PowerBI-JavaScript/archive/refs/tags/v2.19.1.zip",
"type": "zip"
}
}
}
4. Run the following command; you should find that new directories have been
created under "/libraries".
composer require --prefer-dist microsoft/powerbi
Alternative methods:
Manually download and install the library, from https://github.com/microsoft/PowerBI-JavaScript, in the `libraries` folder in the webroot, profile directory or site directory
within drupal. The package should be placed as such, so that the path looks like
`
/powerbi/dist/powerbi.min.js` where `
` is one of the directories mentioned above.
Usage
Power BI Authentication
1. Give permissions to configure the module (Administer Power BI configuration).
2. Configure access credentials: admin/config/pwbi/authentication_settings.
3. Include the service pwbi_authentication.authentication and use the method ::getAccessToken() to get the access token.
4. Use the access token on request to PowerBi Rest API.
Configure pwbi_embed
1. Configure available PowerBi workspaces: admin/config/pwbi/embed_settings
2. Create a Media Entity using the "PowerBi Embed" Media Type
3. Create Media content.
Customizing PowerBi embed
This module allows others to customize the js embedding process. This is achieved by
two events trigger before and after embedding:
1. PowerBiPreEmbed: This event is triggered before embedding the object and allows changing the configuration options,
using something like this:
window.addEventListener("PowerBiPreEmbed",
(e) => {
const powerBiConfig = e.detail;
}
);
2. PowerBiPostEmbed: This event is triggered after embedding the object and allows changing the embedded object,
using something like this:
window.addEventListener("PowerBiPostEmbed",
(e) => {
const powerBiReport = e.detail;
}
);