async function findOneByName()

in web/js/find.js [63:104]


async function findOneByName(graph, name, keyPressed) {

    if (!graph || !name) {
        console.error("findByName requires graph and name")
        return
    }

    if (name.length === 1) {
        return
    }

    for (const node of graph.data.nodes) {
        node.selected = false
    }

    for (const node of graph.data.nodes) {
        const nodeval = node.properties["name"]
        if (!nodeval) {
            node.selected = false
            continue
        }

        // Look for nodes that start with the entered text
        if (nodeval.toLowerCase().startsWith(name.toLowerCase())) {

            // Delay slightly here so we don't highlight everything as 
            // the user types something in quickly
            debounceHighlight(graph, node)

            if (keyPressed === "Enter") {
                // Re-query neptune and return only that node so that we 
                // see a simplified, filtered view.
                // Should we do this all client side? Why re-query?
                // Might be better for when the graph is so big we have to filter.
                await focusOn(graph, node.labels[0], "name", node.properties.name)
                return
            }
        } else {
            node.selected = false
        }
    }
}