diff --git a/app/index.html b/app/index.html index 45dd1e44..a75bf48d 100644 --- a/app/index.html +++ b/app/index.html @@ -209,11 +209,11 @@

- + diff --git a/app/public/js/common/SC2apiService.js b/app/public/js/common/SC2apiService.js index aedbd395..08d0daec 100644 --- a/app/public/js/common/SC2apiService.js +++ b/app/public/js/common/SC2apiService.js @@ -9,7 +9,7 @@ app.service('SC2apiService', function ( $window, $http, $q, - rateLimit + modalFactory ) { /** @@ -118,7 +118,7 @@ app.service('SC2apiService', function ( */ function onResponseError(response) { if (response.status === 429) { - rateLimit.showNotification(); + modalFactory.rateLimitReached(); } return $q.reject(response.data); } diff --git a/app/public/js/common/SCapiService.js b/app/public/js/common/SCapiService.js index d000bb6f..619cd9a0 100644 --- a/app/public/js/common/SCapiService.js +++ b/app/public/js/common/SCapiService.js @@ -8,7 +8,7 @@ app.service('SCapiService', function ( $state, $stateParams, $rootScope, - rateLimit + modalFactory ) { /** @@ -36,7 +36,7 @@ app.service('SCapiService', function ( return $http.get(url) .then(function (response, status) { if (response.status === 429) { - rateLimit.showNotification(); + modalFactory.rateLimitReached(); return []; } diff --git a/app/public/js/common/rateLimitService.js b/app/public/js/common/modalFactory.js similarity index 51% rename from app/public/js/common/rateLimitService.js rename to app/public/js/common/modalFactory.js index 481936a6..304548cf 100644 --- a/app/public/js/common/rateLimitService.js +++ b/app/public/js/common/modalFactory.js @@ -1,15 +1,41 @@ 'use strict'; -// Displays popup with a warning that rate limit is reached, with a link -// to SoundCloud docs attached. Call it when response returns 429 status -app.service('rateLimit', function ( +app.factory('modalFactory', function ( $http, ngDialog ) { - this.showNotification = function () { + + var modalFactory = { + // Unified modal to ask for confirmation of some action + confirm: confirm, + // Displays modal with a warning that rate limit is reached, with a link + // to SoundCloud docs attached. Call it when response returns 429 status + rateLimitReached: rateLimitReached + }; + + return modalFactory; + + // + + function confirm(message) { + return ngDialog.openConfirm({ + showClose: false, + template: 'views/common/modals/confirm.html', + controller: ['$scope', function ($scope) { + + $scope.content = message; + + $scope.closeModal = function () { + ngDialog.closeAll(); + }; + }] + }); + } + + function rateLimitReached() { return ngDialog.open({ showClose: false, - template: 'views/common/modal.html', + template: 'views/common/modals/default.html', controller: ['$scope', function ($scope) { var urlGH = 'https://api.github.com/repos/Soundnode/soundnode-about/contents/rate-limit-reached.html'; var config = { @@ -33,5 +59,6 @@ app.service('rateLimit', function ( }); }] }); - }; + } + }); diff --git a/app/public/js/playlists/playlistsCtrl.js b/app/public/js/playlists/playlistsCtrl.js index d7b7c8d8..8afb4b06 100644 --- a/app/public/js/playlists/playlistsCtrl.js +++ b/app/public/js/playlists/playlistsCtrl.js @@ -1,6 +1,6 @@ 'use strict'; -app.controller('PlaylistsCtrl', function ($scope, SCapiService, $rootScope, $log, $window, $http, $state, $stateParams, notificationFactory) { +app.controller('PlaylistsCtrl', function ($scope, SCapiService, $rootScope, $log, $window, $http, $state, $stateParams, notificationFactory, modalFactory) { var endpoint = 'me/playlists' , params = ''; @@ -80,23 +80,25 @@ app.controller('PlaylistsCtrl', function ($scope, SCapiService, $rootScope, $log * @method removePlaylist */ $scope.removePlaylist = function(playlistId) { - - SCapiService.removePlaylist(playlistId) - .then(function(response) { - if ( typeof response === 'object' ) { - notificationFactory.success("Playlist removed!"); - } - }, function(error) { - notificationFactory.error("Something went wrong!"); - }) - .finally(function() { - $state.transitionTo($state.current, $stateParams, { - reload: true, - inherit: false, - notify: true - }); + modalFactory + .confirm('Do you really want to delete the playlist?') + .then(function () { + SCapiService.removePlaylist(playlistId) + .then(function(response) { + if ( typeof response === 'object' ) { + notificationFactory.success("Playlist removed!"); + } + }, function(error) { + notificationFactory.error("Something went wrong!"); + }) + .finally(function() { + $state.transitionTo($state.current, $stateParams, { + reload: true, + inherit: false, + notify: true + }); + }); }); - }; /** diff --git a/app/views/about/about.html b/app/views/about/about.html index 2fe095ef..8d3406de 100644 --- a/app/views/about/about.html +++ b/app/views/about/about.html @@ -1,5 +1,5 @@
-
+
diff --git a/app/views/common/closeModal.html b/app/views/common/modals/closeButton.html similarity index 100% rename from app/views/common/closeModal.html rename to app/views/common/modals/closeButton.html diff --git a/app/views/common/modals/confirm.html b/app/views/common/modals/confirm.html new file mode 100644 index 00000000..28f4e025 --- /dev/null +++ b/app/views/common/modals/confirm.html @@ -0,0 +1,10 @@ +
+
+ +
+ + +
diff --git a/app/views/common/modal.html b/app/views/common/modals/default.html similarity index 58% rename from app/views/common/modal.html rename to app/views/common/modals/default.html index ac4f5694..063b8a44 100644 --- a/app/views/common/modal.html +++ b/app/views/common/modals/default.html @@ -1,5 +1,5 @@
-
+
diff --git a/app/views/playlists/playlistDashboard.html b/app/views/playlists/playlistDashboard.html index 5129d720..ac5e6a2f 100644 --- a/app/views/playlists/playlistDashboard.html +++ b/app/views/playlists/playlistDashboard.html @@ -1,6 +1,6 @@
-
- +
+

Where do you want to add: {{ playlistSongName }}