Permalink
Browse files

Customize notification.

  • Loading branch information...
1 parent 1f58fd2 commit 3a7f9be8a9fab61b48f70b760fdceb7460a40375 @cmeiklejohn cmeiklejohn committed Jan 7, 2013
Showing with 30 additions and 9 deletions.
  1. +12 −8 assets/javascripts/app/events.js
  2. +18 −1 assets/javascripts/app/models.js
@@ -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();
}
});
}
@@ -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({

0 comments on commit 3a7f9be

Please sign in to comment.