[Kimchi-devel] [PATCH 6/6] Create VMs Asynchronously: UI
Aline Manera
alinefm at linux.vnet.ibm.com
Wed Apr 29 21:36:17 UTC 2015
Signed-off-by: Christy Perez <christy at linux.vnet.ibm.com>
Signed-off-by: Aline Manera <alinefm at linux.vnet.ibm.com>
---
ui/css/theme-default/list.css | 8 ++++----
ui/js/src/kimchi.guest_main.js | 28 +++++++++++++++++++++++++---
ui/pages/guest.html.tmpl | 4 ++--
ui/pages/i18n.json.tmpl | 1 +
4 files changed, 32 insertions(+), 9 deletions(-)
diff --git a/ui/css/theme-default/list.css b/ui/css/theme-default/list.css
index 7b32ea6..e51912d 100644
--- a/ui/css/theme-default/list.css
+++ b/ui/css/theme-default/list.css
@@ -1,7 +1,7 @@
/*
* Project Kimchi
*
- * Copyright IBM, Corp. 2013-2014
+ * Copyright IBM, Corp. 2013-2015
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -289,11 +289,11 @@
padding-left: 10px;
}
-.guest-clone {
+.guest-pending {
margin: 10px;
}
-.guest-clone .icon {
+.guest-pending .icon {
background: url('../../images/theme-default/kimchi-loading15x15.gif') no-repeat;
display: inline-block;
width: 20px;
@@ -301,7 +301,7 @@
vertical-align: middle;
}
-.guest-clone .text {
+.guest-pending .text {
color: #666666;
margin-left: 5px;
text-shadow: -1px -1px 1px #CCCCCC, 1px 1px 1px #FFFFFF;
diff --git a/ui/js/src/kimchi.guest_main.js b/ui/js/src/kimchi.guest_main.js
index c712bb4..260e907 100644
--- a/ui/js/src/kimchi.guest_main.js
+++ b/ui/js/src/kimchi.guest_main.js
@@ -201,6 +201,21 @@ kimchi.listVmsAuto = function() {
if (kimchi.vmTimeout) {
clearTimeout(kimchi.vmTimeout);
}
+ var getCreatingGuests = function(){
+ var guests = [];
+ kimchi.getTasksByFilter('status=running&target_uri='+encodeURIComponent('^/vms/[^/]+$'), function(tasks) {
+ for(var i=0;i<tasks.length;i++){
+ var guestUri = tasks[i].target_uri;
+ var guestName = guestUri.split('/')[2]
+ guests.push($.extend({}, kimchi.sampleGuestObject, {name: guestName, isCreating: true}));
+ if(kimchi.trackingTasks.indexOf(tasks[i].id)==-1)
+ kimchi.trackTask(tasks[i].id, null, function(err){
+ kimchi.message.error(err.message);
+ }, null);
+ }
+ }, null, true);
+ return guests;
+ };
var getCloningGuests = function(){
var guests = [];
kimchi.getTasksByFilter('status=running&target_uri='+encodeURIComponent('^/vms/.+/clone'), function(tasks) {
@@ -219,6 +234,7 @@ kimchi.listVmsAuto = function() {
kimchi.listVMs(function(result, textStatus, jqXHR) {
if (result && textStatus=="success") {
result = getCloningGuests().concat(result);
+ result = getCreatingGuests().concat(result);
if(result.length) {
var listHtml = '';
var guestTemplate = kimchi.guestTemplate;
@@ -281,7 +297,7 @@ kimchi.createGuestLi = function(vmObject, prevScreenImage, openMenu) {
imgLoad.attr('src',load_src);
//Link the stopped tile to the start action, the running tile to open the console
- if(!vmObject.isCloning){
+ if(!(vmObject.isCloning || vmObject.isCreating)){
if (vmRunningBool) {
liveTile.off("click", kimchi.vmstart);
liveTile.on("click", kimchi.openVmConsole);
@@ -329,7 +345,7 @@ kimchi.createGuestLi = function(vmObject, prevScreenImage, openMenu) {
}
//Setup action event handlers
- if(!vmObject.isCloning){
+ if(!(vmObject.isCloning || vmObject.isCreating)){
guestActions.find("[name=vm-start]").on({click : kimchi.vmstart});
guestActions.find("[name=vm-poweroff]").on({click : kimchi.vmpoweroff});
if (vmRunningBool) { //If the guest is not running, do not enable reset
@@ -362,8 +378,14 @@ kimchi.createGuestLi = function(vmObject, prevScreenImage, openMenu) {
}else{
guestActions.find('.btn').attr('disabled', true);
- result.find('.guest-clone').removeClass('hide-content');
$('.popover', guestActions.find("div[name=actionmenu]")).remove();
+
+ result.find('.guest-pending').removeClass('hide-content');
+ pendingText = result.find('.guest-pending .text')
+ if(vmObject.isCloning)
+ pendingText.text(i18n['KCHAPI6009M']);
+ else
+ pendingText.text(i18n['KCHAPI6008M']);
}
return result;
diff --git a/ui/pages/guest.html.tmpl b/ui/pages/guest.html.tmpl
index 17d41ac..8896ac5 100644
--- a/ui/pages/guest.html.tmpl
+++ b/ui/pages/guest.html.tmpl
@@ -26,8 +26,8 @@
<div class="guest-general">
<h2 class="title" title="{name}">{name}</h2>
</div>
- <div class="guest-clone hide-content">
- <span class="icon"></span><span class="text">$_("Cloning")...</span>
+ <div class="guest-pending hide-content">
+ <span class="icon"></span><span class="text"></span>
</div>
</div>
<div name="cpu_utilization" class="sortable">
diff --git a/ui/pages/i18n.json.tmpl b/ui/pages/i18n.json.tmpl
index a6e3f5b..675d9a6 100644
--- a/ui/pages/i18n.json.tmpl
+++ b/ui/pages/i18n.json.tmpl
@@ -48,6 +48,7 @@
"KCHAPI6006M": "$_("Warning")",
"KCHAPI6007M": "$_("Save")",
"KCHAPI6008M": "$_("Creating...")",
+ "KCHAPI6009M": "$_("Cloning...")",
"KCHGRD6001M": "$_("Loading...")",
"KCHGRD6002M": "$_("An error occurred while retrieving system information.")",
--
2.1.0
More information about the Kimchi-devel
mailing list