Add title for project dependency

This commit is contained in:
Kolosov Alexandr 2024-04-01 18:37:40 +05:00
parent 11e9fee9c3
commit f80a78f8cb
16 changed files with 186 additions and 119 deletions

View File

@ -9,35 +9,52 @@
 be nice 󰚩 SEO  site  be nice 󰚩 SEO  site
󰬟 too old  VCS  api 󰬟 too old  VCS  api
󰦖 wait 󰲽 build 󱓞 release   󱓟 releases  Fact  2023
󱔢 reopen 󱞈 testing 󰶯 hotfix   󱓟 releases  Fact
󱞇 in progress 󰦕 done  publish   󱓟 releases  Planned
󱞇 review 󱄊 cancel   󱓟 releases  Planned  2024-12-31 xfirm
  󰧑 competencies
  releases 󱓟  Fact  2023   󰶼 growth zone
  releases 󱓟  Fact    dependencies
  releases 󱓟  Planned   󱁤 tools
  releases 󱓟  Planned  2024-12-31 xfirm
  competencies 󰧑
  growth zone 󰶼
  dependencies  󰦖 wait 󰲽 build
󱔢 reopen 󱞈 testing
󱞇 in progress 󰦕 done
󱞇 review 󱄊 cancel
┌──────────────────────────────────────────────────────────────────────── Planned release ─────────────────────────────────────────────────────────────────┐ ┌──────────────────────────────────────────────────────────────────────── Planned release ─────────────────────────────────────────────────────────────────┐
│ 2024-12-31 4/11 xfirm [############# ] //green - done, blue - test, pink review/build, orange WIP │ 󱓟 Planned 󱜜 󰲌 application  Tasks
│ 4/11 xfirm [###############.......] //green - done, blue - test, pink review/build │ 2024-12-31 1d elk-site 4/11 󰦕 󰦕 󰦕 󰦕 󱞇 󱞇 󱞇 󱞈 󱞈 󱔢 󰦖 󰦖 󰦖
│ 2024-12-31 4/11 xfirm [###############.......] //green - done, blue - test, pink review/build │ elk-site 2/5 󰦕 󰦕 󰦖 󰦖 󰦖
│ 2024-12-31 xfirm 4/11 [############..........] //green - done, blue - test, pink review/build │ elk-site 22/22 󰦕 󰦕 󰦕 󰦕 󰦕 󰦕 󰦕 󰦕 󰦕 󰦕 󰦕 󰦕 󰦕 󰦕 󰦕 󰦕 󱞇 󱞇 󱞇 󱞈 󱞈 󱞈 󱔢 󰦖 󰦖 󰦖
│ 2024-12-31 xfirm 4/11 [############..........] //green - done, blue - test, pink review/build │ 2024-12-31 12d xfirm 4/12 󰦕 󰦕 󰦕 󰦕 󱞇 󱞇 󱞇 󱞈 󱞈 󱞈 󱔢 󰦖 󰦖 󰦖
│ 2024-12-31 xfirm 4/11 [############..........] //green - done, blue - test, pink review/build
│ 2024-12-31 xfirm 4/11 [############..........] //green - done, blue - test, pink review/build
│ 2024-12-31 xfirm 4/11 [############..........] //green - done, blue - test, pink review/build
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
󰨑 show stopper 󰦖 wait 󰲽 build  feature
󰨑 first of all 󱔢 reopen 󱞈 testing  bug
󰨑 just do it 󱞇 in progress 󰦕 done
󰨑 doesn't rush 󱞇 review 󱄊 cancel
┌──────────────────────────────────────────────────────────────────────── checkperson-site ────────────────────────────────────────────────────────────────┐ ┌──────────────────────────────────────────────────────────────────────── checkperson-site ────────────────────────────────────────────────────────────────┐
│ 󰨑 󰦖  ELK-3628 Create new menu.  Anna P. 󰵮 Petrov A. 󰙨 Ivanov I. │ 󰨑 󰦖  ELK-3628 Create new menu.  Anna P. 󰵮 Petrov A. 󰙨 Ivanov I.
│ 󰨑 󰦕  XF-12 Change input hover.  Alex K. 󰵮 Ivanov I. 󰙨 Petrov A., Petrov B. │ 󰨑 󰦕  XF-12 Change input hover.  Alex K. 󰵮 Ivanov I. 󰙨 Petrov A., Petrov B.
│ 󰨑 󱞇  ELK-3628 Crete new project with menu, profile, issues and #  Anna P. 󰵮 Ivanov I. 󰙨 Petrov A., Petrov B. │ 󰨑 󱞇  ELK-3628 Crete new project with menu, profile, issues and #  Anna P. 󰵮 Ivanov I. 󰙨 Petrov A., Petrov B.
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
 publish
󱓞 release
󰶯 hotfix
󱓞 release candidate
┌─────────────────────────────────────────────────────────────────────────── Actual releases 2023 ─────────────────────────────────────────────────────────┐ ┌─────────────────────────────────────────────────────────────────────────── Actual releases 2023 ─────────────────────────────────────────────────────────┐
│ Jan Feb Mar Apl May Jun Jul Aug Sep Oct Nov Dec │ Jan Feb Mar Apl May Jun Jul Aug Sep Oct Nov Dec
│ ├─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤ │ ├─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
@ -48,5 +65,12 @@
 GA4  Jaeger 󰡾 Fallback  Screenshots  Connected  Auth
Я YM  Prometheus 󰉼 Renovate  End2End  Disconnected 󰖟 WWW
󰩃 Husky 󱎴 Sentry 󱉕 Lighthouse  Unit  Not implemented 󰚩 SEO
 Probs  Grafana 󱂅 Kibana  Coverage  No need
┌─────────────────────────────────────────────────────────────────────────── Tools ──────────────────────────────────┐
│   Я  󰉼 󰩃 󱎴 󱉕   󱂅     󰖟 󰚩  󰡾
│ elk-site                   
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

View File

@ -1,3 +1,4 @@
using System.Text;
using TUI.Engine.Attributes; using TUI.Engine.Attributes;
namespace TUI.Engine.Components; namespace TUI.Engine.Components;
@ -8,6 +9,8 @@ public sealed class Sketch : IEnumerable<string>
public Sketch(string content) => ContentRows = content.Split(Symbols.LineBreak); public Sketch(string content) => ContentRows = content.Split(Symbols.LineBreak);
public Sketch(StringBuilder builder) => ContentRows = builder.ToString().Split(Symbols.LineBreak);
public IEnumerator<string> GetEnumerator() => ContentRows.GetEnumerator(); public IEnumerator<string> GetEnumerator() => ContentRows.GetEnumerator();
public IEnumerable<string> Crop(Size maxSize) => ContentRows public IEnumerable<string> Crop(Size maxSize) => ContentRows

View File

@ -18,7 +18,7 @@ public static class SymbolExtensions
{ Symbols.Api, "7F52FF" }, { Symbols.Api, "7F52FF" },
{ Symbols.DockerImage, "086DD7" }, { Symbols.DockerImage, "086DD7" },
{ Symbols.NpmPackage, "CB0000" }, { Symbols.NpmPackage, "CB0000" },
{ Symbols.SEO, "4285F4" }, { Symbols.Seo, "4285F4" },
{ Symbols.Auth, "FFD700" }, { Symbols.Auth, "FFD700" },
}; };
} }

View File

@ -15,7 +15,7 @@ public static class Symbols
public const string Api = ""; public const string Api = "";
public const string DockerImage = ""; public const string DockerImage = "";
public const string NpmPackage = ""; public const string NpmPackage = "";
public const string SEO = "󰚩"; public const string Seo = "󰚩";
public const string Auth = ""; public const string Auth = "";
public const string NotFound = ""; public const string NotFound = "";

View File

@ -0,0 +1,47 @@
using System.Text;
using TUI.Domain;
using TUI.Engine;
using TUI.Engine.Attributes;
using TUI.Engine.Components;
using TUI.Engine.Theme;
using TUI.UserInterface;
using static TUI.Engine.Symbols;
namespace TUI.Controls.Components;
public class ProjectTitle : ComponentBase
{
private readonly Project _project;
public ProjectTitle(Project project)
{
_project = project;
}
protected override Sketch DrawComponent(Size minSize)
{
var builder = new StringBuilder();
builder.Append(GetHub().Colorized());
builder.Append(Space);
builder.Append((_project.IsPublicNetwork ? NetworkPublic : NetworkPrivate).Colorized());
builder.Append(Space);
builder.Append(_project.SeoDependent ? Seo.Colorized() : Seo.Disable());
builder.Append(Space);
builder.Append(_project.HasAuth ? Auth.Colorized() : Auth.Disable());
builder.Append(Space);
builder.Append(GetApplicationType().Colorized());
builder.Append(Space);
builder.Append(_project.Name.Disable());
return new Sketch(builder);
}
private string GetHub() => _project.Hub == "gitlab" ? GitLab : GitHub;
private string GetApplicationType()
{
foreach (var application in Icons.Applications.Where(application => _project.Tags.Have(application.Value)))
return application.Key;
return Undefined.Hint();
}
}

View File

@ -1,61 +0,0 @@
using System.Text;
using TUI.Engine;
using TUI.Engine.Attributes;
using TUI.Engine.Attributes.Alignments;
using TUI.Engine.Components;
using TUI.Engine.Theme;
using TUI.UserInterface;
namespace TUI.Controls.Components;
public class Tag : ComponentBase
{
private IEnumerable<string> _tags;
private string _gitType;
public void Bind(IEnumerable<string> tags, string gitType)
{
_tags = tags;
_gitType = gitType;
}
public void Render(Horizontal horizontal, Size size)
{
var tagBuilder = new StringBuilder();
tagBuilder.Append(GetGitTypeImage(_gitType));
tagBuilder.Append(Symbols.Space);
tagBuilder.Append(_tags.Have("public") ? Symbols.NetworkPublic : Symbols.NetworkPrivate);
tagBuilder.Append(Symbols.Space);
tagBuilder.Append(_tags.Have("seo") ? Symbols.SEO : Symbols.SEO.Disable());
tagBuilder.Append(Symbols.Space);
tagBuilder.Append(_tags.Have("auth") ? Symbols.Auth : Symbols.Auth.Disable());
tagBuilder.Append(Symbols.Space);
tagBuilder.Append(GetApplicationType());
tagBuilder.Append(Symbols.Space);
// base.Render(tagBuilder, position, size);
}
private string GetApplicationType()
{
foreach (var application in Icons.Applications)
if (_tags.Have(application.Value))
return application.Key;
return Symbols.Undefined;
}
private static string GetGitTypeImage(string gitType) =>
gitType switch
{
"gitlab" => Symbols.GitLab,
"github" => Symbols.GitHub,
_ => Symbols.Git
};
protected override Sketch DrawComponent(Size minSize)
{
throw new NotImplementedException();
}
}

View File

@ -13,8 +13,7 @@ public class DashboardContainer : ContainerBase
public DashboardContainer() public DashboardContainer()
{ {
// var panel = new PanelComponent("Dependencies ".Info() + Symbols.Node.Colorized()); var panel = new PanelComponent(" ".Info() + "Dependencies".Main());
var panel = new PanelComponent("Dependencies".Info());
_content = new ContentContainer(); _content = new ContentContainer();
_content.SetOrientationVertical(); _content.SetOrientationVertical();
SetOrientationVertical(); SetOrientationVertical();

View File

@ -14,7 +14,7 @@ namespace TUI.Controls.Containers;
public class DependenciesContainer : ContainerBase public class DependenciesContainer : ContainerBase
{ {
private const int VersionColumnWidth = 10; private const int VersionColumnWidth = 10;
private const int TitleColumnWidth = 20; private const int TitleColumnWidth = 25;
private readonly Nodes _dependencies = new(); private readonly Nodes _dependencies = new();
@ -31,6 +31,7 @@ public class DependenciesContainer : ContainerBase
{ {
title.SetPadding(Level.Normal); title.SetPadding(Level.Normal);
title.SetFixed(Orientation.Horizontal, TitleColumnWidth); title.SetFixed(Orientation.Horizontal, TitleColumnWidth);
title.SetAlignment(Horizontal.Left);
_dependencies.Add(title); _dependencies.Add(title);
} }

View File

@ -11,7 +11,7 @@ public class TagHints : StaticComponentBase
{ {
{ Symbols.Auth, "Auth" }, { Symbols.Auth, "Auth" },
{ Symbols.NetworkPublic, "WWW" }, { Symbols.NetworkPublic, "WWW" },
{ Symbols.SEO, "SEO" }, { Symbols.Seo, "SEO" },
{ Symbols.Git, "VCS" } { Symbols.Git, "VCS" }
}; };

6
src/TUI/Domain/Hub.cs Normal file
View File

@ -0,0 +1,6 @@
namespace TUI.Domain;
public record Hub
{
}

12
src/TUI/Domain/Project.cs Normal file
View File

@ -0,0 +1,12 @@
namespace TUI.Domain;
public record Project(int Id, string Name, IEnumerable<string> Tags, string Hub)
{
private IEnumerable<Dependency> Dependencies => new List<Dependency>();
public bool IsPublicNetwork => Tags.Contains("public");
public bool HasAuth => Tags.Contains("auth");
public bool SeoDependent => Tags.Contains("seo");
}

View File

@ -1,10 +1,12 @@
using System.Diagnostics; using System.Diagnostics;
using TUI.Controls.Components;
using TUI.Controls.Containers; using TUI.Controls.Containers;
using TUI.Controls.Layouts; using TUI.Controls.Layouts;
using TUI.Controls.Statics; using TUI.Controls.Statics;
using TUI.Domain; using TUI.Domain;
using TUI.Engine.Rendering.Canvas; using TUI.Engine.Rendering.Canvas;
using TUI.Providers.Dependencies; using TUI.Providers.Dependencies;
using TUI.Store;
namespace TUI.Pages; namespace TUI.Pages;
@ -31,7 +33,7 @@ public abstract class PageBase : IPage
public class DependenciesPage : PageBase public class DependenciesPage : PageBase
{ {
private IEnumerable<Dependency> ConventionDependencies; private DependenciesStore _store;
public override void Render() public override void Render()
{ {
@ -43,23 +45,31 @@ public class DependenciesPage : PageBase
var dependenciesHeader = new DependenciesContainer(); var dependenciesHeader = new DependenciesContainer();
dependenciesHeader.AddTitleStub(); dependenciesHeader.AddTitleStub();
foreach (var conventionDependency in ConventionDependencies) foreach (var conventionDependency in _store.ConventionDependencies)
{ {
dependenciesHeader.AddDependency(conventionDependency); dependenciesHeader.AddDependency(conventionDependency);
} }
dashboard.AddChildren(dependenciesHeader); dashboard.AddChildren(dependenciesHeader);
// CommandLine = new CommandLine();
// DependenciesView = new DependenciesView(); foreach (var project in _store.Projects)
{
var projectDependencies = new DependenciesContainer();
projectDependencies.AddTitle(new ProjectTitle(project));
dashboard.AddChildren(projectDependencies);
}
var layout = new DashboardLayout(header, dashboard, copyright); var layout = new DashboardLayout(header, dashboard, copyright);
canvas.Draw(layout); canvas.Draw(layout);
// CommandLine = new CommandLine();
// DependenciesView = new DependenciesView();
} }
public override void Bind() public override void Bind()
{ {
var repo = new DependencyRepository(); _store = new DependenciesStore();
ConventionDependencies = repo.Read("javascript"); _store.Bind();
} }
// private bool _commandLineInDisplay; // private bool _commandLineInDisplay;

View File

@ -29,7 +29,7 @@ public class DependencyRepository
} }
} }
public IEnumerable<Dependency> Read(string stackName) public IEnumerable<Dependency> ReadConventions(string stackName)
{ {
return DependenciesDto.Stacks return DependenciesDto.Stacks
.Single(stack => stack.Name == stackName) .Single(stack => stack.Name == stackName)
@ -40,4 +40,22 @@ public class DependencyRepository
return new Dependency(convention.Version, brand); return new Dependency(convention.Version, brand);
}); });
} }
public IEnumerable<Project> ReadProjects(string stackName)
{
var projects = new List<Project>();
var hubs = DependenciesDto.Stacks
.Single(stack => stack.Name == stackName)
.Hubs;
foreach (var hub in hubs)
{
projects.AddRange(hub
.Projects
.Select(proj => new Project(proj.Id, proj.Name, proj.Tags, hub.Type)));
}
return projects;
}
} }

