Skip to content
Snippets Groups Projects
Commit e788291b authored by Eike Cochu's avatar Eike Cochu
Browse files

extracted network graph to root level

parent 2f00565f
No related branches found
No related tags found
No related merge requests found
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<ul class="list-unstyled"> <ul class="list-unstyled">
<li ng-repeat="article in articles"> <li ng-repeat="article in articles">
<a ui-sref="articles.detail.show({id: article.id})" ng-bind="::article.title"></a> <a ui-sref="articles.show({id: article.id})" ng-bind="::article.title"></a>
</li> </li>
</ul> </ul>
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
<tr> <tr>
<th>Links</th> <th>Links</th>
<td> <td>
<a ui-sref="articles.detail.network({id:article.id})">Network graph</a> <a ui-sref="network({type:'articles', id:article.id})">Network graph</a>
</td> </td>
</tr> </tr>
</tbody> </tbody>
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<h4>Latest articles</h4> <h4>Latest articles</h4>
<ul class="list-unstyled"> <ul class="list-unstyled">
<li class="ellipsize" ng-repeat="article in latestArticles"> <li class="ellipsize" ng-repeat="article in latestArticles">
<a ui-sref="articles.detail.show({id:article.id})" ng-bind="article.title"></a> <a ui-sref="articles.show({id:article.id})" ng-bind="article.title"></a>
</li> </li>
</ul> </ul>
</div> </div>
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
<h4>Results <query-time/></h4> <h4>Results <query-time/></h4>
<ul class="list-unstyled search-results"> <ul class="list-unstyled search-results">
<li class="search-result" ng-repeat="article in searchResults"> <li class="search-result" ng-repeat="article in searchResults">
<a ui-sref="articles.detail.show({id:article.id})" ng-bind="article.title"></a> <a ui-sref="articles.show({id:article.id})" ng-bind="article.title"></a>
<p> <p>
<span class="text" ng-bind="article.text"></span> <span class="text" ng-bind="article.text"></span>
<br> <br>
......
<div class="graph" <div class="fullsize navpadding" vis-graph vis-type="type" ng-model="model">
vis-graph
vis-type="article"
ng-model="article">
<div class="graph-legend"> <div class="graph-legend">
<span style="color:#BBC9D2">Articles</span><br> <span style="color:#BBC9D2">Articles</span><br>
<span style="color:#DBB234">Topics</span><br> <span style="color:#DBB234">Topics</span><br>
......
...@@ -18,6 +18,12 @@ ...@@ -18,6 +18,12 @@
<th>Last modified</th> <th>Last modified</th>
<td ng-bind="::topic.modified"></td> <td ng-bind="::topic.modified"></td>
</tr> </tr>
<tr>
<th>Links</th>
<td>
<a ui-sref="network({type:'topics', id:topic.id})">Network graph</a>
</td>
</tr>
</tbody> </tbody>
</table> </table>
......
...@@ -29,6 +29,12 @@ ...@@ -29,6 +29,12 @@
controller: 'IndexController' controller: 'IndexController'
}); });
$stateProvider.state('network', {
url: '/network/:type/:id',
templateUrl: tplBase + '/network.html',
controller: 'NetworkController'
});
// states: articles // states: articles
$stateProvider.state('articles', { $stateProvider.state('articles', {
...@@ -43,24 +49,12 @@ ...@@ -43,24 +49,12 @@
controller: 'ArticlesIndexController' controller: 'ArticlesIndexController'
}); });
$stateProvider.state('articles.detail', { $stateProvider.state('articles.show', {
url: '/:id', url: '/:id',
abstract: true, templateUrl: tplBase + '/articles/show.html',
template: '<ui-view/>'
});
$stateProvider.state('articles.detail.show', {
url: '',
templateUrl: tplBase + '/articles/detail/show.html',
controller: 'ArticlesShowController' controller: 'ArticlesShowController'
}); });
$stateProvider.state('articles.detail.network', {
url: '/network',
templateUrl: tplBase + '/articles/detail/network.html',
controller: 'ArticlesNetworkController'
});
// states: topics // states: topics
$stateProvider.state('topics', { $stateProvider.state('topics', {
......
...@@ -48,6 +48,27 @@ ...@@ -48,6 +48,27 @@
}]); }]);
app.controller('NetworkController', ['$scope', '$state', '$stateParams', 'ArticleFactory', 'TopicFactory',
function($scope, $state, $stateParams, ArticleFactory, TopicFactory) {
$scope.type = $stateParams.type;
var factory;
if($stateParams.type === 'articles')
factory = ArticleFactory;
else if($stateParams.type === 'topics')
factory = TopicFactory;
else {
console.log('unknown network type');
return;
}
factory.get({id: $stateParams.id}, function(response) {
$scope.model = response.data;
});
}]);
/* /*
* Article Controllers * Article Controllers
*/ */
...@@ -83,15 +104,6 @@ ...@@ -83,15 +104,6 @@
}]); }]);
app.controller('ArticlesNetworkController', ['$scope', '$state', '$stateParams', 'ArticleFactory', 'TopicFactory',
function($scope, $state, $stateParams, ArticleFactory, TopicFactory) {
ArticleFactory.get({id: $stateParams.id}, function(response) {
$scope.article = response.data;
});
}]);
/* /*
* Topic Controllers * Topic Controllers
*/ */
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
restrict: 'E', restrict: 'E',
replace: true, replace: true,
transclude: true, transclude: true,
template: '<a class="article-link" ui-sref="articles.detail.show({id:article.id})"><span ng-bind="article.title"></span><ng-transclude/></a>' template: '<a class="article-link" ui-sref="articles.show({id:article.id})"><span ng-bind="article.title"></span><ng-transclude/></a>'
} }
}); });
...@@ -56,18 +56,18 @@ ...@@ -56,18 +56,18 @@
}; };
}); });
app.directive('visGraph', ['$state', 'ArticleFactory', 'TopicFactory', app.directive('visGraph', ['$state', '$timeout', 'ArticleFactory', 'TopicFactory',
function($state, ArticleFactory, TopicFactory) { function($state, $timeout, ArticleFactory, TopicFactory) {
return { return {
scope: { scope: {
ngModel: '=', ngModel: '=',
visType: '@', visType: '=',
visData: '=', visData: '=',
visOptions: '=' visOptions: '='
}, },
transclude: true, transclude: true,
template: '<ng-transclude/><div class="graph" id="visgraph"></div>', template: '<ng-transclude/><div class="fullsize navpadding" id="visgraph"></div>',
link: function($scope, $element) { link: function($scope, $element) {
var id = 0, var id = 0,
ids = {}, ids = {},
...@@ -130,7 +130,10 @@ ...@@ -130,7 +130,10 @@
}; };
// on node select // on node select
var selectTimeout;
$scope.select = function(props) { $scope.select = function(props) {
$timeout.cancel(selectTimeout);
selectTimeout = $timeout(function() {
var node = $scope.nodes.get(props.nodes[0]); var node = $scope.nodes.get(props.nodes[0]);
if(node && !node.loaded) { if(node && !node.loaded) {
if(node.type === 'article') { if(node.type === 'article') {
...@@ -181,13 +184,15 @@ ...@@ -181,13 +184,15 @@
node.loaded = true; node.loaded = true;
$scope.nodes.update(node); $scope.nodes.update(node);
} }
}, 500);
}; };
// on node open // on node open
$scope.open = function(props) { $scope.open = function(props) {
$timeout.cancel(selectTimeout);
var node = $scope.nodes.get(props.nodes[0]); var node = $scope.nodes.get(props.nodes[0]);
if(node.type === 'article') if(node.type === 'article')
$state.transitionTo('articles.detail.show', {id:node.article}); $state.transitionTo('articles.show', {id:node.article});
else else
$state.transitionTo('topics.show', {id:node.topic}); $state.transitionTo('topics.show', {id:node.topic});
}; };
...@@ -197,7 +202,7 @@ ...@@ -197,7 +202,7 @@
if(!newVal) return; if(!newVal) return;
// root node // root node
if($scope.visType === 'article') if($scope.visType === 'articles')
nodes.push(articleNode($scope.ngModel)); nodes.push(articleNode($scope.ngModel));
else else
nodes.push(topicNode($scope.ngModel)); nodes.push(topicNode($scope.ngModel));
......
...@@ -101,7 +101,7 @@ body { ...@@ -101,7 +101,7 @@ body {
.graph { .graph {
position: absolute; position: absolute;
top: 10px; top: 50px;
left: 0; left: 0;
right: 0; right: 0;
bottom: 50px; bottom: 50px;
...@@ -126,6 +126,19 @@ body { ...@@ -126,6 +126,19 @@ body {
cursor: default; cursor: default;
} }
.fullsize {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
.navpadding {
padding-top: 50px;
padding-bottom: 50px;
}
@-moz-keyframes spin { 100% { -moz-transform: rotateY(360deg); } } @-moz-keyframes spin { 100% { -moz-transform: rotateY(360deg); } }
@-webkit-keyframes spin { 100% { -webkit-transform: rotateY(360deg); } } @-webkit-keyframes spin { 100% { -webkit-transform: rotateY(360deg); } }
@keyframes spin { 100% { -webkit-transform: rotateY(360deg); transform:rotateY(360deg); } } @keyframes spin { 100% { -webkit-transform: rotateY(360deg); transform:rotateY(360deg); } }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment