Browse Source

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

pull/16848/head
Igor Kulikov 1 week ago
parent
commit
f1e3dcfdce
  1. 3
      ui-ngx/src/app/modules/home/components/home-components.module.ts
  2. 117
      ui-ngx/src/app/modules/home/components/license/license-actions.service.ts
  3. 0
      ui-ngx/src/app/modules/home/components/license/license-hand-off-dialog.component.html
  4. 0
      ui-ngx/src/app/modules/home/components/license/license-hand-off-dialog.component.scss
  5. 0
      ui-ngx/src/app/modules/home/components/license/license-hand-off-dialog.component.ts
  6. 4
      ui-ngx/src/app/modules/home/pages/admin/admin.module.ts
  7. 154
      ui-ngx/src/app/modules/home/pages/admin/license-management.component.ts
  8. 12
      ui-ngx/src/app/modules/home/pages/home-page/components/install-items-home.component.html
  9. 20
      ui-ngx/src/app/modules/home/pages/home-page/components/install-items-home.component.scss
  10. 7
      ui-ngx/src/app/modules/home/pages/home-page/components/install-items-home.component.ts
  11. 166
      ui-ngx/src/app/modules/home/pages/home-page/components/license-home.component.html
  12. 546
      ui-ngx/src/app/modules/home/pages/home-page/components/license-home.component.scss
  13. 318
      ui-ngx/src/app/modules/home/pages/home-page/components/license-home.component.ts
  14. 2
      ui-ngx/src/app/modules/home/pages/home-page/home-cards.models.ts
  15. 18
      ui-ngx/src/assets/locale/locale.constant-en_US.json

3
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,

117
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<Record<UsageItemType, Record<string, number>>> = {
[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<Record<AddonType, Record<string, boolean>>> = {
[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<AppState>);
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, LicenseHandOffDialogData, boolean>(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');
}
});
});
}
}

0
ui-ngx/src/app/modules/home/pages/admin/license-hand-off-dialog.component.html → ui-ngx/src/app/modules/home/components/license/license-hand-off-dialog.component.html

0
ui-ngx/src/app/modules/home/pages/admin/license-hand-off-dialog.component.scss → ui-ngx/src/app/modules/home/components/license/license-hand-off-dialog.component.scss

0
ui-ngx/src/app/modules/home/pages/admin/license-hand-off-dialog.component.ts → ui-ngx/src/app/modules/home/components/license/license-hand-off-dialog.component.ts

4
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,

154
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, LicenseHandOffDialogData, boolean>(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) {

12
ui-ngx/src/app/modules/home/pages/home-page/components/install-items-home.component.html

@ -26,18 +26,20 @@
}
}
</div>
@if (withFeatures() && features().length) {
@if (withFeatures()) {
<div class="tb-install-head">
<span>{{ 'home.install.features' | translate }}</span>
<span class="tb-install-head-count">{{ 'home.install.features-count' | translate: {on: configured(), total: features().length} }}</span>
@if (loaded()) {
<span class="tb-install-head-count">{{ 'home.install.features-count' | translate: {on: configured(), total: features().length} }}</span>
}
</div>
<div class="tb-install-features" role="list">
@for (feature of features(); track feature.key) {
<a class="tb-install-feature" role="listitem" [class.on]="feature.on" [routerLink]="feature.link"
[matTooltip]="(feature.on ? 'widgets.configured-features.feature-configured' : 'widgets.configured-features.feature-not-configured') | translate">
<a class="tb-install-feature" role="listitem" [class.on]="feature.on" [class.pending]="feature.on === null" [routerLink]="feature.link"
[matTooltip]="(feature.on === null ? 'home.install.checking' : feature.on ? 'widgets.configured-features.feature-configured' : 'widgets.configured-features.feature-not-configured') | translate">
<mat-icon class="tb-install-feature-icon">{{ feature.on ? 'check_circle' : 'radio_button_unchecked' }}</mat-icon>
<span class="tb-install-feature-text">{{ feature.label | translate }}</span>
<span class="tb-home-sr-only">{{ (feature.on ? 'home.install.configured' : 'home.install.not-configured') | translate }}</span>
<span class="tb-home-sr-only">{{ (feature.on === null ? 'home.install.checking' : feature.on ? 'home.install.configured' : 'home.install.not-configured') | translate }}</span>
</a>
}
</div>

20
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);
}

