diff --git a/src/Admin/Controllers/OrganizationsController.cs b/src/Admin/Controllers/OrganizationsController.cs index 63e981f1a4..17029f8d26 100644 --- a/src/Admin/Controllers/OrganizationsController.cs +++ b/src/Admin/Controllers/OrganizationsController.cs @@ -17,6 +17,10 @@ namespace Bit.Admin.Controllers { private readonly IOrganizationRepository _organizationRepository; private readonly IOrganizationUserRepository _organizationUserRepository; + private readonly ICipherRepository _cipherRepository; + private readonly ICollectionRepository _collectionRepository; + private readonly IGroupRepository _groupRepository; + private readonly IPolicyRepository _policyRepository; private readonly IPaymentService _paymentService; private readonly IApplicationCacheService _applicationCacheService; private readonly GlobalSettings _globalSettings; @@ -24,12 +28,20 @@ namespace Bit.Admin.Controllers public OrganizationsController( IOrganizationRepository organizationRepository, IOrganizationUserRepository organizationUserRepository, + ICipherRepository cipherRepository, + ICollectionRepository collectionRepository, + IGroupRepository groupRepository, + IPolicyRepository policyRepository, IPaymentService paymentService, IApplicationCacheService applicationCacheService, GlobalSettings globalSettings) { _organizationRepository = organizationRepository; _organizationUserRepository = organizationUserRepository; + _cipherRepository = cipherRepository; + _collectionRepository = collectionRepository; + _groupRepository = groupRepository; + _policyRepository = policyRepository; _paymentService = paymentService; _applicationCacheService = applicationCacheService; _globalSettings = globalSettings; @@ -71,8 +83,20 @@ namespace Bit.Admin.Controllers return RedirectToAction("Index"); } + var ciphers = await _cipherRepository.GetManyByOrganizationIdAsync(id); + var collections = await _collectionRepository.GetManyByOrganizationIdAsync(id); + IEnumerable groups = null; + if(organization.UseGroups) + { + groups = await _groupRepository.GetManyByOrganizationIdAsync(id); + } + IEnumerable policies = null; + if(organization.UsePolicies) + { + policies = await _policyRepository.GetManyByOrganizationIdAsync(id); + } var users = await _organizationUserRepository.GetManyDetailsByOrganizationAsync(id); - return View(new OrganizationViewModel(organization, users)); + return View(new OrganizationViewModel(organization, users, ciphers, collections, groups, policies)); } [SelfHosted(NotSelfHostedOnly = true)] @@ -84,9 +108,22 @@ namespace Bit.Admin.Controllers return RedirectToAction("Index"); } + var ciphers = await _cipherRepository.GetManyByOrganizationIdAsync(id); + var collections = await _collectionRepository.GetManyByOrganizationIdAsync(id); + IEnumerable groups = null; + if(organization.UseGroups) + { + groups = await _groupRepository.GetManyByOrganizationIdAsync(id); + } + IEnumerable policies = null; + if(organization.UsePolicies) + { + policies = await _policyRepository.GetManyByOrganizationIdAsync(id); + } var users = await _organizationUserRepository.GetManyDetailsByOrganizationAsync(id); var billingInfo = await _paymentService.GetBillingAsync(organization); - return View(new OrganizationEditModel(organization, users, billingInfo, _globalSettings)); + return View(new OrganizationEditModel(organization, users, ciphers, collections, groups, policies, + billingInfo, _globalSettings)); } [HttpPost] diff --git a/src/Admin/Models/OrganizationEditModel.cs b/src/Admin/Models/OrganizationEditModel.cs index af3671f3fe..25c3dbe345 100644 --- a/src/Admin/Models/OrganizationEditModel.cs +++ b/src/Admin/Models/OrganizationEditModel.cs @@ -15,8 +15,9 @@ namespace Bit.Admin.Models public OrganizationEditModel() { } public OrganizationEditModel(Organization org, IEnumerable orgUsers, - BillingInfo billingInfo, GlobalSettings globalSettings) - : base(org, orgUsers) + IEnumerable ciphers, IEnumerable collections, IEnumerable groups, + IEnumerable policies, BillingInfo billingInfo, GlobalSettings globalSettings) + : base(org, orgUsers, ciphers, collections, groups, policies) { BillingInfo = billingInfo; BraintreeMerchantId = globalSettings.Braintree.MerchantId; diff --git a/src/Admin/Models/OrganizationViewModel.cs b/src/Admin/Models/OrganizationViewModel.cs index 9b17b113d9..625cdbee1d 100644 --- a/src/Admin/Models/OrganizationViewModel.cs +++ b/src/Admin/Models/OrganizationViewModel.cs @@ -11,10 +11,16 @@ namespace Bit.Admin.Models { public OrganizationViewModel() { } - public OrganizationViewModel(Organization org, IEnumerable orgUsers) + public OrganizationViewModel(Organization org, IEnumerable orgUsers, + IEnumerable ciphers, IEnumerable collections, IEnumerable groups, + IEnumerable policies) { Organization = org; UserCount = orgUsers.Count(); + CipherCount = ciphers.Count(); + CollectionCount = collections.Count(); + GroupCount = groups?.Count() ?? 0; + PolicyCount = policies?.Count() ?? 0; Owners = string.Join(", ", orgUsers .Where(u => u.Type == OrganizationUserType.Owner && u.Status == OrganizationUserStatusType.Confirmed) @@ -29,5 +35,9 @@ namespace Bit.Admin.Models public string Owners { get; set; } public string Admins { get; set; } public int UserCount { get; set; } + public int CipherCount { get; set; } + public int CollectionCount { get; set; } + public int GroupCount { get; set; } + public int PolicyCount { get; set; } } } diff --git a/src/Admin/Views/Organizations/_ViewInformation.cshtml b/src/Admin/Views/Organizations/_ViewInformation.cshtml index 9a14108152..ab2ff3b15c 100644 --- a/src/Admin/Views/Organizations/_ViewInformation.cshtml +++ b/src/Admin/Views/Organizations/_ViewInformation.cshtml @@ -21,6 +21,18 @@
Using 2FA
@(Model.Organization.TwoFactorIsEnabled() ? "Yes" : "No")
+
Items
+
@Model.CipherCount
+ +
Collections
+
@Model.CollectionCount
+ +
Groups
+
@Model.GroupCount
+ +
Policies
+
@Model.PolicyCount
+
Created
@Model.Organization.CreationDate.ToString()