-
Notifications
You must be signed in to change notification settings - Fork 10
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 #231 from vsimakhin/feature/totals-by-months
Add new stats - totals by month
- Loading branch information
Showing
10 changed files
with
260 additions
and
27 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
"use strict"; | ||
|
||
const statsTotalsByMonth = function () { | ||
const yearChange = async () => { | ||
const api = await commonUtils.getApi('StatsTotalsByMonthYearPage'); | ||
year = commonUtils.getElementValue("year"); | ||
window.location.href = api.replace('{year}', year); | ||
} | ||
|
||
const initPage = async () => { | ||
const tableTotals = $("#totals_by_month").DataTable({ | ||
ordering: false, | ||
info: false, | ||
scrollX: true, | ||
columnDefs: [ | ||
{ targets: "_all", width: "5%" }, | ||
], | ||
paging: false, | ||
searching: false, | ||
initComplete: function () { statsUtils.loadChart('totals_by_month'); } // Show Totals for chart | ||
}); | ||
|
||
document.getElementById("year").addEventListener("change", () => { yearChange(); }); | ||
document.getElementById("year").focus(); | ||
} | ||
|
||
document.addEventListener("DOMContentLoaded", initPage); | ||
}(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
{{ template "base" .}} | ||
{{ define "title" }}Stats - Totals By Month{{ end }} | ||
{{ define "header" }}Stats - Totals By Month{{ end }} | ||
{{ define "css" }}{{ end }} | ||
{{ define "content" }} | ||
{{$settings := index .Data "settings"}} | ||
{{$totalsByMonth := index .Data "totalsByMonth"}} | ||
{{$years := index .Data "years"}} | ||
{{$year := index .Data "year"}} | ||
<div class="row"> | ||
<div class="col-12 col-lg-12"> | ||
<div class="card"> | ||
<div class="card-header p-2"> | ||
<h5 class="card-title">Totals by Month</h5> | ||
</div> | ||
<div class="card-body pt-1" id="table_stats"> | ||
<div class="row mb-2"> | ||
<div class="col-md-4 mb-2"> | ||
<div class="input-group"> | ||
<div class="form-floating"> | ||
<select class="form-control" id="year" name="year" value="{{$year}}"> | ||
{{range $key, $value := $years}} | ||
<option value="{{$value}}" {{if eq $value $year}}selected{{end}}>{{$value}}</option> | ||
{{end}} | ||
</select> | ||
<label>Select a year for the detailed stats</label> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="row mb-2"> | ||
<table id="totals_by_month" class="table table-sm table-striped table-bordered nowrap" width="100%" {{if $settings.StatsFontSize}}style="font-size:{{$settings.StatsFontSize}}%"{{end}}> | ||
<thead> | ||
<tr class="align-top text-center"> | ||
<th>Month</th> | ||
{{if not $settings.HideStatsFields.SE}}<th onclick="statsUtils.onStatsClick('totals_by_month', this.cellIndex);"><a class="nav-link th-hover" href=#>SE</a></th>{{end}} | ||
{{if not $settings.HideStatsFields.ME}}<th onclick="statsUtils.onStatsClick('totals_by_month', this.cellIndex);"><a class="nav-link th-hover" href=#>ME</a></th>{{end}} | ||
{{if not $settings.HideStatsFields.MCC}}<th onclick="statsUtils.onStatsClick('totals_by_month', this.cellIndex);"><a class="nav-link th-hover" href=#>MCC</a></th>{{end}} | ||
{{if not $settings.HideStatsFields.Night}}<th onclick="statsUtils.onStatsClick('totals_by_month', this.cellIndex);"><a class="nav-link th-hover" href=#>Night</a></th>{{end}} | ||
{{if not $settings.HideStatsFields.IFR}}<th onclick="statsUtils.onStatsClick('totals_by_month', this.cellIndex);"><a class="nav-link th-hover" href=#>IFR</a></th>{{end}} | ||
{{if not $settings.HideStatsFields.PIC}}<th onclick="statsUtils.onStatsClick('totals_by_month', this.cellIndex);"><a class="nav-link th-hover" href=#>PIC</a></th>{{end}} | ||
{{if not $settings.HideStatsFields.CoPilot}}<th onclick="statsUtils.onStatsClick('totals_by_month', this.cellIndex);"><a class="nav-link th-hover" href=#>CoP</a></th>{{end}} | ||
{{if not $settings.HideStatsFields.Dual}}<th onclick="statsUtils.onStatsClick('totals_by_month', this.cellIndex);"><a class="nav-link th-hover" href=#>Dual</a></th>{{end}} | ||
{{if not $settings.HideStatsFields.Instructor}}<th onclick="statsUtils.onStatsClick('totals_by_month', this.cellIndex);"><a class="nav-link th-hover" href=#>Instr</a></th>{{end}} | ||
{{if not $settings.HideStatsFields.Sim}}<th onclick="statsUtils.onStatsClick('totals_by_month', this.cellIndex);"><a class="nav-link th-hover" href=#>Sim</a></th>{{end}} | ||
{{if not $settings.HideStatsFields.CrossCountry}}<th onclick="statsUtils.onStatsClick('totals_by_month', this.cellIndex);"><a class="nav-link th-hover" href=#>CC</a></th>{{end}} | ||
{{if not $settings.HideStatsFields.Landings}}<th>Landings</th>{{end}} | ||
{{if not $settings.HideStatsFields.Distance}}<th onclick="statsUtils.onStatsClick('totals_by_month', this.cellIndex);"><a class="nav-link th-hover" href=#>Distance</a></th>{{end}} | ||
<th onclick="statsUtils.onStatsClick('totals_by_month', this.cellIndex);"><a class="nav-link th-hover" href=#>Total</a></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{{range $key, $value := $totalsByMonth}} | ||
<tr> | ||
<td class="fw-bold">{{$key}}</td> | ||
{{if not $settings.HideStatsFields.SE}}<td>{{$value.Time.SE}}</td>{{end}} | ||
{{if not $settings.HideStatsFields.ME}}<td>{{$value.Time.ME}}</td>{{end}} | ||
{{if not $settings.HideStatsFields.MCC}}<td>{{$value.Time.MCC}}</td>{{end}} | ||
{{if not $settings.HideStatsFields.Night}}<td>{{$value.Time.Night}}</td>{{end}} | ||
{{if not $settings.HideStatsFields.IFR}}<td>{{$value.Time.IFR}}</td>{{end}} | ||
{{if not $settings.HideStatsFields.PIC}}<td>{{$value.Time.PIC}}</td>{{end}} | ||
{{if not $settings.HideStatsFields.CoPilot}}<td>{{$value.Time.CoPilot}}</td>{{end}} | ||
{{if not $settings.HideStatsFields.Dual}}<td>{{$value.Time.Dual}}</td>{{end}} | ||
{{if not $settings.HideStatsFields.Instructor}}<td>{{$value.Time.Instructor}}</td>{{end}} | ||
{{if not $settings.HideStatsFields.Sim}}<td>{{$value.SIM.Time}}</td>{{end}} | ||
{{if not $settings.HideStatsFields.CrossCountry}}<td>{{$value.Time.CrossCountry}}</td>{{end}} | ||
{{if not $settings.HideStatsFields.Landings}}<td>{{$value.Landings.Day}}/{{$value.Landings.Night}}</td>{{end}} | ||
{{if not $settings.HideStatsFields.Distance}}<td>{{formatNumber $value.Distance}}</td>{{end}} | ||
<td><strong>{{$value.Time.Total}}</strong></td> | ||
</tr> | ||
{{end}} | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="col-12 col-lg-12"> | ||
<div class="card"> | ||
<div class="card-header p-2"> | ||
<h5 class="card-title">Chart</h5> | ||
<h6 class="card-subtitle text-muted mb-0">Click on the table column header to show the chart</h6> | ||
</div> | ||
<div class="card-body pt-1 text-center" id="chart_stats"> | ||
<div class="row"> | ||
<div class="col-md-12"> | ||
<canvas id="myChart" height="100%"></canvas> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
{{ end }} | ||
|
||
{{ define "js" }} | ||
<script type="text/javascript" src="/static/js/datatables.min.js"></script> | ||
<script type="text/javascript" src="/static/js/chart.min.js"></script> | ||
<script type="text/javascript" src="/static/js/wlb-stats.js"></script> | ||
<script type="text/javascript" src="/static/js/wlb-stats-totals-month.js"></script> | ||
{{ end }} |
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
Oops, something went wrong.