forked from ludeknovy/jtl-reporter-fe
-
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.
- Loading branch information
Showing
19 changed files
with
17,082 additions
and
164 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
30 changes: 30 additions & 0 deletions
30
src/app/item-detail/analyze-charts/add-metric/add-metric.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,30 @@ | ||
<ng-template #content let-modal> | ||
<div class="modal-header"> | ||
<h5 class="modal-title" id="modal-basic-title">Add metrics</h5> | ||
<button type="button" style="outline: none;" class="close" aria-label="Close" | ||
(click)="modal.dismiss('Cross click')"> | ||
<span aria-hidden="true">×</span> | ||
</button> | ||
</div> | ||
|
||
<div class="modal-body"> | ||
<ul class="metric-ul" *ngFor="let item of metrics | keyvalue"> | ||
<div class="metric">{{item.key}}</div> | ||
<li class="label" *ngFor="let _ of item.value"> | ||
<input class="form-check-input" id="{{item.key}}{{_.name}}" type="checkbox" name="list_name_child" [(ngModel)]="_.isChecked"> | ||
<label class="form-check-label" for="{{item.key}}{{_.name}}">{{_.name}}</label> | ||
</li> | ||
</ul> | ||
</div> | ||
|
||
|
||
|
||
|
||
<div class="modal-footer"> | ||
<button class="btn btn-primary" (click)="submit()">Submit</button> | ||
</div> | ||
|
||
|
||
</ng-template> | ||
|
||
<button class="jtl-no-glow add-item jtl-btn-light btn btn-sm" (click)="open(content)" ngbDropdownItem>Edit metrics</button> |
13 changes: 13 additions & 0 deletions
13
src/app/item-detail/analyze-charts/add-metric/add-metric.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,13 @@ | ||
.metric { | ||
font-size: 1.0rem; | ||
font-weight: bold; | ||
} | ||
|
||
.metric-ul{ | ||
padding-left: 25px; | ||
} | ||
|
||
.label { | ||
list-style-type:none; | ||
margin-left: 30px; | ||
} |
32 changes: 32 additions & 0 deletions
32
src/app/item-detail/analyze-charts/add-metric/add-metric.component.spec.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,32 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { FormsModule } from '@angular/forms'; | ||
|
||
import { AddMetricComponent } from './add-metric.component'; | ||
|
||
describe('AddMetricComponent', () => { | ||
let component: AddMetricComponent; | ||
let fixture: ComponentFixture<AddMetricComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [AddMetricComponent], | ||
imports: [FormsModule, | ||
] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(AddMetricComponent); | ||
component = fixture.componentInstance; | ||
component.chartLines = { | ||
labels: new Map([['test', [{ name: 'test' }]]]), | ||
overall: new Map() | ||
}; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
65 changes: 65 additions & 0 deletions
65
src/app/item-detail/analyze-charts/add-metric/add-metric.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,65 @@ | ||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; | ||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; | ||
|
||
@Component({ | ||
selector: 'app-add-metric', | ||
templateUrl: './add-metric.component.html', | ||
styleUrls: ['./add-metric.component.scss'] | ||
}) | ||
export class AddMetricComponent implements OnInit { | ||
|
||
@Input() chartLines; | ||
@Output() chartUpdate = new EventEmitter<{}>(); | ||
|
||
overallChartLines; | ||
labelsChartLines; | ||
labels: string[]; | ||
metrics = {}; | ||
|
||
constructor( | ||
private modalService: NgbModal, | ||
) { | ||
} | ||
|
||
ngOnInit() { | ||
const labelsLines = Array.from(this.chartLines.labels.keys()); | ||
const overallLines = Array.from(this.chartLines.overall.keys()); | ||
const { value: firstItem } = this.chartLines.labels.values().next(); | ||
const labels = firstItem.map(_ => ({ name: _.name, isChecked: false })); | ||
overallLines.forEach((_: string) => { | ||
this.metrics[_] = [{ name: 'overall', isChecked: false }]; | ||
}); | ||
labelsLines.forEach((_: string) => { | ||
const labelsArray = [...JSON.parse(JSON.stringify(labels))]; | ||
this.metrics.hasOwnProperty(_) | ||
? this.metrics[_].push(...labelsArray) | ||
: this.metrics[_] = labelsArray; | ||
}); | ||
|
||
this.overallChartLines = Array.from(this.chartLines.overall.keys()); | ||
this.labelsChartLines = Array.from(this.chartLines.labels.keys()); | ||
} | ||
|
||
open(content) { | ||
this.modalService.open(content, { ariaLabelledBy: 'modal-basic-title' }); | ||
} | ||
|
||
submit() { | ||
const checked = []; | ||
for (const key of Object.keys(this.metrics)) { | ||
const metric = this.metrics[key]; | ||
const checkedMetric = metric.filter((_) => _.isChecked === true).map((_ ) => ({ name: _.name, metric: key })); | ||
if (checkedMetric.length > 0) { | ||
checked.push(...checkedMetric); | ||
} | ||
} | ||
this.chartUpdate.emit(checked); | ||
|
||
|
||
this.modalService.dismissAll(); | ||
|
||
} | ||
|
||
|
||
|
||
} |
7 changes: 7 additions & 0 deletions
7
src/app/item-detail/analyze-charts/analyze-charts.component.css
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,7 @@ | ||
.card-header{ | ||
border-bottom: none; | ||
} | ||
|
||
.card { | ||
margin-top: 20px; | ||
} |
19 changes: 19 additions & 0 deletions
19
src/app/item-detail/analyze-charts/analyze-charts.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,19 @@ | ||
<div class="card" *ngIf="customChartsOptions"> | ||
<h6 class="card-header bg-transparent"> | ||
Custom Chart | ||
<span class="float-right"> | ||
<div display="dynamic" [placement]="['bottom-right', 'bottom-left']" class="btn-group" ngbDropdown role="group" | ||
aria-label=""> | ||
<app-add-metric [chartLines]="chartLines" (chartUpdate)="chartUpdated($event)"></app-add-metric> | ||
</div> | ||
</span> | ||
</h6> | ||
<div class="card-body"> | ||
<div class="chart"> | ||
<highcharts-chart [Highcharts]="Highcharts" [options]="customChartsOptions" [(update)]="updateLabelChartFlag" [oneToOne]="true" | ||
|
||
style="width: 100%; height: 350px; display: block;"></highcharts-chart> | ||
</div> | ||
</div> | ||
|
||
</div> |
35 changes: 35 additions & 0 deletions
35
src/app/item-detail/analyze-charts/analyze-charts.component.spec.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,35 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { FormsModule } from '@angular/forms'; | ||
import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; | ||
import { HighchartsChartModule } from 'highcharts-angular'; | ||
import { AddMetricComponent } from './add-metric/add-metric.component'; | ||
|
||
import { AnalyzeChartsComponent } from './analyze-charts.component'; | ||
|
||
describe('AnalyzeChartsComponent', () => { | ||
let component: AnalyzeChartsComponent; | ||
let fixture: ComponentFixture<AnalyzeChartsComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ AnalyzeChartsComponent, AddMetricComponent ], | ||
imports: [ | ||
HighchartsChartModule, | ||
NgbModule, | ||
FormsModule | ||
] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(AnalyzeChartsComponent); | ||
component = fixture.componentInstance; | ||
component.chartLines = { labels: new Map([['test', [{ name: 'test', data: []}]]]), overall: new Map() }; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
Oops, something went wrong.