From 36259776a1d73ce2c66cd12d5829b1f7509abf24 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Tue, 20 Aug 2013 23:10:24 +0400 Subject: [PATCH] #267: added sound notifications --- Gemfile | 1 + Gemfile.lock | 2 ++ app/assets/javascripts/angularjs/config.js | 19 +++++++++++++++++- .../controllers/build_list_controller.js.erb | 7 +++++-- .../product_build_list_controller.js.erb | 7 +++++-- app/assets/javascripts/application.js | 2 ++ vendor/assets/audios/garbage_shattering.wav | Bin 0 -> 18354 bytes 7 files changed, 33 insertions(+), 5 deletions(-) create mode 100644 vendor/assets/audios/garbage_shattering.wav 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 0000000000000000000000000000000000000000..9953752adb4e61d538b954610cad4432a549432b GIT binary patch literal 18354 zcmeI3&uf)gn#b>ii(Djxiv$TF$Rz{`5+pQPxNu=Zrp5smGB`6XT-ZFZvIt zMJ;+!i(0sF;lhRVxX2<47cMNyrcxL&qLKt7Mq-GPghVtXk_5Uw{pHK^yzhN)q82@? z&VhU0`=0asJkO7Fo^$gb|NhlifBCms?Z1EfU;p|)zyD+FSglt3mtWfEf7WV?|5vMZ z)tbM&`TBQ%{M|Rd%zE?w&HLByqAhMLtgF3#$JpA|+7`X%EpE7JT<;gw=T@J-rOmA_ zZoGcCwzawa;p5J3vF+`v)oS&wM!iw*K0<3YdXLijx(9k%&7ot%y(7m*`^Ngu47iQ; zkM@lmA3D}*_I1-VPv4sjH!$>d_a1FFx{uVmYPFr+4D#HLdoS-ipP0S< z?B?Sek7&1^Ow8VSe)q-wSJTVzJ-52B4)2m#5@e3y)Vzw@fgb2}A8FK~r@uzM+34%G z93#hvdt1$c9yq3Fz8i3A(u489H*IHkZy!ymfqifP!^h2S)=T=HS(#axUY=TVn_iw? z=AG8TD`MG@Y;${Ow^oD4-lNvG^^KO%^KdVk6~AySom$K0)$67e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