[Kimchi-devel] [WIP PATCH 1/2] Federated Hosts Management

Hongliang Wang hlwang at linux.vnet.ibm.com
Mon Dec 30 07:57:38 UTC 2013


Hosts management.

Signed-off-by: Hongliang Wang <hlwang at linux.vnet.ibm.com>
---
 src/kimchi/model.py                          |   1 +
 ui/css/theme-default/host-add.css            |  29 +++++++
 ui/css/theme-default/host-edit.css           |  29 +++++++
 ui/css/theme-default/host.css                |  56 ++++++++++---
 ui/css/theme-default/hosts.css               |  24 ++++++
 ui/css/theme-default/window.css              |   6 +-
 ui/images/theme-default/host-icon-sprite.png | Bin 1034 -> 1163 bytes
 ui/js/src/kimchi.api.js                      |  77 ++++++++++++++++++
 ui/js/src/kimchi.grid.js                     |   2 +-
 ui/js/src/kimchi.host.js                     |   4 +
 ui/js/src/kimchi.host_add_main.js            |  62 ++++++++++++++
 ui/js/src/kimchi.host_edit_main.js           |  62 ++++++++++++++
 ui/js/src/kimchi.hosts.js                    | 116 +++++++++++++++++++++++++++
 ui/pages/guest-add.html.tmpl                 |   2 +-
 ui/pages/guest-edit.html.tmpl                |   2 +-
 ui/pages/host-add.html.tmpl                  |  66 +++++++++++++++
 ui/pages/host-edit.html.tmpl                 |  66 +++++++++++++++
 ui/pages/hosts.html.tmpl                     |  41 ++++++++++
 ui/pages/i18n.html.tmpl                      |   7 ++
 ui/pages/login-window.html.tmpl              |   2 +-
 ui/pages/report-add.html.tmpl                |   2 +-
 ui/pages/storagepool-add.html.tmpl           |   2 +-
 ui/pages/tabs/host.html.tmpl                 |  27 ++++++-
 ui/pages/template-add.html.tmpl              |   2 +-
 ui/pages/template-edit.html.tmpl             |   2 +-
 25 files changed, 664 insertions(+), 25 deletions(-)
 create mode 100644 ui/css/theme-default/host-add.css
 create mode 100644 ui/css/theme-default/host-edit.css
 create mode 100644 ui/css/theme-default/hosts.css
 create mode 100644 ui/js/src/kimchi.host_add_main.js
 create mode 100644 ui/js/src/kimchi.host_edit_main.js
 create mode 100644 ui/js/src/kimchi.hosts.js
 create mode 100644 ui/pages/host-add.html.tmpl
 create mode 100644 ui/pages/host-edit.html.tmpl
 create mode 100644 ui/pages/hosts.html.tmpl

diff --git a/src/kimchi/model.py b/src/kimchi/model.py
index a6790b8..e9d5ee4 100644
--- a/src/kimchi/model.py
+++ b/src/kimchi/model.py
@@ -269,6 +269,7 @@ class Model(object):
 
     def _get_host_info(self):
         res = {}
+        res['hostname'] = platform.node()
         with open('/proc/cpuinfo') as f:
             for line in f.xreadlines():
                 if "model name" in line:
