[Kimchi-devel] [PATCH] [Kimchi] Issue #921: Peers button disappears

sguimaraes943 at gmail.com sguimaraes943 at gmail.com
Fri Aug 26 20:55:47 UTC 2016


From: Samuel Guimarães <sguimaraes943 at gmail.com>

This commit moves peers list from the drop-down on the top navigation bar to a DataTable that will be rendered on Host Dashboard if the user has Gingerbased installed.

Signed-off-by: Samuel Guimarães <sguimaraes943 at gmail.com>
---
 root.py                   |  6 ++++
 ui/js/src/kimchi.peers.js | 71 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 77 insertions(+)
 create mode 100644 ui/js/src/kimchi.peers.js

diff --git a/root.py b/root.py
index 90680b4..cf9a088 100644
--- a/root.py
+++ b/root.py
@@ -67,6 +67,12 @@ class Kimchi(WokRoot):
         self.domain = 'kimchi'
         self.messages = messages
 
+        self.extends = {
+            "/plugins/gingerbase": {
+                "host-dashboard.html": "/plugins/kimchi/js/kimchi.min.js"
+            }
+        }
+
         # Some paths or URI's present in the objectstore have changed after
         # Kimchi 2.0.0 release. Check here if an upgrade in the schema and data
         # are necessary.
diff --git a/ui/js/src/kimchi.peers.js b/ui/js/src/kimchi.peers.js
new file mode 100644
index 0000000..b0dc1cc
--- /dev/null
+++ b/ui/js/src/kimchi.peers.js
@@ -0,0 +1,71 @@
+/*
+ * Project Kimchi
+ *
+ * Copyright IBM Corp, 2013-2016
+ *
+ * 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.initPeers = function() {
+
+    var peersDatatableTable;
+    var peers = new Array();
+
+    var peersAccordion = wok.substitute($('#peersPanel').html());
+    $('#peers-container > div').append(peersAccordion);
+
+    var peersDatatable = function(nwConfigDataSet) {
+        peersDatatableTable = $('#peers-list').DataTable({
+            "processing": true,
+            "data": peers,
+            "language": {
+                "emptyTable": i18n['WOKSETT0010M']
+            },
+            "order": [],
+            "paging": false,
+            "dom": '<"row"<"col-sm-12"t>>',
+            "scrollY": "269px",
+            "scrollCollapse": true,
+            "columnDefs": [{
+                "targets": 0,
+                "searchable": false,
+                "orderable": false,
+                "width": "100%",
+                "className": "tabular-data",
+                "render": function(data, type, full, meta) {
+                    return '<a href="' + data + '" target="_blank">' + data + '</a>';
+                }
+            }],
+            "initComplete": function(settings, json) {
+                $('#peers-content-area > .wok-mask').addClass('hidden');
+            }
+        });
+    };
+
+    var getPeers = function() {
+        kimchi.getPeers(function(result) {
+            peers.length = 0;
+            for (var i = 0; i < result.length; i++) {
+                var tempArr = [];
+                tempArr.push(result[i]);
+                peers.push(tempArr);
+            }
+            peersDatatable(peers);
+        }, function(err) {
+            wok.message.error(err.responseJSON.reason, '#peers-alert-container', true);
+        });
+    };
+
+    kimchi.listPeers = getPeers();
+
+}
-- 
2.5.5




More information about the Kimchi-devel mailing list