Skip to content

Commit 9f00c2f

Browse files
authored
Publish to prod (#88)
1 parent 92e3a65 commit 9f00c2f

4 files changed

Lines changed: 86 additions & 26 deletions

File tree

projects/finance-grid/src/app/finance-grid/finance-grid.component.html

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@
1010
<igx-grid-toolbar-exporter></igx-grid-toolbar-exporter>
1111
</igx-grid-toolbar-actions>
1212
</igx-grid-toolbar>
13-
<igx-column field="id" header="Symbol" width="auto" sortable="true"></igx-column>
14-
<igx-column field="holdingName" header="Asset" [minWidth]="'300px'" sortable="true">
13+
<igx-column field="id" header="Symbol" sortable="true" [width]="'7%'"></igx-column>
14+
<igx-column field="holdingName" header="Asset" sortable="true" [width]="'15%'">
1515
<ng-template igxCell let-cell="cell" let-val>
1616
<div class="assets-container">
1717
<igx-avatar [src]="getPathToImage(val)" [shape]="'rounded'"></igx-avatar>
1818
<span>{{ val }}</span>
1919
</div>
2020
</ng-template>
2121
</igx-column>
22-
<igx-column field="positions" header="Position" sortable="true" [dataType]="'number'" width="auto"></igx-column>
23-
<igx-column field="value.boughtPrice" header="Average Cost/Share" dataType="currency" width="auto" sortable="true"></igx-column>
24-
<igx-column field="value.currentPrice" header="Last Price" [dataType]="'currency'" width="auto" sortable="true"></igx-column>
25-
<igx-column field="dailyPercentageChange" header="Daily Change %" width="auto" dataType="percent" [cellClasses]="profitLossValueClasses" sortable="true">
22+
<igx-column field="positions" header="Position" sortable="true" [dataType]="'number'" [width]="'6%'"></igx-column>
23+
<igx-column field="value.boughtPrice" header="Average Cost/Share" dataType="currency" sortable="true" [width]="'10%'"></igx-column>
24+
<igx-column field="value.currentPrice" header="Last Price" [dataType]="'currency'" sortable="true" [width]="'7%'"></igx-column>
25+
<igx-column field="dailyPercentageChange" header="Daily Change %" dataType="percent" [cellClasses]="profitLossValueClasses" sortable="true" [width]="'10%'">
2626
<ng-template igxCell let-val>
2727
<div class="assets-container">
2828
<div>
@@ -37,8 +37,8 @@
3737
</div>
3838
</ng-template>
3939
</igx-column>
40-
<igx-column field="marketValue" header="Market Value" [dataType]="'currency'" width="auto" sortable="true"></igx-column>
41-
<igx-column field="profitLossValue" header="NET Profit/Loss" width="auto" sortable="true" dataType="currency" [cellClasses]="profitLossValueClasses">
40+
<igx-column field="marketValue" header="Market Value" [dataType]="'currency'" sortable="true" [width]="'5%'"></igx-column>
41+
<igx-column field="profitLossValue" header="NET Profit/Loss" sortable="true" dataType="currency" [width]="'10%'" [cellClasses]="profitLossValueClasses">
4242
<ng-template igxCell let-val>
4343
<div class="assets-container">
4444
<div>
@@ -53,7 +53,7 @@
5353
</div>
5454
</ng-template>
5555
</igx-column>
56-
<igx-column field="profitLossPercentage" header="NET Profit/Loss %" width="auto" sortable="true" dataType="percent" [cellClasses]="profitLossValueClasses">
56+
<igx-column field="profitLossPercentage" header="NET Profit/Loss %" sortable="true" dataType="percent" [width]="'10%'" [cellClasses]="profitLossValueClasses">
5757
<ng-template igxCell let-val>
5858
<div class="assets-container">
5959
<div>
@@ -68,7 +68,7 @@
6868
</div>
6969
</ng-template>
7070
</igx-column>
71-
<igx-column field="allocation" header="Allocation" sortable="true" dataType="percent" [minWidth]="'200px'" width="auto">
71+
<igx-column field="allocation" header="Allocation" sortable="true" dataType="percent" [width]="'10%'">
7272
<ng-template igxCell let-val>
7373
<div class="progress-container">
7474
<div>
@@ -78,7 +78,7 @@
7878
</div>
7979
</ng-template>
8080
</igx-column>
81-
<igx-column field="holdingPeriod" header="Holding Period" sortable="true" width="auto">
81+
<igx-column field="holdingPeriod" header="Holding Period" sortable="true" [width]="'8%'">
8282
<ng-template igxCell let-val> {{ val }} days </ng-template>
8383
</igx-column>
8484
</igx-grid>

projects/fleet-management-grid/src/app/fleet-management-grid/fleet-management-grid.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export class FleetManagementGridComponent implements OnInit {
101101
costPerMeterPeriod: Period.YTD,
102102
fuelCostPeriod: Period.YTD
103103
} */
104-
protected periods: { [vehicleId: string]: { costPerTypePeriod: Period, costPerMeterPeriod: Period, fuelCostPeriod: Period } } = {};
104+
protected periods: { [vehicleId: string]: { costPerTypePeriod: Period, costPerMeterPeriod: Period, fuelCostPeriod: Period } | null } = {};
105105

106106
//driver details for detail overlay
107107
protected driverDetails: DriverDetails = {

projects/sales-grid/src/app/sales-grid/sales-grid.component.html

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@
22
<div class="pivotToolbar igx-grid__tr-pivot">
33
<span class="igx-grid-toolbar__title">Sales Dashboard</span>
44
<div>
5-
<button igxButton="outlined" style="margin-right: 10px;" [igxToggleAction]="viewDropdown">
5+
<button igxButton="contained" style="margin-right: 10px;" [igxToggleAction]="viewDropdown" [igxDropDownItemNavigation]="viewDropdown" [igxTooltipTarget]="configTooltipRef">
66
<igx-icon [name]="'visibility'" [family]="'material'"></igx-icon>
7-
Change View
7+
{{availableConfigs.get(selectedConfig)?.title}}
88
<igx-icon [name]="'arrow_drop_down'" [family]="'default'"></igx-icon>
99
</button>
10-
<button igxButton="outlined" [igxToggleAction]="exportDropdown">
10+
<button igxButton="outlined" [igxToggleAction]="exportDropdown" [igxDropDownItemNavigation]="exportDropdown">
1111
<igx-icon [name]="'file_download'" [family]="'internal_indigo'"></igx-icon>
1212
Export
1313
<igx-icon [name]="'arrow_drop_down'" [family]="'default'"></igx-icon>
1414
</button>
1515
<igx-drop-down #viewDropdown (selectionChanging)="onViewSelection($event)">
16-
<igx-drop-down-item [id]="'brands'"><span>Brands: HM and HM Home</span></igx-drop-down-item>
17-
<igx-drop-down-item [id]="'stores'"><span>Stores: Bulgaria</span></igx-drop-down-item>
16+
@for (configInfo of availableConfigs; track configInfo[0]) {
17+
<igx-drop-down-item [id]="configInfo[0]" [selected]="selectedConfig === configInfo[0]"><span>{{availableConfigs.get(configInfo[0])?.title}}</span></igx-drop-down-item>
18+
}
1819
</igx-drop-down>
1920
<igx-drop-down #exportDropdown (selectionChanging)="onExportSelection($event)">
2021
<igx-drop-down-item [id]="'excel'"><span>Export to Excel</span></igx-drop-down-item>
@@ -42,3 +43,7 @@
4243
</ng-template>
4344
</div>
4445
</div>
46+
47+
<div #configTooltipRef="tooltip" igxTooltip>
48+
Change pivot configuration.
49+
</div>

projects/sales-grid/src/app/sales-grid/sales-grid.component.ts

Lines changed: 64 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,21 @@ import {
2525
FilteringLogic,
2626
IPivotValue,
2727
THEME_TOKEN,
28-
ThemeToken
28+
ThemeToken,
29+
IgxDropDownItemNavigationDirective,
30+
IgxTooltipDirective,
31+
IgxTooltipTargetDirective
2932
} from 'igniteui-angular';
3033
import FLAGS from './data/flags.json'
3134
import SALES_DATA from './data/SalesData.json';
3235

36+
enum PivotViews {
37+
BrandsSeparate = 'brandsOr',
38+
BrandsCombined = 'jeansAnd',
39+
Stores = 'stores'
40+
}
41+
42+
// Custom aggregator to calculate profit value
3343
export class IgxSaleProfitAggregate {
3444
public static totalProfit = (_, data: any[] | undefined) =>
3545
data?.reduce((accumulator, value) => accumulator + (value.Sale - value.Cost), 0) || 0;
@@ -71,7 +81,8 @@ export class IgxSaleProfitAggregate {
7181
@Component({
7282
standalone: true,
7383
selector: 'app-sales-grid',
74-
imports: [CommonModule, IgxPivotGridComponent, IgxPivotDataSelectorComponent, IgxButtonDirective, IgxIconComponent, IgxToggleActionDirective, IgxDropDownComponent, IgxDropDownItemComponent, IgxCellHeaderTemplateDirective],
84+
imports: [CommonModule, IgxPivotGridComponent, IgxPivotDataSelectorComponent, IgxButtonDirective, IgxIconComponent, IgxTooltipDirective, IgxTooltipTargetDirective,
85+
IgxToggleActionDirective, IgxDropDownComponent, IgxDropDownItemComponent, IgxCellHeaderTemplateDirective, IgxDropDownItemNavigationDirective],
7586
templateUrl: './sales-grid.component.html',
7687
providers: [
7788
{
@@ -93,8 +104,9 @@ export class SalesGridComponent {
93104
public currencyPipe = new CurrencyPipe('en-US');
94105
public brandFilter = new FilteringExpressionsTree(FilteringLogic.Or, 'Brand');
95106
public bulgariaCountryFilter = new FilteringExpressionsTree(FilteringLogic.And);
96-
97107
public fileName = 'SalesGridApp';
108+
109+
// #region Various configurations for the grid that can be toggled
98110
public saleValue: IPivotValue = {
99111
enabled: true,
100112
member: 'Sale',
@@ -211,6 +223,44 @@ export class SalesGridComponent {
211223
this.profitValue
212224
]
213225
};
226+
public pivotConfigBrandsCombined: IPivotConfiguration = {
227+
columns: [
228+
{
229+
enabled: true,
230+
memberName: 'Country',
231+
displayName: 'Country'
232+
},
233+
{
234+
enabled: false,
235+
memberName: 'Store',
236+
displayName: 'Store'
237+
},
238+
],
239+
rows: [
240+
new IgxPivotDateDimension({
241+
memberName: 'Date',
242+
displayName: 'All Periods',
243+
enabled: true
244+
},
245+
{
246+
fullDate: true,
247+
quarters: true,
248+
months: false,
249+
})
250+
],
251+
values: [
252+
this.saleValue,
253+
this.profitValue
254+
],
255+
filters: [
256+
{
257+
enabled: true,
258+
memberName: 'Brand',
259+
displayName: 'Brand',
260+
filter: this.brandFilter
261+
},
262+
]
263+
};
214264
public pivotConfigStores: IPivotConfiguration = {
215265
columns: [
216266
new IgxPivotDateDimension({
@@ -251,6 +301,15 @@ export class SalesGridComponent {
251301
}
252302
]
253303
};
304+
// #endregion
305+
306+
public PivotViews = PivotViews;
307+
public selectedConfig = PivotViews.BrandsSeparate;
308+
public availableConfigs = new Map<PivotViews, { title: string, config: IPivotConfiguration}>([
309+
[ PivotViews.BrandsSeparate, { title: 'Brands: HM and HM Home', config: this.pivotConfigBrands} ],
310+
[ PivotViews.BrandsCombined, { title: 'Brands: HM + HM Home', config: this.pivotConfigBrandsCombined} ],
311+
[ PivotViews.Stores, { title: 'Stores: Bulgaria', config: this.pivotConfigStores} ]
312+
]);
254313

255314
public flagsData = FLAGS;
256315
public data: any = SALES_DATA;
@@ -280,12 +339,8 @@ export class SalesGridComponent {
280339
}
281340

282341
public onViewSelection(event: ISelectionEventArgs) {
283-
const newId = event.newSelection.id;
284-
if (newId === 'brands') {
285-
this.pivotGrid.pivotConfiguration = this.pivotConfigBrands;
286-
} else if (newId === 'stores') {
287-
this.pivotGrid.pivotConfiguration = this.pivotConfigStores;
288-
}
342+
this.selectedConfig = <PivotViews>event.newSelection.id;
343+
this.pivotGrid.pivotConfiguration = this.availableConfigs.get(this.selectedConfig)?.config || this.pivotConfigBrands;
289344
}
290345

291346
public onExportSelection(event: ISelectionEventArgs) {

0 commit comments

Comments
 (0)