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

feat: 【apm】span详情信息增加复制按钮 --story=121094991 #4346

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 32 additions & 4 deletions bkmonitor/webpack/src/trace/pages/main/span-details.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,25 @@
}
}

%json-head {
position: absolute;
top: 8px;
right: 8px;
font-size: 16px;
color: #63656e;

.icon-monitor {
margin-left: 12px;
font-size: 16px;
color: #979ba5;
cursor: pointer;

&:hover {
color: #3a84ff;
}
}
}

.span-details-sideslider {
/* stylelint-disable-next-line declaration-no-important */
position: fixed !important;
Expand Down Expand Up @@ -82,7 +101,11 @@
}

.json-text-style {
@extend %json-style
@extend %json-style;

.json-head {
@extend %json-head;
}
}
}

Expand Down Expand Up @@ -567,8 +590,13 @@
}

.json-text-style {
position: relative;
margin-top: 12px;
@extend %json-style
@extend %json-style;

.json-head {
@extend %json-head;
}
}
}

Expand Down Expand Up @@ -755,5 +783,5 @@
.graph-tools {
/* stylelint-disable-next-line declaration-no-important */
left: 60px !important;
}
}
}
}
41 changes: 34 additions & 7 deletions bkmonitor/webpack/src/trace/pages/main/span-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -615,13 +615,22 @@ export default defineComponent({
function handleTitleCopy(content: string) {
let text = '';
const { spanID } = props.spanDetails;
if (content === 'text') {
text = spanID;
} else {
const hash = `#${window.__BK_WEWEB_DATA__?.baseroute || '/'}home/?app_name=${
appName.value
}&search_type=accurate&search_id=spanID&trace_id=${spanID}`;
text = location.href.replace(location.hash, hash);
switch (content) {
case 'text': {
text = spanID;
break;
}
case 'original': {
text = JSON.stringify(originalData.value);
break;
}
default: {
const hash = `#${window.__BK_WEWEB_DATA__?.baseroute || '/'}home/?app_name=${
appName.value
}&search_type=accurate&search_id=spanID&trace_id=${spanID}`;
text = location.href.replace(location.hash, hash);
break;
}
}
copyText(text, (msg: string) => {
Message({
Expand Down Expand Up @@ -974,6 +983,22 @@ export default defineComponent({
</Popover>
</div>
);

// 复制json字符串数据的icon
const copyOriginalElem = () => (
<div class='json-head'>
<Popover
content={t('复制')}
placement='right'
theme='light'
>
<span
class='icon-monitor icon-mc-copy'
onClick={() => handleTitleCopy('original')}
/>
</Popover>
</div>
);
if (window.enable_apm_profiling) {
tabList.push({
label: t('性能分析'),
Expand All @@ -993,6 +1018,7 @@ export default defineComponent({
>
{props.withSideSlider && showOriginalData.value ? (
<div class='json-text-style'>
{copyOriginalElem()}
<VueJsonPretty data={originalData.value} />
</div>
) : (
Expand Down Expand Up @@ -1021,6 +1047,7 @@ export default defineComponent({
<div class='accurate-original-panel'>
{titleInfoElem()}
<div class='json-text-style'>
{copyOriginalElem()}
<VueJsonPretty data={originalData.value} />
</div>
</div>
Expand Down