nVisual作为一个图形化管理软件,首要的是将视图内对象渲染出来,对象渲染的数据来源于diagram接口,本章小编带大家了解这个接口。
- 接口描述:传入视图节点id,获取视图属性、视图背景、视图内对象数据
- URL地址:http://ip:port /wapi/v1/diagram/{diagramId}
- 访问方法::Get
英文参数名 | 中文参数名 | 类型 | 必填 | 默认值 | 描述 |
diagramId | 视图Id | Long | 是 | 顶层视图id是24000000000001,之后打开哪个节点视图,视图id即为节点本身id | |
top_left_x | 视图左上角x坐标 | Double | 否 | 所在视图为地图时,需要传参视图范围,左上角和右下角来限定加载视图范围,根据限定的视图范围,加载范围内对象。地图坐标系是墨卡托投影坐标 | |
top_left_y | 视图左上角y坐标 | Double | 否 | ||
bottom_right_x | 视图右下角x坐标 | Double | 否 | ||
bottom_right_y | 视图右下角y坐标 | Double | 否 | ||
map_zoom | 当前视图所在地图层级 | Double | 否 | 所在视图是地图时,需要知道当前所在视图层级 |
样例传参:
常规视图:
localhost:8081/wapi/v1/diagram/24000000000001
地图:
localhost:8081/wapi/v1/diagram/24000000173161?top_left_x=12004144.930958997&top_left_y=5606184.75128747&bottom_right_x=13607488.03626885&bottom_right_y=4196074.4534825375&map_zoom=8&map_maxZoom=19
接口会根据传参返回当前视图要加载的数据的一切,包含:当前视图层级、视图权限、视图背景图片、视图宽高、视图比例、视图类型、内部节点对象、内部连线对象等…
返回成功样例
{
"code": 200,
"breadcrumbs": [
"顶层",
"测试学习",
"zyb",
"节点",
"学校",
"node"
],
"node_diagram": {
"id": 24000000160302,
"typeId": 26000000000000,
"parentId": 24000000151465,
"name": "node",
"background": "",
"route": "24000000000001/24000000019900/24000000151441/24000000151463/24000000151465/24000000160302",
"diagramWidth": 1000,
"diagramHeight": 750,
"diagramMarginSize": null,
"hidden": null,
"slotId": null,
"masterId": null,
"insertUserId": 94000000000300,
"templateId": null,
"adaNodeId": null,
"connectorCode": null,
"rackOverrideType": null,
"showContainerChildren": true,
"doubleClickBehavior": "default",
"mapCoordinateLeft": null,
"mapCoordinateTop": null,
"mapCoordinateRight": null,
"mapCoordinateBottom": null,
"mapUnitsType": null,
"dinamicMapSupport": null,
"autoLayoutState": null,
"mapSource": null,
"displayGrid": null,
"snapToGrid": null,
"gridSpacingY": null,
"gridSpacingX": null,
"pageColor": "#FFFFFF",
"overrideTemplateGrid": null,
"readOnlyForNonAdmins": null,
"collectorId": null,
"diagramScale": 10,
"mapZoom": 3,
"blocked": false
},
"node_type_diagram": {
"id": 26000000000000,
"name": "node",
"image": "xejh0pfy.svg",
"image2": "",
"background": "",
"defaultWidth": 117.12777191129884,
"defaultHeight": 117.12777191129884,
"typeGroup": 1,
"hierarchyBrowserLabel": 28000000003736,
"width": 50,
"height": 50,
"templateId": null,
"vendorId": 880,
"description": "节点",
"keepAspectRatio": true,
"showContainerChildren": false,
"doubleClickBehavior": "test",
"categoryId": null,
"snmpOid": "",
"independentMounting": false,
"inStock": -1,
"nodeClassGroupId": 110012,
"nodeClassId": null,
"creator": null,
"createDate": null,
"deep": 0,
"enabled": true,
"system": true,
"favourite": true
},
"vis_links": [
{
"linkId": 25000000114815,
"typeId": 27000000000060,
"name": " \n",
"fromNode": 24000000160303,
"toNode": 24000000160304,
"fromRoute": "24000000000001/24000000019900/24000000151441/24000000151463/24000000151465/24000000160302/24000000160303",
"toRoute": "24000000000001/24000000019900/24000000151441/24000000151463/24000000151465/24000000160302/24000000160304",
"visLinkId": 211307,
"diagramId": 24000000160302,
"routepath": null,
"fromAnchorPointX": 0.5,
"fromAnchorPointY": 0.5,
"toAnchorPointX": 0.5,
"toAnchorPointY": 0.5,
"canDelete": true,
"canMove": true,
"displayed": true,
"color": "#cb5b06",
"thickness": 1,
"htLinkType": "{\"linkType\":null,\"startArrowHead\":null,\"endArrowHead\":null,\"autoArrangement\":false}",
"displayedVisLinkFields2": [],
"table": []
}
],
"vis_nodes": [
{
"id": 2550947,
"nodeId": 24000000160303,
"diagramId": 24000000160302,
"x": 217.5785183006974,
"y": 241.13354846368617,
"width": 116.70357514917723,
"height": 160.25068415238206,
"imageOverride": null,
"keepAspectRatio": false,
"angle": 0,
"canMove": true,
"canResize": true,
"canRotate": true,
"canDelete": true,
"zOrder": 0,
"displayed": true,
"typeId": 26000000000000,
"name": "node",
"parentId": 24000000160302,
"slotId": null,
"masterId": null,
"route": "24000000000001/24000000019900/24000000151441/24000000151463/24000000151465/24000000160302/24000000160303",
"mapZoom": 3,
"nodeTypeName": "node",
"nodeTypeImage": "xejh0pfy.svg",
"nodeTypeTypeGroup": 1,
"nodeTypeHeight": 50,
"nodeTypeWidth": 50,
"mountedNodesData": null,
"displayedVisNodeFields": null,
"shapes": null,
"diagramSublink": null,
"diagramSublinks": null,
"unitsHeight": null,
"hasEmbeddedFile": false,
"clusterSize": null,
"table": [],
"blocked": false,
"master": true,
"cluster": null
},
],
"ports": [],
"containerChildren": [],
"slots": [],
"diagram_properties": {
"racks_count": 0,
"nodes_count": 2,
"devices_count": 0,
"links_count": 1
},
"diagram_node_properties": [
{
"propertyId": 28000000003736,
"nodeTypeId": 26000000000000,
"name": "名称",
"defaultValue": "%template%0",
"position": 0,
"mandatory": true,
"displayed": false,
"fontSize": 12,
"fontColor": "#000000",
"notEditable": false,
"offsetX": 0,
"offsetY": 0,
"angle": 0,
"anchorPointX": 1,
"anchorPointY": 1,
"bold": false,
"italic": false,
"underline": false,
"fontFamily": "Arial",
"fillColor": "",
"align": 0,
"lockList": false,
"justification": 0,
"snmpOid": "",
"propertyValueId": 5820681,
"nodeId": 24000000160302,
"value": "node",
"hasPropertyValue": true,
"nodeOverrides": [],
"visNodeFields": {
"visNodeId": 2550946,
"propertyValueId": 5820681,
"offsetY": 0,
"offsetX": 0,
"fontSize": 4.1208791208791204,
"canMove": true,
"color": "#000000",
"state": false,
"angle": 0,
"bold": false,
"italic": false,
"underline": false,
"fontFamily": "Arial",
"backgroundColor": "#FFFFFF",
"align": false,
"anchor": false,
"uprightAlignment": null,
"justification": false,
"mapZoom": 3,
"new": true
},
"system": false,
"inProperties": true,
"typeField": false,
"uniqueForThisType": false,
"uniqueForAllTypes": false
},
],
"free_texts": [],
"diagram_permissions": "Admin"
}
英文参数名 | 中文参数名 | 类型 | 描述 |
code | 状态码 | Int | 200成功,其他失败 |
breadcrumbs | 导航 | Map | |
node_diagram | 视图属性 | Map | |
Id | id | Long | |
typeid | 类型id | Long | |
parentid | 父节点id | Long | |
name | 字段名 | String | |
background | 背景 | String | |
route | 路径 | String | |
diagramWidth | 图形宽度 | Double | |
diagramHeight | 图形长度 | Double | |
diagramMarginSize | 图形页面空白大小 | Double | |
hidden | 隐藏 | Boolean | |
slotId | 槽id | Long | |
masterId | 主体id | Long | |
insertUserId | 用户id | Long | |
templateId | 模板id | Long | |
adaNodeId | 自动数据采集模型id | Long | |
rackOverrideType | 架覆盖类型 | String | |
showContainerChildren | 展示机柜的子级 | Boolean | |
doubleClickBehavior | 双击的反应 | String | |
mapCoordinateLeft | 地图左坐标 | Double | |
mapCoordinateTop | 地图顶部坐标 | Double | |
mapCoordinateRight | 地图右坐标 | Double | |
mapCoordinateBottom | 地图底部坐标 | Double | |
mapUnitsType | 地图单位种类 | ||
dinamicMapSupport | 动态地图支持 | ||
autoLayoutState | 自动布局状态 | ||
mapSource | 地图源 | Int | |
displayGrid | 展示网格 | ||
snapToGrid | 对齐网格 | ||
gridSpacingY | 网格行距y坐标 | ||
gridSpacingX | 网格行距z坐标 | ||
pageColor | 页面颜色 | String | |
overrideTemplateGrid | 覆盖模板网格 | ||
readOnlyForNonAdmins | 非管理员只读 | ||
collectorId | 收藏id | ||
diagramScale | 图形缩放 | Double | |
mapZoom | 地图层级 | Double | |
blocked | 封闭的 | Boolean | |
image | 图像 | String | |
Image2 | 图像2 | String | |
background | 背景 | String | |
defaultWidth | 默认宽度 | Double | |
defaultHeight | 默认高度 | Double | |
typeGroup | 组类型 | Int | |
hierarchyBrowserLabel | 层次结构浏览器标签 | Long | |
width | 宽度 | Double | |
height | 高度 | Double | |
templateId | 模板id | Long | |
vendorId | 供应商id | Long | |
description | 描述 | String | |
keepAspectRatio | 是否保持长宽比 | Boolean | |
categoryId | 种类id | Long | |
snmpOid | |||
independentMounting | 独立安装 | Boolean | |
inStock | 在库的 | Int | |
nodeClassGroupId | 节点类组id | Long | |
nodeClassId | 节点类id | Long | |
creator | 创造者 | ||
createDate | 创造日期 | ||
deep | 深度 | Double | |
enabled | 启用 | Boolean | |
system | 系统 | Boolean | |
favourite | 最喜欢的 | Boolean | |
vis_links | 显示连接 | List | |
linkId | 连接id | Long | |
fromNode | 从哪个节点起 | Long | |
toNode | 到哪个节点 | Long | |
fromRoute | 从什么路径走 | String | |
toRoute | 到什么路径 | String | |
visLinkId | 显示连接id | Long | |
diagramId | 图形Id | Long | |
routepath | 路线路径? | String | |
fromAnchorPointX | 起点锚点x长度 | Double | |
fromAnchorPointY | 起点锚点y长度 | Double | |
toAnchorPointX | 终点锚点x长度 | Double | |
toAnchorPointY | 终点锚点y长度 | Double | |
canDelete | 是否可删除 | Boolean | |
canMove | 是否可移动 | Boolean | |
displayed | 是否显示 | Boolean | |
Color | 颜色 | String | |
htLinkType | Ht连接种类 | String | |
displayedVisLinkFields2 | 显示显示连接域2 | List | |
Table | 表格 | List | |
vis_nodes | 显示节点 | Map | |
nodeId | 节点Id | Long | |
x | x坐标 | Double | |
y | y坐标 | Double | |
width | 宽度 | Double | |
height | 高度 | Double | |
imageOverride | 图像覆盖 | String | |
keepAspectRatio | 是否保持长宽比 | Boolean | |
angle | 角度 | Double | |
canResize | 是否可调大小 | Boolean | |
canRotate | 是否可旋转 | Boolean | |
zOrder | 图层等级 | String | |
nodeTypeName | 节点种类名称 | String | |
nodeTypeImage | 节点种类图像 | String | |
nodeTypeTypeGroup | 节点种类种类组 | Int | |
nodeTypeHeight | 节点种类高 | Double | |
nodeTypeWidth | 节点种类宽 | Double | |
mountedNodesData | 设备上架u位数据 | ||
displayedVisNodeFields | 显示显示节点域 | ||
shapes | 形状 | ||
diagramSublink | 图形子连接 | ||
diagramSublinks | 图形子连接 | ||
unitsHeight | 部件高度 | ||
hasEmbeddedFile | 有嵌入式文件 | Boolean | |
clusterSize | 集群规模 | ||
cluster | 是否是聚合点 | ||
ports | 端口 | List | |
containerChildren | 机柜子集 | List | |
slots | 插槽 | List | |
diagram_properties | 图形属性 | Map | |
racks_count | 机架数 | Int | |
nodes_count | 节点数 | Int | |
devices_count | 设备数 | Int | |
links_count | 连接数 | Int | |
diagram_node_properties | 节点图形属性 | Map | |
propertyId | 属性id | Long | |
nodeTypeId | 节点种类id | Long | |
defaultValue | 默认值 | String | |
position | 位置 | Int | |
fontSize | 字体大小 | Double | |
fontColor | 字体颜色 | String | |
notEditable | 不可编辑的 | Boolean | |
offsetX | X轴偏移 | Double | |
offsetY | Y轴偏移 | Double | |
anchorPointX | X轴锚点 | Double | |
anchorPointY | Y轴锚点 | Double | |
bold | 粗体的? | Boolean | |
italic | 斜体的? | Boolean | |
underline | 下划线 | Boolean | |
fontFamily | 字体 | String | |
fillColor | 填充色 | String | |
align | 对齐 | Int | |
lockList | 列表锁 | Boolean | |
justification | 调整 | Boolean | |
propertyValueId | 属性值id | Long | |
hasPropertyValue | 有属性值 | Boolean | |
nodeOverrides | 节点覆盖 | List | |
visNodeFields | 显示节点的域 | Map | |
visNodeId | 显示节点id | Long | |
state | 状态 | Boolean | |
backgroundColor | 背景颜色 | String | |
anchor | 锚 | Boolean | |
uprightAlignment | 垂直对齐 | ||
new | 是否是新的 | Boolean | |
inProperties | 属性 | Boolean | |
typeField | 类型字段 | Boolean | |
free_texts | 自由文本 | List | |
diagram_permissions | 视图权限 | String |
文:李杨帆
标签:false,视图,diagram,nVisual,二次开发,null,true,节点 From: https://blog.51cto.com/u_14982569/5789395