Skip to content
This repository was archived by the owner on Aug 28, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
Expand All@@ -7,6 +7,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="5.0.8" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="5.0.8" PrivateAssets="all" />
<PackageReference Include="ChartJs.Blazor" Version="1.1.0" />
<PackageReference Include="System.Net.Http.Json" Version="5.0.0" />
</ItemGroup>

Expand Down
16 changes: 0 additions & 16 deletions Kysect.GithubActivityAnalyzer.WebDemo/Client/Pages/Counter.razor

This file was deleted.

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
@page "/TeamDashboard"
@inject HttpClient Http
@inject IJSRuntime jsRuntime
<h1>Team Dashboard</h1>
<p>
<input @bind="@_teamName" @bind:event="oninput" />
</p>

@if (_teamName is null)
{
<p><em>Please write team name</em></p>
}
else
{
<p>Team name: @_teamName </p>
}

<p>
<button class="btn btn-primary" @onclick="GenerateBarChart">Generate Bar Chart</button>
</p>

@if (_statsIsVisible)
{
<div id="chartdiv"></div>
}
else
{
<p><font size="1" color="red" face="Arial">No such team</font></p>
}

<!-- Styles -->
<style>
#chartdiv {
width: 100%;
height: 500px;
font-size: 11px;
}
</style>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
using System;
using System.Threading.Tasks;
using Kysect.GithubActivityAnalyzer.WebDemo.Shared;
using Kysect.GithubActivityAnalyzer.Aggregators.Models;
using Microsoft.JSInterop;
using System.Net;
using System.Net.Http.Json;

namespace Kysect.GithubActivityAnalyzer.WebDemo.Client.Pages.Dashboards
{
public partial class TeamDashboard
{
private string _teamName = String.Empty;
private TeamResponse _team;
private bool _statsIsVisible = true;

private async Task GenerateBarChart()
{
await GetStat();
StateHasChanged();
if (_statsIsVisible)
{
var teamInfo = _team.Members;
await jsRuntime.InvokeVoidAsync("GenerateBarChart", teamInfo);
}
}
private async Task GetStat()
{
Team team = await GetTeam();
if (team is not null)
{
var teamInfoResponse = await Http.PostAsJsonAsync("TeamInfo/GetTeamInfo", team);
_team = await teamInfoResponse.Content.ReadFromJsonAsync<TeamResponse>();
_statsIsVisible = true;
}
else
{
_statsIsVisible = false;
}

}
private async Task<Team> GetTeam()
{
var teamResponse = await Http.PostAsJsonAsync("DBTeam/GetTeam", new Team(_teamName));
if (teamResponse.StatusCode == HttpStatusCode.OK)
{
return await teamResponse.Content.ReadFromJsonAsync<Team>();
}
else
{
return null;
}
}
}
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
@page "/testpage"
@using Kysect.GithubActivityAnalyzer.ApiAccessor.ApiResponses
@inject HttpClient Http
<h1>TestFunc</h1>
<h1>Get activity by 2 ways (Test)</h1>
<p>
<input @bind="_setName" @bind:event="oninput" />
</p>
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
@page "/Team"
@using Kysect.GithubActivityAnalyzer.WebDemo.Shared
@using Kysect.GithubActivityAnalyzer.Aggregators.Models
@inject HttpClient Http
<h1>TestFunc</h1>
<h1>United stat</h1>
<p>
<input @bind="_teamName" @bind:event="oninput" />
<input @bind="@_teamName" @bind:event="oninput" />
</p>

<p>
<input @bind="_username" @bind:event="oninput" />
<input @bind="@_username" @bind:event="oninput" />
</p>
<button class="btn btn-primary" @onclick="AddStudent">Add member</button>

<button class="btn btn-primary" @onclick="@AddStudent">Add member</button>

<p>
<button class="btn btn-primary" @onclick="GetStat">Get Stat</button>
</p>
Expand DownExpand Up@@ -57,28 +58,3 @@ else

}

