Skip to content

Commit 394383b

Browse files
committed
new design
1 parent 4252da2 commit 394383b

53 files changed

Lines changed: 2269 additions & 150 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎demo/app/dataselection.js‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ $(function () {
33

44
console.log('Scenario 7: Data Selection');
55

6-
var reportUrl = 'https://powerbi-embed-api.azurewebsites.net/api/reports/c52af8ab-0468-4165-92af-dc39858d66ad';
6+
var reportUrl = 'https://powerbiembedapi.azurewebsites.net/api/reports/c52af8ab-0468-4165-92af-dc39858d66ad';
77
var $reportContainer = $('#reportContainer');
88
var report;
99
var $dataSelectedContainer = $("#dataSelectedContainer");
@@ -29,12 +29,11 @@ $(function () {
2929
});
3030

3131
function initializeDataSelection(report, $dataSelectedContainer) {
32-
report.on('dataSelected', function(event)
33-
{
32+
report.on('dataSelected', event => {
3433
console.log('dataSelected: ', event);
3534

3635
var data = event.detail;
3736

3837
$dataSelectedContainer.text(JSON.stringify(data, null, ' '));
3938
});
40-
}
39+
}

‎demo/app/defaults.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ $(function () {
33

44
console.log('Scenario 5: Default Page and/or Filter');
55

6-
var staticReportUrl = 'https://powerbi-embed-api.azurewebsites.net/api/reports/c52af8ab-0468-4165-92af-dc39858d66ad';
6+
var staticReportUrl = 'https://powerbiembedapi.azurewebsites.net/api/reports/c52af8ab-0468-4165-92af-dc39858d66ad';
77
var $defaultPageReportContainer = $('#reportdefaults');
88
var defaultPageReport;
99
var defaultPageName = 'ReportSection2';

‎demo/app/dynamic.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ $(function () {
44
console.log('Scenario 2: Dynamic Embed');
55

66
// Declare Variables
7-
var allReportsUrl = 'https://powerbi-embed-api.azurewebsites.net/api/reports';
7+
var allReportsUrl = 'https://powerbiembedapi.azurewebsites.net/api/reports';
88
var $reportsList = $('#reportslist');
99
var $resetButton = $('#resetButton');
1010
var $dynamicReportContainer = $('#reportdynamic');

‎demo/app/filters.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ $(function () {
33

44
console.log('Scenario 4: Custom Filter Pane');
55

6-
var reportUrl = 'https://powerbi-embed-api.azurewebsites.net/api/reports/c52af8ab-0468-4165-92af-dc39858d66ad';
6+
var reportUrl = 'https://powerbiembedapi.azurewebsites.net/api/reports/c52af8ab-0468-4165-92af-dc39858d66ad';
77
var $customFilterPaneContainer = $('#reportcustomfilter');
88
var customFilterPaneReport;
99
var customFilterPaneReportPages;

‎demo/app/index.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ $(function () {
22
var models = window['powerbi-client'].models;
33

44
// Scenario 1: Static Embed
5-
var staticReportUrl = 'https://powerbi-embed-api.azurewebsites.net/api/reports/c52af8ab-0468-4165-92af-dc39858d66ad';
5+
var staticReportUrl = 'https://powerbiembedapi.azurewebsites.net/api/reports/c52af8ab-0468-4165-92af-dc39858d66ad';
66
var $staticReportContainer = $('#reportstatic');
77
var staticReport;
88

@@ -35,11 +35,11 @@ $(function () {
3535
var $reloadReport = $('#reloadReport');
3636
$reloadReport.on('click', function (event) {
3737
staticReport.reload()
38-
.catch(error => { alert(error); });
38+
.catch(function(error) { alert(error); });
3939
});
4040

4141
var $printReport = $('#printReport');
4242
$printReport.on('click', function (event) {
4343
staticReport.print();
4444
});
45-
});
45+
});

‎demo/app/pagenavigation.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ $(function () {
44
console.log('Scenario 3: Custom Page Navigation');
55

66
// Declare Variables
7-
var staticReportUrl = 'https://powerbi-embed-api.azurewebsites.net/api/reports/c52af8ab-0468-4165-92af-dc39858d66ad';
7+
var staticReportUrl = 'https://powerbiembedapi.azurewebsites.net/api/reports/c52af8ab-0468-4165-92af-dc39858d66ad';
88
var $customPageNavContainer = $('#reportcustompagenav');
99
var customPageNavReport;
1010
var $reportPagesList = $('#reportpagesbuttons');

‎demo/app/settings.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ $(function () {
33

44
console.log('Scenario 6: Update settings');
55

6-
var reportUrl = 'https://powerbi-embed-api.azurewebsites.net/api/reports/c52af8ab-0468-4165-92af-dc39858d66ad';
6+
var reportUrl = 'https://powerbiembedapi.azurewebsites.net/api/reports/c52af8ab-0468-4165-92af-dc39858d66ad';
77
var $updateSettingsReport = $('#updatesettingsreport');
88
var updateSettingsReport;
99
var updateSettingsReportFilterPaneEnabled = false;

‎demo/bower.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@
2323
"powerbi-client": "^2.2.1"
2424
},
2525
"devDependencies": {}
26-
}
26+
}

‎demo/bower_components/fetch/bower.json‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
{
22
"name": "fetch",
33
"main": "fetch.js",
4-
"devDependencies": {
5-
"es6-promise": "1.0.0"
6-
},
74
"ignore": [
85
".*",
96
"*.md",

‎demo/bower_components/fetch/fetch.js‎

Lines changed: 98 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,28 @@
2020
arrayBuffer: 'ArrayBuffer' in self
2121
}
2222

23+
if (support.arrayBuffer) {
24+
var viewClasses = [
25+
'[object Int8Array]',
26+
'[object Uint8Array]',
27+
'[object Uint8ClampedArray]',
28+
'[object Int16Array]',
29+
'[object Uint16Array]',
30+
'[object Int32Array]',
31+
'[object Uint32Array]',
32+
'[object Float32Array]',
33+
'[object Float64Array]'
34+
]
35+
36+
var isDataView = function(obj) {
37+
return obj && DataView.prototype.isPrototypeOf(obj)
38+
}
39+
40+
var isArrayBufferView = ArrayBuffer.isView || function(obj) {
41+
return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1
42+
}
43+
}
44+
2345
function normalizeName(name) {
2446
if (typeof name !== 'string') {
2547
name = String(name)
@@ -152,34 +174,59 @@
152174

153175
function readBlobAsArrayBuffer(blob) {
154176
var reader = new FileReader()
177+
var promise = fileReaderReady(reader)
155178
reader.readAsArrayBuffer(blob)
156-
return fileReaderReady(reader)
179+
return promise
157180
}
158181

159182
function readBlobAsText(blob) {
160183
var reader = new FileReader()
184+
var promise = fileReaderReady(reader)
161185
reader.readAsText(blob)
162-
return fileReaderReady(reader)
186+
return promise
187+
}
188+
189+
function readArrayBufferAsText(buf) {
190+
var view = new Uint8Array(buf)
191+
var chars = new Array(view.length)
192+
193+
for (var i = 0; i < view.length; i++) {
194+
chars[i] = String.fromCharCode(view[i])
195+
}
196+
return chars.join('')
197+
}
198+
199+
function bufferClone(buf) {
200+
if (buf.slice) {
201+
return buf.slice(0)
202+
} else {
203+
var view = new Uint8Array(buf.byteLength)
204+
view.set(new Uint8Array(buf))
205+
return view.buffer
206+
}
163207
}
164208

165209
function Body() {
166210
this.bodyUsed = false
167211

168212
this._initBody = function(body) {
169213
this._bodyInit = body
170-
if (typeof body === 'string') {
214+
if (!body) {
215+
this._bodyText = ''
216+
} else if (typeof body === 'string') {
171217
this._bodyText = body
172218
} else if (support.blob && Blob.prototype.isPrototypeOf(body)) {
173219
this._bodyBlob = body
174220
} else if (support.formData && FormData.prototype.isPrototypeOf(body)) {
175221
this._bodyFormData = body
176222
} else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
177223
this._bodyText = body.toString()
178-
} else if (!body) {
179-
this._bodyText = ''
180-
} else if (support.arrayBuffer && ArrayBuffer.prototype.isPrototypeOf(body)) {
181-
// Only support ArrayBuffers for POST method.
182-
// Receiving ArrayBuffers happens via Blobs, instead.
224+
} else if (support.arrayBuffer && support.blob && isDataView(body)) {
225+
this._bodyArrayBuffer = bufferClone(body.buffer)
226+
// IE 10-11 can't handle a DataView body.
227+
this._bodyInit = new Blob([this._bodyArrayBuffer])
228+
} else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {
229+
this._bodyArrayBuffer = bufferClone(body)
183230
} else {
184231
throw new Error('unsupported BodyInit type')
185232
}
@@ -204,6 +251,8 @@
204251

205252
if (this._bodyBlob) {
206253
return Promise.resolve(this._bodyBlob)
254+
} else if (this._bodyArrayBuffer) {
255+
return Promise.resolve(new Blob([this._bodyArrayBuffer]))
207256
} else if (this._bodyFormData) {
208257
throw new Error('could not read FormData body as blob')
209258
} else {
@@ -212,27 +261,28 @@
212261
}
213262

214263
this.arrayBuffer = function() {
215-
return this.blob().then(readBlobAsArrayBuffer)
216-
}
217-
218-
this.text = function() {
219-
var rejected = consumed(this)
220-
if (rejected) {
221-
return rejected
222-
}
223-
224-
if (this._bodyBlob) {
225-
return readBlobAsText(this._bodyBlob)
226-
} else if (this._bodyFormData) {
227-
throw new Error('could not read FormData body as text')
264+
if (this._bodyArrayBuffer) {
265+
return consumed(this) || Promise.resolve(this._bodyArrayBuffer)
228266
} else {
229-
return Promise.resolve(this._bodyText)
267+
return this.blob().then(readBlobAsArrayBuffer)
230268
}
231269
}
232-
} else {
233-
this.text = function() {
234-
var rejected = consumed(this)
235-
return rejected ? rejected : Promise.resolve(this._bodyText)
270+
}
271+
272+
this.text = function() {
273+
var rejected = consumed(this)
274+
if (rejected) {
275+
return rejected
276+
}
277+
278+
if (this._bodyBlob) {
279+
return readBlobAsText(this._bodyBlob)
280+
} else if (this._bodyArrayBuffer) {
281+
return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer))
282+
} else if (this._bodyFormData) {
283+
throw new Error('could not read FormData body as text')
284+
} else {
285+
return Promise.resolve(this._bodyText)
236286
}
237287
}
238288

@@ -260,7 +310,10 @@
260310
function Request(input, options) {
261311
options = options || {}
262312
var body = options.body
263-
if (Request.prototype.isPrototypeOf(input)) {
313+
314+
if (typeof input === 'string') {
315+
this.url = input
316+
} else {
264317
if (input.bodyUsed) {
265318
throw new TypeError('Already read')
266319
}
@@ -271,12 +324,10 @@
271324
}
272325
this.method = input.method
273326
this.mode = input.mode
274-
if (!body) {
327+
if (!body && input._bodyInit != null) {
275328
body = input._bodyInit
276329
input.bodyUsed = true
277330
}
278-
} else {
279-
this.url = input
280331
}
281332

282333
this.credentials = options.credentials || this.credentials || 'omit'
@@ -294,7 +345,7 @@
294345
}
295346

296347
Request.prototype.clone = function() {
297-
return new Request(this)
348+
return new Request(this, { body: this._bodyInit })
298349
}
299350

300351
function decode(body) {
@@ -310,16 +361,17 @@
310361
return form
311362
}
312363

313-
function headers(xhr) {
314-
var head = new Headers()
315-
var pairs = (xhr.getAllResponseHeaders() || '').trim().split('\n')
316-
pairs.forEach(function(header) {
317-
var split = header.trim().split(':')
318-
var key = split.shift().trim()
319-
var value = split.join(':').trim()
320-
head.append(key, value)
364+
function parseHeaders(rawHeaders) {
365+
var headers = new Headers()
366+
rawHeaders.split('\r\n').forEach(function(line) {
367+
var parts = line.split(':')
368+
var key = parts.shift().trim()
369+
if (key) {
370+
var value = parts.join(':').trim()
371+
headers.append(key, value)
372+
}
321373
})
322-
return head
374+
return headers
323375
}
324376

325377
Body.call(Request.prototype)
@@ -330,10 +382,10 @@
330382
}
331383

332384
this.type = 'default'
333-
this.status = options.status
385+
this.status = 'status' in options ? options.status : 200
334386
this.ok = this.status >= 200 && this.status < 300
335-
this.statusText = options.statusText
336-
this.headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers)
387+
this.statusText = 'statusText' in options ? options.statusText : 'OK'
388+
this.headers = new Headers(options.headers)
337389
this.url = options.url || ''
338390
this._initBody(bodyInit)
339391
}
@@ -371,35 +423,16 @@
371423

372424
self.fetch = function(input, init) {
373425
return new Promise(function(resolve, reject) {
374-
var request
375-
if (Request.prototype.isPrototypeOf(input) && !init) {
376-
request = input
377-
} else {
378-
request = new Request(input, init)
379-
}
380-
426+
var request = new Request(input, init)
381427
var xhr = new XMLHttpRequest()
382428

383-
function responseURL() {
384-
if ('responseURL' in xhr) {
385-
return xhr.responseURL
386-
}
387-
388-
// Avoid security warnings on getResponseHeader when not allowed by CORS
389-
if (/^X-Request-URL:/m.test(xhr.getAllResponseHeaders())) {
390-
return xhr.getResponseHeader('X-Request-URL')
391-
}
392-
393-
return
394-
}
395-
396429
xhr.onload = function() {
397430
var options = {
398431
status: xhr.status,
399432
statusText: xhr.statusText,
400-
headers: headers(xhr),
401-
url: responseURL()
433+
headers: parseHeaders(xhr.getAllResponseHeaders() || '')
402434
}
435+
options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL')
403436
var body = 'response' in xhr ? xhr.response : xhr.responseText
404437
resolve(new Response(body, options))
405438
}

0 commit comments

Comments
 (0)