Skip to content

Commit

Permalink
feat: 添加项目描述
Browse files Browse the repository at this point in the history
  • Loading branch information
Qinyouzeng committed Oct 30, 2024
1 parent 173b197 commit cc20561
Show file tree
Hide file tree
Showing 31 changed files with 203 additions and 275 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal ApmService(ICaller caller) : base(caller, "/api/apm") { }

public Task<PaginatedListBase<EndpointListDto>> GetEndpointPageAsync(Guid teamId, BaseApmRequestDto query, string? projectId = default, string? appType = default) => Caller.GetAsync<PaginatedListBase<EndpointListDto>>($"{RootPath}/endpoints?teamId={teamId}&project={projectId}{(string.IsNullOrEmpty(appType) ? "" : $"&appType={appType}")}", data: query)!;

public Task<PaginatedListBase<ErrorMessageDto>> GetErrorsPageAsync(Guid teamId, ApmEndpointRequestDto query, string? projectId = default, string? appType = default,bool ignoreTeam=false) => Caller.GetAsync<PaginatedListBase<ErrorMessageDto>>($"{RootPath}/errors?teamId={teamId}&project={projectId}&ignoreTeam={ignoreTeam}{(string.IsNullOrEmpty(appType) ? "" : $"&appType={appType}")}", data: query)!;
public Task<PaginatedListBase<ErrorMessageDto>> GetErrorsPageAsync(Guid teamId, ApmEndpointRequestDto query, string? projectId = default, string? appType = default, bool ignoreTeam = false) => Caller.GetAsync<PaginatedListBase<ErrorMessageDto>>($"{RootPath}/errors?teamId={teamId}&project={projectId}&ignoreTeam={ignoreTeam}{(string.IsNullOrEmpty(appType) ? "" : $"&appType={appType}")}", data: query)!;

public Task<List<ChartPointDto>> GetSpanErrorsAsync(ApmEndpointRequestDto query) => Caller.GetAsync<List<ChartPointDto>>($"{RootPath}/spanErrors", data: query)!;

Expand All @@ -25,11 +25,11 @@ internal ApmService(ICaller caller) : base(caller, "/api/apm") { }

public Task<EndpointLatencyDistributionDto> GetLatencyDistributionAsync(ApmEndpointRequestDto query) => Caller.GetAsync<EndpointLatencyDistributionDto>($"{RootPath}/latencyDistributions", data: query)!;

public Task<Dictionary<string, List<EnviromentAppDto>>> GetEnviromentServiceAsync(Guid teamId, DateTime start, DateTime end, string env) => Caller.GetAsync<Dictionary<string, List<EnviromentAppDto>>>($"{RootPath}/enviromentService", data: new { teamId, start, end, env })!;
public Task<Dictionary<string, List<EnviromentAppDto>>> GetEnviromentServiceAsync(Guid teamId, DateTime start, DateTime end, string? env = default, bool ignoreTeam = false) => Caller.GetAsync<Dictionary<string, List<EnviromentAppDto>>>($"{RootPath}/enviromentService", data: new { teamId, start, end, env, ignoreTeam })!;

public Task<PaginatedListBase<TraceResponseDto>> GetTraceListAsync(BaseRequestDto query) => Caller.GetByBodyAsync<PaginatedListBase<TraceResponseDto>>($"{RootPath}/traceList", body: query)!;

public Task<PaginatedListBase<LogResponseDto>> GetLogListAsync(Guid teamId, BaseRequestDto query, string? projectId = default, string? appType = default,bool ignoreTeam=false) => Caller.GetByBodyAsync<PaginatedListBase<LogResponseDto>>($"{RootPath}/logList?teamId={teamId}&project={projectId}&&ignoreTeam={ignoreTeam}{(string.IsNullOrEmpty(appType) ? "" : $"&appType={appType}")}", body: query)!;
public Task<PaginatedListBase<LogResponseDto>> GetLogListAsync(Guid teamId, BaseRequestDto query, string? projectId = default, string? appType = default, bool ignoreTeam = false) => Caller.GetByBodyAsync<PaginatedListBase<LogResponseDto>>($"{RootPath}/logList?teamId={teamId}&project={projectId}&&ignoreTeam={ignoreTeam}{(string.IsNullOrEmpty(appType) ? "" : $"&appType={appType}")}", body: query)!;

