From f1e3dcfdce30aed3ac472c14450860bef5b016ae Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Tue, 24 Nov 2026 16:36:31 +0200 Subject: [PATCH] feat: the system administrator Home License card: the plan band (subscription, perpetual, Community Grant, Development) with the next charge or support date, Manage license and the license info refreshed from the header; devices and assets, installations (production instances, edges, remote agents) and AI credits as on License management, amber near the limit and red at it, with the row's add or upgrade action; add-ons as License management decides them, the Professional Pack offer on a Community Grant and Go to production on Development; the license purchase and upgrade actions and the hand-off dialog shared with License management; Install's features listed as pending while they load --- .../home/components/home-components.module.ts | 3 + .../license/license-actions.service.ts | 117 ++++ .../license-hand-off-dialog.component.html | 0 .../license-hand-off-dialog.component.scss | 0 .../license-hand-off-dialog.component.ts | 0 .../modules/home/pages/admin/admin.module.ts | 4 +- .../admin/license-management.component.ts | 154 +---- .../install-items-home.component.html | 12 +- .../install-items-home.component.scss | 20 + .../install-items-home.component.ts | 7 +- .../components/license-home.component.html | 166 ++++++ .../components/license-home.component.scss | 546 ++++++++++++++++++ .../components/license-home.component.ts | 318 +++++++++- .../home/pages/home-page/home-cards.models.ts | 2 +- .../assets/locale/locale.constant-en_US.json | 18 + 15 files changed, 1212 insertions(+), 155 deletions(-) create mode 100644 ui-ngx/src/app/modules/home/components/license/license-actions.service.ts rename ui-ngx/src/app/modules/home/{pages/admin => components/license}/license-hand-off-dialog.component.html (100%) rename ui-ngx/src/app/modules/home/{pages/admin => components/license}/license-hand-off-dialog.component.scss (100%) rename ui-ngx/src/app/modules/home/{pages/admin => components/license}/license-hand-off-dialog.component.ts (100%) create mode 100644 ui-ngx/src/app/modules/home/pages/home-page/components/license-home.component.html create mode 100644 ui-ngx/src/app/modules/home/pages/home-page/components/license-home.component.scss diff --git a/ui-ngx/src/app/modules/home/components/home-components.module.ts b/ui-ngx/src/app/modules/home/components/home-components.module.ts index 6ac875c08d..40f059f06d 100644 --- a/ui-ngx/src/app/modules/home/components/home-components.module.ts +++ b/ui-ngx/src/app/modules/home/components/home-components.module.ts @@ -273,10 +273,12 @@ import { } from '@home/components/converter/converter-library-model-autocomplete.component'; import { AiModule } from '@home/components/ai/ai.module'; import { RequestPePackComponent } from '@home/components/pe-pack/request-pe-pack.component'; +import { LicenseHandOffDialogComponent } from '@home/components/license/license-hand-off-dialog.component'; @NgModule({ declarations: [ + LicenseHandOffDialogComponent, RouterTabsComponent, EntitiesTableComponent, AddEntityDialogComponent, @@ -488,6 +490,7 @@ import { RequestPePackComponent } from '@home/components/pe-pack/request-pe-pack AiModule, ], exports: [ + LicenseHandOffDialogComponent, SharedHomeComponentsModule, RouterTabsComponent, EntitiesTableComponent, diff --git a/ui-ngx/src/app/modules/home/components/license/license-actions.service.ts b/ui-ngx/src/app/modules/home/components/license/license-actions.service.ts new file mode 100644 index 0000000000..df22b413c5 --- /dev/null +++ b/ui-ngx/src/app/modules/home/components/license/license-actions.service.ts @@ -0,0 +1,117 @@ +// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc. +// SPDX-License-Identifier: BUSL-1.1 +import { inject, Injectable } from '@angular/core'; +import { MatDialog } from '@angular/material/dialog'; +import { select, Store } from '@ngrx/store'; +import { take } from 'rxjs/operators'; +import { AppState } from '@core/core.state'; +import { selectUserSettingsProperty } from '@core/auth/auth.selectors'; +import { AddonType, createManageSubscriptionUrl, PlanUiType, SubscriptionInfo, UsageItemType } from '@shared/models/subscription.models'; +import { + LicenseHandOffCase, + LicenseHandOffDialogComponent, + LicenseHandOffDialogData +} from '@home/components/license/license-hand-off-dialog.component'; + +const LIMIT_WARN = 0.85; + +const ADD_ITEMS: Partial>> = { + [UsageItemType.DEVICES]: {extraDeviceCount: 100}, + [UsageItemType.EDGES]: {extraEdgeCount: 1}, + [UsageItemType.PROD_INSTANCES]: {extraInstanceCount: 1}, + [UsageItemType.AI_CREDITS]: {extraAiCreditsCount: 5}, + [UsageItemType.AGENTS]: {extraAgentCount: 1} +}; + +const ADD_ADDONS: Partial>> = { + [AddonType.EDGE]: {edgeEnabled: true}, + [AddonType.TRENDZ]: {trendzEnabled: true}, + [AddonType.PROFESSIONAL_UPGRADE]: {professionalUpgradeEnabled: true} +}; + +export const licenseLimitWarn = (count: number, max: number): boolean => !!count && !!max && count / max >= LIMIT_WARN; + +export const licenseLimitCritical = (count: number, max: number): boolean => !!count && !!max && count >= max; + +export const licenseMeterWidth = (count: number, max: number): number => count > 0 && max > 0 ? Math.min(count / max, 1) * 100 : 0; + +@Injectable({ + providedIn: 'root' +}) +export class LicenseActionsService { + + private store = inject(Store); + private dialog = inject(MatDialog); + + manageLicense(info: SubscriptionInfo): void { + this.openPortal(info, LicenseHandOffCase.MANAGE_LICENSE, null, null, createManageSubscriptionUrl(info)); + } + + addItems(info: SubscriptionInfo, itemType: UsageItemType): void { + const items = ADD_ITEMS[itemType]; + if (items) { + this.openPortal(info, LicenseHandOffCase.ADD_ITEMS, itemType, null, createManageSubscriptionUrl(info, items)); + } + } + + addAddOn(info: SubscriptionInfo, addonType: AddonType): void { + const items = ADD_ADDONS[addonType]; + if (items) { + this.openPortal(info, LicenseHandOffCase.ADD_ADDON, null, addonType, createManageSubscriptionUrl(info, items)); + } + } + + upgradePlanForItems(info: SubscriptionInfo, itemType: UsageItemType): void { + let targetPlan = PlanUiType.TbPilot; + if (itemType === UsageItemType.DEVICES) { + switch (info.planUiType) { + case PlanUiType.TbCommercialSmall: + targetPlan = PlanUiType.TbPilot; + break; + case PlanUiType.TbPilot: + targetPlan = PlanUiType.TbStartup; + break; + default: + targetPlan = PlanUiType.TbBusiness; + } + } + this.upgradePlan(info, itemType, null, targetPlan); + } + + upgradePlanForAddon(info: SubscriptionInfo, addonType: AddonType): void { + this.upgradePlan(info, null, addonType, PlanUiType.TbPilot); + } + + private upgradePlan(info: SubscriptionInfo, itemType: UsageItemType, addonType: AddonType, targetPlan: PlanUiType): void { + const url = `${info.licenseServerEndpoint}/?changeSubscriptionPlan=true&subscriptionId=${info.subscriptionId}&planUiType=${targetPlan}`; + this.openPortal(info, itemType ? LicenseHandOffCase.UPGRADE_PLAN_FOR_ITEMS : LicenseHandOffCase.UPGRADE_PLAN_FOR_ADDON, + itemType, addonType, url); + } + + private openPortal(info: SubscriptionInfo, handOffCase: LicenseHandOffCase, itemType: UsageItemType, addonType: AddonType, + url: string): void { + this.store.pipe(select(selectUserSettingsProperty('notDisplayLicenseHandOff')), take(1)).subscribe((skipDialog: boolean) => { + if (skipDialog) { + window.open(url, '_blank'); + return; + } + this.dialog.open(LicenseHandOffDialogComponent, { + disableClose: true, + autoFocus: false, + panelClass: ['tb-dialog', 'tb-fullscreen-dialog'], + data: { + case: handOffCase, + isPerpetual: info.perpetual, + isCeGrant: info.communityGrantLicense, + itemType, + addonType, + planName: info.subscriptionPlanName + } + }).afterClosed().subscribe(result => { + if (result) { + window.open(url, '_blank'); + } + }); + }); + } +} diff --git a/ui-ngx/src/app/modules/home/pages/admin/license-hand-off-dialog.component.html b/ui-ngx/src/app/modules/home/components/license/license-hand-off-dialog.component.html similarity index 100% rename from ui-ngx/src/app/modules/home/pages/admin/license-hand-off-dialog.component.html rename to ui-ngx/src/app/modules/home/components/license/license-hand-off-dialog.component.html diff --git a/ui-ngx/src/app/modules/home/pages/admin/license-hand-off-dialog.component.scss b/ui-ngx/src/app/modules/home/components/license/license-hand-off-dialog.component.scss similarity index 100% rename from ui-ngx/src/app/modules/home/pages/admin/license-hand-off-dialog.component.scss rename to ui-ngx/src/app/modules/home/components/license/license-hand-off-dialog.component.scss diff --git a/ui-ngx/src/app/modules/home/pages/admin/license-hand-off-dialog.component.ts b/ui-ngx/src/app/modules/home/components/license/license-hand-off-dialog.component.ts similarity index 100% rename from ui-ngx/src/app/modules/home/pages/admin/license-hand-off-dialog.component.ts rename to ui-ngx/src/app/modules/home/components/license/license-hand-off-dialog.component.ts diff --git a/ui-ngx/src/app/modules/home/pages/admin/admin.module.ts b/ui-ngx/src/app/modules/home/pages/admin/admin.module.ts index 1639308414..ed721017e1 100644 --- a/ui-ngx/src/app/modules/home/pages/admin/admin.module.ts +++ b/ui-ngx/src/app/modules/home/pages/admin/admin.module.ts @@ -32,7 +32,6 @@ import { NgxFlowModule } from '@flowjs/ngx-flow'; import { ResourceLibraryTabsComponent } from '@home/pages/admin/resource/resource-library-tabs.component'; import { LicenseManagementComponent } from '@home/pages/admin/license-management.component'; import { AddLicenseItemDialogComponent } from '@home/pages/admin/add-license-item-dialog.component'; -import { LicenseHandOffDialogComponent } from '@home/pages/admin/license-hand-off-dialog.component'; @NgModule({ declarations: @@ -60,8 +59,7 @@ import { LicenseHandOffDialogComponent } from '@home/pages/admin/license-hand-of AutoCommitAdminSettingsComponent, TwoFactorAuthSettingsComponent, LicenseManagementComponent, - AddLicenseItemDialogComponent, - LicenseHandOffDialogComponent + AddLicenseItemDialogComponent ], imports: [ CommonModule, diff --git a/ui-ngx/src/app/modules/home/pages/admin/license-management.component.ts b/ui-ngx/src/app/modules/home/pages/admin/license-management.component.ts index 6f096ba324..7da4fc040a 100644 --- a/ui-ngx/src/app/modules/home/pages/admin/license-management.component.ts +++ b/ui-ngx/src/app/modules/home/pages/admin/license-management.component.ts @@ -5,7 +5,6 @@ import { PageComponent } from '@shared/components/page.component'; import { AddonType, addonTypeTranslationMap, - createManageSubscriptionUrl, pePackOfferInfoMap, pePackOffers, PlanUiType, @@ -16,20 +15,20 @@ import { } from '@shared/models/subscription.models'; import { ActivatedRoute } from '@angular/router'; import { AdminService } from '@core/http/admin.service'; -import { MatDialog } from '@angular/material/dialog'; import { TranslateService } from '@ngx-translate/core'; import { ActionUpdateLicenseParams } from '@core/auth/auth.actions'; -import { getCurrentAuthState, selectUserSettingsProperty } from '@core/auth/auth.selectors'; +import { getCurrentAuthState } from '@core/auth/auth.selectors'; import { DateAgoPipe } from '@shared/pipe/date-ago.pipe'; import { interval, Subscription } from 'rxjs'; import { ErrorStateMatcher } from '@angular/material/core'; import { FormControl, FormGroupDirective, NgForm } from '@angular/forms'; import { SystemSetupService } from '@core/http/system-setup.service'; import { - LicenseHandOffCase, - LicenseHandOffDialogComponent, - LicenseHandOffDialogData -} from '@home/pages/admin/license-hand-off-dialog.component'; + LicenseActionsService, + licenseLimitCritical, + licenseLimitWarn, + licenseMeterWidth +} from '@home/components/license/license-actions.service'; import { select } from '@ngrx/store'; import { take } from 'rxjs/operators'; import { resolveSendErrorMessage } from '@core/utils'; @@ -126,7 +125,7 @@ export class LicenseManagementComponent extends PageComponent implements OnInit, private systemSetupService: SystemSetupService, private translate: TranslateService, private dateAgoPipe: DateAgoPipe, - private dialog: MatDialog) { + private licenseActions: LicenseActionsService) { super(); } @@ -144,8 +143,7 @@ export class LicenseManagementComponent extends PageComponent implements OnInit, if ($event) { $event.stopPropagation(); } - const url = createManageSubscriptionUrl(this.subscriptionInfo); - this.openPortalLinkMaybeShowDialog(LicenseHandOffCase.MANAGE_LICENSE, null, null, url); + this.licenseActions.manageLicense(this.subscriptionInfo); } refreshLicenseInfo($event?: Event) { @@ -181,24 +179,15 @@ export class LicenseManagementComponent extends PageComponent implements OnInit, } itemLimitWarn(count: number, max: number): boolean { - if (count && max) { - return (count / max) >= 0.85; - } - return false; + return licenseLimitWarn(count, max); } itemLimitCritical(count: number, max: number): boolean { - if (count && max) { - return count >= max; - } - return false; + return licenseLimitCritical(count, max); } itemMeterWidth(count: number, max: number): number { - if (count > 0 && max > 0) { - return Math.min(count / max, 1) * 100; - } - return 0; + return licenseMeterWidth(count, max); } itemLimitClass(itemType: UsageItemType, count: number, max: number): string { @@ -219,65 +208,28 @@ export class LicenseManagementComponent extends PageComponent implements OnInit, if ($event) { $event.stopPropagation(); } - switch (itemType) { - case UsageItemType.DEVICES: - this.addDevices(); - break; - case UsageItemType.AI_CREDITS: - this.addAiCredits(); - break; - case UsageItemType.EDGES: - this.addEdges(); - break; - case UsageItemType.PROD_INSTANCES: - this.addInstances(); - break; - case UsageItemType.AGENTS: - this.addAgents(); - break; - } + this.licenseActions.addItems(this.subscriptionInfo, itemType); } upgradePlanForItems($event: Event, itemType: UsageItemType): void { if ($event) { $event.stopPropagation(); } - let targetPlan: PlanUiType; - if (itemType === UsageItemType.DEVICES) { - if (this.subscriptionInfo.planUiType === PlanUiType.TbCommercialSmall) { - targetPlan = PlanUiType.TbPilot; - } else if (this.subscriptionInfo.planUiType === PlanUiType.TbNonCommercial) { - targetPlan = PlanUiType.TbBusiness; - } else if (this.subscriptionInfo.planUiType === PlanUiType.TbPilot) { - targetPlan = PlanUiType.TbStartup; - } else { - targetPlan = PlanUiType.TbBusiness; - } - } else{ - targetPlan = PlanUiType.TbPilot; - } - this.upgradePlan(itemType, null, targetPlan); + this.licenseActions.upgradePlanForItems(this.subscriptionInfo, itemType); } addAddOn($event: Event, addonType: AddonType) { if ($event) { $event.stopPropagation(); } - if (addonType === AddonType.EDGE) { - this.addEdge(); - } else if (addonType === AddonType.TRENDZ) { - this.addTrendz(); - } else if (addonType === AddonType.PROFESSIONAL_UPGRADE) { - this.addProfessionalUpgrade(); - } + this.licenseActions.addAddOn(this.subscriptionInfo, addonType); } upgradePlanForAddon($event: Event, addonType: AddonType): void { if ($event) { $event.stopPropagation(); } - const targetPlan = PlanUiType.TbPilot; - this.upgradePlan(null, addonType, targetPlan); + this.licenseActions.upgradePlanForAddon(this.subscriptionInfo, addonType); } async pasteKey() { @@ -358,82 +310,6 @@ export class LicenseManagementComponent extends PageComponent implements OnInit, )); } - private addDevices() { - this.addLicenseItem(UsageItemType.DEVICES, null, { extraDeviceCount: 100 }); - } - - private addEdges() { - this.addLicenseItem(UsageItemType.EDGES, null, { extraEdgeCount: 1 }); - } - - private addInstances() { - this.addLicenseItem(UsageItemType.PROD_INSTANCES, null, { extraInstanceCount: 1 }); - } - - private addAiCredits() { - this.addLicenseItem(UsageItemType.AI_CREDITS, null, { extraAiCreditsCount: 5 }); - } - - private addAgents() { - this.addLicenseItem(UsageItemType.AGENTS, null, { extraAgentCount: 1 }); - } - - private addEdge() { - this.addLicenseItem(null, AddonType.EDGE, { edgeEnabled: true }); - } - - private addTrendz() { - this.addLicenseItem(null, AddonType.TRENDZ, { trendzEnabled: true }); - } - - private addProfessionalUpgrade() { - this.addLicenseItem(null, AddonType.PROFESSIONAL_UPGRADE, { professionalUpgradeEnabled: true }); - } - - private addLicenseItem(itemType: UsageItemType, addonType: AddonType, items: any) { - const url = createManageSubscriptionUrl(this.subscriptionInfo, items); - const handOffCase = !!itemType ? LicenseHandOffCase.ADD_ITEMS : LicenseHandOffCase.ADD_ADDON; - this.openPortalLinkMaybeShowDialog(handOffCase, itemType, addonType, url); - } - - private upgradePlan(itemType: UsageItemType, addonType: AddonType, targetPlan: PlanUiType): void { - const url = `${this.subscriptionInfo.licenseServerEndpoint}/?changeSubscriptionPlan=true&subscriptionId=${this.subscriptionInfo.subscriptionId}&planUiType=${targetPlan}`; - const handOffCase = !!itemType ? LicenseHandOffCase.UPGRADE_PLAN_FOR_ITEMS : LicenseHandOffCase.UPGRADE_PLAN_FOR_ADDON; - this.openPortalLinkMaybeShowDialog(handOffCase, itemType, addonType, url); - } - - private openPortalLinkMaybeShowDialog(handOffCase: LicenseHandOffCase, - itemType: UsageItemType, addonType: AddonType, url: string): void { - this.store.pipe(select(selectUserSettingsProperty('notDisplayLicenseHandOff'))).pipe( - take(1) - ).subscribe((settings: boolean) => { - if (!settings) { - this.dialog.open(LicenseHandOffDialogComponent, - { - disableClose: true, - autoFocus: false, - panelClass: ['tb-dialog', 'tb-fullscreen-dialog'], - data: { - case: handOffCase, - isPerpetual: this.subscriptionInfo.perpetual, - isCeGrant: this.isCeGrant, - itemType, - addonType, - planName: this.subscriptionInfo.subscriptionPlanName - } - }).afterClosed().subscribe( - (result) => { - if (result) { - window.open(url, '_blank'); - } - } - ); - } else { - window.open(url, '_blank'); - } - }); - } - private refreshAgoTextIfNeeded(): void { this.stopAgoTextTimer(); if (!this.subscriptionInfo.offline && !this.subscriptionInfo.nonProduction) { diff --git a/ui-ngx/src/app/modules/home/pages/home-page/components/install-items-home.component.html b/ui-ngx/src/app/modules/home/pages/home-page/components/install-items-home.component.html index e93e0ed20a..a31b26a71f 100644 --- a/ui-ngx/src/app/modules/home/pages/home-page/components/install-items-home.component.html +++ b/ui-ngx/src/app/modules/home/pages/home-page/components/install-items-home.component.html @@ -26,18 +26,20 @@ } } - @if (withFeatures() && features().length) { + @if (withFeatures()) {
{{ 'home.install.features' | translate }} - {{ 'home.install.features-count' | translate: {on: configured(), total: features().length} }} + @if (loaded()) { + {{ 'home.install.features-count' | translate: {on: configured(), total: features().length} }} + }
diff --git a/ui-ngx/src/app/modules/home/pages/home-page/components/install-items-home.component.scss b/ui-ngx/src/app/modules/home/pages/home-page/components/install-items-home.component.scss index d7b0b5b934..c9fe1301f7 100644 --- a/ui-ngx/src/app/modules/home/pages/home-page/components/install-items-home.component.scss +++ b/ui-ngx/src/app/modules/home/pages/home-page/components/install-items-home.component.scss @@ -121,6 +121,26 @@ color: var(--tb-ink-38, rgba(0, 0, 0, 0.38)); } +.tb-install-feature.pending .tb-install-feature-icon.mat-icon { + color: var(--tb-ink-12, rgba(0, 0, 0, 0.12)); + animation: tb-install-pending 1.2s ease-in-out infinite alternate; +} + +@keyframes tb-install-pending { + from { + opacity: 1; + } + to { + opacity: 0.4; + } +} + +@media (prefers-reduced-motion: reduce) { + .tb-install-feature.pending .tb-install-feature-icon.mat-icon { + animation: none; + } +} + .tb-install-feature.on .tb-install-feature-icon.mat-icon { color: var(--tb-primary-500); } diff --git a/ui-ngx/src/app/modules/home/pages/home-page/components/install-items-home.component.ts b/ui-ngx/src/app/modules/home/pages/home-page/components/install-items-home.component.ts index 942576357a..f45ef7891d 100644 --- a/ui-ngx/src/app/modules/home/pages/home-page/components/install-items-home.component.ts +++ b/ui-ngx/src/app/modules/home/pages/home-page/components/install-items-home.component.ts @@ -58,12 +58,11 @@ export class InstallItemsHomeComponent { readonly features = computed(() => { const info = this.featuresInfo(); - if (!info) { - return []; - } - return FEATURES.map(feature => ({...feature, on: !!info[feature.key]})); + return FEATURES.map(feature => ({...feature, on: info ? !!info[feature.key] : null})); }); + readonly loaded = computed(() => !!this.featuresInfo()); + readonly configured = computed(() => this.features().filter(feature => feature.on).length); constructor() { diff --git a/ui-ngx/src/app/modules/home/pages/home-page/components/license-home.component.html b/ui-ngx/src/app/modules/home/pages/home-page/components/license-home.component.html new file mode 100644 index 0000000000..6e70b7d735 --- /dev/null +++ b/ui-ngx/src/app/modules/home/pages/home-page/components/license-home.component.html @@ -0,0 +1,166 @@ + + + + @if (managed() && updatedAgo()) { + + {{ 'subscription.updated-ago' | translate: {ago: updatedAgo()} }} + + + } + + @if (info(); as license) { +
+ + + @if (license.offline) { + + cloud_off + + } + +
+ {{ (license.development ? 'home.license.development-mode' : license.perpetual ? 'subscription.perpetual-license' : 'subscription.subscription') | translate }} + {{ license.subscriptionPlanName }} + @if (license.development) { + {{ 'home.license.development-line' | translate }} + } @else if (license.perpetual) { + @if (license.endTs) { + {{ 'subscription.updates-and-support-until' | translate: {date: license.endTs | date: 'd MMMM yyyy'} }} + } + } @else if (license.upcomingInvoiceDate) { + + } +
+ @if (managed()) { +
+ +
+ } +
+
+ @if (limitGroups().length) { +
+ @for (group of limitGroups(); track group.id) { +
{{ group.icon }}{{ group.label | translate }}
+ @for (row of group.rows; track row.itemType) { +
+ {{ row.label | translate }} + @if (row.max) { + + {{ row.used | shortNumber: {roundDown: true} }} / {{ row.max | shortNumber: {roundDown: true} }} + @if (row.tone) { + {{ (row.tone === 'critical' ? 'home.license.at-limit' : 'home.license.of-limit') | translate: {percent: row.percent} }} + } + + } @else { + {{ 'subscription.not-included' | translate }} + } + + @if (row.action === 'add') { + + } @else if (row.action === 'upgrade') { + + } @else if (row.max) { + {{ row.percent }}% + } @else { + + } +
+ } + } +
+ } + @switch (offer()) { + @case ('pe-pack') { +
+
+ +
+ {{ 'subscription.pe-pack' | translate }} + {{ 'subscription.pe-pack-desc' | translate }} +
+ +
+ +
+ } + @case ('production') { +
+
+
+ {{ 'home.license.go-to-production' | translate }} +
+ +
+ +
+ } + @default { +
+
extension{{ 'subscription.add-ons' | translate }}
+
    + @for (addon of addons(); track addon.type) { +
  • + {{ addon.label | translate }} + @switch (addon.state) { + @case ('included') { + check_circle{{ 'subscription.included' | translate }} + } + @case ('add') { + + } + @case ('upgrade') { + + } + @case ('not-included') { + {{ 'subscription.not-included' | translate }} + } + @default { + {{ 'home.license.not-in-license' | translate }} + } + } +
  • + } +
+
+ } + } +
+ } +
+ + +
    + @for (item of items; track item.icon) { +
  • + {{ item.icon }} + {{ item.title | translate }}{{ item.text | translate }} +
  • + } +
+
diff --git a/ui-ngx/src/app/modules/home/pages/home-page/components/license-home.component.scss b/ui-ngx/src/app/modules/home/pages/home-page/components/license-home.component.scss new file mode 100644 index 0000000000..0d70fe1629 --- /dev/null +++ b/ui-ngx/src/app/modules/home/pages/home-page/components/license-home.component.scss @@ -0,0 +1,546 @@ +// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc. +// SPDX-License-Identifier: BUSL-1.1 +:host { + display: block; + min-width: 0; + container: tb-license / inline-size; +} + +.tb-home-sr-only { + position: absolute; + width: 1px; + height: 1px; + overflow: hidden; + clip: rect(0 0 0 0); + white-space: nowrap; +} + +.tb-license-updated { + display: inline-flex; + align-items: center; + gap: 2px; + margin-right: -8px; + font: 400 13px/18px var(--tb-font, Roboto, sans-serif); + color: var(--tb-text-secondary, rgba(0, 0, 0, 0.6)); + + > span { + white-space: nowrap; + } +} + +.tb-license-refresh.mat-mdc-icon-button.mat-mdc-button-base { + --mdc-icon-button-state-layer-size: 32px; + --mat-icon-button-state-layer-size: 32px; + display: inline-flex; + align-items: center; + justify-content: center; + width: 32px; + height: 32px; + padding: 0; + color: var(--tb-ink-54, rgba(0, 0, 0, 0.54)); + + .mat-icon { + width: 20px; + height: 20px; + font-size: 20px; + + &.spinning { + animation: tb-license-spin 1s linear infinite; + } + } +} + +@keyframes tb-license-spin { + to { + transform: rotate(360deg); + } +} + +.tb-license-band { + --tb-license-holo: color-mix(in srgb, var(--tb-primary-500) 14%, transparent); + position: relative; + isolation: isolate; + display: flex; + align-items: center; + gap: 20px; + margin: 0 calc(-1 * var(--tb-home-card-padding, 20px)) 8px; + padding: 24px var(--tb-home-card-padding, 20px); + + &::before { + content: ""; + position: absolute; + inset: 0; + z-index: -1; + pointer-events: none; + background: + radial-gradient(50% 70% at 50% 0%, rgb(255 255 255 / 0.7), rgb(255 255 255 / 0) 70%), + linear-gradient(105deg, var(--tb-license-holo) 0%, rgb(0 150 220 / 0.10) 22%, rgb(150 120 240 / 0.09) 42%, + rgb(255 170 130 / 0.08) 60%, rgb(0 190 170 / 0.09) 78%, var(--tb-license-holo) 100%); + background-size: 100% 100%, 220% 100%; + -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 55%, transparent 100%); + mask-image: linear-gradient(180deg, #000 0%, #000 55%, transparent 100%); + animation: tb-license-holo 18s ease-in-out both; + } + + &.grant { + --tb-license-holo: rgb(21 96 180 / 0.14); + } + + &.development::before { + animation: none; + background: radial-gradient(circle at 1px 1px, rgb(15 36 32 / 0.09) 1px, transparent 1.5px) 0 0 / 12px 12px, rgba(0, 0, 0, 0.03); + } +} + +@keyframes tb-license-holo { + from { + background-position: 0 0, 0% 0; + } + to { + background-position: 0 0, 100% 0; + } +} + +@media (prefers-reduced-motion: reduce) { + .tb-license-band::before { + animation: none; + } +} + +.tb-license-mark { + position: relative; + display: block; + flex: none; + width: 72px; + height: 72px; + margin: -6px; + + img { + display: block; + width: 100%; + height: 100%; + } + + &.development img { + filter: grayscale(1); + opacity: 0.72; + } + + &.with-hue::after { + content: ""; + position: absolute; + inset: 0; + background: var(--tb-noncommercial, #1560b4); + mix-blend-mode: hue; + pointer-events: none; + -webkit-mask: url(/assets/license/tb-license-mark.svg) center / 100% 100% no-repeat; + mask: url(/assets/license/tb-license-mark.svg) center / 100% 100% no-repeat; + } +} + +.tb-license-offline { + position: absolute; + top: -2px; + right: -2px; + z-index: 1; + display: flex; + align-items: center; + justify-content: center; + width: 24px; + height: 24px; + border-radius: 50%; + background: #fff; + box-shadow: 0 1px 3px rgba(15, 36, 32, 0.22); + color: var(--tb-ink-76, rgba(0, 0, 0, 0.76)); + + .mat-icon { + width: 16px; + height: 16px; + font-size: 16px; + } +} + +.tb-license-id { + display: flex; + flex: 1; + flex-direction: column; + gap: 2px; + min-width: 0; + + small { + font: 500 12px/16px var(--tb-font, Roboto, sans-serif); + letter-spacing: 0.5px; + text-transform: uppercase; + color: var(--tb-ink-54, rgba(0, 0, 0, 0.54)); + } + + > b { + font: 500 20px/28px var(--tb-font, Roboto, sans-serif); + color: var(--tb-ink, rgba(0, 0, 0, 0.87)); + } + + > span { + font: 400 13px/18px var(--tb-font, Roboto, sans-serif); + color: var(--tb-ink-76, rgba(0, 0, 0, 0.76)); + + ::ng-deep b { + font-weight: 500; + } + } +} + +.tb-license-manage { + display: flex; + flex: none; + flex-direction: column; + align-items: flex-end; + gap: 4px; +} + +.tb-license-button.mdc-button { + height: 32px; + padding: 0 16px; + border-radius: 4px; + white-space: nowrap; + + &.mat-mdc-outlined-button { + background: var(--tb-surface, #fff); + } + + .mat-icon { + width: 18px; + height: 18px; + margin: 0 8px 0 -4px; + font-size: 18px; + } +} + +.tb-license-body { + display: flex; + flex-direction: column; + gap: 16px; +} + +.tb-license-head { + display: flex; + align-items: center; + gap: 6px; + font: 500 12px/16px var(--tb-font, Roboto, sans-serif); + letter-spacing: 0.5px; + text-transform: uppercase; + color: var(--tb-ink-54, rgba(0, 0, 0, 0.54)); + + .mat-icon { + flex: none; + width: 16px; + height: 16px; + font-size: 16px; + color: var(--tb-ink-38, rgba(0, 0, 0, 0.38)); + } +} + +.tb-license-limits { + display: grid; + grid-template-columns: max-content max-content minmax(48px, 1fr) max-content; + align-items: center; + gap: 8px 12px; + min-width: 0; + max-width: 560px; + + > .tb-license-head { + grid-column: 1 / -1; + margin-top: 16px; + + &:first-child { + margin-top: 0; + } + } +} + +.tb-license-limit { + display: contents; + + > * { + display: flex; + align-items: center; + min-height: 32px; + } + + > .tb-license-meter { + display: block; + min-height: 0; + } + + > .tb-license-button { + justify-self: start; + min-height: 0; + margin-left: -8px; + } +} + +.tb-license-limit-name { + font: 400 14px/20px var(--tb-font, Roboto, sans-serif); + letter-spacing: 0.2px; + white-space: nowrap; + color: var(--tb-ink, rgba(0, 0, 0, 0.87)); +} + +.tb-license-limit-counts { + font: 400 14px/20px var(--tb-font, Roboto, sans-serif); + letter-spacing: 0.2px; + white-space: nowrap; + font-variant-numeric: tabular-nums; + color: var(--tb-ink-76, rgba(0, 0, 0, 0.76)); +} + +.tb-license-limit-counts.none { + font-size: 13px; + color: var(--tb-text-secondary, rgba(0, 0, 0, 0.6)); +} + +.tb-license-meter { + height: 8px; + overflow: hidden; + border-radius: 2px; + background: rgba(0, 0, 0, 0.08); + + > i { + display: block; + height: 100%; + border-radius: 2px; + background: var(--tb-primary-500); + } +} + +.tb-license-pct { + font: 400 13px/18px var(--tb-font, Roboto, sans-serif); + font-variant-numeric: tabular-nums; + color: var(--tb-text-secondary, rgba(0, 0, 0, 0.6)); +} + +.tb-license-limit.near { + .tb-license-limit-counts { + color: #955400; + } + + .tb-license-meter { + background: rgb(255 167 38 / 0.16); + + > i { + background: #b26500; + } + } +} + +.tb-license-limit.critical { + .tb-license-limit-counts { + color: var(--tb-sev-critical, #D12730); + } + + .tb-license-meter { + background: rgba(209, 39, 48, 0.06); + + > i { + background: var(--tb-sev-critical, #D12730); + } + } +} + +.tb-license-addons-group { + display: flex; + flex-direction: column; + gap: 8px; + min-width: 0; +} + +.tb-license-addons { + display: grid; + grid-template-columns: max-content max-content; + align-items: center; + gap: 8px 16px; + margin: 0; + padding: 0; + list-style: none; + + li { + display: contents; + font: 400 14px/20px var(--tb-font, Roboto, sans-serif); + color: var(--tb-ink, rgba(0, 0, 0, 0.87)); + + > * { + display: flex; + align-items: center; + min-height: 32px; + } + + > .tb-license-button { + justify-self: start; + min-height: 0; + } + } +} + +.tb-license-addon-name { + min-width: 0; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; +} + +.tb-license-addon-state { + display: inline-flex; + align-items: center; + gap: 4px; + padding-left: 8px; + font: 400 13px/18px var(--tb-font, Roboto, sans-serif); + white-space: nowrap; + color: var(--tb-text-secondary, rgba(0, 0, 0, 0.6)); + + &.included { + color: var(--tb-ink-76, rgba(0, 0, 0, 0.76)); + } + + .mat-icon { + width: 18px; + height: 18px; + font-size: 18px; + color: var(--tb-primary-500); + } +} + +.tb-license-pack { + min-width: 0; + padding: 12px 14px 14px; + border-radius: 10px; + background: + linear-gradient(180deg, rgb(255 255 255 / 0) 35%, var(--tb-surface, #fff) 100%), + radial-gradient(120% 110% at 0% 0%, rgb(255 255 255 / 0.9) 0%, rgb(255 255 255 / 0) 58%), + linear-gradient(115deg, rgb(0 105 92 / 0.11) 0%, rgb(0 105 92 / 0.06) 38%, rgb(0 88 196 / 0.065) 72%, rgb(0 51 202 / 0.10) 100%); +} + +.tb-license-pack-head { + display: flex; + align-items: center; + gap: 10px; + margin: -4px 0 10px -4px; + + img { + flex: none; + } + + &.bare { + margin: 0 0 12px; + } +} + +.tb-license-pack-id { + display: flex; + flex: 1; + flex-direction: column; + gap: 2px; + min-width: 0; + + b { + font: 500 15px/20px var(--tb-font, Roboto, sans-serif); + color: var(--tb-ink, rgba(0, 0, 0, 0.87)); + } + + span { + font: 400 13px/18px var(--tb-font, Roboto, sans-serif); + color: var(--tb-ink-76, rgba(0, 0, 0, 0.76)); + } +} + +.tb-license-pack-grid { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: 8px; + margin: 0; + padding: 0; + list-style: none; + + li { + display: flex; + gap: 9px; + padding: 10px 12px 11px; + border-radius: 8px; + background: var(--tb-surface, #fff); + box-shadow: 0 0 0 1px rgb(0 105 92 / 0.06), 0 1px 2px rgba(15, 36, 32, 0.04); + + > .mat-icon { + flex: none; + width: 20px; + height: 20px; + margin-top: 1px; + font-size: 20px; + color: #023e36; + } + + > span { + display: flex; + flex-direction: column; + gap: 2px; + min-width: 0; + } + } + + b { + font: 500 13px/18px var(--tb-font, Roboto, sans-serif); + color: var(--tb-ink, rgba(0, 0, 0, 0.87)); + } + + small { + font: 400 12px/16px var(--tb-font, Roboto, sans-serif); + color: var(--tb-text-secondary, rgba(0, 0, 0, 0.6)); + } +} + +@container tb-license (min-width: 640px) { + .tb-license-body:not(.offer) { + display: grid; + grid-template-columns: minmax(0, 1fr) max-content; + align-items: start; + column-gap: 40px; + } + + .tb-license-body:not(.offer) .tb-license-limits { + max-width: none; + } +} + +@container tb-license (max-width: 460px) { + .tb-license-limits { + grid-template-columns: max-content max-content minmax(48px, 1fr); + } + + .tb-license-limit { + > .tb-license-button { + grid-column: 1 / -1; + } + + > .tb-license-pct { + display: none; + } + } +} + +@container tb-license (max-width: 420px) { + .tb-license-band { + flex-wrap: wrap; + } + + .tb-license-manage { + flex-basis: 100%; + flex-direction: row; + justify-content: space-between; + align-items: center; + } + + .tb-license-pack-grid { + grid-template-columns: minmax(0, 1fr); + } + + .tb-license-pack-head { + flex-wrap: wrap; + } +} diff --git a/ui-ngx/src/app/modules/home/pages/home-page/components/license-home.component.ts b/ui-ngx/src/app/modules/home/pages/home-page/components/license-home.component.ts index 399d7232d3..05582f95df 100644 --- a/ui-ngx/src/app/modules/home/pages/home-page/components/license-home.component.ts +++ b/ui-ngx/src/app/modules/home/pages/home-page/components/license-home.component.ts @@ -1,16 +1,328 @@ // SPDX-FileCopyrightText: Copyright ThingsBoard, Inc. // SPDX-License-Identifier: BUSL-1.1 -import { ChangeDetectionStrategy, Component } from '@angular/core'; +import { ChangeDetectionStrategy, Component, computed, DestroyRef, ElementRef, inject, signal } from '@angular/core'; +import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; +import { Store } from '@ngrx/store'; +import { interval } from 'rxjs'; +import { AppState } from '@core/core.state'; +import { getCurrentAuthState } from '@core/auth/auth.selectors'; +import { AdminService } from '@core/http/admin.service'; +import { DateAgoPipe } from '@shared/pipe/date-ago.pipe'; import { HomeCardId } from '@shared/models/user-settings.models'; +import { + AddonType, + addonTypeTranslationMap, + PlanUiType, + SubscriptionInfo, + usageAddItemTypeTranslationMap, + UsageItemType, + usageItemTypeTranslationMap +} from '@shared/models/subscription.models'; import { HOME_CARDS } from '@home/pages/home-page/home-cards.models'; +import { + LicenseActionsService, + licenseLimitCritical, + licenseLimitWarn, + licenseMeterWidth +} from '@home/components/license/license-actions.service'; + +const LOADING_HEIGHT = 398; +const HEIGHT_KEY = 'tb-home-license-height'; + +const storedHeight = (): number => { + try { + return Number(localStorage.getItem(HEIGHT_KEY)) || LOADING_HEIGHT; + } catch { + return LOADING_HEIGHT; + } +}; + +const AGO_REFRESH_MS = 30_000; + +const PLANS_URL = 'https://thingsboard.io/pricing/?product=thingsboard-pe'; + +const TONED_ITEMS = [UsageItemType.DEVICES, UsageItemType.ASSETS, UsageItemType.AI_CREDITS]; + +type LimitTone = 'critical' | 'near' | null; + +type LimitAction = 'add' | 'upgrade' | null; + +interface LicenseLimit { + itemType: UsageItemType; + label: string; + used: number; + max: number; + percent: number; + width: number; + tone: LimitTone; + action: LimitAction; + addLabel: string; +} + +interface LicenseLimitGroup { + id: string; + label: string; + icon: string; + rows: LicenseLimit[]; +} + +type AddonState = 'included' | 'not-included' | 'add' | 'upgrade' | 'not-in-license'; + +interface LicenseAddon { + type: AddonType; + label: string; + state: AddonState; +} + +interface LicenseOffer { + icon: string; + title: string; + text: string; +} + +const PE_PACK_OFFERS: LicenseOffer[] = [ + {icon: 'brush', title: 'subscription.white-labeling', text: 'subscription.white-labeling-promo'}, + {icon: 'integration_instructions', title: 'subscription.integrations', text: 'subscription.integrations-promo'}, + {icon: 'schedule', title: 'subscription.scheduler', text: 'subscription.scheduler-promo'}, + {icon: 'assessment', title: 'subscription.reports', text: 'subscription.reports-promo'} +]; + +const PRODUCTION_OFFERS: LicenseOffer[] = [ + {icon: 'rocket_launch', title: 'home.license.production-use', text: 'home.license.production-use-text'}, + {icon: 'brush', title: 'subscription.white-labeling', text: 'subscription.white-labeling-promo'}, + {icon: 'auto_awesome', title: 'subscription.ai-credits', text: 'home.license.ai-credits-text'}, + {icon: 'extension', title: 'subscription.add-ons', text: 'home.license.add-ons-text'} +]; @Component({ selector: 'tb-license-home', - template: ``, + templateUrl: './license-home.component.html', + styleUrls: ['./license-home.component.scss'], standalone: false, changeDetection: ChangeDetectionStrategy.OnPush }) export class LicenseHomeComponent { - readonly card = HOME_CARDS[HomeCardId.LICENSE]; + private adminService = inject(AdminService); + private dateAgoPipe = inject(DateAgoPipe); + private licenseActions = inject(LicenseActionsService); + private aiEnabled = getCurrentAuthState(inject(Store)).aiEnabled; + + readonly pePackOffers = PE_PACK_OFFERS; + readonly productionOffers = PRODUCTION_OFFERS; + + readonly info = signal(null); + readonly refreshing = signal(false); + private readonly now = signal(Date.now()); + + readonly cardDefinition = computed(() => { + const card = HOME_CARDS[HomeCardId.LICENSE]; + return this.info() ? card : {...card, height: storedHeight()}; + }); + + readonly kind = computed(() => { + const info = this.info(); + if (!info) { + return null; + } + if (info.development) { + return 'development'; + } + if (info.communityGrantLicense) { + return 'grant'; + } + return info.perpetual ? 'perpetual' : 'subscription'; + }); + + readonly markHue = computed(() => { + switch (this.info()?.planUiType) { + case PlanUiType.TbNonCommercial: + case PlanUiType.TbNonCommercialOffline: + case PlanUiType.TbCommunityGrant: + return true; + default: + return false; + } + }); + + readonly managed = computed(() => { + const info = this.info(); + return !!info && !info.offline && !info.nonProduction; + }); + + readonly updatedAgo = computed(() => { + this.now(); + const dataTs = this.info()?.dataTs; + return dataTs ? this.dateAgoPipe.transform(dataTs, {applyAgo: true, long: true, textPart: true}) : null; + }); + + readonly limitGroups = computed(() => { + const info = this.info(); + if (!info || info.development) { + return []; + } + const groups: LicenseLimitGroup[] = []; + const entities = [ + this.limit(info, UsageItemType.DEVICES, info.devicesCount, info.maxDevices, info.planExtraDeviceEnabled), + this.limit(info, UsageItemType.ASSETS, info.assetsCount, info.maxAssets, false) + ].filter(row => !!row); + if (entities.length) { + groups.push({id: 'entities', label: 'home.license.devices-and-assets', icon: 'memory', rows: entities}); + } + const installations = [ + info.maxInstances > 0 ? + this.limit(info, UsageItemType.PROD_INSTANCES, info.instancesCount, info.maxInstances, info.planExtraInstanceEnabled) : null, + info.edgeEnabled ? this.limit(info, UsageItemType.EDGES, info.edgesCount, info.maxEdges, info.planExtraEdgeEnabled) : null, + info.maxAgents > 0 || info.planExtraAgentEnabled ? + this.limit(info, UsageItemType.AGENTS, info.agentsCount, info.maxAgents, info.planExtraAgentEnabled) : null + ].filter(row => !!row); + if (installations.length) { + groups.push({id: 'installations', label: 'home.license.installations', icon: 'lan', rows: installations}); + } + if (this.aiEnabled && !info.offline && info.maxAiCredits > 0) { + const credits = this.limit(info, UsageItemType.AI_CREDITS, info.usedAiCredits, info.maxAiCredits, info.planExtraAiCreditsEnabled, + 'home.license.this-month'); + groups.push({id: 'credits', label: 'subscription.ai-credits', icon: 'auto_awesome', rows: [credits]}); + } + return groups; + }); + + readonly offer = computed<'pe-pack' | 'production' | null>(() => { + const info = this.info(); + if (!info) { + return null; + } + if (info.development) { + return 'production'; + } + return info.communityGrantLicense && !info.whiteLabelingEnabled ? 'pe-pack' : null; + }); + + readonly addons = computed(() => { + const info = this.info(); + if (!info || this.offer()) { + return []; + } + const addons: LicenseAddon[] = []; + if (!info.communityGrantLicense || info.whiteLabelingEnabled) { + addons.push(this.addon(info, AddonType.WHITE_LABELING, info.whiteLabelingEnabled, false)); + } + if (!info.perpetual || info.planEdgeEnabled) { + addons.push(this.addon(info, AddonType.EDGE, info.edgeEnabled, info.planEdgeEnabled)); + } + if (!info.perpetual || info.planTrendzEnabled) { + addons.push(this.addon(info, AddonType.TRENDZ, info.trendzEnabled, info.planTrendzEnabled)); + } + if (info.communityGrantLicense && info.whiteLabelingEnabled) { + addons.push(this.addon(info, AddonType.PROFESSIONAL_UPGRADE, true, false)); + } + return addons; + }); + + constructor() { + const destroyRef = inject(DestroyRef); + this.adminService.getSubscriptionInfo({ignoreLoading: true}).pipe(takeUntilDestroyed(destroyRef)) + .subscribe(info => this.info.set(info)); + interval(AGO_REFRESH_MS).pipe(takeUntilDestroyed(destroyRef)).subscribe(() => this.now.set(Date.now())); + const host = inject>(ElementRef); + const observer = new ResizeObserver(() => this.rememberHeight(host.nativeElement)); + observer.observe(host.nativeElement); + destroyRef.onDestroy(() => observer.disconnect()); + } + + refresh(): void { + this.refreshing.set(true); + this.adminService.refreshLicense({ignoreLoading: true}).subscribe({ + next: info => { + this.info.set(info); + this.refreshing.set(false); + }, + error: () => this.refreshing.set(false) + }); + } + + manageLicense(): void { + this.licenseActions.manageLicense(this.info()); + } + + limitAction(row: LicenseLimit): void { + if (row.action === 'add') { + this.licenseActions.addItems(this.info(), row.itemType); + } else if (row.action === 'upgrade') { + this.licenseActions.upgradePlanForItems(this.info(), row.itemType); + } + } + + addonAction(addon: LicenseAddon): void { + if (addon.state === 'add') { + this.licenseActions.addAddOn(this.info(), addon.type); + } else if (addon.state === 'upgrade') { + this.licenseActions.upgradePlanForAddon(this.info(), addon.type); + } + } + + addProfessionalPack(): void { + this.licenseActions.addAddOn(this.info(), AddonType.PROFESSIONAL_UPGRADE); + } + + seePlans(): void { + window.open(PLANS_URL, '_blank'); + } + + private rememberHeight(element: HTMLElement): void { + const height = Math.round(element.getBoundingClientRect().height); + if (!this.info() || !height) { + return; + } + try { + localStorage.setItem(HEIGHT_KEY, String(height)); + } catch { + return; + } + } + + private limit(info: SubscriptionInfo, itemType: UsageItemType, used: number, max: number, addEnabled: boolean, + label = usageItemTypeTranslationMap.get(itemType)): LicenseLimit | null { + if (max == null || max < 0) { + return null; + } + const count = used ?? 0; + let tone: LimitTone = null; + if (max > 0 && count > max) { + tone = 'critical'; + } else if (TONED_ITEMS.includes(itemType)) { + tone = licenseLimitCritical(count, max) ? 'critical' : licenseLimitWarn(count, max) ? 'near' : null; + } + let action: LimitAction = null; + if ((tone || max === 0) && !info.offline && itemType !== UsageItemType.ASSETS) { + action = addEnabled ? 'add' : !info.perpetual ? 'upgrade' : null; + } + return { + itemType, + label, + used: count, + max, + percent: max > 0 ? Math.round(count / max * 100) : 0, + width: licenseMeterWidth(count, max), + tone, + action, + addLabel: usageAddItemTypeTranslationMap.get(itemType) + }; + } + + private addon(info: SubscriptionInfo, type: AddonType, enabled: boolean, addEnabled: boolean): LicenseAddon { + let state: AddonState; + if (enabled) { + state = 'included'; + } else if (info.offline) { + state = 'not-included'; + } else if (addEnabled) { + state = 'add'; + } else if (!info.perpetual) { + state = 'upgrade'; + } else { + state = 'not-in-license'; + } + return {type, label: addonTypeTranslationMap.get(type), state}; + } } diff --git a/ui-ngx/src/app/modules/home/pages/home-page/home-cards.models.ts b/ui-ngx/src/app/modules/home/pages/home-page/home-cards.models.ts index b071924468..5ec95eaf53 100644 --- a/ui-ngx/src/app/modules/home/pages/home-page/home-cards.models.ts +++ b/ui-ngx/src/app/modules/home/pages/home-page/home-cards.models.ts @@ -25,7 +25,7 @@ export const HOME_CARDS: Record = { [HomeCardId.PRODUCT_RELEASE]: {id: HomeCardId.PRODUCT_RELEASE, icon: 'new_releases', name: 'home.cards.product-release', height: 100}, [HomeCardId.GET_STARTED_SYS_ADMIN]: {id: HomeCardId.GET_STARTED_SYS_ADMIN, icon: 'rocket_launch', name: 'home.cards.get-started'}, [HomeCardId.SYSTEM_STATUS]: {id: HomeCardId.SYSTEM_STATUS, icon: 'dns', name: 'home.cards.system-status'}, - [HomeCardId.LICENSE]: {id: HomeCardId.LICENSE, icon: 'verified', name: 'home.cards.license', link: '/license', height: 398}, + [HomeCardId.LICENSE]: {id: HomeCardId.LICENSE, icon: 'verified', name: 'home.cards.license', link: '/license'}, [HomeCardId.INSTALL_ITEMS]: {id: HomeCardId.INSTALL_ITEMS, icon: 'domain', name: 'home.cards.install-items'} }; diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json index 604a4e778d..f7d5ecd3c7 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -8832,6 +8832,23 @@ "action": "Open Notifications settings" } }, + "license": { + "development-mode": "Development mode", + "development-line": "Non-production use only. Limits do not apply; White labeling is not available.", + "updated-tooltip": "When the license info was last read from the License Portal", + "devices-and-assets": "Devices and assets", + "installations": "Installations", + "this-month": "This month", + "of-limit": "{{percent}}% of your limit", + "at-limit": "At your limit", + "not-in-license": "Not in your license", + "go-to-production": "Go to production", + "see-plans": "See plans", + "production-use": "Production use", + "production-use-text": "Real devices and customers on this install.", + "ai-credits-text": "A monthly pool for the AI Assistant across the install.", + "add-ons-text": "Edge Computing and Trendz Analytics, added to the license." + }, "install": { "add-tenant": "Add tenant", "tenants": "Tenants", @@ -8841,6 +8858,7 @@ "dashboards": "Dashboards", "integrations": "Integrations", "features": "Features", + "checking": "Checking the configuration", "features-count": "{{on}} of {{total}}", "white-labeling": "White labeling", "mail-server": "Mail server",