Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beautify Portal TraceLog UI interface #5148

Closed

Conversation

BlackBear2003
Copy link
Member

@BlackBear2003 BlackBear2003 commented May 24, 2024

What's the purpose of this PR

Beautify Portal TraceLog UI interface

Which issue(s) this PR fixes:

Fixes # #5147

Brief changelog

in portal front-end side

Follow this checklist to help us incorporate your contribution quickly and easily:

  • Read the Contributing Guide before making this pull request.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit tests to verify the code.
  • Run mvn clean test to make sure this pull request doesn't break anything.
  • Update the CHANGES log.

Summary by CodeRabbit

  • New Features

    • Introduced a treeview display for audit log trace details for better visualization.
  • Improvements

    • Enhanced UI styling with new treeview-specific styles.
    • Updated functionality to support treeview structure in trace details.
  • Bug Fixes

    • Removed outdated functions and improved initialization process for better performance.
  • Style

    • Adjusted border-radius for a more consistent look.

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label May 24, 2024
}

});
return roots.map(root => buildTreeNode(root));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6').

metaDetail: node
};
if (node.children) {
node.children.forEach(child => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6').

const parentSpanId = log.parentSpanId;

if (parentSpanId && nodeMap.has(parentSpanId)) {
const parent = nodeMap.get(parentSpanId);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).


data.forEach(item => {
const log = item.logDTO;
const parentSpanId = log.parentSpanId;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

var roots = [];

data.forEach(item => {
const log = item.logDTO;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

// 构建图的根节点列表
var roots = [];

data.forEach(item => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6').

function buildTree(data) {
// 构建 spanId 到节点的映射
var nodeMap = new Map();
data.forEach(item => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6').

Copy link
Contributor

coderabbitai bot commented May 24, 2024

Walkthrough

The changes introduce a treeview structure to display audit log trace details in the Apollo Portal. This involves replacing the previous list-based display with a more navigable treeview, using Bootstrap Treeview. The HTML, JavaScript, and CSS files have been updated accordingly to support this new structure.

Changes

Files & Paths Change Summary
.../audit_log_trace_detail.html Replaced list-based log details display with a <div id="treeview"> and added Bootstrap Treeview script.
.../AuditLogTraceDetailController.js Removed old functions, added tree building functions, and updated initialization to use treeview.
.../styles/audit-log.css Changed border-radius property and added styles for treeview elements.

Possibly related issues

In the portal's logs, a tree does grow,
With branches of details, in a structured flow.
No more lists, just nodes to see,
A clearer view for you and me.
🌳✨

Tip

New Features and Improvements

Review Settings

Introduced new personality profiles for code reviews. Users can now select between "Chill" and "Assertive" review tones to tailor feedback styles according to their preferences. The "Assertive" profile posts more comments and nitpicks the code more aggressively, while the "Chill" profile is more relaxed and posts fewer comments.

AST-based Instructions

CodeRabbit offers customizing reviews based on the Abstract Syntax Tree (AST) pattern matching. Read more about AST-based instructions in the documentation.

Community-driven AST-based Rules

We are kicking off a community-driven initiative to create and share AST-based rules. Users can now contribute their AST-based rules to detect security vulnerabilities, code smells, and anti-patterns. Please see the ast-grep-essentials repository for more information.

New Static Analysis Tools

We are continually expanding our support for static analysis tools. We have added support for biome, hadolint, and ast-grep. Update the settings in your .coderabbit.yaml file or head over to the settings page to enable or disable the tools you want to use.

Tone Settings

Users can now customize CodeRabbit to review code in the style of their favorite characters or personalities. Here are some of our favorite examples:

  • Mr. T: "You must talk like Mr. T in all your code reviews. I pity the fool who doesn't!"
  • Pirate: "Arr, matey! Ye must talk like a pirate in all yer code reviews. Yarrr!"
  • Snarky: "You must be snarky in all your code reviews. Snark, snark, snark!"

Revamped Settings Page

We have redesigned the settings page for a more intuitive layout, enabling users to find and adjust settings quickly. This change was long overdue; it not only improves the user experience but also allows our development team to add more settings in the future with ease. Going forward, the changes to .coderabbit.yaml will be reflected in the settings page, and vice versa.

Miscellaneous

  • Turn off free summarization: You can switch off free summarization of PRs opened by users not on a paid plan using the enable_free_tier setting.
  • Knowledge-base scope: You can now set the scope of the knowledge base to either the repository (local) or the organization (global) level using the knowledge_base setting. In addition, you can specify Jira project keys and Linear team keys to limit the knowledge base scope for those integrations.
  • High-level summary placement: You can now customize the location of the high-level summary in the PR description using the high_level_summary_placeholder setting (default @coderabbitai summary).
  • Revamped request changes workflow: You can now configure CodeRabbit to auto-approve or request changes on PRs based on the review feedback using the request_changes_workflow setting.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

github-actions bot commented May 24, 2024

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@BlackBear2003
Copy link
Member Author

I have read the CLA Document and I hereby sign the CLA

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 3d14e6f and 1688083.
Files selected for processing (3)
  • apollo-portal/src/main/resources/static/audit_log_trace_detail.html (3 hunks)
  • apollo-portal/src/main/resources/static/scripts/controller/AuditLogTraceDetailController.js (2 hunks)
  • apollo-portal/src/main/resources/static/styles/audit-log.css (2 hunks)
Files skipped from review due to trivial changes (1)
  • apollo-portal/src/main/resources/static/audit_log_trace_detail.html
Additional Context Used
Biome (20)
apollo-portal/src/main/resources/static/scripts/controller/AuditLogTraceDetailController.js (20)

58-61: This function expression can be turned into an arrow function.


51-64: This function expression can be turned into an arrow function.


47-65: This function expression can be turned into an arrow function.


70-74: Prefer for...of instead of forEach.


78-92: Prefer for...of instead of forEach.


102-105: Prefer for...of instead of forEach.


108-108: Avoid the delete operator which can impact performance.


136-149: This function expression can be turned into an arrow function.


158-170: This function expression can be turned into an arrow function.


172-179: Prefer for...of instead of forEach.


174-176: Template literals are preferred over string concatenation.


172-179: This function expression can be turned into an arrow function.


181-197: Prefer for...of instead of forEach.


183-197: This function expression can be turned into an arrow function.


22-22: Use let or const instead of var.


32-32: Use let or const instead of var.


69-70: Use let or const instead of var.


77-77: Use let or const instead of var.


95-96: Use let or const instead of var.


96-101: Use let or const instead of var.

Additional comments not posted (5)
apollo-portal/src/main/resources/static/styles/audit-log.css (2)

115-115: Updated border-radius from 3% to 0% to align with modern UI design principles.


142-145: Added styles for .treeview and .node-treeview to support the new treeview functionality in the audit log interface.

Also applies to: 147-151, 153-155, 157-159, 161-165

apollo-portal/src/main/resources/static/scripts/controller/AuditLogTraceDetailController.js (3)

26-26: Initialized new variables to support the treeview functionality in the audit log interface.


42-42: Updated the init function to call buildTraceDetailsTree for setting up the treeview on initialization.


114-117: Updated changeShowingDetail to handle node selection in the treeview, enhancing user interaction.

Comment on lines +45 to 65
function buildTraceDetailsTree() {
AuditLogService.find_trace_details($scope.traceId).then(
function (result) {
$scope.traceDetails = result;
$scope.traceDetailsTree = buildTree($scope.traceDetails);
// 初始化 Bootstrap Treeview
$(document).ready(function() {
$('#treeview').treeview({
color: "#252525",
showBorder: false,
data: $scope.traceDetailsTree,
levels: 99,
showTags: true,
onNodeSelected: function (event, data) {
changeShowingDetail(data.metaDetail);
}
});

});
}
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented buildTraceDetailsTree to fetch and display trace details using the treeview. Consider using arrow functions for better readability and ES6 features like for...of for iterating over arrays.

- data.forEach(item => {
+ for (const item of data) {

Committable suggestion was skipped due low confidence.

Comment on lines +67 to +112
function buildTree(data) {
// 构建 spanId 到节点的映射
var nodeMap = new Map();
data.forEach(item => {
nodeMap.set(item.logDTO.spanId, item);
});

// 构建图的根节点列表
var roots = [];

data.forEach(item => {
const log = item.logDTO;
const parentSpanId = log.parentSpanId;

if (parentSpanId && nodeMap.has(parentSpanId)) {
const parent = nodeMap.get(parentSpanId);
if (!parent.children) {
parent.children = [];
}
parent.children.push(item);
} else {
roots.push(item);
}
});

// 递归生成 Treeview 格式的节点
function buildTreeNode(node) {
var log = node.logDTO;
var treeNode = {
text: log.opName,
nodes: [],
metaDetail: node
};
if (node.children) {
node.children.forEach(child => {
treeNode.nodes.push(buildTreeNode(child));
});
}
if (treeNode.nodes.length === 0) {
delete treeNode.nodes;
}
return treeNode;
}

});
return roots.map(root => buildTreeNode(root));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored buildTree to construct the tree structure from trace details. Optimize by avoiding the delete operator and using for...of loops.

- data.forEach(item => {
+ for (const item of data) {
- delete treeNode.nodes;
+ if (treeNode.nodes.length === 0) treeNode.nodes = undefined;

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
function buildTree(data) {
// 构建 spanId 到节点的映射
var nodeMap = new Map();
data.forEach(item => {
nodeMap.set(item.logDTO.spanId, item);
});
// 构建图的根节点列表
var roots = [];
data.forEach(item => {
const log = item.logDTO;
const parentSpanId = log.parentSpanId;
if (parentSpanId && nodeMap.has(parentSpanId)) {
const parent = nodeMap.get(parentSpanId);
if (!parent.children) {
parent.children = [];
}
parent.children.push(item);
} else {
roots.push(item);
}
});
// 递归生成 Treeview 格式的节点
function buildTreeNode(node) {
var log = node.logDTO;
var treeNode = {
text: log.opName,
nodes: [],
metaDetail: node
};
if (node.children) {
node.children.forEach(child => {
treeNode.nodes.push(buildTreeNode(child));
});
}
if (treeNode.nodes.length === 0) {
delete treeNode.nodes;
}
return treeNode;
}
});
return roots.map(root => buildTreeNode(root));
}
function buildTree(data) {
// 构建 spanId 到节点的映射
var nodeMap = new Map();
for (const item of data) {
nodeMap.set(item.logDTO.spanId, item);
}
// 构建图的根节点列表
var roots = [];
for (const item of data) {
const log = item.logDTO;
const parentSpanId = log.parentSpanId;
if (parentSpanId && nodeMap.has(parentSpanId)) {
const parent = nodeMap.get(parentSpanId);
if (!parent.children) {
parent.children = [];
}
parent.children.push(item);
} else {
roots.push(item);
}
}
// 递归生成 Treeview 格式的节点
function buildTreeNode(node) {
var log = node.logDTO;
var treeNode = {
text: log.opName,
nodes: [],
metaDetail: node
};
if (node.children) {
for (const child of node.children) {
treeNode.nodes.push(buildTreeNode(child));
}
}
if (treeNode.nodes.length === 0) {
treeNode.nodes = undefined;
}
return treeNode;
}
return roots.map(root => buildTreeNode(root));
}

@BlackBear2003
Copy link
Member Author

d

@github-actions github-actions bot locked and limited conversation to collaborators May 24, 2024
@BlackBear2003 BlackBear2003 deleted the beautify-tracelog-ui branch May 24, 2024 12:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant