diff --git a/Gemfile b/Gemfile index 44d8c428d..7fee616c9 100644 --- a/Gemfile +++ b/Gemfile @@ -65,6 +65,7 @@ gem 'ng-rails-csrf' gem 'momentjs-rails' gem 'angular-i18n', '0.1.2' gem 'js-routes' +gem 'soundmanager-rails' gem 'time_diff' diff --git a/Gemfile.lock b/Gemfile.lock index ec77c2116..4d08d44a6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -372,6 +372,7 @@ GEM skinny (0.2.3) eventmachine (~> 1.0.0) thin (~> 1.5.0) + soundmanager-rails (0.1.5) sprockets (2.2.2) hike (~> 1.2) multi_json (~> 1.0) @@ -492,6 +493,7 @@ DEPENDENCIES sass-rails (~> 3.2.5) shotgun shoulda + soundmanager-rails state_machine therubyracer (~> 0.10.2) therubyrhino (~> 1.73.1) diff --git a/app/assets/javascripts/angularjs/config.js b/app/assets/javascripts/angularjs/config.js index c8bbb149b..9d1a7862e 100644 --- a/app/assets/javascripts/angularjs/config.js +++ b/app/assets/javascripts/angularjs/config.js @@ -23,4 +23,21 @@ var LocalesHelper = function($locale) { } } } -RosaABF.factory("LocalesHelper", ['$locale', LocalesHelper]); \ No newline at end of file +RosaABF.factory("LocalesHelper", ['$locale', LocalesHelper]); + +var SoundNotificationsHelper = function() { + var statusChangedSound = null; + soundManager.setup({ + url: '/assets/swf/', + onready: function() { + statusChangedSound = soundManager.createSound({url: '/assets/garbage_shattering.wav'}); + } + }); + return { + buildStatusChanged: function() { + if (statusChangedSound) + statusChangedSound.play(); + } + } +} +RosaABF.factory('SoundNotificationsHelper', SoundNotificationsHelper); \ No newline at end of file diff --git a/app/assets/javascripts/angularjs/controllers/build_list_controller.js.erb b/app/assets/javascripts/angularjs/controllers/build_list_controller.js.erb index 47b735e38..07eb79599 100644 --- a/app/assets/javascripts/angularjs/controllers/build_list_controller.js.erb +++ b/app/assets/javascripts/angularjs/controllers/build_list_controller.js.erb @@ -1,4 +1,4 @@ -RosaABF.controller('BuildListController', ['$scope', '$http', '$timeout', function($scope, $http, $timeout) { +RosaABF.controller('BuildListController', ['$scope', '$http', '$timeout', 'SoundNotificationsHelper', function($scope, $http, $timeout, SoundNotificationsHelper) { $scope.advisoriable_types = <%=BuildList::RELEASE_UPDATE_TYPES%>; @@ -13,7 +13,10 @@ RosaABF.controller('BuildListController', ['$scope', '$http', '$timeout', functi $scope.getBuildList = function() { $http.get(Routes.build_list_path($scope.id, {format: 'json'})).success(function(results) { - $scope.build_list = $scope.subject = new BuildList(results.build_list); + var build_list = new BuildList(results.build_list); + if ($scope.build_list && $scope.build_list.status != build_list.status) + SoundNotificationsHelper.buildStatusChanged(); + $scope.build_list = $scope.subject = build_list; }); } diff --git a/app/assets/javascripts/angularjs/controllers/product_build_list_controller.js.erb b/app/assets/javascripts/angularjs/controllers/product_build_list_controller.js.erb index cbe6863fd..33875bc07 100644 --- a/app/assets/javascripts/angularjs/controllers/product_build_list_controller.js.erb +++ b/app/assets/javascripts/angularjs/controllers/product_build_list_controller.js.erb @@ -1,4 +1,4 @@ -RosaABF.controller('ProductBuildListController', ['$scope', '$http', '$timeout', function($scope, $http, $timeout) { +RosaABF.controller('ProductBuildListController', ['$scope', '$http', '$timeout', 'SoundNotificationsHelper', function($scope, $http, $timeout, SoundNotificationsHelper) { $scope.id = $('#product_build_list_id').val(); $scope.pbl = null; @@ -6,7 +6,10 @@ RosaABF.controller('ProductBuildListController', ['$scope', '$http', '$timeout', $scope.getProductBuildList = function() { $http.get(Routes.product_build_list_path($scope.id, {format: 'json'})).success(function(results) { - $scope.pbl = $scope.subject = results.product_build_list; + var product_build_list = results.product_build_list; + if ($scope.pbl && $scope.pbl.status != product_build_list.status) + SoundNotificationsHelper.buildStatusChanged(); + $scope.pbl = $scope.subject = product_build_list; }); } diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index da4b48c1a..8cbc38920 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -19,6 +19,8 @@ //= require angular-i18n //= require_tree ./angularjs //= require moment +//= require soundmanager2 +// require soundmanager2-nodebug-jsmin //= require_self diff --git a/vendor/assets/audios/garbage_shattering.wav b/vendor/assets/audios/garbage_shattering.wav new file mode 100644 index 000000000..9953752ad Binary files /dev/null and b/vendor/assets/audios/garbage_shattering.wav differ