Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/* DashboardListing.css */
html, body, #root, #DashboardListing, #viewer-section, #dashboard {
height: 100%;
}
html, body, #root > div {
height: 100%;
}
/* html, body, #root {
width: 100%;
height: 100%;
overflow: hidden;
} */

#section {
height: 100%;
width: 20%;
background-color: slategrey;
float: left;
transition: width 0.3s ease; /* Smooth transition */
}

#section.collapsed {
width: 30%;
}

#viewer-section {
width: 80%;
height: 100%;
float: left;
transition: width 0.3s ease; /* Smooth transition */
}

#viewer-section.expanded {
width: 70%;
}

button {
color: black;
background: none;
border: none;
padding: 10px 20px;
cursor: pointer;
}

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import '../index';
import { BoldBI } from '@boldbi/boldbi-embedded-sdk';
import './DashboardListing.css'; // Import the CSS file

//ASP.NET Core application would be run on https://localhost:5001; http://localhost:5000, which needs to be set as `apiHost`
const apiHost = "http://localhost:5292";
Expand All @@ -23,44 +24,221 @@ class DashboardListing extends React.Component {
renderDashboard(data) {
this.dashboard = BoldBI.create({
serverUrl: data.ServerUrl + "/" + data.SiteIdentifier,
dashboardId: data.DashboardId,
// dashboardId: "015e1ce3-2a6a-4fac-ab1e-59b3243d565a",
//dashboardId: "b2446acf-b80f-4881-aaa1-117283c8c84d", // Multi
//viewName: "TestJSSimplification",
// viewName: "Nithya Gopal",
dashboardId: "6fecfd2b-d07c-4992-9597-5f02dec00174",
//datasourceName: "sdfsdsfsfdfssdgfd",
// dashboardId: data.DashboardId,
// dashboardPaths: ["/Sales/Sales Analysis Dashboard (2)", "/Government/DynamicConnectionStringty"],
//viewId: "754c76be-3dcb-4f10-a9ca-be3b3279e62a",
embedContainerId: "dashboard",
embedType: data.EmbedType,
environment: data.Environment,
mode: BoldBI.Mode.View,
width: "100%",
height: window.innerHeight + 'px',
expirationTime: 100000,
//pinboardName: "Pinboard",
// embedType: data.EmbedType,
// environment: data.Environment,
//mode: BoldBI.Mode.View,
// mode: BoldBI.Mode.Design,
//mode: BoldBI.Mode.DataSource,
// mode: BoldBI.Mode.Connection,
// width: "600px",
// height: "600px",
// width: window.innerWidth +"px",
// height: window.innerHeight + "px",
// width: "100vw",
// height: "100vh",
// width: "100%",
// // height: "100%",

// height: window.innerHeight + 'px',
//expirationTime: 100000,
authorizationServer: {
url: apiHost + authorizationUrl
},

// widgetContainerSettings: {
// margin: 50,
// }

widgetList: [{ widgetName: "Chart2", containerId: "widget1" },
{ widgetName: "Chart3", containerId: "widget2" }],
});

this.dashboard.loadDashboard();
// this.dashboard.loadDashboardWidget("Chart1");
this.dashboard.loadMultipleWidgets();
// this.dashboard.loadMultitabDashboard();
//this.dashboard.loadView();
//this.dashboard.loadDashboard();
// this.dashboard.loadDesigner();
// this.dashboard.loadPinboard();
//this.dashboard.loadDatasource();
}

renderDashboard12(data) {
this.dashboard = BoldBI.create({
serverUrl: data.ServerUrl + "/" + data.SiteIdentifier,
dashboardId: "6fecfd2b-d07c-4992-9597-5f02dec00174",
embedContainerId: "dashboard",
width: "90%",
height: "80%",
authorizationServer: {
url: apiHost + authorizationUrl
},
});


// this.dashboard.loadDashboardWidget("Chart1");
//this.dashboard.loadMultipleWidgets();
//this.dashboard.loadMultitabDashboard();
//this.dashboard.loadView();
this.dashboard.loadDashboard();



var widget1Instance = BoldBI.create({
serverUrl: data.ServerUrl + "/" + data.SiteIdentifier,
dashboardId: "6fecfd2b-d07c-4992-9597-5f02dec00174",
embedContainerId: "widget1",
width: "50%",
height: "40%",
authorizationServer: {
url: apiHost + authorizationUrl
},
});
widget1Instance.loadDashboardWidget("Chart1");

var widget2Instance = BoldBI.create({
serverUrl: data.ServerUrl + "/" + data.SiteIdentifier,
dashboardId: "6fecfd2b-d07c-4992-9597-5f02dec00174",
embedContainerId: "widget2",
width: "65%",
height: "100%",
authorizationServer: {
url: apiHost + authorizationUrl
},
});
widget2Instance.loadDashboardWidget("Chart3");
}




toggleSection = () => {
this.setState((prevState) => ({
isCollapsed: !prevState.isCollapsed
}), () => {
// Use BoldBI SDK to resize the dashboard
// setTimeout(() => {
// if (this.dashboard) {
// this.dashboard.resizeDashboard();
// }
// }, 300);

const instance = BoldBI.getInstance('dashboard');
setTimeout(() => {
if (instance) {
instance.resizeDashboard();
}
}, 300);
});
}

render() {
const sectionClass = this.state.isCollapsed ? 'section collapsed' : 'section';
const viewerClass = this.state.isCollapsed ? 'viewer-section expanded' : 'viewer-section';

return (
<div id="DashboardListing">
<div id="container">
<div id="section" className={sectionClass}>
<button onClick={this.toggleSection}>
{this.state.isCollapsed ? 'Expand' : 'Collapse'}
</button>
</div>
<div id="viewer-section">
<div id="viewer-section" className={viewerClass}>
<div id="dashboard"></div>
<div id="widget1"></div>
<div id="widget2"></div>
</div>
</div>
);
}

// toggleSection = () => {
// this.setState((prevState) => ({
// isCollapsed: !prevState.isCollapsed
// }), () => {
// this.adjustLayout();
// // Use BoldBI SDK to resize the dashboard
// setTimeout(() => {
// if (this.dashboard) {
// this.dashboard.resizeDashboard();
// }
// }, 300);
// });
// }

// adjustLayout() {
// const section = document.getElementById('section');
// const viewerSection = document.getElementById('viewer-section');

// if (section && viewerSection) {
// section.style.width = this.state.isCollapsed ? '30%' : '20%';
// viewerSection.style.width = this.state.isCollapsed ? '70%' : '80%';
// }
// }

// render() {
// const sidebarStyle = {
// width: this.state.isCollapsed ? '30%' : '20%',
// height: '100%',
// backgroundColor: 'slategrey',
// float: 'left',
// transition: 'width 0.3s ease',
// };

// const viewerStyle = {
// width: this.state.isCollapsed ? '70%' : '80%',
// height: '100%',
// float: 'left',
// transition: 'width 0.3s ease',
// };

// return (
// <div id="DashboardListing">
// <div id="section" style={sidebarStyle}>
// <button onClick={this.toggleSection} style={{ color: 'black', background: 'none', border: 'none', padding: '10px 20px', cursor: 'pointer' }}>
// {this.state.isCollapsed ? 'Expand' : 'Collapse'}
// </button>
// </div>
// <div id="viewer-section" style={viewerStyle}>
// <div id="dashboard"></div>
// </div>
// </div>
// );
// }

// render() {
// return (
// <div id="DashboardListing">
// <div id="container">
// </div>
// <div id="viewer-section">
// <div id="dashboard"></div>
// </div>
// </div>
// );
// }

async componentDidMount() {
var dashboard = undefined;
// var querystring = require('querystring');
// var querystring = require('querystring');
var token = "";

try {
const response = await fetch(apiHost + '/api/boldbiembed/GetData');
const data = await response.json();
// Transform camelCase keys to PascalCase
const transformedEmbedConfigData = {
// Transform camelCase keys to PascalCase
const transformedEmbedConfigData = {
DashboardId: data.dashboardId,
EmbedType: data.embedType,
Environment: data.environment,
Expand Down
10 changes: 10 additions & 0 deletions React-with-ASP.NETCore/embedConfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"DashboardId": "0258acaa-6372-4134-9a08-d4067a1ddda8",
"ServerUrl": "http://localhost:53153/bi",
"UserEmail": "nithya.gopal@syncfusion.com",
"EmbedSecret": "3yVxUNWqU8VxORxBEYYQRdsSMPz4tdHP",
"EmbedType": "component",
"Environment": "onpremise",
"ExpirationTime": "10000",
"SiteIdentifier": "site/site1"
}
2 changes: 1 addition & 1 deletion React-with-ASP.NETCore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@boldbi/boldbi-embedded-sdk": "^7.9.50",
"@boldbi/boldbi-embedded-sdk": "file:../../../Provide-auto-heightandwidth-support-in-sdk/boldbi-sdk",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.4.0",
"@testing-library/user-event": "^7.2.1",
Expand Down