diff --git a/corehq/apps/enterprise/api/api.py b/corehq/apps/enterprise/api/api.py index a0c8508b5e54..06b3c6f82139 100644 --- a/corehq/apps/enterprise/api/api.py +++ b/corehq/apps/enterprise/api/api.py @@ -10,7 +10,7 @@ WebUserResource, DataExportReportResource, SMSResource, - APIUsageResource, + APIKeysResource, TwoFactorAuthResource, ) @@ -24,5 +24,5 @@ v1_api.register(DataExportReportResource()) v1_api.register(CommCareVersionComplianceResource()) v1_api.register(SMSResource()) -v1_api.register(APIUsageResource()) +v1_api.register(APIKeysResource()) v1_api.register(TwoFactorAuthResource()) diff --git a/corehq/apps/enterprise/api/resources.py b/corehq/apps/enterprise/api/resources.py index 52efe902633d..650f30b99287 100644 --- a/corehq/apps/enterprise/api/resources.py +++ b/corehq/apps/enterprise/api/resources.py @@ -500,7 +500,7 @@ def get_primary_keys(self): return ('mobile_worker', 'domain',) -class APIUsageResource(ODataEnterpriseReportResource): +class APIKeysResource(ODataEnterpriseReportResource): web_user = fields.CharField() api_key_name = fields.CharField() scope = fields.CharField() @@ -508,7 +508,7 @@ class APIUsageResource(ODataEnterpriseReportResource): created_date = fields.DateTimeField() last_used_date = fields.DateTimeField() - REPORT_SLUG = EnterpriseReport.API_USAGE + REPORT_SLUG = EnterpriseReport.API_KEYS def dehydrate(self, bundle): bundle.data['web_user'] = bundle.obj[0] diff --git a/corehq/apps/enterprise/enterprise.py b/corehq/apps/enterprise/enterprise.py index 1864d2238a83..f25555186453 100644 --- a/corehq/apps/enterprise/enterprise.py +++ b/corehq/apps/enterprise/enterprise.py @@ -58,7 +58,7 @@ class EnterpriseReport(ABC): DATA_EXPORTS = 'data_exports' COMMCARE_VERSION_COMPLIANCE = 'commcare_version_compliance' SMS = 'sms' - API_USAGE = 'api_usage' + API_KEYS = 'api_keys' TWO_FACTOR_AUTH = '2fa' DATE_ROW_FORMAT = '%Y/%m/%d %H:%M:%S' @@ -69,12 +69,11 @@ def title(self): pass @property - @abstractmethod def total_description(self): """ To provide a description of the total number we displayed in tile """ - pass + return '' def __init__(self, account, couch_user, **kwargs): self.account = account @@ -111,7 +110,7 @@ def create(cls, slug, account_id, couch_user, **kwargs): report = EnterpriseCommCareVersionReport(account, couch_user, **kwargs) elif slug == cls.SMS: report = EnterpriseSMSReport(account, couch_user, **kwargs) - elif slug == cls.API_USAGE: + elif slug == cls.API_KEYS: report = EnterpriseAPIReport(account, couch_user, **kwargs) elif slug == cls.TWO_FACTOR_AUTH: report = Enterprise2FAReport(account, couch_user, **kwargs) @@ -160,7 +159,6 @@ def total(self): class EnterpriseDomainReport(EnterpriseReport): title = gettext_lazy('Project Spaces') - total_description = gettext_lazy('# of Project Spaces') def __init__(self, account, couch_user): super().__init__(account, couch_user) @@ -192,7 +190,6 @@ def total_for_domain(self, domain_obj): class EnterpriseWebUserReport(EnterpriseReport): title = gettext_lazy('Web Users') - total_description = gettext_lazy('# of Web Users') @property def headers(self): @@ -239,7 +236,6 @@ def total_for_domain(self, domain_obj): class EnterpriseMobileWorkerReport(EnterpriseReport): title = gettext_lazy('Mobile Workers') - total_description = gettext_lazy('# of Mobile Workers') @property def headers(self): @@ -271,7 +267,6 @@ def total_for_domain(self, domain_obj): class EnterpriseFormReport(EnterpriseReport): title = gettext_lazy('Mobile Form Submissions') - total_description = gettext_lazy('# of Mobile Form Submissions') MAXIMUM_USERS_PER_DOMAIN = getattr(settings, 'ENTERPRISE_REPORT_DOMAIN_USER_LIMIT', 20_000) MAXIMUM_ROWS_PER_REQUEST = getattr(settings, 'ENTERPRISE_REPORT_ROW_LIMIT', 1_000_000) @@ -380,7 +375,6 @@ def total_for_domain(self, domain_obj): class EnterpriseODataReport(EnterpriseReport): title = gettext_lazy('OData Feeds') - total_description = gettext_lazy('# of OData Feeds') MAXIMUM_EXPECTED_EXPORTS = 150 @@ -476,7 +470,6 @@ def app_query(self, domain): class EnterpriseDataExportReport(EnterpriseReport): title = gettext_lazy('Data Exports') - total_description = gettext_lazy('# of Exports') @property def headers(self): @@ -685,8 +678,7 @@ def rows_for_domain(self, domain_obj): class EnterpriseAPIReport(EnterpriseReport): - title = gettext_lazy('API Usage') - total_description = gettext_lazy('# of Active API Keys') + title = gettext_lazy('API Keys') @property def headers(self): diff --git a/corehq/apps/enterprise/static/enterprise/js/project_dashboard.js b/corehq/apps/enterprise/static/enterprise/js/project_dashboard.js index 048da6ca2c26..a12d27097066 100644 --- a/corehq/apps/enterprise/static/enterprise/js/project_dashboard.js +++ b/corehq/apps/enterprise/static/enterprise/js/project_dashboard.js @@ -225,11 +225,13 @@ hqDefine("enterprise/js/project_dashboard", [ function updateDisplayTotal($element, kwargs) { const $display = $element.find(".js-total"); + const $helpTotal = $element.find(".help-total"); const slug = $element.data("slug"); const requestParams = { url: initialPageData.reverse("enterprise_dashboard_total", slug), success: function (data) { $display.html(localizeNumberlikeString(data.total)); + $helpTotal.removeClass("d-none"); }, error: function (request) { if (request.responseJSON) { @@ -238,10 +240,12 @@ hqDefine("enterprise/js/project_dashboard", [ alertUser.alert_user(gettext("Error updating display total, please try again or report an issue if this persists."), "danger"); } $display.html(gettext("??")); + $helpTotal.addClass("d-none"); }, data: kwargs, }; $display.html(''); + $helpTotal.addClass("d-none"); $.ajax(requestParams); } diff --git a/corehq/apps/enterprise/templates/enterprise/partials/project_tile.html b/corehq/apps/enterprise/templates/enterprise/partials/project_tile.html index 49b7e6f201d6..49fbde957902 100644 --- a/corehq/apps/enterprise/templates/enterprise/partials/project_tile.html +++ b/corehq/apps/enterprise/templates/enterprise/partials/project_tile.html @@ -1,34 +1,52 @@ {% load i18n %}