Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <meta charset="utf-8"/>
- <html>
- <head>
- <title>Neovis.js Simple Example</title>
- <style type="text/css">
- html, body {
- font: 16pt arial;
- }
- #viz {
- width: 1200px;
- height: 650px;
- border: 10px solid #456789;
- font: 22pt arial;
- }
- </style>
- <!-- FIXME: load from dist -->
- <script type="text/javascript" src="https://rawgit.com/neo4j-
- contrib/neovis.js/master/dist/neovis.js"></script>
- <script
- src="https://code.jquery.com/jquery-3.2.1.min.js"
- integrity="sha256-
- hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
- crossorigin="anonymous"></script>
- <script type="text/javascript">
- var viz;
- function draw() {
- var config = {
- container_id: "viz",
- server_url: "bolt://localhost:11003",
- server_user: "neo4j",
- server_password: "V1",
- labels: {
- "API": {
- "caption": "name",
- "size": "pagerank",
- "community": "community"
- }
- },
- relationships: {
- "cc": {
- "thickness": "weight",
- "caption": false
- }
- },
- initial_cypher :"MATCH (n) RETURN (n)" ,
- arrows: false
- };
- viz = new NeoVis.default(config);
- viz.render();
- console.log(viz);
- }
- </script>
- </head>
- <body onload="draw()">
- <div id="viz"></div>
- Cypher query: <textarea rows="4" cols=50 id="cypher"></textarea><br>
- <input type="submit" value="Submit" id="reload">
- <input type="submit" value="Stabilize" id="stabilize">
- </body>
- <script>
- $("#reload").click(function() {
- var cypher = $("#cypher").val();
- if (cypher.length > 3) {
- viz.renderWithCypher(cypher);
- } else {
- console.log("reload");
- viz.reload();
- }
- });
- $("#stabilize").click(function() {
- viz.stabilize();
- })
- </script>
- <frameset cols="50%,50%">
- <frame src="frame_a.htm" frameborder="0">
- <frame src="frame_b.htm" frameborder="0">
- </frameset>
- </html>
- import { Component, OnInit } from '@angular/core';
- import { Injectable } from '@angular/core';
- import { ToasterService } from '../toaster.service';
- import { Http, Response, Headers } from '@angular/http';
- import { config } from '../config';
- import { Subject } from 'rxjs';
- import { takeUntil } from 'rxjs/operators';
- import 'rxjs/add/operator/map';
- import { map } from 'rxjs/operators';
- import 'rxjs/Rx';
- import { Observable } from 'rxjs';
- // Statics
- import 'rxjs/add/observable/throw';
- @Component({
- selector: 'app-neo4j-primary',
- templateUrl: './neo4j-primary.component.html',
- styleUrls: ['./neo4j-primary.component.css']
- })
- export class Neo4jPrimaryComponent implements OnInit {
- constructor(private http: Http, private notify: ToasterService) { }
- ngOnInit() {
- this.viewNodesStart();
- }
- emptyObj;
- info;
- // ------------------------------- Nodes Entire Data ------------
- viewNodesStart() {
- console.log("INSIDE viewNodesStart()")
- // Nodes Value
- console.log("inside Nodes Value");
- var data = localStorage.getItem('token');
- console.log("data is=>",data);
- var url = config.url;
- var port = config.port;
- this.http.post("bolt://"+url+":"+port+"/viewNodesStart",this.emptyObj,
- { headers: new Headers({ 'Authorization': 'Bearer ' +
- localStorage.getItem('token') }) } )
- .map(Response => Response.json())
- .subscribe((res: Response) => {
- console.log("XXXXXXXXXXXX", res);
- this.info = res;
- console.log('success', this.info.statusCode);
- if (this.info.statusCode == 200) {
- this.notify.Success("Data added successfully");
- } else {
- this.notify.Error("Data is not inserted")
- }
- });
- }
- }
- // Require Neo4j
- var neo4j = require('neo4j-driver').v1;
- var path = require('path');
- var logger = require('morgan');
- var bodyParser = require('body-parser');
- var express = require('express');
- var router = express.Router();
- var app = express();
- // Create Driver
- const driver = new neo4j.driver("bolt://localhost:11001",
- neo4j.auth.basic("neo4j", "Virtuallib1"));
- app.set('views',path.join(__dirname,'views'));
- app.set('view engine','ejs');
- app.use(logger('dev'));
- app.use(bodyParser.json());
- app.use(bodyParser.urlencoded({extended:false}));
- app.use(express.static(path.join(__dirname,'public')));
- var driver =
- neo4j.driver('bolt://localhost',
- neo4j.auth.basic('neo4j','V1'));
- var session = driver.session();
- // Create Driver session
- const session = req.driver.session();
- // Run Cypher query
- const cypher = 'MATCH (n) RETURN count(n) as count';
- app.get('/viewNodesStart',function(req,res){
- session
- .run('MATCH (n) RETURN n LIMIT 25')
- .then(function (result){
- result.records.forEach(function(record){
- console.log("record", record);
- console.log("result = ", result)
- console.log("record._fields[0].properties",
- record._fields[0].properties);
- });
- })
- .catch(function(err){
- console.log(err);
- });
- res.send('It Works');
- res.send(result);
- });
- app.listen(11003);
- console.log('Server started on port 11003');
- module.exports = app;
Add Comment
Please, Sign In to add comment