Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return di.ids.indexOf(dashboardLayerId) > -1;
})
) {
// in some cases the id will not contain a layer name...it will have the dashboard id for another widget
// in that case lookup the datasource from referenced widget
const dashboardWidgetId: string = id.split("#")[0];
datasourceInfos.some(di => {
const references: string[] = di.references || [];
const hasRef: boolean = references.indexOf(dashboardWidgetId) > -1;
info = hasRef ? di : info;
return hasRef;
});
}
} else {
// otherwise match the itemId and the layerId to get the correct fields and path
const itemId: any = common.cleanLayerBasedItemId(
common.getProp(obj, "dataSource.itemId")
);
const layerId: any = common.cleanLayerId(
common.getProp(obj, "dataSource.layerId")
);
if (itemId) {
datasourceInfos.some(di => {
const matches: boolean = itemId === di.itemId && layerId === di.layerId;
info = matches ? di : info;
return matches;
});
}
}
return info;
}
layersAndTables.forEach(layer => {
const obj: any = {};
let itemId: any;
if (layer.itemId) {
itemId = layer.itemId;
} else if (layer.url && layer.url.indexOf("{{") > -1) {
// some layers like heatmap layer don't have a itemId
itemId = layer.url
.replace("{{", "")
.replace(/([.]layer([0-9]|[1-9][0-9])[.]url)[}]{2}/, "");
}
if (itemId) {
obj[common.cleanLayerBasedItemId(itemId)] = {
id: layer.id,
url: layer.url
};
hashItem.layersAndTables.push(obj);
}
});
}
obj.datasets.forEach((dataset: IDashboardDataset) => {
// when the datasource has an itemId it's an external datasource
const itemId: string = common.cleanLayerBasedItemId(
common.getProp(dataset, "dataSource.itemId")
);
if (itemId) {
const layerId: number = common.cleanLayerId(
common.getProp(dataset, "dataSource.layerId")
);
datasourceInfos.some(ds => {
if (ds.itemId === itemId && ds.layerId === layerId) {
_updateReferences(ds, obj.id);
return true;
} else {
return false;
}
});
} else {
// add placeholder for map layer datasource info so we can know the items that reference them