Add Insights Dashboard To custom app

How Add dashboard generated from insights app to custom app to reuse it?

I’m not sure if you can declare Insights as a dependency of your app to have it installed when your app is installed.

But you could simply install Insights on your main site (on which you install your app), and then link to Insight’s dashboard(s) you want from a custom Workspace or from some page of your app.

Dear @Mohamed_AbdelSabour

1st - First, you need to export the dashboard configuration from the Insights app. This typically involves exporting the JSON configuration of the dashboard.

create a custom app in ERPNext. You can do this using the following command

bench new-app your_custom_app

Install the custom app on your site

bench --site your_site_name install-app your_custom_app

Place the exported dashboard configuration JSON file in your custom app’s directory. A common location would be within a data or config folder in your custom app.

Write a script to load the dashboard configuration into ERPNext. This can be done using a custom script in your app’s hooks.py or by creating a custom server-side script.

import frappe

def load_dashboard():
    with open(frappe.get_app_path('your_custom_app', 'data', 'dashboard_config.json')) as f:
        dashboard_config = f.read()
        dashboard = frappe.get_doc(json.loads(dashboard_config))
        dashboard.insert(ignore_permissions=True)

# Call the function to load the dashboard
load_dashboard()

Ensure that the script is called when your app is installed or updated. You can add it to the after_install or after_migrate hooks in your hooks.py file - add the script to the hooks. 

after_install = "your_custom_app.your_module.load_dashboard"
after_migrate = "your_custom_app.your_module.load_dashboard"

Deploy your custom app and test to ensure that the dashboard is correctly loaded and displayed in ERPNext!

Keenly waiting to know whether this clicked or not.