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

Aline Manera alinefm at linux.vnet.ibm.com
Wed Aug 31 16:26:42 UTC 2016



On 08/30/2016 04:19 PM, sguimaraes943 at gmail.com wrote:
> 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/kimchi.peers.js   | 145 ++++++++++++++++++++++++++++++++++++++++++++++++
>   ui/js/src/kimchi.api.js |  14 -----
>   ui/pages/i18n.json.tmpl |   4 +-
>   4 files changed, 154 insertions(+), 15 deletions(-)
>   create mode 100644 ui/js/kimchi.peers.js
>
> diff --git a/root.py b/root.py
> index 90680b4..faa9eb9 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.peers.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/kimchi.peers.js b/ui/js/kimchi.peers.js
> new file mode 100644
> index 0000000..36ac867
> --- /dev/null
> +++ b/ui/js/kimchi.peers.js
> @@ -0,0 +1,145 @@
> +/*
> + * 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.
> + */
> +
> +var kimchi = {
> +
> +    getPeers: function(suc, err) {
> +        wok.requestJSON({
> +            url: 'plugins/kimchi/peers',
> +            type: 'GET',
> +            contentType: 'application/json',
> +            dataType: 'json',
> +            resend: true,
> +            success: suc,
> +            error: err ? err : function(data) {
> +                wok.message.error(data.responseJSON.reason);
> +            }
> +        });
> +    },
> +
> +    initPeers: function() {
> +
> +        var peersAccordion = "<div class='panel-group federation-enabled accordion' id='peers-content-area-accordion' role='tablist' aria-multiselectable='true'>" +
> +            "<h3>" +
> +            "<a role='button' aria-expanded='true' data-toggle='collapse' data-parent='#peers-content-area-accordion' href='#peers-content-area' aria-expanded='false' aria-controls='peers-content-area' class=''>" +
> +            "<span class='accordion-icon'></span>" +
> +            "<span class='accordion-text' id='#peers-title'>"+i18n['KCHPEERS0001M']+"</span>" +
> +            "</a>" +
> +            "</h3>" +
> +            "<div id='peers-content-area' class='panel-collapse collapse in' role='tabpanel' aria-labelledby='peers-title'>" +
> +            "<div id='peers-alert-container'></div>" +
> +            "<div class='row'>" +
> +            "<div class='col-sm-12'>" +
> +            "<table id='peers-list' class='table table-striped' cellspacing='0' width='100%''>" +
> +            "<thead>" +
> +            "<tr>" +
> +            "<th>" + i18n['KCHPEERS0001M'] + "</th>" +
> +            "</tr>" +
> +            "</thead>" +
> +            "</table>" +
> +            "</div>" +
> +            "</div>" +
> +            "<div class='wok-mask' role='presentation'>" +
> +            "<div class='wok-mask-loader-container'>" +
> +            "<div class='wok-mask-loading'>" +
> +            "<div class='wok-mask-loading-icon'></div>" +
> +            "<div class='wok-mask-loading-text'>" + i18n['WOKGRD6001M'] + "</div>" +
> +            "</div>" +
> +            "</div>" +
> +            "</div>" +
> +            "</div>" +
> +            "</div>";
> +
> +        var peersDatatableTable;
> +        var peers = new Array();
> +

> +        $('#peers-container > div').append(peersAccordion);
> +

The peers-container should not be part of the Ginger Base HTML code.
Instead of that, you will need to append a new div to "peers-container" 
to the "host-root-container"

Something like:

$('#host-root-container').append("<div id="peers-container" 
class="empty-when-logged-off"> <div class="container"></div> </div> ")

And then you can manipulate the peers-container.

That way the Ginger Base code will only contain code related to Ginger 
Base features.

>




More information about the Kimchi-devel mailing list