Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Big assets dump, loads, displays minimally.

  • Loading branch information...
commit 3d66b70d19db2492bbb2e646468ec091bd3c31a6 1 parent 6d01aa4
@seancribbs seancribbs authored
View
6 assets/javascripts/app/controllers.js
@@ -59,10 +59,10 @@ GiddyUp.TestInstanceController = Ember.ObjectController.extend({
GiddyUp.TestResultsController = Ember.ArrayController.extend({
sortProperties: ['createdAt'],
- sortAscending: false,
- itemController: 'test_result'
+ sortAscending: false
});
-GiddyUp.TestResultController = Ember.ObjectController.extend({
+GiddyUp.ArtifactsController = Ember.ArrayController.extend({});
+GiddyUp.ArtifactController = Ember.ObjectController.extend({
});
View
38 assets/javascripts/app/helpers.js
@@ -71,3 +71,41 @@ helper('timeAgoInWords', function(date){
return distance_in_years + " years ago";
}
});
+
+helper('mediaIcon', function(ctype){
+ if(Ember.isNone(ctype))
+ return '';
+
+ var type = ctype.toString().split(";")[0].trim().split("/"),
+ major = type[0],
+ minor = type[1],
+ icon;
+ if(major === 'image'){
+ icon = 'icon-picture';
+ } else if(major === 'text') {
+ if(minor === 'csv'){
+ icon = 'icon-th';
+ } else {
+ icon = 'icon-pencil';
+ }
+ } else {
+ icon = 'icon-file';
+ }
+ return new Handlebars.SafeString('<i class=\"' + icon + '\"></i>');
+});
+
+helper('shortpath', function(url){
+ // We want to extract the shortest meaningful path from the given
+ // URL. For now we assume the file will either be named "ID.log"
+ // where ID is a number, or "ID/some/deep/path/to/tehfile.bmp". For
+ // the former, just return the full thing, for the latter, strip off
+ // the ID prefix.
+ if(Ember.isNone(url))
+ return '';
+
+ var path = url.split("/").slice(3);
+ if(path[0].match("^[0-9]+$"))
+ return path.slice(1).join("/");
+ else
+ return path.join('/');
+});
View
41 assets/javascripts/app/models.js
@@ -20,16 +20,45 @@ GiddyUp.TestInstance = DS.Model.extend({
GiddyUp.TestResult = DS.Model.extend({
testInstance: DS.belongsTo('GiddyUp.TestInstance'),
+ artifacts: DS.hasMany('GiddyUp.Artifact'),
status: DS.attr('boolean'),
logUrl: DS.attr('string'),
- // Hack until we can get real artifacts
- log: function(){
- return GiddyUp.Log.find(this.get('id'));
- }.property('id'),
createdAt: DS.attr('date'),
longVersion: DS.attr('string')
});
-GiddyUp.Log = DS.Model.extend({
- body: DS.attr('string')
+GiddyUp.Artifact = DS.Model.extend({
+ url: DS.attr('string'),
+ contentType: DS.attr('string'),
+ testResult: DS.belongsTo('GiddyUp.TestResult'),
+ text: function(){
+ var url = this.get('url'),
+ ctype = this.get('contentType'),
+ id = this.get('id');
+
+ if(Ember.isNone(ctype) || Ember.isNone(url) || !ctype.match(/^text/))
+ return '';
+
+ // l33t h4x - avert thine eyes
+ var adapter = GiddyUp.__container__.lookup('store:main').get('_adapter'),
+ root = adapter.rootForType(GiddyUp.Artifact);
+
+ url = adapter.buildURL(root, id);
+
+ console.log(['fetching dat text', url, id, ctype]);
+
+ $.ajax(url, {
+ cache: false,
+ accepts: {'text': ctype},
+ context: this,
+ dataType: 'text',
+ success: function(data){
+ this.set('text', data);
+ },
+ error: function(){
+ this.set('text', 'Could not load the log the GiddyUp server!');
+ }
+ });
+ return 'Loading...';
+ }.property('url', 'contentType')
});
View
53 assets/javascripts/app/router.js
@@ -15,14 +15,15 @@ GiddyUp.Router.map(function(){
this.resource('test_instance', { path: ':test_instance_id' }, function(){
// /projects/:project_id/scorecards/:scorecard_id/:test_instance_id/:test_result_id
// Display an individual test result
- this.resource('test_result', { path: ':test_result_id' });
+ this.resource('test_result', { path: ':test_result_id' }, function(){
+ // /projects/:project_id/scorecards/:scorecard_id/:test_instance_id/:test_result_id/:artifact_id
+ // Display a test result's artifact
+ this.resource('artifact', { path: 'artifacts/:artifact_id' });
+ });
});
});
});
});
- // /logs/:test_result_id
- // Display the log of a test result in the full window
- this.resource('log', {path: '/logs/:log_id' });
});
GiddyUp.IndexRoute = Ember.Route.extend({
@@ -107,6 +108,8 @@ GiddyUp.TestInstanceRoute = Ember.Route.extend({
setupController: function(controller, model){
var testResults = this.controllerFor('test_results');
testResults.set('model', model.get('testResults'));
+ },
+ renderTemplate: function(){
this.render('test_instance', {into: 'scorecard'});
}
});
@@ -115,6 +118,8 @@ GiddyUp.TestInstanceIndexRoute = Ember.Route.extend({
setupController: function(){
var testResults = this.controllerFor('test_results');
testResults.set('selectedItem', null);
+ },
+ renderTemplate: function(){
this.render('help/test_instance', {into: 'application', outlet: 'help'});
this.render();
}
@@ -125,23 +130,39 @@ GiddyUp.TestResultRoute = Ember.Route.extend({
return GiddyUp.TestResult.find(params.test_result_id);
},
setupController: function(controller, model){
- var testResults = this.controllerFor('test_results');
+ var testResults = this.controllerFor('test_results'),
+ artifacts = this.controllerFor('artifacts');
testResults.set('selectedItem', model);
- this.render();
+ artifacts.set('model', model.get('artifacts'));
+ },
+ renderTemplate: function(){
+ this.render('artifacts', {into: 'test_instance',
+ outlet: 'artifacts' });
+ }
+});
+
+GiddyUp.TestResultIndexRoute = Ember.Route.extend({
+ setupController: function(){
+ var artifacts = this.controllerFor('artifacts'),
+ testResults = this.controllerFor('test_results');
+ artifacts.set('selectedItem', null);
+ },
+ renderTemplate: function(){
this.render('help/test_result', {into: 'application', outlet: 'help'});
+ this.render('test_instance/index', {into: 'test_instance'});
}
});
-GiddyUp.LogRoute = Ember.Route.extend({
- helpWasShowing: false,
- activate: function(){
- $('img.cowboy').hide();
- this.set('helpWasShowing', $('#help').is(':visible'))
- $('#help').hide();
+GiddyUp.ArtifactRoute = Ember.Route.extend({
+ model: function(params){
+ return GiddyUp.Artifact.find(params.artifact_id);
+ },
+ setupController: function(controller, model){
+ var artifacts = this.controllerFor('artifacts');
+ artifacts.set('selectedItem', model);
},
- deactivate: function(){
- $('img.cowboy').show();
- if(this.get('helpWasShowing'))
- $('#help').show();
+ renderTemplate: function(){
+ this.render('help/artifact', {into: 'application', outlet: 'help'});
+ this.render('artifact', {into: 'test_instance'});
}
});
View
3  assets/javascripts/app/templates/artifact/download.hbs
@@ -0,0 +1,3 @@
+<div class="span9 well">
+ <p><i class="icon-download"></i><a target="_blank" {{bindAttr href="url"}}>Download this artifact</a></p>
+</div>
View
3  assets/javascripts/app/templates/artifact/image.hbs
@@ -0,0 +1,3 @@
+<div class="span9">
+ <img {{bindAttr src="url"}} />
+</div>
View
3  assets/javascripts/app/templates/artifact/text.hbs
@@ -0,0 +1,3 @@
+<div class="span9">
+ <pre class="abridged">{{ text }}</pre>
+</div>
View
7 assets/javascripts/app/templates/artifacts.hbs
@@ -0,0 +1,7 @@
+<ul class="nav nav-list">
+ <li class="divider"></li>
+ <li class="nav-header">Artifacts</li>
+ {{#each controller itemViewClass="GiddyUp.ArtifactItemView"}}
+ {{#linkTo 'artifact' this}}{{mediaIcon contentType}} {{shortpath this.url}}{{/linkTo}}
+ {{/each}}
+</ul>
View
11 assets/javascripts/app/templates/help/artifact.hbs
@@ -0,0 +1,11 @@
+<h3 class="popover-title">Whoa, boy!</h3>
+<div class="popover-content">
+
+ <p>That there is a lot of stuff! riak_test uses lots of four-dollar
+ words, I tell ye'.</p>
+
+ <p>Scroll down to see the rest of the output if the thing you've
+ selected is text. Otherwise just have a look at the pretty
+ picture!</p>
+
+</div>
View
8 assets/javascripts/app/templates/help/test_result.hbs
@@ -1,11 +1,7 @@
<h3 class="popover-title">Git along, lil' dogie!</h3>
<div class="popover-content">
- <p>There's ye'r test output in the dark box. If ye' can't see enough
- of it at once, click yonder "enlarge log" link below the
- varmint.</p>
-
- <p>To show this screen again after enlarging the log, just click
- ye'r Back button.</p>
+ <p>We herded a number for ye' from the time that there test was run.
+ Click an artifact to get an ideer of how things transpired.</p>
</div>
View
3  assets/javascripts/app/templates/test_instance.hbs
@@ -1,9 +1,10 @@
<div class="row-fluid">
- <h4>{{descriptor}} {{#linkTo 'scorecard' this.scorecard class="btn btn-mini" activeClass="fakeActive"}}&times;&nbsp; Hide results{{/linkTo}}</h4>
+ <h4>{{#linkTo 'scorecard' scorecard activeClass="fakeActive"}}{{scorecard.name}}{{/linkTo}} : {{descriptor}}</h4>
</div>
<div class="row-fluid">
<div class="span3 well">
{{ render "test_results" }}
+ {{ outlet artifacts }}
</div>
{{outlet}}
</div>
View
8 assets/javascripts/app/templates/test_result.hbs
@@ -1,7 +1 @@
-<div class="span9">
- <pre class="abridged">{{ log.body }}</pre>
-
- <div class="pull-right" style="margin-bottom: 10px">
- {{#linkTo log log}}enlarge log{{/linkTo}}
- </div>
-</div>
+{{ render "artifacts" }}
View
22 assets/javascripts/app/views.js
@@ -3,8 +3,30 @@ require('selectable');
GiddyUp.ProjectItemView = Ember.View.extend(GiddyUp.Selectable);
GiddyUp.ScorecardItemView = Ember.View.extend(GiddyUp.Selectable);
GiddyUp.TestResultItemView = Ember.View.extend(GiddyUp.Selectable);
+GiddyUp.ArtifactItemView = Ember.View.extend(GiddyUp.Selectable);
GiddyUp.HelpView = Ember.View.extend();
+GiddyUp.ArtifactView = Ember.View.extend({
+ templateName: function(){
+ var ctype = this.get('controller.contentType'),
+ type, major, minor;
+
+ if(Ember.isNone(ctype))
+ return 'artifact/download';
+
+ type = ctype.toString().split(";")[0].trim().split("/");
+ major = type[0];
+ minor = type[1];
+
+ if(major === 'text')
+ return 'artifact/text';
+ else if (major === 'image')
+ return 'artifact/image';
+ else
+ return 'artifact/download';
+ }.property('controller.contentType')
+});
+
GiddyUp.BubbleView = Ember.View.extend({
tagName: 'div',
statusClasses: function(){
View
1  config.ru
@@ -14,6 +14,7 @@ Rack::Mime::MIME_TYPES['.woff'] = 'application/x-font-woff'
use Rack::Rewrite do
rewrite %r{^(.*)\/$}, '$1/index.html'
+ rewrite %r{^(.*)\/img\/(.*)$}, '$1/images/$2' # Hack for bootstrap
end
unless ENV['RACK_ENV'] == 'production'
View
17 lib/giddyup/resources.rb
@@ -236,6 +236,22 @@ def transactional?
end
end
+ class ArtifactListResource < Resource
+ def resource_exists?
+ begin
+ @artifacts = Artifact.find(query_ids)
+ rescue ActiveRecord::RecordNotFound
+ false
+ else
+ true
+ end
+ end
+
+ def to_json
+ ActiveModel::ArraySerializer.new(@artifacts, {:root => "artifacts"}).to_json
+ end
+ end
+
class TestResultsResource < Resource
def resource_exists?
begin
@@ -381,6 +397,7 @@ def to_json
add ['live'], LiveResource
add ['scorecards', :id], ScorecardResource
add ['scorecards'], ScorecardsResource
+ add ['artifacts'], ArtifactListResource
add ['artifacts', :id], ArtifactResource
add ['test_results', :test_result_id, 'artifacts', '*'], ArtifactResource do |request|
request.post?
View
2  lib/giddyup/serializers.rb
@@ -46,5 +46,5 @@ def test_instance_ids
end
class ArtifactSerializer < ActiveModel::Serializer
- attributes :url, :content_type, :test_result_id
+ attributes :id, :url, :content_type, :test_result_id
end
View
BIN  public/images/glyphicons-halflings-white.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  public/images/glyphicons-halflings.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Please sign in to comment.
Something went wrong with that request. Please try again.