BI框架

2023-04-05

BI(Business Intelligence)框架是一种软件工具集合,用于帮助企业从大量的数据中提取、分析和可视化有关业务运营的洞察。它提供了一套功能强大的工具和技术,用于数据仓库、数据处理、数据可视化、报表和仪表盘等方面的业务分析。

superset

使用官方参考:

https://hub.docker.com/r/apache/superset

启动:

docker run -d -p 888:8088 -e “SUPERSET_SECRET_KEY=bric” -v /app/download/superset/app:/app –name sp3 superset:v1

汉化

开启中文:\app\superset\config.py 修改

# Setup default language
BABEL_DEFAULT_LOCALE = "zh"

本地创建pybabel命令:vim /usr/local/bin/pybabel

#!/usr/local/bin/python
# -*- coding: utf-8 -*-
import re
import sys
from babel.messages.frontend import main
if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(main())

将pybabel命令工具导入容器中:

docker cp /usr/local/bin/pybabel sp2:/usr/local/bin/pybabel

赋予写入权限:

chmod 777 -R superset chmod 777 -R superset-frontend chmod 777 -r superset-home

编译汉化:进入容器执行

cd /app
superset fab babel-compile --target superset/translations

用户注入

关闭CSRF:\app\superset\config.py 修改

# Flask-WTF flag for CSRF
WTF_CSRF_ENABLED = False

给 \app\superset\views\core.py 添加:

from flask import render_template
from superset import appbuilder

@appbuilder.app.route('/custom')  
def custom():
return render_template('custom.html')

创建文件: \app\superset\templates\custom.html

<script>
const formData = new FormData();
formData.append('username', name);
formData.append('password', pass);

async function sendRequest(csrfToken) {
    const url = "/login/";
    const response = await fetch(url, {
        method: "POST",
        body: formData,
    }).then(
        data => {
            window.location.href = "/dashboard/list/";
        }
    );
}
sendRequest();
</script>