mirror of
https://github.com/tencentmusic/cube-studio.git
synced 2024-11-27 05:33:10 +08:00
add metric mark
This commit is contained in:
parent
27bbc65e4d
commit
0ca97a6d88
@ -7,8 +7,8 @@ from wtforms.validators import DataRequired
|
||||
from myapp import app, appbuilder
|
||||
from wtforms import StringField, SelectField
|
||||
from flask_appbuilder.fieldwidgets import BS3TextFieldWidget, Select2Widget
|
||||
from myapp.forms import MyBS3TextAreaFieldWidget,MySelect2Widget
|
||||
|
||||
from myapp.forms import MyBS3TextAreaFieldWidget, MySelect2Widget, MyBS3TextFieldWidget
|
||||
import json
|
||||
from .baseApi import (
|
||||
MyappModelRestApi
|
||||
)
|
||||
@ -41,30 +41,54 @@ class Metadata_Metrics_table_Filter(MyappFilter):
|
||||
|
||||
|
||||
|
||||
Remark_fields = {
|
||||
"begin_date":StringField(
|
||||
label=_("起点时间"),
|
||||
default='',
|
||||
description='起点时间精确到天',
|
||||
widget=MyBS3TextFieldWidget(is_date=True)
|
||||
),
|
||||
"end_date": StringField(
|
||||
label=_('终点时间'),
|
||||
default='',
|
||||
description='终点时间',
|
||||
widget=MyBS3TextFieldWidget(is_date=True),
|
||||
),
|
||||
"tip": StringField(
|
||||
label=_('备注'),
|
||||
description='备注',
|
||||
widget=BS3TextFieldWidget(),
|
||||
validators=[DataRequired()]
|
||||
)
|
||||
}
|
||||
|
||||
class Metadata_metric_ModelView_base():
|
||||
label_title='指标'
|
||||
datamodel = SQLAInterface(Metadata_metric)
|
||||
base_permissions = ['can_add','can_show','can_edit','can_list','can_delete']
|
||||
base_order = ("id", "desc")
|
||||
order_columns = ['id']
|
||||
search_columns=['metric_data_type','metric_responsible','app','name','label','describe','metric_type','metric_level','task_id','caliber']
|
||||
show_columns=['id','app','metric_data_type','name','label','describe','metric_type','metric_level','metric_dim','metric_responsible','caliber','task_id','public']
|
||||
search_columns=['metric_data_type','metric_responsible','app','name','label','describe','metric_type','metric_level','task_id','caliber','remark']
|
||||
show_columns=['id','app','metric_data_type','name','label','describe','metric_type','metric_level','metric_dim','metric_responsible','caliber','task_id','public','remark']
|
||||
list_columns = ['app','metric_data_type','name','label','describe','metric_level','metric_responsible','public','metric_type','task_id']
|
||||
cols_width = {
|
||||
"name":{"type": "ellip2", "width": 200},
|
||||
"label": {"type": "ellip2", "width": 200},
|
||||
"task_id": {"type": "ellip2", "width": 250},
|
||||
"describe": {"type": "ellip2", "width": 400},
|
||||
"metric_responsible": {"type": "ellip2", "width": 300}
|
||||
"metric_responsible": {"type": "ellip2", "width": 300},
|
||||
"remark_html": {"type": "ellip1", "width": 300}
|
||||
}
|
||||
spec_label_columns={
|
||||
"name":"指标英文名",
|
||||
"label": "指标中文名",
|
||||
"describe":"指标描述",
|
||||
"metric_data_type":"指标模块",
|
||||
"task_id":"任务id"
|
||||
"task_id": "任务id",
|
||||
"remark_html":"备注"
|
||||
}
|
||||
add_columns = ['app','metric_data_type','name','label','describe','metric_type','metric_level','metric_dim','metric_responsible','caliber','task_id','public']
|
||||
# show_columns = ['project','name','describe','config_html','dag_json_html','created_by','changed_by','created_on','changed_on','expand_html']
|
||||
add_columns = ['app','metric_data_type','name','label','describe','metric_type','metric_level','metric_dim','metric_responsible','caliber','task_id','public','remark']
|
||||
# show_columns = ['project','name','describe','config_html','dag_json_html','expand_html']
|
||||
edit_columns = add_columns
|
||||
base_filters = [["id", Metadata_Metrics_table_Filter, lambda: []]]
|
||||
add_form_extra_fields = {
|
||||
@ -92,6 +116,12 @@ class Metadata_metric_ModelView_base():
|
||||
widget=BS3TextFieldWidget(),
|
||||
validators=[DataRequired()]
|
||||
),
|
||||
"remark": StringField(
|
||||
label=_(datamodel.obj.lab('remark')),
|
||||
description='指标备注',
|
||||
default='',
|
||||
widget=MyBS3TextAreaFieldWidget(expand_filed=Remark_fields)
|
||||
),
|
||||
"metric_type": SelectField(
|
||||
label=_(datamodel.obj.lab('metric_type')),
|
||||
description='指标类型',
|
||||
@ -149,6 +179,32 @@ class Metadata_metric_ModelView_base():
|
||||
download_data=True
|
||||
|
||||
|
||||
def pre_show_res(self,_response):
|
||||
data = _response['data']
|
||||
if data.get('remark',None):
|
||||
data['remark']=json.loads(data.get('remark','[]'))
|
||||
|
||||
def pre_add_req(self, req_json=None):
|
||||
if req_json and 'remark' in req_json:
|
||||
req_json['remark'] = json.dumps(req_json.get('remark',[]),indent=4,ensure_ascii=False)
|
||||
return req_json
|
||||
|
||||
pre_update_req=pre_add_req
|
||||
|
||||
add_fieldsets = [
|
||||
(
|
||||
_('指标'),
|
||||
{"fields": ['app','metric_data_type','name','label','describe','metric_type','metric_level','metric_dim','metric_responsible','caliber','task_id','public'], "expanded": True},
|
||||
),
|
||||
(
|
||||
_('备注'),
|
||||
{"fields": ['remark'],
|
||||
"expanded": True},
|
||||
)
|
||||
]
|
||||
edit_fieldsets = add_fieldsets
|
||||
|
||||
|
||||
def pre_upload(self,data):
|
||||
data['public'] = bool(int(data.get('public', 1)))
|
||||
return data
|
||||
|
Loading…
Reference in New Issue
Block a user