Fixed wrong behavior under customer level

This commit is contained in:
kalytka 2024-07-19 14:48:47 +03:00
parent 90d945cb2c
commit a246b0454c
2 changed files with 22 additions and 13 deletions

View File

@ -48,7 +48,7 @@
{{ 'widgets.recent-dashboards.name' | translate }}
</mat-header-cell>
<mat-cell class="title" *matCellDef="let lastVisitedDashboard">
<a routerLink="/dashboards/{{lastVisitedDashboard.id}}">{{ lastVisitedDashboard.title }}</a>
<a [routerLink]="createDashboardUrl(lastVisitedDashboard.id)">{{ lastVisitedDashboard.title }}</a>
</mat-cell>
</ng-container>
<ng-container matColumnDef="lastVisited">
@ -78,7 +78,7 @@
class="star" [ngClass]="{'starred': dashboard.starred}">{{ dashboard.starred ? 'star' : 'star_border' }}</mat-icon>
</div>
<div class="tb-cell title">
<a routerLink="/dashboards/{{dashboard.id}}">{{ dashboard.title }}</a>
<a [routerLink]="createDashboardUrl(dashboard.id)">{{ dashboard.title }}</a>
</div>
</div>
</div>
@ -87,6 +87,7 @@
subscriptSizing="dynamic"
appearance="outline"
[useIdValue]="false"
[customerId]="customerId"
label=""
placeholder="{{ 'dashboard.select-dashboard' | translate }}"
[(ngModel)]="starredDashboardValue" (ngModelChange)="onStarDashboard($event)"></tb-dashboard-autocomplete>

View File

@ -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<AppState>,
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) {