|
|
@ -15,8 +15,8 @@ |
|
|
///
|
|
|
///
|
|
|
|
|
|
|
|
|
import _ from 'lodash'; |
|
|
import _ from 'lodash'; |
|
|
import { Observable, Subject, fromEvent, of } from 'rxjs'; |
|
|
import { Observable, Observer, of, Subject } from 'rxjs'; |
|
|
import { finalize, share, map } from 'rxjs/operators'; |
|
|
import { finalize, map, share } from 'rxjs/operators'; |
|
|
import base64js from 'base64-js'; |
|
|
import base64js from 'base64-js'; |
|
|
import { Datasource } from '@app/shared/models/widget.models'; |
|
|
import { Datasource } from '@app/shared/models/widget.models'; |
|
|
|
|
|
|
|
|
@ -224,11 +224,14 @@ function scrollParents(node: Node): Node[] { |
|
|
|
|
|
|
|
|
function hashCode(str) { |
|
|
function hashCode(str) { |
|
|
let hash = 0; |
|
|
let hash = 0; |
|
|
let i, char; |
|
|
let i; |
|
|
|
|
|
let char; |
|
|
if (str.length === 0) return hash; |
|
|
if (str.length === 0) return hash; |
|
|
for (i = 0; i < str.length; i++) { |
|
|
for (i = 0; i < str.length; i++) { |
|
|
char = str.charCodeAt(i); |
|
|
char = str.charCodeAt(i); |
|
|
|
|
|
// tslint:disable-next-line:no-bitwise
|
|
|
hash = ((hash << 5) - hash) + char; |
|
|
hash = ((hash << 5) - hash) + char; |
|
|
|
|
|
// tslint:disable-next-line:no-bitwise
|
|
|
hash = hash & hash; // Convert to 32bit integer
|
|
|
hash = hash & hash; // Convert to 32bit integer
|
|
|
} |
|
|
} |
|
|
return hash; |
|
|
return hash; |
|
|
@ -430,10 +433,24 @@ export function getDescendantProp(obj: any, path: string): any { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
export function imageLoader(imageUrl: string): Observable<HTMLImageElement> { |
|
|
export function imageLoader(imageUrl: string): Observable<HTMLImageElement> { |
|
|
const image = new Image(); |
|
|
return new Observable((observer: Observer<HTMLImageElement>) => { |
|
|
const imageLoad$ = fromEvent(image, 'load').pipe(map(() => image)); |
|
|
const image = new Image(); |
|
|
image.src = imageUrl; |
|
|
image.style.position = 'absolute'; |
|
|
return imageLoad$; |
|
|
image.style.left = '-99999px'; |
|
|
|
|
|
image.style.top = '-99999px'; |
|
|
|
|
|
image.onload = () => { |
|
|
|
|
|
observer.next(image); |
|
|
|
|
|
document.body.removeChild(image); |
|
|
|
|
|
observer.complete(); |
|
|
|
|
|
}; |
|
|
|
|
|
image.onerror = err => { |
|
|
|
|
|
observer.error(err); |
|
|
|
|
|
document.body.removeChild(image); |
|
|
|
|
|
observer.complete(); |
|
|
|
|
|
}; |
|
|
|
|
|
document.body.appendChild(image) |
|
|
|
|
|
image.src = imageUrl; |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
export function createLabelFromDatasource(datasource: Datasource, pattern: string) { |
|
|
export function createLabelFromDatasource(datasource: Datasource, pattern: string) { |
|
|
|