diff --git a/app/js/controllers.js b/app/js/controllers.js index e9e0bb1c..edee7fa8 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -2510,7 +2510,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) }) - .controller('SettingsModalController', function ($rootScope, $scope, $timeout, $modal, AppUsersManager, AppChatsManager, AppPhotosManager, MtpApiManager, Storage, NotificationsManager, MtpApiFileManager, ApiUpdatesManager, ChangelogNotifyService, LayoutSwitchService, AppRuntimeManager, ErrorService, _) { + .controller('SettingsModalController', function ($rootScope, $scope, $timeout, $modal, AppUsersManager, AppChatsManager, AppPhotosManager, MtpApiManager, Storage, NotificationsManager, MtpApiFileManager, PasswordManager, ApiUpdatesManager, ChangelogNotifyService, LayoutSwitchService, AppRuntimeManager, ErrorService, _) { $scope.profile = {}; $scope.photo = {}; @@ -2533,6 +2533,30 @@ angular.module('myApp.controllers', ['myApp.i18n']) $scope.$watch('photo.file', onPhotoSelected); + $scope.password = {_: 'account.noPassword'}; + updatePasswordState(); + + $scope.changePassword = function (options) { + options = options || {}; + var scope = $rootScope.$new(); + angular.extend(scope, options); + var modal = $modal.open({ + scope: scope, + templateUrl: templateUrl('password_update_modal'), + controller: 'PasswordUpdateModalController', + windowClass: 'md_simple_modal_window mobile_modal' + }); + + modal.result['finally'](updatePasswordState); + }; + + function updatePasswordState (argument) { + PasswordManager.getPasswordState().then(function (result) { + $scope.password = result; + }); + } + + function onPhotoSelected (photo) { if (!photo || !photo.type || photo.type.indexOf('image') !== 0) { return; @@ -2858,6 +2882,10 @@ angular.module('myApp.controllers', ['myApp.i18n']) }) }) + .controller('PasswordUpdateModalController', function ($scope, PasswordManager, MtpApiManager) { + + }) + .controller('ContactsModalController', function ($scope, $timeout, $modal, $modalInstance, MtpApiManager, AppUsersManager, ErrorService) { $scope.contacts = []; diff --git a/app/js/services.js b/app/js/services.js index e5161442..d71b4005 100755 --- a/app/js/services.js +++ b/app/js/services.js @@ -4537,6 +4537,20 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) }) +.service('PasswordManager', function ($timeout, $rootScope, MtpApiManager) { + + return { + getPasswordState: getPasswordState + }; + + function getPasswordState () { + return MtpApiManager.invokeApi('account.getPassword').then(function (result) { + return result; + }); + } + +}) + .service('ErrorService', function ($rootScope, $modal, $window) { diff --git a/app/partials/desktop/password_update_modal.html b/app/partials/desktop/password_update_modal.html new file mode 100644 index 00000000..8031f62e --- /dev/null +++ b/app/partials/desktop/password_update_modal.html @@ -0,0 +1,47 @@ +
+ +
+ + + +
+ + + +
\ No newline at end of file diff --git a/app/partials/desktop/settings_modal.html b/app/partials/desktop/settings_modal.html index 21977275..5a419325 100644 --- a/app/partials/desktop/settings_modal.html +++ b/app/partials/desktop/settings_modal.html @@ -110,6 +110,13 @@
+ +