Enhancing index, view and dashboard ui
This commit is contained in:
@@ -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();
|
||||
}]);
|
||||
|
||||
|
||||
@@ -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';
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,7 @@
|
||||
var runsFactory = angular.module('runsFactory', ['ngResource']);
|
||||
|
||||
runsFactory.factory('Runs', ['$resource', function($resource) {
|
||||
return $resource('/api/runs/:runId', {
|
||||
|
||||
});
|
||||
}]);
|
||||
Reference in New Issue
Block a user