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 }} {{ 'widgets.recent-dashboards.name' | translate }}
</mat-header-cell> </mat-header-cell>
<mat-cell class="title" *matCellDef="let lastVisitedDashboard"> <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> </mat-cell>
</ng-container> </ng-container>
<ng-container matColumnDef="lastVisited"> <ng-container matColumnDef="lastVisited">
@ -78,7 +78,7 @@
class="star" [ngClass]="{'starred': dashboard.starred}">{{ dashboard.starred ? 'star' : 'star_border' }}</mat-icon> class="star" [ngClass]="{'starred': dashboard.starred}">{{ dashboard.starred ? 'star' : 'star_border' }}</mat-icon>
</div> </div>
<div class="tb-cell title"> <div class="tb-cell title">
<a routerLink="/dashboards/{{dashboard.id}}">{{ dashboard.title }}</a> <a [routerLink]="createDashboardUrl(dashboard.id)">{{ dashboard.title }}</a>
</div> </div>
</div> </div>
</div> </div>
@ -87,6 +87,7 @@
subscriptSizing="dynamic" subscriptSizing="dynamic"
appearance="outline" appearance="outline"
[useIdValue]="false" [useIdValue]="false"
[customerId]="customerId"
label="" label=""
placeholder="{{ 'dashboard.select-dashboard' | translate }}" placeholder="{{ 'dashboard.select-dashboard' | translate }}"
[(ngModel)]="starredDashboardValue" (ngModelChange)="onStarDashboard($event)"></tb-dashboard-autocomplete> [(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, Input,
OnDestroy, OnDestroy,
OnInit, OnInit,
QueryList, ViewChild, QueryList,
ViewChild,
ViewChildren ViewChildren
} from '@angular/core'; } from '@angular/core';
import { PageComponent } from '@shared/components/page.component'; import { PageComponent } from '@shared/components/page.component';
@ -29,11 +30,12 @@ import { Store } from '@ngrx/store';
import { AppState } from '@core/core.state'; import { AppState } from '@core/core.state';
import { Authority } from '@shared/models/authority.enum'; import { Authority } from '@shared/models/authority.enum';
import { BehaviorSubject, Observable, of } from 'rxjs'; 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 { WidgetContext } from '@home/models/widget-component.models';
import { import {
AbstractUserDashboardInfo, AbstractUserDashboardInfo,
LastVisitedDashboardInfo, StarredDashboardInfo, LastVisitedDashboardInfo,
StarredDashboardInfo,
UserDashboardAction, UserDashboardAction,
UserDashboardsInfo UserDashboardsInfo
} from '@shared/models/user-settings.models'; } from '@shared/models/user-settings.models';
@ -77,6 +79,8 @@ export class RecentDashboardsWidgetComponent extends PageComponent implements On
hasDashboardsAccess = true; hasDashboardsAccess = true;
dirty = false; dirty = false;
public customerId: string;
private isFullscreenMode = getCurrentAuthState(this.store).forceFullscreen;
constructor(protected store: Store<AppState>, constructor(protected store: Store<AppState>,
private cd: ChangeDetectorRef, private cd: ChangeDetectorRef,
@ -85,6 +89,9 @@ export class RecentDashboardsWidgetComponent extends PageComponent implements On
} }
ngOnInit() { 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); this.hasDashboardsAccess = [Authority.TENANT_ADMIN, Authority.CUSTOMER_USER].includes(this.authUser.authority);
if (this.hasDashboardsAccess) { if (this.hasDashboardsAccess) {
this.reload(); 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') { toggleValueChange(value: 'last' | 'starred') {
this.toggleValue = value; this.toggleValue = value;
if (this.dirty) { if (this.dirty) {

Loading…
Cancel
Save