<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">On 02/20/2014 03:21 AM, Aline Manera
wrote:<br>
</div>
<blockquote cite="mid:5305043B.1020709@linux.vnet.ibm.com"
type="cite">
<br>
The "Update All" link is still disabled even when there are
packages to be updated.
<br>
<br>
Also I'd suggest to remove the horizontal scroll bar as it is not
needed.
<br>
<br>
More comments below
<br>
</blockquote>
Agree. Though seems it's a bug in grid widget. The initial width of
the grid content is always a little larger than the grid width so
horizontal scroll bar appears. Let's track it in another issue with
a lower priority.
<blockquote cite="mid:5305043B.1020709@linux.vnet.ibm.com"
type="cite">
<br>
On 02/18/2014 12:06 AM, Hongliang Wang wrote:
<br>
<blockquote type="cite">Added UI support for software updating.
The Host Tab will initially
<br>
list available updates to user if there are any; or we will
disable
<br>
"Update All" Button if no updates available.
<br>
<br>
V1 -> V2:
<br>
2a) Fixed "Update All" Button always being disabled issue
<br>
(Thanks to Paulo Ricardo Paz Vital's comment)
<br>
<br>
Signed-off-by: Hongliang Wang <a class="moz-txt-link-rfc2396E" href="mailto:hlwang@linux.vnet.ibm.com"><hlwang@linux.vnet.ibm.com></a>
<br>
---
<br>
ui/css/theme-default/host.css | 22 +++++++++++++++
<br>
ui/js/src/kimchi.api.js | 52
++++++++++++++++++++++++++++++++++
<br>
ui/js/src/kimchi.host.js | 65
+++++++++++++++++++++++++++++++++++++++++++
<br>
ui/pages/i18n.html.tmpl | 9 ++++++
<br>
ui/pages/tabs/host.html.tmpl | 13 +++++++++
<br>
5 files changed, 161 insertions(+)
<br>
<br>
diff --git a/ui/css/theme-default/host.css
b/ui/css/theme-default/host.css
<br>
index 67daeaf..1342ade 100644
<br>
--- a/ui/css/theme-default/host.css
<br>
+++ b/ui/css/theme-default/host.css
<br>
@@ -227,3 +227,25 @@
<br>
width: 300px;
<br>
}
<br>
/* End of Debug Report */
<br>
+
<br>
+/* Software Updates */
<br>
+.host-panel #software-updates-grid {
<br>
+ border-color: #ddd;
<br>
+ height: 300px;
<br>
+ width: 850px;
<br>
+}
<br>
+
<br>
+.software-update-id {
<br>
+ width: 30px;
<br>
+}
<br>
+
<br>
+.software-update-name,
<br>
+.software-update-repos {
<br>
+ width: 220px;
<br>
+}
<br>
+
<br>
+.software-update-version,
<br>
+.software-update-arch {
<br>
+ width: 190px;
<br>
+}
<br>
+/* End of Software Updates */
<br>
diff --git a/ui/js/src/kimchi.api.js b/ui/js/src/kimchi.api.js
<br>
index 6433fe0..c3a9516 100644
<br>
--- a/ui/js/src/kimchi.api.js
<br>
+++ b/ui/js/src/kimchi.api.js
<br>
@@ -731,5 +731,57 @@ var kimchi = {
<br>
success : suc,
<br>
error : err
<br>
});
<br>
+ },
<br>
+
<br>
+ listSoftwareUpdates : function(suc, err) {
<br>
+ kimchi.requestJSON({
<br>
+ url : kimchi.url + 'host/packagesupdate',
<br>
+ type : 'GET',
<br>
+ contentType : 'application/json',
<br>
+ dataType : 'json',
<br>
+ resend: true,
<br>
+ success : suc,
<br>
+ error : err
<br>
+ });
<br>
+ },
<br>
+
<br>
+ updateSoftwares : function(suc, err) {
<br>
+ var taskID = -1;
<br>
+ var onResponse = function(data) {
<br>
+ taskID = data['id'];
<br>
+ trackTask();
<br>
+ };
<br>
+
<br>
+ var trackTask = function() {
<br>
+ kimchi.getTask(taskID, onTaskResponse, err);
<br>
+ };
<br>
+
<br>
+ var onTaskResponse = function(result) {
<br>
+ var taskStatus = result['status'];
<br>
+ switch(taskStatus) {
<br>
+ case 'running':
<br>
+ setTimeout(function() {
<br>
+ trackTask();
<br>
+ }, 200);
<br>
+ break;
<br>
+ case 'finished':
<br>
+ suc(result);
<br>
+ break;
<br>
+ case 'failed':
<br>
+ err(result);
<br>
+ break;
<br>
+ default:
<br>
+ break;
<br>
+ }
<br>
+ };
<br>
</blockquote>
<br>
In the 'message' parameter from task, there will be the update
output process.
<br>
I think would be good to show it to user - but I don't know where
in the window
<br>
<br>
example:
<br>
<br>
Add a tab to the update grid with "Update output" where we can
show the user the update progress
<br>
</blockquote>
Good point!<br>
<br>
For a complete coverage, we need consider following cases:<br>
<br>
1. No Updates Available<br>
Disable "Update All" Button and list nothing in the grid.<br>
<br>
2. There are Updates Found<br>
<br>
User Logged in Kimchi First Time and He Found Available Updates<br>
Because it's the first time the user found available updates and
no action was taken before, so enable "Update All" Button here.<br>
User operations and system processes:<br>
#1 Clicks "Update All" Button<br>
#2 UI disable the button and send request to update software<br>
#3 Back-end stores the status of the update process (/task can
be used by UI to track it)<br>
#4 User intentionally close the browser or the browser crashes
so the user reopens browser to log in Kimchi<br>
#5 Because updating is time-consuming, so the task is still
running. Here the UI should disable the "Update All" Button and set
the content of the button with "Updating..." to tell the user the
progress. So you can find that we need provide a "progress" here
such as 10%, 20%, etc. to let user know the progress at any time.<br>
#6 After updating completed, list available updates again and if
there is any, enable "Update All" Button at the same time.<br>
<br>
<b>Potential Effort</b><br>
The recommended enhancement for above includes:<br>
<br>
1) Add a property to host status like:<br>
GET /host<br>
<br>
{<br>
// ...<br>
"swupdate": {<br>
"status": "processing or running",<br>
"taskid": "1"<br>
},<br>
"status": "running"<br>
}<br>
<br>
2) Enhance task to allow showing progress like:<br>
GET /task/1<br>
<br>
{<br>
"id": 1,<br>
"status": "running",<br>
"progress": 0.5<br>
}<br>
<br>
3) For UI, we need a new visual widget: progress widget and
integrate it with grid widget.<br>
<br>
<b>Conclusion</b><br>
<br>
As discussed above, extra effort is needed for the task, so I
suggest add a new item in enhancement and defer it to next release.
<blockquote cite="mid:5305043B.1020709@linux.vnet.ibm.com"
type="cite">
<br>
<blockquote type="cite">+
<br>
+ kimchi.requestJSON({
<br>
+ url : kimchi.url + 'host/packagesupdate/update',
<br>
</blockquote>
<br>
Need to adjust it according to the latest patches
<br>
<br>
/host/swupdate
<br>
</blockquote>
ACK.<br>
<blockquote cite="mid:5305043B.1020709@linux.vnet.ibm.com"
type="cite">
<br>
<blockquote type="cite">+ type : "POST",
<br>
+ contentType : "application/json",
<br>
+ dataType : "json",
<br>
+ success : onResponse,
<br>
+ error : err
<br>
+ });
<br>
}
<br>
};
<br>
diff --git a/ui/js/src/kimchi.host.js b/ui/js/src/kimchi.host.js
<br>
index a5c341b..b6a5878 100644
<br>
--- a/ui/js/src/kimchi.host.js
<br>
+++ b/ui/js/src/kimchi.host.js
<br>
@@ -131,6 +131,69 @@ kimchi.host_main = function() {
<br>
});
<br>
};
<br>
<br>
+ var softwareUpdatesGridID = 'software-updates-grid';
<br>
+ var softwareUpdatesGrid = null;
<br>
+ var initSoftwareUpdatesGrid = function(softwareUpdates) {
<br>
+ softwareUpdatesGrid = new kimchi.widget.Grid({
<br>
+ container: 'software-updates-grid-container',
<br>
+ id: softwareUpdatesGridID,
<br>
+ title: i18n['KCHUPD6001M'],
<br>
+ toolbarButtons: [{
<br>
+ id: softwareUpdatesGridID + '-update-button',
<br>
+ label: i18n['KCHUPD6006M'],
<br>
+ disabled: true,
<br>
+ onClick: function(event) {
<br>
+ var updateButton = $(this);
<br>
+
$(updateButton).text(i18n['KCHUPD6007M']).prop('disabled',
true);
<br>
+ kimchi.updateSoftwares(function(result) {
<br>
+
$(updateButton).text(i18n['KCHUPD6006M']).prop('disabled',
false);
<br>
+ });
<br>
+ }
<br>
+ }],
<br>
+ frozenFields: [{
<br>
+ name: 'id',
<br>
+ label: ' ',
<br>
+ 'class': 'software-update-id'
<br>
+ }],
<br>
+ fields: [{
<br>
+ name: 'package_name',
<br>
+ label: i18n['KCHUPD6002M'],
<br>
+ 'class': 'software-update-name'
<br>
+ }, {
<br>
+ name: 'version',
<br>
+ label: i18n['KCHUPD6003M'],
<br>
+ 'class': 'software-update-version'
<br>
+ }, {
<br>
+ name: 'arch',
<br>
+ label: i18n['KCHUPD6004M'],
<br>
+ 'class': 'software-update-arch'
<br>
+ }, {
<br>
+ name: 'repository',
<br>
+ label: i18n['KCHUPD6005M'],
<br>
+ 'class': 'software-update-repos'
<br>
+ }],
<br>
+ data: softwareUpdates
<br>
+ });
<br>
+ };
<br>
+
<br>
+ var listSoftwareUpdates = function() {
<br>
+ kimchi.listSoftwareUpdates(function(softwareUpdates) {
<br>
+ $.each(softwareUpdates, function(i, item) {
<br>
+ softwareUpdates[i]['id'] = i + 1;
<br>
+ });
<br>
+
<br>
+ if(softwareUpdatesGrid) {
<br>
+ softwareUpdatesGrid.setData(softwareUpdates);
<br>
+ }
<br>
+ else {
<br>
+ initSoftwareUpdatesGrid(softwareUpdates);
<br>
+ }
<br>
+
<br>
+ $(softwareUpdatesGridID + '-update-button')
<br>
+ .prop('disabled', softwareUpdates.length ===
0);
<br>
+ });
<br>
+ };
<br>
+
<br>
var shutdownButtonID = '#host-button-shutdown';
<br>
var restartButtonID = '#host-button-restart';
<br>
var shutdownHost = function(params) {
<br>
@@ -189,6 +252,8 @@ kimchi.host_main = function() {
<br>
kimchi.keepMonitoringHost = this['checked'];
<br>
});
<br>
<br>
+ listSoftwareUpdates();
<br>
+
<br>
kimchi.getCapabilities(function(capabilities) {
<br>
if(!capabilities['system_report_tool']) {
<br>
return;
<br>
diff --git a/ui/pages/i18n.html.tmpl b/ui/pages/i18n.html.tmpl
<br>
index 098a0a9..a9d86b3 100644
<br>
--- a/ui/pages/i18n.html.tmpl
<br>
+++ b/ui/pages/i18n.html.tmpl
<br>
@@ -94,6 +94,15 @@ var i18n = {
<br>
'KCHDR6010M': "$_("Download")",
<br>
<br>
<br>
+ 'KCHUPD6001M': "$_("Software Updates")",
<br>
+ 'KCHUPD6002M': "$_("Package Name")",
<br>
+ 'KCHUPD6003M': "$_("Version")",
<br>
+ 'KCHUPD6004M': "$_("Architecture")",
<br>
+ 'KCHUPD6005M': "$_("Repository")",
<br>
+ 'KCHUPD6006M': "$_("Update All")",
<br>
+ 'KCHUPD6007M': "$_("Updating...")",
<br>
+
<br>
+
<br>
'KCHVM6001M': "$_("This will delete the virtual machine
and its virtual disks. This operation cannot be undone. Would
you like to continue?")",
<br>
<br>
'KCHNET6001E': "$_("The VLAN id must be between 1 and
4094.")",
<br>
diff --git a/ui/pages/tabs/host.html.tmpl
b/ui/pages/tabs/host.html.tmpl
<br>
index d32773a..1de4fcd 100644
<br>
--- a/ui/pages/tabs/host.html.tmpl
<br>
+++ b/ui/pages/tabs/host.html.tmpl
<br>
@@ -123,6 +123,19 @@
<br>
</div>
<br>
</div>
<br>
</div>
<br>
+ <div id="software-update-section"
class="host-section">
<br>
+ <h3 class="section-header"
<br>
+ aria-controls="content-software-update">
<br>
+ $_("Software Updates")
<br>
+ </h3>
<br>
+ <div id="content-software-update"
class="section-content">
<br>
+ <div class="section-row">
<br>
+ <div class="section-value">
<br>
+ <div
id="software-updates-grid-container"></div>
<br>
+ </div>
<br>
+ </div>
<br>
+ </div>
<br>
+ </div>
<br>
<div id="debug-report-section"
class="host-section hidden">
<br>
<h3 class="section-header"
<br>
aria-controls="content-sys-reports">
<br>
</blockquote>
<br>
</blockquote>
<br>
</body>
</html>