diff --git a/Kysect.GithubActivityAnalyzer.WebDemo/Client/Kysect.GithubActivityAnalyzer.WebDemo.Client.csproj b/Kysect.GithubActivityAnalyzer.WebDemo/Client/Kysect.GithubActivityAnalyzer.WebDemo.Client.csproj index 72bce1d..b89ba8c 100644 --- a/Kysect.GithubActivityAnalyzer.WebDemo/Client/Kysect.GithubActivityAnalyzer.WebDemo.Client.csproj +++ b/Kysect.GithubActivityAnalyzer.WebDemo/Client/Kysect.GithubActivityAnalyzer.WebDemo.Client.csproj @@ -1,4 +1,4 @@ - + net5.0 @@ -7,6 +7,7 @@ + diff --git a/Kysect.GithubActivityAnalyzer.WebDemo/Client/Pages/Counter.razor b/Kysect.GithubActivityAnalyzer.WebDemo/Client/Pages/Counter.razor deleted file mode 100644 index 8641f78..0000000 --- a/Kysect.GithubActivityAnalyzer.WebDemo/Client/Pages/Counter.razor +++ /dev/null @@ -1,16 +0,0 @@ -@page "/counter" - -

Counter

- -

Current count: @currentCount

- - - -@code { - private int currentCount = 0; - - private void IncrementCount() - { - currentCount++; - } -} diff --git a/Kysect.GithubActivityAnalyzer.WebDemo/Client/Pages/Dashboards/TeamDashboard.razor b/Kysect.GithubActivityAnalyzer.WebDemo/Client/Pages/Dashboards/TeamDashboard.razor new file mode 100644 index 0000000..4dba122 --- /dev/null +++ b/Kysect.GithubActivityAnalyzer.WebDemo/Client/Pages/Dashboards/TeamDashboard.razor @@ -0,0 +1,38 @@ +@page "/TeamDashboard" +@inject HttpClient Http +@inject IJSRuntime jsRuntime +

Team Dashboard

+

+ +

+ +@if (_teamName is null) +{ +

Please write team name

+} +else +{ +

Team name: @_teamName

+} + +

+ +

+ +@if (_statsIsVisible) +{ +
+} +else +{ +

No such team

+} + + + \ No newline at end of file diff --git a/Kysect.GithubActivityAnalyzer.WebDemo/Client/Pages/Dashboards/TeamDashboard.razor.cs b/Kysect.GithubActivityAnalyzer.WebDemo/Client/Pages/Dashboards/TeamDashboard.razor.cs new file mode 100644 index 0000000..7bc12fc --- /dev/null +++ b/Kysect.GithubActivityAnalyzer.WebDemo/Client/Pages/Dashboards/TeamDashboard.razor.cs @@ -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(); + _statsIsVisible = true; + } + else + { + _statsIsVisible = false; + } + + } + private async Task GetTeam() + { + var teamResponse = await Http.PostAsJsonAsync("DBTeam/GetTeam", new Team(_teamName)); + if (teamResponse.StatusCode == HttpStatusCode.OK) + { + return await teamResponse.Content.ReadFromJsonAsync(); + } + else + { + return null; + } + } + } +} diff --git a/Kysect.GithubActivityAnalyzer.WebDemo/Client/Pages/TestPage.razor b/Kysect.GithubActivityAnalyzer.WebDemo/Client/Pages/SingleStat.razor similarity index 96% rename from Kysect.GithubActivityAnalyzer.WebDemo/Client/Pages/TestPage.razor rename to Kysect.GithubActivityAnalyzer.WebDemo/Client/Pages/SingleStat.razor index 5b1e9f8..6a987ec 100644 --- a/Kysect.GithubActivityAnalyzer.WebDemo/Client/Pages/TestPage.razor +++ b/Kysect.GithubActivityAnalyzer.WebDemo/Client/Pages/SingleStat.razor @@ -1,7 +1,7 @@ @page "/testpage" @using Kysect.GithubActivityAnalyzer.ApiAccessor.ApiResponses @inject HttpClient Http -

TestFunc

+

Get activity by 2 ways (Test)

