Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// 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;
}
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
// needed when item field reference are derived from another widgets datasource eg. #datasetname
const id: any = common.getProp(dataset, "dataSource.id");
if (id) {
const dashboardLayerId: string = id.split("#")[1];