diff --git a/src/app/pages/ui/modals/ModalsPageCtrl.js b/src/app/pages/ui/modals/ModalsPageCtrl.js index 159a252..0be75e3 100644 --- a/src/app/pages/ui/modals/ModalsPageCtrl.js +++ b/src/app/pages/ui/modals/ModalsPageCtrl.js @@ -9,7 +9,7 @@ .controller('ModalsPageCtrl', ModalsPageCtrl); /** @ngInject */ - function ModalsPageCtrl($scope, $uibModal) { + function ModalsPageCtrl($scope, $uibModal, baProgressModal) { $scope.open = function (page, size) { $uibModal.open({ animation: true, @@ -22,6 +22,7 @@ } }); }; + $scope.openProgressDialog = baProgressModal.open; } diff --git a/src/app/pages/ui/modals/modals.html b/src/app/pages/ui/modals/modals.html index 4efb3a8..b0e302c 100644 --- a/src/app/pages/ui/modals/modals.html +++ b/src/app/pages/ui/modals/modals.html @@ -42,5 +42,17 @@
+
+
+ +
+
diff --git a/src/app/pages/ui/modals/progressModal/ProgressModalCtrl.js b/src/app/pages/ui/modals/progressModal/ProgressModalCtrl.js new file mode 100644 index 0000000..73633da --- /dev/null +++ b/src/app/pages/ui/modals/progressModal/ProgressModalCtrl.js @@ -0,0 +1,25 @@ +/** + * Created by n.poltoratsky + * on 24.06.2016. + */ +(function () { + 'use strict'; + + angular.module('BlurAdmin.pages.ui.modals') + .controller('ProgressModalCtrl', ProgressModalCtrl); + + function ProgressModalCtrl($timeout, baProgressModal) { + + baProgressModal.setProgress(0); + + (function changeValue() { + if (baProgressModal.getProgress() >= 100) { + baProgressModal.close(); + } else { + baProgressModal.setProgress(baProgressModal.getProgress() + 10); + $timeout(changeValue, 300); + } + })(); + } + +})(); diff --git a/src/app/pages/ui/modals/progressModal/progressModal.html b/src/app/pages/ui/modals/progressModal/progressModal.html new file mode 100644 index 0000000..e4be891 --- /dev/null +++ b/src/app/pages/ui/modals/progressModal/progressModal.html @@ -0,0 +1,8 @@ + \ No newline at end of file diff --git a/src/app/theme/components/progressBarRound/progressBarRound.directive.js b/src/app/theme/components/progressBarRound/progressBarRound.directive.js new file mode 100644 index 0000000..d65cb7e --- /dev/null +++ b/src/app/theme/components/progressBarRound/progressBarRound.directive.js @@ -0,0 +1,30 @@ +/** + * Created by n.poltoratsky + * on 28.06.2016. + */ +(function () { + 'use strict'; + + angular.module('BlurAdmin.theme.components') + .directive('progressBarRound', progressBarRound); + + /** @ngInject */ + function progressBarRound(baProgressModal) { + return { + restrict: 'E', + templateUrl: 'app/theme/components/progressBarRound/progressBarRound.html', + link:function($scope, element, attrs) { + $scope.baProgressDialog = baProgressModal; + $scope.$watch(function () { + return baProgressModal.getProgress(); + }, animateBar); + + function animateBar() { + var circle = element.find('#loader')[0]; + circle.setAttribute("stroke-dasharray", baProgressModal.getProgress() * 180 * Math.PI / 100 + ", 20000"); + $scope.progress = baProgressModal.getProgress(); + } + } + } + } +})(); \ No newline at end of file diff --git a/src/app/theme/components/progressBarRound/progressBarRound.html b/src/app/theme/components/progressBarRound/progressBarRound.html new file mode 100644 index 0000000..c7c2b9b --- /dev/null +++ b/src/app/theme/components/progressBarRound/progressBarRound.html @@ -0,0 +1,8 @@ + + + + Loading... + {{progress}}% + \ No newline at end of file diff --git a/src/app/theme/services/baProgressModal.js b/src/app/theme/services/baProgressModal.js new file mode 100644 index 0000000..f0a4ea7 --- /dev/null +++ b/src/app/theme/services/baProgressModal.js @@ -0,0 +1,55 @@ +/** + * @author n.poltoratsky + * created on 27.06.2016 + */ +(function () { + 'use strict'; + + angular.module('BlurAdmin.theme') + .factory('baProgressModal', baProgressModal); + + /** @ngInject */ + function baProgressModal($uibModal) { + var methods = {}; + var progress = 0; + var max = 100; + var opened = false; + + return { + setProgress: function (value) { + if (value > max) { + throw Error('Progress can\'t be greater than max'); + } + progress = value; + }, + getProgress: function () { + return progress; + }, + open: function() { + if (!opened) { + methods = $uibModal.open({ + animation: true, + templateUrl: 'app/pages/ui/modals/progressmodal/progressModal.html', + size: 'sm', + keyboard: false, + backdrop: 'static' + }); + opened = true; + } else { + throw Error('Progress modal opened now'); + } + + }, + close: function() { + if (opened) { + methods.close(); + opened = false; + } else { + throw Error('Progress modal is not active'); + } + + } + }; + } + +})(); \ No newline at end of file diff --git a/src/sass/theme/components/_progressRound.scss b/src/sass/theme/components/_progressRound.scss new file mode 100644 index 0000000..5de9471 --- /dev/null +++ b/src/sass/theme/components/_progressRound.scss @@ -0,0 +1,12 @@ +svg.progress-bar-round circle { + transition: 0.5s; +} +.percentage { + font-size: 46px; +} +.loading { + font-size: 16px; +} +.progress-bar-round { + margin-top: 15px; +} \ No newline at end of file