Enhancing index, view and dashboard ui

This commit is contained in:
achrafbenyounes
2014-12-18 18:02:39 +01:00
parent d712eb3a59
commit c4a7b1f129
23 changed files with 2122 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
var queueCtrl = angular.module('queueCtrl', ['runsFactory']);
queueCtrl.controller('QueueCtrl', ['$scope', '$routeParams', '$location', 'Runs', function($scope, $routeParams, $location, Runs) {
$scope.runId = $routeParams.runId;
function getRunStatus () {
Runs.get({runId: $scope.runId}, function(data) {
$scope.status = data.status;
if (data.status.statusCode === 'running' || data.status.statusCode === 'awaiting') {
// Retrying in 2 seconds
setTimeout(getRunStatus, 2000);
} else if (data.status.statusCode === 'complete') {
$location.path('/result/' + $scope.runId);
} else {
// Handled by the view
}
});
}
getRunStatus();
}]);
+34
View File
@@ -0,0 +1,34 @@
var gradeDirective = angular.module('gradeDirective', []);
gradeDirective.directive('grade', function() {
return {
restrict: 'E',
scope: {
score: '=score'
},
template: '<div ng-class="getGrade(score)">{{getGrade(score)}}</div>',
replace: true,
controller : function($scope) {
$scope.getGrade = function(score) {
console.log(score);
if (score >= 85) {
return 'A';
}
if (score >= 65) {
return 'B';
}
if (score >= 45) {
return 'C';
}
if (score >= 30) {
return 'D';
}
if (score >= 15) {
return 'E';
}
return 'F';
}
}
};
});
+7
View File
@@ -0,0 +1,7 @@
var runsFactory = angular.module('runsFactory', ['ngResource']);
runsFactory.factory('Runs', ['$resource', function($resource) {
return $resource('/api/runs/:runId', {
});
}]);