Skip to content

Commit

Permalink
Merge pull request #769 from EvildoerXiaoyy/hotfix_agis
Browse files Browse the repository at this point in the history
bugfix: 修复仪表盘跳转异常
  • Loading branch information
EvildoerXiaoyy authored Mar 8, 2022
2 parents f0400f9 + c6a67ed commit 9c20fe9
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 40 deletions.
72 changes: 33 additions & 39 deletions bk_dataview/grafana/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,29 +57,44 @@
)
+ f"""window.ageisId = "{settings.TAM_AEGIS_KEY}";"""
+ """
{}
var _wr = function(type) {{
setTimeout(function(){
if(window.ageisId) {
const aegis = new Aegis({
id: window.ageisId, // 项目ID
uin: window.grafanaBootData ? (window.grafanaBootData.user ? window.grafanaBootData.user.name : "dev") : "dev",
reportApiSpeed: true, // 接口测速
reportAssetSpeed: true, // 静态资源测速
pagePerformance: true, // 页面测速
onError: true, // 当前实例是否需要进行错误监听,获取错误日志
delay: 1000, // 上报节流时间,在该时间段内的上报将会合并到一个上报请求中
repeat: 5, // 重复上报次数,对于同一个错误超过多少次不上报
offlineLog: false, // 是否使用离线日志
restfulApiList: [], // 当开启了接口测速,且项目中有些接口采用了 restful 规范,需要在该配置中列出,帮助 Aegis 识别哪些接口是同一条接
spa: true
})
}
},5000);
var _wr = function(type) {
var orig = history[type];
return function() {{
return function() {
var rv = orig.apply(this, arguments);
var e = new Event(type);
e.arguments = arguments;
window.dispatchEvent(e);
return rv;
}};
}};
};
};
history.pushState = _wr('pushState');
history.replaceState = _wr('replaceState');
["popstate", "replaceState", "pushState"].forEach(function(eventName) {{
window.addEventListener(eventName, function() {{
window.parent.postMessage({{ pathname: this.location.pathname }}, "*");
}});
}});
window.addEventListener('message', function(e) {{
if(e && e.data ) {{
["popstate", "replaceState", "pushState"].forEach(function(eventName) {
window.addEventListener(eventName, function() {
window.parent.postMessage({ pathname: this.location.pathname }, "*");
});
});
window.addEventListener('message', function(e) {
if(e && e.data ) {
var dom = null;
switch(e.data) {{
switch(e.data) {
case 'create':
dom = document.querySelector('.sidemenu__top .sidemenu-item:nth-child(2) .dropdown-menu li:nth-child(2) a');
break;
Expand All @@ -89,33 +104,12 @@
case 'import':
dom = document.querySelector('.sidemenu__top .sidemenu-item:nth-child(2) .dropdown-menu li:nth-child(4) a');
break;
}}
}
dom && dom.click()
}}
}})
}
})
</script>
""".format(
"""
setTimeout(function(){
if(window.ageisId) {
const aegis = new Aegis({
id: window.ageisId, // 项目ID
uin: window.grafanaBootData ? (window.grafanaBootData.user ? window.grafanaBootData.user.name : "dev") : "dev",
reportApiSpeed: true, // 接口测速
reportAssetSpeed: true, // 静态资源测速
pagePerformance: true, // 页面测速
onError: true, // 当前实例是否需要进行错误监听,获取错误日志
delay: 1000, // 上报节流时间,在该时间段内的上报将会合并到一个上报请求中
repeat: 5, // 重复上报次数,对于同一个错误超过多少次不上报
offlineLog: false, // 是否使用离线日志
restfulApiList: [], // 当开启了接口测速,且项目中有些接口采用了 restful 规范,需要在该配置中列出,帮助 Aegis 识别哪些接口是同一条接
spa: true
})
}
},5000);"""
if settings.TAM_AEGIS_KEY
else ""
)
"""
},
"BACKEND_CLASS": "bk_dataview.grafana.backends.api.APIHandler",
}
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/nav/head-nav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ export default {
resMenu.children.forEach((item) => {
item.id = this.routeMap[item.id] || item.id;
if (resMenu.id === 'dashboard') {
item.id = item.id.replace(/_/g, '-');
item.id = item.id.replace(/-/g, '_');
}
const menu = oldMenu.children.find(menuItem => menuItem.id === item.id);
if (menu) {
Expand Down

0 comments on commit 9c20fe9

Please sign in to comment.