|
137 |
this.addChild(this._searchSidebar); |
137 |
this.addChild(this._searchSidebar); |
138 |
|
138 |
|
139 |
this._grid = new GalleryPane({ |
139 |
this._grid = new GalleryPane({ |
|
|
140 |
showTooltips: false, |
140 |
region: 'center', |
141 |
region: 'center', |
141 |
|
142 |
|
142 |
style: 'height: 100%; width: 100%;', |
143 |
style: 'height: 100%; width: 100%;', |
|
203 |
this._searchSidebar.on('search', lang.hitch(this, 'filterApplications')); |
204 |
this._searchSidebar.on('search', lang.hitch(this, 'filterApplications')); |
204 |
|
205 |
|
205 |
this.own(this._grid.on('.dgrid-row:click', lang.hitch(this, function(evt) { |
206 |
this.own(this._grid.on('.dgrid-row:click', lang.hitch(this, function(evt) { |
206 |
this._show_details(this._grid.row(evt)); |
207 |
var app = this._grid.row(evt).data; |
207 |
topic.publish('/umc/actions', this.moduleID, this.moduleFlavor, this._grid.row(evt).id, 'show'); |
208 |
this._show_details(app); |
|
|
209 |
topic.publish('/umc/actions', this.moduleID, this.moduleFlavor, app.id, 'show'); |
208 |
}))); |
210 |
}))); |
209 |
|
211 |
|
210 |
this._buildRenderingDeferred.resolve(); // for apps.js |
212 |
this._buildRenderingDeferred.resolve(); // for apps.js |
|
228 |
|
230 |
|
229 |
// inspired by PackagesPage._show_details |
231 |
// inspired by PackagesPage._show_details |
230 |
_show_details: function(app) { |
232 |
_show_details: function(app) { |
231 |
this.standby(true); |
233 |
var width = 550; // mimic the default of dialog.confirm |
232 |
|
234 |
|
233 |
tools.umcpCommand('appcenter/get', {'application': app.id}).then( |
235 |
var label_style = 'vertical-align:top;text-align:right;padding-left:1em;padding-right:.5em;white-space:nowrap;font-weight:bold;'; |
234 |
lang.hitch(this, function(data) { |
236 |
var data_style = 'vertical-align:top;padding-bottom:.25em;'; |
235 |
this.standby(false); |
|
|
236 |
var app = data.result; |
237 |
var width = 550; // mimic the default of dialog.confirm |
238 |
|
237 |
|
239 |
var label_style = 'vertical-align:top;text-align:right;padding-left:1em;padding-right:.5em;white-space:nowrap;font-weight:bold;'; |
238 |
var txt = "<h1>" + _("Details for Application '%(name)s'", app) + "</h1>"; |
240 |
var data_style = 'vertical-align:top;padding-bottom:.25em;'; |
239 |
txt += "<table>\n"; |
241 |
|
240 |
var fields = this._detail_field_order(); |
242 |
var txt = "<h1>" + _("Details for Application '%(name)s'", app) + "</h1>"; |
241 |
array.forEach(fields, lang.hitch(this, function(key) { |
243 |
txt += "<table>\n"; |
242 |
var label = this._detail_field_label(key); |
244 |
var fields = this._detail_field_order(); |
243 |
var value = app[key]; |
245 |
array.forEach(fields, lang.hitch(this, function(key) { |
244 |
var detail_func = this['_detail_field_custom_' + key]; |
246 |
var label = this._detail_field_label(key); |
245 |
if (detail_func) { |
247 |
var value = app[key]; |
246 |
value = lang.hitch(this, detail_func)(app); |
248 |
var detail_func = this['_detail_field_custom_' + key]; |
247 |
} |
249 |
if (detail_func) { |
248 |
if (!value) { |
250 |
value = lang.hitch(this, detail_func)(app); |
249 |
return; // continue |
251 |
} |
250 |
} |
252 |
if (!value) { |
251 |
if (label) { |
253 |
return; // continue |
252 |
txt += "<tr>\n"; |
254 |
} |
253 |
txt += "<td style='" + label_style + "'>" + label + "</td>\n"; |
255 |
if (label) { |
254 |
txt += "<td style='" + data_style + "'>" + value + "</td>\n"; |
256 |
txt += "<tr>\n"; |
255 |
txt += "</tr>\n"; |
257 |
txt += "<td style='" + label_style + "'>" + label + "</td>\n"; |
256 |
} |
258 |
txt += "<td style='" + data_style + "'>" + value + "</td>\n"; |
257 |
})); |
259 |
txt += "</tr>\n"; |
258 |
txt += "</table>\n"; |
260 |
} |
259 |
var buttons = []; |
261 |
})); |
260 |
if (!app.allows_using && this._udm_accessible) { |
262 |
txt += "</table>\n"; |
261 |
var label = app.can_update ? _('Upgrade') : _('Install'); // call it Install/Upgrade, although it is request |
263 |
var buttons = []; |
262 |
buttons.push({ |
264 |
if (!app.allows_using && this._udm_accessible) { |
263 |
name: 'request', |
265 |
var label = app.can_update ? _('Upgrade') : _('Install'); // call it Install/Upgrade, although it is request |
264 |
label: label, |
266 |
buttons.push({ |
265 |
callback: lang.hitch(this, function() { |
267 |
name: 'request', |
266 |
this._show_license_request(); |
268 |
label: label, |
267 |
}) |
269 |
callback: lang.hitch(this, function() { |
268 |
}); |
270 |
this._show_license_request(); |
269 |
} |
271 |
}) |
270 |
if (app.allows_using && app.can_install) { |
272 |
}); |
271 |
buttons.push({ |
273 |
} |
272 |
name: 'install', |
274 |
if (app.allows_using && app.can_install) { |
273 |
label: _("Install"), |
275 |
buttons.push({ |
274 |
callback: lang.hitch(this, function() { |
276 |
name: 'install', |
275 |
if (app.licenseagreement) { |
277 |
label: _("Install"), |
276 |
// before installing, user must agree on license terms |
278 |
callback: lang.hitch(this, function() { |
277 |
var content = '<h1>' + _('License agreement') + '</h1>'; |
279 |
if (app.licenseagreement) { |
278 |
content += '<div style="max-height:250px; overflow:auto;">' + |
280 |
// before installing, user must agree on license terms |
279 |
this.formatTxt(app.licenseagreement) + |
281 |
var content = '<h1>' + _('License agreement') + '</h1>'; |
280 |
'</div>'; |
282 |
content += '<div style="max-height:250px; overflow:auto;">' + |
281 |
dialog.confirm(content, [{ |
283 |
this.formatTxt(app.licenseagreement) + |
282 |
name: 'decline', |
284 |
'</div>'; |
283 |
label: _('Cancel'), |
285 |
dialog.confirm(content, [{ |
284 |
'default': true |
286 |
name: 'decline', |
285 |
}, { |
287 |
label: _('Cancel'), |
286 |
name: 'accept', |
288 |
'default': true |
287 |
label: _('Accept license') |
289 |
}, { |
288 |
}], _('License agreement')).then(lang.hitch(this, function(response) { |
290 |
name: 'accept', |
289 |
if (response == 'accept') { |
291 |
label: _('Accept license') |
|
|
292 |
}], _('License agreement')).then(lang.hitch(this, function(response) { |
293 |
if (response == 'accept') { |
294 |
this._call_installer('install', app); |
295 |
} |
296 |
})); |
297 |
} else { |
298 |
this._call_installer('install', app); |
290 |
this._call_installer('install', app); |
299 |
} |
291 |
} |
300 |
}) |
292 |
})); |
301 |
}); |
293 |
} else { |
302 |
} |
294 |
this._call_installer('install', app); |
303 |
if (app.allows_using && app.can_update) { |
|
|
304 |
buttons.push({ |
305 |
name: 'update', |
306 |
label: _("Upgrade"), |
307 |
callback: lang.hitch(this, function() { |
308 |
this.upgradeApp(app); |
309 |
}) |
310 |
}); |
311 |
} |
312 |
if (app.can_uninstall) { |
313 |
buttons.push({ |
314 |
name: 'uninstall', |
315 |
label: _("Uninstall"), |
316 |
callback: lang.hitch(this, function() { |
317 |
this._call_installer('uninstall', app); |
318 |
}) |
319 |
}); |
320 |
if (UMCApplication.getModule(app.umc_module, app.umc_flavor)) { |
321 |
buttons.push({ |
322 |
name: 'open', |
323 |
label: _("Open"), |
324 |
callback: lang.hitch(this, function() { |
325 |
topic.publish('/umc/modules/open', app.umc_module, app.umc_flavor); |
326 |
}) |
327 |
}); |
328 |
} |
295 |
} |
329 |
} |
296 |
}) |
330 |
// always: a button to close the dialog. |
297 |
}); |
|
|
298 |
} |
299 |
if (app.allows_using && app.can_update) { |
300 |
buttons.push({ |
301 |
name: 'update', |
302 |
label: _("Upgrade"), |
303 |
callback: lang.hitch(this, function() { |
304 |
this.upgradeApp(app); |
305 |
}) |
306 |
}); |
307 |
} |
308 |
if (app.can_uninstall) { |
309 |
buttons.push({ |
310 |
name: 'uninstall', |
311 |
label: _("Uninstall"), |
312 |
callback: lang.hitch(this, function() { |
313 |
this._call_installer('uninstall', app); |
314 |
}) |
315 |
}); |
316 |
if (UMCApplication.getModule(app.umc_module, app.umc_flavor)) { |
331 |
buttons.push({ |
317 |
buttons.push({ |
332 |
name: 'cancel', |
318 |
name: 'open', |
333 |
'default': true, |
319 |
label: _("Open"), |
334 |
label: _("Close") |
320 |
callback: lang.hitch(this, function() { |
|
|
321 |
topic.publish('/umc/modules/open', app.umc_module, app.umc_flavor); |
322 |
}) |
335 |
}); |
323 |
}); |
|
|
324 |
} |
325 |
} |
326 |
// always: a button to close the dialog. |
327 |
buttons.push({ |
328 |
name: 'cancel', |
329 |
'default': true, |
330 |
label: _("Close") |
331 |
}); |
336 |
|
332 |
|
337 |
var dialogText = new Text({ |
333 |
var dialogText = new Text({ |
338 |
'class': 'umcConfirmDialogText', |
334 |
'class': 'umcConfirmDialogText', |
339 |
content: txt |
335 |
content: txt |
340 |
}); |
336 |
}); |
341 |
var confirmDialog = new ConfirmDialog({ |
337 |
var confirmDialog = new ConfirmDialog({ |
342 |
title: _('Application details'), |
338 |
title: _('Application details'), |
343 |
message: dialogText, |
339 |
message: dialogText, |
344 |
options: buttons |
340 |
options: buttons |
345 |
}); |
341 |
}); |
346 |
|
342 |
|
347 |
// decorate screenshot images with a Lightbox |
343 |
// decorate screenshot images with a Lightbox |
348 |
var lightbox; |
344 |
var lightbox; |
349 |
query('.umcScreenshot', confirmDialog.domNode).forEach(function(imgNode) { |
345 |
query('.umcScreenshot', confirmDialog.domNode).forEach(function(imgNode) { |
350 |
lightbox = new Lightbox({ href: imgNode.src }, imgNode); |
346 |
lightbox = new Lightbox({ href: imgNode.src }, imgNode); |
351 |
imgNode.onload = function() { |
347 |
imgNode.onload = function() { |
352 |
confirmDialog.resize(); |
348 |
confirmDialog.resize(); |
353 |
}; |
349 |
}; |
354 |
}); |
350 |
}); |
355 |
|
351 |
|
356 |
// connect to 'onConfirm' event to close the dialog in any case |
352 |
// connect to 'onConfirm' event to close the dialog in any case |
357 |
confirmDialog.on('confirm', function() { |
353 |
confirmDialog.on('confirm', function() { |
358 |
confirmDialog.close(); |
354 |
confirmDialog.close(); |
359 |
}); |
355 |
}); |
360 |
|
356 |
|
361 |
// show the confirmation dialog |
357 |
// show the confirmation dialog |
362 |
confirmDialog.show(); |
358 |
confirmDialog.show(); |
363 |
|
|
|
364 |
}), |
365 |
lang.hitch(this, function() { |
366 |
this.standby(false); |
367 |
}) |
368 |
); |
369 |
}, |
359 |
}, |
370 |
|
360 |
|
371 |
_package_changes_one: function(changes, label) { |
361 |
_package_changes_one: function(changes, label) { |