Guest User

Untitled

a guest
Oct 6th, 2018
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.29 KB | None | 0 0
  1. <!doctype html>
  2. <meta charset="utf-8"/>
  3. <html>
  4. <head>
  5. <title>Neovis.js Simple Example</title>
  6. <style type="text/css">
  7. html, body {
  8. font: 16pt arial;
  9. }
  10. #viz {
  11. width: 1200px;
  12. height: 650px;
  13. border: 10px solid #456789;
  14. font: 22pt arial;
  15. }
  16. </style>
  17.  
  18. <!-- FIXME: load from dist -->
  19. <script type="text/javascript" src="https://rawgit.com/neo4j-
  20. contrib/neovis.js/master/dist/neovis.js"></script>
  21.  
  22.  
  23. <script
  24. src="https://code.jquery.com/jquery-3.2.1.min.js"
  25. integrity="sha256-
  26. hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
  27. crossorigin="anonymous"></script>
  28.  
  29. <script type="text/javascript">
  30.  
  31. var viz;
  32. function draw() {
  33. var config = {
  34. container_id: "viz",
  35. server_url: "bolt://localhost:11003",
  36. server_user: "neo4j",
  37. server_password: "V1",
  38. labels: {
  39.  
  40. "API": {
  41. "caption": "name",
  42. "size": "pagerank",
  43. "community": "community"
  44.  
  45. }
  46. },
  47. relationships: {
  48. "cc": {
  49. "thickness": "weight",
  50. "caption": false
  51. }
  52. },
  53.  
  54. initial_cypher :"MATCH (n) RETURN (n)" ,
  55. arrows: false
  56. };
  57. viz = new NeoVis.default(config);
  58. viz.render();
  59. console.log(viz);
  60. }
  61. </script>
  62. </head>
  63. <body onload="draw()">
  64. <div id="viz"></div>
  65.  
  66.  
  67. Cypher query: <textarea rows="4" cols=50 id="cypher"></textarea><br>
  68. <input type="submit" value="Submit" id="reload">
  69. <input type="submit" value="Stabilize" id="stabilize">
  70.  
  71.  
  72. </body>
  73.  
  74. <script>
  75.  
  76. $("#reload").click(function() {
  77. var cypher = $("#cypher").val();
  78. if (cypher.length > 3) {
  79. viz.renderWithCypher(cypher);
  80. } else {
  81. console.log("reload");
  82. viz.reload();
  83. }
  84. });
  85. $("#stabilize").click(function() {
  86. viz.stabilize();
  87. })
  88. </script>
  89. <frameset cols="50%,50%">
  90. <frame src="frame_a.htm" frameborder="0">
  91. <frame src="frame_b.htm" frameborder="0">
  92. </frameset>
  93. </html>
  94.  
  95. import { Component, OnInit } from '@angular/core';
  96. import { Injectable } from '@angular/core';
  97. import { ToasterService } from '../toaster.service';
  98. import { Http, Response, Headers } from '@angular/http';
  99. import { config } from '../config';
  100. import { Subject } from 'rxjs';
  101. import { takeUntil } from 'rxjs/operators';
  102.  
  103.  
  104. import 'rxjs/add/operator/map';
  105. import { map } from 'rxjs/operators';
  106. import 'rxjs/Rx';
  107. import { Observable } from 'rxjs';
  108.  
  109. // Statics
  110. import 'rxjs/add/observable/throw';
  111.  
  112.  
  113. @Component({
  114. selector: 'app-neo4j-primary',
  115. templateUrl: './neo4j-primary.component.html',
  116. styleUrls: ['./neo4j-primary.component.css']
  117. })
  118.  
  119. export class Neo4jPrimaryComponent implements OnInit {
  120.  
  121. constructor(private http: Http, private notify: ToasterService) { }
  122.  
  123. ngOnInit() {
  124. this.viewNodesStart();
  125. }
  126.  
  127.  
  128. emptyObj;
  129. info;
  130.  
  131. // ------------------------------- Nodes Entire Data ------------
  132.  
  133. viewNodesStart() {
  134.  
  135. console.log("INSIDE viewNodesStart()")
  136.  
  137. // Nodes Value
  138.  
  139. console.log("inside Nodes Value");
  140. var data = localStorage.getItem('token');
  141. console.log("data is=>",data);
  142. var url = config.url;
  143. var port = config.port;
  144.  
  145.  
  146. this.http.post("bolt://"+url+":"+port+"/viewNodesStart",this.emptyObj,
  147. { headers: new Headers({ 'Authorization': 'Bearer ' +
  148. localStorage.getItem('token') }) } )
  149. .map(Response => Response.json())
  150. .subscribe((res: Response) => {
  151.  
  152. console.log("XXXXXXXXXXXX", res);
  153.  
  154. this.info = res;
  155.  
  156. console.log('success', this.info.statusCode);
  157. if (this.info.statusCode == 200) {
  158. this.notify.Success("Data added successfully");
  159.  
  160. } else {
  161. this.notify.Error("Data is not inserted")
  162.  
  163. }
  164. });
  165.  
  166.  
  167. }
  168.  
  169. }
  170.  
  171. // Require Neo4j
  172. var neo4j = require('neo4j-driver').v1;
  173.  
  174. var path = require('path');
  175. var logger = require('morgan');
  176. var bodyParser = require('body-parser');
  177. var express = require('express');
  178. var router = express.Router();
  179. var app = express();
  180.  
  181.  
  182.  
  183. // Create Driver
  184. const driver = new neo4j.driver("bolt://localhost:11001",
  185. neo4j.auth.basic("neo4j", "Virtuallib1"));
  186.  
  187.  
  188.  
  189. app.set('views',path.join(__dirname,'views'));
  190. app.set('view engine','ejs');
  191.  
  192. app.use(logger('dev'));
  193. app.use(bodyParser.json());
  194. app.use(bodyParser.urlencoded({extended:false}));
  195. app.use(express.static(path.join(__dirname,'public')));
  196.  
  197.  
  198. var driver =
  199. neo4j.driver('bolt://localhost',
  200. neo4j.auth.basic('neo4j','V1'));
  201.  
  202. var session = driver.session();
  203.  
  204. // Create Driver session
  205. const session = req.driver.session();
  206.  
  207. // Run Cypher query
  208. const cypher = 'MATCH (n) RETURN count(n) as count';
  209.  
  210.  
  211. app.get('/viewNodesStart',function(req,res){
  212.  
  213.  
  214. session
  215. .run('MATCH (n) RETURN n LIMIT 25')
  216. .then(function (result){
  217. result.records.forEach(function(record){
  218. console.log("record", record);
  219. console.log("result = ", result)
  220.  
  221.  
  222. console.log("record._fields[0].properties",
  223. record._fields[0].properties);
  224. });
  225. })
  226. .catch(function(err){
  227. console.log(err);
  228. });
  229.  
  230. res.send('It Works');
  231. res.send(result);
  232. });
  233.  
  234.  
  235.  
  236. app.listen(11003);
  237.  
  238. console.log('Server started on port 11003');
  239.  
  240. module.exports = app;
Add Comment
Please, Sign In to add comment