diff --git a/src/app/organization/organizationPeopleController.js b/src/app/organization/organizationPeopleController.js index 6ab8aaca91..bd91a7368e 100644 --- a/src/app/organization/organizationPeopleController.js +++ b/src/app/organization/organizationPeopleController.js @@ -39,6 +39,21 @@ }); }; + $scope.edit = function (id) { + var modal = $uibModal.open({ + animation: true, + templateUrl: 'app/organization/views/organizationPeopleEdit.html', + controller: 'organizationPeopleEditController', + resolve: { + id: function () { return id; } + } + }); + + modal.result.then(function () { + loadList(); + }); + }; + function loadList() { apiService.organizationUsers.list({ orgId: $state.params.orgId }, function (list) { var users = []; diff --git a/src/app/organization/organizationPeopleEditController.js b/src/app/organization/organizationPeopleEditController.js new file mode 100644 index 0000000000..7cb971de84 --- /dev/null +++ b/src/app/organization/organizationPeopleEditController.js @@ -0,0 +1,90 @@ +angular + .module('bit.organization') + + .controller('organizationPeopleEditController', function ($scope, $state, $uibModalInstance, apiService, cipherService, id) { + $scope.loading = true; + $scope.selectedSubvaults = []; + $scope.selectedSubvaultsReadOnly = []; + + $uibModalInstance.opened.then(function () { + apiService.subvaults.listOrganization({ orgId: $state.params.orgId }, function (list) { + $scope.subvaults = cipherService.decryptSubvaults(list.Data, $state.params.orgId, true); + $scope.loading = false; + }); + + apiService.organizationUsers.get({ orgId: $state.params.orgId, id: id }, function (user) { + if (user && user.Subvaults) { + var subvaults = []; + var subvaultsReadOnly = []; + for (var i = 0; i < user.Subvaults.Data.length; i++) { + subvaults.push(user.Subvaults.Data[i].SubvaultId); + if (user.Subvaults.Data[i].ReadOnly) { + subvaultsReadOnly.push(user.Subvaults.Data[i].SubvaultId); + } + } + } + $scope.selectedSubvaults = subvaults; + $scope.selectedSubvaultsReadOnly = subvaultsReadOnly; + }); + }); + + $scope.toggleSubvaultSelectionAll = function ($event) { + var subvaultIds = []; + if ($event.target.checked) { + for (var i = 0; i < $scope.subvaults.length; i++) { + subvaultIds.push($scope.subvaults[i].id); + } + } + else { + $scope.selectedSubvaultsReadOnly = []; + } + + $scope.selectedSubvaults = subvaultIds; + }; + + $scope.toggleSubvaultSelection = function (id) { + var i = $scope.selectedSubvaults.indexOf(id); + if (i > -1) { + $scope.selectedSubvaults.splice(i, 1); + + var j = $scope.selectedSubvaultsReadOnly.indexOf(id); + if (j > -1) { + $scope.selectedSubvaultsReadOnly.splice(j, 1); + } + } + else { + $scope.selectedSubvaults.push(id); + } + }; + + $scope.toggleSubvaultReadOnlySelection = function (id) { + var i = $scope.selectedSubvaultsReadOnly.indexOf(id); + if (i > -1) { + $scope.selectedSubvaultsReadOnly.splice(i, 1); + } + else { + $scope.selectedSubvaultsReadOnly.push(id); + } + }; + + $scope.submit = function (model) { + var subvaults = []; + for (var i = 0; i < $scope.selectedSubvaults.length; i++) { + subvaults.push({ + id: null, + subvaultId: $scope.selectedSubvaults[i], + readOnly: $scope.selectedSubvaultsReadOnly.indexOf($scope.selectedSubvaults[i]) > -1 + }); + } + + apiService.organizationUsers.put({ orgId: $state.params.orgId, id: 0 }, { + subvaults: subvaults + }, function () { + $uibModalInstance.close(); + }); + }; + + $scope.close = function () { + $uibModalInstance.dismiss('cancel'); + }; + }); diff --git a/src/app/organization/organizationPeopleInviteController.js b/src/app/organization/organizationPeopleInviteController.js index 231cfdb586..35226b4fe3 100644 --- a/src/app/organization/organizationPeopleInviteController.js +++ b/src/app/organization/organizationPeopleInviteController.js @@ -1,9 +1,71 @@ angular .module('bit.organization') - .controller('organizationPeopleInviteController', function ($scope, $state, $uibModalInstance, apiService) { + .controller('organizationPeopleInviteController', function ($scope, $state, $uibModalInstance, apiService, cipherService) { + $scope.loading = true; + $scope.selectedSubvaults = []; + $scope.selectedSubvaultsReadOnly = []; + + $uibModalInstance.opened.then(function () { + apiService.subvaults.listOrganization({ orgId: $state.params.orgId }, function (list) { + $scope.subvaults = cipherService.decryptSubvaults(list.Data, $state.params.orgId, true); + $scope.loading = false; + }); + }); + + $scope.toggleSubvaultSelectionAll = function ($event) { + var subvaultIds = []; + if ($event.target.checked) + { + for (var i = 0; i < $scope.subvaults.length; i++) { + subvaultIds.push($scope.subvaults[i].id); + } + } + else { + $scope.selectedSubvaultsReadOnly = []; + } + + $scope.selectedSubvaults = subvaultIds; + }; + + $scope.toggleSubvaultSelection = function (id) { + var i = $scope.selectedSubvaults.indexOf(id); + if (i > -1) { + $scope.selectedSubvaults.splice(i, 1); + + var j = $scope.selectedSubvaultsReadOnly.indexOf(id); + if (j > -1) { + $scope.selectedSubvaultsReadOnly.splice(j, 1); + } + } + else { + $scope.selectedSubvaults.push(id); + } + }; + + $scope.toggleSubvaultReadOnlySelection = function (id) { + var i = $scope.selectedSubvaultsReadOnly.indexOf(id); + if (i > -1) { + $scope.selectedSubvaultsReadOnly.splice(i, 1); + } + else { + $scope.selectedSubvaultsReadOnly.push(id); + } + }; + $scope.submit = function (model) { - apiService.organizationUsers.invite({ orgId: $state.params.orgId }, { email: model.email }, function () { + var subvaults = []; + for (var i = 0; i < $scope.selectedSubvaults.length; i++) { + subvaults.push({ + subvaultId: $scope.selectedSubvaults[i], + readOnly: $scope.selectedSubvaultsReadOnly.indexOf($scope.selectedSubvaults[i]) > -1 + }); + } + + apiService.organizationUsers.invite({ orgId: $state.params.orgId }, { + email: model.email, + subvaults: subvaults + }, function () { $uibModalInstance.close(); }); }; diff --git a/src/app/organization/views/organizationPeople.html b/src/app/organization/views/organizationPeople.html index 3344e46b3c..77cc83487f 100644 --- a/src/app/organization/views/organizationPeople.html +++ b/src/app/organization/views/organizationPeople.html @@ -41,7 +41,7 @@ class="img-circle" alt="User Image"> - {{user.email}} + {{user.email}}
{{user.name}}
diff --git a/src/app/organization/views/organizationPeopleEdit.html b/src/app/organization/views/organizationPeopleEdit.html new file mode 100644 index 0000000000..1bb828c1cc --- /dev/null +++ b/src/app/organization/views/organizationPeopleEdit.html @@ -0,0 +1,58 @@ + +
+ + +
diff --git a/src/app/organization/views/organizationPeopleInvite.html b/src/app/organization/views/organizationPeopleInvite.html index 04ea9f0397..ae15c09be6 100644 --- a/src/app/organization/views/organizationPeopleInvite.html +++ b/src/app/organization/views/organizationPeopleInvite.html @@ -18,6 +18,50 @@ +

Subvault Access

+
+ Loading... +
+
+

No subvaults.

+
+
+ + + + + + + + + + + + + + + +
+ + NameRead Only
+ + + {{subvault.name}} + + +
+
- \ No newline at end of file diff --git a/src/index.html b/src/index.html index 0f366e4370..f4b8c189bf 100644 --- a/src/index.html +++ b/src/index.html @@ -124,6 +124,7 @@ +