this is my script is used for entity identifier i used index name also i.e people
var _parameters = {
entityId: ‘$$ALL$’,
entityIdSet: new Set(),
condition: ‘’,
expression: ‘’,
imageMode: ‘url’,
modelProperty: ‘’,
when: ‘always’,
selection: ,
methods: {}
};
function getLensDefinition(graphId, graphModel, selection, precomputed) {
var html = ‘Entity Type’;
let entities = ;
html += f.buildSelectEntityMenu(graphModel, precomputed, entities);
html += ‘If …’;
html += ‘
always’;
html += ‘
’;
html += ‘only for the {{ params.selection.length }} selected elements.’;
html += ‘’;
html += ‘ ’;
html += ‘’;
html += ‘
’;
html += ‘only if the condition is true’;
html += ‘<expression-editor entity-id-set=“data.entityIdSet” required-field=“params.when === 'conditional'”’;
html += ’ ng-hide=“params.when !== 'conditional'” ‘;
html += ’ type=“params.entityId” expression=“params.condition” error-message=“data.errorMessages.condition”>’;
html += ‘’;
html += ‘
Set this property’;
html += ‘’;
html += ‘’;
html += ‘Url ’;
html += ‘’;
html += ‘Image Proxy Url ’;
html += ‘’;
html += ‘Local image’;
html += ‘’;
_parameters.selection = selection;
_parameters.methods = {
imageModeChanged: function () {
if (this.params.imageMode === ‘urlDirect’) {
this.params.expression = ‘'https://cdn4.iconfinder.com/data/icons/fugue/icon_shadowless/dummy.png\’‘;
} else if (this.params.imageMode === ‘urlProxy’) {
this.params.expression = ‘'https://siren.io/wp-content/uploads/Siren-small_V1.1.png\’’;
} else {
this.params.expression = ‘'set1/bank.png'’;
}
},
propertyChanged: function (prop) {
if (prop.name === ‘pathIcon’) {
this.params.imageMode = ‘url’;
}
this.params.expression = prop.default;
},
showSelection: function () {
this.loadItems({ selection: this.params.selection });
},
isPathIcon: function () {
var prop = this.params.modelProperty;
return prop.name === ‘pathIcon’;
},
updateSelection: function () {
this.params.selection = _.filter(this.getSelection(), function (id) {
return id.split(‘/’).length === 3;
});
}
};
return Promise.resolve({
displayName: ‘Entity Icon with Image’,
type: ‘Advanced’,
template: html,
params: _parameters,
data: {
entityIdSet: precomputed.entityIdSet,
currentSelection: selection,
entities: entities
}
});
}
function setParams(params) {
_parameters = params;
}
function onGraphUpdate(graphId, graphModel, oldModel, precomputed) {
const entityId = _parameters.entityId;
const prop = _parameters.modelProperty;
const imageMode = _parameters.imageMode;
const expression = _parameters.expression.replace(/\n\r?/g, ’ ');
const selection = _parameters.selection;
const when = _parameters.when;
return f.getEntityAndDescendantsIds(entityId).then(function (entityIds) {
const proms = ;
function getImageUrlFromDoc(node) {
const query = {
size: 1,
query: {
match_all:{}
},
_source: ["image"]
};
return f.executeEsSearch("people", null, query).then(function (res) {
const hit = res.hits.hits[0];
if (hit && hit._source && hit._source.image_url) {
let img = hit._source.image_url;
if (prop.name === "pathIcon") {
if (imageMode === "urlDirect") {
node[prop.name] = img;
} else if (imageMode === "urlProxy") {
node[prop.name] = "/image_proxy?url=" + encodeURIComponent(img);
}
}
}
});
}
_.each(graphModel.nodes, function (node) {
if (prop && prop.name === 'pathIcon') {
if (node.isEntityIdentifier) {
proms.push(getImageUrlFromDoc(node));
} else {
let nodeExpr = '\'\' + ' + expression;
proms.push(jexl.eval(nodeExpr, node).then(function (img) {
if (imageMode === 'urlDirect') {
node[prop.name] = img;
} else if (imageMode === 'urlProxy') {
node[prop.name] = '/image_proxy?url=' + encodeURIComponent(img);
}
}).catch(() => {}));
}
}
});
return Promise.all(proms).then(() => graphModel);
});
}
not working for me