refactor: update CRUD dspy and UI files

This commit is contained in:
yumoqing 2026-05-29 18:25:40 +08:00
parent 4ea407c60b
commit b41dc0a02d
20 changed files with 889 additions and 854 deletions

View File

@ -1,5 +1,8 @@
ns = params_kw.copy() ns = params_kw.copy()
for k,v in ns.items():
if v == 'NaN' or v == 'null':
ns[k] = None
id = params_kw.id id = params_kw.id
if not id or len(id) > 32: if not id or len(id) > 32:
id = uuid() id = uuid()
@ -8,13 +11,12 @@ ns['id'] = id
db = DBPools() db = DBPools()
dbname = await rfexe('get_module_dbname', 'cpcc') dbname = get_module_dbname('cpcc')
async with db.sqlorContext(dbname) as sor: async with db.sqlorContext(dbname) as sor:
r = await sor.C('components', ns.copy()) r = await sor.C('components', ns.copy())
return { return {
"widgettype":"Message", "widgettype":"Message",
"options":{ "options":{
"user_data":ns,
"cwidth":16, "cwidth":16,
"cheight":9, "cheight":9,
"title":"Add Success", "title":"Add Success",

View File

@ -5,7 +5,7 @@ ns = {
db = DBPools() db = DBPools()
dbname = await rfexe('get_module_dbname', 'cpcc') dbname = get_module_dbname('cpcc')
async with db.sqlorContext(dbname) as sor: async with db.sqlorContext(dbname) as sor:
r = await sor.D('components', ns) r = await sor.D('components', ns)
debug('delete success'); debug('delete success');

View File

@ -15,8 +15,7 @@ from (select * from components where 1=1 [[filterstr]]) a left join (select k as
v as ccatelogid_text from appcodes_kv where parentid='ccatelog') b on a.ccatelogid = b.ccatelogid''' v as ccatelogid_text from appcodes_kv where parentid='ccatelog') b on a.ccatelogid = b.ccatelogid'''
filterjson = params_kw.get('data_filter') filterjson = params_kw.get('data_filter')
if not filterjson: fields_str=r'''[
fields = [ f['name'] for f in [
{ {
"name": "id", "name": "id",
"title": "id", "title": "id",
@ -52,7 +51,10 @@ if not filterjson:
"title": "计量值", "title": "计量值",
"type": "short" "type": "short"
} }
] ] ]'''
ori_fields = json.loads(fields_str)
if not filterjson:
fields = [ f['name'] for f in ori_fields ]
filterjson = default_filterjson(fields, ns) filterjson = default_filterjson(fields, ns)
filterdic = ns.copy() filterdic = ns.copy()
filterdic['filterstr'] = '' filterdic['filterstr'] = ''
@ -73,7 +75,7 @@ sql = ac.convert(sql, filterdic)
debug(f'{sql=}') debug(f'{sql=}')
db = DBPools() db = DBPools()
dbname = await rfexe('get_module_dbname', 'cpcc') dbname = get_module_dbname('cpcc')
async with db.sqlorContext(dbname) as sor: async with db.sqlorContext(dbname) as sor:
r = await sor.sqlPaging(sql, ns) r = await sor.sqlPaging(sql, ns)
return r return r

View File

@ -3,6 +3,8 @@
"id":"components_tbl", "id":"components_tbl",
"widgettype":"Tabular", "widgettype":"Tabular",
"options":{ "options":{
"width":"100%",
"height":"100%",
"title":"部件表", "title":"部件表",
@ -12,14 +14,22 @@
"css":"card", "css":"card",
"editable":{ "editable":{
"new_data_url":"{{entire_url('add_components.dspy')}}", "new_data_url":"{{entire_url('add_components.dspy')}}",
"delete_data_url":"{{entire_url('delete_components.dspy')}}", "delete_data_url":"{{entire_url('delete_components.dspy')}}",
"update_data_url":"{{entire_url('update_components.dspy')}}" "update_data_url":"{{entire_url('update_components.dspy')}}"
}, },
"data_url":"{{entire_url('./get_components.dspy')}}", "data_url":"{{entire_url('./get_components.dspy')}}",
"data_method":"GET", "data_method":"GET",
"data_params":{{json.dumps(params_kw, indent=4, ensure_ascii=False)}}, "data_params":{{json.dumps(params_kw, indent=4, ensure_ascii=False)}},
"row_options":{ "row_options":{
@ -69,7 +79,7 @@
"valueField": "ccatelogid", "valueField": "ccatelogid",
"textField": "ccatelogid_text", "textField": "ccatelogid_text",
"params": { "params": {
"dbname": "{{rfexe('get_module_dbname', 'cpcc')}}", "dbname": "{{get_module_dbname('cpcc')}}",
"table": "appcodes_kv", "table": "appcodes_kv",
"tblvalue": "k", "tblvalue": "k",
"tbltext": "v", "tbltext": "v",

View File

@ -1,12 +1,16 @@
ns = params_kw.copy() ns = params_kw.copy()
for k,v in ns.items():
if v == 'NaN' or v == 'null':
ns[k] = None
db = DBPools() db = DBPools()
dbname = await rfexe('get_module_dbname', 'cpcc') dbname = get_module_dbname('cpcc')
async with db.sqlorContext(dbname) as sor: async with db.sqlorContext(dbname) as sor:
r = await sor.U('components', ns) r = await sor.U('components', ns)
debug('update success'); debug('update success');
return { return {

View File

@ -1,5 +1,8 @@
ns = params_kw.copy() ns = params_kw.copy()
for k,v in ns.items():
if v == 'NaN' or v == 'null':
ns[k] = None
id = params_kw.id id = params_kw.id
if not id or len(id) > 32: if not id or len(id) > 32:
id = uuid() id = uuid()
@ -8,13 +11,12 @@ ns['id'] = id
db = DBPools() db = DBPools()
dbname = await rfexe('get_module_dbname', 'cpcc') dbname = get_module_dbname('cpcc')
async with db.sqlorContext(dbname) as sor: async with db.sqlorContext(dbname) as sor:
r = await sor.C('cpccluster', ns.copy()) r = await sor.C('cpccluster', ns.copy())
return { return {
"widgettype":"Message", "widgettype":"Message",
"options":{ "options":{
"user_data":ns,
"cwidth":16, "cwidth":16,
"cheight":9, "cheight":9,
"title":"Add Success", "title":"Add Success",

View File

@ -5,7 +5,7 @@ ns = {
db = DBPools() db = DBPools()
dbname = await rfexe('get_module_dbname', 'cpcc') dbname = get_module_dbname('cpcc')
async with db.sqlorContext(dbname) as sor: async with db.sqlorContext(dbname) as sor:
r = await sor.D('cpccluster', ns) r = await sor.D('cpccluster', ns)
debug('delete success'); debug('delete success');
@ -16,7 +16,7 @@ async with db.sqlorContext(dbname) as sor:
"timeout":3, "timeout":3,
"cwidth":16, "cwidth":16,
"cheight":9, "cheight":9,
"message":"ok记得把关联的节点都解除占用状态 ~" "message":"ok"
} }
} }

View File

@ -9,14 +9,14 @@ if not ns.get('sort'):
ns['sort'] = 'id' ns['sort'] = 'id'
sql = '''select a.*, b.clustertype_text, c.controllerid_text sql = '''select a.*, b.clustertype_text, c.controllerid_text
from (select * from cpccluster where 1=1 [[filterstr]]) a left join (select k as clustertype, from (select * from cpccluster where 1=1 [[filterstr]]) a left join (select k as clustertype,
v as clustertype_text from appcodes_kv where parentid='clustertype') b on a.clustertype = b.clustertype left join (select id as controllerid, v as clustertype_text from appcodes_kv where parentid='clustertype') b on a.clustertype = b.clustertype left join (select id as controllerid,
ip as controllerid_text from cpcnode where 1 = 1) c on a.controllerid = c.controllerid''' name as controllerid_text from hostdev where 1 = 1) c on a.controllerid = c.controllerid'''
filterjson = params_kw.get('data_filter') filterjson = params_kw.get('data_filter')
if not filterjson: fields_str=r'''[
fields = [ f['name'] for f in [
{ {
"name": "id", "name": "id",
"title": "id", "title": "id",
@ -60,7 +60,10 @@ if not filterjson:
"type": "date", "type": "date",
"length": 255 "length": 255
} }
] ] ]'''
ori_fields = json.loads(fields_str)
if not filterjson:
fields = [ f['name'] for f in ori_fields ]
filterjson = default_filterjson(fields, ns) filterjson = default_filterjson(fields, ns)
filterdic = ns.copy() filterdic = ns.copy()
filterdic['filterstr'] = '' filterdic['filterstr'] = ''
@ -81,7 +84,7 @@ sql = ac.convert(sql, filterdic)
debug(f'{sql=}') debug(f'{sql=}')
db = DBPools() db = DBPools()
dbname = await rfexe('get_module_dbname', 'cpcc') dbname = get_module_dbname('cpcc')
async with db.sqlorContext(dbname) as sor: async with db.sqlorContext(dbname) as sor:
r = await sor.sqlPaging(sql, ns) r = await sor.sqlPaging(sql, ns)
return r return r

View File

@ -1,77 +1,56 @@
{ {
"id": "cpccluster_tbl", "id":"cpccluster_tbl",
"widgettype": "Tabular", "widgettype":"Tabular",
"options": { "options":{
"title": "算力集群", "width":"100%",
"css": "card", "height":"100%",
"toolbar": {
"tools": [
{ "title":"算力集群",
"name": "newworker",
"selected_row": true,
"label": "新增工作节点"
"css":"card",
"editable":{
"new_data_url":"{{entire_url('add_cpccluster.dspy')}}",
"delete_data_url":"{{entire_url('delete_cpccluster.dspy')}}",
"update_data_url":"{{entire_url('update_cpccluster.dspy')}}"
}, },
{
"name": "newpodyaml",
"selected_row": true, "data_url":"{{entire_url('./get_cpccluster.dspy')}}",
"label": "新建资源YAML"
} "data_method":"GET",
], "data_params":{{json.dumps(params_kw, indent=4, ensure_ascii=False)}},
"css": "float-right" "row_options":{
},
"editable": {
"new_data_url": "{{entire_url('add_cpccluster.dspy')}}",
"delete_data_url": "{{entire_url('delete_cpccluster.dspy')}}",
"update_data_url": "{{entire_url('update_cpccluster.dspy')}}"
},
"data_url": "{{entire_url('./get_cpccluster.dspy')}}",
"data_method": "GET",
"data_params": {{json.dumps(params_kw, indent=4, ensure_ascii=False)}},
"row_options": {
"browserfields": { "browserfields": {
"exclouded": [ "exclouded": [
"id", "id",
"cpcid", "cpcid"
"clusterid"
], ],
"alters": {} "alters": {}
}, },
"editexclouded": [
"editexclouded":[
"id", "id",
"cpcid", "cpcid"
"clusterid" ],
],
"fields": [ "fields":[
{
"name": "name",
"title": "集群名称",
"type": "str",
"length": 255,
"cwidth": 14,
"uitype": "str",
"datatype": "str",
"label": "集群名称"
},
{
"name": "controllerid",
"title": "控制节点IP",
"type": "str",
"length": 32,
"cwidth": 12,
"label": "控制节点IP",
"uitype": "code",
"valueField": "controllerid",
"textField": "controllerid_text",
"params": {
"dbname": "{{rfexe('get_module_dbname', 'cpcc')}}",
"table": "cpcnode",
"tblvalue": "id",
"tbltext": "name",
"valueField": "controllerid",
"textField": "controllerid_text"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{ {
"name": "id", "name": "id",
"title": "id", "title": "id",
@ -82,13 +61,23 @@
"datatype": "str", "datatype": "str",
"label": "id" "label": "id"
}, },
{
"name": "name",
"title": "名称",
"type": "str",
"length": 255,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "名称"
},
{ {
"name": "cpcid", "name": "cpcid",
"title": "算力中心id", "title": "算力中心id",
"type": "str", "type": "str",
"length": 32, "length": 32,
"nullable": "no", "nullable": "no",
"cwidth": 10, "cwidth": 18,
"uitype": "str", "uitype": "str",
"datatype": "str", "datatype": "str",
"label": "算力中心id" "label": "算力中心id"
@ -98,13 +87,12 @@
"title": "集群类型", "title": "集群类型",
"type": "str", "type": "str",
"length": 1, "length": 1,
"cwidth": 8,
"label": "集群类型", "label": "集群类型",
"uitype": "code", "uitype": "code",
"valueField": "clustertype", "valueField": "clustertype",
"textField": "clustertype_text", "textField": "clustertype_text",
"params": { "params": {
"dbname": "{{rfexe('get_module_dbname', 'cpcc')}}", "dbname": "{{get_module_dbname('cpcc')}}",
"table": "appcodes_kv", "table": "appcodes_kv",
"tblvalue": "k", "tblvalue": "k",
"tbltext": "v", "tbltext": "v",
@ -115,21 +103,30 @@
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}" "dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
}, },
{ {
"name": "clusterjoin", "name": "controllerid",
"title": "加入集群凭证", "title": "控制节点id",
"type": "str", "type": "str",
"length": 255, "length": 32,
"cwidth": 45, "label": "控制节点id",
"uitype": "str", "uitype": "code",
"datatype": "str", "valueField": "controllerid",
"label": "加入集群凭证" "textField": "controllerid_text",
"params": {
"dbname": "{{get_module_dbname('cpcc')}}",
"table": "hostdev",
"tblvalue": "id",
"tbltext": "name",
"valueField": "controllerid",
"textField": "controllerid_text"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
}, },
{ {
"name": "enable_date", "name": "enable_date",
"title": "启用日期", "title": "启用日期",
"type": "date", "type": "date",
"length": 0, "length": 0,
"cwidth": 8, "cwidth": 18,
"uitype": "date", "uitype": "date",
"datatype": "date", "datatype": "date",
"label": "启用日期" "label": "启用日期"
@ -139,101 +136,20 @@
"title": "停用日期", "title": "停用日期",
"type": "date", "type": "date",
"length": 0, "length": 0,
"cwidth": 8, "cwidth": 18,
"uitype": "date", "uitype": "date",
"datatype": "date", "datatype": "date",
"label": "停用日期" "label": "停用日期"
} }
] ]
}, },
"content_view": {
"widgettype": "TabPanel",
"options": {
"tab_wide": "auto", "page_rows":160,
"height": "100%", "cache_limit":5
"width": "100%",
"tab_pos": "top",
"items": [
{
"name": "cpcpod",
"label": "实时资源实例",
"content": {
"widgettype": "urlwidget",
"options": {
"params": {
"clusterid": "${id}",
"cpcid": "${cpcid}"
},
"url": "{{entire_url('..\/cpcpod')}}"
} }
}
}, ,"binds":[]
{
"name": "cpcworker",
"label": "实时集群节点",
"content": {
"widgettype": "urlwidget",
"options": {
"params": {
"clusterid": "${id}",
"cpcid": "${cpcid}"
},
"url": "{{entire_url('..\/cpcworker')}}"
}
}
},
{
"name": "cpcyamlconfig",
"label": "资源实例配置",
"content": {
"widgettype": "urlwidget",
"options": {
"params": {
"clusterid": "${id}",
"cpcid": "${cpcid}"
},
"url": "{{entire_url('..\/cpcpodyaml')}}"
}
}
}
]
}
},
"page_rows": 160,
"cache_limit": 5
},
"binds": [
{
"wid": "self",
"event": "newworker",
"actiontype": "urlwidget",
"target": "PopupWindow",
"popup_options": {
"width": "80%",
"height": "80%"
},
"options": {
"url": "{{entire_url('../cpcworker/new_worker.ui')}}",
"params": {
"id": "{{params_kw.id}}"
}
}
},
{
"wid": "self",
"event": "newpodyaml",
"actiontype": "urlwidget",
"target": "PopupWindow",
"popup_options": {
"width": "80%",
"height": "80%"
},
"options": {
"url": "{{entire_url('../cpcpod/new_podyaml.ui')}}",
"params": {
"id": "{{params_kw.id}}"
}
}
}
]
} }

View File

@ -1,12 +1,16 @@
ns = params_kw.copy() ns = params_kw.copy()
for k,v in ns.items():
if v == 'NaN' or v == 'null':
ns[k] = None
db = DBPools() db = DBPools()
dbname = await rfexe('get_module_dbname', 'cpcc') dbname = get_module_dbname('cpcc')
async with db.sqlorContext(dbname) as sor: async with db.sqlorContext(dbname) as sor:
r = await sor.U('cpccluster', ns) r = await sor.U('cpccluster', ns)
debug('update success'); debug('update success');
return { return {

View File

@ -1,5 +1,8 @@
ns = params_kw.copy() ns = params_kw.copy()
for k,v in ns.items():
if v == 'NaN' or v == 'null':
ns[k] = None
id = params_kw.id id = params_kw.id
if not id or len(id) > 32: if not id or len(id) > 32:
id = uuid() id = uuid()
@ -25,13 +28,12 @@ if not userorgid:
ns['orgid'] = userorgid ns['orgid'] = userorgid
db = DBPools() db = DBPools()
dbname = await rfexe('get_module_dbname', 'cpcc') dbname = get_module_dbname('cpcc')
async with db.sqlorContext(dbname) as sor: async with db.sqlorContext(dbname) as sor:
r = await sor.C('cpclist', ns.copy()) r = await sor.C('cpclist', ns.copy())
return { return {
"widgettype":"Message", "widgettype":"Message",
"options":{ "options":{
"user_data":ns,
"cwidth":16, "cwidth":16,
"cheight":9, "cheight":9,
"title":"Add Success", "title":"Add Success",

View File

@ -19,7 +19,7 @@ if not userorgid:
ns['orgid'] = userorgid ns['orgid'] = userorgid
db = DBPools() db = DBPools()
dbname = await rfexe('get_module_dbname', 'cpcc') dbname = get_module_dbname('cpcc')
async with db.sqlorContext(dbname) as sor: async with db.sqlorContext(dbname) as sor:
r = await sor.D('cpclist', ns) r = await sor.D('cpclist', ns)
debug('delete success'); debug('delete success');

View File

@ -30,8 +30,7 @@ from (select * from cpclist where 1=1 [[filterstr]]) a left join (select id as o
orgname as orgid_text from organization where 1 = 1) b on a.orgid = b.orgid''' orgname as orgid_text from organization where 1 = 1) b on a.orgid = b.orgid'''
filterjson = params_kw.get('data_filter') filterjson = params_kw.get('data_filter')
if not filterjson: fields_str=r'''[
fields = [ f['name'] for f in [
{ {
"name": "id", "name": "id",
"title": "id", "title": "id",
@ -92,7 +91,10 @@ if not filterjson:
"type": "str", "type": "str",
"length": 100 "length": 100
} }
] ] ]'''
ori_fields = json.loads(fields_str)
if not filterjson:
fields = [ f['name'] for f in ori_fields ]
filterjson = default_filterjson(fields, ns) filterjson = default_filterjson(fields, ns)
filterdic = ns.copy() filterdic = ns.copy()
filterdic['filterstr'] = '' filterdic['filterstr'] = ''
@ -113,7 +115,7 @@ sql = ac.convert(sql, filterdic)
debug(f'{sql=}') debug(f'{sql=}')
db = DBPools() db = DBPools()
dbname = await rfexe('get_module_dbname', 'cpcc') dbname = get_module_dbname('cpcc')
async with db.sqlorContext(dbname) as sor: async with db.sqlorContext(dbname) as sor:
r = await sor.sqlPaging(sql, ns) r = await sor.sqlPaging(sql, ns)
return r return r

View File

@ -1,27 +1,63 @@
{ {
"id": "cpclist_tbl", "id":"cpclist_tbl",
"widgettype": "Tabular", "widgettype":"Tabular",
"options": { "options":{
"title": "算力中心列表", "width":"100%",
"toolbar": { "height":"100%",
"title":"算力中心列表",
"toolbar":{
"tools": [ "tools": [
{ {
"name": "newcluster", "name": "newcluster",
"selected_row": true, "selected_row": true,
"label": "新建集群" "label": "新建集群"
},
{
"selected_row": true,
"name": "cpccluster",
"icon": "{{entire_url('/imgs/cpccluster.svg')}}",
"label": "集群"
},
{
"selected_row": true,
"name": "cpcnode",
"icon": "{{entire_url('/imgs/cpcnode.svg')}}",
"label": "节点"
} }
] ]
},
"css":"card",
"editable":{
"new_data_url":"{{entire_url('add_cpclist.dspy')}}",
"delete_data_url":"{{entire_url('delete_cpclist.dspy')}}",
"update_data_url":"{{entire_url('update_cpclist.dspy')}}"
}, },
"css": "card",
"editable": {
"new_data_url": "{{entire_url('add_cpclist.dspy')}}", "data_url":"{{entire_url('./get_cpclist.dspy')}}",
"delete_data_url": "{{entire_url('delete_cpclist.dspy')}}",
"update_data_url": "{{entire_url('update_cpclist.dspy')}}" "data_method":"GET",
}, "data_params":{{json.dumps(params_kw, indent=4, ensure_ascii=False)}},
"data_url": "{{entire_url('./get_cpclist.dspy')}}", "row_options":{
"data_method": "GET",
"data_params": {{json.dumps(params_kw, indent=4, ensure_ascii=False)}},
"row_options": {
"browserfields": { "browserfields": {
"exclouded": [ "exclouded": [
"id", "id",
@ -31,12 +67,15 @@
"pcapi_pwd" "pcapi_pwd"
], ],
"alters": {} "alters": {}
}, },
"editexclouded": [
"editexclouded":[
"id", "id",
"orgid" "orgid"
], ],
"fields": [
"fields":[
{ {
"name": "id", "name": "id",
"title": "id", "title": "id",
@ -67,7 +106,7 @@
"valueField": "orgid", "valueField": "orgid",
"textField": "orgid_text", "textField": "orgid_text",
"params": { "params": {
"dbname": "{{rfexe('get_module_dbname', 'cpcc')}}", "dbname": "{{get_module_dbname('cpcc')}}",
"table": "organization", "table": "organization",
"tblvalue": "id", "tblvalue": "id",
"tbltext": "orgname", "tbltext": "orgname",
@ -102,7 +141,7 @@
"type": "str", "type": "str",
"length": 100, "length": 100,
"cwidth": 18, "cwidth": 18,
"uitype": "str", "uitype": "password",
"datatype": "str", "datatype": "str",
"label": "接口密码" "label": "接口密码"
}, },
@ -146,49 +185,16 @@
"datatype": "str", "datatype": "str",
"label": "联系电话" "label": "联系电话"
} }
] ]
}, },
"content_view": {
"widgettype": "TabPanel",
"options": {
"tab_wide": "auto", "page_rows":160,
"height": "100%", "cache_limit":5
"width": "100%",
"tab_pos": "top",
"items": [
{
"name": "cpccluster",
"label": "集群",
"content": {
"widgettype": "urlwidget",
"options": {
"params": {
"cpcid": "${id}"
},
"url": "{{entire_url('..\/cpccluster')}}"
} }
}
}, ,"binds":[
{
"name": "cpcnode",
"label": "节点",
"content": {
"widgettype": "urlwidget",
"options": {
"params": {
"cpcid": "${id}"
},
"url": "{{entire_url('..\/cpcnode')}}"
}
}
}
]
}
},
"page_rows": 160,
"cache_limit": 5
},
"binds": [
{ {
"wid": "self", "wid": "self",
"event": "newcluster", "event": "newcluster",
@ -204,6 +210,57 @@
"id": "{{params_kw.id}}" "id": "{{params_kw.id}}"
} }
} }
},
{
"wid": "self",
"event": "cpccluster",
"actiontype": "urlwidget",
"target": "PopupWindow",
"popup_options": {
"title": "集群",
"icon": "{{entire_url('/appbase/get_icon.dspy')}}?id=cpccluster",
"resizable": true,
"height": "70%",
"width": "70%"
},
"params_mapping": {
"mapping": {
"id": "cpcid",
"referer_widget": "referer_widget"
},
"need_other": false
},
"options": {
"method": "POST",
"params": {},
"url": "{{entire_url('../cpccluster')}}"
} }
] },
{
"wid": "self",
"event": "cpcnode",
"actiontype": "urlwidget",
"target": "PopupWindow",
"popup_options": {
"title": "节点",
"icon": "{{entire_url('/appbase/get_icon.dspy')}}?id=cpcnode",
"resizable": true,
"height": "70%",
"width": "70%"
},
"params_mapping": {
"mapping": {
"id": "cpcid",
"referer_widget": "referer_widget"
},
"need_other": false
},
"options": {
"method": "POST",
"params": {},
"url": "{{entire_url('../cpcnode')}}"
}
}
]
} }

View File

@ -1,5 +1,8 @@
ns = params_kw.copy() ns = params_kw.copy()
for k,v in ns.items():
if v == 'NaN' or v == 'null':
ns[k] = None
userorgid = await get_userorgid() userorgid = await get_userorgid()
@ -22,8 +25,29 @@ if params_kw.get('api_pwd'):
db = DBPools() db = DBPools()
dbname = await rfexe('get_module_dbname', 'cpcc') dbname = get_module_dbname('cpcc')
async with db.sqlorContext(dbname) as sor: async with db.sqlorContext(dbname) as sor:
ns1 = {
"orgid": userorgid,
"id": params_kw.id
}
recs = await sor.R('cpclist', ns1)
if len(recs) < 1:
return {
"widgettype":"Error",
"options":{
"title":"Update Error",
"cwidth":16,
"cheight":9,
"timeout":3,
"message":"Record no exist or with wrong ownership"
}
}
r = await sor.U('cpclist', ns) r = await sor.U('cpclist', ns)
debug('update success'); debug('update success');
return { return {

View File

@ -1,5 +1,8 @@
ns = params_kw.copy() ns = params_kw.copy()
for k,v in ns.items():
if v == 'NaN' or v == 'null':
ns[k] = None
id = params_kw.id id = params_kw.id
if not id or len(id) > 32: if not id or len(id) > 32:
id = uuid() id = uuid()
@ -11,13 +14,12 @@ if params_kw.get('adminpwd'):
db = DBPools() db = DBPools()
dbname = await rfexe('get_module_dbname', 'cpcc') dbname = get_module_dbname('cpcc')
async with db.sqlorContext(dbname) as sor: async with db.sqlorContext(dbname) as sor:
r = await sor.C('cpcnode', ns.copy()) r = await sor.C('cpcnode', ns.copy())
return { return {
"widgettype":"Message", "widgettype":"Message",
"options":{ "options":{
"user_data":ns,
"cwidth":16, "cwidth":16,
"cheight":9, "cheight":9,
"title":"Add Success", "title":"Add Success",

View File

@ -5,7 +5,7 @@ ns = {
db = DBPools() db = DBPools()
dbname = await rfexe('get_module_dbname', 'cpcc') dbname = get_module_dbname('cpcc')
async with db.sqlorContext(dbname) as sor: async with db.sqlorContext(dbname) as sor:
r = await sor.D('cpcnode', ns) r = await sor.D('cpcnode', ns)
debug('delete success'); debug('delete success');

View File

@ -10,17 +10,12 @@ if not ns.get('sort'):
ns['sort'] = 'id' ns['sort'] = 'id'
sql = '''select a.*, b.node_status_text,d.devicetype_text sql = '''select a.*, b.node_status_text
from (select * from cpcnode where 1=1 [[filterstr]]) from (select * from cpcnode where 1=1 [[filterstr]]) a left join (select k as node_status,
a left join (select k as node_status, v as node_status_text from appcodes_kv where parentid='node_status') v as node_status_text from appcodes_kv where parentid='node_status') b on a.node_status = b.node_status'''
b on a.node_status = b.node_status
left join (select k as devicetype, v as devicetype_text from appcodes_kv where parentid = 'devicetype')
d on a.devicetype = d.devicetype'''
filterjson = params_kw.get('data_filter') filterjson = params_kw.get('data_filter')
if not filterjson: fields_str=r'''[
fields = [ f['name'] for f in [
{ {
"name": "id", "name": "id",
"title": "id", "title": "id",
@ -33,12 +28,6 @@ if not filterjson:
"type": "str", "type": "str",
"length": 255 "length": 255
}, },
{
"name": "devicetype",
"title": "设备类型",
"type": "str",
"length": 1
},
{ {
"name": "ip", "name": "ip",
"title": "内网ip", "title": "内网ip",
@ -95,7 +84,10 @@ if not filterjson:
"type": "date", "type": "date",
"length": 255 "length": 255
} }
] ] ]'''
ori_fields = json.loads(fields_str)
if not filterjson:
fields = [ f['name'] for f in ori_fields ]
filterjson = default_filterjson(fields, ns) filterjson = default_filterjson(fields, ns)
filterdic = ns.copy() filterdic = ns.copy()
filterdic['filterstr'] = '' filterdic['filterstr'] = ''
@ -116,7 +108,7 @@ sql = ac.convert(sql, filterdic)
debug(f'{sql=}') debug(f'{sql=}')
db = DBPools() db = DBPools()
dbname = await rfexe('get_module_dbname', 'cpcc') dbname = get_module_dbname('cpcc')
async with db.sqlorContext(dbname) as sor: async with db.sqlorContext(dbname) as sor:
r = await sor.sqlPaging(sql, ns) r = await sor.sqlPaging(sql, ns)
return r return r

View File

@ -1,32 +1,57 @@
{ {
"id": "cpcnode_tbl", "id":"cpcnode_tbl",
"widgettype": "Tabular", "widgettype":"Tabular",
"options": { "options":{
"title": "入网算力节点", "width":"100%",
"css": "card", "height":"100%",
"editable": {
"new_data_url": "{{entire_url('add_cpcnode.dspy')}}",
"delete_data_url": "{{entire_url('delete_cpcnode.dspy')}}", "title":"算力节点",
"update_data_url": "{{entire_url('update_cpcnode.dspy')}}"
"css":"card",
"editable":{
"new_data_url":"{{entire_url('add_cpcnode.dspy')}}",
"delete_data_url":"{{entire_url('delete_cpcnode.dspy')}}",
"update_data_url":"{{entire_url('update_cpcnode.dspy')}}"
}, },
"data_url": "{{entire_url('./get_cpcnode.dspy')}}",
"data_method": "GET",
"data_params": {{json.dumps(params_kw, indent=4, ensure_ascii=False)}}, "data_url":"{{entire_url('./get_cpcnode.dspy')}}",
"row_options": {
"data_method":"GET",
"data_params":{{json.dumps(params_kw, indent=4, ensure_ascii=False)}},
"row_options":{
"browserfields": { "browserfields": {
"exclouded": [ "exclouded": [
"id", "id",
"cpcid", "cpcid"
"clusterid"
], ],
"alters": {} "alters": {}
}, },
"editexclouded": [
"editexclouded":[
"id", "id",
"cpcid", "cpcid",
"clusterid" "clusterid"
], ],
"fields": [
"fields":[
{ {
"name": "id", "name": "id",
"title": "id", "title": "id",
@ -37,46 +62,25 @@
"datatype": "str", "datatype": "str",
"label": "id" "label": "id"
}, },
{
"name": "ip",
"title": "内网ip",
"type": "str",
"length": 90,
"cwidth": 10,
"uitype": "str",
"datatype": "str",
"label": "内网ip"
},
{ {
"name": "name", "name": "name",
"title": "名称", "title": "名称",
"type": "str", "type": "str",
"length": 255, "length": 255,
"cwidth": 16, "cwidth": 18,
"uitype": "str", "uitype": "str",
"datatype": "str", "datatype": "str",
"label": "名称" "label": "名称"
}, },
{ {
"name": "devicetype", "name": "ip",
"title": "设备类型", "title": "内网ip",
"type": "str", "type": "str",
"length": 1, "length": 90,
"cwidth": 8, "cwidth": 18,
"label": "设备类型", "uitype": "str",
"uitype": "code", "datatype": "str",
"valueField": "devicetype", "label": "内网ip"
"textField": "devicetype_text",
"params": {
"dbname": "{{rfexe('get_module_dbname', 'cpcc')}}",
"table": "appcodes_kv",
"tblvalue": "k",
"tbltext": "v",
"valueField": "devicetype",
"textField": "devicetype_text",
"cond": "parentid='devicetype'"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
}, },
{ {
"name": "sshport", "name": "sshport",
@ -92,7 +96,7 @@
"title": "管理账号", "title": "管理账号",
"type": "str", "type": "str",
"length": 99, "length": 99,
"cwidth": 8, "cwidth": 18,
"uitype": "str", "uitype": "str",
"datatype": "str", "datatype": "str",
"label": "管理账号" "label": "管理账号"
@ -103,7 +107,7 @@
"type": "str", "type": "str",
"length": 99, "length": 99,
"cwidth": 18, "cwidth": 18,
"uitype": "str", "uitype": "password",
"datatype": "str", "datatype": "str",
"label": "管理密码" "label": "管理密码"
}, },
@ -129,7 +133,7 @@
"valueField": "node_status", "valueField": "node_status",
"textField": "node_status_text", "textField": "node_status_text",
"params": { "params": {
"dbname": "{{rfexe('get_module_dbname', 'cpcc')}}", "dbname": "{{get_module_dbname('cpcc')}}",
"table": "appcodes_kv", "table": "appcodes_kv",
"tblvalue": "k", "tblvalue": "k",
"tbltext": "v", "tbltext": "v",
@ -170,10 +174,15 @@
"datatype": "date", "datatype": "date",
"label": "停用日期" "label": "停用日期"
} }
] ]
}, },
"page_rows": 160,
"cache_limit": 5
},
"binds": [] "page_rows":160,
"cache_limit":5
}
,"binds":[]
} }

View File

@ -1,5 +1,8 @@
ns = params_kw.copy() ns = params_kw.copy()
for k,v in ns.items():
if v == 'NaN' or v == 'null':
ns[k] = None
@ -8,8 +11,9 @@ if params_kw.get('adminpwd'):
db = DBPools() db = DBPools()
dbname = await rfexe('get_module_dbname', 'cpcc') dbname = get_module_dbname('cpcc')
async with db.sqlorContext(dbname) as sor: async with db.sqlorContext(dbname) as sor:
r = await sor.U('cpcnode', ns) r = await sor.U('cpcnode', ns)
debug('update success'); debug('update success');
return { return {