This commit is contained in:
alexziskind1 2019-04-17 16:05:41 -07:00
Родитель faedffea8d
Коммит 5f4a47a951
2 изменённых файлов: 144 добавлений и 5 удалений

Просмотреть файл

@ -1,7 +1,106 @@
@page
@model RPS.Web.Pages.DashboardModel
@{
ViewData["Title"] = "Dashboard";
@{
var userId = ViewData["userId"];
}
<h2>Dashboard</h2>
<div class="dashboard">
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3">
<div class="col-md order-md-first text-center text-md-left">
<h2>
<span class="small text-uppercase text-muted d-block">Statistics</span>
@if (Model.DateStart.HasValue && Model.DateEnd.HasValue)
{
<span id="spanFilteredDateRange">
@Model.DateStart.Value.ToString("MMM d, yyyy") - @Model.DateEnd.Value.ToString("MMM d, yyyy")
</span>
}
</h2>
</div>
<div class="btn-toolbar mb-2 mb-md-0">
<div class="btn-group mr-2">
<button type="button" class="pt-class-range-filter" data-range="3" onclick="location.href = '/?months=3&userId=@userId'">
3 Months
</button>
<button type="button" class="pt-class-range-filter" data-range="6" onclick="location.href = '/?months=6&userId=@userId'">
6 Months
</button>
<button type="button" class="pt-class-range-filter" data-range="12" onclick="location.href = '/?months=12&userId=@userId'">
1 Year
</button>
</div>
</div>
</div>
<div class="card">
<h3 class="card-header">Active Issues</h3>
<div class="card-block">
<div class="row">
<div class="col-12 col-lg-6 col-xl pb-4 active-issues">
<span class="comp-label">
<strong>@Model.IssueCountActive</strong>
<small>Active issues</small>
</span>
</div>
<div class="col-12 col-lg-6 col-xl pb-4 text-success closed-issues">
<span class="comp-label">
<strong>@Model.IssueCountClosed</strong>
<small>Closed issues</small>
</span>
</div>
<div class="col-12 col-lg-6 col-xl pb-4 text-danger open-issues">
<span class="comp-label">
<strong>@Model.IssueCountOpen</strong>
<small>Open issues</small>
</span>
</div>
<div class="col-12 col-lg-6 col-xl pb-4 close-rate">
<span class="comp-label">
<strong>@Model.IssueCloseRate</strong>
<small>Close rate</small>
</span>
<p class="m-0 small text-uppercase text-muted">
Highest:
100%
on Oct 11, 2018
</p>
<p class="m-0 small text-uppercase text-muted">
Lowest:
20%
on Oct 9, 2018
</p>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<h3>All issues</h3>
</div>
</div>
</div>
</div>
</div>
@section styles {
<link href="~/css/dashboard.css" rel="stylesheet" />
}

Просмотреть файл

@ -4,14 +4,54 @@ using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using RPS.Core.Models.Dto;
using RPS.Data;
namespace RPS.Web.Pages
{
public class DashboardModel : PageModel
{
public void OnGet()
{
private readonly IPtDashboardRepository rpsDashRepo;
public DateTime? DateStart { get; set; }
public DateTime? DateEnd { get; set; }
public int IssueCountOpen { get; set; }
public int IssueCountClosed { get; set; }
public int IssueCountActive { get { return IssueCountOpen + IssueCountClosed; } }
public decimal IssueCloseRate { get { return Math.Round((decimal)IssueCountClosed / (decimal)IssueCountActive * 100m, 2); } }
public DashboardModel(IPtDashboardRepository rpsDashData)
{
rpsDashRepo = rpsDashData;
}
public void OnGet(int? userId, int? months)
{
ViewData.Add("userId", userId);
ViewData.Add("months", months);
DateTime start = months.HasValue ? DateTime.Now.AddMonths(months.Value * -1) : DateTime.Now.AddYears(-5);
DateTime end = DateTime.Now;
PtDashboardFilter filter = new PtDashboardFilter
{
DateStart = start,
DateEnd = end,
UserId = userId.HasValue ? userId.Value : 0
};
var statusCounts = rpsDashRepo.GetStatusCounts(filter);
IssueCountOpen = statusCounts.OpenItemsCount;
IssueCountClosed = statusCounts.ClosedItemsCount;
if (months.HasValue)
{
DateStart = filter.DateStart;
DateEnd = filter.DateEnd;
}
}
}
}