diff --git a/ui-ngx/src/app/modules/home/home.component.html b/ui-ngx/src/app/modules/home/home.component.html index 440dc09745..46c4435f5e 100644 --- a/ui-ngx/src/app/modules/home/home.component.html +++ b/ui-ngx/src/app/modules/home/home.component.html @@ -118,7 +118,7 @@ - @if (authState.aiEnabled) { + @if (aiAvailable) { } diff --git a/ui-ngx/src/app/modules/home/home.component.ts b/ui-ngx/src/app/modules/home/home.component.ts index 1f1e9b06c7..2ebc079a87 100644 --- a/ui-ngx/src/app/modules/home/home.component.ts +++ b/ui-ngx/src/app/modules/home/home.component.ts @@ -74,6 +74,8 @@ export class HomeComponent extends PageComponent implements AfterViewInit, OnIni private tourService = inject(TourService); + readonly aiAvailable = this.tourService.aiAvailable(); + constructor(protected store: Store, @Inject(WINDOW) private window: Window, private activeComponentService: ActiveComponentService, diff --git a/ui-ngx/src/app/modules/home/pages/home-page/components/devices-activity-home.component.html b/ui-ngx/src/app/modules/home/pages/home-page/components/devices-activity-home.component.html index a7800f0882..f8d917b85d 100644 --- a/ui-ngx/src/app/modules/home/pages/home-page/components/devices-activity-home.component.html +++ b/ui-ngx/src/app/modules/home/pages/home-page/components/devices-activity-home.component.html @@ -7,7 +7,7 @@ {{ 'home.activity.period' | translate }} - @if (loaded() && !empty()) { + @if (loaded() && !empty() && series.length > 1) { } @@ -15,10 +15,10 @@ @if (empty()) {
-
{{ 'home.activity.none' | translate }}
+
{{ (sysAdmin ? 'home.activity.no-messages' : 'home.activity.none') | translate }}
} @else { -
+
@for (series of series; track series.id) {
{{ series.label | translate }}
diff --git a/ui-ngx/src/app/modules/home/pages/home-page/components/devices-activity-home.component.scss b/ui-ngx/src/app/modules/home/pages/home-page/components/devices-activity-home.component.scss index 2112d7619e..f379e7962a 100644 --- a/ui-ngx/src/app/modules/home/pages/home-page/components/devices-activity-home.component.scss +++ b/ui-ngx/src/app/modules/home/pages/home-page/components/devices-activity-home.component.scss @@ -54,3 +54,11 @@ display: block; } } + +.tb-activity-pair.single { + display: block; + + .tb-activity-name { + display: block; + } +} diff --git a/ui-ngx/src/app/modules/home/pages/home-page/components/devices-activity-home.component.ts b/ui-ngx/src/app/modules/home/pages/home-page/components/devices-activity-home.component.ts index c3974c9d5b..6c24cd225f 100644 --- a/ui-ngx/src/app/modules/home/pages/home-page/components/devices-activity-home.component.ts +++ b/ui-ngx/src/app/modules/home/pages/home-page/components/devices-activity-home.component.ts @@ -16,6 +16,10 @@ import { } from '@angular/core'; import { DomSanitizer } from '@angular/platform-browser'; import { TranslateService } from '@ngx-translate/core'; +import { Store } from '@ngrx/store'; +import { AppState } from '@core/core.state'; +import { getCurrentAuthUser } from '@core/auth/auth.selectors'; +import { Authority } from '@shared/models/authority.enum'; import * as echarts from 'echarts/core'; import tinycolor from 'tinycolor2'; import { CallbackDataParams } from 'echarts/types/dist/shared'; @@ -38,7 +42,8 @@ type ActivitySeries = 'devices' | 'messages'; const DAY = 86400000; const DAYS = 30; const LABEL_STEP = 7; -const SCALE_STEPS = [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000]; +const SCALE_STEPS = [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000, + 1e6, 2e6, 5e6, 1e7, 2e7, 5e7, 1e8, 2e8, 5e8, 1e9]; const startOfFirstDay = (now: number): number => { const date = new Date(now - (DAYS - 1) * DAY); @@ -89,9 +94,11 @@ export class DevicesActivityHomeComponent implements AfterViewInit { readonly card = HOME_CARDS[HomeCardId.ACTIVITY]; - readonly series = SERIES; + readonly sysAdmin = getCurrentAuthUser(inject(Store))?.authority === Authority.SYS_ADMIN; - readonly tabOptions: HomeToggleOption[] = SERIES.map(series => ({value: series.id, label: series.label})); + readonly series = this.sysAdmin ? SERIES.filter(series => series.id === 'messages') : SERIES; + + readonly tabOptions: HomeToggleOption[] = this.series.map(series => ({value: series.id, label: series.label})); private telemetryWsService = inject(TelemetryWebsocketService); private zone = inject(NgZone); @@ -101,13 +108,13 @@ export class DevicesActivityHomeComponent implements AfterViewInit { private injector = inject(Injector); private host = inject>(ElementRef); - readonly tab = signal('devices'); + readonly tab = signal(this.series[0].id); private readonly data = signal | null>(null); readonly loaded = computed(() => this.data() !== null); readonly empty = computed(() => { const data = this.data(); - return !!data && SERIES.every(series => !data[series.id].some(point => point[1] > 0)); + return !!data && this.series.every(series => !data[series.id].some(point => point[1] > 0)); }); private readonly devicesChart = viewChild>('devicesChart'); @@ -163,7 +170,7 @@ export class DevicesActivityHomeComponent implements AfterViewInit { this.startTs = startOfFirstDay(this.endTs); this.historyLoaded = false; SERIES.forEach(series => this.raw[series.id].clear()); - const keys = SERIES.map(series => series.key); + const keys = this.series.map(series => series.key); const cmd = new EntityDataCmd(); cmd.query = { entityFilter: {type: AliasFilterType.apiUsageState}, @@ -187,7 +194,7 @@ export class DevicesActivityHomeComponent implements AfterViewInit { subscriber.entityData$.subscribe(update => { const entities = update.data?.data ?? update.update ?? []; entities.forEach(entity => { - SERIES.forEach(series => { + this.series.forEach(series => { (entity.timeseries?.[series.key] ?? []).forEach(value => this.put(series.id, value.ts, value.value)); const latest = entity.latest?.[EntityKeyType.TIME_SERIES]?.[series.key]; if (latest?.ts) { @@ -272,7 +279,7 @@ export class DevicesActivityHomeComponent implements AfterViewInit { } echartsModule.init(); const color = getComputedStyle(this.host.nativeElement).getPropertyValue('--tb-primary-500').trim() || '#305680'; - SERIES.forEach(series => { + this.series.forEach(series => { const element = (series.id === 'devices' ? this.devicesChart() : this.messagesChart())?.nativeElement; if (!element) { return; @@ -343,7 +350,7 @@ export class DevicesActivityHomeComponent implements AfterViewInit { axisLabel: { ...AXIS_LABEL, margin: 8, - formatter: (value: number) => value >= 1000 ? `${value / 1000}k` : `${value}` + formatter: (value: number) => value >= 1e6 ? `${value / 1e6}M` : value >= 1000 ? `${value / 1000}k` : `${value}` } }], series: [{ diff --git a/ui-ngx/src/app/modules/home/pages/home-page/components/get-started-sys-admin-home.component.html b/ui-ngx/src/app/modules/home/pages/home-page/components/get-started-sys-admin-home.component.html new file mode 100644 index 0000000000..a26a4f1c6d --- /dev/null +++ b/ui-ngx/src/app/modules/home/pages/home-page/components/get-started-sys-admin-home.component.html @@ -0,0 +1,84 @@ + + + @if (loaded()) { +
+ +
+
+ @for (group of groups; track group.label) { +
{{ group.label | translate }}
+
    + @for (step of group.steps; track step.key) { + @let stepState = state(step); +
  1. +
    + + +
    + @if (open() === step) { +
    +
    + {{ 'home.get-started.step-of' | translate: {step: number(step), total: total} }} + {{ 'home.get-started-sys-admin.' + step.key + '.title' | translate }} +
    +

    {{ 'home.get-started-sys-admin.' + step.key + '.text' | translate }} + {{ 'home.get-started.guide' | translate }}{{ 'home.dashboards.opens-new-tab' | translate }} +

    +
    + @if (stepState === 'done') { + + {{ 'home.get-started-sys-admin.' + step.key + '.action' | translate }} + } @else { + + {{ 'home.get-started-sys-admin.' + step.key + '.action' | translate }} + } + + @if (!step.needed && stepState !== 'done') { + + } +
    +
    + } +
  2. + } +
+ } +
+ @if (finished()) { +
+ {{ (doneCount() === total ? 'home.get-started-sys-admin.finished' : 'home.get-started-sys-admin.finished-skipped') + | translate: {count: total - doneCount()} }} + +
+ } + } +
diff --git a/ui-ngx/src/app/modules/home/pages/home-page/components/get-started-sys-admin-home.component.scss b/ui-ngx/src/app/modules/home/pages/home-page/components/get-started-sys-admin-home.component.scss new file mode 100644 index 0000000000..c178db33f5 --- /dev/null +++ b/ui-ngx/src/app/modules/home/pages/home-page/components/get-started-sys-admin-home.component.scss @@ -0,0 +1,303 @@ +// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc. +// SPDX-License-Identifier: BUSL-1.1 +@use './home-table'; + +:host { + --tb-home-card-gap: 8px; + --tb-home-card-hideable-top: 20px; + --tb-home-card-hideable-header: 36px; + display: block; + min-width: 0; + container: tb-get-started-sys-admin / inline-size; +} + +.tb-sgs-bar { + height: 4px; + margin-top: -6px; + overflow: hidden; + border-radius: 2px; + background: rgba(0, 0, 0, 0.08); + + > i { + display: block; + height: 100%; + border-radius: 2px; + background: var(--tb-ok, #198038); + } +} + +.tb-sgs-group { + margin: 10px 0 2px; + 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)); + + &:first-child { + margin-top: 0; + } +} + +.tb-sgs-list { + display: grid; + gap: 2px; + margin: 0 -8px; + padding: 0; + list-style: none; + + li { + min-width: 0; + border-radius: 10px; + + &.open { + background: rgba(0, 0, 0, 0.03); + } + } +} + +.tb-sgs-row { + display: flex; + align-items: center; + gap: 10px; + padding: 0 8px; +} + +.tb-sgs-mark { + display: inline-flex; + flex: none; + align-items: center; + justify-content: center; + box-sizing: border-box; + width: 22px; + height: 22px; + border: 1px solid var(--tb-ink-38, rgba(0, 0, 0, 0.38)); + border-radius: 50%; + background: #fff; + font: 500 12px/1 var(--tb-font, Roboto, sans-serif); + color: var(--tb-ink-76, rgba(0, 0, 0, 0.76)); + + .mat-icon { + width: 16px; + height: 16px; + font-size: 16px; + color: inherit; + } +} + +li.done .tb-sgs-mark { + border-color: transparent; + background: var(--tb-ok-tint, rgba(25, 128, 56, 0.08)); + color: var(--tb-ok, #198038); +} + +li.skipped .tb-sgs-mark { + background: rgba(0, 0, 0, 0.05); + color: var(--tb-ink-54, rgba(0, 0, 0, 0.54)); +} + +.tb-sgs-title { + display: flex; + flex: 1; + align-items: center; + justify-content: space-between; + gap: 8px; + min-width: 0; + height: 36px; + margin: 0; + padding: 0; + border: 0; + border-radius: 6px; + background: none; + font: 400 14px/20px var(--tb-font, Roboto, sans-serif); + letter-spacing: 0.2px; + text-align: left; + color: var(--tb-ink, rgba(0, 0, 0, 0.87)); + cursor: pointer; + + &:focus-visible { + outline: 2px solid var(--tb-primary-500); + outline-offset: 2px; + } +} + +.tb-sgs-title-text { + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; +} + +li.open .tb-sgs-title { + font-weight: 500; +} + +li.done:not(.open) .tb-sgs-title { + color: var(--tb-text-secondary, rgba(0, 0, 0, 0.6)); +} + +.tb-sgs-state { + flex: none; + font: 400 12px/16px var(--tb-font, Roboto, sans-serif); + white-space: nowrap; + color: var(--tb-text-secondary, rgba(0, 0, 0, 0.6)); +} + +.tb-sgs-body { + display: grid; + grid-template-columns: minmax(0, 1fr); + gap: 8px; + min-width: 0; + padding: 0 12px 8px 40px; + + p { + margin: 0; + font: 400 13px/18px var(--tb-font, Roboto, sans-serif); + letter-spacing: 0.2px; + color: var(--tb-text-secondary, rgba(0, 0, 0, 0.6)); + } +} + +.tb-sgs-head { + display: none; +} + +.tb-sgs-guide { + border-radius: 4px; + font-weight: 500; + text-decoration: underline; + text-decoration-thickness: 1px; + text-underline-offset: 3px; + text-decoration-color: transparent; + white-space: nowrap; + color: var(--tb-primary-500); + transition: text-decoration-color .15s ease; + + &, &:hover, &:focus, &:active { + border-bottom: none; + } + + &:hover { + text-decoration-color: currentColor; + } + + .mat-icon { + width: 14px; + height: 14px; + margin-left: 2px; + font-size: 14px; + line-height: 14px; + vertical-align: -2px; + } +} + +.tb-sgs-actions { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: 4px 8px; +} + +.tb-sgs-spacer { + flex: 1 1 auto; + min-width: 0; +} + +.tb-sgs-action.mdc-button { + height: 32px; + padding: 0 16px; + border-radius: 4px; +} + +.tb-sgs-action.mat-mdc-outlined-button { + --mdc-outlined-button-outline-color: rgba(0, 0, 0, 0.1); + --mat-outlined-button-outline-color: rgba(0, 0, 0, 0.1); + --mdc-outlined-button-label-text-color: var(--tb-ink-76, rgba(0, 0, 0, 0.76)); + --mat-outlined-button-label-text-color: var(--tb-ink-76, rgba(0, 0, 0, 0.76)); + background: #fff; +} + +.tb-sgs-skip.mat-mdc-button, .tb-sgs-close.mat-mdc-outlined-button { + --mdc-text-button-label-text-color: var(--tb-ink-76, rgba(0, 0, 0, 0.76)); + --mat-text-button-label-text-color: var(--tb-ink-76, rgba(0, 0, 0, 0.76)); + --mdc-outlined-button-label-text-color: var(--tb-ink-76, rgba(0, 0, 0, 0.76)); + --mat-outlined-button-label-text-color: var(--tb-ink-76, rgba(0, 0, 0, 0.76)); + height: 32px; +} + +.tb-sgs-skip.mat-mdc-button { + margin-right: -8px; + padding: 0 8px; +} + +.tb-sgs-finish { + display: flex; + align-items: center; + justify-content: space-between; + gap: 12px; + font: 400 13px/18px var(--tb-font, Roboto, sans-serif); + color: var(--tb-ink-76, rgba(0, 0, 0, 0.76)); +} + +.tb-sgs-close.mat-mdc-outlined-button { + flex: none; + padding: 0 16px; + border-radius: 4px; +} + +@container tb-get-started-sys-admin (min-width: 600px) { + .tb-sgs-steps { + position: relative; + padding-right: 54%; + } + + .tb-sgs-body { + position: absolute; + top: 0; + right: 0; + bottom: 0; + display: flex; + flex-direction: column; + gap: 12px; + box-sizing: border-box; + width: calc(54% - 16px); + padding: 14px 16px; + border-radius: 10px; + background: rgba(0, 0, 0, 0.03); + + p { + max-width: 52ch; + font-size: 14px; + line-height: 22px; + letter-spacing: 0.1px; + } + } + + .tb-sgs-head { + display: flex; + flex-direction: column; + gap: 2px; + } + + .tb-sgs-head-n { + font: 400 12px/16px var(--tb-font, Roboto, sans-serif); + letter-spacing: 0.4px; + color: var(--tb-ink-54, rgba(0, 0, 0, 0.54)); + } + + .tb-sgs-head-t { + font: 500 16px/24px var(--tb-font, Roboto, sans-serif); + color: var(--tb-ink, rgba(0, 0, 0, 0.87)); + } + + .tb-sgs-actions { + margin-top: auto; + padding-top: 4px; + } + + .tb-sgs-action.mdc-button, .tb-sgs-skip.mat-mdc-button { + height: 36px; + } + + li.open .tb-sgs-title-text { + white-space: normal; + } +} diff --git a/ui-ngx/src/app/modules/home/pages/home-page/components/get-started-sys-admin-home.component.ts b/ui-ngx/src/app/modules/home/pages/home-page/components/get-started-sys-admin-home.component.ts new file mode 100644 index 0000000000..3d64af7183 --- /dev/null +++ b/ui-ngx/src/app/modules/home/pages/home-page/components/get-started-sys-admin-home.component.ts @@ -0,0 +1,188 @@ +// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc. +// SPDX-License-Identifier: BUSL-1.1 +import { + ChangeDetectionStrategy, + Component, + computed, + DestroyRef, + ElementRef, + inject, + NgZone, + signal +} from '@angular/core'; +import { Store } from '@ngrx/store'; +import { TranslateService } from '@ngx-translate/core'; +import { of } from 'rxjs'; +import { catchError } from 'rxjs/operators'; +import { AppState } from '@core/core.state'; +import { ActionPreferencesUpdateHomeCards } from '@core/auth/auth.actions'; +import { UserSettingsService } from '@core/http/user-settings.service'; +import { WhiteLabelingService } from '@core/http/white-labeling.service'; +import { TelemetryWebsocketService } from '@core/ws/telemetry-websocket.service'; +import { EntityCountCmd, TelemetrySubscriber } from '@shared/models/telemetry/telemetry.models'; +import { AliasFilterType } from '@shared/models/alias.models'; +import { EntityType } from '@shared/models/entity-type.models'; +import { FeaturesInfo } from '@shared/models/settings.models'; +import { HomeCardId } from '@shared/models/user-settings.models'; +import { HOME_CARDS } from '@home/pages/home-page/home-cards.models'; +import { SysAdminHomeService } from '@home/pages/home-page/sys-admin-home.service'; + +type SysAdminStepKey = 'tenant' | 'email' | 'sms' | 'wl' | '2fa' | 'oauth' | 'slack'; + +export interface SysAdminStep { + key: SysAdminStepKey; + needed: boolean; + link: string; + queryParams?: Record; + guide: string; + feature?: keyof FeaturesInfo; +} + +const STEPS: SysAdminStep[] = [ + {key: 'tenant', needed: true, link: '/tenants', queryParams: {action: 'add'}, guide: 'user-guide/multi-tenancy/'}, + {key: 'email', needed: true, link: '/settings/outgoing-mail', guide: 'user-guide/ui/mail-settings/', feature: 'emailEnabled'}, + {key: 'sms', needed: false, link: '/settings/notifications', guide: 'user-guide/ui/sms-provider-settings/', feature: 'smsEnabled'}, + {key: 'wl', needed: false, link: '/white-labeling/whiteLabel', guide: 'user-guide/white-labeling/', feature: 'whiteLabelingEnabled'}, + {key: '2fa', needed: false, link: '/security-settings/2fa', guide: 'user-guide/security/two-factor-authentication/', + feature: 'twoFaEnabled'}, + {key: 'oauth', needed: false, link: '/security-settings/oauth2', guide: 'user-guide/security/oauth-2-support/', feature: 'oauthEnabled'}, + {key: 'slack', needed: false, link: '/settings/notifications', guide: 'user-guide/ui/slack-settings/', feature: 'notificationEnabled'} +]; + +const LOADING_HEIGHT = 398; +const HEIGHT_KEY = 'tb-home-get-started-sys-admin-height'; + +const storedHeight = (): number => { + try { + return Number(localStorage.getItem(HEIGHT_KEY)) || LOADING_HEIGHT; + } catch { + return LOADING_HEIGHT; + } +}; + +export type StepState = 'done' | 'skipped' | 'todo'; + +@Component({ + selector: 'tb-get-started-sys-admin-home', + templateUrl: './get-started-sys-admin-home.component.html', + styleUrls: ['./get-started-sys-admin-home.component.scss'], + standalone: false, + changeDetection: ChangeDetectionStrategy.OnPush +}) +export class GetStartedSysAdminHomeComponent { + + private readonly card = HOME_CARDS[HomeCardId.GET_STARTED_SYS_ADMIN]; + + readonly total = STEPS.length; + + readonly groups = [ + {label: 'home.get-started-sys-admin.before-tenants', steps: STEPS.filter(step => step.needed)}, + {label: 'home.get-started-sys-admin.when-needed', steps: STEPS.filter(step => !step.needed)} + ]; + + private store = inject(Store); + private translate = inject(TranslateService); + private userSettingsService = inject(UserSettingsService); + private readonly docs = inject(WhiteLabelingService).getDocsUrl(); + + private readonly tenants = signal(null); + private readonly features = signal(null); + private readonly skipped = signal(null); + private readonly selected = signal(null); + + readonly loaded = computed(() => this.tenants() !== null && this.features() !== null && this.skipped() !== null); + + readonly cardDefinition = computed(() => this.loaded() ? this.card : {...this.card, height: storedHeight()}); + + readonly states = computed>(() => { + const features = this.features(); + const skipped = this.skipped() ?? []; + return Object.fromEntries(STEPS.map(step => { + const done = step.key === 'tenant' ? !!this.tenants() : !!features?.[step.feature]; + let state: StepState = 'todo'; + if (done) { + state = 'done'; + } else if (!step.needed && skipped.includes(step.key)) { + state = 'skipped'; + } + return [step.key, state]; + })) as Record; + }); + + readonly doneCount = computed(() => STEPS.filter(step => this.states()[step.key] === 'done').length); + + readonly progress = computed(() => this.doneCount() + ? this.translate.instant('home.get-started-sys-admin.progress', {done: this.doneCount(), total: STEPS.length}) : null); + + readonly finished = computed(() => this.loaded() && STEPS.every(step => ['done', 'skipped'].includes(this.states()[step.key]))); + + readonly open = computed(() => { + const selected = this.selected(); + if (selected === '-') { + return null; + } + return STEPS.find(step => step.key === selected) ?? STEPS.find(step => this.states()[step.key] === 'todo') ?? null; + }); + + readonly tenantCount = computed(() => this.tenants() ?? 0); + + constructor() { + const config = {ignoreErrors: true, ignoreLoading: true}; + inject(SysAdminHomeService).featuresInfo$.subscribe(features => this.features.set(features ?? {} as FeaturesInfo)); + this.userSettingsService.getGettingStarted(config).pipe(catchError(() => of(null))) + .subscribe(settings => this.skipped.set(settings?.skipped ?? [])); + const cmd = new EntityCountCmd(); + cmd.query = {entityFilter: {type: AliasFilterType.entityType, entityType: EntityType.TENANT}}; + const subscriber = new TelemetrySubscriber(inject(TelemetryWebsocketService), inject(NgZone)); + subscriber.subscriptionCommands.push(cmd); + subscriber.entityCount$.subscribe(update => this.tenants.set(update.count ?? 0)); + subscriber.subscribe(); + const host = inject>(ElementRef); + const observer = new ResizeObserver(() => this.rememberHeight(host.nativeElement)); + observer.observe(host.nativeElement); + inject(DestroyRef).onDestroy(() => { + subscriber.unsubscribe(); + observer.disconnect(); + }); + } + + state(step: SysAdminStep): StepState { + return this.states()[step.key]; + } + + number(step: SysAdminStep): number { + return STEPS.indexOf(step) + 1; + } + + docUrl(step: SysAdminStep): string { + return this.docs + step.guide; + } + + toggle(step: SysAdminStep): void { + this.selected.set(this.open() === step ? '-' : step.key); + } + + skip(step: SysAdminStep): void { + const skipped = this.skipped() ?? []; + const next = skipped.includes(step.key) ? skipped.filter(key => key !== step.key) : [...skipped, step.key]; + this.skipped.set(next); + this.selected.set(null); + this.userSettingsService.updateGettingStarted({skipped: next}).subscribe(); + } + + private rememberHeight(element: HTMLElement): void { + const height = Math.round(element.getBoundingClientRect().height); + if (!this.loaded() || !height) { + return; + } + try { + localStorage.setItem(HEIGHT_KEY, String(height)); + } catch { + return; + } + } + + close(): void { + this.store.dispatch(new ActionPreferencesUpdateHomeCards({[HomeCardId.GET_STARTED_SYS_ADMIN]: false})); + } +} diff --git a/ui-ngx/src/app/modules/home/pages/home-page/components/home-card.component.scss b/ui-ngx/src/app/modules/home/pages/home-page/components/home-card.component.scss index 5ace01f3b2..d6d496d07f 100644 --- a/ui-ngx/src/app/modules/home/pages/home-page/components/home-card.component.scss +++ b/ui-ngx/src/app/modules/home/pages/home-page/components/home-card.component.scss @@ -111,7 +111,7 @@ padding-top: var(--tb-home-card-hideable-top, 16px); .tb-home-card-header { - min-height: 32px; + min-height: var(--tb-home-card-hideable-header, 32px); flex-wrap: nowrap; } } 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 new file mode 100644 index 0000000000..e93e0ed20a --- /dev/null +++ b/ui-ngx/src/app/modules/home/pages/home-page/components/install-items-home.component.html @@ -0,0 +1,45 @@ + + + + + add{{ 'home.install.add-tenant' | translate }} + + +
+ @for (item of counts; track item.entityType) { + @let count = item.count(); + @if (item.link && count) { + + {{ item.label | translate }} + {{ count | shortNumber }} + + } @else { +
+ {{ item.label | translate }} + {{ count === null ? '–' : (count | shortNumber) }} +
+ } + } +
+ @if (withFeatures() && features().length) { +
+ {{ 'home.install.features' | translate }} + {{ '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 new file mode 100644 index 0000000000..d7b0b5b934 --- /dev/null +++ b/ui-ngx/src/app/modules/home/pages/home-page/components/install-items-home.component.scss @@ -0,0 +1,157 @@ +// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc. +// SPDX-License-Identifier: BUSL-1.1 +@use './home-tiles'; +@use './home-table'; + +:host { + display: block; + min-width: 0; + container: tb-install-home / inline-size; +} + +.tb-install-add.mat-mdc-button { + &, &:hover, &:focus, &:active { + border-bottom: none; + } + + .mat-icon { + margin-right: 6px; + } +} + +.tb-install-counts { + display: grid; + grid-template-columns: repeat(3, minmax(0, 1fr)); + gap: 8px; + + .tb-home-tile.tb-home-tile { + width: auto; + max-width: none; + height: 60px; + padding: 5px 10px; + text-decoration: none; + + &, &:hover, &:focus, &:active { + border-bottom-style: solid; + } + + &.static { + cursor: default; + + &:hover { + border-color: rgba(0, 0, 0, 0.10); + } + } + + &.zero { + border-style: dashed; + background: transparent; + + &:hover { + border-style: dashed; + } + + .tb-home-tile-label { + color: var(--tb-ink-54, rgba(0, 0, 0, 0.54)); + } + } + } +} + +@container tb-install-home (max-width: 440px) { + .tb-install-counts { + grid-template-columns: repeat(2, minmax(0, 1fr)); + } +} + +.tb-install-head { + display: flex; + align-items: baseline; + justify-content: space-between; + gap: 8px; + margin-top: 4px; + 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)); +} + +.tb-install-head-count { + letter-spacing: 0.25px; + text-transform: none; + font-variant-numeric: tabular-nums; + color: var(--tb-text-secondary, rgba(0, 0, 0, 0.6)); +} + +.tb-install-features { + display: grid; + grid-template-columns: minmax(0, 1fr); + margin: 0 -8px; +} + +.tb-install-feature { + display: flex; + align-items: center; + gap: 12px; + box-sizing: border-box; + min-width: 0; + height: 40px; + padding: 0 8px; + border: none; + border-radius: 6px; + text-decoration: none; + color: var(--tb-ink-76, rgba(0, 0, 0, 0.76)); + + &:hover { + border: none; + background: rgba(0, 0, 0, 0.04); + } + + &:focus-visible { + outline: 2px solid var(--tb-primary-500); + outline-offset: -2px; + } +} + +.tb-install-feature-icon.mat-icon { + flex: none; + width: 20px; + height: 20px; + font-size: 20px; + color: var(--tb-ink-38, rgba(0, 0, 0, 0.38)); +} + +.tb-install-feature.on .tb-install-feature-icon.mat-icon { + color: var(--tb-primary-500); +} + +.tb-install-feature-text { + min-width: 0; + overflow: hidden; + font: 400 14px/20px var(--tb-font, Roboto, sans-serif); + letter-spacing: 0.2px; + white-space: nowrap; + text-overflow: ellipsis; +} + +@container tb-install-home (min-width: 260px) { + .tb-install-features { + grid-template-columns: repeat(2, minmax(0, 1fr)); + column-gap: 12px; + clip-path: inset(1px -8px 0 -8px); + + > .tb-install-feature { + position: relative; + + &::before { + content: ""; + position: absolute; + top: 0; + right: 8px; + left: 8px; + border-top: 1px solid var(--tb-line-soft, rgba(0, 0, 0, 0.05)); + pointer-events: none; + } + } + } +} 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 new file mode 100644 index 0000000000..942576357a --- /dev/null +++ b/ui-ngx/src/app/modules/home/pages/home-page/components/install-items-home.component.ts @@ -0,0 +1,84 @@ +// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc. +// SPDX-License-Identifier: BUSL-1.1 +import { ChangeDetectionStrategy, Component, computed, DestroyRef, inject, input, NgZone, signal, WritableSignal } from '@angular/core'; +import { TelemetryWebsocketService } from '@core/ws/telemetry-websocket.service'; +import { EntityCountCmd, TelemetrySubscriber } from '@shared/models/telemetry/telemetry.models'; +import { AliasFilterType } from '@shared/models/alias.models'; +import { EntityType } from '@shared/models/entity-type.models'; +import { FeaturesInfo } from '@shared/models/settings.models'; +import { HomeCardId } from '@shared/models/user-settings.models'; +import { HOME_CARDS } from '@home/pages/home-page/home-cards.models'; +import { SysAdminHomeService } from '@home/pages/home-page/sys-admin-home.service'; + +interface InstallCount { + label: string; + entityType: EntityType; + link?: string; + count: WritableSignal; +} + +interface InstallFeature { + label: string; + key: keyof FeaturesInfo; + link: string; +} + +const FEATURES: InstallFeature[] = [ + {label: 'home.install.white-labeling', key: 'whiteLabelingEnabled', link: '/white-labeling/whiteLabel'}, + {label: 'home.install.mail-server', key: 'emailEnabled', link: '/settings/outgoing-mail'}, + {label: 'home.install.sms-provider', key: 'smsEnabled', link: '/settings/notifications'}, + {label: 'home.install.slack', key: 'notificationEnabled', link: '/settings/notifications'}, + {label: 'home.install.oauth', key: 'oauthEnabled', link: '/security-settings/oauth2'}, + {label: 'home.install.two-fa', key: 'twoFaEnabled', link: '/security-settings/2fa'} +]; + +@Component({ + selector: 'tb-install-items-home', + templateUrl: './install-items-home.component.html', + styleUrls: ['./install-items-home.component.scss'], + standalone: false, + changeDetection: ChangeDetectionStrategy.OnPush +}) +export class InstallItemsHomeComponent { + + withFeatures = input(true); + + readonly card = HOME_CARDS[HomeCardId.INSTALL_ITEMS]; + + readonly counts: InstallCount[] = [ + {label: 'home.install.tenants', entityType: EntityType.TENANT, link: '/tenants', count: signal(null)}, + {label: 'home.install.tenant-profiles', entityType: EntityType.TENANT_PROFILE, link: '/tenantProfiles', count: signal(null)}, + {label: 'home.install.users', entityType: EntityType.USER, count: signal(null)}, + {label: 'home.install.customers', entityType: EntityType.CUSTOMER, count: signal(null)}, + {label: 'home.install.dashboards', entityType: EntityType.DASHBOARD, count: signal(null)}, + {label: 'home.install.integrations', entityType: EntityType.INTEGRATION, count: signal(null)} + ]; + + private readonly featuresInfo = signal(null); + + readonly features = computed(() => { + const info = this.featuresInfo(); + if (!info) { + return []; + } + return FEATURES.map(feature => ({...feature, on: !!info[feature.key]})); + }); + + readonly configured = computed(() => this.features().filter(feature => feature.on).length); + + constructor() { + inject(SysAdminHomeService).featuresInfo$.subscribe(info => this.featuresInfo.set(info)); + const telemetryWsService = inject(TelemetryWebsocketService); + const zone = inject(NgZone); + const subscribers = this.counts.map(item => { + const cmd = new EntityCountCmd(); + cmd.query = {entityFilter: {type: AliasFilterType.entityType, entityType: item.entityType}}; + const subscriber = new TelemetrySubscriber(telemetryWsService, zone); + subscriber.subscriptionCommands.push(cmd); + subscriber.entityCount$.subscribe(update => item.count.set(update.count ?? 0)); + subscriber.subscribe(); + return subscriber; + }); + inject(DestroyRef).onDestroy(() => subscribers.forEach(subscriber => subscriber.unsubscribe())); + } +} 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 new file mode 100644 index 0000000000..399d7232d3 --- /dev/null +++ b/ui-ngx/src/app/modules/home/pages/home-page/components/license-home.component.ts @@ -0,0 +1,16 @@ +// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc. +// SPDX-License-Identifier: BUSL-1.1 +import { ChangeDetectionStrategy, Component } from '@angular/core'; +import { HomeCardId } from '@shared/models/user-settings.models'; +import { HOME_CARDS } from '@home/pages/home-page/home-cards.models'; + +@Component({ + selector: 'tb-license-home', + template: ``, + standalone: false, + changeDetection: ChangeDetectionStrategy.OnPush +}) +export class LicenseHomeComponent { + + readonly card = HOME_CARDS[HomeCardId.LICENSE]; +} diff --git a/ui-ngx/src/app/modules/home/pages/home-page/components/product-release-home.component.html b/ui-ngx/src/app/modules/home/pages/home-page/components/product-release-home.component.html new file mode 100644 index 0000000000..e20b7a1053 --- /dev/null +++ b/ui-ngx/src/app/modules/home/pages/home-page/components/product-release-home.component.html @@ -0,0 +1,33 @@ + +@if (shown()) { +
+ +
+

{{ 'home.release.title' | translate: {version: update().latestVersion} }}

+

+ {{ 'home.release.read-notes' | translate }} + {{ 'home.release.notes' | translate }} +

+ +
+ +
+} diff --git a/ui-ngx/src/app/modules/home/pages/home-page/components/product-release-home.component.scss b/ui-ngx/src/app/modules/home/pages/home-page/components/product-release-home.component.scss new file mode 100644 index 0000000000..6894c6bde8 --- /dev/null +++ b/ui-ngx/src/app/modules/home/pages/home-page/components/product-release-home.component.scss @@ -0,0 +1,161 @@ +// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc. +// SPDX-License-Identifier: BUSL-1.1 +:host { + display: contents; +} + +.tb-release { + position: relative; + display: flex; + align-items: center; + gap: 16px; + box-sizing: border-box; + min-width: 0; + padding: 20px; + border-radius: 12px; + background: var(--tb-surface, #fff); + box-shadow: var(--tb-home-card-shadow); + font: 400 14px/20px var(--tb-font, Roboto, sans-serif); + letter-spacing: 0.2px; + color: var(--tb-ink, rgba(0, 0, 0, 0.87)); +} + +.tb-release-mark { + position: relative; + display: inline-block; + flex: none; + width: 56px; + height: 56px; + + > img { + display: block; + width: 100%; + height: 100%; + } +} + +.tb-release-badge { + position: absolute; + top: -2px; + right: -2px; + display: flex; + align-items: center; + justify-content: center; + width: 34%; + height: 34%; + border-radius: 50%; + background: var(--tb-primary-500); + box-shadow: 0 0 0 2px var(--tb-surface, #fff); + + .mat-icon { + width: auto; + height: auto; + font-size: 13px; + line-height: 1; + color: var(--tb-surface, #fff); + } +} + +.tb-release-body { + display: flex; + flex: 1; + flex-direction: column; + min-width: 0; +} + +.tb-release-title { + margin: 0; + font: 600 16px/24px var(--tb-font, Roboto, sans-serif); + letter-spacing: 0.15px; + color: var(--tb-ink-76, rgba(0, 0, 0, 0.76)); +} + +.tb-release-line { + margin: 0; + font-size: 14px; + line-height: 20px; + letter-spacing: 0.2px; + color: var(--tb-ink-76, rgba(0, 0, 0, 0.76)); + + a { + font-weight: 500; + white-space: nowrap; + text-decoration: none; + color: var(--tb-ink-76, rgba(0, 0, 0, 0.76)); + border-bottom: 1px solid var(--tb-ink-12, rgba(0, 0, 0, 0.12)); + + &:hover { + color: var(--tb-ink, rgba(0, 0, 0, 0.87)); + border-bottom-color: currentColor; + } + } +} + +.tb-release-actions { + display: flex; + flex: none; + align-items: center; + gap: 4px; + margin-right: -8px; +} + +.tb-release-upgrade.mdc-button { + height: 32px; + padding: 0 16px; + border-radius: 4px; +} + +.tb-release-hide.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-text-secondary, rgba(0, 0, 0, 0.6)); + + .mat-icon { + width: 20px; + height: 20px; + font-size: 20px; + } +} + +.tb-release-phone { + display: none; +} + +@media (max-width: 599px) { + .tb-release { + align-items: flex-start; + gap: 12px; + padding-right: 44px; + } + + .tb-release-mark { + width: 40px; + height: 40px; + + .tb-release-badge .mat-icon { + font-size: 10px; + } + } + + .tb-release-actions { + position: absolute; + top: 8px; + right: 8px; + margin: 0; + + > .tb-release-upgrade { + display: none; + } + } + + .tb-release-phone { + display: flex; + margin-top: 10px; + } +} diff --git a/ui-ngx/src/app/modules/home/pages/home-page/components/product-release-home.component.ts b/ui-ngx/src/app/modules/home/pages/home-page/components/product-release-home.component.ts new file mode 100644 index 0000000000..c9cef6714d --- /dev/null +++ b/ui-ngx/src/app/modules/home/pages/home-page/components/product-release-home.component.ts @@ -0,0 +1,57 @@ +// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc. +// SPDX-License-Identifier: BUSL-1.1 +import { ChangeDetectionStrategy, Component, computed, inject, signal } from '@angular/core'; +import { TranslateService } from '@ngx-translate/core'; +import { AdminService } from '@core/http/admin.service'; +import { ToastNotificationService } from '@core/services/toast-notification.service'; +import { UpdateMessage } from '@shared/models/settings.models'; + +const UNDO_MS = 6000; + +let hiddenVersion: string | null = null; + +@Component({ + selector: 'tb-product-release-home', + templateUrl: './product-release-home.component.html', + styleUrls: ['./product-release-home.component.scss'], + standalone: false, + changeDetection: ChangeDetectionStrategy.OnPush +}) +export class ProductReleaseHomeComponent { + + private translate = inject(TranslateService); + private toast = inject(ToastNotificationService); + + readonly update = signal(null); + + private readonly hidden = signal(hiddenVersion); + + readonly shown = computed(() => { + const update = this.update(); + return !!update?.updateAvailable && this.hidden() !== update.latestVersion; + }); + + constructor() { + inject(AdminService).checkUpdates({ignoreErrors: true, ignoreLoading: true}).subscribe(update => this.update.set(update)); + } + + hide(): void { + const version = this.update().latestVersion; + this.setHidden(version); + this.toast.dispatchNotification({ + message: this.translate.instant('home.release.hidden', {version}), + type: 'info', + duration: UNDO_MS, + horizontalPosition: 'right', + verticalPosition: 'bottom', + panelClass: 'tb-home-toast', + actionLabel: this.translate.instant('home.customize.undo'), + onAction: () => this.setHidden(null) + }); + } + + private setHidden(version: string | null): void { + hiddenVersion = version; + this.hidden.set(version); + } +} diff --git a/ui-ngx/src/app/modules/home/pages/home-page/components/status-line-home.component.scss b/ui-ngx/src/app/modules/home/pages/home-page/components/status-line-home.component.scss index d78ca2a89c..aeba5d4a37 100644 --- a/ui-ngx/src/app/modules/home/pages/home-page/components/status-line-home.component.scss +++ b/ui-ngx/src/app/modules/home/pages/home-page/components/status-line-home.component.scss @@ -63,3 +63,21 @@ .warn .tb-status-dot { background: rgb(246, 103, 22); } + +.tb-status-line-reserved { + min-height: 32px; +} + +.tb-status-line-in { + animation: tb-status-line-in .2s ease both; + + @media (prefers-reduced-motion: reduce) { + animation: none; + } +} + +@keyframes tb-status-line-in { + from { + opacity: 0; + } +} diff --git a/ui-ngx/src/app/modules/home/pages/home-page/components/status-line-home.component.ts b/ui-ngx/src/app/modules/home/pages/home-page/components/status-line-home.component.ts index 5d40dfa850..f98d0a7266 100644 --- a/ui-ngx/src/app/modules/home/pages/home-page/components/status-line-home.component.ts +++ b/ui-ngx/src/app/modules/home/pages/home-page/components/status-line-home.component.ts @@ -1,34 +1,64 @@ // SPDX-FileCopyrightText: Copyright ThingsBoard, Inc. // SPDX-License-Identifier: BUSL-1.1 -import { ChangeDetectionStrategy, Component, computed, DestroyRef, inject, NgZone, signal, WritableSignal } from '@angular/core'; +import { ChangeDetectionStrategy, Component, computed, DestroyRef, effect, inject, NgZone, signal, WritableSignal } from '@angular/core'; import { Router } from '@angular/router'; import { Store } from '@ngrx/store'; import { AppState } from '@core/core.state'; import { getCurrentAuthUser, selectPersistDeviceStateToTelemetry } from '@core/auth/auth.selectors'; import { TelemetryWebsocketService } from '@core/ws/telemetry-websocket.service'; -import { AlarmCountCmd, EntityCountCmd, TelemetrySubscriber } from '@shared/models/telemetry/telemetry.models'; +import { AlarmCountCmd, EntityCountCmd, EntityDataCmd, TelemetrySubscriber } from '@shared/models/telemetry/telemetry.models'; import { AliasFilterType } from '@shared/models/alias.models'; import { EntityType } from '@shared/models/entity-type.models'; import { EntityKeyType, EntityKeyValueType, FilterPredicateType, BooleanOperation, KeyFilter } from '@shared/models/query/query.models'; import { AlarmSearchStatus, AlarmSeverity } from '@shared/models/alarm.models'; import { Authority } from '@shared/models/authority.enum'; import { HomeCardId } from '@shared/models/user-settings.models'; -import { take } from 'rxjs/operators'; +import { AdminService } from '@core/http/admin.service'; +import { SysAdminHomeService } from '@home/pages/home-page/sys-admin-home.service'; +import { TranslateService } from '@ngx-translate/core'; +import { FeaturesInfo } from '@shared/models/settings.models'; +import { SubscriptionInfo } from '@shared/models/subscription.models'; +import { of } from 'rxjs'; +import { catchError, take } from 'rxjs/operators'; type StatusKind = 'crit' | 'warn' | 'ok'; interface StatusPart { key: string; params?: Record; - card?: HomeCardId; + cards?: HomeCardId[]; link?: string; } +type SystemMetric = 'cpu' | 'ram' | 'disk'; + +interface SystemLoad { + metric: SystemMetric; + value: number; + services: string[]; +} + +interface ClusterService { + serviceId: string; + cpuUsage: number; + memoryUsage: number; + discUsage: number; +} + +const SYSTEM_KEYS = ['cpuUsage', 'memoryUsage', 'discUsage', 'clusterMode', 'clusterSystemData']; +const METRIC_KEYS: Record = {cpu: 'cpuUsage', ram: 'memoryUsage', disk: 'discUsage'}; +const METRIC_NAMES: Record = {cpu: 'CPU', ram: 'RAM', disk: 'Disk'}; +const LICENSE_NEAR = 0.85; +const WARN_LOAD = 75; +const CRIT_LOAD = 85; + +const loadLevel = (value: number): StatusKind => value > CRIT_LOAD ? 'crit' : value > WARN_LOAD ? 'warn' : 'ok'; + @Component({ selector: 'tb-status-line-home', template: ` @if (parts().length) { -
+
@for (part of parts(); track part.key; let first = $first) { @if (first) { @@ -38,7 +68,7 @@ interface StatusPart { } } - @if (part.link) { + @if (part.link || part.cards) { {{ part.key | translate: part.params }} } @else { {{ part.key | translate: part.params }} @@ -46,6 +76,8 @@ interface StatusPart { }
+ } @else if (reserve && !resolved()) { + } `, styleUrls: ['./status-line-home.component.scss'], @@ -59,7 +91,20 @@ export class StatusLineHomeComponent { private router = inject(Router); private store = inject(Store); - private readonly customer = getCurrentAuthUser(this.store)?.authority === Authority.CUSTOMER_USER; + private translate = inject(TranslateService); + + private readonly authority = getCurrentAuthUser(this.store)?.authority; + private readonly customer = this.authority === Authority.CUSTOMER_USER; + readonly sysAdmin = this.authority === Authority.SYS_ADMIN; + + private readonly shownKey = `tb-home-status-line:${getCurrentAuthUser(this.store)?.userId}`; + + readonly reserve = this.authority !== Authority.TENANT_ADMIN || this.wasShown(); + + private systemLoad = signal(null); + private subscription = signal(undefined); + private features = signal(undefined); + private tenants = signal(null); private critical = signal(null); private active = signal(null); @@ -68,7 +113,15 @@ export class StatusLineHomeComponent { private subscribers: TelemetrySubscriber[] = []; - readonly parts = computed(() => { + readonly parts = computed(() => this.sysAdmin ? this.sysAdminParts() : this.tenantParts()); + + readonly resolved = computed(() => this.sysAdmin + ? !!this.systemLoad() && this.subscription() !== undefined && this.tenants() !== null + : [this.critical(), this.active(), this.devices(), this.inactive()].every(value => value !== null)); + + readonly kind = computed(() => this.sysAdmin ? this.sysAdminKind() : this.critical() ? 'crit' : this.inactive() ? 'warn' : 'ok'); + + private tenantParts(): StatusPart[] { const critical = this.critical(); const active = this.active(); const devices = this.devices(); @@ -81,23 +134,96 @@ export class StatusLineHomeComponent { } const parts: StatusPart[] = []; if (critical) { - parts.push({key: 'home.status.critical-alarms', params: {count: critical}, card: HomeCardId.ALARMS, link: '/alarms'}); + parts.push({key: 'home.status.critical-alarms', params: {count: critical}, cards: [HomeCardId.ALARMS], link: '/alarms'}); } else if (active) { - parts.push({key: 'home.status.active-alarms', params: {count: active}, card: HomeCardId.ALARMS, link: '/alarms'}); + parts.push({key: 'home.status.active-alarms', params: {count: active}, cards: [HomeCardId.ALARMS], link: '/alarms'}); } else { parts.push({key: 'home.status.no-alarms'}); } if (inactive) { - parts.push({key: 'home.status.inactive-devices', params: {count: inactive}, card: HomeCardId.DEVICES, link: '/entities/devices'}); + parts.push({key: 'home.status.inactive-devices', params: {count: inactive}, cards: [HomeCardId.DEVICES], link: '/entities/devices'}); } else { parts.push({key: devices === 1 ? 'home.status.device-active' : 'home.status.all-devices-active', params: {count: devices}}); } return parts; - }); + } + + private sysAdminParts(): StatusPart[] { + const load = this.systemLoad(); + const subscription = this.subscription(); + const features = this.features(); + const tenants = this.tenants(); + if (!load || subscription === undefined || tenants === null) { + return []; + } + const parts: StatusPart[] = []; + if (loadLevel(load.value) === 'ok') { + parts.push({key: 'home.status.system-ok'}); + } else { + const params = {name: METRIC_NAMES[load.metric], value: Math.round(load.value)}; + if (!load.services.length) { + parts.push({key: 'home.status.system-high', params, cards: [HomeCardId.SYSTEM_STATUS]}); + } else if (load.services.length === 1) { + parts.push({key: 'home.status.system-high-on', params: {...params, service: load.services[0]}, cards: [HomeCardId.SYSTEM_STATUS]}); + } else { + parts.push({key: 'home.status.system-high-services', params: {...params, count: load.services.length}, cards: [HomeCardId.SYSTEM_STATUS]}); + } + } + const near = this.licenseNear(subscription); + if (near.length) { + parts.push({key: 'home.status.license-near', params: {items: near.join(', ')}, cards: [HomeCardId.LICENSE], link: '/license'}); + } + if (!tenants) { + parts.push({key: 'home.status.no-tenants', cards: [HomeCardId.GET_STARTED_SYS_ADMIN], link: '/tenants'}); + } else if (features) { + const off = [features.whiteLabelingEnabled, features.emailEnabled, + features.smsEnabled, features.notificationEnabled, features.oauthEnabled, features.twoFaEnabled].filter(enabled => !enabled).length; + if (off) { + parts.push({key: 'home.status.features-off', params: {count: off}, + cards: [HomeCardId.GET_STARTED_SYS_ADMIN, HomeCardId.INSTALL_ITEMS]}); + } + } + return parts; + } - readonly kind = computed(() => this.critical() ? 'crit' : this.inactive() ? 'warn' : 'ok'); + private sysAdminKind(): StatusKind { + const load = this.systemLoad(); + const level = load ? loadLevel(load.value) : 'ok'; + if (level === 'crit') { + return 'crit'; + } + const subscription = this.subscription(); + return level === 'warn' || (subscription && this.licenseNear(subscription).length) ? 'warn' : 'ok'; + } + + private licenseNear(subscription: SubscriptionInfo | null): string[] { + if (!subscription) { + return []; + } + const items: [string, number, number][] = [ + ['home.status.license-devices', subscription.devicesCount, subscription.maxDevices], + ['home.status.license-assets', subscription.assetsCount, subscription.maxAssets], + ['home.status.license-ai-credits', subscription.usedAiCredits, subscription.maxAiCredits] + ]; + return items.filter(([, used, max]) => max > 0 && (used ?? 0) / max >= LICENSE_NEAR) + .map(([key, used, max]) => this.translate.instant(key, {percent: Math.round(used / max * 100)})); + } constructor() { + inject(DestroyRef).onDestroy(() => this.subscribers.forEach(subscriber => subscriber.unsubscribe())); + effect(() => { + if (this.resolved()) { + this.rememberShown(this.parts().length > 0); + } + }); + if (this.sysAdmin) { + this.watchSysAdmin(); + } else { + this.watchTenant(); + } + } + + private watchTenant(): void { this.store.select(selectPersistDeviceStateToTelemetry).pipe(take(1)).subscribe(persisted => { const activeKeyType = persisted ? EntityKeyType.TIME_SERIES : EntityKeyType.SERVER_ATTRIBUTE; this.countAlarms(this.critical, [AlarmSeverity.CRITICAL]); @@ -113,11 +239,26 @@ export class StatusLineHomeComponent { } }]); }); - inject(DestroyRef).onDestroy(() => this.subscribers.forEach(subscriber => subscriber.unsubscribe())); + } + + private wasShown(): boolean { + try { + return localStorage.getItem(this.shownKey) === '1'; + } catch { + return false; + } + } + + private rememberShown(shown: boolean): void { + try { + localStorage.setItem(this.shownKey, shown ? '1' : '0'); + } catch { + return; + } } open(part: StatusPart): void { - const card = part.card ? document.querySelector(`[data-home-card="${part.card}"]`) : null; + const card = (part.cards ?? []).map(id => document.querySelector(`[data-home-card="${id}"]`)).find(element => !!element); if (card) { card.scrollIntoView({behavior: 'smooth', block: 'center'}); } else if (part.link) { @@ -137,10 +278,74 @@ export class StatusLineHomeComponent { subscriber.subscribe(); } + private watchSysAdmin(): void { + const adminService = inject(AdminService); + const config = {ignoreErrors: true, ignoreLoading: true}; + adminService.getSubscriptionInfo(config).pipe(catchError(() => of(null))).subscribe(info => this.subscription.set(info)); + const sysAdminHome = inject(SysAdminHomeService, {optional: true}); + (sysAdminHome ? sysAdminHome.featuresInfo$ : adminService.getFeaturesInfo(config).pipe(catchError(() => of(null)))) + .subscribe(info => this.features.set(info)); + this.countEntities(this.tenants, EntityType.TENANT); + const keys = SYSTEM_KEYS.map(key => ({type: EntityKeyType.TIME_SERIES, key})); + const cmd = new EntityDataCmd(); + cmd.query = { + entityFilter: {type: AliasFilterType.apiUsageState}, + pageLink: {page: 0, pageSize: 1}, + entityFields: [], + latestValues: keys + }; + cmd.latestCmd = {keys}; + const values: Record = {}; + const subscriber = new TelemetrySubscriber(this.telemetryWsService, this.zone); + subscriber.subscriptionCommands.push(cmd); + this.subscribers.push(subscriber); + subscriber.entityData$.subscribe(update => { + const entity = (update.data?.data ?? update.update ?? [])[0]; + SYSTEM_KEYS.forEach(key => { + const latest = entity?.latest?.[EntityKeyType.TIME_SERIES]?.[key]; + if (latest?.ts) { + values[key] = latest.value; + } + }); + if (entity || update.data) { + this.systemLoad.set(this.toSystemLoad(values)); + } + }); + subscriber.subscribe(); + } + + private toSystemLoad(values: Record): SystemLoad { + const metrics = Object.keys(METRIC_KEYS) as SystemMetric[]; + if (values.clusterMode === 'true' && values.clusterSystemData) { + let services: ClusterService[] = []; + try { + services = JSON.parse(values.clusterSystemData); + } catch { + services = []; + } + if (services.length) { + const loads = metrics.flatMap(metric => services.map(service => + ({metric, value: Number(service[METRIC_KEYS[metric]]) || 0, service: service.serviceId}))); + const worst = loads.reduce((top, load) => load.value > top.value ? load : top); + return { + metric: worst.metric, + value: worst.value, + services: loads.filter(load => load.metric === worst.metric && load.value === worst.value).map(load => load.service) + }; + } + } + return metrics.map(metric => ({metric, value: Number(values[METRIC_KEYS[metric]]) || 0, services: []})) + .reduce((top, load) => load.value > top.value ? load : top); + } + private countDevices(target: WritableSignal, keyFilters?: KeyFilter[]): void { + this.countEntities(target, EntityType.DEVICE, keyFilters); + } + + private countEntities(target: WritableSignal, entityType: EntityType, keyFilters?: KeyFilter[]): void { const cmd = new EntityCountCmd(); cmd.query = { - entityFilter: {type: AliasFilterType.entityType, entityType: EntityType.DEVICE}, + entityFilter: {type: AliasFilterType.entityType, entityType}, keyFilters }; const subscriber = this.subscribe(cmd); diff --git a/ui-ngx/src/app/modules/home/pages/home-page/components/system-status-home.component.ts b/ui-ngx/src/app/modules/home/pages/home-page/components/system-status-home.component.ts new file mode 100644 index 0000000000..dea5e21c67 --- /dev/null +++ b/ui-ngx/src/app/modules/home/pages/home-page/components/system-status-home.component.ts @@ -0,0 +1,16 @@ +// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc. +// SPDX-License-Identifier: BUSL-1.1 +import { ChangeDetectionStrategy, Component } from '@angular/core'; +import { HomeCardId } from '@shared/models/user-settings.models'; +import { HOME_CARDS } from '@home/pages/home-page/home-cards.models'; + +@Component({ + selector: 'tb-system-status-home', + template: ``, + standalone: false, + changeDetection: ChangeDetectionStrategy.OnPush +}) +export class SystemStatusHomeComponent { + + readonly card = HOME_CARDS[HomeCardId.SYSTEM_STATUS]; +} 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 8c8287546f..917a916973 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 @@ -21,7 +21,12 @@ export const HOME_CARDS: Record = { link: '/notification/inbox'}, [HomeCardId.QUICK_LINKS]: {id: HomeCardId.QUICK_LINKS, icon: 'link', name: 'home.cards.quick-links'}, [HomeCardId.USAGE]: {id: HomeCardId.USAGE, icon: 'data_usage', name: 'home.cards.usage', link: '/usage'}, - [HomeCardId.MOBILE_APP]: {id: HomeCardId.MOBILE_APP, icon: 'phone_iphone', name: 'home.cards.mobile-app'} + [HomeCardId.MOBILE_APP]: {id: HomeCardId.MOBILE_APP, icon: 'phone_iphone', name: 'home.cards.mobile-app'}, + [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', height: 304}, + [HomeCardId.LICENSE]: {id: HomeCardId.LICENSE, icon: 'verified', name: 'home.cards.license', link: '/license', height: 398}, + [HomeCardId.INSTALL_ITEMS]: {id: HomeCardId.INSTALL_ITEMS, icon: 'domain', name: 'home.cards.install-items'} }; export const isHomeCardShown = (settings: HomeCardsSettings, id: HomeCardId): boolean => settings?.[id] !== false; diff --git a/ui-ngx/src/app/modules/home/pages/home-page/home-page-routing.module.ts b/ui-ngx/src/app/modules/home/pages/home-page/home-page-routing.module.ts index 0d687f671f..fcde0b2081 100644 --- a/ui-ngx/src/app/modules/home/pages/home-page/home-page-routing.module.ts +++ b/ui-ngx/src/app/modules/home/pages/home-page/home-page-routing.module.ts @@ -9,89 +9,14 @@ import { Authority } from '@shared/models/authority.enum'; import { mergeMap, Observable, of } from 'rxjs'; import { HomeDashboard } from '@shared/models/dashboard.models'; import { DashboardService } from '@core/http/dashboard.service'; -import { select, Store } from '@ngrx/store'; -import { AppState } from '@core/core.state'; import { catchError, first, map } from 'rxjs/operators'; -import { - getCurrentAuthUser, - selectHomeDashboardParams, - selectMobileQrEnabled, - selectPersistDeviceStateToTelemetry -} from '@core/auth/auth.selectors'; -import { EntityKeyType } from '@shared/models/query/query.models'; -import { ResourcesService } from '@core/services/resources.service'; -import { isDefinedAndNotNull } from '@core/utils'; import { MenuId } from '@core/services/menu.models'; import { MenuService } from '@core/services/menu.service'; -const sysAdminHomePageJson = '/assets/dashboard/sys_admin_home_page.json'; -// const customerUserHomePageJson = '/assets/dashboard/customer_user_home_page.json'; - -const getHomeDashboard = (store: Store, resourcesService: ResourcesService) => { - const authority = getCurrentAuthUser(store).authority; - switch (authority) { - case Authority.SYS_ADMIN: - return applySystemParametersToHomeDashboard(store, resourcesService.loadJsonResource(sysAdminHomePageJson), authority); - // case Authority.CUSTOMER_USER: - // return applySystemParametersToHomeDashboard(store, resourcesService.loadJsonResource(customerUserHomePageJson), authority); - default: - return of(null); - } -}; - -const applySystemParametersToHomeDashboard = (store: Store, - dashboard$: Observable, - authority: Authority): Observable => { - let selectParams$: Observable<{persistDeviceStateToTelemetry?: boolean; mobileQrEnabled?: boolean}>; - switch (authority) { - case Authority.SYS_ADMIN: - selectParams$ = store.pipe( - select(selectMobileQrEnabled), - map(mobileQrEnabled => ({mobileQrEnabled})) - ); - break; - case Authority.TENANT_ADMIN: - selectParams$ = store.pipe(select(selectHomeDashboardParams)); - break; - case Authority.CUSTOMER_USER: - selectParams$ = store.pipe( - select(selectPersistDeviceStateToTelemetry), - map(persistDeviceStateToTelemetry => ({persistDeviceStateToTelemetry})) - ); - break; - } - return selectParams$.pipe( - mergeMap((params) => dashboard$.pipe( - map((dashboard) => { - if (params.persistDeviceStateToTelemetry) { - for (const filterId of Object.keys(dashboard.configuration.filters)) { - if (['Active Devices', 'Inactive Devices'].includes(dashboard.configuration.filters[filterId].filter)) { - dashboard.configuration.filters[filterId].keyFilters[0].key.type = EntityKeyType.TIME_SERIES; - } - } - } - if (isDefinedAndNotNull(params.mobileQrEnabled)) { - for (const widgetId of Object.keys(dashboard.configuration.widgets)) { - if (dashboard.configuration.widgets[widgetId].config.title === 'Select show mobile QR code') { - dashboard.configuration.widgets[widgetId].config.settings.markdownTextFunction = - (dashboard.configuration.widgets[widgetId].config.settings.markdownTextFunction as string) - .replace(/\${mobileQrEnabled:([^}]+)}/, `\${mobileQrEnabled:${String(params.mobileQrEnabled)}}`); - break; - } - } - } - dashboard.hideDashboardToolbar = true; - dashboard.isSystemDashboard = true; - return dashboard; - }) - )) - ); -}; +const getHomeDashboard = (): Observable => of(null); const resolveMenuHomeDashboard = (menuService: MenuService, - dashboardService: DashboardService, - resourcesService: ResourcesService, - store: Store): Observable => + dashboardService: DashboardService): Observable => menuService.menuSections().pipe(first()).pipe( mergeMap((sections) => { const homeSection = sections.find(s => s.id === MenuId.home); @@ -101,36 +26,32 @@ const resolveMenuHomeDashboard = (menuService: MenuService, ...dashboard, hideDashboardToolbar: homeSection.homeHideDashboardToolbar })), - catchError(() => getHomeDashboard(store, resourcesService)) + catchError(() => getHomeDashboard()) ); } else { - return getHomeDashboard(store, resourcesService); + return getHomeDashboard(); } }) ); const resolveHomeDashboard = (menuService: MenuService, - dashboardService: DashboardService, - resourcesService: ResourcesService, - store: Store): Observable => + dashboardService: DashboardService): Observable => dashboardService.getHomeDashboard().pipe( mergeMap((dashboard) => { if (!dashboard) { - return resolveMenuHomeDashboard(menuService, dashboardService, resourcesService, store); + return resolveMenuHomeDashboard(menuService, dashboardService); } return of(dashboard); }), - catchError(() => resolveMenuHomeDashboard(menuService, dashboardService, resourcesService, store)) + catchError(() => resolveMenuHomeDashboard(menuService, dashboardService)) ); export const homeDashboardResolver: ResolveFn = ( _route: ActivatedRouteSnapshot, _state: RouterStateSnapshot, menuService = inject(MenuService), - dashboardService = inject(DashboardService), - resourcesService = inject(ResourcesService), - store: Store = inject(Store) -): Observable => resolveHomeDashboard(menuService, dashboardService, resourcesService, store); + dashboardService = inject(DashboardService) +): Observable => resolveHomeDashboard(menuService, dashboardService); const routes: Routes = [ { diff --git a/ui-ngx/src/app/modules/home/pages/home-page/home-page.module.ts b/ui-ngx/src/app/modules/home/pages/home-page/home-page.module.ts index 55c335e375..83ecf431a6 100644 --- a/ui-ngx/src/app/modules/home/pages/home-page/home-page.module.ts +++ b/ui-ngx/src/app/modules/home/pages/home-page/home-page.module.ts @@ -34,6 +34,11 @@ import { HomeHscrollComponent } from '@home/pages/home-page/components/home-hscr import { HomeToggleComponent } from '@home/pages/home-page/components/home-toggle.component'; import { HomeListFooterComponent } from '@home/pages/home-page/components/home-list-footer.component'; import { AiStartHomeComponent } from '@home/pages/home-page/components/ai-start-home.component'; +import { ProductReleaseHomeComponent } from '@home/pages/home-page/components/product-release-home.component'; +import { GetStartedSysAdminHomeComponent } from '@home/pages/home-page/components/get-started-sys-admin-home.component'; +import { SystemStatusHomeComponent } from '@home/pages/home-page/components/system-status-home.component'; +import { LicenseHomeComponent } from '@home/pages/home-page/components/license-home.component'; +import { InstallItemsHomeComponent } from '@home/pages/home-page/components/install-items-home.component'; import { AiModule } from '@home/components/ai/ai.module'; @NgModule({ @@ -64,7 +69,12 @@ import { AiModule } from '@home/components/ai/ai.module'; HomeHscrollComponent, HomeToggleComponent, HomeListFooterComponent, - AiStartHomeComponent + AiStartHomeComponent, + ProductReleaseHomeComponent, + GetStartedSysAdminHomeComponent, + SystemStatusHomeComponent, + LicenseHomeComponent, + InstallItemsHomeComponent ], imports: [ CommonModule, diff --git a/ui-ngx/src/app/modules/home/pages/home-page/pages/sys-admin-home.component.ts b/ui-ngx/src/app/modules/home/pages/home-page/pages/sys-admin-home.component.ts index 3d142261a1..2a968387d2 100644 --- a/ui-ngx/src/app/modules/home/pages/home-page/pages/sys-admin-home.component.ts +++ b/ui-ngx/src/app/modules/home/pages/home-page/pages/sys-admin-home.component.ts @@ -1,19 +1,101 @@ // SPDX-FileCopyrightText: Copyright ThingsBoard, Inc. // SPDX-License-Identifier: BUSL-1.1 -import { ChangeDetectionStrategy, Component } from '@angular/core'; +import { ChangeDetectionStrategy, Component, computed, inject } from '@angular/core'; +import { toSignal } from '@angular/core/rxjs-interop'; +import { Store } from '@ngrx/store'; +import { AppState } from '@core/core.state'; +import { selectHomeCards, selectMobileQrEnabled } from '@core/auth/auth.selectors'; +import { HomeCardId } from '@shared/models/user-settings.models'; +import { isHomeCardShown } from '@home/pages/home-page/home-cards.models'; +import { SysAdminHomeService } from '@home/pages/home-page/sys-admin-home.service'; + +const MAIN_CARDS = [HomeCardId.GET_STARTED_SYS_ADMIN, HomeCardId.SYSTEM_STATUS, HomeCardId.LICENSE, HomeCardId.ACTIVITY]; +const SIDE_CARDS = [HomeCardId.NOTIFICATIONS, HomeCardId.INSTALL_ITEMS, HomeCardId.QUICK_LINKS, HomeCardId.MOBILE_APP]; @Component({ selector: 'tb-sys-admin-home', template: ` + + @switch (id) { + @case (HomeCardId.GET_STARTED_SYS_ADMIN) { + + } + @case (HomeCardId.SYSTEM_STATUS) { + + } + @case (HomeCardId.LICENSE) { + + } + @case (HomeCardId.ACTIVITY) { + + } + @case (HomeCardId.NOTIFICATIONS) { + + } + @case (HomeCardId.INSTALL_ITEMS) { + + } + @case (HomeCardId.QUICK_LINKS) { + + } + @case (HomeCardId.MOBILE_APP) { + + } + } +
+ +
+
+
+ + @for (id of mainCards(); track id) { + + } +
+
+ @for (id of sideCards(); track id) { + + } +
+
`, styleUrls: ['./tenant-admin-home.component.scss'], + providers: [SysAdminHomeService], standalone: false, changeDetection: ChangeDetectionStrategy.OnPush }) export class SysAdminHomeComponent { + + readonly HomeCardId = HomeCardId; + + private readonly store = inject(Store); + + private readonly settings = toSignal(this.store.select(selectHomeCards), {initialValue: {}}); + + private readonly mobileQrEnabled = toSignal(this.store.select(selectMobileQrEnabled), {initialValue: false}); + + readonly getStartedShown = computed(() => isHomeCardShown(this.settings(), HomeCardId.GET_STARTED_SYS_ADMIN)); + + readonly cards = computed(() => [...MAIN_CARDS, ...SIDE_CARDS].filter(id => this.available(id))); + + readonly mainCards = computed(() => MAIN_CARDS.filter(id => this.shown(id))); + + readonly sideCards = computed(() => SIDE_CARDS.filter(id => this.shown(id))); + + constructor() { + inject(SysAdminHomeService).featuresInfo$.subscribe(); + } + + private available(id: HomeCardId): boolean { + return id !== HomeCardId.MOBILE_APP || this.mobileQrEnabled(); + } + + private shown(id: HomeCardId): boolean { + return this.available(id) && isHomeCardShown(this.settings(), id); + } } diff --git a/ui-ngx/src/app/modules/home/pages/home-page/quick-links.models.ts b/ui-ngx/src/app/modules/home/pages/home-page/quick-links.models.ts index 3b37aef1ec..a42ef7b564 100644 --- a/ui-ngx/src/app/modules/home/pages/home-page/quick-links.models.ts +++ b/ui-ngx/src/app/modules/home/pages/home-page/quick-links.models.ts @@ -37,7 +37,15 @@ export const defaultQuickLinks = (authority: Authority, docsUrl: string, transla const web = (id: string, name: string, icon: string, link: string) => ({[QUICK_WEB_LINK_PREFIX + id]: {name, icon, link}}); switch (authority) { case Authority.SYS_ADMIN: - return {links: ['tenants', 'tenant_profiles']}; + return { + links: ['getting-started', 'tenant-profiles', 'api', 'widgets-library'].map(id => QUICK_WEB_LINK_PREFIX + id), + webLinks: { + ...web('getting-started', translate('home.quick-links.getting-started'), 'rocket_launch', docsUrl + 'getting-started/'), + ...web('tenant-profiles', translate('home.quick-links.tenant-profiles'), 'account_box', docsUrl + 'user-guide/tenant-profiles/'), + ...web('api', translate('home.quick-links.api'), 'api', docsUrl + 'apis-and-sdks/'), + ...web('widgets-library', translate('home.quick-links.widgets-library'), 'widgets', docsUrl + 'reference/widgets/widget-library/') + } + }; case Authority.CUSTOMER_USER: return { links: ['assets', 'entity_views', 'notification_inbox', QUICK_WEB_LINK_PREFIX + 'user-guide'], diff --git a/ui-ngx/src/app/modules/home/pages/home-page/sys-admin-home.service.ts b/ui-ngx/src/app/modules/home/pages/home-page/sys-admin-home.service.ts new file mode 100644 index 0000000000..ac793a1bab --- /dev/null +++ b/ui-ngx/src/app/modules/home/pages/home-page/sys-admin-home.service.ts @@ -0,0 +1,16 @@ +// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc. +// SPDX-License-Identifier: BUSL-1.1 +import { inject, Injectable } from '@angular/core'; +import { Observable, of } from 'rxjs'; +import { catchError, shareReplay } from 'rxjs/operators'; +import { AdminService } from '@core/http/admin.service'; +import { FeaturesInfo } from '@shared/models/settings.models'; + +@Injectable() +export class SysAdminHomeService { + + readonly featuresInfo$: Observable = inject(AdminService).getFeaturesInfo({ignoreErrors: true, ignoreLoading: true}).pipe( + catchError(() => of(null)), + shareReplay(1) + ); +} diff --git a/ui-ngx/src/app/shared/models/user-settings.models.ts b/ui-ngx/src/app/shared/models/user-settings.models.ts index 735f848c06..ae2a55e322 100644 --- a/ui-ngx/src/app/shared/models/user-settings.models.ts +++ b/ui-ngx/src/app/shared/models/user-settings.models.ts @@ -35,7 +35,12 @@ export enum HomeCardId { NOTIFICATIONS = 'notifications', QUICK_LINKS = 'quickLinks', USAGE = 'usage', - MOBILE_APP = 'mobileApp' + MOBILE_APP = 'mobileApp', + PRODUCT_RELEASE = 'productRelease', + GET_STARTED_SYS_ADMIN = 'getStartedSysAdmin', + SYSTEM_STATUS = 'systemStatus', + LICENSE = 'license', + INSTALL_ITEMS = 'installItems' } export type HomeCardsSettings = Partial>; @@ -72,6 +77,7 @@ export interface QuickLinks { export interface GettingStarted { maxSelectedIndex?: number; lastSelectedIndex?: number; + skipped?: string[]; } export interface AbstractUserDashboardInfo { 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 120238f2ac..bb562e8e10 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -8545,7 +8545,17 @@ "inactive-devices": "{ count, plural, =1 {1 device inactive} other {# devices inactive} }", "device-active": "Device active", "all-devices-active": "All {{count}} devices active", - "nothing-assigned": "No devices or dashboards assigned to you yet" + "nothing-assigned": "No devices or dashboards assigned to you yet", + "system-ok": "CPU, RAM and disk under 75%", + "system-high": "{{name}} at {{value}}%", + "system-high-on": "{{name}} at {{value}}% on {{service}}", + "system-high-services": "{{name}} at {{value}}% on {{count}} services", + "license-near": "License: {{items}}", + "license-devices": "devices {{percent}}%", + "license-assets": "assets {{percent}}%", + "license-ai-credits": "AI credits {{percent}}%", + "no-tenants": "No tenants yet", + "features-off": "{ count, plural, =1 {1 feature not configured} other {# features not configured} }" }, "greeting": { "morning": "Good morning", @@ -8565,7 +8575,11 @@ "notifications": "Notifications", "quick-links": "Quick links", "usage": "Usage", - "mobile-app": "Mobile app" + "mobile-app": "Mobile app", + "product-release": "Product release", + "system-status": "System", + "license": "License", + "install-items": "Install" }, "alarms": { "whose": "Whose alarms", @@ -8661,7 +8675,8 @@ "devices": "Active devices", "messages": "Messages", "today": "Today", - "none": "No activity yet" + "none": "No activity yet", + "no-messages": "No messages from devices yet" }, "get-started": { "progress": "{{done}} of {{total}}", @@ -8723,6 +8738,10 @@ "opens-new-tab": "(opens in a new tab)", "documentation": "Documentation", "user-guide": "User guide", + "getting-started": "Getting started", + "tenant-profiles": "Tenant profiles", + "api": "API", + "widgets-library": "Widgets library", "add-title": "Add quick link", "edit-web-link": "Edit web link", "link-type": "Link type", @@ -8757,6 +8776,81 @@ "download-on-the": "Download on the", "get-it-on": "Get it on" }, + "release": { + "available": "Update available", + "title": "ThingsBoard {{version}} is available", + "read-notes": "Read the release notes before upgrading.", + "notes": "Release notes", + "upgrade": "Upgrade", + "hide": "Hide", + "hidden": "{{version}} hidden" + }, + "get-started-sys-admin": { + "before-tenants": "Before tenants sign in", + "when-needed": "When you need them", + "progress": "{{done}} of {{total}}", + "tenants": "{ count, plural, =1 {1 tenant} other {# tenants} }", + "configured": "Configured", + "skipped": "Skipped", + "skip": "Skip", + "undo-skip": "Undo skip", + "finished": "Every step is done. Install's Features takes this place.", + "finished-skipped": "{{count}} skipped. Install's Features takes this place; each stays there to set up.", + "tenant": { + "title": "Create a tenant and its administrator", + "text": "A tenant owns devices and assets; its administrators create and manage its devices, assets, customers and dashboards.", + "action": "Add tenant" + }, + "email": { + "title": "Mail server", + "text": "Mail server configuration is essential for user activation, password recovery, and alarm notification delivery.", + "action": "Open Mail server" + }, + "sms": { + "title": "SMS provider", + "text": "Configure SMS providers to notify the customers about the alarms via SMS.", + "action": "Open Notifications settings" + }, + "wl": { + "title": "White labeling", + "text": "Customize your company's or product's logo and color scheme without coding and without restarting the service.", + "action": "Open White labeling" + }, + "2fa": { + "title": "Two-factor authentication (2FA)", + "text": "Improve security of the platform accounts with two-factor authentication.", + "action": "Open Two-factor authentication" + }, + "oauth": { + "title": "OAuth 2.0 single sign-on", + "text": "Simplify login for the tenant and customer users with Single Sign-On functionality via OAuth 2.0.", + "action": "Open OAuth 2.0" + }, + "slack": { + "title": "Slack", + "text": "Distribute notifications to the tenant and customer users via Slack according to the notification rules you set.", + "action": "Open Notifications settings" + } + }, + "install": { + "add-tenant": "Add tenant", + "tenants": "Tenants", + "tenant-profiles": "Tenant profiles", + "users": "Users", + "customers": "Customers", + "dashboards": "Dashboards", + "integrations": "Integrations", + "features": "Features", + "features-count": "{{on}} of {{total}}", + "white-labeling": "White labeling", + "mail-server": "Mail server", + "sms-provider": "SMS provider", + "slack": "Slack", + "oauth": "OAuth 2.0", + "two-fa": "2FA", + "configured": "configured", + "not-configured": "not configured" + }, "list": { "show-more": "Show more", "show-all": "Show all",