public Task<PhoneModelDto> GetDeviceModelAsync(string brand, string model) => Caller.GetAsync<PhoneModelDto>($"{RootPath}/model?brand={brand}&model={model}")!;

Expand Down
35 changes: 17 additions & 18 deletions src/Services/Masa.Tsc.Service.Admin/Services/ApmService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,32 +215,31 @@ public async Task<PaginatedListBase<LogResponseDto>> GetLogList([FromServices] I
public async Task<PhoneModelDto> GetModel([FromServices] IApmService apmService, string brand, string model)
=> await apmService.GetDeviceModelAsync(brand, model);

public async Task<Dictionary<string, List<EnviromentAppDto>>> GetEnviromentService([FromServices] IApmService apmService, [FromServices] IAuthClient authClient, [FromServices] IPmClient pmClient, IMultiEnvironmentContext multiEnvironmentContext, Guid teamId, string start, string end)
public async Task<Dictionary<string, List<EnviromentAppDto>>> GetEnviromentService([FromServices] IApmService apmService
, [FromServices] IAuthClient authClient
, [FromServices] IPmClient pmClient
, IMultiEnvironmentContext multiEnvironmentContext, Guid teamId, string start, string end, bool ignoreTeam = false)
{
var data = await apmService.GetEnviromentServices(new BaseApmRequestDto
{
Start = start.ParseUTCTime(),
End = end.ParseUTCTime()
});
//#if RELEASE

var teamData = await GetTeamAllEnvAppsAsync(authClient, pmClient, teamId, data.Keys);
if (teamData.Count == 0)
return new Dictionary<string, List<EnviromentAppDto>> { { multiEnvironmentContext.CurrentEnvironment, new() } };
var result = new Dictionary<string, List<EnviromentAppDto>>();
foreach (var env in teamData.Keys)
{
var teamData = await GetTeamAllEnvAppsAsync(authClient, pmClient, teamId, data.Keys);
if (teamData.Count == 0)
return new Dictionary<string, List<EnviromentAppDto>> { { multiEnvironmentContext.CurrentEnvironment, new() } };
var result = new Dictionary<string, List<EnviromentAppDto>>();
foreach (var env in teamData.Keys)
{
if (!data.ContainsKey(env)) continue;
result.Add(env, teamData[env].Where(app => data[env].Contains(app.AppId)).ToList());
}
if (result.Count == 0)
{
result.Add(multiEnvironmentContext.CurrentEnvironment, new());
}
return result;
if (!ignoreTeam && !data.ContainsKey(env)) continue;
result.Add(env, teamData[env].Where(app => data[env].Contains(app.AppId)).ToList());
}
//#endif
//return data;
if (result.Count == 0)
{
result.Add(multiEnvironmentContext.CurrentEnvironment, new());
}
return result;
}

private async Task<bool> GetApps<Request>(Request request, IAuthClient authClient, IPmClient pmClient, Guid teamId, string? project, AppTypes? appType) where Request : BaseApmRequestDto
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

25 changes: 24 additions & 1 deletion src/Web/Masa.Tsc.Web.Admin.Rcl/Components/Apm/ApmLogView.razor
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,30 @@
<tr>
<td></td>
<td>@currentName</td>
<td><div class="text-wrap">@value</div></td>
<td><div class="text-wrap">
@if (string.Equals(currentName, "Resource.service.name"))
{
var service = value?.ToString();
var text = GetService(service, Masa.Tsc.Web.Admin.Rcl.Pages.App.Index.GetService)?.AppDescription;
if (string.IsNullOrEmpty(text))
text = "";
<MTooltip Top Left Context="tooltipContent">
<ActivatorContent>
<div @attributes="@tooltipContent.Attrs" class="text-truncate">
@service
</div>
</ActivatorContent>
<ChildContent>
<span>@text</span>
</ChildContent>
</MTooltip>

}
else
{
@value
}
</div></td>
</tr>
}
else if (value is IDictionary<string, object> dicValue)
Expand Down
11 changes: 0 additions & 11 deletions src/Web/Masa.Tsc.Web.Admin.Rcl/Components/Apm/ApmMultiSearch.razor

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@
<SAutoComplete Value=Search.Service
ValueChanged="OnServiceChanged"
Items="services"
TItem="string"
TItem="ValueTuple<string,string>"
TValue="string"
TItemValue="string"
ItemText="item=>item"
ItemValue="item=>item"
ItemText="@(item=>string.IsNullOrEmpty(item.Item2)?item.Item1:$"{item.Item1} {item.Item2}")"
ItemValue="item=>item.Item1"
Disabled="isServiceLoading"
Small
HideSelected=false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public partial class ApmSearchComponent
new (ApmComparisonTypes.Day, "Day before"),
new (ApmComparisonTypes.Week, "Week before"),
};
private List<string> services = new();
private List<ValueTuple<string, string>> services = new();
private List<string> projects = new();
private List<string> environments = new();
private Dictionary<string, List<EnviromentAppDto>> enviromentServices = new();
Expand Down Expand Up @@ -259,10 +259,10 @@ private async Task LoadServiceAsync()
projects = projects.Where(app => app.AppType.ToString() == Search.ServiceType).ToList();
}

