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
) {
25 templateUrl
: 'views/grades.html',
26 controller
: 'GradesCtrl',
27 controllerAs
: 'gradesCtrl'
31 .factory('Feedback', [ '$http', function($http
) {
33 loadEntityStars
: function(id
, cb
, cbErr
) {
34 $http
.get('/api/feedback/stars/' + id
)
38 loadEntityStarsDimension
: function(id
, dimension
, cb
, cbErr
) {
39 $http
.get('/api/feedback/stars/' + id
+ '/dimension/' + dimension
)
43 postEntityStarDimension
: function(id
, dimension
, rating
, cb
, cbErr
) {
44 $http
.post('/api/feedback/stars/' + id
+ '/dimension/' + dimension
,
49 loadMostRated
: function(cb
, cbErr
) {
50 $http
.get('/api/feedback/grades/most')
54 loadBestRated
: function(cb
, cbErr
) {
55 $http
.get('/api/feedback/grades/best')
59 loadWorstRated
: function(cb
, cbErr
) {
60 $http
.get('/api/feedback/grades/worst')
64 loadUsersRatings
: function(cb
, cbErr
) {
65 $http
.get('/api/feedback/grades/users')
72 .controller('GradesCtrl', ['Feedback', '$scope', function(Feedback
, $scope
) {
74 this.loadMostRated
= function() {
75 Feedback
.loadMostRated(
83 this.loadBestRated
= function() {
84 Feedback
.loadBestRated(
91 this.loadWorstRated
= function() {
92 Feedback
.loadWorstRated(
99 this.loadUsersRatings
= function() {
100 Feedback
.loadUsersRatings(
102 $scope
.ratings
= data
;
108 this.loadMostRated();
109 this.loadBestRated();
110 this.loadWorstRated();
111 this.loadUsersRatings();