Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More cleanup #12

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion interface/.jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
"trailing": true,
"smarttabs": true,
"globals": {
"angular": false
"angular": false,
"d3": false,
"_": false
}
}
3 changes: 2 additions & 1 deletion interface/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css" />
<!-- build:css styles/vendor.css -->
<!-- bower:css -->
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css" />
<link rel="stylesheet" href="bower_components/angular-motion/dist/angular-motion.css" />
<link rel="stylesheet" href="bower_components/animate.css/animate.css" />
<link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.css" />
<!-- endbower -->
Expand Down
4 changes: 2 additions & 2 deletions interface/app/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ angular.module('interfaceApp', [
})
.when('/login/:code', {
template: '<div></div>',
controller: [ 'AuthService', function(AuthService) { AuthService.getToken(); }]
controller: [ 'AuthService', function(AuthService) { AuthService.getToken(); }]
})
.when('/forbidden', {
template: "<h4 class='text-center'>You don't have permission to use this site.</h4>"
template: '<h4 class=\'text-center\'>You don\'t have permission to use this site.</h4>'
})
.otherwise({
redirectTo: '/'
Expand Down
2 changes: 1 addition & 1 deletion interface/app/scripts/controllers/entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ angular.module('interfaceApp')

DataService.site = {
'code': $routeParams.code
}
};
DataService.getEntityNetwork($routeParams.entityId);
}]);
152 changes: 76 additions & 76 deletions interface/app/scripts/controllers/site.js
Original file line number Diff line number Diff line change
@@ -1,91 +1,91 @@
'use strict';

