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()
for k,v in ns.items():
if v == 'NaN' or v == 'null':
ns[k] = None
id = params_kw.id
if not id or len(id) > 32:
id = uuid()
@ -8,28 +11,27 @@ ns['id'] = id
db = DBPools()
dbname = await rfexe('get_module_dbname', 'cpcc')
dbname = get_module_dbname('cpcc')
async with db.sqlorContext(dbname) as sor:
r = await sor.C('components', ns.copy())
return {
"widgettype":"Message",
"options":{
"user_data":ns,
r = await sor.C('components', ns.copy())
return {
"widgettype":"Message",
"options":{
"cwidth":16,
"cheight":9,
"title":"Add Success",
"title":"Add Success",
"timeout":3,
"message":"ok"
}
}
"message":"ok"
}
}
return {
"widgettype":"Error",
"options":{
"title":"Add Error",
"widgettype":"Error",
"options":{
"title":"Add Error",
"cwidth":16,
"cheight":9,
"timeout":3,
"message":"failed"
}
"message":"failed"
}
}

View File

@ -1,33 +1,33 @@
ns = {
'id':params_kw['id'],
'id':params_kw['id'],
}
db = DBPools()
dbname = await rfexe('get_module_dbname', 'cpcc')
dbname = get_module_dbname('cpcc')
async with db.sqlorContext(dbname) as sor:
r = await sor.D('components', ns)
debug('delete success');
return {
"widgettype":"Message",
"options":{
"title":"Delete Success",
r = await sor.D('components', ns)
debug('delete success');
return {
"widgettype":"Message",
"options":{
"title":"Delete Success",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"ok"
}
}
"message":"ok"
}
}
debug('Delete failed');
return {
"widgettype":"Error",
"options":{
"title":"Delete Error",
"widgettype":"Error",
"options":{
"title":"Delete Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"failed"
}
"message":"failed"
}
}

View File

