--- /dev/null
+<h4>Grade this entity</h4>
+
+<div class='container-fluid'>
+ <div class='col-xs-8'>
+ <dl class='dl-horizontal'>
+ <dt>Feature</dt>
+ <dd>
+ <entity-stars mentity='mentity' dimension='feature' mean='ratings.feature.mean' list='ratings.feature.ratings' user='ratings.feature.user' ratings='ratings' />
+ <p class='text-muted'><i>This entity is useful, usable and has a good API. It helps me getting things done.</i></p>
+ </dd>
+ <dt>Documentation</dt>
+ <dd>
+ <entity-stars mentity='mentity' dimension='doc' mean='ratings.doc.mean' list='ratings.doc.ratings' user='ratings.doc.user' ratings='ratings' />
+ <p class='text-muted'><i>This entity is well documented, the explanations are clear and useful. They help me understand the feature and how to use it.</i></p>
+ </dd>
+ <dt>Examples</dt>
+ <dd>
+ <entity-stars mentity='mentity' dimension='examples' mean='ratings.examples.mean' list='ratings.examples.ratings' user='ratings.examples.user' ratings='ratings' />
+ <p class='text-muted'><i>This entity is provided with examples, they are runnable and free of bugs. They help me understand the feature behavior and how to use it.</i></p>
+ </dd>
+ <dt>Code</dt>
+ <dd>
+ <entity-stars mentity='mentity' dimension='code' mean='ratings.code.mean' list='ratings.code.ratings' user='ratings.code.user' ratings='ratings' />
+ <p class='text-muted'><i>This entity is well coded and respects the Nit standards.</i></p>
+ </dd>
+ </dl>
+ </div>
+ <div class='col-xs-4'>
+ <h1 class='text-center'>
+ <span class='text-danger'>{{ratings.feature.mean + ratings.doc.mean + ratings.examples.mean + ratings.code.mean | number: 1}} / 20</span><br><small>{{ratings.ratings.length}} votes</small>
+ </h1>
+ </div>
+</div>
+
+<h4>History</h4>
+
+<table class='table'>
+ <tr ng-repeat='rating in ratings.ratings | orderBy: "-timestamp"'>
+ <td>{{rating.timestamp * 1000 | date: 'yy/MM/dd hh:mm a'}}</td>
+ <td>
+ <i>{{rating.user ? rating.user : "anon"}}<i>
+ </td>
+ <td>
+ rated the <b>{{rating.dimension}}</b>
+ </td>
+ <td>
+ <span class='stars' ng-repeat='star in [1, 2, 3, 4, 5]'>
+ <span
+ class='star glyphicon'
+ ng-class='star <= rating.rating? "glyphicon-star": "glyphicon-star-empty"' />
+ </span>
+ </td>
+ </tr>
+</table>
angular
.module('entities', ['ngSanitize', 'ui', 'model'])
- .controller('EntityCtrl', ['Model', 'Metrics', '$routeParams', '$scope', '$sce', function(Model, Metrics, $routeParams, $scope, $sce) {
+ .controller('EntityCtrl', ['Model', 'Metrics', 'Feedback', '$routeParams', '$scope', '$sce', function(Model, Metrics, Feedback, $routeParams, $scope, $sce) {
$scope.entityId = $routeParams.id;
this.loadEntityLinearization = function() {
};
})
- .directive('entityCard', function() {
+ .directive('entityCard', ['Feedback', function(Feedback) {
return {
restrict: 'E',
scope: {
templateUrl: '/directives/entity/card.html',
link: function ($scope, element, attrs) {
$scope.currentTab = $scope.defaultTab ? $scope.defaultTab : 'signature';
+
+ $scope.loadEntityStars = function() {
+ Feedback.loadEntityStars($scope.mentity.full_name,
+ function(data) {
+ $scope.ratings = data;
+ }, function(message, status) {
+ $scope.error = {message: message, status: status};
+ });
+ };
}
};
- })
+ }])
.directive('entityList', function() {
return {
};
}])
- .directive('entityRating', ['Feedback', function(Feedback, Code) {
+ .controller('StarsCtrl', ['Feedback', '$scope', function(Feedback, $scope) {
+ $ctrl = this;
+
+ this.postStar = function(rating) {
+ Feedback.postEntityStarDimension($scope.mentity.full_name,
+ $scope.dimension, rating,
+ function(data) {
+ $scope.mean = data.mean;
+ $scope.list = data.ratings;
+ $scope.user = data.user;
+ $ctrl.loadEntityStars($scope);
+ }, function(err) {
+ $scope.err = err;
+ });
+ }
+
+ this.loadEntityStars = function($scope) {
+ Feedback.loadEntityStars($scope.mentity.full_name,
+ function(data) {
+ $scope.ratings = data;
+ }, function(message, status) {
+ $scope.error = {message: message, status: status};
+ });
+ };
+ }])
+
+ .directive('entityRating', ['Feedback', function(Feedback) {
return {
restrict: 'E',
scope: {
- mentity: '='
+ mentity: '=',
+ ratings: '='
},
- templateUrl: '/directives/entity/stars.html',
- link: function ($scope, element, attrs) {
- $scope.postStar = function(rating) {
- Feedback.postEntityStar($scope.mentity.full_name, rating,
- function(data) {
- $scope.ratings = data;
- }, function(err) {
- $scope.err = err;
- });
- }
+ controller: 'StarsCtrl',
+ controllerAs: 'ratingsCtrl',
+ templateUrl: '/directives/entity/rating.html'
+ };
+ }])
- Feedback.loadEntityStars($scope.mentity.full_name,
- function(data) {
- $scope.ratings = data;
- }, function(err) {
- $scope.err = err;
- });
- }
+ .directive('entityStars', ['Feedback', function(Feedback) {
+ return {
+ restrict: 'E',
+ scope: {
+ mentity: '=',
+ dimension: '@',
+ mean: '=',
+ list: '=',
+ user: '=',
+ refresh: '=',
+ ratings: '='
+ },
+ controller: 'StarsCtrl',
+ controllerAs: 'starsCtrl',
+ templateUrl: '/directives/entity/stars.html'
};
}])
})();