diff --git a/Kysect.GithubActivityAnalyzer.WebDemo/Client/Pages/GetTeam.razor b/Kysect.GithubActivityAnalyzer.WebDemo/Client/Pages/UnitedStat.razor similarity index 52% rename from Kysect.GithubActivityAnalyzer.WebDemo/Client/Pages/GetTeam.razor rename to Kysect.GithubActivityAnalyzer.WebDemo/Client/Pages/UnitedStat.razor index 3f7b376..4b194f5 100644 --- a/Kysect.GithubActivityAnalyzer.WebDemo/Client/Pages/GetTeam.razor +++ b/Kysect.GithubActivityAnalyzer.WebDemo/Client/Pages/UnitedStat.razor @@ -1,15 +1,16 @@ @page "/Team" -@using Kysect.GithubActivityAnalyzer.WebDemo.Shared -@using Kysect.GithubActivityAnalyzer.Aggregators.Models @inject HttpClient Http -

TestFunc

+

United stat

- +

+

- +

- + + +

@@ -57,28 +58,3 @@ else } -@code { - private string _username = String.Empty; - private string _teamName = String.Empty; - private List _usernames = new List(); - 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(); - _statsIsVisible = true; - } - - private void AddStudent() - { - _usernames.Add(_username); - } -} diff --git a/Kysect.GithubActivityAnalyzer.WebDemo/Client/Pages/UnitedStat.razor.cs b/Kysect.GithubActivityAnalyzer.WebDemo/Client/Pages/UnitedStat.razor.cs new file mode 100644 index 0000000..df38480 --- /dev/null +++ b/Kysect.GithubActivityAnalyzer.WebDemo/Client/Pages/UnitedStat.razor.cs @@ -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 +{ + public partial class UnitedStat + { + private string _username = String.Empty; + private string _teamName = String.Empty; + private List _usernames = new List(); + 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(); + _statsIsVisible = true; + } + private void AddStudent() + { + if (!_usernames.Contains(_username)) + _usernames.Add(_username); + } + + } +} diff --git a/Kysect.GithubActivityAnalyzer.WebDemo/Client/Shared/NavMenu.razor b/Kysect.GithubActivityAnalyzer.WebDemo/Client/Shared/NavMenu.razor index f51aaaf..fb9be82 100644 --- a/Kysect.GithubActivityAnalyzer.WebDemo/Client/Shared/NavMenu.razor +++ b/Kysect.GithubActivityAnalyzer.WebDemo/Client/Shared/NavMenu.razor @@ -12,19 +12,14 @@ Home - + diff --git a/Kysect.GithubActivityAnalyzer.WebDemo/Client/_Imports.razor b/Kysect.GithubActivityAnalyzer.WebDemo/Client/_Imports.razor index 2b477dc..d440f4d 100644 --- a/Kysect.GithubActivityAnalyzer.WebDemo/Client/_Imports.razor +++ b/Kysect.GithubActivityAnalyzer.WebDemo/Client/_Imports.razor @@ -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 \ No newline at end of file diff --git a/Kysect.GithubActivityAnalyzer.WebDemo/Client/wwwroot/index.html b/Kysect.GithubActivityAnalyzer.WebDemo/Client/wwwroot/index.html index 37bcc83..de6da85 100644 --- a/Kysect.GithubActivityAnalyzer.WebDemo/Client/wwwroot/index.html +++ b/Kysect.GithubActivityAnalyzer.WebDemo/Client/wwwroot/index.html @@ -1,4 +1,4 @@ - + @@ -20,6 +20,13 @@ 🗙 + + + + + + + diff --git a/Kysect.GithubActivityAnalyzer.WebDemo/Client/wwwroot/js/Chart.js b/Kysect.GithubActivityAnalyzer.WebDemo/Client/wwwroot/js/Chart.js new file mode 100644 index 0000000..23cfa27 --- /dev/null +++ b/Kysect.GithubActivityAnalyzer.WebDemo/Client/wwwroot/js/Chart.js @@ -0,0 +1,42 @@ +function GenerateBarChart(teamInfo) { + 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 + + }); +} diff --git a/Kysect.GithubActivityAnalyzer.WebDemo/Server/Controllers/DBTeamController.cs b/Kysect.GithubActivityAnalyzer.WebDemo/Server/Controllers/DBTeamController.cs index 637d300..f2fdee8 100644 --- a/Kysect.GithubActivityAnalyzer.WebDemo/Server/Controllers/DBTeamController.cs +++ b/Kysect.GithubActivityAnalyzer.WebDemo/Server/Controllers/DBTeamController.cs @@ -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 @@ -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")] + [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); } } } diff --git a/Kysect.GithubActivityAnalyzer.WebDemo/Server/Controllers/TeamController.cs b/Kysect.GithubActivityAnalyzer.WebDemo/Server/Controllers/TeamInfoController.cs similarity index 68% rename from Kysect.GithubActivityAnalyzer.WebDemo/Server/Controllers/TeamController.cs rename to Kysect.GithubActivityAnalyzer.WebDemo/Server/Controllers/TeamInfoController.cs index 8ed4b79..b81993f 100644 --- a/Kysect.GithubActivityAnalyzer.WebDemo/Server/Controllers/TeamController.cs +++ b/Kysect.GithubActivityAnalyzer.WebDemo/Server/Controllers/TeamInfoController.cs @@ -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 { private readonly GithubActivityProvider _provider = new GithubActivityProvider(); - [HttpPost] - public TeamResponse GetStudyGroup(Shared.Team info) + [HttpPost("GetTeamInfo")] + public TeamResponse GetTeamInfo(Shared.Team info) { return new TeamResponse(new Aggregators.Team(info.TeamName, info.Usernames, _provider)); } diff --git a/Kysect.GithubActivityAnalyzer.WebDemo/Server/Services/IActivityService.cs b/Kysect.GithubActivityAnalyzer.WebDemo/Server/Services/IActivityService.cs index add3b58..0df4d32 100644 --- a/Kysect.GithubActivityAnalyzer.WebDemo/Server/Services/IActivityService.cs +++ b/Kysect.GithubActivityAnalyzer.WebDemo/Server/Services/IActivityService.cs @@ -1,14 +1,11 @@ using Kysect.GithubActivityAnalyzer.ApiAccessor.ApiResponses; -using System; -using System.Collections.Generic; -using System.Linq; using System.Threading.Tasks; namespace Kysect.GithubActivityAnalyzer.WebDemo.Server.Services { public interface IActivityService { - public Task GetActivityInfoFromGithub(string username); - public ActivityInfo GetActivityInfoFromDB(string username); + Task GetActivityInfoFromGithub(string username); + ActivityInfo GetActivityInfoFromDB(string username); } } diff --git a/Kysect.GithubActivityAnalyzer.WebDemo/Server/Services/ITeamService.cs b/Kysect.GithubActivityAnalyzer.WebDemo/Server/Services/ITeamService.cs index fc7576d..04cc5d2 100644 --- a/Kysect.GithubActivityAnalyzer.WebDemo/Server/Services/ITeamService.cs +++ b/Kysect.GithubActivityAnalyzer.WebDemo/Server/Services/ITeamService.cs @@ -1,20 +1,18 @@ -using Kysect.GithubActivityAnalyzer.Extensions.Data.Entities; -using Kysect.GithubActivityAnalyzer.WebDemo.Shared; using System.Linq; +using Kysect.GithubActivityAnalyzer.WebDemo.Shared; +using Kysect.GithubActivityAnalyzer.Extensions.Data.Entities; namespace Kysect.GithubActivityAnalyzer.WebDemo.Server.Services { public interface ITeamService { - public void AddTeam(Team team); - public void DeleteTeam(string teamName); - public void UpdateMember(string username, string teamName); - public void DeleteMember(string username); - - //TODO: разобраться с возвращаемым значением - public void GetAllTeams(); + void AddTeam(Team team); + void DeleteTeam(string teamName); + void UpdateMember(string username, string teamName); + void DeleteMember(string username); //TODO: разобраться с возвращаемым значением - public IQueryable GetTeam(string teamName); + void GetAllTeams(); + bool TryGetTeam(Team teamName, out Team team); } } diff --git a/Kysect.GithubActivityAnalyzer.WebDemo/Server/Services/TeamService.cs b/Kysect.GithubActivityAnalyzer.WebDemo/Server/Services/TeamService.cs index a3ab797..73d0348 100644 --- a/Kysect.GithubActivityAnalyzer.WebDemo/Server/Services/TeamService.cs +++ b/Kysect.GithubActivityAnalyzer.WebDemo/Server/Services/TeamService.cs @@ -33,13 +33,18 @@ public void DeleteMember(string username) } //TODO: Уточнить с ТЗ и реализовать - void ITeamService.GetAllTeams() + public void GetAllTeams() { throw new System.NotImplementedException(); } - IQueryable ITeamService.GetTeam(string teamName) + public bool TryGetTeam(Team teamName, out Team team) { - throw new System.NotImplementedException(); + team = new Team() { TeamName = teamName.TeamName }; + team.Usernames = _teamRepository.GetAllByTeam(teamName.TeamName).Select(p => p.Username).ToList(); + if (team.Usernames.Any()) + return true; + else + return false; } } }