Mercurial > hg > NetworkVis
view popoto/js/app-ismi.js @ 4:72dc19d750ad
ADDED: Basic text box implementation for predefined constraints, to be added to in the coming week. nodeProvider, linkProvider additions.
author | alistair |
---|---|
date | Mon, 07 Sep 2015 23:51:47 -0400 |
parents | 130beb4cabec |
children | fa1b4fa5b4f8 |
line wrap: on
line source
/** * URL used to access Neo4j REST API to execute queries. * Update this parameter to your running server instance. * * For more information on Neo4J REST API the documentation is available here: http://neo4j.com/docs/stable/rest-api-cypher.html */ popoto.rest.CYPHER_URL = "https://ismi-dev.mpiwg-berlin.mpg.de/neo4j-ismi/db/data/transaction/commit"; //popoto.rest.CYPHER_URL = "http://localhost:7474/db/data/transaction/commit"; /** * Add this authorization property if your Neo4j server uses basic HTTP authentication. * The value of this property must be "Basic <payload>", where "payload" is a base64 encoded string of "username:password". * * "btoa" is a JavaScript function that can be used to encode the user and password value in base64 but it is recommended to directly use the Base64 value. * * For example Base64 encoding value of "neo4j:password" is "bmVvNGo6cGFzc3dvcmQ=" */ popoto.rest.AUTHORIZATION = "Basic " + btoa("neo4j:neo5j"); //popoto.rest.AUTHORIZATION = "Basic " + btoa("neo4j:eagrussell"); /** * These functions fill the predefinedConstraints array for "PERSON" * Called when the filter button is hit * * Uses the text box implementation currently */ // TODO: finish textbox implementation as backup and add in dropdown menu implementation var personPredefinedConstraints = []; d3.select("#filter-button").on("click", function (d) { var constraint = d3.select("#constraint")[0][0].value; personPredefinedConstraints = [constraint]; // Recreate taxonomies panel d3.select("#" + popoto.taxonomy.containerId).selectAll("ul").data([]).exit().remove(); popoto.taxonomy.createTaxonomyPanel(); popoto.tools.reset(); }); d3.select("#filter-button2").on("click", function (d) { var constraint = d3.select("#constraint2")[0][0].value; personPredefinedConstraints = [constraint]; // Recreate taxonomies panel d3.select("#" + popoto.taxonomy.containerId).selectAll("ul").data([]).exit().remove(); popoto.taxonomy.createTaxonomyPanel(); popoto.tools.reset(); }); /** * Define the Label provider you need for your application. * This configuration is mandatory and should contain at least all the labels you could find in your graph model. * * In this alpha version only nodes with a label are supported. * * By default If no attributes are specified Neo4j internal ID will be used. * These label provider configuration can be used to customize the node display in the graph. * See www.popotojs.com or example for more details on available configuration options. */ // TODO: add in predefined constraint functions for other nodeProviders popoto.provider.nodeProviders = { "CODEX": { "returnAttributes": ["label", "ismi_id", "identifier"], "displayAttribute": "label", //"getPredefinedConstraints": function (node) { // return personPredefinedConstraints; //}, }, "WITNESS": { "returnAttributes": ["label", "ismi_id", "folios"], "displayAttribute": "label", //"getPredefinedConstraints": function (node) { // return personPredefinedConstraints; //}, }, "TEXT": { "returnAttributes": ["label", "full_title", "ismi_id"], "displayAttribute": "label", //"getPredefinedConstraints": function (node) { // return personPredefinedConstraints; //}, }, "PERSON": { "returnAttributes": ["label", "ismi_id", "death_date_text", "url"], "displayAttribute": "label", "getPredefinedConstraints": function (node) { return personPredefinedConstraints; }, }, "REPOSITORY": { "returnAttributes": ["label", "ismi_id"], "displayAttribute": "label", //"getPredefinedConstraints": function (node) { // return personPredefinedConstraints; //}, }, "FLORUIT_DATE": { "isSearchable": false //"getPredefinedConstraints": function (node) { // return personPredefinedConstraints; //}, } }; /** * Popoto label provider * Define the label provider used to customize the link displayed text: */ // TODO: ensure these cover all the different relations. Commented out for now. /* popoto.provider.linkProvider = { // Customize the text displayed on links: "getLinkTextValue": function (link) { // The links labels are just changed in lower case in this example. // But it is possible to use a localization mechanism here to replace values. if (link.type === popoto.graph.link.LinkTypes.RELATION) { if (link.source.label == "PERSON") { switch (link.label) { case "was_student_of": return "was student of"; case "is_prime_alias_name_of": return "is prime alias name of"; case "was_born_in": return "was born in"; case "lived_in": return "lived in"; case "has_role": return "has role"; case "has_floruit_date": return "has floruit date"; case "died_in": return "died in"; default : return "" } } if (link.source.label == "CODEX") { switch (link.label) { case "owned_by": return "owned by"; case "is_alias_of": return "is alias of"; case "is_part_of": return "is part of"; } } if (link.source.label == "WITNESS") { switch (link.label) { case "was_copied_in": return "was copied in"; case "was_studied_by": return "was studied by"; case "had_patron": return "had patron"; case "is_part_of": return "is part of"; case "is_exemplar_of": return "is exemplar of"; case "has_title_written_as": return "has title written as"; case "has_author_written_as": return "as author written as"; case "was_copied_by": return "was copied by"; } } if (link.source.label == "PLACE") { switch (link.label) { case "is_part_of": return "is part of"; case "is_in": return "is in"; } } } else { return popoto.provider.getSemanticValue(link.target); } } }; */ /** * Here a listener is used to retrieve the total results count and update the page accordingly. * This listener will be called on every graph modification. */ popoto.result.onTotalResultCount(function (count) { document.getElementById("result-total-count").innerHTML = "(" + count + ")"; }); /** * The number of results returned can be changed with the following parameter. * Default value is 100. * * Note that in this current alpha version no pagination mechanism is available in displayed results */ popoto.query.RESULTS_PAGE_SIZE = 1000; /** * For the alpha version, popoto.js has been generated with debug traces you can activate with the following properties: * The value can be one in DEBUG, INFO, WARN, ERROR, NONE. * * With INFO level all the executed cypher query can be seen in the navigator console. * Default is NONE */ popoto.logger.LEVEL = popoto.logger.LogLevels.INFO; /** * Start popoto.js generation. * The function requires the label to use as root element in the graph. */ popoto.start("PERSON"); /* do not zoom with scroll wheel */ popoto.graph.WHEEL_ZOOM_ENABLED = false; /* show source and target relations */ popoto.query.USE_RELATION_DIRECTION = true;