From a246b0454c3c75b9f34e270641537233067a6f3a Mon Sep 17 00:00:00 2001 From: kalytka Date: Fri, 19 Jul 2024 14:48:47 +0300 Subject: [PATCH 1/3] Fixed wrong behavior under customer level --- .../recent-dashboards-widget.component.html | 5 ++-- .../recent-dashboards-widget.component.ts | 30 ++++++++++++------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/home-page/recent-dashboards-widget.component.html b/ui-ngx/src/app/modules/home/components/widget/lib/home-page/recent-dashboards-widget.component.html index 7ec7562d31..72b5d8a7f9 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/home-page/recent-dashboards-widget.component.html +++ b/ui-ngx/src/app/modules/home/components/widget/lib/home-page/recent-dashboards-widget.component.html @@ -48,7 +48,7 @@ {{ 'widgets.recent-dashboards.name' | translate }} - {{ lastVisitedDashboard.title }} + {{ lastVisitedDashboard.title }} @@ -78,7 +78,7 @@ class="star" [ngClass]="{'starred': dashboard.starred}">{{ dashboard.starred ? 'star' : 'star_border' }} @@ -87,6 +87,7 @@ subscriptSizing="dynamic" appearance="outline" [useIdValue]="false" + [customerId]="customerId" label="" placeholder="{{ 'dashboard.select-dashboard' | translate }}" [(ngModel)]="starredDashboardValue" (ngModelChange)="onStarDashboard($event)"> diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/home-page/recent-dashboards-widget.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/home-page/recent-dashboards-widget.component.ts index 69b2230e25..cff11c349a 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/home-page/recent-dashboards-widget.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/home-page/recent-dashboards-widget.component.ts @@ -14,16 +14,7 @@ /// limitations under the License. /// -import { - AfterViewInit, - ChangeDetectorRef, - Component, - Input, - OnDestroy, - OnInit, - QueryList, ViewChild, - ViewChildren -} from '@angular/core'; +import { AfterViewInit, ChangeDetectorRef, Component, Input, OnDestroy, OnInit, QueryList, ViewChild, ViewChildren } from '@angular/core'; import { PageComponent } from '@shared/components/page.component'; import { Store } from '@ngrx/store'; import { AppState } from '@core/core.state'; @@ -33,7 +24,8 @@ import { getCurrentAuthUser } from '@core/auth/auth.selectors'; import { WidgetContext } from '@home/models/widget-component.models'; import { AbstractUserDashboardInfo, - LastVisitedDashboardInfo, StarredDashboardInfo, + LastVisitedDashboardInfo, + StarredDashboardInfo, UserDashboardAction, UserDashboardsInfo } from '@shared/models/user-settings.models'; @@ -46,6 +38,8 @@ import { Direction, SortOrder } from '@shared/models/page/sort-order'; import { MatSort } from '@angular/material/sort'; import { DashboardInfo } from '@shared/models/dashboard.models'; import { DashboardAutocompleteComponent } from '@shared/components/dashboard-autocomplete.component'; +import { UserService } from '@core/http/user.service'; +import { User } from '@shared/models/user.model'; @Component({ selector: 'tb-recent-dashboards-widget', @@ -77,14 +71,23 @@ export class RecentDashboardsWidgetComponent extends PageComponent implements On hasDashboardsAccess = true; dirty = false; + public customerId: string; + private isFullscreenMode = false; constructor(protected store: Store, private cd: ChangeDetectorRef, + private userService: UserService, private userSettingService: UserSettingsService) { super(store); } ngOnInit() { + this.userService.getUser(this.authUser.userId).subscribe((userInfo: User) => { + this.isFullscreenMode = userInfo.additionalInfo.defaultDashboardFullscreen; + }); + if (this.authUser.authority === Authority.CUSTOMER_USER) { + this.customerId = this.authUser.customerId; + } this.hasDashboardsAccess = [Authority.TENANT_ADMIN, Authority.CUSTOMER_USER].includes(this.authUser.authority); if (this.hasDashboardsAccess) { this.reload(); @@ -110,6 +113,11 @@ export class RecentDashboardsWidgetComponent extends PageComponent implements On ); } + public createDashboardUrl(id: string): string { + const baseUrl = this.isFullscreenMode ? '/dashboard/' : '/dashboards/'; + return baseUrl + id; + } + toggleValueChange(value: 'last' | 'starred') { this.toggleValue = value; if (this.dirty) { From 5229efb6ceed7e46c6a045b98a623ef7d2dff7e5 Mon Sep 17 00:00:00 2001 From: kalytka Date: Fri, 19 Jul 2024 15:49:16 +0300 Subject: [PATCH 2/3] Refactoring --- .../home-page/recent-dashboards-widget.component.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/home-page/recent-dashboards-widget.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/home-page/recent-dashboards-widget.component.ts index cff11c349a..76eef3f9b2 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/home-page/recent-dashboards-widget.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/home-page/recent-dashboards-widget.component.ts @@ -14,7 +14,17 @@ /// limitations under the License. /// -import { AfterViewInit, ChangeDetectorRef, Component, Input, OnDestroy, OnInit, QueryList, ViewChild, ViewChildren } from '@angular/core'; +import { + AfterViewInit, + ChangeDetectorRef, + Component, + Input, + OnDestroy, + OnInit, + QueryList, + ViewChild, + ViewChildren +} from '@angular/core'; import { PageComponent } from '@shared/components/page.component'; import { Store } from '@ngrx/store'; import { AppState } from '@core/core.state'; From 5eb7b502da31fb46aa3eed40617f65b68a29a04c Mon Sep 17 00:00:00 2001 From: kalytka Date: Mon, 22 Jul 2024 10:50:21 +0300 Subject: [PATCH 3/3] Updated fulscreen logic --- .../home-page/recent-dashboards-widget.component.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/home-page/recent-dashboards-widget.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/home-page/recent-dashboards-widget.component.ts index 76eef3f9b2..9ec876ffd6 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/home-page/recent-dashboards-widget.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/home-page/recent-dashboards-widget.component.ts @@ -30,7 +30,7 @@ import { Store } from '@ngrx/store'; import { AppState } from '@core/core.state'; import { Authority } from '@shared/models/authority.enum'; import { BehaviorSubject, Observable, of } from 'rxjs'; -import { getCurrentAuthUser } from '@core/auth/auth.selectors'; +import { getCurrentAuthState, getCurrentAuthUser } from '@core/auth/auth.selectors'; import { WidgetContext } from '@home/models/widget-component.models'; import { AbstractUserDashboardInfo, @@ -48,8 +48,6 @@ import { Direction, SortOrder } from '@shared/models/page/sort-order'; import { MatSort } from '@angular/material/sort'; import { DashboardInfo } from '@shared/models/dashboard.models'; import { DashboardAutocompleteComponent } from '@shared/components/dashboard-autocomplete.component'; -import { UserService } from '@core/http/user.service'; -import { User } from '@shared/models/user.model'; @Component({ selector: 'tb-recent-dashboards-widget', @@ -82,19 +80,15 @@ export class RecentDashboardsWidgetComponent extends PageComponent implements On dirty = false; public customerId: string; - private isFullscreenMode = false; + private isFullscreenMode = getCurrentAuthState(this.store).forceFullscreen; constructor(protected store: Store, private cd: ChangeDetectorRef, - private userService: UserService, private userSettingService: UserSettingsService) { super(store); } ngOnInit() { - this.userService.getUser(this.authUser.userId).subscribe((userInfo: User) => { - this.isFullscreenMode = userInfo.additionalInfo.defaultDashboardFullscreen; - }); if (this.authUser.authority === Authority.CUSTOMER_USER) { this.customerId = this.authUser.customerId; }