diff --git a/Api/Controllers/v1/StatsController.cs b/Api/Controllers/v1/StatsController.cs new file mode 100644 index 0000000..12ea64b --- /dev/null +++ b/Api/Controllers/v1/StatsController.cs @@ -0,0 +1,35 @@ +using Application.DataTransferObjects.Stat; +using Application.Interfaces; +using Asp.Versioning; +using Microsoft.AspNetCore.Mvc; + +namespace Api.Controllers.v1 +{ + [Route("api/v{version:apiVersion}/[controller]")] + [ApiController] + [ApiVersion("1.0")] + public class StatsController(IStatRepository statRepository, ILogger logger) : ControllerBase + { + [HttpGet("useCount")] + public async Task> GetUseCount(CancellationToken cancellationToken) + { + try + { + var useCountResult = await statRepository.GetAllianceUseToolCountAsync(cancellationToken); + + return useCountResult.IsFailure + ? BadRequest(useCountResult.Error) + : Ok(useCountResult.Value); + } + catch (Exception e) + { + logger.LogError(e, "{ErrorMessage}", e.Message); + return Problem( + detail: $"Failed to process {nameof(GetUseCount)}", + statusCode: StatusCodes.Status500InternalServerError, + title: "Internal server error"); + } + } + + } +} diff --git a/Application/ApplicationDependencyInjection.cs b/Application/ApplicationDependencyInjection.cs index 18f9510..bc1fd37 100644 --- a/Application/ApplicationDependencyInjection.cs +++ b/Application/ApplicationDependencyInjection.cs @@ -36,6 +36,7 @@ public static class ApplicationDependencyInjection services.AddScoped(); services.AddScoped(); services.AddScoped(); + services.AddScoped(); services.AddTransient(); diff --git a/Application/DataTransferObjects/Stat/AllianceUseToolCount.cs b/Application/DataTransferObjects/Stat/AllianceUseToolCount.cs new file mode 100644 index 0000000..a6d0015 --- /dev/null +++ b/Application/DataTransferObjects/Stat/AllianceUseToolCount.cs @@ -0,0 +1,6 @@ +namespace Application.DataTransferObjects.Stat; + +public class AllianceUseToolCount +{ + public int Amount { get; set; } +} \ No newline at end of file diff --git a/Application/Interfaces/IStatRepository.cs b/Application/Interfaces/IStatRepository.cs new file mode 100644 index 0000000..9de11c8 --- /dev/null +++ b/Application/Interfaces/IStatRepository.cs @@ -0,0 +1,9 @@ +using Application.Classes; +using Application.DataTransferObjects.Stat; + +namespace Application.Interfaces; + +public interface IStatRepository +{ + Task> GetAllianceUseToolCountAsync(CancellationToken cancellationToken); +} \ No newline at end of file diff --git a/Application/Repositories/StatRepository.cs b/Application/Repositories/StatRepository.cs new file mode 100644 index 0000000..b0f5d27 --- /dev/null +++ b/Application/Repositories/StatRepository.cs @@ -0,0 +1,20 @@ +using Application.Classes; +using Application.DataTransferObjects.Stat; +using Application.Interfaces; +using Database; +using Microsoft.EntityFrameworkCore; + +namespace Application.Repositories; + +public class StatRepository(ApplicationContext dbContext) : IStatRepository +{ + public async Task> GetAllianceUseToolCountAsync(CancellationToken cancellationToken) + { + var allianceCount = await dbContext.Alliances.CountAsync(cancellationToken); + + return Result.Success(new AllianceUseToolCount + { + Amount = allianceCount + }); + } +} \ No newline at end of file diff --git a/Ui/package-lock.json b/Ui/package-lock.json index e836d9d..16939fd 100644 --- a/Ui/package-lock.json +++ b/Ui/package-lock.json @@ -26,6 +26,7 @@ "bootswatch": "^5.3.3", "jest-editor-support": "*", "moment": "^2.30.1", + "ngx-countup": "^13.2.0", "ngx-mask": "^19.0.6", "ngx-pagination": "^6.0.3", "ngx-spinner": "^17.0.0", @@ -6536,6 +6537,11 @@ "node": ">= 0.10" } }, + "node_modules/countup.js": { + "version": "2.8.2", + "resolved": "https://registry.npmjs.org/countup.js/-/countup.js-2.8.2.tgz", + "integrity": "sha512-UtRoPH6udaru/MOhhZhI/GZHJKAyAxuKItD2Tr7AbrqrOPBX/uejWBBJt8q86169AMqKkE9h9/24kFWbUk/Bag==" + }, "node_modules/critters": { "version": "0.0.24", "resolved": "https://registry.npmjs.org/critters/-/critters-0.0.24.tgz", @@ -10841,6 +10847,19 @@ "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==", "dev": true }, + "node_modules/ngx-countup": { + "version": "13.2.0", + "resolved": "https://registry.npmjs.org/ngx-countup/-/ngx-countup-13.2.0.tgz", + "integrity": "sha512-8HpLinaRAg9qta8P/1BjP7IzVY8USNbn9981StlvYPNshLwZcmSmxKJIuHzE9zTL+y7ILWih2L4SDyJDfsIyVw==", + "dependencies": { + "countup.js": "^2.3.2", + "tslib": "^2.0.0" + }, + "peerDependencies": { + "@angular/common": ">=13.0.0", + "@angular/core": ">=13.0.0" + } + }, "node_modules/ngx-mask": { "version": "19.0.6", "resolved": "https://registry.npmjs.org/ngx-mask/-/ngx-mask-19.0.6.tgz", diff --git a/Ui/package.json b/Ui/package.json index 72a71ed..4265b58 100644 --- a/Ui/package.json +++ b/Ui/package.json @@ -28,6 +28,7 @@ "bootswatch": "^5.3.3", "jest-editor-support": "*", "moment": "^2.30.1", + "ngx-countup": "^13.2.0", "ngx-mask": "^19.0.6", "ngx-pagination": "^6.0.3", "ngx-spinner": "^17.0.0", diff --git a/Ui/src/app/Authentication/login/login.component.css b/Ui/src/app/Authentication/login/login.component.css index 332a49f..229e456 100644 --- a/Ui/src/app/Authentication/login/login.component.css +++ b/Ui/src/app/Authentication/login/login.component.css @@ -138,6 +138,18 @@ color: #ff3860; } +.alliance-counter { + margin-top: 20px; + font-size: 1rem; + font-weight: 500; + text-align: center; + color: #ffffffcc; +} +.count { + color: #4fc3f7; + font-weight: bold; + margin: 0 6px; +} /* Footer */ /*.footer {*/ /* display: flex;*/ diff --git a/Ui/src/app/Authentication/login/login.component.html b/Ui/src/app/Authentication/login/login.component.html index 5d3b89f..5b513c3 100644 --- a/Ui/src/app/Authentication/login/login.component.html +++ b/Ui/src/app/Authentication/login/login.component.html @@ -80,6 +80,13 @@ +
+ Currently + + + + alliances use the tool +