Skip to content

Instantly share code, notes, and snippets.

@tardyp
Created June 9, 2015 12:11
Show Gist options
  • Save tardyp/e9ba58896b77dfa428d4 to your computer and use it in GitHub Desktop.
Save tardyp/e9ba58896b77dfa428d4 to your computer and use it in GitHub Desktop.
new api for buildsumary directive
diff --git a/www/base/src/app/common/directives/buildsummary/buildsummary.directive.coffee b/www/base/src/app/common/directives/buildsummary/buildsummary.directive.coffee
index c91373c..d26d66a 100644
--- a/www/base/src/app/common/directives/buildsummary/buildsummary.directive.coffee
+++ b/www/base/src/app/common/directives/buildsummary/buildsummary.directive.coffee
@@ -11,6 +11,8 @@ class Buildsummary extends Directive('common')
class _buildsummary extends Controller('common')
constructor: ($scope, buildbotService, resultsService, $urlMatcherFactory, $location) ->
+ data = new buildbotService()
+
baseurl = $location.absUrl().split("#")[0]
buildrequestURLMatcher = $urlMatcherFactory.compile(
"#{baseurl}#buildrequests/{buildrequestid:[0-9]+}")
@@ -50,19 +52,22 @@ class _buildsummary extends Controller('common')
$scope.isBuildURL = (url) ->
return buildURLMatcher.exec(url) != null
+ $scope.$on("$destroy", -> data.close())
$scope.$watch 'buildid', (buildid) ->
$scope.buldid = buildid
- buildbotService.one('builds', $scope.buildid)
- .bind($scope).then (build) ->
- buildbotService.one('builders', build.builderid).bind($scope)
- build.all('steps').bind $scope,
- onchild: (step) ->
+ data.getBuild($scope.buildid)
+ .then (build) ->
+ $scope.build = build
+ data.getBuilder(build.builderid).then (builder) ->
+ $scope.builder = builder
+ data.getStepsForBuild().then (steps) ->
+ $scope.steps = steps
+ $scope.steps.onchild (step) ->
$scope.$watch (-> step.complete), ->
step.fulldisplay = step.complete == 0 || step.results > 0
if step.complete
step.duration = step.complete_at - step.started_at
- logs = buildbotService.one("steps", step.stepid).all("logs")
- logs.bind $scope,
- dest: step
+ data.getLogsForStep(step.stepid).then (logs) ->
+ step.logs = logs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment