Commits

Benoît Allard committed 86aad8b

First version, builders are shown, together with their idleism

Comments (0)

Files changed (6)

+server_url = 'http://buildbot.buildbot.net/json/'
+
+BuildBot = Ember.Application.create();
+
+BuildBot.Router.map(function(){
+    this.resource('builds');
+    this.resource('builders');
+    this.resource('slaves');
+});
+
+
+BuildBot.BuildersRoute = Ember.Route.extend({
+    model: function() {
+	var content = [];
+	
+	$.ajax({
+	    url: server_url+'builders',
+	    dataType: 'json',
+	    success: function(data) {
+		// Turn JSON objects into bindable Ember
+		// objects.
+		for (name in data){
+		    data[name].name = name
+		    content.pushObject(BuildBot.Builder.create(data[name]));
+		}
+	    },
+	});
+	return content;
+    }, 
+});
+
+BuildBot.Step = Ember.Object.extend({});
+
+BuildBot.Build = Ember.Object.extend({
+    builder: null,
+    number: null,
+    slave: null,
+    steps: [],
+    isDone: false,
+    isFailed: false,
+});
+
+BuildBot.Builder = Ember.Object.extend({
+    name: null,
+    state: null,
+    isIdle: function(){
+	return this.get('state') == 'idle';
+    }.property('state'),
+});
+
+BuildBot.Slave = Ember.Object.extend({
+    name: null,
+    builders: [],
+});
+
+BuildBot.BuildersController = Ember.ArrayController.extend({
+
+    busyCount: function() {
+	var busys = this.filter(function(builder) {
+	    return ! builder.get('isIdle');
+	});
+	return busys.get('length');
+    }.property('content.@each'),
+});
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html> <head>
+<title>BuildBot-js</title>
+<script src="vendor/jquery-1.9.1.min.js", type="text/javascript"></script>
+<script src="vendor/handlebars-1.0.0-rc.3.js", type="text/javascript"></script>
+<script src="vendor/ember-1.0.0-rc.1.js", type="text/javascript"></script>
+<script src="app.js", type="text/javascript"></script>
+</head>
+
+<body>
+<h1>BuildBot-js</h1>
+
+<script type="text/x-handlebars" data-template-name="application" >
+<nav>
+  {{#linkTo 'index'}}Home{{/linkTo}}
+  {{#linkTo 'builders'}}Builders{{/linkTo}}
+  {{#linkTo 'slaves'}}Slaves{{/linkTo}}
+  {{#linkTo 'builds'}}Last Builds{{/linkTo}}
+</nav>
+<div>
+  {{outlet}}
+</div>
+</script>
+
+<script type="text/x-handlebars" data-template-name="builders" >
+{{controller.busyCount}} busy builders at the moment.
+<ul>
+  {{#each builder in controller}}
+  {{#with builder}}
+    <li {{bindAttr class="state"}}>{{name}}{{#unless
+  isIdle}}(BUSY){{/unless}}</li>
+  {{/with}}
+  {{/each}}
+</ul>
+</script>
+
+
+
+</body> </html>