angular.module('interfaceApp')
.controller('SiteCtrl', [ '$rootScope', '$scope', '$routeParams', '$http', '$timeout', '$location', 'configuration', 'DataService',
function($rootScope, $scope, $routeParams, $http, $timeout, $location, conf, DataService) {
.controller('SiteCtrl', ['$rootScope', '$scope', '$routeParams', '$http', '$timeout', '$location', 'configuration', 'DataService',
function ($rootScope, $scope, $routeParams, $http, $timeout, $location, conf, DataService) {

$scope.site = $routeParams.code;
$scope.graph = $routeParams.explore;
$scope.service = conf[conf.service];
$scope.showEntityNetwork = false;
$scope.site = $routeParams.code;
$scope.graph = $routeParams.explore;
$scope.service = conf[conf.service];
$scope.showEntityNetwork = false;

$scope.initting = true;
$scope.progress = false;
$scope.datasetError = false;
$scope.ready = false;
$scope.loadGraph = false;
$scope.total = 0;
$scope.processed = 0;

var url = $scope.service + '/network/' + $scope.site + '/' + $scope.graph;
$http.get(url).then(function(d) {
// kick off the progress update in a moment; needs time to get going..
$timeout(function() { $scope.update(); }, 100);
$scope.progress = false;
$scope.site = {
'name': d.data.name,
'url': d.data.url,
'code': $scope.site
}
DataService.site = $scope.site;
},
function() {
$scope.datasetError = true;
$scope.initting = true;
$scope.progress = false;
$scope.initting = false;
});

$scope.$on('graph-ready', function() {
$scope.showControls = true;
})
$scope.$on('load-entity-network-view', function() {
$scope.showEntityNetwork = true;
})
$scope.$on('destroy-entity-network-view', function() {
$scope.showEntityNetwork = false;
})

// When the back button is pressed whilst viewing the entity network,
// intercept the location change event, cancel it, and destroy the
// entity network
$scope.$on('$locationChangeStart', function(e, n, o) {
if (o.match(/^.*\/site\/.*\/byEntity$/) && $scope.showEntityNetwork === true) {
$scope.showEntityNetwork = false;
e.preventDefault();
}
});
$scope.datasetError = false;
$scope.ready = false;
$scope.loadGraph = false;
$scope.total = 0;
$scope.processed = 0;

$scope.update = function() {
var url = $scope.service + '/network/' + $scope.site.code + '/' + $scope.graph + '/status';
$http.get(url).then(function(resp) {
if ((resp.data.processed !== null) && (resp.data.processed !== "")) {
$scope.initting = false;
$scope.progress = true;
$scope.processed = resp.data.processed;
$scope.total = resp.data.total;
$timeout(function() { $scope.update(); }, 100);
} else {
var url = $scope.service + '/network/' + $scope.site + '/' + $scope.graph;
$http.get(url).then(function (d) {
// kick off the progress update in a moment; needs time to get going..
$timeout(function () { $scope.update(); }, 100);
$scope.progress = false;
$scope.site = {
'name': d.data.name,
'url': d.data.url,
'code': $scope.site
};
DataService.site = $scope.site;
},
function () {
$scope.datasetError = true;
$scope.progress = false;
$scope.initting = false;
$scope.processData(resp.data);
});

$scope.$on('graph-ready', function () {
$scope.showControls = true;
});
$scope.$on('load-entity-network-view', function () {
$scope.showEntityNetwork = true;
});
$scope.$on('destroy-entity-network-view', function () {
$scope.showEntityNetwork = false;
});

// When the back button is pressed whilst viewing the entity network,
// intercept the location change event, cancel it, and destroy the
// entity network
$scope.$on('$locationChangeStart', function (e, n, o) {
if (o.match(/^.*\/site\/.*\/byEntity$/) && $scope.showEntityNetwork === true) {
$scope.showEntityNetwork = false;
e.preventDefault();
}
},
function(){
$scope.progress = false;
});
};

$scope.processData = function(d) {
DataService.init();
$scope.data = DataService.processSiteData(d);
$scope.update = function () {
var url = $scope.service + '/network/' + $scope.site.code + '/' + $scope.graph + '/status';
$http.get(url).then(function (resp) {
if ((resp.data.processed !== null) && (resp.data.processed !== '')) {
$scope.initting = false;
$scope.progress = true;
$scope.processed = resp.data.processed;
$scope.total = resp.data.total;
$timeout(function () { $scope.update(); }, 100);
} else {
$scope.progress = false;
$scope.initting = false;
$scope.processData(resp.data);
}
},
function () {
$scope.progress = false;
});
};

$scope.processData = function (d) {
DataService.init();
$scope.data = DataService.processSiteData(d);

// now get it all going
$scope.ready = true;

// now get it all going
$scope.ready = true;

$timeout(function(d) {
$scope.loadGraph = true;
}, 100);
}
$timeout(function () {
$scope.loadGraph = true;
}, 100);
};


}]);
}]);
16 changes: 8 additions & 8 deletions interface/app/scripts/directives/colour-picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ angular.module('interfaceApp')
'data': '=',
},
controllerAs: 'colourPickerCtrl',
link: function postLink(scope, element, attrs) {
link: function postLink(scope) {
scope.showPicker = false;
scope.showChooser = false;
scope.custom = {};
Expand All @@ -20,7 +20,7 @@ angular.module('interfaceApp')
scope.$on('close-colour-picker', function() {
scope.showPicker = false;
scope.showChooser = false;
})
});

// get the default colours from the configuration
var process = function() {
Expand All @@ -32,7 +32,7 @@ angular.module('interfaceApp')
scope.types[k] = DataService.types[k];
}
});
}
};

scope.toggleColourPicker = function() {
scope.showPicker = !scope.showPicker;
Expand All @@ -41,28 +41,28 @@ angular.module('interfaceApp')
$rootScope.$broadcast('close-type-filter');
process();
}
}
};

scope.changeColour = function(type) {
scope.showPicker = false;
scope.showChooser = true;
scope.type = type;
}
};
scope.setColor = function(color) {
scope.types[scope.type].color = color;
DataService.setColor(scope.type, color);
scope.showPicker = true;
scope.showChooser = false;
$rootScope.$broadcast('colours-changed');
}
};
scope.save = function() {
scope.setColor(scope.custom.color);
scope.dismissChooser();
}
};
scope.dismissChooser = function() {
scope.showPicker = true;
scope.showChooser = false;
}
};
}
};
}]);
Loading