Browse Source

Merge pull request #11238 from kalutkaz/fix/homeDashboardsWidget

Fix 'Home dasboards' widget
pull/11294/head
Igor Kulikov 2 years ago
committed by GitHub
parent
commit
f8c66f50b9
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 5
      ui-ngx/src/app/modules/home/components/widget/lib/home-page/recent-dashboards-widget.component.html
  2. 18
      ui-ngx/src/app/modules/home/components/widget/lib/home-page/recent-dashboards-widget.component.ts

5
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 }}
</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>

18
ui-ngx/src/app/modules/home/components/widget/lib/home-page/recent-dashboards-widget.component.ts

@ -21,7 +21,8 @@ import {
Input,
OnDestroy,
OnInit,
QueryList, ViewChild,
QueryList,
ViewChild,
ViewChildren
} from '@angular/core';
import { PageComponent } from '@shared/components/page.component';
@ -29,11 +30,12 @@ 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,
LastVisitedDashboardInfo, StarredDashboardInfo,
LastVisitedDashboardInfo,
StarredDashboardInfo,
UserDashboardAction,
UserDashboardsInfo
} from '@shared/models/user-settings.models';
@ -77,6 +79,8 @@ export class RecentDashboardsWidgetComponent extends PageComponent implements On
hasDashboardsAccess = true;
dirty = false;
public customerId: string;
private isFullscreenMode = getCurrentAuthState(this.store).forceFullscreen;
constructor(protected store: Store<AppState>,
private cd: ChangeDetectorRef,
@ -85,6 +89,9 @@ export class RecentDashboardsWidgetComponent extends PageComponent implements On
}
ngOnInit() {
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 +117,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) {

Loading…
Cancel
Save