Skip to content

Commit 444f7c7

Browse files
committed
fixed small bugs
1 parent 9aa7f17 commit 444f7c7

File tree

5 files changed

+43
-14
lines changed

5 files changed

+43
-14
lines changed

src/views/codeAnalytics/CodeObjectGroups/EndpointGroup.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { StringifyOptions } from "querystring";
22
import { EndpointSchema } from "../../../services/analyticsProvider";
33
import { GroupItem, IListGroupItemBase } from "../../ListView/IListViewGroupItem";
4+
import { adjustHttpRouteIfNeeded } from "../InsightListView/EndpointInsight";
45
import { ICodeObjectScopeGroupCreator } from "./ICodeObjectScopeGroupCreator";
56

67

@@ -10,17 +11,30 @@ export class EndpointGroup implements ICodeObjectScopeGroupCreator{
1011
){
1112

1213
}
14+
15+
private getRoutePreix(route:string){
16+
if (route.startsWith(EndpointSchema.HTTP)){
17+
return 'HTTP';
18+
}
19+
else if (route.startsWith(EndpointSchema.RPC)){
20+
return 'RPC';
21+
}
22+
else {
23+
return 'UKNOWN';
24+
}
25+
}
1326
async create(type: string, name: string): Promise<IListGroupItemBase| undefined> {
1427

28+
const fullRoute = adjustHttpRouteIfNeeded(name);
1529
const shortRouteName = EndpointSchema.getShortRouteName(name);
1630
const parts = shortRouteName.split(' ');
1731

18-
return new GroupItem(name, "Endpoint", `
32+
return new GroupItem(fullRoute, "Endpoint", `
1933
<div class="group-item">
2034
<span class="scope">REST: </span>
2135
<span class="codicon codicon-symbol-interface" title="Endpoint"></span>
2236
<span class="uppercase">
23-
<strong>HTTP </strong>${parts[0]}&nbsp;</span>
37+
<strong>${this.getRoutePreix(fullRoute)} </strong>${parts[0]}&nbsp;</span>
2438
<span>${parts[1]}</span>
2539
</div>
2640
`);

src/views/codeAnalytics/InsightListView/EndpointInsight.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export class LowUsageListViewItemsCreator implements IInsightListViewItemsCreato
8282
return {
8383
getHtml: () => this.template.generateHtml(codeObjectsInsight.maxCallsIn1Min, "Endpoint low traffic", "Servicing a low number of requests", "gauge_low.png"),
8484
sortIndex: 0,
85-
groupId: EndpointSchema.getShortRouteName(codeObjectsInsight.route)
85+
groupId: codeObjectsInsight.route
8686
};
8787
}
8888

@@ -108,7 +108,7 @@ export class NormalUsageListViewItemsCreator implements IInsightListViewItemsCre
108108
return {
109109
getHtml: () => this.template.generateHtml(codeObjectsInsight.maxCallsIn1Min, "Endpoint normal level of traffic", "Servicing an average number of requests", "guage_normal.png"),
110110
sortIndex: 0,
111-
groupId: EndpointSchema.getShortRouteName(codeObjectsInsight.route)
111+
groupId: codeObjectsInsight.route
112112
};
113113
}
114114

@@ -150,7 +150,7 @@ export class HighUsageListViewItemsCreator implements IInsightListViewItemsCreat
150150
return {
151151
getHtml: () => this.template.generateHtml(codeObjectsInsight.maxCallsIn1Min, "Endpoint high traffic", "Servicing a high number of requests", "guage_high.png"),
152152
sortIndex: 0,
153-
groupId: EndpointSchema.getShortRouteName(codeObjectsInsight.route)
153+
groupId: codeObjectsInsight.route
154154
};
155155
}
156156

@@ -231,7 +231,7 @@ export class SlowestSpansListViewItemsCreator implements IInsightListViewItemsCr
231231
return {
232232
getHtml: () => html,
233233
sortIndex: 0,
234-
groupId: EndpointSchema.getShortRouteName(codeObjectsInsight.route)
234+
groupId: codeObjectsInsight.route
235235
};
236236
}
237237

@@ -309,7 +309,7 @@ export class SlowEndpointListViewItemsCreator implements IInsightListViewItemsCr
309309
return {
310310
getHtml: () => html,
311311
sortIndex: 0,
312-
groupId: EndpointSchema.getShortRouteName(codeObjectsInsight.route)
312+
groupId: codeObjectsInsight.route
313313
};
314314
}
315315

@@ -320,16 +320,21 @@ export class SlowEndpointListViewItemsCreator implements IInsightListViewItemsCr
320320
}
321321

322322

323-
export function adjustHttpRouteIfNeeded(endpointInsight: EndpointInsight): void {
324-
const origValue = endpointInsight.route;
323+
export function adjustHttpRouteIfNeeded(route: string): string {
324+
const origValue = route;
325325
if (origValue.startsWith(EndpointSchema.HTTP)) {
326-
return;
326+
return origValue;
327327
}
328328
if (origValue.startsWith(EndpointSchema.RPC)) {
329-
return;
329+
return origValue;
330330
}
331331
// default behaviour, to be backword compatible, where did not have the scheme part of the route, so adding it as HTTP one
332-
endpointInsight.route = EndpointSchema.HTTP + origValue;
332+
return EndpointSchema.HTTP + origValue;
333+
}
334+
335+
export function adjustHttpInsightIfNeeded(endpointInsight: EndpointInsight): void {
336+
337+
endpointInsight.route = adjustHttpRouteIfNeeded(endpointInsight.route);
333338
}
334339

335340

src/views/codeAnalytics/InsightListView/IInsightListViewItemsCreator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { UsageStatusResults } from "../../../services/analyticsProvider";
22
import { IListViewItemBase } from "../../ListView/IListViewItem";
33
import { CodeObjectInfo } from "../codeAnalyticsView";
4-
import { EndpointInsight, adjustHttpRouteIfNeeded } from "./EndpointInsight";
4+
import { EndpointInsight, adjustHttpRouteIfNeeded, adjustHttpInsightIfNeeded } from "./EndpointInsight";
55

66
export interface CodeObjectInsight{
77
codeObjectId: string,
@@ -47,7 +47,7 @@ export class InsightListViewItemsCreator implements IInsightListViewItemsCreator
4747
codeObjectInsights.forEach(coi => {
4848
if (coi.hasOwnProperty("route")) {
4949
const endpointInsight = coi as EndpointInsight;
50-
adjustHttpRouteIfNeeded(endpointInsight);
50+
adjustHttpInsightIfNeeded(endpointInsight);
5151
}
5252
});
5353
}

src/views/codeAnalytics/codeAnalyticsView.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,12 @@ class CodeAnalyticsViewProvider implements vscode.WebviewViewProvider,vscode.Dis
277277
if (event.environment){
278278
await Settings.environment.set(event.environment);
279279
}
280+
if (this._overlay.isVisible){
281+
const editor = vscode.window.activeTextEditor;
282+
if (editor){
283+
this.getCodeObjectOrShowOverlay(editor.document,editor.selection.anchor);
284+
}
285+
}
280286
this.onTabRefreshRequested(new UiMessage.Notify.TabRefreshRequested());
281287
}
282288
public async onTabChangedEvent(event: UiMessage.Notify.TabChanged)

src/views/codeAnalytics/overlayView.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { HtmlHelper } from "./common";
88

99
export class OverlayView
1010
{
11+
12+
1113
public static UnsupportedDocumentOverlayId = "UnsupportedDocument";
1214
public static CodeSelectionNotFoundOverlayId = "CodeSelectionNotFound";
1315

@@ -44,6 +46,8 @@ export class OverlayView
4446
this.show(html, OverlayView.UnsupportedDocumentOverlayId);
4547
}
4648

49+
50+
4751
public async showCodeSelectionNotFoundMessage(docInfo: DocumentInfo){
4852
const links = [];
4953

0 commit comments

Comments
 (0)