@code {
private string _username = String.Empty;
private string _teamName = String.Empty;
private List<string> _usernames = new List<string>();
private TeamResponse _team;
private bool _statsIsVisible = false;


protected async Task GetStat()
{
Team newTeamInfo = new Team()
{
TeamName = _teamName,
Usernames = _usernames
};
var response = await Http.PostAsJsonAsync("Team", newTeamInfo);
_team = await response.Content.ReadFromJsonAsync<TeamResponse>();
_statsIsVisible = true;
}

private void AddStudent()
{
_usernames.Add(_username);
}
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Kysect.GithubActivityAnalyzer.WebDemo.Shared;
using Kysect.GithubActivityAnalyzer.Aggregators.Models;
using System.Net.Http.Json;

namespace Kysect.GithubActivityAnalyzer.WebDemo.Client.Pages
Comment thread
ALEXXXANDRO marked this conversation as resolved.
{
public partial class UnitedStat
{
private string _username = String.Empty;
private string _teamName = String.Empty;
private List<string> _usernames = new List<string>();
private TeamResponse _team;
private bool _statsIsVisible = false;
protected async Task GetStat()
{
Team newTeamInfo = new Team()
{
TeamName = _teamName,
Usernames = _usernames
Comment thread
ALEXXXANDRO marked this conversation as resolved.
};
var response = await Http.PostAsJsonAsync("Team", newTeamInfo);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Потыкай @MGSDS, он тебе расскажет как он в SeaInk планирует реализовывать Sdk проект и выносить такие запросы.

_team = await response.Content.ReadFromJsonAsync<TeamResponse>();
_statsIsVisible = true;
}
private void AddStudent()
{
if (!_usernames.Contains(_username))
_usernames.Add(_username);
}
Comment thread
ALEXXXANDRO marked this conversation as resolved.

}
}
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,26 +12,26 @@
<span class="oi oi-home" aria-hidden="true"></span> Home
</NavLink>
</li>
<li class="nav-item px-3">
<NavLink class="nav-link" href="counter">
<span class="oi oi-plus" aria-hidden="true"></span> Counter
</NavLink>
</li>
<li class="nav-item px-3">
<NavLink class="nav-link" href="testpage">
<span class="oi oi-plus" aria-hidden="true"></span> Test Page
<span class="oi oi-plus" aria-hidden="true"></span> Single stat
</NavLink>
</li>
<li class="nav-item px-3">
<NavLink class="nav-link" href="Team">
<span class="oi oi-plus" aria-hidden="true"></span> Team
<span class="oi oi-plus" aria-hidden="true"></span> United Stat
</NavLink>
</li>
<li class="nav-item px-3">
<NavLink class="nav-link" href="databaseTeam">
<span class="oi oi-plus" aria-hidden="true"></span> DatabaseTeam
</NavLink>
</li>
<li class="nav-item px-3">
<NavLink class="nav-link" href="TeamDashboard">
<span class="oi oi-plus" aria-hidden="true"></span> Team Dashboard
</NavLink>
</li>
</ul>
</div>

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,4 +7,4 @@
@using Microsoft.AspNetCore.Components.WebAssembly.Http
@using Microsoft.JSInterop
@using Kysect.GithubActivityAnalyzer.WebDemo.Client
@using Kysect.GithubActivityAnalyzer.WebDemo.Client.Shared
@using Kysect.GithubActivityAnalyzer.WebDemo.Client.Shared
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!DOCTYPE html>
<html>

<head>
Expand All@@ -20,6 +20,13 @@
<a class="dismiss">🗙</a>
</div>
<script src="_framework/blazor.webassembly.js"></script>

<!-- Resources -->
<script src="https://www.amcharts.com/lib/3/amcharts.js"></script>
<script src="https://www.amcharts.com/lib/3/serial.js"></script>
<script src="https://www.amcharts.com/lib/3/plugins/export/export.min.js"></script>
<link rel="stylesheet" href="https://www.amcharts.com/lib/3/plugins/export/export.css" type="text/css" media="all" />
<script src="js/Chart.js"></script>
</body>

</html>
42 changes: 42 additions & 0 deletions Kysect.GithubActivityAnalyzer.WebDemo/Client/wwwroot/js/Chart.js
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
function GenerateBarChart(teamInfo) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ты решил прям сразу на js писать?)

AmCharts.makeChart("chartdiv", {
"type": "serial",
"theme": "none",
"categoryField": "username",
"rotate": true,
"startDuration": 1,
"categoryAxis": {
"gridPosition": "start",
"position": "left"
},
"trendLines": [],
"graphs": [
{
"balloonText": "totalContributions:[[value]]",
"fillAlphas": 0.8,
"id": "AmGraph-1",
"lineAlpha": 0.2,
"title": "totalContributions",
"type": "column",
"valueField": "totalContributions"
},
],
"guides": [],
"valueAxes": [
{
"id": "ValueAxis-1",
"position": "top",
"axisAlpha": 0
}
],
"allLabels": [],
"balloon": {},
"titles": [],
"dataProvider": teamInfo,
"export": {
"enabled": true
},
"hideCredits": true

});
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
using Kysect.GithubActivityAnalyzer.WebDemo.Server.Services;
using Kysect.GithubActivityAnalyzer.WebDemo.Shared;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Kysect.GithubActivityAnalyzer.WebDemo.Server.Controllers
Expand DownExpand Up@@ -32,19 +33,29 @@ public void DeleteMember(string username)
_teamService.DeleteMember(username);
}

///TO DO: to realize
[HttpPost("updateMember")]
public void UpdateMember()
{
}

///TO DO: to realize
[HttpGet("GetAllTeams")]
public void GetAllTeams()
{
}

[HttpGet("GetTeam")]
public void GetTeam()
[HttpPost("GetTeam")]
Comment thread
ALEXXXANDRO marked this conversation as resolved.
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(Team))]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public IActionResult GetTeam(Team teamName)
{

if (!_teamService.TryGetTeam(teamName, out var team))
{
return NotFound();
}

return Ok(team);
}
}
}
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
using Microsoft.AspNetCore.Mvc;
using Kysect.GithubActivityAnalyzer.Aggregators;
using Kysect.GithubActivityAnalyzer.Aggregators.Models;
using Kysect.GithubActivityAnalyzer.ApiAccessor;
using Kysect.GithubActivityAnalyzer.WebDemo.Shared;

namespace Kysect.GithubActivityAnalyzer.WebDemo.Server.Controllers
{
[ApiController]
[Route("[controller]")]
public class TeamController : Controller
public class TeamInfoController : Controller

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Мне не очень нравится, что тут Info. Обычно, используют имя сущности. В данном случае - Team. Зачем Info - не понятно.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Просто у нас есть сущность TeamResponse, которая представляет собой агрегацию статистики и members, и из неё как раз и происходит процесс извлечения всякой информации. У меня язык не повернулся назвать TeamResponseController, хотя мб я не прав. TeamController не очень подходит, т.к. есть DBTeamController который нужен для CRUD команд в базе

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ладно, потом перепишем всё )

{
private readonly GithubActivityProvider _provider = new GithubActivityProvider();

[HttpPost]
public TeamResponse GetStudyGroup(Shared.Team info)
[HttpPost("GetTeamInfo")]
public TeamResponse GetTeamInfo(Shared.Team info)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А тут можно убрать Namespace?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не очень, потому что есть Aggregators.Team и Shared.Team

{
return new TeamResponse(new Aggregators.Team(info.TeamName, info.Usernames, _provider));
}
Expand Down
Loading