forked from akveo/ngx-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from denStrigo/ecommerce-dashboard-orders-profi…
…t-card feat(ecommerce): add order chart, add profit chart template
- Loading branch information
Showing
14 changed files
with
773 additions
and
124 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
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
20 changes: 20 additions & 0 deletions
20
src/app/pages/ec-dashboard/charts-panel/charts-header/charts-header.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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<div class="chart-header"> | ||
<div class="legends"> | ||
<div *ngFor="let legend of chartLegend" class="legend"> | ||
<div class="legend-item-color" [ngClass]="legend.styleClass"></div> | ||
<div class="legend-title">{{ legend.title }}</div> | ||
</div> | ||
</div> | ||
|
||
<div class="dropdown" | ||
[ngClass]="{ 'ghost-dropdown': currentTheme === 'corporate' }" | ||
ngbDropdown> | ||
<button type="button" ngbDropdownToggle class="btn" | ||
[ngClass]="{ 'btn-outline-success': currentTheme == 'default', 'btn-primary': currentTheme != 'default'}"> | ||
{{ type }} | ||
</button> | ||
<ul class="dropdown-menu" ngbDropdownMenu> | ||
<li class="dropdown-item" *ngFor="let period of types" (click)="changePeriod(period)">{{ period }}</li> | ||
</ul> | ||
</div> | ||
</div> |
60 changes: 60 additions & 0 deletions
60
src/app/pages/ec-dashboard/charts-panel/charts-header/charts-header.component.scss
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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
@import '../../../../@theme/styles/themes'; | ||
|
||
$legend-all-orders-color: #00977e; | ||
$legend-payment-color: #6935ca; | ||
$legend-canceled-color: #3f4fda; | ||
|
||
@include nb-install-component() { | ||
|
||
.chart-header { | ||
display: flex; | ||
justify-content: space-between; | ||
margin-bottom: 2.125rem; | ||
} | ||
|
||
.legends { | ||
display: flex; | ||
color: nb-theme(color-fg); | ||
padding: 0 1.5rem; | ||
margin-left: 1.25rem; | ||
} | ||
|
||
.legend { | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
margin-left: 4rem; | ||
|
||
&:first-child { | ||
margin-left: 0; | ||
} | ||
} | ||
|
||
.legend-item-color { | ||
height: 0.875rem; | ||
width: 0.875rem; | ||
|
||
&.legend-all-orders { | ||
box-shadow: 0 3px 0 $legend-all-orders-color; | ||
background: linear-gradient(90deg, #00c7c7 0%, #00d977 100%); | ||
} | ||
|
||
&.legend-payment { | ||
box-shadow: 0 3px 0 $legend-payment-color; | ||
background: linear-gradient(90deg, #a454ff 0%, #7659ff 100%); | ||
} | ||
|
||
&.legend-canceled { | ||
box-shadow: 0 3px 0 $legend-canceled-color; | ||
background: linear-gradient(90deg, #0088ff 0%, #3dafff 100%); | ||
} | ||
} | ||
|
||
.legend-title { | ||
padding-left: 0.75rem; | ||
} | ||
|
||
.dropdown { | ||
min-width: 8.125rem; | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
src/app/pages/ec-dashboard/charts-panel/charts-header/charts-header.component.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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import {Component, EventEmitter, Input, OnDestroy, Output} from '@angular/core'; | ||
import { NbThemeService } from '@nebular/theme'; | ||
import { takeWhile } from 'rxjs/operators'; | ||
|
||
@Component({ | ||
selector: 'ngx-chart-header', | ||
styleUrls: ['./charts-header.component.scss'], | ||
templateUrl: './charts-header.component.html', | ||
}) | ||
export class ChartsHeaderComponent implements OnDestroy { | ||
private alive = true; | ||
|
||
@Output() periodChange = new EventEmitter<string>(); | ||
|
||
@Input() type: string = 'week'; | ||
types: string[] = ['week', 'month', 'year']; | ||
|
||
chartLegend: {styleClass: string; title: string}[] = [ | ||
{ | ||
styleClass: 'legend-all-orders', | ||
title: 'All orders', | ||
}, | ||
{ | ||
styleClass: 'legend-payment', | ||
title: 'Payment', | ||
}, | ||
{ | ||
styleClass: 'legend-canceled', | ||
title: 'Canceled', | ||
}, | ||
]; | ||
|
||
currentTheme: string; | ||
|
||
constructor(private themeService: NbThemeService) { | ||
this.themeService.getJsTheme() | ||
.pipe(takeWhile(() => this.alive)) | ||
.subscribe(theme => { | ||
this.currentTheme = theme.name; | ||
}); | ||
} | ||
|
||
changePeriod(period: string): void { | ||
this.type = period; | ||
this.periodChange.emit(period); | ||
} | ||
|
||
ngOnDestroy() { | ||
this.alive = false; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/app/pages/ec-dashboard/charts-panel/charts-panel.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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<nb-card size="medium"> | ||
<nb-tabset fullWidth (changeTab)="changeTab($event)"> | ||
<nb-tab tabTitle="Orders"> | ||
<div class="chart-container"> | ||
<ngx-chart-header [type]="period" (periodChange)="setPeriod($event)"></ngx-chart-header> | ||
<ngx-orders-chart #ordersChart [period]="period"></ngx-orders-chart> | ||
</div> | ||
</nb-tab> | ||
<nb-tab tabTitle="Profit" [lazyLoad]="true"> | ||
<div class="chart-container"> | ||
<ngx-chart-header [type]="period" (periodChange)="setPeriod($event)"></ngx-chart-header> | ||
<ngx-profit-chart #profitChart></ngx-profit-chart> | ||
</div> | ||
</nb-tab> | ||
</nb-tabset> | ||
</nb-card> |
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
34 changes: 20 additions & 14 deletions
34
src/app/pages/ec-dashboard/charts-panel/charts-panel.component.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,21 +1,27 @@ | ||
import { Component } from '@angular/core'; | ||
import {Component, ViewChild} from '@angular/core'; | ||
import { OrdersChartComponent } from './charts/orders-chart.component'; | ||
import { ProfitChartComponent } from './charts/profit-chart.component'; | ||
|
||
@Component({ | ||
selector: 'ngx-ec-charts', | ||
styleUrls: ['./charts-panel.component.scss'], | ||
template: ` | ||
<nb-card size="medium"> | ||
<nb-tabset fullWidth> | ||
<nb-tab tabTitle="Orders"> | ||
<ngx-orders-chart></ngx-orders-chart> | ||
</nb-tab> | ||
<nb-tab tabTitle="Profit"> | ||
<ngx-profit-chart></ngx-profit-chart> | ||
</nb-tab> | ||
</nb-tabset> | ||
</nb-card> | ||
`, | ||
templateUrl: './charts-panel.component.html', | ||
}) | ||
export class EcChartsPanelComponent { | ||
period: string = 'week'; | ||
|
||
@ViewChild('ordersChart') ordersChart: OrdersChartComponent; | ||
@ViewChild('profitChart') profitChart: ProfitChartComponent; | ||
|
||
setPeriod(value: string): void { | ||
this.period = value; | ||
} | ||
|
||
changeTab(selectedTab) { | ||
if (selectedTab.tabTitle === 'Profit') { | ||
this.profitChart.resizeChart(); | ||
} else { | ||
this.ordersChart.resizeChart(); | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
height: 100%; | ||
width: 100%; | ||
|
||
/deep/ chart { | ||
.echart { | ||
display: block; | ||
height: 100%; | ||
width: 100%; | ||
|
Oops, something went wrong.