Skip to content
Closed
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
2 changes: 1 addition & 1 deletion demo/code-demo/code_area.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
<img src="images\copy.png"/> Copy
</button>
</div>
<textarea id="txtCode" readonly />
<textarea id="txtCode" />
112 changes: 63 additions & 49 deletions demo/code-demo/scripts/utils.js
Original file line number Diff line number Diff line change
@@ -1,78 +1,92 @@
function ValidateEmbedUrl(embedUrl) {
var embedUrl = $('#txtReportEmbed').val();

if (!embedUrl)
{
alert("You must specify an embed url.");
return false;
}
var id = null;
var parts = embedUrl.split("reportId=");
if (parts && parts.length > 0)
{
var guidParts = parts[parts.length -1].split("&");
if (guidParts && guidParts.length > 0)
{
id = guidParts[0];
}
}

if (!id)
{
alert("Could not find report ID in url");
return false;
var embedUrl = $('#txtReportEmbed').val();

if (!embedUrl) {
alert("You must specify an embed url.");
return false;
}
var id = null;
var parts = embedUrl.split("reportId=");
if (parts && parts.length > 0) {
var guidParts = parts[parts.length - 1].split("&");
if (guidParts && guidParts.length > 0) {
id = guidParts[0];
}

return true;
}

if (!id) {
alert("Could not find report ID in url");
return false;
}

return true;
}

function BodyCodeOfFunction(func) {
var lines = func.toString().split('\n');
lines = lines.slice(1, lines.length-1);

for (var i = 0; i < lines.length; ++i)
{
// remove trailing spaces.
lines[i] = lines[i].substring(4);
}
var lines = func.toString().split('\n');
lines = lines.slice(1, lines.length - 1);

return lines.join('\n');
for (var i = 0; i < lines.length; ++i) {
// remove trailing spaces.
lines[i] = lines[i].substring(4);
}

return lines.join('\n');
}

function LoadCodeArea(divSelector, initialFunctionCode) {
$(divSelector).load("code_area.html", function() {
SetCode(initialFunctionCode);
});

$(divSelector).load("code_area.html", function () {
$("#txtCode").on('input', e => SetCodeInSession(e));
SetCode(initialFunctionCode);
});

}

function LoadLogWindow(divSelector) {
$(divSelector).load("log_window.html");
$(divSelector).load("log_window.html");
}

function SetCode(func) {
$("#txtCode").val(BodyCodeOfFunction(func));

$('#btnRunCode').off('click');
$('#btnRunCode').click(func);

$("#txtCode").val(GetCodeFromSession(func));
$("#txtCode").attr('func', func.name); // Set attribute on textarea so we know what function to update on change event.

$('#btnRunCode').off('click');
$('#btnRunCode').click(e => eval($("#txtCode").val()));
}

function GetCodeFromSession(func) {
// Load code from session. Add if not there.
var code = GetSession(func.name);
if (!code) {
SetSession(func.name, BodyCodeOfFunction(func));
code = GetSession(func.name);
}
return code;
}

function SetCodeInSession(e) {
return SetSession($(e.target).attr('func'), e.target.value);
}

function CopyCode() {
CopyTextArea("#txtCode", "#btnRunCopyCode");
CopyTextArea("#txtCode", "#btnRunCopyCode");
}

function CopyResponseWindow() {
CopyTextArea("#txtResponse", "#btnCopyResponse");
CopyTextArea("#txtResponse", "#btnCopyResponse");
}

function CopyTextArea(textAreaSelector, buttonSelector) {
$(textAreaSelector).select();
document.execCommand('copy');
window.getSelection().removeAllRanges();
$(textAreaSelector).select();
document.execCommand('copy');
window.getSelection().removeAllRanges();

// Set focus on copy button - this will deselect text in copied area.
$(buttonSelector).focus();
// Set focus on copy button - this will deselect text in copied area.
$(buttonSelector).focus();
}

function ClearTextArea(textAreaSelector) {
$(textAreaSelector).val("");
$(textAreaSelector).val("");
}
8 changes: 4 additions & 4 deletions demo/code-demo/step_authorize.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ <h5>Prerequisites</h5>

<div class="line">
<h5>Instructions to generate an embed App Token</h5>
Once you have improted a report into Power BI workspace, you are ready to embed it.
Once you have imported a report into Power BI workspace, you are ready to embed it.

To embed a report, you need to get an embed App Token. You can create this token in multiple ways.
<ul>
<li>Using <a href="https://github.com/Microsoft/PowerBI-cli">PowerBI-Cli</a> tool.</li>
<li>From .Net Code using <a href="http://www.nuget.org/packages/Microsoft.PowerBI.Core/">Microsoft.PowerBI.Core</a> package.</li>
<li>From NodeJS code using <a href="https://github.com/Microsoft/PowerBI-Node">powerbi-api</a> package.</li>
<li>.NET NuGet Package: <a href="http://www.nuget.org/packages/Microsoft.PowerBI.Core/" target="_blank">Microsoft.PowerBI.Core</a>.</li>
<li>Node.js Command Line Interface: <a href="https://github.com/Microsoft/PowerBI-cli" target="_blank">PowerBI-Cli</a>.</li>
<li>Node.js API Wrapper: <a href="https://github.com/Microsoft/PowerBI-Node" target="_blank">powerbi-api</a>.</li>
</ul>
</div>

Expand Down