From 3f35b152da563f546257cb4196db92eabc25863f Mon Sep 17 00:00:00 2001 From: Adam Coldrick Date: Sat, 26 Sep 2015 16:33:54 +0100 Subject: Sort the steps array and reload the array each minute --- js/main.js | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'js/main.js') diff --git a/js/main.js b/js/main.js index 4e6416d..8b10d78 100644 --- a/js/main.js +++ b/js/main.js @@ -6,7 +6,7 @@ app.config(['$httpProvider', function($httpProvider) { } ]); -app.controller('VisualisationController', function($scope, $http, $q) { +app.controller('VisualisationController', function($scope, $http, $q, $interval) { function checkInArray(array, key) { if (array) { if (array.indexOf(key) > -1) { @@ -28,17 +28,21 @@ app.controller('VisualisationController', function($scope, $http, $q) { lastBuildID = value.cachedBuilds[value.cachedBuilds.length - 1]; } - var buildsPath = 'http://ciat.baserock.org:8010/json/builders/' + - key + '/builds/' + lastBuildID; - $http.get(buildsPath).then(function(response) { - var details = { - success: checkInArray(response.data.text, 'successful'), - failed: checkInArray(response.data.text, 'failed') - }; - $scope.steps.push({ - name: key, - lastBuild: details, - data: value + var buildsPath = 'http://ciat.baserock.org:8010/json/builders/' + + key + '/builds/' + lastBuildID; + $http.get(buildsPath).then(function(response) { + var details = { + success: checkInArray(response.data.text, 'successful'), + failed: checkInArray(response.data.text, 'failed') + }; + $scope.steps.push({ + name: key, + lastBuild: details, + data: value + }); + $scope.steps.sort(function(a, b) { + return a.charAt(0) > b.charAt(0); + }); }); }); }); -- cgit v1.2.1