From b6e83424665cbb9107174472ca273181a97eff54 Mon Sep 17 00:00:00 2001 From: Jens L Date: Tue, 18 Jul 2023 23:24:44 +0200 Subject: [PATCH] enterprise: add more info to enterprise forecast (#6292) * add more info to enterprise forecast Signed-off-by: Jens Langhammer * fix banner colour Signed-off-by: Jens Langhammer * fix some layout Signed-off-by: Jens Langhammer * fix layout for warning banner Signed-off-by: Jens Langhammer --------- Signed-off-by: Jens Langhammer --- authentik/enterprise/api.py | 8 +- schema.yml | 6 + web/src/admin/AdminInterface.ts | 13 +-- .../enterprise/EnterpriseLicenseListPage.ts | 16 ++- web/src/elements/PageHeader.ts | 105 +++++++++--------- .../enterprise/EnterpriseStatusBanner.ts | 2 +- web/src/user/UserInterface.ts | 6 + 7 files changed, 85 insertions(+), 71 deletions(-) diff --git a/authentik/enterprise/api.py b/authentik/enterprise/api.py index d10d5296d..2f29832a2 100644 --- a/authentik/enterprise/api.py +++ b/authentik/enterprise/api.py @@ -64,6 +64,8 @@ class LicenseForecastSerializer(PassiveSerializer): users = IntegerField(required=True) external_users = IntegerField(required=True) + forecasted_users = IntegerField(required=True) + forecasted_external_users = IntegerField(required=True) class LicenseViewSet(UsedByMixin, ModelViewSet): @@ -142,8 +144,10 @@ class LicenseViewSet(UsedByMixin, ModelViewSet): forecast_for_months = 12 response = LicenseForecastSerializer( data={ - "users": users_in_last_month * forecast_for_months, - "external_users": external_in_last_month * forecast_for_months, + "users": LicenseKey.get_default_user_count(), + "external_users": LicenseKey.get_external_user_count(), + "forecasted_users": (users_in_last_month * forecast_for_months), + "forecasted_external_users": (external_in_last_month * forecast_for_months), } ) response.is_valid(raise_exception=True) diff --git a/schema.yml b/schema.yml index d5d9c5158..15f06c636 100644 --- a/schema.yml +++ b/schema.yml @@ -31746,8 +31746,14 @@ components: type: integer external_users: type: integer + forecasted_users: + type: integer + forecasted_external_users: + type: integer required: - external_users + - forecasted_external_users + - forecasted_users - users LicenseRequest: type: object diff --git a/web/src/admin/AdminInterface.ts b/web/src/admin/AdminInterface.ts index c59809c13..9fd6db2eb 100644 --- a/web/src/admin/AdminInterface.ts +++ b/web/src/admin/AdminInterface.ts @@ -75,17 +75,7 @@ export class AdminInterface extends Interface { .display-none { display: none; } - :host { - display: flex; - flex-direction: column; - height: 100%; - } - ak-locale-context { - display: flex; - flex-grow: 1; - } .pf-c-page { - flex-grow: 1; background-color: var(--pf-c-page--BackgroundColor) !important; } /* Global page background colour */ @@ -130,8 +120,7 @@ export class AdminInterface extends Interface { } render(): TemplateResult { - return html` + return html`
{ class="pf-l-grid__item" icon="pf-icon pf-icon-user" header=${msg("Forecast default users")} - subtext=${msg("Estimated user count one year from now")} + subtext=${msg( + str`Estimated user count one year from now based on ${this.forecast?.users} current users and ${this.forecast?.forecastedUsers} forecasted users.`, + )} > - ~ ${this.forecast?.users} + ~ ${(this.forecast?.users || 0) + + (this.forecast?.forecastedUsers || 0)} - ~ ${this.forecast?.externalUsers} + ~ ${(this.forecast?.externalUsers || 0) + + (this.forecast?.forecastedExternalUsers || 0)} { - this.dispatchEvent( - new CustomEvent(EVENT_SIDEBAR_TOGGLE, { - bubbles: true, - composed: true, - }), - ); - }} - > - - -
-
-

- ${this.renderIcon()} - ${this.header} -

- ${this.description ? html`

${this.description}

` : html``} -
-
- - `; + return html` +
+ +
+
+

+ ${this.renderIcon()} + ${this.header} +

+ ${this.description ? html`

${this.description}

` : html``} +
+
+ + +
`; } } diff --git a/web/src/elements/enterprise/EnterpriseStatusBanner.ts b/web/src/elements/enterprise/EnterpriseStatusBanner.ts index fddf29990..0ac115457 100644 --- a/web/src/elements/enterprise/EnterpriseStatusBanner.ts +++ b/web/src/elements/enterprise/EnterpriseStatusBanner.ts @@ -28,7 +28,7 @@ export class EnterpriseStatusBanner extends AKElement { } renderBanner(): TemplateResult { - return html`
+ return html`
${msg("Warning: The current user count has exceeded the configured licenses.")} ${msg("Click here for more info.")}
`; diff --git a/web/src/user/UserInterface.ts b/web/src/user/UserInterface.ts index 8986bc8c2..4d1857708 100644 --- a/web/src/user/UserInterface.ts +++ b/web/src/user/UserInterface.ts @@ -94,6 +94,12 @@ export class UserInterface extends Interface { width: 100vw; position: absolute; z-index: -1; + top: 0; + left: 0; + } + ak-locale-context { + display: flex; + flex-direction: column; } `, ];