Rankingi - pliki CSV
This commit is contained in:
parent
92097b2237
commit
cb7120973b
@ -15,6 +15,12 @@
|
||||
<input type="radio" name="options" id="option2" autocomplete="off"><i class="fas fa-pencil-ruler"></i> Ranking testów
|
||||
</label>
|
||||
</div>
|
||||
<br />
|
||||
<div *ngIf="group">
|
||||
<button class="btn btn-study-cave float-right mr-1" (click)="downloadCSVResults()">Eksportuj ranking do pliku CSV</button>
|
||||
<div style="clear: both;"></div>
|
||||
</div>
|
||||
<br />
|
||||
<ag-grid-angular style="width: 100%; height: 475px;" class="ag-theme-dark" [rowData]="data" [columnDefs]="columnDefs"
|
||||
[enableSorting]="true" [enableFilter]="true" (gridReady)="onGridReady($event)" [gridOptions]="gridOptions"
|
||||
[pagination]="true" [paginationAutoPageSize]="true" [localeText]="localeText" (gridColumnsChanged)="onGridColumnsChanged($event)"
|
||||
|
@ -6,6 +6,7 @@ import { Subscription } from 'rxjs/Subscription';
|
||||
import { RankingType } from './ranking';
|
||||
import { GridOptions } from 'ag-grid-community/main';
|
||||
import localeText from './../../../assets/localeText';
|
||||
import { ngxCsv } from 'ngx-csv/ngx-csv';
|
||||
import * as picasso from 'picasso.js';
|
||||
picasso.default('canvas');
|
||||
|
||||
@ -32,7 +33,7 @@ export class RankingComponent implements OnInit, OnDestroy {
|
||||
{ headerName: 'Użytkownik', field: 'username', headerTooltip: 'Użytkownik' },
|
||||
{ headerName: 'Punkty', field: 'points', headerTooltip: 'Punkty' },
|
||||
];
|
||||
public data;
|
||||
public data = [];
|
||||
|
||||
|
||||
constructor(private route: ActivatedRoute, private groupService: GroupsService, private router: Router) { }
|
||||
@ -58,6 +59,11 @@ export class RankingComponent implements OnInit, OnDestroy {
|
||||
});
|
||||
}
|
||||
|
||||
downloadCSVResults() {
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
new ngxCsv(this.data, this.group.name + '_ranking_' + this.typeOfRankingToDisplay);
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
if (this.groupDetailsSubscription) {
|
||||
this.groupDetailsSubscription.unsubscribe();
|
||||
@ -127,7 +133,7 @@ export class RankingComponent implements OnInit, OnDestroy {
|
||||
|
||||
showGlobalRanking(): void {
|
||||
this.typeOfRankingToDisplay = RankingType.all;
|
||||
this.rankingSubscription = this.groupService.getGlobalRanking(this.group.id).subscribe(data => {
|
||||
this.rankingSubscription = this.groupService.getGlobalRanking(this.id).subscribe(data => {
|
||||
this.data = data.sort((a, b) => {
|
||||
if (a.points > b.points) {
|
||||
return -1;
|
||||
@ -143,7 +149,7 @@ export class RankingComponent implements OnInit, OnDestroy {
|
||||
|
||||
showOnlyTestsRanking(): void {
|
||||
this.typeOfRankingToDisplay = RankingType.test;
|
||||
this.rankingSubscription = this.groupService.getTestsRanking(this.group.id).subscribe(data => {
|
||||
this.rankingSubscription = this.groupService.getTestsRanking(this.id).subscribe(data => {
|
||||
this.data = data.sort((a, b) => {
|
||||
if (a.points > b.points) {
|
||||
return -1;
|
||||
|
@ -15,7 +15,7 @@
|
||||
<div *ngIf="selectedTest">
|
||||
<h2>Wybrany test: {{selectedTest.title}}</h2>
|
||||
<br />
|
||||
<button class="btn btn-study-cave float-right mr-1" (click)="downloadCSVResults()">Pobierz plik CSV z wynikami</button>
|
||||
<button *ngIf="group" class="btn btn-study-cave float-right mr-1" (click)="downloadCSVResults()">Eksportuj wyniki do pliku CSV</button>
|
||||
<div style="clear: both;"></div>
|
||||
<br />
|
||||
<ag-grid-angular style="width: 100%; height: 475px;" class="ag-theme-dark" [rowData]="testdata" [columnDefs]="testcolumnDefs"
|
||||
|
@ -6,7 +6,6 @@ import { Subscription } from 'rxjs/Subscription';
|
||||
import localeText from './../../../assets/localeText';
|
||||
import { GridOptions, RowDoubleClickedEvent } from 'ag-grid-community/main';
|
||||
import { MatSnackBar } from '@angular/material';
|
||||
|
||||
import { ngxCsv } from 'ngx-csv/ngx-csv';
|
||||
|
||||
|
||||
@ -105,7 +104,7 @@ export class TestsInGroupResultsComponent implements OnInit, OnDestroy {
|
||||
|
||||
downloadCSVResults() {
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
new ngxCsv(this.testdata, this.selectedTest.title + '_wyniki');
|
||||
new ngxCsv(this.testdata, this.group.name + '_' + this.selectedTest.title + '_wyniki');
|
||||
}
|
||||
|
||||
getResults(id: number) {
|
||||
|
Loading…
Reference in New Issue
Block a user