diff --git a/src/app/organization/organizationDeleteController.js b/src/app/organization/organizationDeleteController.js new file mode 100644 index 0000000000..8075d21ea9 --- /dev/null +++ b/src/app/organization/organizationDeleteController.js @@ -0,0 +1,26 @@ +angular + .module('bit.organization') + + .controller('organizationDeleteController', function ($scope, $state, apiService, $uibModalInstance, cryptoService, + authService, toastr, $analytics) { + $analytics.eventTrack('organizationDeleteController', { category: 'Modal' }); + $scope.submit = function () { + var request = { + masterPasswordHash: cryptoService.hashPassword($scope.masterPassword) + }; + + $scope.submitPromise = apiService.organizations.del({ id: $state.params.orgId }, request, function () { + $uibModalInstance.dismiss('cancel'); + authService.removeProfileOrganization($state.params.orgId); + $analytics.eventTrack('Deleted Organization'); + $state.go('backend.user.vault').then(function () { + toastr.success('This organization and all associated data has been deleted.', + 'Organization Deleted'); + }); + }).$promise; + }; + + $scope.close = function () { + $uibModalInstance.dismiss('cancel'); + }; + }); diff --git a/src/app/organization/organizationSettingsController.js b/src/app/organization/organizationSettingsController.js index 6e9ad777eb..32e8604098 100644 --- a/src/app/organization/organizationSettingsController.js +++ b/src/app/organization/organizationSettingsController.js @@ -1,7 +1,7 @@ angular .module('bit.organization') - .controller('organizationSettingsController', function ($scope, $state, apiService, toastr, authService) { + .controller('organizationSettingsController', function ($scope, $state, apiService, toastr, authService, $uibModal) { $scope.model = {}; $scope.$on('$viewContentLoaded', function () { apiService.organizations.get({ id: $state.params.orgId }, function (org) { @@ -20,4 +20,12 @@ }); }).$promise; }; + + $scope.delete = function () { + $uibModal.open({ + animation: true, + templateUrl: 'app/organization/views/organizationDelete.html', + controller: 'organizationDeleteController' + }); + }; }); diff --git a/src/app/organization/views/organizationDelete.html b/src/app/organization/views/organizationDelete.html new file mode 100644 index 0000000000..4f4db0d84b --- /dev/null +++ b/src/app/organization/views/organizationDelete.html @@ -0,0 +1,34 @@ +