-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
213 lines (190 loc) · 7.96 KB
/
index.html
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
<link href="https://cdn.bootcss.com/semantic-ui/2.4.1/semantic.min.css" rel="stylesheet">
<script src="https://cdn.bootcss.com/semantic-ui/2.4.1/semantic.min.js"></script>
<script src="https://unpkg.com/[email protected]/konva.min.js"></script>
<meta charset="utf-8" />
<title>Modelerjs Demo</title>
<style>
body {
margin: 0;
padding: 0;
overflow: hidden;
background-color: #f0f0f0;
}
#contextmenu {
position: fixed;
z-index: 1000;
left: 0;
top: 0;
display: none;
}
</style>
</head>
<body>
<div id="container"></div>
<div class="ui basic vertical menu" id="contextmenu">
<a class="item search-table global-level">搜索表 </a>
<a class="item add-table global-level">新增表 </a>
<a class="item drop-table table-level">删除表 </a>
<a class="item update-relation table-level">更新关系 </a>
<a class="item save-position global-level">保存位置 </a>
</div>
<div class="ui action input" id="search"
style="position: fixed; right: 10px; top: 10px; z-index: 1000; display: none">
<select class="ui compact selection dropdown">
<option value="schema">Schema</option>
<option value="table">表名</option>
<option value="column">列名</option>
<option value="description">注释</option>
</select>
<input type="text" placeholder="Search...">
<div class="ui button">搜索</div>
</div>
<div class="ui larger modal table-addition">
<div class="header">新增表</div>
<div class="content">
<select name="schema" class="ui fluid dropdown">
<option value="">Schema</option>
<option value="etl">etl</option>
<option value="stg">stg</option>
<option value="owl">owl</option>
</select>
<div class="ui hidden divider"></div>
<select name="table" multiple="" class="ui fluid dropdown tables">
<option value="">Table</option>
</select>
</div>
<div class="actions">
<div class="ui button cancel">取消</div>
<div class="ui positive right button save-tables">保存</div>
</div>
</div>
<div class="ui larger modal table-relation">
<div class="header">更新表关系</div>
<div class="content">
<div class="ui segment">
<div class="source">
<select name="source-columns" multiple="" class="ui fluid dropdown source-columns">
<option value="">源表字段</option>
<option value="data_time">data_time</option>
<option value="mn_code">device_id</option>
<option value="data_value">data_value</option>
</select>
</div>
<h4 class="ui horizontal divider">Source <i class="arrow right icon"></i> Target</h4>
<div class="target">
<select name="target-table" class="ui fluid dropdown target-table">
<option value="">选择目标表</option>
<option value="chr.history_data">chr.history_data</option>
</select>
<div class="ui hidden divider"></div>
<select name="target-columns" multiple="" class="ui fluid dropdown target-columns">
<option value="">选择目标表字段</option>
<option value="data_time">data_time</option>
<option value="device_id">mn_code</option>
<option value="data_value">data_value</option>
</select>
</div>
</div>
</div>
<div class="actions">
<div class="ui button cancel">取消</div>
<div class="ui positive right button save-relation">保存</div>
</div>
</div>
<script type="module">
import { Designer } from "./js/designer.js";
let designer;
window.onload = function () {
$('.ui.dropdown').dropdown();
designer = new Designer({
container: "container",
contextmenu: "contextmenu"
});
// chr.history_data
let table = designer.createTable("chr.history_data");
let cellContent = [
["data_time", "timestamp(6)", "时间"],
["mn_code", "varchar(100)", "监控点"],
["data_value", "numeric(12,5)", "数据值"]
];
for (let i = 0; i < 3; i++) {
table.addRow(...cellContent[i])
};
// rpt.owl_device_hour
table = designer.createTable("rpt.owl_device_hour", 200, 300);
cellContent = [
["data_time", "timestamp(6)", "时间"],
["device_id", "varchar(100)", "设备ID"],
["data_value", "numeric(12,5)", "时间"]
];
for (let i = 0; i < 3; i++) {
table.addRow(...cellContent[i])
};
designer.drawRelation("rpt.owl_device_hour", [
"data_time", "data_value"
], "chr.history_data", ["data_time", "data_value"], 3)
// rpt.owl_enterprise_hour
table = designer.createTable("rpt.owl_enterprise_hour", 200, 500);
cellContent = [
["data_time", "timestamp(6)", "时间"],
["enterprise_code", "varchar(100)", "企业号"],
["data_value", "numeric(12,5)", "时间"]
];
for (let i = 0; i < 3; i++) {
table.addRow(...cellContent[i])
};
designer.drawRelation("rpt.owl_device_hour", [
"data_time", "data_value"
],"rpt.owl_enterprise_hour", ["data_time", "data_value"], 2);
designer.flush();
$(".drop-table").click(function(){
designer.dropTableByTableName(designer.selectedTableName);
});
$(".search-table").click(function(){
$("#search").show();
});
$("#search .button").click(function(){
let type = $("#search select").val();
let keyword = $("#search input").val();
console.log(keyword, type);
designer.showTableByKeyword(keyword, type);
});
$(".add-table").click(function(){
$(".table-addition").modal('show')
});
$(".update-relation").click(function(){
$('.table-relation').modal('show');
});
$(".save-position").click(function(){
console.log(designer.fetchAllTablesPos());
});
$(".save-relation").click(function(){
designer.drawRelation(
designer.selectedTableName,
$(".source-columns").dropdown("get value"),
$(".target-table").dropdown("get value"),
$(".target-columns").dropdown("get value")
);
console.log(
designer.selectedTableName,
$(".source-columns").dropdown("get value"),
$(".target-table").dropdown("get value"),
$(".target-columns").dropdown("get value")
)
});
console.log(designer.fetchTableRelation("rpt.owl_device_hour"));
console.log(designer.relations);
$(".tables").dropdown({
values: [
{name: "abc", value: "abc"},
{name: "cde", value: "cde"},
]
})
}
</script>
</body>
</html>