2 * Copyright 2016 Alexandre Terrasa <alexandre@moz-code.org>.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 .module('grades', ['ngSanitize'])
21 .config(function($stateProvider
, $locationProvider
) {
23 .state('doc.entity.grades', {
25 templateUrl
: 'views/doc/grades.html',
27 metrics
: function(Feedback
, $q
, $stateParams
, $state
) {
29 Feedback
.loadEntityStars($stateParams
.id
, d
.resolve
,
31 $state
.go('404', null, { location
: false })
36 controller
: function(mentity
, metrics
) {
37 this.mentity
= mentity
;
38 this.metrics
= metrics
;
44 templateUrl
: 'views/grades.html',
45 controller
: 'GradesCtrl',
46 controllerAs
: 'gradesCtrl'
50 .factory('Feedback', [ '$http', function($http
) {
52 loadEntityStars
: function(id
, cb
, cbErr
) {
53 $http
.get('/api/feedback/stars/' + id
)
57 loadEntityStarsDimension
: function(id
, dimension
, cb
, cbErr
) {
58 $http
.get('/api/feedback/stars/' + id
+ '/dimension/' + dimension
)
62 postEntityStarDimension
: function(id
, dimension
, rating
, cb
, cbErr
) {
63 $http
.post('/api/feedback/stars/' + id
+ '/dimension/' + dimension
,
68 loadMostRated
: function(cb
, cbErr
) {
69 $http
.get('/api/feedback/grades/most')
73 loadBestRated
: function(cb
, cbErr
) {
74 $http
.get('/api/feedback/grades/best')
78 loadWorstRated
: function(cb
, cbErr
) {
79 $http
.get('/api/feedback/grades/worst')
83 loadUsersRatings
: function(cb
, cbErr
) {
84 $http
.get('/api/feedback/grades/users')
91 .controller('GradesCtrl', ['Feedback', '$scope', function(Feedback
, $scope
) {
93 this.loadMostRated
= function() {
94 Feedback
.loadMostRated(
102 this.loadBestRated
= function() {
103 Feedback
.loadBestRated(
110 this.loadWorstRated
= function() {
111 Feedback
.loadWorstRated(
118 this.loadUsersRatings
= function() {
119 Feedback
.loadUsersRatings(
121 $scope
.ratings
= data
;
127 this.loadMostRated();
128 this.loadBestRated();
129 this.loadWorstRated();
130 this.loadUsersRatings();