Portal Page Developer Helper
Portal Page Developer Helper allows you to write code for Portal Pages in any IDE and then import it to your Metric Insights application as Portal Page asset. Also you can launch your Portal Page on localhost before applying any changes to the actual Portal Page's code.
PREREQUISITE:
- Install Node.js
Table of contents:
- Create Portal Page
- Create package.json File in Portal Page Directory
- Install Portal Page Developer Helper Package
- Open Portal Page Directory in IDE
- Create a Config File
- Configure package.json File
- Create Content for Portal Page
- Open Portal Page Locally
- Log In to Metric Insights
- View Portal Page Locally And Work With Tool Panel
- Build Portal Page Assets
1. Create Portal Page
Access Content > Portal Pages
- [+New Page]
- Enter a Portal Page Name
- Enter a Name used in URL and note it down, it will be needed later for integration configuration
- Note: Letters, numbers, dashes and underscores are the only supported characters for Portal Pages' URL names
- [Save], this will open the created Portal Page
- Copy and note down the Portal Page's ID from the URL, this value will also be needed for further configuration
2. Create package.json File in Portal Page Directory
Run npm init
from the local Portal Page directory and proceed entering the needed data to create a package.json
file.
3. Install Portal Page Developer Helper Package
Run npm i @metricinsights/pp-dev
to install the Portal Page Developer package.
4. Open Portal Page Directory in IDE
In an IDE:
- Ctrl + K Ctrl + O or [Open Folder]
- Select the Portal Page Folder, [Select Folder]
5. Create a Config File
Note: The name of the config file must be pp-dev.config
.
- Create a file named
pp-dev.config.js
- Enter the following code:
module.exports = {
backendBaseURL: '<MI Application Server>',
portalPageId: <Portal Page ID>,
};
Replace <MI Application Server> with the URL of your MI instance and <Portal Page ID> with the ID of the previously created Portal Page. Save the entered data.
5.1. Optional Parameters
-
miHudLess:
- true: Metric Insights' navigation bar and back-end including jQuery are disabled for Portal Page's local development, Portal Page Variables are accessible.
- false: The default value.
-
templateLess:
-
true: Portal Page Variables are not fetched from a Portal Page. Metric Insights' navigation bar is not displayed. If this parameter is set to true, the
portalPageId
parameter does not have to be provided. - false: The default value.
-
true: Portal Page Variables are not fetched from a Portal Page. Metric Insights' navigation bar is not displayed. If this parameter is set to true, the
-
enableProxyCache:
- true: The default value.
- false: The proxy cache is disabled. It is not recommended to change the value of this parameter, as the proxy cache is utilized to reduce the number of requests to the back-end. It caches the requests to different files, such as containing styles and images.
-
proxyCacheTTL: The proxy cache's time-to-live in milliseconds. The default value is
10 * 60 * 1000
.
6. Configure package.json File
- Open
package.json
- Add the following code to the
scripts
property:
"dev": "pp-dev",
"build":"pp-dev build"
Save the config file.
7. Create Content for Portal Page
Note: Files that are not used in the Portal Page are not transferred to the archive with Portal Page assets. The exception is the directory public
.
- Create an
index.html
file - Enter the Portal Page's code in the
index.html
file -
Optionally, create a directory named
public
the contents of which are transferred to the archive with Portal Page assets regardless of being utilized in the Portal Page- The contents of the
public
folder are transferred to the root of the archive with Portal Page assets. However, you can create folders inside thepublic
, these folders and their contents will be transferred to the archive's root.
- The contents of the
8. Open Portal Page Locally
- Access Terminal > New Terminal
- Run
npm run dev
- Note: After executing this command, press h to open console shortcuts
- Ctrl + click on the local link or copy and open it in the browser
9. Log In to Metric Insights
- Enter credentials of an Admin user from the MI application server that you have listed in the config file
- [Login]
10. View Portal Page Locally And Work With Tool Panel
Once the Portal Page is opened, the Portal Page Developer Helper tool panel is displayed at the bottom-left corner of the screen with its controls:
- Hide tool panel
- Open link to the npm package of the Portal Page Developer Helper
- Open link to the Metric Insights instance
- Shows whether or not the Template mode is enabled. This is controlled by the templateLess parameter
- Open link to the Portal Page on the Metric Insights instance
11. Build Portal Page Assets
- Execute
run npm build
in the terminal - Folder
dist-zip
is created and contains a zip archive with Portal Page's assets and contents of the public directory. This archive can be uploaded to the Metric Insights' instance.