@ -4,7 +4,7 @@ ns = params_kw.copy()
debug(f'get_components.dspy:{ns=}')
if not ns.get('page'):
ns['page'] = 1
ns['page'] = 1
if not ns.get('sort'):
ns['sort'] = 'id'
@ -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'''
filterjson = params_kw.get('data_filter')
if not filterjson:
fields = [ f['name'] for f in [
fields_str=r'''[
{
"name": "id",
"title": "id",
@ -52,7 +51,10 @@ if not filterjson:
"title": "计量值",
"type": "short"
}
] ]
]'''
ori_fields = json.loads(fields_str)
if not filterjson:
fields = [ f['name'] for f in ori_fields ]
filterjson = default_filterjson(fields, ns)
filterdic = ns.copy()
filterdic['filterstr'] = ''
@ -73,10 +75,10 @@ sql = ac.convert(sql, filterdic)
debug(f'{sql=}')
db = DBPools()
dbname = await rfexe('get_module_dbname', 'cpcc')
dbname = get_module_dbname('cpcc')
async with db.sqlorContext(dbname) as sor:
r = await sor.sqlPaging(sql, ns)
return r
r = await sor.sqlPaging(sql, ns)
return r
return {
"total":0,
"rows":[]

View File

@ -1,8 +1,10 @@
{
"id":"components_tbl",
"widgettype":"Tabular",
"options":{
"widgettype":"Tabular",
"options":{
"width":"100%",
"height":"100%",
"title":"部件表",
@ -12,14 +14,22 @@
"css":"card",
"editable":{
"new_data_url":"{{entire_url('add_components.dspy')}}",
"delete_data_url":"{{entire_url('delete_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_params":{{json.dumps(params_kw, indent=4, ensure_ascii=False)}},
"row_options":{
@ -69,7 +79,7 @@
"valueField": "ccatelogid",
"textField": "ccatelogid_text",
"params": {
"dbname": "{{rfexe('get_module_dbname', 'cpcc')}}",
"dbname": "{{get_module_dbname('cpcc')}}",
"table": "appcodes_kv",
"tblvalue": "k",
"tbltext": "v",
@ -109,13 +119,13 @@
"label": "计量值"
}
]
},
},
"page_rows":160,
"cache_limit":5
}
"page_rows":160,
"cache_limit":5
}
,"binds":[]

View File

@ -1,32 +1,36 @@
ns = params_kw.copy()
for k,v in ns.items():
if v == 'NaN' or v == 'null':
ns[k] = None
db = DBPools()
dbname = await rfexe('get_module_dbname', 'cpcc')
dbname = get_module_dbname('cpcc')
async with db.sqlorContext(dbname) as sor:
r = await sor.U('components', ns)
debug('update success');
return {
"widgettype":"Message",
"options":{
"title":"Update Success",
r = await sor.U('components', ns)
debug('update success');
return {
"widgettype":"Message",
"options":{
"title":"Update Success",
"cwidth":16,
"cheight":9,
"timeout":3,
"message":"ok"
}
}
"message":"ok"
}
}
return {
"widgettype":"Error",
"options":{
"title":"Update Error",
"widgettype":"Error",
"options":{
"title":"Update Error",
"cwidth":16,
"cheight":9,
"timeout":3,
"message":"failed"
}
"message":"failed"
}
}

View File

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

View File

@ -1,33 +1,33 @@
ns = {
'id':params_kw['id'],
'id':params_kw['id'],
}
db = DBPools()
dbname = await rfexe('get_module_dbname', 'cpcc')
dbname = get_module_dbname('cpcc')
async with db.sqlorContext(dbname) as sor:
r = await sor.D('cpccluster', ns)
debug('delete success');
return {
"widgettype":"Message",
"options":{
"title":"Delete Success",
r = await sor.D('cpccluster', ns)
debug('delete success');
return {
"widgettype":"Message",
"options":{
"title":"Delete Success",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"ok记得把关联的节点都解除占用状态 ~"
}
}
"message":"ok"
}
}
debug('Delete failed');
return {
"widgettype":"Error",
"options":{
"title":"Delete Error",
"widgettype":"Error",
"options":{
"title":"Delete Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"failed"
}
"message":"failed"
}
}

View File

@ -4,19 +4,19 @@ ns = params_kw.copy()
debug(f'get_cpccluster.dspy:{ns=}')
if not ns.get('page'):
ns['page'] = 1
ns['page'] = 1
if not ns.get('sort'):
ns['sort'] = 'id'
sql = '''select a.*, b.clustertype_text, c.controllerid_text
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,
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')
if not filterjson:
fields = [ f['name'] for f in [
fields_str=r'''[
{
"name": "id",
"title": "id",
@ -60,7 +60,10 @@ if not filterjson:
"type": "date",
"length": 255
}
] ]
]'''
ori_fields = json.loads(fields_str)
if not filterjson:
fields = [ f['name'] for f in ori_fields ]
filterjson = default_filterjson(fields, ns)
filterdic = ns.copy()
filterdic['filterstr'] = ''
@ -81,10 +84,10 @@ sql = ac.convert(sql, filterdic)
debug(f'{sql=}')
db = DBPools()
dbname = await rfexe('get_module_dbname', 'cpcc')
dbname = get_module_dbname('cpcc')
async with db.sqlorContext(dbname) as sor:
r = await sor.sqlPaging(sql, ns)
return r
r = await sor.sqlPaging(sql, ns)
return r
return {
"total":0,
"rows":[]

View File

@ -1,239 +1,155 @@
{
"id": "cpccluster_tbl",
"widgettype": "Tabular",
"options": {
"title": "算力集群",
"css": "card",
"toolbar": {
"tools": [
{
"name": "newworker",
"selected_row": true,
"label": "新增工作节点"
},
{
"name": "newpodyaml",
"selected_row": true,
"label": "新建资源YAML"
}
],
"css": "float-right"
},
"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": {
"exclouded": [
"id",
"cpcid",
"clusterid"
],
"alters": {}
},
"editexclouded": [
"id",
"cpcid",
"clusterid"
],
"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",
"title": "id",
"type": "str",
"length": 32,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "id"
},
{
"name": "cpcid",
"title": "算力中心id",
"type": "str",
"length": 32,
"nullable": "no",
"cwidth": 10,
"uitype": "str",
"datatype": "str",
"label": "算力中心id"
},
{
"name": "clustertype",
"title": "集群类型",
"type": "str",
"length": 1,
"cwidth": 8,
"label": "集群类型",
"uitype": "code",
"valueField": "clustertype",
"textField": "clustertype_text",
"params": {
"dbname": "{{rfexe('get_module_dbname', 'cpcc')}}",
"table": "appcodes_kv",
"tblvalue": "k",
"tbltext": "v",
"valueField": "clustertype",
"textField": "clustertype_text",
"cond": "parentid='clustertype'"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{
"name": "clusterjoin",
"title": "加入集群凭证",
"type": "str",
"length": 255,
"cwidth": 45,
"uitype": "str",
"datatype": "str",
"label": "加入集群凭证"
},
{
"name": "enable_date",
"title": "启用日期",
"type": "date",
"length": 0,
"cwidth": 8,
"uitype": "date",
"datatype": "date",
"label": "启用日期"
},
{
"name": "export_date",
"title": "停用日期",
"type": "date",
"length": 0,
"cwidth": 8,
"uitype": "date",
"datatype": "date",
"label": "停用日期"
}
]
},
"content_view": {
"widgettype": "TabPanel",
"options": {
"tab_wide": "auto",
"height": "100%",
"width": "100%",
"tab_pos": "top",
"items": [
{
"name": "cpcpod",
"label": "实时资源实例",
"content": {
"widgettype": "urlwidget",
"options": {
"params": {
"clusterid": "${id}",
"cpcid": "${cpcid}"
},
"url": "{{entire_url('..\/cpcpod')}}"
}
}
},
{
"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": [
"id":"cpccluster_tbl",
"widgettype":"Tabular",
"options":{
"width":"100%",
"height":"100%",
"title":"算力集群",
"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')}}"
},
"data_url":"{{entire_url('./get_cpccluster.dspy')}}",
"data_method":"GET",
"data_params":{{json.dumps(params_kw, indent=4, ensure_ascii=False)}},
"row_options":{
"browserfields": {
"exclouded": [
"id",
"cpcid"
],
"alters": {}
},
"editexclouded":[
"id",
"cpcid"
],
"fields":[
{
"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}}"
}
}
"name": "id",
"title": "id",
"type": "str",
"length": 32,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "id"
},
{
"wid": "self",
"event": "newpodyaml",
"actiontype": "urlwidget",
"target": "PopupWindow",
"popup_options": {
"width": "80%",
"height": "80%"
"name": "name",
"title": "名称",
"type": "str",
"length": 255,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "名称"
},
{
"name": "cpcid",
"title": "算力中心id",
"type": "str",
"length": 32,
"nullable": "no",
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "算力中心id"
},
{
"name": "clustertype",
"title": "集群类型",
"type": "str",
"length": 1,
"label": "集群类型",
"uitype": "code",
"valueField": "clustertype",
"textField": "clustertype_text",
"params": {
"dbname": "{{get_module_dbname('cpcc')}}",
"table": "appcodes_kv",
"tblvalue": "k",
"tbltext": "v",
"valueField": "clustertype",
"textField": "clustertype_text",
"cond": "parentid='clustertype'"
},
"options": {
"url": "{{entire_url('../cpcpod/new_podyaml.ui')}}",
"params": {
"id": "{{params_kw.id}}"
}
}
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{
"name": "controllerid",
"title": "控制节点id",
"type": "str",
"length": 32,
"label": "控制节点id",
"uitype": "code",
"valueField": "controllerid",
"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",
"title": "启用日期",
"type": "date",
"length": 0,
"cwidth": 18,
"uitype": "date",
"datatype": "date",
"label": "启用日期"
},
{
"name": "export_date",
"title": "停用日期",
"type": "date",
"length": 0,
"cwidth": 18,
"uitype": "date",
"datatype": "date",
"label": "停用日期"
}
]
}
]
},
"page_rows":160,
"cache_limit":5
}
,"binds":[]
}

View File

@ -1,32 +1,36 @@
ns = params_kw.copy()
for k,v in ns.items():
if v == 'NaN' or v == 'null':
ns[k] = None
db = DBPools()
dbname = await rfexe('get_module_dbname', 'cpcc')
dbname = get_module_dbname('cpcc')
async with db.sqlorContext(dbname) as sor:
r = await sor.U('cpccluster', ns)
debug('update success');
return {
"widgettype":"Message",
"options":{
"title":"Update Success",
r = await sor.U('cpccluster', ns)
debug('update success');
return {
"widgettype":"Message",
"options":{
"title":"Update Success",
"cwidth":16,
"cheight":9,
"timeout":3,
"message":"ok"
}
}
"message":"ok"
}
}
return {
"widgettype":"Error",
"options":{
"title":"Update Error",
"widgettype":"Error",
"options":{
"title":"Update Error",
"cwidth":16,
"cheight":9,
"timeout":3,
"message":"failed"
}
"message":"failed"
}
}

View File

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

View File

@ -1,6 +1,6 @@
ns = {
'id':params_kw['id'],
'id':params_kw['id'],
}
@ -19,29 +19,29 @@ if not userorgid:
ns['orgid'] = userorgid
db = DBPools()
dbname = await rfexe('get_module_dbname', 'cpcc')
dbname = get_module_dbname('cpcc')
async with db.sqlorContext(dbname) as sor:
r = await sor.D('cpclist', ns)
debug('delete success');
return {
"widgettype":"Message",
"options":{
"title":"Delete Success",
r = await sor.D('cpclist', ns)
debug('delete success');
return {
"widgettype":"Message",
"options":{
"title":"Delete Success",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"ok"
}
}
"message":"ok"
}
}
debug('Delete failed');
return {
"widgettype":"Error",
"options":{
"title":"Delete Error",
"widgettype":"Error",
"options":{
"title":"Delete Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"failed"
}
"message":"failed"
}
}

View File

@ -19,7 +19,7 @@ ns['userorgid'] = userorgid
debug(f'get_cpclist.dspy:{ns=}')
if not ns.get('page'):
ns['page'] = 1
ns['page'] = 1
if not ns.get('sort'):
ns['sort'] = 'id'
@ -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'''
filterjson = params_kw.get('data_filter')
if not filterjson:
fields = [ f['name'] for f in [
fields_str=r'''[
{
"name": "id",
"title": "id",
@ -92,7 +91,10 @@ if not filterjson:
"type": "str",
"length": 100
}
] ]
]'''
ori_fields = json.loads(fields_str)
if not filterjson:
fields = [ f['name'] for f in ori_fields ]
filterjson = default_filterjson(fields, ns)
filterdic = ns.copy()
filterdic['filterstr'] = ''
@ -113,10 +115,10 @@ sql = ac.convert(sql, filterdic)
debug(f'{sql=}')
db = DBPools()
dbname = await rfexe('get_module_dbname', 'cpcc')
dbname = get_module_dbname('cpcc')
async with db.sqlorContext(dbname) as sor:
r = await sor.sqlPaging(sql, ns)
return r
r = await sor.sqlPaging(sql, ns)
return r
return {
"total":0,
"rows":[]

View File

@ -1,209 +1,266 @@
{
"id": "cpclist_tbl",
"widgettype": "Tabular",
"options": {
"title": "算力中心列表",
"toolbar": {
"tools": [
{
"name": "newcluster",
"selected_row": true,
"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')}}"
},
"data_url": "{{entire_url('./get_cpclist.dspy')}}",
"data_method": "GET",
"data_params": {{json.dumps(params_kw, indent=4, ensure_ascii=False)}},
"row_options": {
"browserfields": {
"exclouded": [
"id",
"orgid",
"pcapi_url",
"pcapi_user",
"pcapi_pwd"
],
"alters": {}
},
"editexclouded": [
"id",
"orgid"
],
"fields": [
{
"name": "id",
"title": "id",
"type": "str",
"length": 32,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "id"
},
{
"name": "name",
"title": "名称",
"type": "str",
"length": 255,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "名称"
},
{
"name": "orgid",
"title": "属主机构id",
"type": "str",
"length": 32,
"label": "属主机构id",
"uitype": "code",
"valueField": "orgid",
"textField": "orgid_text",
"params": {
"dbname": "{{rfexe('get_module_dbname', 'cpcc')}}",
"table": "organization",
"tblvalue": "id",
"tbltext": "orgname",
"valueField": "orgid",
"textField": "orgid_text"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{
"name": "pcapi_url",
"title": "pcapi网址",
"type": "str",
"length": 500,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "pcapi网址"
},
{
"name": "api_user",
"title": "接口用户",
"type": "str",
"length": 100,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "接口用户"
},
{
"name": "api_pwd",
"title": "接口密码",
"type": "str",
"length": 100,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "接口密码"
},
{
"name": "enable_date",
"title": "启用日期",
"type": "date",
"length": 0,
"cwidth": 18,
"uitype": "date",
"datatype": "date",
"label": "启用日期"
},
{
"name": "expire_date",
"title": "停用日期",
"type": "date",
"length": 0,
"cwidth": 18,
"uitype": "date",
"datatype": "date",
"label": "停用日期"
},
{
"name": "contactname",
"title": "联系人",
"type": "str",
"length": 100,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "联系人"
},
{
"name": "contactphone",
"title": "联系电话",
"type": "str",
"length": 100,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "联系电话"
}
]
},
"content_view": {
"widgettype": "TabPanel",
"options": {
"tab_wide": "auto",
"height": "100%",
"width": "100%",
"tab_pos": "top",
"items": [
{
"name": "cpccluster",
"label": "集群",
"content": {
"widgettype": "urlwidget",
"options": {
"params": {
"cpcid": "${id}"
},
"url": "{{entire_url('..\/cpccluster')}}"
}
}
},
{
"name": "cpcnode",
"label": "节点",
"content": {
"widgettype": "urlwidget",
"options": {
"params": {
"cpcid": "${id}"
},
"url": "{{entire_url('..\/cpcnode')}}"
}
}
}
]
}
},
"page_rows": 160,
"cache_limit": 5
},
"binds": [
"id":"cpclist_tbl",
"widgettype":"Tabular",
"options":{
"width":"100%",
"height":"100%",
"title":"算力中心列表",
"toolbar":{
"tools": [
{
"wid": "self",
"event": "newcluster",
"actiontype": "urlwidget",
"target": "PopupWindow",
"popup_options": {
"width": "80%",
"height": "80%"
},
"options": {
"url": "{{entire_url('../handy/new_cluster.ui')}}",
"params": {
"id": "{{params_kw.id}}"
}
}
"name": "newcluster",
"selected_row": true,
"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')}}"
},
"data_url":"{{entire_url('./get_cpclist.dspy')}}",
"data_method":"GET",
"data_params":{{json.dumps(params_kw, indent=4, ensure_ascii=False)}},
"row_options":{
"browserfields": {
"exclouded": [
"id",
"orgid",
"pcapi_url",
"pcapi_user",
"pcapi_pwd"
],
"alters": {}
},
"editexclouded":[
"id",
"orgid"
],
"fields":[
{
"name": "id",
"title": "id",
"type": "str",
"length": 32,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "id"
},
{
"name": "name",
"title": "名称",
"type": "str",
"length": 255,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "名称"
},
{
"name": "orgid",
"title": "属主机构id",
"type": "str",
"length": 32,
"label": "属主机构id",
"uitype": "code",
"valueField": "orgid",
"textField": "orgid_text",
"params": {
"dbname": "{{get_module_dbname('cpcc')}}",
"table": "organization",
"tblvalue": "id",
"tbltext": "orgname",
"valueField": "orgid",
"textField": "orgid_text"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{
"name": "pcapi_url",
"title": "pcapi网址",
"type": "str",
"length": 500,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "pcapi网址"
},
{
"name": "api_user",
"title": "接口用户",
"type": "str",
"length": 100,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "接口用户"
},
{
"name": "api_pwd",
"title": "接口密码",
"type": "str",
"length": 100,
"cwidth": 18,
"uitype": "password",
"datatype": "str",
"label": "接口密码"
},
{
"name": "enable_date",
"title": "启用日期",
"type": "date",
"length": 0,
"cwidth": 18,
"uitype": "date",
"datatype": "date",
"label": "启用日期"
},
{
"name": "expire_date",
"title": "停用日期",
"type": "date",
"length": 0,
"cwidth": 18,
"uitype": "date",
"datatype": "date",
"label": "停用日期"
},
{
"name": "contactname",
"title": "联系人",
"type": "str",
"length": 100,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "联系人"
},
{
"name": "contactphone",
"title": "联系电话",
"type": "str",
"length": 100,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "联系电话"
}
]
},
"page_rows":160,
"cache_limit":5
}
,"binds":[
{
"wid": "self",
"event": "newcluster",
"actiontype": "urlwidget",
"target": "PopupWindow",
"popup_options": {
"width": "80%",
"height": "80%"
},
"options": {
"url": "{{entire_url('../handy/new_cluster.ui')}}",
"params": {
"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()
for k,v in ns.items():
if v == 'NaN' or v == 'null':
ns[k] = None
userorgid = await get_userorgid()
@ -18,32 +21,53 @@ ns['orgid'] = userorgid
if params_kw.get('api_pwd'):
ns['api_pwd'] = password_encode(params_kw.get('api_pwd'))
ns['api_pwd'] = password_encode(params_kw.get('api_pwd'))
db = DBPools()
dbname = await rfexe('get_module_dbname', 'cpcc')
dbname = get_module_dbname('cpcc')
async with db.sqlorContext(dbname) as sor:
r = await sor.U('cpclist', ns)
debug('update success');
return {
"widgettype":"Message",
"options":{
"title":"Update Success",
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)
debug('update success');
return {
"widgettype":"Message",
"options":{
"title":"Update Success",
"cwidth":16,
"cheight":9,
"timeout":3,
"message":"ok"
}
}
"message":"ok"
}
}
return {
"widgettype":"Error",
"options":{
"title":"Update Error",
"widgettype":"Error",
"options":{
"title":"Update Error",
"cwidth":16,
"cheight":9,
"timeout":3,
"message":"failed"
}
"message":"failed"
}
}

View File

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

View File

@ -1,33 +1,33 @@
ns = {
'id':params_kw['id'],
'id':params_kw['id'],
}
db = DBPools()
dbname = await rfexe('get_module_dbname', 'cpcc')
dbname = get_module_dbname('cpcc')
async with db.sqlorContext(dbname) as sor:
r = await sor.D('cpcnode', ns)
debug('delete success');
return {
"widgettype":"Message",
"options":{
"title":"Delete Success",
r = await sor.D('cpcnode', ns)
debug('delete success');
return {
"widgettype":"Message",
"options":{
"title":"Delete Success",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"ok"
}
}
"message":"ok"
}
}
debug('Delete failed');
return {
"widgettype":"Error",
"options":{
"title":"Delete Error",
"widgettype":"Error",
"options":{
"title":"Delete Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"failed"
}
"message":"failed"
}
}

View File

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

View File

@ -1,179 +1,188 @@
{
"id": "cpcnode_tbl",
"widgettype": "Tabular",
"options": {
"title": "入网算力节点",
"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)}},
"row_options": {
"browserfields": {
"exclouded": [
"id",
"cpcid",
"clusterid"
],
"alters": {}
},
"editexclouded": [
"id",
"cpcid",
"clusterid"
],
"fields": [
{
"name": "id",
"title": "id",
"type": "str",
"length": 32,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "id"
},
{
"name": "ip",
"title": "内网ip",
"type": "str",
"length": 90,
"cwidth": 10,
"uitype": "str",
"datatype": "str",
"label": "内网ip"
},
{
"name": "name",
"title": "名称",
"type": "str",
"length": 255,
"cwidth": 16,
"uitype": "str",
"datatype": "str",
"label": "名称"
},
{
"name": "devicetype",
"title": "设备类型",
"type": "str",
"length": 1,
"cwidth": 8,
"label": "设备类型",
"uitype": "code",
"valueField": "devicetype",
"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",
"title": "ssh端口号",
"type": "short",
"length": 0,
"uitype": "int",
"datatype": "short",
"label": "ssh端口号"
},
{
"name": "adminuser",
"title": "管理账号",
"type": "str",
"length": 99,
"cwidth": 8,
"uitype": "str",
"datatype": "str",
"label": "管理账号"
},
{
"name": "adminpwd",
"title": "管理密码",
"type": "str",
"length": 99,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "管理密码"
},
{
"name": "cpcid",
"title": "算力中心id",
"type": "str",
"length": 32,
"nullable": "no",
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "算力中心id"
},
{
"name": "node_status",
"title": "节点状态",
"type": "str",
"length": 1,
"nullable": "yes",
"label": "节点状态",
"uitype": "code",
"valueField": "node_status",
"textField": "node_status_text",
"params": {
"dbname": "{{rfexe('get_module_dbname', 'cpcc')}}",
"table": "appcodes_kv",
"tblvalue": "k",
"tbltext": "v",
"valueField": "node_status",
"textField": "node_status_text",
"cond": "parentid='node_status'"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{
"name": "clusterid",
"title": "所属集群",
"type": "long",
"length": 0,
"nullable": "yes",
"cwidth": 18,
"uitype": "int",
"datatype": "long",
"label": "所属集群"
},
{
"name": "enable_date",
"title": "启用日期",
"type": "date",
"length": 0,
"cwidth": 18,
"uitype": "date",
"datatype": "date",
"label": "启用日期"
},
{
"name": "export_date",
"title": "停用日期",
"type": "date",
"length": 0,
"cwidth": 18,
"uitype": "date",
"datatype": "date",
"label": "停用日期"
}
]
},
"page_rows": 160,
"cache_limit": 5
"id":"cpcnode_tbl",
"widgettype":"Tabular",
"options":{
"width":"100%",
"height":"100%",
"title":"算力节点",
"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)}},
"row_options":{
"browserfields": {
"exclouded": [
"id",
"cpcid"
],
"alters": {}
},
"editexclouded":[
"id",
"cpcid",
"clusterid"
],
"fields":[
{
"name": "id",
"title": "id",
"type": "str",
"length": 32,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "id"
},
"binds": []
{
"name": "name",
"title": "名称",
"type": "str",
"length": 255,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "名称"
},
{
"name": "ip",
"title": "内网ip",
"type": "str",
"length": 90,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "内网ip"
},
{
"name": "sshport",
"title": "ssh端口号",
"type": "short",
"length": 0,
"uitype": "int",
"datatype": "short",
"label": "ssh端口号"
},
{
"name": "adminuser",
"title": "管理账号",
"type": "str",
"length": 99,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "管理账号"
},
{
"name": "adminpwd",
"title": "管理密码",
"type": "str",
"length": 99,
"cwidth": 18,
"uitype": "password",
"datatype": "str",
"label": "管理密码"
},
{
"name": "cpcid",
"title": "算力中心id",
"type": "str",
"length": 32,
"nullable": "no",
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "算力中心id"
},
{
"name": "node_status",
"title": "节点状态",
"type": "str",
"length": 1,
"nullable": "yes",
"label": "节点状态",
"uitype": "code",
"valueField": "node_status",
"textField": "node_status_text",
"params": {
"dbname": "{{get_module_dbname('cpcc')}}",
"table": "appcodes_kv",
"tblvalue": "k",
"tbltext": "v",
"valueField": "node_status",
"textField": "node_status_text",
"cond": "parentid='node_status'"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{
"name": "clusterid",
"title": "所属集群",
"type": "long",
"length": 0,
"nullable": "yes",
"cwidth": 18,
"uitype": "int",
"datatype": "long",
"label": "所属集群"
},
{
"name": "enable_date",
"title": "启用日期",
"type": "date",
"length": 0,
"cwidth": 18,
"uitype": "date",
"datatype": "date",
"label": "启用日期"
},
{
"name": "export_date",
"title": "停用日期",
"type": "date",
"length": 0,
"cwidth": 18,
"uitype": "date",
"datatype": "date",
"label": "停用日期"
}
]
},
"page_rows":160,
"cache_limit":5
}
,"binds":[]
}

View File

@ -1,35 +1,39 @@
ns = params_kw.copy()
for k,v in ns.items():
if v == 'NaN' or v == 'null':
ns[k] = None
if params_kw.get('adminpwd'):
ns['adminpwd'] = password_encode(params_kw.get('adminpwd'))
ns['adminpwd'] = password_encode(params_kw.get('adminpwd'))
db = DBPools()
dbname = await rfexe('get_module_dbname', 'cpcc')
dbname = get_module_dbname('cpcc')
async with db.sqlorContext(dbname) as sor:
r = await sor.U('cpcnode', ns)
debug('update success');
return {
"widgettype":"Message",
"options":{
"title":"Update Success",
r = await sor.U('cpcnode', ns)
debug('update success');
return {
"widgettype":"Message",
"options":{
"title":"Update Success",
"cwidth":16,
"cheight":9,
"timeout":3,
"message":"ok"
}
}
"message":"ok"
}
}
return {
"widgettype":"Error",
"options":{
"title":"Update Error",
"widgettype":"Error",
"options":{
"title":"Update Error",
"cwidth":16,
"cheight":9,
"timeout":3,
"message":"failed"
}
"message":"failed"
}
}