View File

@ -1,30 +1,41 @@
using System.Text.Json; using TUI.Domain;
using TUI.Providers.Dependencies; using TUI.Providers.Dependencies;
namespace TUI.Store; namespace TUI.Store;
public static class DependenciesStore public class DependenciesStore
{ {
private readonly static Dictionary<string, Package> Packages = new(); public IEnumerable<Dependency> ConventionDependencies;
private static Package DownloadPackage(ProjectDto projectDto) public IEnumerable<Project> Projects;
public void Bind()
{ {
// var endpoint = projectDto.Tags.Have("gitlab") ? GetGitlabEndpoint(projectDto) : projectDto.Repo; var repo = new DependencyRepository();
var endpoint = ""; ConventionDependencies = repo.ReadConventions("javascript");
if (Packages.TryGetValue(endpoint, out var downloadPackage)) return downloadPackage; Projects = repo.ReadProjects("javascript");
using HttpClient client = new();
var json = client.GetStringAsync(endpoint).GetAwaiter().GetResult();
var package = JsonSerializer.Deserialize<Package>(json);
Packages.Add(endpoint, package);
return package;
} }
private static string GetGitlabEndpoint(ProjectDto projectDto) // private readonly static Dictionary<string, Package> Packages = new();
{ //
var token = Environment.GetEnvironmentVariable("TLD_GITLAB_PAT"); // private static Package DownloadPackage(ProjectDto projectDto)
// return $"{projectDto.Repo}/api/v4/projects/{projectDto.ProjectId}/repository/files/package.json/raw?" + // {
// $"private_token={token}&ref=dev"; // // var endpoint = projectDto.Tags.Have("gitlab") ? GetGitlabEndpoint(projectDto) : projectDto.Repo;
return ""; // var endpoint = "";
} // if (Packages.TryGetValue(endpoint, out var downloadPackage)) return downloadPackage;
//
// using HttpClient client = new();
// var json = client.GetStringAsync(endpoint).GetAwaiter().GetResult();
// var package = JsonSerializer.Deserialize<Package>(json);
// Packages.Add(endpoint, package);
// return package;
// }
//
// private static string GetGitlabEndpoint(ProjectDto projectDto)
// {
// var token = Environment.GetEnvironmentVariable("TLD_GITLAB_PAT");
// // return $"{projectDto.Repo}/api/v4/projects/{projectDto.ProjectId}/repository/files/package.json/raw?" +
// // $"private_token={token}&ref=dev";
// return "";
// }
} }

View File

@ -30,8 +30,5 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\TUI.Engine\TUI.Engine.csproj"/> <ProjectReference Include="..\TUI.Engine\TUI.Engine.csproj"/>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Settings\" />
</ItemGroup>
</Project> </Project>

View File

@ -10,7 +10,7 @@ public static class Icons
{ {
{ Symbols.NpmPackage.Colorized(), "package" }, { Symbols.NpmPackage.Colorized(), "package" },
{ Symbols.DockerImage.Colorized(), "image" }, { Symbols.DockerImage.Colorized(), "image" },
{ Symbols.Site.Pastel("666666"), "site" }, { Symbols.Site.Colorized(), "site" },
{ Symbols.Api, "api" } { Symbols.Api, "api" }
}; };
} }