-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
757ad6e
commit d06a893
Showing
12 changed files
with
594 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var React = __importStar(require("react")); | ||
var Embed_1 = __importDefault(require("./Embed")); | ||
var config_1 = require("./utils/config"); | ||
var onEmbedHandlers_1 = require("./utils/onEmbedHandlers"); | ||
var Dashboard = function (props) { | ||
var _a = React.useState(null), currentConfig = _a[0], setCurrentConfig = _a[1]; | ||
var performOnEmbed = React.useCallback(function (dashboard, dashboardRef) { | ||
(0, onEmbedHandlers_1.dashboardHandler)(dashboard, dashboardRef, props); | ||
}, [props]); | ||
React.useEffect(function () { | ||
setCurrentConfig((0, config_1.createDashboardConfig)(props)); | ||
}, [props]); | ||
if (!currentConfig) { | ||
return (React.createElement("div", null, "Error!")); | ||
} | ||
return (React.createElement(Embed_1.default, { config: currentConfig, performOnEmbed: performOnEmbed, style: props.style })); | ||
}; | ||
exports.default = Dashboard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var React = __importStar(require("react")); | ||
var index_1 = require("./utils/index"); | ||
var useReport_1 = require("./hooks/useReport"); | ||
var Embed = function (_a) { | ||
var config = _a.config, performOnEmbed = _a.performOnEmbed, style = _a.style; | ||
var id = config.id; | ||
var randId = (0, index_1.generateRandomHexWithId)(id); | ||
var reportEl = React.useRef(null); | ||
var _b = (0, useReport_1._useReport)(performOnEmbed), _ = _b[0], setEmbed = _b[1]; | ||
React.useEffect(function () { | ||
if (reportEl) { | ||
setEmbed(reportEl, config); | ||
} | ||
}, []); | ||
return (React.createElement("div", { className: 'report', style: style, ref: reportEl, id: randId })); | ||
}; | ||
exports.default = Embed; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var React = __importStar(require("react")); | ||
var Embed_1 = __importDefault(require("./Embed")); | ||
var config_1 = require("./utils/config"); | ||
var onEmbedHandlers_1 = require("./utils/onEmbedHandlers"); | ||
var Report = function (props) { | ||
var _a = React.useState(null), currentConfig = _a[0], setCurrentConfig = _a[1]; | ||
var performOnEmbed = React.useCallback(function (report, reportRef) { | ||
(0, onEmbedHandlers_1.reportHandler)(report, reportRef, props); | ||
}, [props]); | ||
React.useEffect(function () { | ||
setCurrentConfig((0, config_1.createReportConfig)(props)); | ||
}, [props]); | ||
if (!currentConfig) { | ||
return (React.createElement("div", null, "Error!")); | ||
} | ||
return (React.createElement(Embed_1.default, { config: currentConfig, performOnEmbed: performOnEmbed, style: props.style })); | ||
}; | ||
exports.default = Report; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var React = __importStar(require("react")); | ||
var Embed_1 = __importDefault(require("./Embed")); | ||
var config_1 = require("./utils/config"); | ||
var onEmbedHandlers_1 = require("./utils/onEmbedHandlers"); | ||
var ReportVisual = function (props) { | ||
var _a = React.useState(null), currentConfig = _a[0], setCurrentConfig = _a[1]; | ||
var performOnEmbed = React.useCallback(function (report, reportRef) { | ||
(0, onEmbedHandlers_1.reportVisualHandler)(report, reportRef, props); | ||
}, [props]); | ||
React.useEffect(function () { | ||
setCurrentConfig((0, config_1.createReportVisualConfig)(props)); | ||
}, [props]); | ||
if (!currentConfig) { | ||
return React.createElement("div", null, "Error!"); | ||
} | ||
return (React.createElement(Embed_1.default, { config: currentConfig, performOnEmbed: performOnEmbed, style: props.style })); | ||
}; | ||
exports.default = ReportVisual; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var React = __importStar(require("react")); | ||
var Embed_1 = __importDefault(require("./Embed")); | ||
var config_1 = require("./utils/config"); | ||
var onEmbedHandlers_1 = require("./utils/onEmbedHandlers"); | ||
var Tile = function (props) { | ||
var _a = React.useState(null), currentConfig = _a[0], setCurrentConfig = _a[1]; | ||
var performOnEmbed = React.useCallback(function (tile) { | ||
(0, onEmbedHandlers_1.tileHandler)(tile, props); | ||
}, [props]); | ||
React.useEffect(function () { | ||
setCurrentConfig((0, config_1.createTileConfig)(props)); | ||
}, [props]); | ||
if (!currentConfig) { | ||
return (React.createElement("div", null, "Error!")); | ||
} | ||
return (React.createElement(Embed_1.default, { config: currentConfig, performOnEmbed: performOnEmbed, style: props.style })); | ||
}; | ||
exports.default = Tile; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.useBootstrap = exports.useReport = exports._useReport = void 0; | ||
var react_1 = require("react"); | ||
var config_1 = require("../utils/config"); | ||
function _useReport(performOnEmbed) { | ||
var _a = (0, react_1.useState)(null), report = _a[0], _setEmbedInstance = _a[1]; | ||
var setEmbed = function (embedDivRef, embedConfig) { | ||
var errors = (0, config_1.validateConfig)(embedConfig); | ||
if (!errors || errors.length === 0) { | ||
embed(embedDivRef.current, embedConfig); | ||
} | ||
else { | ||
var errorString = (0, config_1.parseConfigErrors)(errors); | ||
throw new Error(errorString || 'invalid configuration passed'); | ||
} | ||
}; | ||
var embed = function (ref, config) { | ||
var reportMode = config.reportMode; | ||
var isCreateMode = reportMode === 'Create'; | ||
var embedInstance; | ||
if (isCreateMode) | ||
embedInstance = window.powerbi.createReport(ref, config); | ||
else { | ||
embedInstance = window.powerbi.embed(ref, config); | ||
} | ||
if (performOnEmbed) { | ||
performOnEmbed(embedInstance, ref); | ||
} | ||
_setEmbedInstance(embedInstance); | ||
}; | ||
return [report, setEmbed]; | ||
} | ||
exports._useReport = _useReport; | ||
function useReport() { | ||
var _a = (0, react_1.useState)(null), report = _a[0], _setEmbedInstance = _a[1]; | ||
var embed = function (ref, config) { | ||
var embedConfig = (0, config_1.createEmbedConfigBasedOnEmbedType)(config); | ||
var errors = (0, config_1.validateConfig)(embedConfig); | ||
if (!errors || errors.length === 0) { | ||
var _embed = window.powerbi.embed(ref.current, embedConfig); | ||
var embedInstance = window.powerbi.get(ref.current); | ||
_setEmbedInstance(embedInstance); | ||
} | ||
else { | ||
var errorString = (0, config_1.parseConfigErrors)(errors); | ||
throw new Error(errorString || 'invalid configuration passed'); | ||
} | ||
}; | ||
return [report, embed]; | ||
} | ||
exports.useReport = useReport; | ||
function useBootstrap() { | ||
var _a = (0, react_1.useState)(false), isBotstrapped = _a[0], setIsBootstrapped = _a[1]; | ||
var _b = (0, react_1.useState)(null), report = _b[0], _setEmbedInstance = _b[1]; | ||
var embed = function (ref, config) { | ||
if (isBotstrapped) { | ||
var embedConfig = (0, config_1.createEmbedConfigBasedOnEmbedType)(config); | ||
var errors = (0, config_1.validateConfig)(embedConfig); | ||
if (!errors || errors.length === 0) { | ||
var _embed = window.powerbi.embed(ref.current, embedConfig); | ||
var embedInstance = window.powerbi.get(ref.current); | ||
_setEmbedInstance(embedInstance); | ||
} | ||
else { | ||
var errorString = (0, config_1.parseConfigErrors)(errors); | ||
throw new Error(errorString || 'invalid configuration passed'); | ||
} | ||
} | ||
else { | ||
throw new Error('bootstrap was not called'); | ||
} | ||
}; | ||
var bootstrap = function (ref, config) { | ||
var bootstrapConfig = (0, config_1.createEmbedConfigBasedOnEmbedType)(config); | ||
if ((0, config_1.validateBootrapConfig)(bootstrapConfig)) { | ||
window.powerbi.bootstrap(ref.current, bootstrapConfig); | ||
setIsBootstrapped(true); | ||
} | ||
else { | ||
throw new Error('invalid configuration passed'); | ||
} | ||
}; | ||
return [report, bootstrap, embed]; | ||
} | ||
exports.useBootstrap = useBootstrap; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.useBootstrap = exports.ReportVisual = exports.useReport = exports.Tile = exports.Report = exports.Dashboard = void 0; | ||
var Dashboard_1 = __importDefault(require("./Dashboard")); | ||
exports.Dashboard = Dashboard_1.default; | ||
var Report_1 = __importDefault(require("./Report")); | ||
exports.Report = Report_1.default; | ||
var Tile_1 = __importDefault(require("./Tile")); | ||
exports.Tile = Tile_1.default; | ||
var useReport_1 = require("./hooks/useReport"); | ||
Object.defineProperty(exports, "useReport", { enumerable: true, get: function () { return useReport_1.useReport; } }); | ||
Object.defineProperty(exports, "useBootstrap", { enumerable: true, get: function () { return useReport_1.useBootstrap; } }); | ||
var ReportVisual_1 = __importDefault(require("./ReportVisual")); | ||
exports.ReportVisual = ReportVisual_1.default; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
Oops, something went wrong.