7
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() {

166
ui-ngx/src/app/modules/home/pages/home-page/components/license-home.component.html

@ -0,0 +1,166 @@
<!--
SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
SPDX-License-Identifier: BUSL-1.1
-->
<tb-home-card [card]="cardDefinition()">
<ng-container homeCardActions>
@if (managed() && updatedAgo()) {
<span class="tb-license-updated">
<span [matTooltip]="'home.license.updated-tooltip' | translate">{{ 'subscription.updated-ago' | translate: {ago: updatedAgo()} }}</span>
<button mat-icon-button type="button" class="tb-license-refresh" [disabled]="refreshing()"
[matTooltip]="'action.update' | translate" [attr.aria-label]="'action.update' | translate" (click)="refresh()">
<mat-icon [class.spinning]="refreshing()">refresh</mat-icon>
</button>
</span>
}
</ng-container>
@if (info(); as license) {
<div class="tb-license-band" [class]="kind()">
<span class="tb-license-mark" [class.with-hue]="markHue()" [class.development]="license.development">
<img src="/assets/license/tb-license-mark.svg" alt width="72" height="72">
@if (license.offline) {
<i class="tb-license-offline" [matTooltip]="'subscription.offline-mode' | translate">
<mat-icon>cloud_off</mat-icon>
</i>
}
</span>
<div class="tb-license-id">
<small>{{ (license.development ? 'home.license.development-mode' : license.perpetual ? 'subscription.perpetual-license' : 'subscription.subscription') | translate }}</small>
<b>{{ license.subscriptionPlanName }}</b>
@if (license.development) {
<span>{{ 'home.license.development-line' | translate }}</span>
} @else if (license.perpetual) {
@if (license.endTs) {
<span>{{ 'subscription.updates-and-support-until' | translate: {date: license.endTs | date: 'd MMMM yyyy'} }}</span>
}
} @else if (license.upcomingInvoiceDate) {
<span [innerHTML]="('subscription.next-charge-and-due-date' | translate: {
total: license.upcomingInvoiceAmountDue | tbCurrency: {short: true},
date: license.upcomingInvoiceDate | date: 'd MMMM',
dueDate: license.endTs | date: 'd MMMM'}) | safe: 'html'"></span>
}
</div>
@if (managed()) {
<div class="tb-license-manage">
<button mat-stroked-button type="button" class="tb-license-button" (click)="manageLicense()">
{{ 'subscription.manage-license' | translate }}
</button>
</div>
}
</div>
<div class="tb-license-body" [class.offer]="offer()">
@if (limitGroups().length) {
<div class="tb-license-limits">
@for (group of limitGroups(); track group.id) {
<div class="tb-license-head"><mat-icon>{{ group.icon }}</mat-icon>{{ group.label | translate }}</div>
@for (row of group.rows; track row.itemType) {
<div class="tb-license-limit" [class]="row.tone">
<span class="tb-license-limit-name">{{ row.label | translate }}</span>
@if (row.max) {
<span class="tb-license-limit-counts" [matTooltip]="'home.license.of-limit' | translate: {percent: row.percent}">
{{ row.used | shortNumber: {roundDown: true} }} / {{ row.max | shortNumber: {roundDown: true} }}
@if (row.tone) {
<span class="tb-home-sr-only">{{ (row.tone === 'critical' ? 'home.license.at-limit' : 'home.license.of-limit') | translate: {percent: row.percent} }}</span>
}
</span>
} @else {
<span class="tb-license-limit-counts none">{{ 'subscription.not-included' | translate }}</span>
}
<span class="tb-license-meter"><i [style.width.%]="row.width"></i></span>
@if (row.action === 'add') {
<button mat-button color="primary" type="button" class="tb-license-button" (click)="limitAction(row)">
<mat-icon>add</mat-icon>{{ row.addLabel | translate }}
</button>
} @else if (row.action === 'upgrade') {
<button mat-button color="primary" type="button" class="tb-license-button" (click)="limitAction(row)">
<mat-icon>arrow_upward</mat-icon>{{ 'subscription.upgrade-plan' | translate }}
</button>
} @else if (row.max) {
<span class="tb-license-pct">{{ row.percent }}%</span>
} @else {
<span class="tb-license-pct"></span>
}
</div>
}
}
</div>
}
@switch (offer()) {
@case ('pe-pack') {
<div class="tb-license-pack">
<div class="tb-license-pack-head">
<img src="/assets/license/tb-pro-mark.svg" alt width="56" height="56">
<div class="tb-license-pack-id">
<b>{{ 'subscription.pe-pack' | translate }}</b>
<span>{{ 'subscription.pe-pack-desc' | translate }}</span>
</div>
<button mat-flat-button color="primary" type="button" class="tb-license-button" (click)="addProfessionalPack()">
{{ 'subscription.add-to-license' | translate }}
</button>
</div>
<ng-container *ngTemplateOutlet="offers; context: {$implicit: pePackOffers}"></ng-container>
</div>
}
@case ('production') {
<div class="tb-license-pack">
<div class="tb-license-pack-head bare">
<div class="tb-license-pack-id">
<b>{{ 'home.license.go-to-production' | translate }}</b>
</div>
<button mat-flat-button color="primary" type="button" class="tb-license-button" (click)="seePlans()">
{{ 'home.license.see-plans' | translate }}
</button>
</div>
<ng-container *ngTemplateOutlet="offers; context: {$implicit: productionOffers}"></ng-container>
</div>
}
@default {
<div class="tb-license-addons-group">
<div class="tb-license-head"><mat-icon>extension</mat-icon>{{ 'subscription.add-ons' | translate }}</div>
<ul class="tb-license-addons">
@for (addon of addons(); track addon.type) {
<li>
<span class="tb-license-addon-name">{{ addon.label | translate }}</span>
@switch (addon.state) {
@case ('included') {
<span class="tb-license-addon-state included"><mat-icon>check_circle</mat-icon>{{ 'subscription.included' | translate }}</span>
}
@case ('add') {
<button mat-button color="primary" type="button" class="tb-license-button" (click)="addonAction(addon)">
<mat-icon>add</mat-icon>{{ 'subscription.add-to-license' | translate }}
</button>
}
@case ('upgrade') {
<button mat-button color="primary" type="button" class="tb-license-button" (click)="addonAction(addon)">
<mat-icon>arrow_upward</mat-icon>{{ 'subscription.upgrade-plan' | translate }}
</button>
}
@case ('not-included') {
<span class="tb-license-addon-state">{{ 'subscription.not-included' | translate }}</span>
}
@default {
<span class="tb-license-addon-state">{{ 'home.license.not-in-license' | translate }}</span>
}
}
</li>
}
</ul>
</div>
}
}
</div>
}
</tb-home-card>
<ng-template #offers let-items>
<ul class="tb-license-pack-grid">
@for (item of items; track item.icon) {
<li>
<mat-icon>{{ item.icon }}</mat-icon>
<span><b>{{ item.title | translate }}</b><small>{{ item.text | translate }}</small></span>
</li>
}
</ul>
</ng-template>

546
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;
}
}

318
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: `<tb-home-card [card]="card"></tb-home-card>`,
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<AppState>)).aiEnabled;
readonly pePackOffers = PE_PACK_OFFERS;
readonly productionOffers = PRODUCTION_OFFERS;
readonly info = signal<SubscriptionInfo | null>(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<LicenseLimitGroup[]>(() => {
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<LicenseAddon[]>(() => {
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<HTMLElement>>(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};
}
}

2
ui-ngx/src/app/modules/home/pages/home-page/home-cards.models.ts

@ -25,7 +25,7 @@ export const HOME_CARDS: Record<HomeCardId, HomeCardDefinition> = {
[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'}
};

18
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",

Loading…
Cancel
Save