1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
6
|
|
7
|
|
8
|
|
9
|
|
10
|
|
11
|
|
12
|
|
13
|
|
14
|
|
15
|
|
16
|
|
17
|
|
18
|
|
19
|
|
20
|
|
21
|
|
22
|
|
23
|
|
24
|
Ext.namespace('sitools.admin.converters');
|
25
|
|
26
|
|
27
|
|
28
|
|
29
|
|
30
|
|
31
|
|
32
|
Ext.define('sitools.admin.converters.ConvertersCrud', {
|
33
|
extend : 'Ext.grid.GridPanel',
|
34
|
alias : 'widget.s-converters',
|
35
|
border : false,
|
36
|
height : ADMIN_PANEL_HEIGHT,
|
37
|
id : ID.BOX.CONVERTERS,
|
38
|
pageSize : ADMIN_PANEL_NB_ELEMENTS,
|
39
|
modify : false,
|
40
|
urlGrid : null,
|
41
|
converterChainedId : {},
|
42
|
|
43
|
conflictWarned : false,
|
44
|
forceFit : true,
|
45
|
mixins : {
|
46
|
utils : "sitools.admin.utils.utils"
|
47
|
},
|
48
|
requires : ['sitools.admin.converters.ConvertersProp'],
|
49
|
|
50
|
viewConfig : {
|
51
|
autoFill : true
|
52
|
|
53
|
|
54
|
|
55
|
|
56
|
|
57
|
|
58
|
|
59
|
|
60
|
|
61
|
|
62
|
|
63
|
|
64
|
|
65
|
|
66
|
|
67
|
|
68
|
|
69
|
|
70
|
|
71
|
|
72
|
},
|
73
|
|
74
|
initComponent : function () {
|
75
|
this.urlDatasets = loadUrl.get('APP_URL') + loadUrl.get('APP_DATASETS_URL');
|
76
|
this.converterUrlPart = loadUrl.get('APP_DATASETS_CONVERTERS_URL');
|
77
|
|
78
|
var storeDatasets = Ext.create("Ext.data.JsonStore", {
|
79
|
fields : [ 'id', 'name' ],
|
80
|
proxy : {
|
81
|
type : 'ajax',
|
82
|
url : this.urlDatasets,
|
83
|
limitParam : undefined,
|
84
|
startParam : undefined,
|
85
|
reader : {
|
86
|
type : 'json',
|
87
|
root : "data"
|
88
|
}
|
89
|
},
|
90
|
autoLoad : true,
|
91
|
listeners : {
|
92
|
scope : this,
|
93
|
load : function (store, records) {
|
94
|
if (this.comboDatasets.rendered) {
|
95
|
record = this.comboDatasets.getStore().getAt(0);
|
96
|
this.comboDatasets.setValue(record.get(this.comboDatasets.valueField), true);
|
97
|
this.comboDatasets.fireEvent('select', this.comboDatasets, [record]);
|
98
|
}
|
99
|
}
|
100
|
}
|
101
|
});
|
102
|
|
103
|
this.comboDatasets = Ext.create("Ext.form.ComboBox", {
|
104
|
store : storeDatasets,
|
105
|
displayField : 'name',
|
106
|
valueField : 'id',
|
107
|
typeAhead : true,
|
108
|
queryMode : 'local',
|
109
|
forceSelection : true,
|
110
|
triggerAction : 'all',
|
111
|
emptyText : i18n.get('label.selectDatasets'),
|
112
|
selectOnFocus : true,
|
113
|
listeners : {
|
114
|
scope : this,
|
115
|
select : function (combo, rec, index) {
|
116
|
this.datasetId = rec[0].get("id");
|
117
|
|
118
|
this.getStore().setProxy({
|
119
|
type : 'ajax',
|
120
|
url : this.urlDatasets + "/" + this.datasetId + this.converterUrlPart,
|
121
|
limitParam : undefined,
|
122
|
startParam : undefined,
|
123
|
reader : {
|
124
|
type : 'json',
|
125
|
root : "converterChainedModel.converters",
|
126
|
idProperty : 'id'
|
127
|
}
|
128
|
});
|
129
|
|
130
|
this.getStore().removeAll();
|
131
|
this.getStore().load();
|
132
|
}
|
133
|
}
|
134
|
});
|
135
|
|
136
|
this.store = Ext.create("Ext.data.JsonStore", {
|
137
|
fields : [ {
|
138
|
name : 'id',
|
139
|
type : 'string'
|
140
|
}, {
|
141
|
name : 'name',
|
142
|
type : 'string'
|
143
|
}, {
|
144
|
name : 'description',
|
145
|
type : 'string'
|
146
|
}, {
|
147
|
name : 'className',
|
148
|
type : 'string'
|
149
|
}, {
|
150
|
name : 'descriptionAction',
|
151
|
type : 'string'
|
152
|
}, {
|
153
|
name : 'parameters'
|
154
|
}, {
|
155
|
name : 'classVersion',
|
156
|
type : 'string'
|
157
|
}, {
|
158
|
name : 'classAuthor',
|
159
|
type : 'string'
|
160
|
}, {
|
161
|
name : 'currentClassVersion',
|
162
|
type : 'string'
|
163
|
}, {
|
164
|
name : 'currentClassAuthor',
|
165
|
type : 'string'
|
166
|
}, {
|
167
|
name : 'status',
|
168
|
type : 'string'
|
169
|
}, {
|
170
|
name : 'classOwner',
|
171
|
type : 'string'
|
172
|
}]
|
173
|
});
|
174
|
|
175
|
this.columns = {
|
176
|
|
177
|
defaults : {
|
178
|
sortable : true
|
179
|
|
180
|
},
|
181
|
items : [ {
|
182
|
header : i18n.get('label.name'),
|
183
|
dataIndex : 'name',
|
184
|
width : 150,
|
185
|
sortable : false
|
186
|
}, {
|
187
|
header : i18n.get('label.description'),
|
188
|
dataIndex : 'description',
|
189
|
width : 200,
|
190
|
sortable : false
|
191
|
}, {
|
192
|
header : i18n.get('label.descriptionAction'),
|
193
|
dataIndex : 'descriptionAction',
|
194
|
width : 200,
|
195
|
sortable : false
|
196
|
}, {
|
197
|
header : i18n.get('label.status'),
|
198
|
dataIndex : 'status',
|
199
|
width : 50,
|
200
|
sortable : false,
|
201
|
renderer : function (value, meta, record, index, colIndex, store) {
|
202
|
meta.tdCls += value;
|
203
|
return value;
|
204
|
}
|
205
|
}, {
|
206
|
header : i18n.get('label.className'),
|
207
|
dataIndex : 'className',
|
208
|
width : 150,
|
209
|
sortable : false
|
210
|
}, {
|
211
|
header : i18n.get('label.classVersion'),
|
212
|
dataIndex : 'classVersion',
|
213
|
width : 50,
|
214
|
sortable : false
|
215
|
}, {
|
216
|
header : i18n.get('label.currentClassVersion'),
|
217
|
dataIndex : 'currentClassVersion',
|
218
|
width : 50,
|
219
|
sortable : false
|
220
|
}, {
|
221
|
header : i18n.get('label.classAuthor'),
|
222
|
dataIndex : 'classAuthor',
|
223
|
width : 100,
|
224
|
sortable : false
|
225
|
}, {
|
226
|
header : i18n.get('label.classOwner'),
|
227
|
dataIndex : 'classOwner',
|
228
|
width : 100,
|
229
|
sortable : false
|
230
|
} ]
|
231
|
};
|
232
|
|
233
|
this.tbar = {
|
234
|
xtype : 'sitools.public.widget.grid.GridSorterToolbar',
|
235
|
defaults : {
|
236
|
scope : this
|
237
|
},
|
238
|
items : [ this.comboDatasets, {
|
239
|
text : i18n.get('label.add'),
|
240
|
icon : loadUrl.get("APP_URL") + loadUrl.get('APP_CLIENT_PUBLIC_URL') +'/res/images/icons/toolbar_create.png',
|
241
|
handler : this.onCreate,
|
242
|
xtype : 's-menuButton'
|
243
|
}, {
|
244
|
text : i18n.get('label.modify'),
|
245
|
icon : loadUrl.get("APP_URL") + loadUrl.get('APP_CLIENT_PUBLIC_URL') +'/res/images/icons/toolbar_edit.png',
|
246
|
handler : this.onModify,
|
247
|
xtype : 's-menuButton'
|
248
|
}, {
|
249
|
text : i18n.get('label.delete'),
|
250
|
icon : loadUrl.get("APP_URL") + loadUrl.get('APP_CLIENT_PUBLIC_URL') +'/res/images/icons/toolbar_delete.png',
|
251
|
handler : this.onDelete,
|
252
|
xtype : 's-menuButton'
|
253
|
}, '-', {
|
254
|
text : i18n.get('label.deleteAll'),
|
255
|
icon : loadUrl.get("APP_URL") + loadUrl.get('APP_CLIENT_PUBLIC_URL') +'/res/images/icons/toolbar_delete.png',
|
256
|
handler : this.onDeleteAll,
|
257
|
xtype : 's-menuButton'
|
258
|
}, {
|
259
|
text : i18n.get('label.saveOrder'),
|
260
|
itemId : 'saveOrderBtnId',
|
261
|
icon : loadUrl.get("APP_URL") + loadUrl.get('APP_CLIENT_PUBLIC_URL') +'/res/images/icons/save.png',
|
262
|
handler : this.onSave,
|
263
|
xtype : 's-menuButton'
|
264
|
}, {
|
265
|
text : i18n.get('label.active'),
|
266
|
icon : loadUrl.get("APP_URL") + loadUrl.get('APP_CLIENT_PUBLIC_URL') +'/res/images/icons/toolbar_active.png',
|
267
|
handler : this._onActive,
|
268
|
xtype : 's-menuButton'
|
269
|
}, {
|
270
|
text : i18n.get('label.disactive'),
|
271
|
icon : loadUrl.get("APP_URL") + loadUrl.get('APP_CLIENT_PUBLIC_URL') + '/res/images/icons/toolbar_disactive.png',
|
272
|
handler : this._onDisactive,
|
273
|
xtype : 's-menuButton'
|
274
|
} ],
|
275
|
listeners : {
|
276
|
scope : this,
|
277
|
afterrender : function (toolbar) {
|
278
|
var buttons = toolbar.query('button');
|
279
|
Ext.each(buttons, function (button) {
|
280
|
if (button.alias == 'widget.gridUp' || button.alias == 'widget.gridDown' ||
|
281
|
button.alias == 'widget.gridTop' || button.alias == 'widget.gridBottom') {
|
282
|
|
283
|
button.on('click', function () {
|
284
|
var saveButton = this.down('toolbar button#saveOrderBtnId');
|
285
|
saveButton.addCls('not-save-textfield');
|
286
|
}, this);
|
287
|
}
|
288
|
}, this);
|
289
|
}
|
290
|
}
|
291
|
};
|
292
|
|
293
|
this.listeners = {
|
294
|
scope : this,
|
295
|
itemdblclick : this.onModify
|
296
|
};
|
297
|
|
298
|
this.callParent(arguments);
|
299
|
},
|
300
|
|
301
|
onCreate : function () {
|
302
|
if (Ext.isEmpty(this.comboDatasets.getValue())) {
|
303
|
return;
|
304
|
}
|
305
|
var up = Ext.create("sitools.admin.converters.ConvertersProp", {
|
306
|
action : 'create',
|
307
|
parent : this,
|
308
|
datasetId : this.datasetId,
|
309
|
converterUrlPart : this.converterUrlPart,
|
310
|
urlDatasets : this.urlDatasets
|
311
|
});
|
312
|
up.show(ID.BOX.CONVERTERS);
|
313
|
},
|
314
|
|
315
|
onSave : function () {
|
316
|
if (Ext.isEmpty(this.comboDatasets.getValue())) {
|
317
|
return;
|
318
|
}
|
319
|
|
320
|
var datasetId = this.comboDatasets.getValue(), jsonReturn = {};
|
321
|
|
322
|
jsonReturn.id = datasetId;
|
323
|
jsonReturn.idOrder = [];
|
324
|
|
325
|
for (var i = 0; i < this.store.getCount(); i++) {
|
326
|
var rec = this.store.getAt(i);
|
327
|
jsonReturn.idOrder.push(rec.get("id"));
|
328
|
}
|
329
|
var url = this.urlDatasets + "/" + datasetId + this.converterUrlPart;
|
330
|
Ext.Ajax.request({
|
331
|
url : url,
|
332
|
method : "PUT",
|
333
|
scope : this,
|
334
|
jsonData : jsonReturn,
|
335
|
success : function (ret) {
|
336
|
var data = Ext.decode(ret.responseText);
|
337
|
if (!data.success) {
|
338
|
Ext.Msg.alert(i18n.get('label.warning'), data.message);
|
339
|
return false;
|
340
|
}
|
341
|
|
342
|
popupMessage(i18n.get('label.information'), i18n.get('label.converterSaved'), null, 'x-info');
|
343
|
Ext.Msg.alert(i18n.get("label.information"), i18n.get("label.restartDsNeededConv"));
|
344
|
|
345
|
var saveButton = this.down('toolbar button#saveOrderBtnId');
|
346
|
saveButton.removeCls('not-save-textfield');
|
347
|
this.getStore().reload();
|
348
|
}
|
349
|
});
|
350
|
},
|
351
|
|
352
|
onModify : function () {
|
353
|
if (Ext.isEmpty(this.comboDatasets.getValue())) {
|
354
|
return;
|
355
|
}
|
356
|
var rec = this.getLastSelectedRecord();
|
357
|
var index = this.getStore().indexOf(rec);
|
358
|
if (!rec) {
|
359
|
return popupMessage("", i18n.get('warning.noselection'), loadUrl.get('APP_URL') + loadUrl.get('APP_CLIENT_PUBLIC_URL')+'/res/images/msgBox/16/icon-info.png');;
|
360
|
}
|
361
|
var up = Ext.create("sitools.admin.converters.ConvertersProp", {
|
362
|
action : 'modify',
|
363
|
parent : this,
|
364
|
converter : rec.data,
|
365
|
index : index,
|
366
|
datasetId : this.datasetId,
|
367
|
converterUrlPart : this.converterUrlPart,
|
368
|
urlDatasets : this.urlDatasets,
|
369
|
converterChainedId : this.converterChainedId
|
370
|
});
|
371
|
up.show(ID.BOX.CONVERTERS);
|
372
|
},
|
373
|
|
374
|
onDelete : function () {
|
375
|
var rec = this.getLastSelectedRecord();
|
376
|
if (Ext.isEmpty(rec)) {
|
377
|
return false;
|
378
|
}
|
379
|
Ext.Msg.show({
|
380
|
title : i18n.get('label.delete'),
|
381
|
buttons : Ext.Msg.YESNO,
|
382
|
msg : Ext.String.format(i18n.get('label.convertersCrud.deleteConverter'), rec.data.name),
|
383
|
scope : this,
|
384
|
fn : function (btn, text) {
|
385
|
if (btn == 'yes') {
|
386
|
this.doDelete(rec.data.id);
|
387
|
}
|
388
|
}
|
389
|
|
390
|
});
|
391
|
},
|
392
|
|
393
|
doDelete : function (converterId) {
|
394
|
var datasetId = this.comboDatasets.getValue();
|
395
|
var url = this.urlDatasets + "/" + datasetId + this.converterUrlPart + "/" + converterId;
|
396
|
|
397
|
Ext.Ajax.request({
|
398
|
url : url,
|
399
|
method : "DELETE",
|
400
|
scope : this,
|
401
|
success : function (ret) {
|
402
|
if (showResponse(ret)) {
|
403
|
this.getStore().reload();
|
404
|
Ext.Msg.alert(i18n.get("label.information"), i18n.get("label.restartDsNeededConvDelete"));
|
405
|
}
|
406
|
}
|
407
|
});
|
408
|
},
|
409
|
|
410
|
onDeleteAll : function () {
|
411
|
if (Ext.isEmpty(this.comboDatasets.getValue())) {
|
412
|
return;
|
413
|
}
|
414
|
Ext.Msg.show({
|
415
|
title : i18n.get('label.delete'),
|
416
|
buttons : Ext.Msg.YESNO,
|
417
|
msg : i18n.get('label.convertersCrud.delete.all'),
|
418
|
scope : this,
|
419
|
fn : function (btn, text) {
|
420
|
if (btn == 'yes') {
|
421
|
this.doDeleteAll();
|
422
|
}
|
423
|
}
|
424
|
});
|
425
|
},
|
426
|
|
427
|
doDeleteAll : function () {
|
428
|
var datasetId = this.comboDatasets.getValue();
|
429
|
var url = this.urlDatasets + "/" + datasetId + this.converterUrlPart;
|
430
|
|
431
|
Ext.Ajax.request({
|
432
|
url : url,
|
433
|
method : "DELETE",
|
434
|
scope : this,
|
435
|
success : function (ret) {
|
436
|
if (showResponse(ret)) {
|
437
|
this.getStore().removeAll();
|
438
|
this.getStore().reload();
|
439
|
Ext.Msg.alert(i18n.get("label.information"), i18n.get("label.restartDsNeededConvDelete"));
|
440
|
}
|
441
|
}
|
442
|
});
|
443
|
},
|
444
|
_onActive : function () {
|
445
|
var rec = this.getLastSelectedRecord();
|
446
|
if (!rec) {
|
447
|
return popupMessage("", i18n.get('warning.noselection'), loadUrl.get('APP_URL') + loadUrl.get('APP_CLIENT_PUBLIC_URL')+'/res/images/msgBox/16/icon-info.png');;
|
448
|
}
|
449
|
Ext.Ajax.request({
|
450
|
url : this.urlDatasets + "/" + this.datasetId + this.converterUrlPart + "/" + rec.data.id + "/start",
|
451
|
method : 'PUT',
|
452
|
scope : this,
|
453
|
success : function (ret) {
|
454
|
if (showResponse(ret)) {
|
455
|
this.store.reload();
|
456
|
}
|
457
|
},
|
458
|
failure : alertFailure
|
459
|
});
|
460
|
},
|
461
|
|
462
|
_onDisactive : function () {
|
463
|
var rec = this.getLastSelectedRecord();
|
464
|
if (!rec) {
|
465
|
return popupMessage("", i18n.get('warning.noselection'), loadUrl.get('APP_URL') + loadUrl.get('APP_CLIENT_PUBLIC_URL')+'/res/images/msgBox/16/icon-info.png');;
|
466
|
}
|
467
|
Ext.Ajax.request({
|
468
|
url : this.urlDatasets + "/" + this.datasetId + this.converterUrlPart + "/" + rec.data.id + "/stop",
|
469
|
method : 'PUT',
|
470
|
scope : this,
|
471
|
success : function (ret) {
|
472
|
if (showResponse(ret)) {
|
473
|
this.store.reload();
|
474
|
}
|
475
|
},
|
476
|
failure : alertFailure
|
477
|
});
|
478
|
}
|
479
|
|
480
|
});
|
481
|
|