/config/capabilities was requested twice for the templates tab: one
request to identify if qemu has spice support and other one to identify
if the qemu has ISO streaming support.
Those requests were made right before using the information, causing a
delay on UI until get the server response.
For example, for distant servers, while creating a new template the
"Remote ISO" option was disabled at the first time and after some time it was
enabled.
The same behavior was identified while editing a template, as the graphics
options blinked to add the spice on it.
To fix it, request /config/capabilities when loading the templates tab to have
this information prior to edit or create a new template.
Signed-off-by: Aline Manera <alinefm(a)linux.vnet.ibm.com>
---
ui/js/src/kimchi.template_add_main.js | 27 ++++++++++++---------------
ui/js/src/kimchi.template_edit_main.js | 12 ++++--------
ui/js/src/kimchi.template_main.js | 6 ++++++
3 files changed, 22 insertions(+), 23 deletions(-)
diff --git a/ui/js/src/kimchi.template_add_main.js
b/ui/js/src/kimchi.template_add_main.js
index a24a306..a7421d7 100644
--- a/ui/js/src/kimchi.template_add_main.js
+++ b/ui/js/src/kimchi.template_add_main.js
@@ -222,22 +222,19 @@ kimchi.template_add_main = function() {
//1-2 remote iso
$('#iso-remote').css('opacity', 0.3).css('cursor',
'not-allowed');
- kimchi.getCapabilities(function(result) {
- if (result.qemu_stream == true) {
- $('#iso-remote').css('opacity', 1).css('cursor',
'pointer');
-
- $('#iso-remote').click(function() {
- kimchi.switchPage('iso-type-box', 'iso-remote-box');
- initRemoteIsoField();
- initIsoUrlField();
- kimchi.listDistros(function(isos) {
- showRemoteIsoField(isos);
- }, function() {
- });
+ if (kimchi.capabilities.qemu_stream == true) {
+ $('#iso-remote').css('opacity', 1).css('cursor',
'pointer');
+
+ $('#iso-remote').click(function() {
+ kimchi.switchPage('iso-type-box', 'iso-remote-box');
+ initRemoteIsoField();
+ initIsoUrlField();
+ kimchi.listDistros(function(isos) {
+ showRemoteIsoField(isos);
+ }, function() {
});
- }
- }, function() {
- });
+ });
+ }
$('#iso-remote-box-back').click(function() {
kimchi.switchPage('iso-remote-box', 'iso-type-box',
'right');
diff --git a/ui/js/src/kimchi.template_edit_main.js
b/ui/js/src/kimchi.template_edit_main.js
index d42108c..281154a 100644
--- a/ui/js/src/kimchi.template_edit_main.js
+++ b/ui/js/src/kimchi.template_edit_main.js
@@ -39,14 +39,10 @@ kimchi.template_edit_main = function() {
}
var options = [{label: 'VNC', value: 'vnc'}];
- kimchi.getCapabilities(function(result) {
- if (result.qemu_spice == true) {
- options.push({label: 'Spice', value: 'spice'})
- }
- }, function() {
- }, function() {
- kimchi.select('template-edit-graphics-list', options);
- });
+ if (kimchi.capabilities.qemu_spice == true) {
+ options.push({label: 'Spice', value: 'spice'})
+ }
+ kimchi.select('template-edit-graphics-list', options);
var scsipools = {};
kimchi.listStoragePools(function(result) {
diff --git a/ui/js/src/kimchi.template_main.js b/ui/js/src/kimchi.template_main.js
index 3c8421d..8a783c3 100644
--- a/ui/js/src/kimchi.template_main.js
+++ b/ui/js/src/kimchi.template_main.js
@@ -83,6 +83,12 @@ kimchi.hideTitle = function() {
};
kimchi.template_main = function() {
+ kimchi.getCapabilities(function(result) {
+ kimchi.capabilities = result;
+ }, function() {
+ kimchi.capabilities = {};
+ });
+
if(kimchi.tabMode['templates'] === 'admin') {
$('.tools').attr('style','display');
$("#template-add").on("click", function(event) {
--
1.9.3