diff --git a/ui/css/theme-default/host-add.css b/ui/css/theme-default/host-add.css
new file mode 100644
index 0000000..ed460c8
--- /dev/null
+++ b/ui/css/theme-default/host-add.css
@@ -0,0 +1,29 @@
+/*
+ * Project Kimchi
+ *
+ * Copyright IBM, Corp. 2013
+ *
+ * Authors:
+ *  Hongliang Wang <hlwang at linux.vnet.ibm.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#host-add-window {
+    height: 380px;
+    width: 420px;
+}
+
+#host-add-window .textbox-wrapper input {
+    box-sizing: border-box;
+    width: 100%;
+}
diff --git a/ui/css/theme-default/host-edit.css b/ui/css/theme-default/host-edit.css
new file mode 100644
index 0000000..ae88517
--- /dev/null
+++ b/ui/css/theme-default/host-edit.css
@@ -0,0 +1,29 @@
+/*
+ * Project Kimchi
+ *
+ * Copyright IBM, Corp. 2013
+ *
+ * Authors:
+ *  Hongliang Wang <hlwang at linux.vnet.ibm.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#host-edit-window {
+    height: 380px;
+    width: 420px;
+}
+
+#host-edit-window .textbox-wrapper input {
+    box-sizing: border-box;
+    width: 100%;
+}
diff --git a/ui/css/theme-default/host.css b/ui/css/theme-default/host.css
index 5e96b37..782758d 100644
--- a/ui/css/theme-default/host.css
+++ b/ui/css/theme-default/host.css
@@ -3,24 +3,60 @@
   margin-bottom: 100px;
 }
 
-.host-panel .logo-container, .host-panel .info-container,
+.host-panel .other-servers-container, .host-panel .info-container,
 .host-panel .section-label, .host-panel .section-value {
   display: inline-block;
   vertical-align: top;
 }
 
+.host-panel .other-servers-container {
+  background: #efefef;
+  margin-top: 16px;
+  padding: 0 5px 12px;
+  position: relative;
+  width: 150px;
+}
+
+.host-panel .other-servers-title {
+  font-size: 18px;
+  line-height: 32px;
+}
+
+.host-panel .other-servers-popup-button-container {
+  position: absolute;
+  right: 10px;
+  top: 10px;
+}
+
+.host-panel .other-servers-popup-button {
+  background: url("../images/theme-default/host-icon-sprite.png") no-repeat left -28px;
+  border: none;
+  height: 12px;
+  width: 12px;
+}
+
+.host-panel .other-servers-list li {
+  line-height: 20px;
+  overflow: hidden;
+  text-overflow: ellipsis;
+  white-space: nowrap;
+}
+
+.host-panel .other-servers-list a {
+  color: #888;
+  text-decoration: none;
+}
+
+.host-panel .other-servers-list a:hover {
+  text-decoration: underline;
+}
+
 .host-panel .section-label {
   display: inline-block;
   margin-right: 1em;
   vertical-align: top;
 }
 
-.host-panel .logo {
-  background: url("../images/icon-vm.png") no-repeat left top;
-  height: 128px;
-  width: 128px;
-}
-
 .host-panel .hostname {
   text-decoration: underline;
 }
@@ -99,7 +135,7 @@
 
 .host-panel .info-container {
   padding-top: 16px;
-  width: 892px;
+  width: 860px;
 }
 
 .host-panel .section-header {
@@ -167,7 +203,7 @@
 #container-chart-network-io {
   border: 1px solid white;
   box-shadow: 2px 2px 2px gray, 2px -2px 2px gray, -2px -2px 2px gray, -2px 2px 2px gray;
-  height: 100px;
+  height: 80px;
   width: 500px;
 }
 
@@ -180,7 +216,7 @@
 .host-panel #available-reports-grid {
   border-color: #ddd;
   height: 400px;
-  width: 750px;
+  width: 820px;
 }
 
 .host-panel select#available-reports-list {
diff --git a/ui/css/theme-default/hosts.css b/ui/css/theme-default/hosts.css
new file mode 100644
index 0000000..ed028e0
--- /dev/null
+++ b/ui/css/theme-default/hosts.css
@@ -0,0 +1,24 @@
+#hosts-window {
+  font-size: 12px;
+  height: 400px;
+  width: 820px;
+}
+
+#hosts-window #hosts-grid {
+  border-color: #ddd;
+  height: 344px;
+  width: 814px;
+}
+
+#hosts-window .host-id {
+  width: 30px;
+}
+
+#hosts-window .host-name,
+#hosts-window .host-url {
+  width: 390px;
+}
+
+#hosts-window .content {
+  margin-bottom: 0;
+}
diff --git a/ui/css/theme-default/window.css b/ui/css/theme-default/window.css
index 0a95dce..130eea5 100644
--- a/ui/css/theme-default/window.css
+++ b/ui/css/theme-default/window.css
@@ -52,7 +52,7 @@
     max-height: 100%;
 }
 
-.window>header {
+.window-header {
     position: absolute;
     left: 0;
     right: 0;
@@ -101,12 +101,12 @@
     cursor: pointer;
 }
 
-.window>header>.close:HOVER {
+.window-header>.close:HOVER {
     border: 2px solid #444;
     color: #444;
 }
 
-.window>header>.title {
+.window-header>.title {
     font-size: 18px;
     height: 48px;
     line-height: 48px;
diff --git a/ui/images/theme-default/host-icon-sprite.png b/ui/images/theme-default/host-icon-sprite.png
index da1cd3f2562a5905a526446bcc8fc18bea06c734..e1a141168c78724322bce46964c95fa495ed0fc0 100644
GIT binary patch
delta 1070
zcmV+}1kwA72#X1j7YZl{1^@s6A6n0fks&b&3>OIuCL1Hx2$5SXfA2{|K~#9!?V3-B
z990m;e?3l!$V!4lEl}5k<hb4jJtT)cM`92>2x4Xh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AMG-LpNZ}&Rh6!6N+HWJ7tM_fZ4JaZ
z4FHVJK*>()18@$&B>-mu{7_Z5>Ofu&G}~jtLAPf_L=smAs!7kX47bp*>cE2e{W(Op
zUedpxe=g&P>yyFRKMi0z&>mIQrid&iVqA_4oV3~tBC;bQJ7_QMEcIHnC?X#LytKL>
zs%r052kP~DY<0ls{5RDBFDZ*`N~hftRMj`pW7t-CT|^!ky^4A7udB@<*0kwB7vI-)
znq=l_0(fe5kBi7gBF9Bcoc6<NF-#g4k&RAye at t4u-R5IO=W)j7Hh|GU*H;m_5V=)~
zh?fUAlUzqu2UK;qQ}P*wsffiaSlX%ssyY}NRTlK|cO&w((*SM(cpT-Rqzp(K9UhTD
z<-MxD1~3KShKQ`Sr2|C*7Lh*yZma52nkz5cdB>1xLAeRwAb8dTz&{5}I`QFP^#cF^
O3IG5}MNUMnLSTY<HL~ge

diff --git a/ui/js/src/kimchi.api.js b/ui/js/src/kimchi.api.js
index fbcf4a2..3bbe2a4 100644
--- a/ui/js/src/kimchi.api.js
+++ b/ui/js/src/kimchi.api.js
@@ -681,5 +681,82 @@ var kimchi = {
             success : suc,
             error : err
         });
+    },
+
+    addHost : function(settings, suc, err) {
+        suc();
+/*
+        kimchi.requestJSON({
+            url : kimchi.url + 'hosts',
+            type : 'POST',
+            contentType : 'application/json',
+            data : JSON.stringify(settings),
+            dataType : 'json',
+            success: suc,
+            error: err
+        });
+*/
+    },
+
+    updateHost : function(settings, suc, err) {
+        suc();
+/*
+        kimchi.requestJSON({
+            url : kimchi.url + 'hosts',
+            type : 'PUT',
+            contentType : 'application/json',
+            data : JSON.stringify(settings),
+            dataType : 'json',
+            success: suc,
+            error: err
+        });
+*/
+    },
+
+    deleteHost : function(host, suc, err) {
+        suc();
+/*
+        kimchi.requestJSON({
+            url : kimchi.url + 'hosts/' + encodeURIComponent(host),
+            type : 'DELETE',
+            contentType : 'application/json',
+            dataType : 'json',
+            success : suc,
+            error : err
+        });
+*/
+    },
+
+    /**
+     *
+     */
+    listHosts : function(suc, err) {
+        suc([{
+            name: 'RHEL 6.4',
+            url: 'http://9.123.141.113:8000'
+        }, {
+            name: 'RHEL 6.5',
+            url: 'http://9.123.141.113:8000'
+        }, {
+            name: 'Fedora 18',
+            url: 'http://9.123.141.113:8000'
+        }, {
+            name: 'Fedora 19',
+            url: 'http://9.123.141.113:8000'
+        }, {
+            name: 'Fedora with very very very very very long name',
+            url: 'http://9.123.141.113:8000'
+        }]);
+/*
+        kimchi.requestJSON({
+            url : kimchi.url + 'hosts',
+            type : 'GET',
+            contentType : 'application/json',
+            dataType : 'json',
+            resend: true,
+            success : suc,
+            error : err
+        });
+*/
     }
 };
