How to refresh Dashboard with different params & resource?

1
<html>
 
<head>
    <script type='text/javascript' src="https://xxx.com/jasperserver-pro/client/visualize.js"></script>
</head>
 
<body>
    <button onclick="dashboardA()">Dashboard Type A</button>
    <button onclick="dashboardB()">Dashboard Type B</button>
    <button onclick="dashboardBWithDifferentParams()">Dashboard Type B with different params</button>
 
    <div id="container" style="width: 100%; height: 100%;"></div>
 
    <script>
        function runDashboard(config) {
            visualize({
                    auth: {
                        name: "id",
                        password: "password",
                        organization: "organization_1"
                    }
                },
                function (v) {
                    v.dashboard(config);
                });
        }
 
        dashboardA();
 
        function dashboardA() {
            runDashboard({
                resource: "pathA",
                container: "#container",
                params: {}
            });
        }
 
        function dashboardB() {
            runDashboard({
                resource: "pathB",
                container: "#container",
                params: {
                    projectId: ["78CDBAFB-C517-4BCC-B7E7-C86C76F0D1CB"]
                },
                linkOptions: {
                    events: {
                        click: (event, link, defaultHandler) => alert(link.parameters.projectId)
                    }
                }
            });
        }
 
        function dashboardBWithDifferentParams() {
            runDashboard({
                resource: "pathB",
                container: "#container",
                params: {
                    projectId: ["3DC646DA-BD65-4E5F-842F-7BA730CB79A0"]
                },
                linkOptions: {
                    events: {
                        click: (event, link, defaultHandler) => alert(link.parameters.projectId)
                    }
                }
            });
        }
    </script>
</body>
 
</html>

As you can see, I need to update dashboard with different params or different resource path on same div.

I tried using dashboard.params({}).run(); but it only works on same resource of dashboard.

Is there any way to update dashboard?

Even though dashboard is refreshed, params are still previous params that I ran the first time.

Help me...

jun.an's picture
7
Joined: Jun 5 2018 - 10:54am
Last seen: 1 year 5 months ago

0 Answers:

No answers yet
Feedback
randomness