-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(admin-ui): Allow default dashboard widget widths to be set
Relates to #334
- Loading branch information
1 parent
aa835e8
commit 3e33bbc
Showing
6 changed files
with
107 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/admin-ui/src/lib/dashboard/src/components/dashboard/dashboard.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<div class="clr-row dashboard-row" *ngFor="let row of widgetLayout"> | ||
<div *ngFor="let widget of row" [ngClass]="getClassForWidth(widget.width)"> | ||
<vdr-dashboard-widget *vdrIfPermissions="widget.requiresPermissions || null" [widgetConfig]="widget"></vdr-dashboard-widget> | ||
<vdr-dashboard-widget *vdrIfPermissions="widget.config.requiresPermissions || null" [widgetConfig]="widget.config"></vdr-dashboard-widget> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 12 additions & 6 deletions
18
packages/admin-ui/src/lib/dashboard/src/default-widgets.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,40 @@ | ||
import { APP_INITIALIZER, FactoryProvider } from '@angular/core'; | ||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; | ||
import { DashboardWidgetConfig, DashboardWidgetService, Permission } from '@vendure/admin-ui/core'; | ||
import { | ||
DashboardWidgetConfig, | ||
DashboardWidgetService, | ||
Permission, | ||
WidgetLayoutDefinition, | ||
} from '@vendure/admin-ui/core'; | ||
|
||
import { LatestOrdersWidgetComponent } from './widgets/latest-orders-widget/latest-orders-widget.component'; | ||
import { OrderSummaryWidgetComponent } from './widgets/order-summary-widget/order-summary-widget.component'; | ||
import { TestWidgetComponent } from './widgets/test-widget/test-widget.component'; | ||
import { WelcomeWidgetComponent } from './widgets/welcome-widget/welcome-widget.component'; | ||
|
||
export const DEFAULT_DASHBOARD_WIDGET_LAYOUT = ['welcome', 'orderSummary', 'latestOrders'] as const; | ||
export const DEFAULT_DASHBOARD_WIDGET_LAYOUT: WidgetLayoutDefinition = [ | ||
{ id: 'welcome', width: 12 }, | ||
{ id: 'orderSummary', width: 6 }, | ||
{ id: 'latestOrders', width: 6 }, | ||
]; | ||
|
||
export const DEFAULT_WIDGETS: { [id: string]: DashboardWidgetConfig } = { | ||
welcome: { | ||
loadComponent: () => WelcomeWidgetComponent, | ||
width: 12, | ||
}, | ||
orderSummary: { | ||
title: _('dashboard.orders-summary'), | ||
loadComponent: () => OrderSummaryWidgetComponent, | ||
width: 6, | ||
requiresPermissions: [Permission.ReadOrder], | ||
}, | ||
latestOrders: { | ||
title: _('dashboard.latest-orders'), | ||
loadComponent: () => LatestOrdersWidgetComponent, | ||
width: 6, | ||
supportedWidths: [6, 8, 12], | ||
requiresPermissions: [Permission.ReadOrder], | ||
}, | ||
testWidget: { | ||
title: 'Test Widget', | ||
loadComponent: () => TestWidgetComponent, | ||
width: 4, | ||
}, | ||
}; |