You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.5 KiB

  1. 'use strict';
  2. angular.module('app.network', ['ngRoute'])
  3. .config(['$routeProvider', function($routeProvider) {
  4. $routeProvider.when('/network', {
  5. templateUrl: 'views/network/network.html',
  6. controller: 'NetworkCtrl'
  7. });
  8. }])
  9. .controller('NetworkCtrl', function($scope, $http, $routeParams) {
  10. $scope.data = [];
  11. $scope.nodes = [];
  12. $scope.edges = [];
  13. var nodes, edges, container;
  14. var options = {
  15. layout: {
  16. improvedLayout: false
  17. }
  18. /*,
  19. physics:{
  20. //stabilization: false,
  21. // enabled: false
  22. }*/
  23. };
  24. $scope.showMap = function() {
  25. var nodes = $scope.nodes;
  26. var edges = $scope.edges;
  27. var container = document.getElementById('mynetwork');
  28. var data = {
  29. nodes: nodes,
  30. edges: edges
  31. };
  32. var network = new vis.Network(container, data, options);
  33. };
  34. $http.get(urlapi + 'admin/network')
  35. .then(function(data, status, headers, config) {
  36. console.log('data success');
  37. console.log(data);
  38. $scope.nodes = data.data.nodes;
  39. $scope.edges = data.data.edges;
  40. $scope.showMap();
  41. }, function(data, status, headers, config) {
  42. console.log('data error');
  43. });
  44. });