cpee-model-management 1.0.17 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/cpee-model-management.gemspec +1 -1
- data/lib/cpee-model-management/implementation.rb +282 -22
- data/lib/cpee-model-management/implementation.xml +133 -0
- data/lib/cpee-model-management/moma.xml +19 -98
- data/server/moma.conf +1 -0
- data/tools/cpee-moma +60 -1
- data/ui/css/design.css +5 -0
- data/ui/css/stats.css +55 -0
- data/ui/css/stats_standalone.css +7 -0
- data/ui/index.html +68 -10
- data/ui/instances.html +89 -0
- data/ui/instances_view.html +89 -0
- data/ui/js/design.js +5 -5
- data/ui/js/stats.js +227 -0
- data/ui/resources.html +96 -0
- metadata +10 -4
- data/ui/design.js +0 -239
data/ui/js/stats.js
ADDED
@@ -0,0 +1,227 @@
|
|
1
|
+
var value_count = 100
|
2
|
+
|
3
|
+
function resource_update(ename) {
|
4
|
+
var iname = ename.replace(/[^a-z0-9A-Z]/g,'-').replace(/-$/,'')
|
5
|
+
$.get('server/dash/stats/',{ engine: ename },function(data){
|
6
|
+
$('#resource_utilization_text_' + iname + ' .total_created').text(data.total_created)
|
7
|
+
$('#resource_utilization_text_' + iname + ' .total_finished').text(data.total_finished)
|
8
|
+
$('#resource_utilization_text_' + iname + ' .total_abandoned').text(data.total_abandoned)
|
9
|
+
$('#resource_utilization_text_' + iname + ' .current_ready').text(data.ready)
|
10
|
+
$('#resource_utilization_text_' + iname + ' .current_running').text(data.running)
|
11
|
+
$('#resource_utilization_text_' + iname + ' .current_stopped').text(data.stopped)
|
12
|
+
});
|
13
|
+
}
|
14
|
+
|
15
|
+
function resource_add(ename) {
|
16
|
+
let inode = document.importNode($("#stats_engine")[0].content,true);
|
17
|
+
var iname = ename.replace(/[^a-z0-9A-Z]/g,'-').replace(/-$/,'')
|
18
|
+
$('.stats_title',inode).text($('.stats_title',inode).text() + ename)
|
19
|
+
$('.stats_plot',inode).attr('id','resource_utilization_plot_'+iname)
|
20
|
+
$('.stats_text',inode).attr('id','resource_utilization_text_'+iname)
|
21
|
+
|
22
|
+
$('#resources').append(inode)
|
23
|
+
|
24
|
+
resource_update(ename);
|
25
|
+
|
26
|
+
var trace1 = {
|
27
|
+
y: Array(value_count).fill(0),
|
28
|
+
type: 'scatter',
|
29
|
+
name: '% CPU'
|
30
|
+
};
|
31
|
+
|
32
|
+
var trace2 = {
|
33
|
+
y: Array(value_count).fill(0),
|
34
|
+
type: 'scatter',
|
35
|
+
name: '% Mem Used'
|
36
|
+
};
|
37
|
+
|
38
|
+
var layout = {
|
39
|
+
margin: {t:0,r:0,b:0,l:20},
|
40
|
+
height: 200,
|
41
|
+
width: 700,
|
42
|
+
yaxis: {
|
43
|
+
range: [-5, 105]
|
44
|
+
},
|
45
|
+
xaxis: {
|
46
|
+
showticklabels: false,
|
47
|
+
fixedrange: true
|
48
|
+
}
|
49
|
+
};
|
50
|
+
|
51
|
+
var data = [trace1, trace2];
|
52
|
+
|
53
|
+
Plotly.newPlot('resource_utilization_plot_' + iname, data, layout, {displayModeBar: false});
|
54
|
+
}
|
55
|
+
|
56
|
+
function instance_change(d) {
|
57
|
+
const ename = d.engine
|
58
|
+
const iname = d.engine.replace(/[^a-z0-9A-Z]/g,'-').replace(/-$/,'')
|
59
|
+
|
60
|
+
if (d.state == "ready") {
|
61
|
+
if ($('[data-id=' + d.uuid + ']').length > 0) {
|
62
|
+
if ($('[data-id=' + d.uuid + ']').attr('data-parent') != parent) {
|
63
|
+
$('[data-id=' + d.uuid + ']').remove()
|
64
|
+
instance_add(iname,d.uuid,d.url,d.name,d.state,d.author,0,0,d.parent)
|
65
|
+
} else {
|
66
|
+
instance_upd(d.uuid,d.name,d.state,d.author,0,0,d.parent)
|
67
|
+
}
|
68
|
+
} else {
|
69
|
+
instance_add(iname,d.uuid,d.url,d.name,d.state,d.author,0,0,d.parent)
|
70
|
+
}
|
71
|
+
} else if (d.state == 'abandoned' || d.state == 'finished') {
|
72
|
+
if ($('tr.sub[data-id=' + d.uuid + '] > td > table > tr').length > 0) {
|
73
|
+
$('tr.text[data-id=' + d.uuid + ']').replaceWith($('tr.sub[data-id=' + d.uuid + '] > td > table > tr'))
|
74
|
+
}
|
75
|
+
$('[data-id=' + d.uuid + ']').remove()
|
76
|
+
instances_striping(iname)
|
77
|
+
} else {
|
78
|
+
if ($('tr.sub[data-id=' + d.uuid + ']').attr('data-parent') != d.parent) {
|
79
|
+
$('[data-id=' + d.uuid + ']').remove()
|
80
|
+
instance_add(iname,d.uuid,d.url,d.name,d.state,d.author,0,0,d.parent)
|
81
|
+
} else {
|
82
|
+
instance_upd(d.uuid,d.name,d.state,d.author,0,0,d.parent)
|
83
|
+
}
|
84
|
+
}
|
85
|
+
}
|
86
|
+
|
87
|
+
function instance_upd(uuid,name,state,author,cpu,mem,parent) {
|
88
|
+
if (name != "") {
|
89
|
+
$('[data-id=' + uuid + '] > .name a').text(name)
|
90
|
+
$('[data-id=' + uuid + '] > .name a').attr('title',name)
|
91
|
+
}
|
92
|
+
$('[data-id=' + uuid + '] > .state span.value').text(state)
|
93
|
+
$('[data-id=' + uuid + '] > .state').attr('data-state',state)
|
94
|
+
if (author != "") {
|
95
|
+
$('[data-id=' + uuid + '] > .author').text(author)
|
96
|
+
}
|
97
|
+
instance_res(uuid,cpu,mem)
|
98
|
+
}
|
99
|
+
function instance_res(uuid,cpu,mem) {
|
100
|
+
$('[data-id=' + uuid + '] > .cpu').text($.sprintf('%05.2f',cpu))
|
101
|
+
$('[data-id=' + uuid + '] > .mem').text($.sprintf('%05.2f',mem))
|
102
|
+
}
|
103
|
+
function instance_add(iname,uuid,url,name,state,author,cpu,mem,parent) {
|
104
|
+
let inode = document.importNode($("#stats_instance")[0].content,true);
|
105
|
+
$('.sub',inode).attr('id',uuid)
|
106
|
+
$('.sub',inode).attr('data-id',uuid)
|
107
|
+
$('.sub',inode).attr('data-parent',parent)
|
108
|
+
$('.text',inode).attr('data-id',uuid)
|
109
|
+
$('.text',inode).attr('data-url',url)
|
110
|
+
$('.name a',inode).attr('href','server/dash/show?url=' + url)
|
111
|
+
$('.num span',inode).text(url.split(/[\\/]/).pop())
|
112
|
+
if (name != "") {
|
113
|
+
$('.name a',inode).text(name)
|
114
|
+
$('.name a',inode).attr('title',name)
|
115
|
+
}
|
116
|
+
$('.state span.value',inode).text(state)
|
117
|
+
$('.state',inode).attr('data-state',state)
|
118
|
+
if (author != "") {
|
119
|
+
$('.author',inode).text(author)
|
120
|
+
}
|
121
|
+
$('.cpu',inode).text($.sprintf('%05.2f',cpu))
|
122
|
+
$('.mem',inode).text($.sprintf('%05.2f',mem))
|
123
|
+
if (parent == "") {
|
124
|
+
$('#instances_' + iname).append(inode)
|
125
|
+
} else {
|
126
|
+
$('#' + parent + ' > td > table').append(inode)
|
127
|
+
}
|
128
|
+
instances_striping(iname)
|
129
|
+
}
|
130
|
+
|
131
|
+
function instances_striping(iname) {
|
132
|
+
let even = true
|
133
|
+
$('#instances_' + iname + ' tr.text').removeClass('even')
|
134
|
+
$('#instances_' + iname + ' tr.text').each((i,e)=>{
|
135
|
+
if (even) {
|
136
|
+
$(e).addClass('even')
|
137
|
+
}
|
138
|
+
even = (even == true ? false : true)
|
139
|
+
})
|
140
|
+
}
|
141
|
+
|
142
|
+
function timer(ms) { return new Promise(res => setTimeout(res, ms)); }
|
143
|
+
|
144
|
+
function instances_init(ename) {
|
145
|
+
const iname = ename.replace(/[^a-z0-9A-Z]/g,'-').replace(/-$/,'')
|
146
|
+
let inode = document.importNode($("#stats_instances")[0].content,true);
|
147
|
+
$('.stats_title',inode).text($('.stats_title',inode).text() + ename)
|
148
|
+
$('table',inode).attr('id','instances_'+iname)
|
149
|
+
$('#instances').append(inode)
|
150
|
+
$.ajax({
|
151
|
+
type: "GET",
|
152
|
+
url: 'server/dash/instances',
|
153
|
+
data: { engine: ename },
|
154
|
+
success: (result) => {
|
155
|
+
$('instance',result).each(async (i,ele)=>{
|
156
|
+
const e = $(ele);
|
157
|
+
setTimeout(()=>{instance_add(iname,e.attr('uuid'),e.attr('url'),e.attr('name'),e.attr('state'),e.attr('author'),e.attr('cpu'),e.attr('mem'),e.attr('parent'))},0)
|
158
|
+
})
|
159
|
+
}
|
160
|
+
})
|
161
|
+
}
|
162
|
+
|
163
|
+
function resource_paint(iname,data,count) {
|
164
|
+
count[iname]++
|
165
|
+
Plotly.extendTraces('resource_utilization_plot_' + iname, {y: [[data.cpu_usage], [(data.mem_total-data.mem_available)/data.mem_total * 100]]}, [0,1])
|
166
|
+
Plotly.relayout('resource_utilization_plot_' + iname, {
|
167
|
+
xaxis: {
|
168
|
+
range: [count[iname]-value_count,count[iname]],
|
169
|
+
showticklabels: false,
|
170
|
+
fixedrange: true
|
171
|
+
}
|
172
|
+
});
|
173
|
+
}
|
174
|
+
|
175
|
+
function stats_init() {
|
176
|
+
let es = new EventSource('server/dash/events/');
|
177
|
+
let count = {};
|
178
|
+
es.onopen = function() {
|
179
|
+
console.log('stats open');
|
180
|
+
};
|
181
|
+
es.onmessage = function(e) {
|
182
|
+
let data = JSON.parse(e.data)
|
183
|
+
const iname = data.engine.replace(/[^a-z0-9A-Z]/g,'-').replace(/-$/,'')
|
184
|
+
if ($('#instances').length > 0) {
|
185
|
+
if ($('#instances_' + iname).length == 0) {
|
186
|
+
instances_init(data.engine);
|
187
|
+
}
|
188
|
+
}
|
189
|
+
if (data.topic == "node" && data.event == "resource_utilization") {
|
190
|
+
if ($('#resources').length > 0) {
|
191
|
+
if ($('#resource_utilization_plot_' + iname).length == 0) {
|
192
|
+
resource_add(data.engine);
|
193
|
+
count[iname] = value_count;
|
194
|
+
}
|
195
|
+
resource_paint(iname,data,count)
|
196
|
+
}
|
197
|
+
} else if (data.topic == "state" && data.event == "change") {
|
198
|
+
if ($('#resources').length > 0) {
|
199
|
+
resource_update(data.engine)
|
200
|
+
}
|
201
|
+
if ($('#instances').length > 0) {
|
202
|
+
instance_change(data)
|
203
|
+
}
|
204
|
+
} else if (data.topic == "status" && data.event == "resource_utilization") {
|
205
|
+
if ($('#instances').length > 0) {
|
206
|
+
instance_res(data.uuid,data.cpu,data.mem)
|
207
|
+
}
|
208
|
+
} else {
|
209
|
+
console.log(data);
|
210
|
+
}
|
211
|
+
};
|
212
|
+
es.onerror = function() {
|
213
|
+
console.log('stats error');
|
214
|
+
}
|
215
|
+
}
|
216
|
+
|
217
|
+
$(document).ready(function() {
|
218
|
+
stats_init();
|
219
|
+
$('#instances').on('click','.abandon',function(e){
|
220
|
+
const par = $(e.target).parents('[data-url]').first()
|
221
|
+
$.ajax({
|
222
|
+
type: "PUT",
|
223
|
+
url: 'server/dash/abandon',
|
224
|
+
data: { url: par.attr('data-url') }
|
225
|
+
})
|
226
|
+
})
|
227
|
+
});
|
data/ui/resources.html
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
<!--
|
2
|
+
This file is part of CPEE-MODEL-MANAGEMENT.
|
3
|
+
|
4
|
+
CPEE-MODEL-MANAGEMENT is free software: you can redistribute it and/or
|
5
|
+
modify it under the terms of the GNU General Public License as published by
|
6
|
+
the Free Software Foundation, either version 3 of the License, or (at your
|
7
|
+
option) any later version.
|
8
|
+
|
9
|
+
CPEE-MODEL-MANAGEMENT is distributed in the hope that it will be useful, but
|
10
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
11
|
+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
12
|
+
more details.
|
13
|
+
|
14
|
+
You should have received a copy of the GNU General Public License along with
|
15
|
+
CPEE-MODEL-MANAGEMENT (file LICENSE in the main directory). If not, see
|
16
|
+
<http://www.gnu.org/licenses/>.
|
17
|
+
-->
|
18
|
+
|
19
|
+
<!DOCTYPE html>
|
20
|
+
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
21
|
+
<head>
|
22
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
23
|
+
<title>Resources</title>
|
24
|
+
|
25
|
+
<!-- libs, do not modify. When local than load local libs. -->
|
26
|
+
<script type="text/javascript" src="/js_libs/jquery.min.js"></script>
|
27
|
+
<script type="text/javascript" src="/js_libs/jquery.browser.js"></script>
|
28
|
+
<script type="text/javascript" src="/js_libs/jquery.svg.min.js"></script>
|
29
|
+
<script type="text/javascript" src="/js_libs/jquery.svgdom.min.js"></script>
|
30
|
+
<script type="text/javascript" src="/js_libs/vkbeautify.js"></script>
|
31
|
+
<script type="text/javascript" src="/js_libs/util.js"></script>
|
32
|
+
<script type="text/javascript" src="/js_libs/printf.js"></script>
|
33
|
+
<script type="text/javascript" src="/js_libs/strftime.min.js"></script>
|
34
|
+
<script type="text/javascript" src="/js_libs/parsequery.js"></script>
|
35
|
+
<script type="text/javascript" src="/js_libs/underscore.min.js"></script>
|
36
|
+
<script type="text/javascript" src="/js_libs/jquery.caret.min.js"></script>
|
37
|
+
<script type="text/javascript" src="/js_libs/jquery.cookie.js"></script>
|
38
|
+
<script type="text/javascript" src="/js_libs/plotly.min.js"></script>
|
39
|
+
|
40
|
+
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.qrcode/1.0/jquery.qrcode.min.js"></script>
|
41
|
+
|
42
|
+
<script type="text/javascript" src="/js_libs/relaxngui.js"></script>
|
43
|
+
|
44
|
+
<script type="text/javascript" src="/js_libs/uidash.js"></script>
|
45
|
+
<script type="text/javascript" src="/js_libs/custommenu.js"></script>
|
46
|
+
|
47
|
+
<link rel="stylesheet" href="/js_libs/custommenu.css" type="text/css"/>
|
48
|
+
<link rel="stylesheet" href="/js_libs/uidash.css" type="text/css"/>
|
49
|
+
|
50
|
+
<link rel="stylesheet" href="/global_ui/ui.css" type="text/css"/>
|
51
|
+
|
52
|
+
<link rel="stylesheet" href="/js_libs/relaxngui.css" type="text/css"/>
|
53
|
+
|
54
|
+
<!-- custom stuff, play arround -->
|
55
|
+
<link rel="stylesheet" href="css/stats.css" type="text/css"/>
|
56
|
+
<link rel="stylesheet" href="css/stats_standalone.css" type="text/css"/>
|
57
|
+
<script type="text/javascript" src="js/stats.js"></script>
|
58
|
+
<style>
|
59
|
+
[is="x-ui-"] {
|
60
|
+
overflow: scroll;
|
61
|
+
}
|
62
|
+
</style>
|
63
|
+
</head>
|
64
|
+
<body is="x-ui-">
|
65
|
+
<p>
|
66
|
+
Show statistics about instances per server, and metrics about the health of the environment.
|
67
|
+
</p>
|
68
|
+
<template id="stats_engine">
|
69
|
+
<h1 class="stats_title">Engine: </h1>
|
70
|
+
<div class="stats_plot"></div>
|
71
|
+
<div class="stats_text">
|
72
|
+
<table>
|
73
|
+
<tbody>
|
74
|
+
<tr>
|
75
|
+
<td>Total Instances <strong>Created</strong> / <strong>Finished</strong> / <strong>Abandoned</strong>:</td>
|
76
|
+
<td class='total_created'></td>
|
77
|
+
<td>/</td>
|
78
|
+
<td class='total_finished'></td>
|
79
|
+
<td>/</td>
|
80
|
+
<td class='total_abandoned'></td>
|
81
|
+
</tr>
|
82
|
+
<tr>
|
83
|
+
<td>Instances Currently <strong>Ready</strong> / <strong>Running</strong> / <strong>Stopped</strong>:</td>
|
84
|
+
<td class='current_ready'></td>
|
85
|
+
<td>/</td>
|
86
|
+
<td class='current_running'></td>
|
87
|
+
<td>/</td>
|
88
|
+
<td class='current_stopped'></td>
|
89
|
+
</tr>
|
90
|
+
</tbody>
|
91
|
+
</table>
|
92
|
+
</div>
|
93
|
+
</template>
|
94
|
+
<div id='resources'></div>
|
95
|
+
</body>
|
96
|
+
</html>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cpee-model-management
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juergen eTM Mangler
|
8
8
|
autorequire:
|
9
9
|
bindir: tools
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: riddl
|
@@ -73,6 +73,7 @@ files:
|
|
73
73
|
- cpee-model-management.gemspec
|
74
74
|
- lib/cpee-model-management/commit.rb
|
75
75
|
- lib/cpee-model-management/implementation.rb
|
76
|
+
- lib/cpee-model-management/implementation.xml
|
76
77
|
- lib/cpee-model-management/moma.xml
|
77
78
|
- lib/cpee-model-management/stages
|
78
79
|
- server/model.xml
|
@@ -81,9 +82,14 @@ files:
|
|
81
82
|
- server/testset.xml
|
82
83
|
- tools/cpee-moma
|
83
84
|
- ui/css/design.css
|
84
|
-
- ui/
|
85
|
+
- ui/css/stats.css
|
86
|
+
- ui/css/stats_standalone.css
|
85
87
|
- ui/index.html
|
88
|
+
- ui/instances.html
|
89
|
+
- ui/instances_view.html
|
86
90
|
- ui/js/design.js
|
91
|
+
- ui/js/stats.js
|
92
|
+
- ui/resources.html
|
87
93
|
homepage: http://cpee.org/
|
88
94
|
licenses:
|
89
95
|
- LGPL-3.0
|
@@ -103,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
109
|
- !ruby/object:Gem::Version
|
104
110
|
version: '0'
|
105
111
|
requirements: []
|
106
|
-
rubygems_version: 3.
|
112
|
+
rubygems_version: 3.3.7
|
107
113
|
signing_key:
|
108
114
|
specification_version: 4
|
109
115
|
summary: "(Lifecycle) manage your process models in a directory or git repo."
|
data/ui/design.js
DELETED
@@ -1,239 +0,0 @@
|
|
1
|
-
var gstage;
|
2
|
-
var gdir;
|
3
|
-
|
4
|
-
function move_it(name,todir) {
|
5
|
-
$.ajax({
|
6
|
-
type: "PUT",
|
7
|
-
url: "server/" + gdir + name,
|
8
|
-
data: { dir: todir }
|
9
|
-
});
|
10
|
-
}
|
11
|
-
function shift_it(name,to) {
|
12
|
-
$.ajax({
|
13
|
-
type: "PUT",
|
14
|
-
url: "server/" + gdir + name,
|
15
|
-
data: { stage: to }
|
16
|
-
});
|
17
|
-
}
|
18
|
-
function rename_it(name) {
|
19
|
-
var newname;
|
20
|
-
if (newname = prompt('New name please!',name.replace(/\.xml$/,'').replace(/\.dir$/,''))) {
|
21
|
-
$.ajax({
|
22
|
-
type: "PUT",
|
23
|
-
url: "server/" + gdir + name,
|
24
|
-
data: { new: newname }
|
25
|
-
});
|
26
|
-
}
|
27
|
-
}
|
28
|
-
function duplicate_it(name) {
|
29
|
-
var newname;
|
30
|
-
if (newname = prompt('New name please!',name.replace(/\.xml$/,'').replace(/\.dir$/,''))) {
|
31
|
-
$.ajax({
|
32
|
-
type: "POST",
|
33
|
-
url: "server/" + gdir,
|
34
|
-
data: { new: newname, old: name }
|
35
|
-
});
|
36
|
-
}
|
37
|
-
}
|
38
|
-
function delete_it(name) {
|
39
|
-
if (confirm('Are you really, really, REALLY sure!')) {
|
40
|
-
$.ajax({
|
41
|
-
type: "DELETE",
|
42
|
-
url: "server/" + gdir + name
|
43
|
-
});
|
44
|
-
}
|
45
|
-
}
|
46
|
-
|
47
|
-
function es_init(gdir,gstage) {
|
48
|
-
var es = new EventSource('server/');
|
49
|
-
es.onopen = function() {
|
50
|
-
console.log('es open');
|
51
|
-
};
|
52
|
-
es.onmessage = function(e) {
|
53
|
-
paint(gdir,gstage);
|
54
|
-
};
|
55
|
-
es.onerror = function() {
|
56
|
-
console.log('es error');
|
57
|
-
// es_init();
|
58
|
-
};
|
59
|
-
}
|
60
|
-
|
61
|
-
function paint(gdir,gstage) {
|
62
|
-
$('#models tbody').empty();
|
63
|
-
if (gdir && gdir != '') {
|
64
|
-
var clone = document.importNode(document.querySelector('#up').content,true);
|
65
|
-
$('[data-class=name] a',clone).text('..');
|
66
|
-
$('[data-class=name] a',clone).attr('href',window.location.pathname + '?stage=' + gstage + '&dir=');
|
67
|
-
$('#models tbody').append(clone);
|
68
|
-
}
|
69
|
-
$.ajax({
|
70
|
-
type: "GET",
|
71
|
-
url: "server/" + gdir,
|
72
|
-
data: { stage: gstage },
|
73
|
-
success: function(res) {
|
74
|
-
$(res).each(function(k,data) {
|
75
|
-
if (data.type == 'dir') {
|
76
|
-
var clone = document.importNode(document.querySelector('#folder').content,true);
|
77
|
-
$('[data-class=name] a',clone).text(data['name'].replace(/\.dir$/,''));
|
78
|
-
$('[data-class=name]',clone).attr('data-full-name',data['name']);
|
79
|
-
$('[data-class=name] a',clone).attr('href',window.location.pathname + '?stage=' + gstage + '&dir=' + data['name']);
|
80
|
-
} else {
|
81
|
-
var clone = document.importNode(document.querySelector('#model').content,true);
|
82
|
-
$('[data-class=name] a',clone).text(data['name']);
|
83
|
-
$('[data-class=name]',clone).attr('data-full-name',data['name']);
|
84
|
-
$('[data-class=name] a',clone).attr('href','server/' + gdir + data['name'] + '/open?stage=' + gstage);
|
85
|
-
$('[data-class=force] a',clone).attr('href','server/' + gdir + data['name'] + '/open-new?stage=' + gstage);
|
86
|
-
$('[data-class=raw] a',clone).attr('href','server/' + gdir + data['name']);
|
87
|
-
|
88
|
-
$('[data-class=guarded] abbr',clone).attr('title',data['guarded'] || '');
|
89
|
-
$('[data-class=guarded] abbr',clone).text((data['guarded'] || '').match(/none/i) ? '' : (data['guarded'] || '').charAt(0).toUpperCase());
|
90
|
-
$('[data-class=resource]',clone).text(data['guarded_id'] || '');
|
91
|
-
}
|
92
|
-
$('[data-class=author]',clone).text(data['author']);
|
93
|
-
$('[data-class=date]',clone).text(new Date(data['date']).strftime('%Y-%m-%d, %H:%M:%S'));
|
94
|
-
$('#models tbody').append(clone);
|
95
|
-
});
|
96
|
-
}
|
97
|
-
});
|
98
|
-
}
|
99
|
-
|
100
|
-
function change_it(gdir,gstage) {
|
101
|
-
window.location.href = window.location.pathname + '?stage=' + gstage + '&dir=' + gdir;
|
102
|
-
}
|
103
|
-
|
104
|
-
$(document).ready(function() {
|
105
|
-
const queryString = window.location.search;
|
106
|
-
const urlParams = new URLSearchParams(queryString);
|
107
|
-
|
108
|
-
gstage = urlParams.get('stage') || 'draft';
|
109
|
-
gdir = urlParams.get('dir') ? (urlParams.get('dir') + '/').replace(/\/+/,'/') : '';
|
110
|
-
|
111
|
-
es_init(gdir,gstage);
|
112
|
-
|
113
|
-
var shifts = []
|
114
|
-
$.ajax({
|
115
|
-
type: "GET",
|
116
|
-
url: "server/",
|
117
|
-
data: { stages: 'stages' },
|
118
|
-
success: (r) => {
|
119
|
-
shifts = shifts.concat(r);
|
120
|
-
shifts = shifts.filter(item => item !== gstage);
|
121
|
-
}
|
122
|
-
});
|
123
|
-
|
124
|
-
$('input[name=stage]').val(gstage);
|
125
|
-
$('input[name=dir]').val(gdir);
|
126
|
-
$('ui-behind span').text(gstage);
|
127
|
-
$('ui-behind span').click((e) => {
|
128
|
-
if (shifts.length > 0) {
|
129
|
-
var menu = {};
|
130
|
-
menu['Change to'] = [];
|
131
|
-
shifts.forEach(ele => {
|
132
|
-
menu['Change to'].push(
|
133
|
-
{
|
134
|
-
'label': ele,
|
135
|
-
'function_call': change_it,
|
136
|
-
'text_icon': '➔',
|
137
|
-
'type': undefined,
|
138
|
-
'class': 'capitalized',
|
139
|
-
'params': [gdir,ele]
|
140
|
-
}
|
141
|
-
);
|
142
|
-
});
|
143
|
-
new CustomMenu(e).contextmenu(menu);
|
144
|
-
}
|
145
|
-
});
|
146
|
-
|
147
|
-
var dragged;
|
148
|
-
$('#models').on('drag','td[data-class=model]',false);
|
149
|
-
$('#models').on('dragstart','td[data-class=model]',(e) => {
|
150
|
-
dragged = $(e.currentTarget).parents('tr').find('td[data-class=name]').text();
|
151
|
-
});
|
152
|
-
$('#models').on('dragover','td[data-class=folder]',false);
|
153
|
-
$('#models').on('drop','td[data-class=folder]',(e) => {
|
154
|
-
e.preventDefault();
|
155
|
-
e.stopPropagation();
|
156
|
-
if (dragged) {
|
157
|
-
var todir = $(e.currentTarget).parents('tr').find('td[data-class=name]').text();
|
158
|
-
todir = todir.replace(/\./g,'');
|
159
|
-
if (todir != '') {
|
160
|
-
todir += '.dir';
|
161
|
-
}
|
162
|
-
move_it(dragged,todir);
|
163
|
-
dragged = undefined;
|
164
|
-
}
|
165
|
-
});
|
166
|
-
$('#models').on('click','td[data-class=ops]',(e) => {
|
167
|
-
var menu = {};
|
168
|
-
var name = $(e.currentTarget).parents('tr').find('td[data-class=name]').attr('data-full-name');
|
169
|
-
menu['Operations'] = [
|
170
|
-
{
|
171
|
-
'label': 'Delete',
|
172
|
-
'function_call': delete_it,
|
173
|
-
'text_icon': '❌',
|
174
|
-
'type': undefined,
|
175
|
-
'params': [name]
|
176
|
-
},
|
177
|
-
{
|
178
|
-
'label': 'Rename',
|
179
|
-
'function_call': rename_it,
|
180
|
-
'type': undefined,
|
181
|
-
'text_icon': '📛',
|
182
|
-
'params': [name]
|
183
|
-
}
|
184
|
-
];
|
185
|
-
if (name.match(/\.xml$/)) {
|
186
|
-
menu['Operations'].unshift(
|
187
|
-
{
|
188
|
-
'label': 'Duplicate',
|
189
|
-
'function_call': duplicate_it,
|
190
|
-
'text_icon': '➕',
|
191
|
-
'type': undefined,
|
192
|
-
'params': [name]
|
193
|
-
}
|
194
|
-
);
|
195
|
-
}
|
196
|
-
if (shifts.length > 0) {
|
197
|
-
menu['Shifting'] = [];
|
198
|
-
shifts.forEach(ele => {
|
199
|
-
menu['Shifting'].push(
|
200
|
-
{
|
201
|
-
'label': 'Shift to ' + ele,
|
202
|
-
'function_call': shift_it,
|
203
|
-
'text_icon': '➔',
|
204
|
-
'type': undefined,
|
205
|
-
'params': [name,ele]
|
206
|
-
}
|
207
|
-
);
|
208
|
-
});
|
209
|
-
}
|
210
|
-
new CustomMenu(e).contextmenu(menu);
|
211
|
-
});
|
212
|
-
|
213
|
-
history.pushState({}, document.title, window.location.pathname + '?stage=' + gstage + '&dir=' + gdir);
|
214
|
-
paint(gdir,gstage);
|
215
|
-
|
216
|
-
$('#newmod').on('submit',(e) => {
|
217
|
-
$.ajax({
|
218
|
-
type: "POST",
|
219
|
-
url: "server/" + gdir,
|
220
|
-
data: { stage: gstage, new: $("#newmod input[name=new]").val() },
|
221
|
-
success: (r) => {
|
222
|
-
uidash_activate_tab($('ui-tab').first());
|
223
|
-
}
|
224
|
-
});
|
225
|
-
return false;
|
226
|
-
});
|
227
|
-
|
228
|
-
$('#newdir').on('submit',(e) => {
|
229
|
-
$.ajax({
|
230
|
-
type: "POST",
|
231
|
-
url: "server/",
|
232
|
-
data: { dir: $("#newdir input[name=newdir]").val() },
|
233
|
-
success: (r) => {
|
234
|
-
uidash_activate_tab($('ui-tab').first());
|
235
|
-
}
|
236
|
-
});
|
237
|
-
return false;
|
238
|
-
});
|
239
|
-
});
|