Sidebar-FlowMeterComponent.js
3.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
(function () {
// Adds Atlassian shapes
// flowMeter label
Sidebar.prototype.addThingsKitFlowMeterPalette = function () {
const gn = 'mxgraph.flowMeter';
const dt = 'flowMeter';
const label = mxResources.get('flowmeter')
const width = 66;
const height = 74;
const prefix = `image;image=${window?.PROJECT_ENV.base}/webapp/images/thingskit/libs/`
const defaultStyle = ';imageAspect=0;'
this.setCurrentSearchEntryLibrary(dt);
const { COMPONENT_KEY, CATEGORY } = window.CellAttributeKeyEnum
function createUserObject(attribute) {
attribute = Object.assign({ [COMPONENT_KEY]: '', [CATEGORY]: '' }, attribute || {})
var xmlElement = mxUtils.createXmlDocument().createElement('UserObject');
Object.keys(attribute).forEach(key => {
xmlElement.setAttribute(key, attribute[key]);
})
return xmlElement
}
// 自定义属性
const cellAttribute = {
[COMPONENT_KEY]: 'Image',
[CATEGORY]: 'DEFAULT'
}
const graphPathLib = [
{
"name": mxResources.get('flowmeter1'),
"path": "flowMeter/压力.svg"
},
{
"name": mxResources.get('flowmeter2'),
"path": "flowMeter/微电脑控制器.svg"
},
{
"name": mxResources.get('flowmeter3'),
"path": "flowMeter/排气压力.svg"
},
{
"name": mxResources.get('flowmeter4'),
"path": "flowMeter/智能电磁流量计.svg"
},
{
"name": mxResources.get('flowmeter5'),
"path": "flowMeter/智能科氏流量计 1.svg"
},
{
"name": mxResources.get('flowmeter6'),
"path": "flowMeter/智能科氏流量计 2.svg"
},
{
"name": mxResources.get('flowmeter7'),
"path": "flowMeter/模拟输出流量传感器.svg"
},
{
"name": mxResources.get('flowmeter8'),
"path": "flowMeter/气旋流量计.svg"
},
{
"name": mxResources.get('flowmeter9'),
"path": "flowMeter/流元件.svg"
},
{
"name": mxResources.get('flowmeter0'),
"path": "flowMeter/流管.svg"
},
{
"name": mxResources.get('flowmeter11'),
"path": "flowMeter/流量积算器.svg"
},
{
"name": mxResources.get('flowmeter12'),
"path": "flowMeter/流量计.svg"
},
{
"name": mxResources.get('flowmeter13'),
"path": "flowMeter/涡轮流量计.svg"
},
{
"name": mxResources.get('flowmeter14'),
"path": "flowMeter/温度.svg"
},
{
"name": mxResources.get('flowmeter15'),
"path": "flowMeter/热式质量流量计.svg"
},
{
"name": mxResources.get('flowmeter16'),
"path": "flowMeter/电磁流量计 1.svg"
},
{
"name": mxResources.get('flowmeter17'),
"path": "flowMeter/电磁流量计 2.svg"
},
{
"name": mxResources.get('flowmeter18'),
"path": "flowMeter/电磁流量计3.svg"
},
{
"name": mxResources.get('flowmeter19'),
"path": "flowMeter/简单流量控制器.svg"
},
{
"name": mxResources.get('flowmeter20'),
"path": "flowMeter/简单流量控制器2.svg"
},
{
"name": mxResources.get('flowmeter21'),
"path": "flowMeter/锥式流量计.svg"
}
]
const fns = graphPathLib.map(item => {
return this.addEntry(this.getTagsForStencil(gn, item.name, dt).join(' '), mxUtils.bind(this, function () {
const cell = new mxCell(createUserObject(cellAttribute), new mxGeometry(0, 0, width, height), `${prefix}${item.path}${defaultStyle}`);
cell.setVertex(true)
return this.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, item.name);
}));
})
this.setGalleryLib(dt, label, graphPathLib)
this.addPaletteFunctions(dt, label, false, fns);
this.setCurrentSearchEntryLibrary();
};
})();