Skip to content

Commit

Permalink
Customize notification.
Browse files Browse the repository at this point in the history
  • Loading branch information
cmeiklejohn committed Jan 7, 2013
1 parent 1f58fd2 commit 3a7f9be
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
20 changes: 12 additions & 8 deletions assets/javascripts/app/events.js
Expand Up @@ -4,19 +4,23 @@ GiddyUp.EventProcessor = Ember.Object.extend({

this.source.addEventListener('test_result', function(e) {
var parsedResponse = JSON.parse(e.data);
var testResult = parsedResponse.test_result;
var testResult = parsedResponse.test_result;

// Load the new test result into the store.
//
GiddyUp.store.load(GiddyUp.TestResult, testResult);

// Trigger a notification.
// Notification handling.
//
if (window.webkitNotifications &&
window.webkitNotifications.checkPermission() === 0) {
window.webkitNotifications.createNotification(
'icon.png',
'GiddyUp: Test Result Posted!',
'Build: ' + testResult.long_version).
show();
window.webkitNotifications.checkPermission() === 0) {

var result = GiddyUp.TestResult.find(testResult.id);
var message = result.get('notification');

window.webkitNotifications.createNotification(
"icon.png", message.title, message.message
).show();
}
});
}
Expand Down
19 changes: 18 additions & 1 deletion assets/javascripts/app/models.js
Expand Up @@ -70,7 +70,24 @@ GiddyUp.TestResult = DS.Model.extend({

log_url: DS.attr('string'),
created_at: DS.attr('date'),
long_version: DS.attr('string')
long_version: DS.attr('string'),

notification: function() {
var status = this.get('status') === true ? "pass" : "fail";
var instance = this.get('test_instance');
var scorecard = instance.get('scorecard');
var project = scorecard.get('project');
var backend = instnace.get('backend') || "undefined";

return {
title: "GiddyUp: New " + status + " on " +
project.get('name') + " " +
scorecard.get('name'),
message: instance.get('name') + " | " +
instance.get('backend') + " | " +
instance.get('platform')
};
}.property()
});

GiddyUp.Log = DS.Model.extend({
Expand Down

0 comments on commit 3a7f9be

Please sign in to comment.