mirror of
https://github.com/bitwarden/server.git
synced 2025-04-05 05:00:19 -05:00
Add additional meta data to org view (#655)
* Add additional meta data to org view * null check policies and groups
This commit is contained in:
parent
927f073362
commit
5b598b811e
@ -17,6 +17,10 @@ namespace Bit.Admin.Controllers
|
|||||||
{
|
{
|
||||||
private readonly IOrganizationRepository _organizationRepository;
|
private readonly IOrganizationRepository _organizationRepository;
|
||||||
private readonly IOrganizationUserRepository _organizationUserRepository;
|
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 IPaymentService _paymentService;
|
||||||
private readonly IApplicationCacheService _applicationCacheService;
|
private readonly IApplicationCacheService _applicationCacheService;
|
||||||
private readonly GlobalSettings _globalSettings;
|
private readonly GlobalSettings _globalSettings;
|
||||||
@ -24,12 +28,20 @@ namespace Bit.Admin.Controllers
|
|||||||
public OrganizationsController(
|
public OrganizationsController(
|
||||||
IOrganizationRepository organizationRepository,
|
IOrganizationRepository organizationRepository,
|
||||||
IOrganizationUserRepository organizationUserRepository,
|
IOrganizationUserRepository organizationUserRepository,
|
||||||
|
ICipherRepository cipherRepository,
|
||||||
|
ICollectionRepository collectionRepository,
|
||||||
|
IGroupRepository groupRepository,
|
||||||
|
IPolicyRepository policyRepository,
|
||||||
IPaymentService paymentService,
|
IPaymentService paymentService,
|
||||||
IApplicationCacheService applicationCacheService,
|
IApplicationCacheService applicationCacheService,
|
||||||
GlobalSettings globalSettings)
|
GlobalSettings globalSettings)
|
||||||
{
|
{
|
||||||
_organizationRepository = organizationRepository;
|
_organizationRepository = organizationRepository;
|
||||||
_organizationUserRepository = organizationUserRepository;
|
_organizationUserRepository = organizationUserRepository;
|
||||||
|
_cipherRepository = cipherRepository;
|
||||||
|
_collectionRepository = collectionRepository;
|
||||||
|
_groupRepository = groupRepository;
|
||||||
|
_policyRepository = policyRepository;
|
||||||
_paymentService = paymentService;
|
_paymentService = paymentService;
|
||||||
_applicationCacheService = applicationCacheService;
|
_applicationCacheService = applicationCacheService;
|
||||||
_globalSettings = globalSettings;
|
_globalSettings = globalSettings;
|
||||||
@ -71,8 +83,20 @@ namespace Bit.Admin.Controllers
|
|||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var ciphers = await _cipherRepository.GetManyByOrganizationIdAsync(id);
|
||||||
|
var collections = await _collectionRepository.GetManyByOrganizationIdAsync(id);
|
||||||
|
IEnumerable<Group> groups = null;
|
||||||
|
if(organization.UseGroups)
|
||||||
|
{
|
||||||
|
groups = await _groupRepository.GetManyByOrganizationIdAsync(id);
|
||||||
|
}
|
||||||
|
IEnumerable<Policy> policies = null;
|
||||||
|
if(organization.UsePolicies)
|
||||||
|
{
|
||||||
|
policies = await _policyRepository.GetManyByOrganizationIdAsync(id);
|
||||||
|
}
|
||||||
var users = await _organizationUserRepository.GetManyDetailsByOrganizationAsync(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)]
|
[SelfHosted(NotSelfHostedOnly = true)]
|
||||||
@ -84,9 +108,22 @@ namespace Bit.Admin.Controllers
|
|||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var ciphers = await _cipherRepository.GetManyByOrganizationIdAsync(id);
|
||||||
|
var collections = await _collectionRepository.GetManyByOrganizationIdAsync(id);
|
||||||
|
IEnumerable<Group> groups = null;
|
||||||
|
if(organization.UseGroups)
|
||||||
|
{
|
||||||
|
groups = await _groupRepository.GetManyByOrganizationIdAsync(id);
|
||||||
|
}
|
||||||
|
IEnumerable<Policy> policies = null;
|
||||||
|
if(organization.UsePolicies)
|
||||||
|
{
|
||||||
|
policies = await _policyRepository.GetManyByOrganizationIdAsync(id);
|
||||||
|
}
|
||||||
var users = await _organizationUserRepository.GetManyDetailsByOrganizationAsync(id);
|
var users = await _organizationUserRepository.GetManyDetailsByOrganizationAsync(id);
|
||||||
var billingInfo = await _paymentService.GetBillingAsync(organization);
|
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]
|
[HttpPost]
|
||||||
|
@ -15,8 +15,9 @@ namespace Bit.Admin.Models
|
|||||||
public OrganizationEditModel() { }
|
public OrganizationEditModel() { }
|
||||||
|
|
||||||
public OrganizationEditModel(Organization org, IEnumerable<OrganizationUserUserDetails> orgUsers,
|
public OrganizationEditModel(Organization org, IEnumerable<OrganizationUserUserDetails> orgUsers,
|
||||||
BillingInfo billingInfo, GlobalSettings globalSettings)
|
IEnumerable<Cipher> ciphers, IEnumerable<Collection> collections, IEnumerable<Group> groups,
|
||||||
: base(org, orgUsers)
|
IEnumerable<Policy> policies, BillingInfo billingInfo, GlobalSettings globalSettings)
|
||||||
|
: base(org, orgUsers, ciphers, collections, groups, policies)
|
||||||
{
|
{
|
||||||
BillingInfo = billingInfo;
|
BillingInfo = billingInfo;
|
||||||
BraintreeMerchantId = globalSettings.Braintree.MerchantId;
|
BraintreeMerchantId = globalSettings.Braintree.MerchantId;
|
||||||
|
@ -11,10 +11,16 @@ namespace Bit.Admin.Models
|
|||||||
{
|
{
|
||||||
public OrganizationViewModel() { }
|
public OrganizationViewModel() { }
|
||||||
|
|
||||||
public OrganizationViewModel(Organization org, IEnumerable<OrganizationUserUserDetails> orgUsers)
|
public OrganizationViewModel(Organization org, IEnumerable<OrganizationUserUserDetails> orgUsers,
|
||||||
|
IEnumerable<Cipher> ciphers, IEnumerable<Collection> collections, IEnumerable<Group> groups,
|
||||||
|
IEnumerable<Policy> policies)
|
||||||
{
|
{
|
||||||
Organization = org;
|
Organization = org;
|
||||||
UserCount = orgUsers.Count();
|
UserCount = orgUsers.Count();
|
||||||
|
CipherCount = ciphers.Count();
|
||||||
|
CollectionCount = collections.Count();
|
||||||
|
GroupCount = groups?.Count() ?? 0;
|
||||||
|
PolicyCount = policies?.Count() ?? 0;
|
||||||
Owners = string.Join(", ",
|
Owners = string.Join(", ",
|
||||||
orgUsers
|
orgUsers
|
||||||
.Where(u => u.Type == OrganizationUserType.Owner && u.Status == OrganizationUserStatusType.Confirmed)
|
.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 Owners { get; set; }
|
||||||
public string Admins { get; set; }
|
public string Admins { get; set; }
|
||||||
public int UserCount { 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; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,18 @@
|
|||||||
<dt class="col-sm-4 col-lg-3">Using 2FA</dt>
|
<dt class="col-sm-4 col-lg-3">Using 2FA</dt>
|
||||||
<dd class="col-sm-8 col-lg-9">@(Model.Organization.TwoFactorIsEnabled() ? "Yes" : "No")</dd>
|
<dd class="col-sm-8 col-lg-9">@(Model.Organization.TwoFactorIsEnabled() ? "Yes" : "No")</dd>
|
||||||
|
|
||||||
|
<dt class="col-sm-4 col-lg-3">Items</dt>
|
||||||
|
<dd class="col-sm-8 col-lg-9">@Model.CipherCount</dd>
|
||||||
|
|
||||||
|
<dt class="col-sm-4 col-lg-3">Collections</dt>
|
||||||
|
<dd class="col-sm-8 col-lg-9">@Model.CollectionCount</dd>
|
||||||
|
|
||||||
|
<dt class="col-sm-4 col-lg-3">Groups</dt>
|
||||||
|
<dd class="col-sm-8 col-lg-9">@Model.GroupCount</dd>
|
||||||
|
|
||||||
|
<dt class="col-sm-4 col-lg-3">Policies</dt>
|
||||||
|
<dd class="col-sm-8 col-lg-9">@Model.PolicyCount</dd>
|
||||||
|
|
||||||
<dt class="col-sm-4 col-lg-3">Created</dt>
|
<dt class="col-sm-4 col-lg-3">Created</dt>
|
||||||
<dd class="col-sm-8 col-lg-9">@Model.Organization.CreationDate.ToString()</dd>
|
<dd class="col-sm-8 col-lg-9">@Model.Organization.CreationDate.ToString()</dd>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user