cpee-model-management 1.1.4 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/ui/js/moma.js ADDED
@@ -0,0 +1,379 @@
1
+ let gstage;
2
+ var gdir;
3
+ var selections = [];
4
+ var updating = false;
5
+ var updating_counter = 0;
6
+ var fingerprint = "";
7
+
8
+ function copy_all() {
9
+ selections.forEach((name) => {
10
+ $.ajax({
11
+ type: "PUT",
12
+ url: "server/" + name,
13
+ data: { dupdir: gdir }
14
+ });
15
+ });
16
+ unmark_all();
17
+ }
18
+ function move_all() {
19
+ selections.forEach((name) => {
20
+ $.ajax({
21
+ type: "PUT",
22
+ url: "server/" + name,
23
+ data: { movedir: gdir }
24
+ });
25
+ });
26
+ unmark_all();
27
+ }
28
+ function delete_all() {
29
+ if (confirm('Are you really, really, REALLY sure!')) {
30
+ selections.forEach((name) => {
31
+ $.ajax({
32
+ type: "DELETE",
33
+ url: "server/" + name
34
+ });
35
+ });
36
+ unmark_all();
37
+ }
38
+ }
39
+ function unmark_all() {
40
+ selections = [];
41
+ $('[data-class=special]').attr('class','invisible');
42
+ $('td.selected').removeClass('selected');
43
+ }
44
+ function shift_all(to) {
45
+ selections.forEach((name) => {
46
+ $.ajax({
47
+ type: "PUT",
48
+ url: "server/" + name,
49
+ data: { stage: to }
50
+ });
51
+ });
52
+ unmark_all();
53
+ }
54
+
55
+ function move_it(name,todir) {
56
+ $.ajax({
57
+ type: "PUT",
58
+ url: "server/" + gdir + name,
59
+ data: { movedir: todir }
60
+ });
61
+ }
62
+ function shift_it(name,to) {
63
+ $.ajax({
64
+ type: "PUT",
65
+ url: "server/" + gdir + name,
66
+ data: { stage: to }
67
+ });
68
+ }
69
+ function rename_it(name) {
70
+ var newname;
71
+ if (newname = prompt('New name please!',name.replace(/\.xml$/,'').replace(/\.dir$/,''))) {
72
+ $.ajax({
73
+ type: "PUT",
74
+ url: "server/" + gdir + name,
75
+ data: { new: newname }
76
+ });
77
+ }
78
+ }
79
+ function duplicate_it(name) {
80
+ var newname;
81
+ if (newname = prompt('New name please!',name.replace(/\.xml$/,'').replace(/\.dir$/,''))) {
82
+ $.ajax({
83
+ type: "PUT",
84
+ url: "server/" + gdir + name,
85
+ data: { dupdir: gdir }
86
+ });
87
+ }
88
+ }
89
+ function delete_it(name) {
90
+ if (confirm('Are you really, really, REALLY sure!')) {
91
+ $.ajax({
92
+ type: "DELETE",
93
+ url: "server/" + gdir + name
94
+ });
95
+ }
96
+ }
97
+
98
+ function moma_init() {
99
+ var es = new EventSource('server/management/');
100
+ es.onopen = function() {
101
+ console.log('design open');
102
+ };
103
+ es.onmessage = function(e) {
104
+ paint(gdir,gstage);
105
+ };
106
+ es.onerror = function() {
107
+ console.log('design error');
108
+ setTimeout(function(){ if (es.readyState == 2) { moma_init() } }, 5000);
109
+ };
110
+ }
111
+
112
+ function possibly_paint() {
113
+ if (updating_counter > 0 && updating != true) {
114
+ updating_counter = 0;
115
+ paint(gdir,gstage);
116
+ }
117
+ }
118
+
119
+ function paint(pdir,gstage,statesave=true) {
120
+ if (updating == true) { updating_counter += 1; return };
121
+ updating = true;
122
+ gdir = (pdir + '/').replaceAll(/\/+/g,'/').replace(/^\/*/,'');
123
+
124
+ $('div.breadcrumb .added').remove();
125
+
126
+ document.title = $('html head title').attr('data-orig') + (gdir == '' ? '' : ' - ' + gdir.replace(/\.dir|\.xml/g,''));
127
+ if (statesave) {
128
+ history.pushState({gstage: gstage, gdir: gdir}, '', window.location.pathname + '?stage=' + gstage + '&dir=' + gdir);
129
+ }
130
+ $('div.breadcrumb span.crumb').attr('onclick','paint("","' + gstage + '")');
131
+
132
+ let adddir = '';
133
+ let node;
134
+ gdir.split('/').filter((ele) => ele != '').forEach((ele,i) => {
135
+ adddir += ele + '/';
136
+ node = $('div.breadcrumb').append('<span class="separator added">/</span><span class="crumb added" onclick="paint(\'' + adddir + '\',\'' + gstage + '\')">' + ele.replace('.dir','') + '</span>');
137
+ });
138
+
139
+ $.ajax({
140
+ type: "GET",
141
+ url: "server/" + gdir,
142
+ data: { stage: gstage },
143
+ success: function(res,status,request) {
144
+ let fp = request.getResponseHeader('cpee-moma-fingerprint');
145
+ if (fp != fingerprint) {
146
+ $('#models tbody').empty();
147
+ fingerprint = fp;
148
+ let tempcont = $();
149
+ $(res).each(function(k,data) {
150
+ if (data.type == 'dir') {
151
+ let dp = gdir + data['name'] + '/';
152
+ var clone = document.importNode(document.querySelector('#folder').content,true);
153
+ $('[data-class=folder]',clone).attr('data-path',dp);
154
+ if (selections.includes(dp)) { $('[data-class=folder]',clone).toggleClass('selected'); }
155
+ $('[data-class=name] a',clone).text(data['name'].replace(/\.dir$/,''));
156
+ $('[data-class=name]',clone).attr('data-full-name',data['name']);
157
+ $('[data-class=name] a',clone).attr('href','javascript:paint("' + gdir + '/' + data['name'] + '","' + gstage + '")');
158
+ } else {
159
+ let dp = gdir + data['name'];
160
+ var clone = document.importNode(document.querySelector('#model').content,true);
161
+ $('[data-class=model]',clone).attr('data-path',dp);
162
+ if (selections.includes(dp)) { $('[data-class=model]',clone).toggleClass('selected'); }
163
+ $('[data-class=name] a',clone).text(data['name']);
164
+ $('[data-class=name]',clone).attr('data-full-name',data['name']);
165
+ $('[data-class=name] a',clone).attr('href','server/' + gdir + data['name'] + '/open?stage=' + gstage);
166
+ $('[data-class=force] a',clone).attr('href','server/' + gdir + data['name'] + '/open-new?stage=' + gstage);
167
+ $('[data-class=raw] a',clone).attr('href','server/' + gdir + data['name']);
168
+
169
+ $('[data-class=guarded] abbr',clone).attr('title',data['guarded'] || '');
170
+ $('[data-class=guarded] abbr',clone).text((data['guarded'] || '').match(/none/i) ? '' : (data['guarded'] || '').charAt(0).toUpperCase());
171
+ $('[data-class=resource]',clone).text(data['guarded_id'] || '');
172
+
173
+ if (data['guarded']) {
174
+ $('[data-class=guarded] abbr',clone).attr('title',data['guarded']);
175
+ $('[data-class=guarded] abbr',clone).text(data['guarded'].match(/none/i) ? '' : data['guarded'].charAt(0).toUpperCase());
176
+ $('[data-class=resource]',clone).text(data['guarded_what']);
177
+ }
178
+ }
179
+ $('[data-class=author]',clone).text(data['author']);
180
+ $('[data-class=date]',clone).text(new Date(data['date']).strftime('%Y-%m-%d, %H:%M:%S'));
181
+ tempcont.push(clone);
182
+ });
183
+ $('#models tbody').append(tempcont);
184
+ }
185
+ updating = false;
186
+ }
187
+ });
188
+ }
189
+
190
+ function change_it(gdir,gstage) {
191
+ window.location.href = window.location.pathname + '?stage=' + gstage + '&dir=' + gdir;
192
+ }
193
+
194
+ $(document).ready(function() {
195
+ const queryString = window.location.search;
196
+ const urlParams = new URLSearchParams(queryString);
197
+
198
+ gstage = urlParams.get('stage') || 'draft';
199
+ gdir = urlParams.get('dir') ? (urlParams.get('dir') + '/').replaceAll(/\/+/g,'/') : '';
200
+
201
+ moma_init();
202
+
203
+ var shifts = []
204
+ $.ajax({
205
+ type: "GET",
206
+ url: "server/",
207
+ data: { stages: 'stages' },
208
+ success: (r) => {
209
+ shifts = shifts.concat(r);
210
+ shifts = shifts.filter(item => item !== gstage);
211
+ }
212
+ });
213
+
214
+ window.onpopstate = function(e){
215
+ let d = e.state || { gstage: 'draft', 'gdir': '' };
216
+ paint(d.gdir,d.gstage,false);
217
+ };
218
+
219
+ $('ui-behind span').text(gstage);
220
+ $('ui-behind span').click((e) => {
221
+ if (shifts.length > 0) {
222
+ var menu = {};
223
+ menu['Change to'] = [];
224
+ shifts.forEach(ele => {
225
+ menu['Change to'].push(
226
+ {
227
+ 'label': ele,
228
+ 'function_call': change_it,
229
+ 'text_icon': '➔',
230
+ 'type': undefined,
231
+ 'class': 'capitalized',
232
+ 'params': [gdir,ele]
233
+ }
234
+ );
235
+ });
236
+ new CustomMenu(e).contextmenu(menu);
237
+ }
238
+ });
239
+
240
+ $('#models').on('click','[data-class=model]',(e) => {
241
+ const tar = $(e.currentTarget);
242
+ tar.toggleClass('selected');
243
+ if (tar.hasClass('selected')) {
244
+ selections.push(tar.attr('data-path'));
245
+ } else {
246
+ selections = selections.filter(item => item !== tar.attr('data-path'));
247
+ }
248
+ if (selections.length > 0) {
249
+ $('[data-class=special]').attr('class','');
250
+ } else {
251
+ $('[data-class=special]').attr('class','invisible');
252
+ }
253
+ });
254
+ $('#models').on('click','th[data-class=special]',(e) => {
255
+ var menu = {};
256
+ var name = $(e.currentTarget).parents('tr').find('td[data-class=name]').attr('data-full-name');
257
+ menu['Operations'] = [
258
+ {
259
+ 'label': 'Move all marked entries to the current directory',
260
+ 'function_call': move_all,
261
+ 'text_icon': '⨀',
262
+ 'type': undefined,
263
+ 'params': []
264
+ },
265
+ {
266
+ 'label': 'Copy all marked entries to the current directory',
267
+ 'function_call': copy_all,
268
+ 'text_icon': '⨁',
269
+ 'type': undefined,
270
+ 'params': []
271
+ },
272
+ {
273
+ 'label': 'Delete all marked entries',
274
+ 'function_call': delete_all,
275
+ 'text_icon': '❌',
276
+ 'type': undefined,
277
+ 'params': []
278
+ },
279
+ {
280
+ 'label': 'Unmarked all marked entries',
281
+ 'function_call': unmark_all,
282
+ 'type': undefined,
283
+ 'text_icon': '🟥',
284
+ 'params': []
285
+ }
286
+ ];
287
+ if (shifts.length > 0) {
288
+ menu['Shifting'] = [];
289
+ shifts.forEach(ele => {
290
+ menu['Shifting'].push(
291
+ {
292
+ 'label': 'Shift all marked entries to ' + ele,
293
+ 'function_call': shift_all,
294
+ 'text_icon': '➔',
295
+ 'type': undefined,
296
+ 'params': [ele]
297
+ }
298
+ );
299
+ });
300
+ }
301
+ new CustomMenu(e).contextmenu(menu);
302
+ });
303
+
304
+ $('#models').on('click','td[data-class=ops]',(e) => {
305
+ var menu = {};
306
+ var name = $(e.currentTarget).parents('tr').find('td[data-class=name]').attr('data-full-name');
307
+ var is_model = $(e.currentTarget).parents('tr').find('td[data-class=model]').length > 0 ? true : false;
308
+ menu['Operations'] = [
309
+ {
310
+ 'label': 'Delete',
311
+ 'function_call': delete_it,
312
+ 'text_icon': '❌',
313
+ 'type': undefined,
314
+ 'params': [name]
315
+ },
316
+ {
317
+ 'label': 'Rename',
318
+ 'function_call': rename_it,
319
+ 'type': undefined,
320
+ 'text_icon': '📛',
321
+ 'params': [name]
322
+ }
323
+ ];
324
+ if (name.match(/\.xml$/)) {
325
+ menu['Operations'].unshift(
326
+ {
327
+ 'label': 'Duplicate',
328
+ 'function_call': duplicate_it,
329
+ 'text_icon': '➕',
330
+ 'type': undefined,
331
+ 'params': [name]
332
+ }
333
+ );
334
+ }
335
+ if (shifts.length > 0 && is_model) {
336
+ menu['Shifting'] = [];
337
+ shifts.forEach(ele => {
338
+ menu['Shifting'].push(
339
+ {
340
+ 'label': 'Shift to ' + ele,
341
+ 'function_call': shift_it,
342
+ 'text_icon': '➔',
343
+ 'type': undefined,
344
+ 'params': [name,ele]
345
+ }
346
+ );
347
+ });
348
+ }
349
+ new CustomMenu(e).contextmenu(menu);
350
+ });
351
+
352
+ paint(gdir,gstage);
353
+
354
+ $('#newmod').on('submit',(e) => {
355
+ $.ajax({
356
+ type: "POST",
357
+ url: "server/" + gdir,
358
+ data: { stage: gstage, new: $("#newmod input[name=new]").val() },
359
+ success: (r) => {
360
+ uidash_activate_tab($('ui-tab').first());
361
+ }
362
+ });
363
+ return false;
364
+ });
365
+
366
+ $('#newdir').on('submit',(e) => {
367
+ $.ajax({
368
+ type: "POST",
369
+ url: "server/" + gdir,
370
+ data: { dir: $("#newdir input[name=newdir]").val() },
371
+ success: (r) => {
372
+ uidash_activate_tab($('ui-tab').first());
373
+ }
374
+ });
375
+ return false;
376
+ });
377
+
378
+ setInterval(possibly_paint,1000);
379
+ });
data/ui/js/stats.js CHANGED
@@ -211,6 +211,7 @@ function stats_init() {
211
211
  };
212
212
  es.onerror = function() {
213
213
  console.log('stats error');
214
+ setTimeout(function(){ if (es.readyState == 2) { stats_init() } }, 5000);
214
215
  }
215
216
  }
216
217
 
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.1.4
4
+ version: 1.2.0
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: 2023-03-16 00:00:00.000000000 Z
11
+ date: 2024-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: riddl
@@ -79,16 +79,17 @@ files:
79
79
  - server/model.xml
80
80
  - server/moma
81
81
  - server/moma.conf
82
+ - server/redis.rdb
82
83
  - server/testset.xml
83
84
  - tools/cpee-moma
84
- - ui/css/design.css
85
+ - ui/css/moma.css
85
86
  - ui/css/stats.css
86
87
  - ui/css/stats_standalone.css
87
88
  - ui/favicon.ico
88
89
  - ui/index.html
89
90
  - ui/instances.html
90
91
  - ui/instances_view.html
91
- - ui/js/design.js
92
+ - ui/js/moma.js
92
93
  - ui/js/stats.js
93
94
  - ui/resources.html
94
95
  homepage: http://cpee.org/
@@ -110,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
111
  - !ruby/object:Gem::Version
111
112
  version: '0'
112
113
  requirements: []
113
- rubygems_version: 3.4.6
114
+ rubygems_version: 3.4.10
114
115
  signing_key:
115
116
  specification_version: 4
116
117
  summary: "(Lifecycle) manage your process models in a directory or git repo."
data/ui/css/design.css DELETED
@@ -1,67 +0,0 @@
1
- td {
2
- padding-right: 1em;
3
- }
4
-
5
- td[data-class=model] {
6
- font-size: 1.7em;
7
- }
8
- td[data-class=folder] {
9
- font-size: 1.7em;
10
- }
11
- td[data-class=ops] {
12
- cursor: pointer;
13
- }
14
-
15
- td[draggable] {
16
- cursor: move;
17
- }
18
-
19
- form input {
20
- width: 45em !important;
21
- }
22
-
23
- ui-behind {
24
- text-transform: capitalize;
25
- font-weight: bold;
26
- color: #d0d0d0;
27
- }
28
-
29
- ui-area > *:first-child {
30
- padding-top: 0;
31
- margin-top: 0;
32
- }
33
-
34
- ui-behind span {
35
- cursor: pointer;
36
- }
37
-
38
- [is="x-ui-"] table.ui-table {
39
- border-collapse: collapse;
40
- }
41
- [is="x-ui-"] table.ui-table thead th {
42
- font-weight: bold;
43
- text-align: left;
44
- padding: 0.3em 0.5em;
45
- }
46
- [is="x-ui-"] table.ui-table tbody td {
47
- padding: 0.1em 0.5em;
48
- }
49
- [is="x-ui-"] table.ui-table tbody tr:nth-child(odd) td {
50
- background-color: var(--x-ui-content-light-background);
51
- }
52
- [is="x-ui-"] table.ui-table tbody tr:hover td {
53
- background-color: var(--x-ui-content-hover-background);
54
- }
55
-
56
- [is="x-ui-"] table.ui-table tbody tr:nth-child(odd) td[data-class=ops] {
57
- background-color: #d0d0d0;
58
- }
59
- [is="x-ui-"] table.ui-table tbody tr:hover td[data-class=ops] {
60
- background-color: #99cee6b0;
61
- }
62
-
63
- [is="x-ui-"] ui-rest > ui-content > ui-area { padding: 1em; }
64
-
65
- tr.contextmenuitem .capitalized {
66
- text-transform: capitalize;
67
- }