diff --git a/ui/js/src/kimchi.grid.js b/ui/js/src/kimchi.grid.js
index 0fe195f..6e5f1fe 100644
--- a/ui/js/src/kimchi.grid.js
+++ b/ui/js/src/kimchi.grid.js
@@ -291,7 +291,7 @@ kimchi.widget.Grid = function(params) {
     };
 
     var endResizing = function(event) {
-        if(!$('body').hasClass('resizing')) {
+        if(!$('body').hasClass('resizing') || !columnBeingResized) {
             return;
         }
         resizerLeftmost.addClass('hidden');
diff --git a/ui/js/src/kimchi.host.js b/ui/js/src/kimchi.host.js
index e9279fb..0bcdf80 100644
--- a/ui/js/src/kimchi.host.js
+++ b/ui/js/src/kimchi.host.js
@@ -196,6 +196,10 @@ kimchi.host_main = function() {
             $('#debug-report-section').removeClass('hidden');
             listDebugReports();
         });
+
+        $('#button-edit-hosts').on('click', function(event) {
+            kimchi.window.open('hosts.html');
+        });
     };
 
     kimchi.topic('kimchi/debugReportAdded').subscribe(function(params) {
diff --git a/ui/js/src/kimchi.host_add_main.js b/ui/js/src/kimchi.host_add_main.js
new file mode 100644
index 0000000..c6e7ce6
--- /dev/null
+++ b/ui/js/src/kimchi.host_add_main.js
@@ -0,0 +1,62 @@
+/*
+ * Project Kimchi
+ *
+ * Copyright IBM, Corp. 2013
+ *
+ * Authors:
+ *  Hongliang Wang <hlwang at linux.vnet.ibm.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+kimchi.host_add_main = function() {
+
+    var addForm = $('#form-host-add');
+    var addButton = $('#button-host-add');
+
+    var nameBox = $('input[name="name"]', addForm);
+    var urlBox = $('input[name="url"]', addForm);
+
+    var validateForm = function(event) {
+        var valid = $(nameBox).val() !== ''  && $(urlBox).val() !== '';
+        $(addButton).prop('disabled', !valid);
+        return valid;
+    };
+
+    $(nameBox).on('change', validateForm);
+    $(urlBox).on('change', validateForm);
+
+    var addHost = function(event) {
+        var valid = validateForm();
+        if(!valid) {
+            return false;
+        }
+
+        var formData = $(addForm).serializeObject();
+
+        kimchi.addHost(formData, function() {
+            kimchi.topic("hostAdded").publish();
+            kimchi.window.close();
+        }, function(jqXHR, textStatus, errorThrown) {
+            var reason = jqXHR &&
+                jqXHR['responseJSON'] &&
+                jqXHR['responseJSON']['reason'];
+            reason = reason ? ': ' + reason : '';
+            kimchi.message.error(i18n['msg.hosts.failed.add'] + reason);
+        });
+
+        return false;
+    };
+
+    $(addForm).on('submit', addHost);
+    $(addButton).on('click', addHost);
+};
diff --git a/ui/js/src/kimchi.host_edit_main.js b/ui/js/src/kimchi.host_edit_main.js
new file mode 100644
index 0000000..0caec82
--- /dev/null
+++ b/ui/js/src/kimchi.host_edit_main.js
@@ -0,0 +1,62 @@
+/*
+ * Project Kimchi
+ *
+ * Copyright IBM, Corp. 2013
+ *
+ * Authors:
+ *  Hongliang Wang <hlwang at linux.vnet.ibm.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+kimchi.host_edit_main = function() {
+
+    var editForm = $('#form-host-edit');
+    var saveButton = $('#button-host-save');
+
+    var nameBox = $('input[name="name"]', editForm);
+    var urlBox = $('input[name="url"]', editForm);
+
+    var validateForm = function(event) {
+        var valid = $(nameBox).val() !== ''  && $(urlBox).val() !== '';
+        $(saveButton).prop('disabled', !valid);
+        return valid;
+    };
+
+    $(nameBox).on('change', validateForm);
+    $(urlBox).on('change', validateForm);
+
+    var editHost = function(event) {
+        var valid = validateForm();
+        if(!valid) {
+            return false;
+        }
+
+        var formData = $(editForm).serializeObject();
+
+        kimchi.updateHost(formData, function() {
+            kimchi.topic('hostUpdated').publish();
+            kimchi.window.close();
+        }, function(jqXHR, textStatus, errorThrown) {
+            var reason = jqXHR &&
+                jqXHR['responseJSON'] &&
+                jqXHR['responseJSON']['reason'];
+            reason = reason ? ': ' + reason : '';
+            kimchi.message.error(i18n['msg.hosts.failed.edit'] + reason);
+        });
+
+        return false;
+    };
+
+    $(editForm).on('submit', editHost);
+    $(saveButton).on('click', editHost);
+};
diff --git a/ui/js/src/kimchi.hosts.js b/ui/js/src/kimchi.hosts.js
new file mode 100644
index 0000000..f55ebf8
--- /dev/null
+++ b/ui/js/src/kimchi.hosts.js
@@ -0,0 +1,116 @@
+/*
+ * Project Kimchi
+ *
+ * Copyright IBM, Corp. 2013
+ *
+ * Authors:
+ *  Hongliang Wang <hlwang at linux.vnet.ibm.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+kimchi.hosts_main = function() {
+    var hostsGridID = 'hosts-grid';
+    var hostsGrid = null;
+    var initHostsGrid = function(hosts) {
+        hostsGrid = new kimchi.widget.Grid({
+            container: 'hosts-grid-container',
+            id: hostsGridID,
+            toolbarButtons: [{
+                id: hostsGridID + '-create-button',
+                label: i18n['msg.hosts.add'],
+                onClick: function(event) {
+                    kimchi.window.open('host-add.html', {
+                        close: function() {
+                        }
+                    });
+                }
+            }, {
+                id: hostsGridID + '-edit-button',
+                label: i18n['msg.hosts.edit'],
+                disabled: true,
+                onClick: function(event) {
+                    kimchi.window.open('host-edit.html', {
+                        close: function() {
+                        }
+                    });
+                }
+            }, {
+                id: hostsGridID + '-remove-button',
+                label: i18n['msg.hosts.remove'],
+                disabled: true,
+                onClick: function(event) {
+                    var host = hostsGrid.getSelected();
+                    if(!host) {
+                        return;
+                    }
+
+                    var settings = {
+                        title : i18n['msg.hosts.confirm.title'],
+                        content : i18n['msg.hosts.confirm.content'],
+                        confirm : i18n['msg.confirm'],
+                        cancel : i18n['msg.cancel']
+                    };
+
+                    kimchi.confirm(settings, function() {
+                        kimchi.deleteHost({
+                            name: host['name']
+                        }, function(result) {
+                            listHosts();
+                        }, function(error) {
+                        });
+                    });
+                }
+            }],
+            onRowSelected: function(row) {
+                $('#' + hostsGridID + '-edit-button')
+                    .prop('disabled', false);
+                $('#' + hostsGridID + '-remove-button')
+                    .prop('disabled', false);
+            },
+            frozenFields: [{
+                name: 'id',
+                label: ' ',
+                'class': 'host-id'
+            }],
+            fields: [{
+                name: 'name',
+                label: i18n['msg.hosts.name'],
+                'class': 'host-name'
+            }, {
+                name: 'url',
+                label: i18n['msg.hosts.url'],
+                'class': 'host-url'
+            }],
+            data: hosts
+        });
+    };
+
+    var listHosts = function() {
+        kimchi.listHosts(function(hosts) {
+            $.each(hosts, function(i, item) {
+                hosts[i]['id'] = i + 1;
+            });
+            if(hostsGrid) {
+                hostsGrid.setData(hosts);
+            }
+            else {
+                initHostsGrid(hosts);
+            }
+        });
+    };
+
+    listHosts();
+
+    kimchi.topic('hostAdded').subscribe(listHosts);
+    kimchi.topic('hostUpdated').subscribe(listHosts);
+};
diff --git a/ui/pages/guest-add.html.tmpl b/ui/pages/guest-add.html.tmpl
index 36a0f35..e57884e 100644
--- a/ui/pages/guest-add.html.tmpl
+++ b/ui/pages/guest-add.html.tmpl
@@ -28,7 +28,7 @@
 <html>
 <body>
 <div class="window" style="width: 900px;height: 580px;">
-    <header>
+    <header class="window-header">
         <h1 class="title">$_("Create a New Virtual Machine")</h1>
         <div class="close">X</div>
     </header>
diff --git a/ui/pages/guest-edit.html.tmpl b/ui/pages/guest-edit.html.tmpl
index 91f780c..7ff7e60 100644
--- a/ui/pages/guest-edit.html.tmpl
+++ b/ui/pages/guest-edit.html.tmpl
@@ -26,7 +26,7 @@
 #silent _t = t.gettext
 
 <div id="guest-edit-window" class="window">
-    <header>
+    <header class="window-header">
         <h1 class="title">$_("Edit Guest")</h1>
         <div class="close">X</div>
     </header>
diff --git a/ui/pages/host-add.html.tmpl b/ui/pages/host-add.html.tmpl
new file mode 100644
index 0000000..c2a22a6
--- /dev/null
+++ b/ui/pages/host-add.html.tmpl
@@ -0,0 +1,66 @@
+#*
+ * Project Kimchi
+ *
+ * Copyright IBM, Corp. 2013
+ *
+ * Authors:
+ *  Hongliang Wang <hlwang at linux.vnet.ibm.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required="required" by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *#
+#unicode UTF-8
+#import gettext
+#from kimchi.cachebust import href
+#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang)
+#silent _ = t.gettext
+#silent _t = t.gettext
+<div id="host-add-window" class="window">
+    <form id="form-host-add">
+        <header class="window-header">
+            <h1 class="title">$_("Add a Host")</h1>
+            <div class="close">X</div>
+        </header>
+        <div class="content">
+            <section class="form-section">
+                <h2>1. $_("Host Name")</h2>
+                <div class="field">
+                    <p class="text-help">
+                        $_("The name used to identify the host.")
+                    </p>
+                    <div class="textbox-wrapper">
+                        <input type="text" class="text" name="name" required="required" />
+                    </div>
+                </div>
+            </section>
+            <section class="form-section">
+                <h2>2. $_("Console URL")</h2>
+                <div class="field">
+                    <p class="text-help">
+                        $_("The URL of the host management console in format: http://[domain or IP]:[port]")
+                    </p>
+                    <div class="textbox-wrapper">
+                        <input type="text" class="text" name="url" required="required" />
+                    </div>
+                </div>
+            </section>
+        </div>
+        <footer>
+            <div class="btn-group">
+                <button type="submit" id="button-host-add" class="btn-normal" disabled="disabled"><span class="text">$_("Add")</span></button>
+            </div>
+        </footer>
+    </form>
+</div>
+<script>
+    kimchi.host_add_main();
+</script>
diff --git a/ui/pages/host-edit.html.tmpl b/ui/pages/host-edit.html.tmpl
new file mode 100644
index 0000000..0d003cb
--- /dev/null
+++ b/ui/pages/host-edit.html.tmpl
@@ -0,0 +1,66 @@
+#*
+ * Project Kimchi
+ *
+ * Copyright IBM, Corp. 2013
+ *
+ * Authors:
+ *  Hongliang Wang <hlwang at linux.vnet.ibm.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *#
+#unicode UTF-8
+#import gettext
+#from kimchi.cachebust import href
+#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang)
+#silent _ = t.gettext
+#silent _t = t.gettext
+<div id="host-edit-window" class="window">
+    <form id="form-host-edit">
+        <header class="window-header">
+            <h1 class="title">$_("Edit a Host")</h1>
+            <div class="close">X</div>
+        </header>
+        <div class="content">
+            <section class="form-section">
+                <h2>1. $_("Host Name")</h2>
+                <div class="field">
+                    <p class="text-help">
+                        $_("The name used to identify the host.")
+                    </p>
+                    <div class="textbox-wrapper">
+                        <input type="text" class="text" name="name">
+                    </div>
+                </div>
+            </section>
+            <section class="form-section">
+                <h2>2. $_("Console URL")</h2>
+                <div class="field">
+                    <p class="text-help">
+                        $_("The URL of the host management console in format: http://[domain or IP]:[port]")
+                    </p>
+                    <div class="textbox-wrapper">
+                        <input type="text" class="text" name="url">
+                    </div>
+                </div>
+            </section>
+        </div>
+        <footer>
+            <div class="btn-group">
+                <button type="submit" id="button-host-save" class="btn-normal" disabled="disabled"><span class="text">$_("Save")</span></button>
+            </div>
+        </footer>
+    </form>
+</div>
+<script>
+    kimchi.host_edit_main();
+</script>
diff --git a/ui/pages/hosts.html.tmpl b/ui/pages/hosts.html.tmpl
new file mode 100644
index 0000000..4e75b64
--- /dev/null
+++ b/ui/pages/hosts.html.tmpl
@@ -0,0 +1,41 @@
+#*
+ * Project Kimchi
+ *
+ * Copyright IBM, Corp. 2013
+ *
+ * Authors:
+ *  Hongliang Wang <hlwang at linux.vnet.ibm.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *#
+
+#unicode UTF-8
+#import gettext
+#from kimchi.cachebust import href
+#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang)
+#silent _ = t.gettext
+#silent _t = t.gettext
+
+<div id="hosts-window" class="window">
+    <header class="window-header">
+        <h1 class="title">$_("Hosts Management")</h1>
+        <div class="close">X</div>
+    </header>
+    <div class="content">
+        <div id="hosts-grid-container"></div>
+    </div>
+</div>
+
+<script type="text/javascript">
+    kimchi.hosts_main();
+</script>
diff --git a/ui/pages/i18n.html.tmpl b/ui/pages/i18n.html.tmpl
index c1fc3d1..475629e 100644
--- a/ui/pages/i18n.html.tmpl
+++ b/ui/pages/i18n.html.tmpl
@@ -81,6 +81,13 @@ var i18n = {
     'msg.host.shutdown.vmrunning': "$_("Some VM(s) are running!")",
     'msg.host.shutdown.confirm.title': "$_("Confirm")",
     'msg.host.shutdown.confirm.content': "$_("Shutting down or restarting host will cause unsaved work lost. Continue to shut down/restarting?")",
+    'msg.hosts.add': "$_("Add")",
+    'msg.hosts.edit': "$_("Edit")",
+    'msg.hosts.remove': "$_("Remove")",
+    'msg.hosts.confirm.title': "$_("Remove Host Confirmation")",
+    'msg.hosts.confirm.content': "$_("Host information will be removed permanently. Do you want to continue?")",
+    'msg.hosts.name': "$_("Name")",
+    'msg.hosts.url': "$_("URL")",
     'msg.vm.confirm.delete': "$_("This will delete the VM and its virtual disks. "
                                  "This operation cannot be undone. "
                                  "Would you like to continue?")",
diff --git a/ui/pages/login-window.html.tmpl b/ui/pages/login-window.html.tmpl
index 5dd37f6..2f12f75 100644
--- a/ui/pages/login-window.html.tmpl
+++ b/ui/pages/login-window.html.tmpl
@@ -25,7 +25,7 @@
 #silent _ = t.gettext
 #silent _t = t.gettext
 <div id="login-window" class="window">
-  <header>
+  <header class="window-header">
     <div class="logo"></div>
     <span class="title">$_("Log In")</span>
     <form id="form-language" class="language" action="" method="GET">
diff --git a/ui/pages/report-add.html.tmpl b/ui/pages/report-add.html.tmpl
index 2a962d4..af7bb74 100644
--- a/ui/pages/report-add.html.tmpl
+++ b/ui/pages/report-add.html.tmpl
@@ -26,7 +26,7 @@
 #silent _t = t.gettext
 <!DOCTYPE html>
 <div id="report-add-window" class="window">
-    <header>
+    <header class="window-header">
         <h1 class="title">$_("Generate a New Debug Report")</h1>
         <div class="close">X</div>
     </header>
diff --git a/ui/pages/storagepool-add.html.tmpl b/ui/pages/storagepool-add.html.tmpl
index 5a2dd45..9679b73 100644
--- a/ui/pages/storagepool-add.html.tmpl
+++ b/ui/pages/storagepool-add.html.tmpl
@@ -28,7 +28,7 @@
 <html>
 <body>
     <div class="window" style="width: 600px; height: 600px;">
-        <header>
+        <header class="window-header">
             <h1 class="title">$_("Define a New Storage Pool")</h1>
             <div class="close">X</div>
         </header>
diff --git a/ui/pages/tabs/host.html.tmpl b/ui/pages/tabs/host.html.tmpl
index aa4ecfb..2ded6d4 100644
--- a/ui/pages/tabs/host.html.tmpl
+++ b/ui/pages/tabs/host.html.tmpl
@@ -35,9 +35,6 @@
 
 <script id="host-tmpl" type="kimchi/template">
     <div class="host-panel">
-        <div class="logo-container">
-            <div class="logo" style="background-image: url({logo});"></div>
-        </div>
         <div id="host-info-container" class="info-container">
             <h2 class="hostname">{hostname}</h2>
             <div class="action-panel">
@@ -130,7 +127,6 @@
                 </h3>
                 <div id="content-sys-reports" class="section-content">
                     <div class="section-row">
-                        <div class="section-label"></div>
                         <div class="section-value">
                             <div id="available-reports-grid-container"></div>
                         </div>
@@ -138,6 +134,29 @@
                 </div>
             </div>
         </div>
+        <div class="other-servers-container">
+            <div class="other-servers-popup-button-container">
+                <button id="button-edit-hosts" title="Edit" class="other-servers-popup-button"></button>
+            </div>
+            <div class="other-servers-title">Other Servers</div>
+            <ul class="other-servers-list">
+                <li>
+                    <a href="http://9.123.141.113:8000">RHEL6.4</a>
+                </li>
+                <li>
+                    <a href="http://9.123.141.113:8000">RHEL6.5</a>
+                </li>
+                <li>
+                    <a href="http://9.123.141.113:8000">Fedora 18</a>
+                </li>
+                <li>
+                    <a href="http://9.123.141.113:8000">Fedora 19</a>
+                </li>
+                <li>
+                    <a href="http://9.123.141.113:8000" title="Fedora with very very very very very long name">Fedora with very very very very very long name</a>
+                </li>
+            </ul>
+        </div>
     </div>
 </script>
 
diff --git a/ui/pages/template-add.html.tmpl b/ui/pages/template-add.html.tmpl
index 27d8a90..3a1c517 100644
--- a/ui/pages/template-add.html.tmpl
+++ b/ui/pages/template-add.html.tmpl
@@ -29,7 +29,7 @@
 <html>
 <body>
 <div class="window" style="width: 992px;height: 660px;">
-    <header>
+    <header class="window-header">
         <h1 class="title">$_("Add Template")</h1>
         <div class="close">X</div>
     </header>
diff --git a/ui/pages/template-edit.html.tmpl b/ui/pages/template-edit.html.tmpl
index fe7314d..80d80e0 100644
--- a/ui/pages/template-edit.html.tmpl
+++ b/ui/pages/template-edit.html.tmpl
@@ -27,7 +27,7 @@
 #silent _t = t.gettext
 
 <div id="template-edit-window" class="window">
-    <header>
+    <header class="window-header">
         <h1 class="title">$_("Edit Template")</h1>
         <div class="close">X</div>
     </header>
-- 
1.8.1.4




More information about the Kimchi-devel mailing list