- App 组件中注释 Menu, 去除顶部菜单
MenuWrapper
SubMenuComponent
-
请求/chart/add ,直接展示绘图页
此过程,浏览器只加载静态资源,没有api的数据请求。
取消登录限制:
api
: GET, POST /chart/add
view
: SliceModelView.add
源码
:superset/views/chart/view.py
取消登录
: 注释has_access 登录要求 -
选数据集,触发api请求
api
: GET- /api/v1/dataset/
查询参数
:‘q’ = “(columns:!(id,table_name,description,datasource_type),filters:!((col:table_name,opr:ct,value:‘’)),order_column:table_name,order_direction:asc,page:0,page_size:100)”
view
: DatasetRestApi.get_list
源码
:superset/datasets/api.py
取消登录
:
flask_appbuilder/api/_init_.py 搜索get_list
注释@protect
显示固定的测试用例数据
:
slice: 存储创建的图表
tables:存储用户的数据集(表名等)
flask_appbuilder/api/_init_.py
# get_list_headless
if count == 0:
response["result"] = [{'description': None, 'datasource_type': 'table', 'id': 1, 'table_name': 'line_t'}]
response["ids"] = [1]
response["count"] = 1
将测试用例数据存储的表信息存入tables
//未登录的 查询数据集
{
'list_title': 'List Sqla Table',
'list_columns': ['id', 'table_name', 'description', 'datasource_type'],
'description_columns': {},
'label_columns': {'id': 'Id', 'description': 'Description', 'table_name': 'Table Name', 'datasource_type': 'Datasource Type'},
'order_columns': ['table_name'],
'result': [],
'ids': [],
'count': 0
}
//登录后的查询数据集
{
'list_title': 'List Sqla Table',
'list_columns': ['id', 'table_name', 'description', 'datasource_type'],
'description_columns': {},
'label_columns': {'id': 'Id', 'description': 'Description', 'table_name': 'Table Name', 'datasource_type': 'Datasource Type'},
'order_columns': ['table_name'],
//差异部分
'result': [{'description': None, 'datasource_type': 'table', 'id': 1, 'table_name': 'line_t'}],
'ids': [1],
'count': 1}
登录后的查询过程:
joined_filters: FILTERS:tables.table_name:
tables.id:<function DatasetRestApi.<lambda> at 0x000002011A3653A0>
order_column: table_name
order_direction: asc
self.list_select_columns: ['id', 'database.id', 'database.database_name', 'changed_by_name', 'changed_by_url', 'changed_by.first_name', 'changed_by
.username', 'changed_on_utc', 'changed_on_delta_humanized', 'default_endpoint', 'description', 'datasource_type', 'explore_url', 'extra', 'kind', '
owners.id', 'owners.username', 'owners.first_name', 'owners.last_name', 'schema', 'sql', 'table_name', 'changed_on', 'changed_by_fk']
self.list_outer_default_load: True
查询self.obj: <class 'superset.connectors.sqla.models.SqlaTable'>
query: SELECT tables.uuid AS tables_uuid, tables.created_on AS tables_created_on, tables.changed_on AS tables_changed_on, tables.id AS tables_id, t
ables.description AS tables_description, tables.default_endpoint AS tables_default_endpoint, tables.is_featured AS tables_is_featured, tables.filte
r_select_enabled AS tables_filter_select_enabled, tables.offset AS tables_offset, tables.cache_timeout AS tables_cache_timeout, tables.params AS ta
bles_params, tables.perm AS tables_perm, tables.schema_perm AS tables_schema_perm, tables.is_managed_externally AS tables_is_managed_externally, ta
bles.external_url AS tables_external_url, tables.table_name AS tables_table_name, tables.main_dttm_col AS tables_main_dttm_col, tables.database_id
AS tables_database_id, tables.fetch_values_predicate AS tables_fetch_values_predicate, tables.`schema` AS tables_schema, tables.`sql` AS tables_sql
, tables.is_sqllab_view AS tables_is_sqllab_view, tables.template_params AS tables_template_params, tables.extra AS tables_extra, tables.created_by
_fk AS tables_created_by_fk, tables.changed_by_fk AS tables_changed_by_fk
FROM tables
//
query_results: [(superset.line_t, examples, admin user)]
count, result: 1 [superset.line_t]
未登录的查询过程:
joined_filters: FILTERS:tables.table_name:
tables.id:<function DatasetRestApi.<lambda> at 0x000001940DC79280>
order_column: table_name
order_direction: asc
self.list_select_columns: ['id', 'database.id', 'database.database_name', 'changed_by_name', 'changed_by_url', 'changed_by.first_name', 'changed_by
.username', 'changed_on_utc', 'changed_on_delta_humanized', 'default_endpoint', 'description', 'datasource_type', 'explore_url', 'extra', 'kind', '
owners.id', 'owners.username', 'owners.first_name', 'owners.last_name', 'schema', 'sql', 'table_name', 'changed_on', 'changed_by_fk']
self.list_outer_default_load: True
查询self.obj: <class 'superset.connectors.sqla.models.SqlaTable'>
query: SELECT tables.uuid AS tables_uuid, tables.created_on AS tables_created_on, tables.changed_on AS tables_changed_on, tables.id AS tables_id, t
ables.description AS tables_description, tables.default_endpoint AS tables_default_endpoint, tables.is_featured AS tables_is_featured, tables.filte
r_select_enabled AS tables_filter_select_enabled, tables.offset AS tables_offset, tables.cache_timeout AS tables_cache_timeout, tables.params AS ta
bles_params, tables.perm AS tables_perm, tables.schema_perm AS tables_schema_perm, tables.is_managed_externally AS tables_is_managed_externally, ta
bles.external_url AS tables_external_url, tables.table_name AS tables_table_name, tables.main_dttm_col AS tables_main_dttm_col, tables.database_id
AS tables_database_id, tables.fetch_values_predicate AS tables_fetch_values_predicate, tables.`schema` AS tables_schema, tables.`sql` AS tables_sql
, tables.is_sqllab_view AS tables_is_sqllab_view, tables.template_params AS tables_template_params, tables.extra AS tables_extra, tables.created_by
_fk AS tables_created_by_fk, tables.changed_by_fk AS tables_changed_by_fk
FROM tables
query_results: []
count, result: 0 []
pks: []
tables中的uuid不可编辑:
继续: 选择图形后,点击添加图表,发送get
- GET-/api/v1/explore/
查询参数:(‘viz_type’, ‘echarts_timeseries_line’), (‘datasource_id’, ‘1’), (‘datasource_type’, ‘table’)]
- GET-/api/v1/database/1/table_extra/line_t/superset/
POST-/api/v1/explore/form_data-ImmutableMultiDict([(‘tab_id’, ‘5’)])
4. 登录功能分析
后端加一个钩子函数,查看请求交互!
# 处理请求之前
@app.before_request
def analyze():
xxxx
return None
/api/v1/me/ 验证用户的登录
未登录返401,前端重定向到/login/
已登录,返回用户信息
去除登录功能:
接口:
GET /api/v1/me/
视图:
- 获取flask app所有的接口
- flask routes 获取接口
- 根据api接口查找视图
- 搜索视图源码位置
在这里插入代码片