services = projects.Select(app => app.AppId).Distinct().ToList();
services = projects.Select(app => ValueTuple.Create(app.AppId, app.AppDescription)).Distinct().ToList();
if (!string.IsNullOrEmpty(Search.Project) && !projects.Exists(p => p.ProjectId == Search.Project))
Search.Service = default!;
if (!string.IsNullOrEmpty(Search.Service) && !services.Contains(Search.Service))
if (!string.IsNullOrEmpty(Search.Service) && !services.Exists(item => item.Item1 == Search.Service))
Search.Service = default!;
isServiceLoading = false;
await Task.CompletedTask;
Expand Down
19 changes: 18 additions & 1 deletion src/Web/Masa.Tsc.Web.Admin.Rcl/Components/Apm/ApmTraceView.razor
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,24 @@ else
var time1 = (DateTime)dic["Timestamp"];
DateTime start = time1.AddHours(-6), end = time1.AddHours(6);
var url = path?.ToString().Split('?')[0];
<a style="text-decoration:none" href="/apm/endpoints/@(HttpUtility.UrlEncode(url)+GetUrlParam(service: resources["service.name"].ToString(), env: resources["service.namespace"].ToString(),endpoint:url, start: start, end: end,traceId:dic["TraceId"].ToString()))" target="_blank">@value</a>
<a style="text-decoration:none" href="/apm/endpoints/@(HttpUtility.UrlEncode(url)+ GetUrlParam(service: resources["service.name"].ToString(), env: resources["service.namespace"].ToString(),endpoint:url, start: start, end: end,traceId:dic["TraceId"].ToString()))" target="_blank">@value</a>
}
else if (string.Equals(currentName, "Resource.service.name"))
{
var service = value?.ToString();
var text = GetService(service, Masa.Tsc.Web.Admin.Rcl.Pages.App.Index.GetService)?.AppDescription;
if (string.IsNullOrEmpty(text))
text = "";
<MTooltip Top Left Context="tooltipContent">
<ActivatorContent>
<div @attributes="@tooltipContent.Attrs" class="text-truncate">
@service
</div>
</ActivatorContent>
<ChildContent>
<span>@text</span>
</ChildContent>
</MTooltip>
}
else
{
Expand Down
2 changes: 0 additions & 2 deletions src/Web/Masa.Tsc.Web.Admin.Rcl/Data/Apm/SearchData.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) MASA Stack All rights reserved.
// Licensed under the Apache License. See LICENSE.txt in the project root for license information.

using Masa.BuildingBlocks.StackSdks.Pm.Enum;

namespace Masa.Tsc.Web.Admin.Rcl.Data.Apm;

public class SearchData
Expand Down
Loading

0 comments on commit cc20561

Please sign in to comment.