Skip to content

Commit

Permalink
bugfix: 企业版取消ageis相关配置
Browse files Browse the repository at this point in the history
  • Loading branch information
EvildoerXiaoyy committed Mar 7, 2022
1 parent 1e331da commit a206a37
Showing 1 changed file with 54 additions and 46 deletions.
100 changes: 54 additions & 46 deletions bk_dataview/grafana/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,65 +33,53 @@
"CODE_INJECTIONS": {
"<head>": """<head>
<style>
.sidemenu {
.sidemenu {{
display: none !important;
}
.navbar-page-btn .gicon-dashboard {
}}
.navbar-page-btn .gicon-dashboard {{
display: none !important;
}
.navbar .navbar-buttons--tv {
}}
.navbar .navbar-buttons--tv {{
display: none !important;
}
.css-1jrggg2 {
}}
.css-1jrggg2 {{
left: 0 !important;
}
.css-9nwlx8 {
}}
.css-9nwlx8 {{
display: none;
}
}}
</style>
<script src="http://cdn-go.cn/aegis/aegis-sdk/latest/aegis.min.js?_bid=3977"></script>
<script>"""
{}
<script>""".format(
"""<script src="http://cdn-go.cn/aegis/aegis-sdk/latest/aegis.min.js?_bid=3977"></script>"""
if settings.TAM_AEGIS_KEY
else ""
)
+ f"""window.ageisId = "{settings.TAM_AEGIS_KEY}";"""
+ """
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 _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 @@ -101,19 +89,39 @@
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",
}

IMPORT_STRINGS = ["AUTHENTICATION_CLASSES", "PERMISSION_CLASSES", "PROVISIONING_CLASSES", "BACKEND_CLASS"]


APP_LABEL = "grafana"


Expand Down

0 comments on commit a206a37

Please sign in to comment.