{% extends theme("layout.html") %}
{% block head %}
    {{ super() }}
    <style type="text/css">

        @media (min-width: 768px) {
            .form-horizontal .control-label {
                text-align: left;
            }
        }

        label>span {
            color: deepskyblue;
        }

        .table {
            font-size: 12px;
            border-width: 1px;
            line-height: 20px;
        }
        .table > thead > tr > th,
        .table > tfoot > tr > th {
            color: #999999;
            font-weight: normal;
            border-bottom: 0 solid #e1e6eb;
            background-color: #F5F6FA;
        }
        
        .table > tbody > tr > td {
            color: #424547;
        }

        .table-bordered > tbody > tr {
            padding-top: 10px;
            padding-bottom: 10px;
        }

        .table-bordered > thead > tr > th,
        .table-bordered > tbody > tr > th,
        .table-bordered > tfoot > tr > th,
        .table-bordered > thead > tr > td,
        .table-bordered > tbody > tr > td,
        .table-bordered > tfoot > tr > td {
            border-style: solid;
            border-width: 1px 0 0 0;
        }

        .btn,
        .form-control,
        .modal-content {
            border-radius: 0 !important;
        }

        .btn-shortcut {
            font-size: 12px !important;
            padding: 0 26px;
        }

        .show {
            display: inline-block !important;
        }

        .tr-selected td,
        .tr-selected {
            color: #000 !important;
            background: #fafaff !important;
        }
    </style>
{% endblock head %}
{% block content %}

<script type="text/javascript">
    var page = 1;
    var page_size = 10;
    var keyword = '';
    var resource_path = window.location.pathname;
    var cur_url = resource_path;

    $(document).ready(function() {
        page_size = $('#page_size').val();
        cur_url = resource_path + '?page=' + page + '&page_size=' + page_size;

        var last_ready = null;
        $('#content_search').keydown(function() {
            if (last_ready !== null) {
                clearTimeout(last_ready);
            }
            last_ready = setTimeout(function () {
                keyword = $('#content_search').val();
                cur_url = resource_path + '?page=' + page + '&page_size=' + page_size;
                if (keyword.length > 0) {
                    cur_url = resource_path + '?page=' + page + '&page_size=' + page_size + '&keyword=' + keyword;
                }
                window.location.href=cur_url;
            }, 1000);
        });

        $('#page_size').change(function () {
            keyword = $('#content_search').val();
            page_size = $('#page_size').val();
            cur_url = resource_path + '?page=' + page + '&page_size=' + page_size;
            if (keyword.length > 0) {
                cur_url = resource_path + '?page=' + page + '&page_size=' + page_size + '&keyword=' + keyword;
            }
            window.location.href=cur_url;
        });

        $("thead").on('click', ".all_selector", function() {
            if ($("thead .all_selector").is(':checked')) {
                $("tbody tr").find('td input[type="checkbox"]:eq(0)').prop('checked', true);
                $(".all_selector").prop('checked', true);
            } else {
                $("tbody tr").find('td input[type="checkbox"]:eq(0)').prop('checked', false);
                $(".all_selector").prop('checked', false);
            }

            select_item_action();
        });

        $("tfoot").on('click', ".all_selector", function() {
            if ($("tfoot .all_selector").is(':checked')) {
                $("tbody tr").find('td input[type="checkbox"]:eq(0)').prop('checked', true);
                $(".all_selector").prop('checked', true);
            } else {
                $("tbody tr").find('td input[type="checkbox"]:eq(0)').prop('checked', false);
                $(".all_selector").prop('checked', false);
            }

            select_item_action();
        });

        $("tbody tr").on('click', "input[type='checkbox']", function() {
            select_item_action();
        });

        $('#edit_label_modal').on('show.bs.modal', function (me) {
            $('#ssh_key_id').val($(me.relatedTarget).parent().parent().prev().prev().text());
            $('#edit_label').val($(me.relatedTarget).prev().text());
        });

        $('#edit_public_key_modal').on('show.bs.modal', function (me) {
            $('#ssh_key_id').val($(me.relatedTarget).parent().parent().prev().prev().prev().prev().text());
            $('#edit_public_key').val($(me.relatedTarget).prev().text());
        });

        $('#add_ssh_key_modal').on('show.bs.modal', function (me) {
            //
        });

        $('#ssh_key_bind_modal').on('show.bs.modal', function (me) {
            refresh_multi_selector($('#bind_multi_selector'), false);
        });

        $('#ssh_key_unbind_modal').on('show.bs.modal', function (me) {
            refresh_multi_selector($('#unbind_multi_selector'), true);
        });

        $('#add_ssh_key_form').formValidation({
            framework: 'bootstrap4',
            icon: {
                valid: 'fa fa-check',
                invalid: 'fa fa-times',
                validating: 'fa fa-refresh'
            },
            // Since the Bootstrap Button hides the radio and checkbox
            // We exclude the disabled elements only
            excluded: ':disabled',
            locale: 'zh_CN',
            fields: {
                label: {
                    validators: {
                        notEmpty: {},
                        stringLength: {
                            min: 2,
                            max: 255
                        }
                    }
                },
                public_key: {
                    validators: {
                        notEmpty: {},
                        stringLength: {
                            min: 200,
                            max: 1000
                        }
                    }
                }
            }
        })
        .on('success.field.fv', function(e, data) {
            if (data.fv.getInvalidFields().length > 0) {    // There is invalid field
                data.fv.disableSubmitButtons(true);
            }
        }).on('success.form.fv', function (e, data) {
            create();
        });

        init_multi_selector($('#bind_multi_selector'));
        init_multi_selector($('#unbind_multi_selector'));
    });

    function refresh() {
        keyword = $('#content_search').val();
        page = $('#pagination li.active a').text();
        page_size = $('#page_size').val();
        cur_url = resource_path + '?page=' + page + '&page_size=' + page_size;
        if (keyword.length > 0) {
            cur_url = resource_path + '?page=' + page + '&page_size=' + page_size + '&keyword=' + keyword;
        }
        window.location.href=cur_url;
    }

    function row_onmouseover(me) {
        $(me).find(".edit_label_trigger, .edit_path_trigger").css('display','inline-flex');
    }

    function row_onmouseout(me) {
        $(me).find(".edit_label_trigger, .edit_path_trigger").css('display','none');
    }

    function label_update(me) {
        var ssh_key_id = $('#ssh_key_id').val();
        var label = $('#edit_label').val();
        $('#edit_label_modal').modal('hide');
        $.ajax({
            url : '/api/ssh_keys/' + ssh_key_id,
            type : 'PATCH',
            contentType: "application/json; charset=utf-8",
            data : JSON.stringify({
                label: label
            }),
            error : function() {
                alter_danger('SSH Key 名称更新失败！');
            },
            success : function() {
                alter_success('SSH Key 名称更新成功！');
                setTimeout(function() {
                    refresh();
                }, 1000);
            }
        });
    }

    function public_key_update(me) {
        var ssh_key_id = $('#ssh_key_id').val();
        var public_key = $('#edit_public_key').val();
        $('#edit_public_key_modal').modal('hide');
        $.ajax({
            url : '/api/ssh_keys/' + ssh_key_id,
            type : 'PATCH',
            contentType: "application/json; charset=utf-8",
            data : JSON.stringify({
                public_key: public_key
            }),
            error : function() {
                alter_danger('Public Key 更新失败！');
            },
            success : function() {
                alter_success('Public Key 更新成功！');
                setTimeout(function() {
                    refresh();
                }, 1000);
            }
        });
    }

    function get_selected_element(checked) {
        if (checked === null) {
            checked = true;
        }

        if (checked) {
            return $('tbody :checked');
        } else {

            return $('tbody input:not(:checked)');
        }
    }
    
    function highlight_selected_element() {
        var selected_element = get_selected_element(true);
        var no_selected_element = get_selected_element(false);

        selected_element.each(function(i, e) {
            $(e).parent().parent().toggleClass('tr-selected', true);
        });

        no_selected_element.each(function(i, e) {
            $(e).parent().parent().toggleClass('tr-selected', false);
        });
    }
    
    function shortcut_bar_enable() {
        var selected_element = get_selected_element(true);

        if (selected_element.length > 0) {
            $('.btn-shortcut').toggleClass('disabled', false);
        } else {
            $('.btn-shortcut').toggleClass('disabled', true);
        }
    }

    function select_item_action() {
        highlight_selected_element();
        shortcut_bar_enable();
    }

    function remove(id) {
        $.ajax({
            url : '/api/ssh_keys/' + id,
            type : 'DELETE',
            contentType: "application/json; charset=utf-8",
            error : function() {
                alter_danger('SSH Key 删除指令发送失败！');
            },
            success : function() {
                alter_success('SSH Key 删除指令发送成功！');
                setTimeout(function() {
                    refresh();
                }, 1000);
            }
        });
    }

    function delete_at(me) {
        var ssh_key_id = $('#ssh_key_id').val();
        remove(ssh_key_id);
        $('#delete_modal').modal('hide');
    }

    function bind_unbind_button_disable(multi_selector) {

        var the_button = $('#ssh_key_bind_button');
        if (multi_selector.attr('id') !== 'bind_multi_selector'){
            the_button = $('#ssh_key_unbind_button');
        }

        if (multi_selector.val() !== null) {
            the_button.removeAttr('disabled');
        } else {
            the_button.prop('disabled', 'true');
        }
    }

    function init_multi_selector(multi_selector) {

        multi_selector.multiSelect({
            selectableHeader: "<input type='text' class='form-control' autocomplete='off' placeholder='关键字查找...'>",
            selectionHeader: "<input type='text' class='form-control' autocomplete='off' placeholder='关键字查找...'>",
            afterInit: function(ms){
                var that = this,
                    $selectableSearch = that.$selectableUl.prev(),
                    $selectionSearch = that.$selectionUl.prev(),
                    selectableSearchString = '#'+that.$container.attr('id')+' .ms-elem-selectable:not(.ms-selected)',
                    selectionSearchString = '#'+that.$container.attr('id')+' .ms-elem-selection.ms-selected';

                ms.css({ width: '100%' });

                that.qs1 = $selectableSearch.quicksearch(selectableSearchString)
                    .on('keydown', function(e){
                        if (e.which === 40){
                            that.$selectableUl.focus();
                            return false;
                        }
                    });

                that.qs2 = $selectionSearch.quicksearch(selectionSearchString)
                    .on('keydown', function(e){
                        if (e.which == 40){
                            that.$selectionUl.focus();
                            return false;
                        }
                    });
            },
            afterSelect: function(){
                this.qs1.cache();
                this.qs2.cache();

                bind_unbind_button_disable(multi_selector);
            },
            afterDeselect: function(){
                this.qs1.cache();
                this.qs2.cache();

                bind_unbind_button_disable(multi_selector);
            }
        });
    }
    
    function refresh_multi_selector(multi_selector, is_bound) {
        var ssh_key_id = $('#ssh_key_id').val();
        var url = '/api/ssh_key/_bound/';
        if (!is_bound) {
            url = '/api/ssh_key/_unbound/';
        }

        $.ajax({
            url : url + ssh_key_id,
            type : 'GET',
            async: false,
            contentType: "application/json; charset=utf-8",
            dataType: 'json',
            error : function() {
                alter_danger('获取 SSH-Key 绑定信息失败！');
            },
            success : function(data, textStatus, xhr) {
                multi_selector.empty();
                var subtext = '';
                $.each(data.data, function(k, v) {
                    subtext = v['remark'];
                    if (subtext === '') {
                        subtext = v['ip']
                    }
                    multi_selector.multiSelect('addOption', {value: v['uuid'], text: v['label'] + ' / ' + subtext});
                });
                multi_selector.multiSelect('refresh');
            }
        });

        bind_unbind_button_disable(multi_selector);
    }

    function ssh_key_bind() {
        $('#ssh_key_bind_modal').modal('hide');

        var ssh_key_id = $('#ssh_key_id').val();
        var uuids = $('#bind_multi_selector').val();
        var url = '/api/ssh_key/_bind/';

        $.ajax({
            url : url + ssh_key_id + '/' + uuids.join(','),
            type : 'PUT',
            contentType: "application/json; charset=utf-8",
            dataType: 'json',
            error : function() {
                alter_danger('绑定 SSH-Key 失败！');
            },
            success : function(data, textStatus, xhr) {
                alter_success('绑定 SSH-Key 成功！');
            }
        });
    }

    function ssh_key_unbind() {
        $('#ssh_key_unbind_modal').modal('hide');

        var ssh_key_id = $('#ssh_key_id').val();
        var uuids = $('#unbind_multi_selector').val();
        var url = '/api/ssh_key/_unbind/';

        $.ajax({
            url : url + ssh_key_id + '/' + uuids.join(','),
            type : 'PUT',
            contentType: "application/json; charset=utf-8",
            dataType: 'json',
            error : function() {
                alter_danger('解绑 SSH-Key 失败！');
            },
            success : function(data, textStatus, xhr) {
                alter_success('解绑 SSH-Key 成功！');
            }
        });
    }

    function create() {
        $('#add_ssh_key_modal').modal('hide');

        var data = {
            label: $('#label').val(),
            public_key: $('#public_key').val()
        };

        var go_back_url = '/ssh_keys';

        $.ajax({
            url : '/api/ssh_key',
            type : 'POST',
            contentType: "application/json; charset=utf-8",
            async: false,
            dataType: "json",
            data : JSON.stringify(data),
            error : function(data, textStatus, xhr) {
                alter_warning('添加 SSH Key 失败！');
                alter_danger(data.responseText);
            },
            success : function(data, textStatus, xhr) {
                alter_success('您所提交的 SSH Key 已创建。页面将在3秒钟后自动跳转到模板列表页面！');
            }
        });

        setTimeout(function() {
            window.location.href=go_back_url;
        }, 3000);
    }
</script>
<div class="panel">
    <div class="panel-body">
        <h3 class="title-hero" style="font-size: 24px;">
            SSH Keys
        </h3>
        <div>
            <div id="datatable-row-highlight_wrapper" class="dataTables_wrapper form-inline">
                <div class="row" style="padding: 10px 10px 10px 0; width: 100%;">
                    <div class="col-sm-12" style="padding-right: 0;">
                        <div id="datatable-row-highlight_filter" class="dataTables_filter" style="display: inline-block;">
                            <input id="content_search" type="search" class="form-control" placeholder="模糊搜索..." value="{%- if keyword -%} {{ keyword }} {%- endif -%}" style="margin-left: 0; border-radius: 0;">
                        </div>
                        <div class="pull-right">
                            <button class="btn btn-default" onclick="refresh()" style="border-radius: 0;"><span class="glyph-icon icon-elusive-arrows-cw"></span></button>
                            <a class="btn btn-info" href="javascript:;" data-toggle="modal" data-target="#add_ssh_key_modal" style="border-radius: 0; padding-left: 40px; padding-right: 40px;">添加 SSH Key</a>
                        </div>
                    </div>
                </div>
                <table id="ssh_keys_list" class="table table-bordered table-hover" cellspacing="0" width="100%" role="grid"
                       style="width: 100%; margin-bottom: 0; border-bottom-width: 0; table-layout: fixed;">
                <thead>
                <tr role="row">
                    <th style="display: none;">ID</th>
                    <th><input class="all_selector" title="选取所有" type="checkbox"></th>
                    <th width="180px;">名称</th>
                    <th width="480px;">Public Key</th>
                    <th>创建时间</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                {% for item in ssh_keys %}
                <tr role="row" class="odd" onmouseover="row_onmouseover(this);" onmouseout="row_onmouseout(this);">
                    <td style="display: none;">{{ item.id }}</td>
                    <td><input title="选中" type="checkbox"></td>
                    <td>
                        <div>
                            <p style="display: inline-block;">{{ item.label }}</p>
                            <a href="javascript:;" class="edit_label_trigger" data-toggle="modal" data-target="#edit_label_modal" style="display: none; float: right;">
                                <span class="glyph-icon icon-elusive-pencil" style="width: 20px; height: 20px; margin-left: 10px; border-radius: 0; border: 1px solid rgb(220, 233, 255); background-color: #ffffff;"></span>
                            </a>
                        </div>
                    </td>
                    <td class="text-left" style="text-overflow: ellipsis; overflow: hidden;">
                        {{ item.public_key }}
                    </td>
                    <td>
                        {{ format_datetime_by_tus(item.create_time * 1000000) }}
                    </td>
                    <td>
                        <div class="dropdown inline-block">
                            <a href="javascript:;" style="color: #0066cc" data-toggle="modal" data-target="#ssh_key_bind_modal" onclick="$('#ssh_key_id').val($(this).parent().parent().parent().children()[0].textContent)">绑定</a>
                            <span> | </span>
                            <a href="javascript:;" style="color: #0066cc" data-toggle="modal" data-target="#ssh_key_unbind_modal" onclick="$('#ssh_key_id').val($(this).parent().parent().parent().children()[0].textContent)">解绑</a>
                            <span> | </span>
                            <a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown">
                                更多
                            </a>
                            <ul class="dropdown-menu">
                                <li>
                                    <a href="javascript:;" data-toggle="modal" data-target="#delete_modal"
                                       onclick="$('#ssh_key_id').val($(this).parent().parent().parent().parent().parent().children()[0].textContent);
                                       $('#delete_instance_desc').text($(this).parent().parent().parent().parent().parent().children()[2].textContent)">
                                        删除
                                    </a>
                                </li>
                            </ul>
                        </div>
                    </td>
                </tr>
                {% endfor %}
                </tbody>
                </table>

                <table class="table table-bordered" style="border-top-width: 0; z-index: 99; position: sticky; bottom: 0;">
                    <tfoot>
                    <tr style="height: 70px;">
                        <th><input type="checkbox" title="选取所有" class="all_selector"></th>
                        <th>
                            <div class="row">
                                <div class="col-sm-6">
                                </div>
                                <div class="col-sm-3" style="font-size: 12px; padding-top: 5px; text-align: right;">
                                    共有{{ paging.total }}条，每页显示：
                                    <select id="page_size" name="datatable-row-highlight_length" title="page_size" class="form-control" style="height: 22px; vertical-align: baseline;">
                                        <option value="10" {% if page_size == 10 %} selected {% endif %}>10</option>
                                        <option value="20" {% if page_size == 20 %} selected {% endif %}>20</option>
                                        <option value="50" {% if page_size == 50  %} selected {% endif %}>50</option>
                                    </select>&nbsp;&nbsp;条
                                </div>
                                <div class="col-sm-3" style="text-align: left;">
                                    <div class="dataTables_paginate paging_bootstrap" id="datatable-row-highlight_paginate">
                                        <ul id="pagination" class="pagination">
                                            <li class="{% if page == 1 %} disabled {% endif %}">
                                                <a href="{{ resource_path }}?page={{ page - 1 }}&page_size={{ page_size }}{% if keyword %}&keyword={{ keyword }}{% endif %}{% if order_by %}&order_by={{ order_by }}{% endif %}{% if order %}&order={{ order }}{% endif %}">«</a>
                                            </li>
                                            {% for item in pages %}
                                            <li class="{% if item == page %} active {% endif %}">
                                                <a href="{{ resource_path }}?page={{ item }}&page_size={{ page_size }}{% if keyword %}&keyword={{ keyword }}{% endif %}{% if order_by %}&order_by={{ order_by }}{% endif %}{% if order %}&order={{ order }}{% endif %}">{{ item }}</a>
                                            </li>
                                            {% endfor %}
                                            <li class="{% if page == last_page %} disabled {% endif %}">
                                                <a href="{{ resource_path }}?page={{ page + 1 }}&page_size={{ page_size }}{% if keyword %}&keyword={{ keyword }}{% endif %}{% if order_by %}&order_by={{ order_by }}{% endif %}{% if order %}&order={{ order }}{% endif %}">»</a>
                                            </li>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </th>
                    </tr>
                    </tfoot>
                </table>
            </div>
        </div>
    </div>
</div>

<input id="ssh_key_id" title="SSH Key ID" class="form-control" name="ssh_key_id" hidden>

<div class="modal" id="edit_label_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title">编辑 SSH Key 名称：</h4>
            </div>
            <div class="modal-body">
                <input id="edit_label" title="SSH Key 名称" class="form-control" name="ssh_key_label">
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-sm btn-primary" onclick="label_update();">确定</button>
                <button type="button" class="btn btn-sm btn-default" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>

<div class="modal" id="edit_public_key_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title">编辑 SSH Key：</h4>
            </div>
            <div class="modal-body">
                <input id="edit_public_key" title="Public Key" class="form-control" name="public_key">
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-sm btn-primary" onclick="public_key_update();">确定</button>
                <button type="button" class="btn btn-sm btn-default" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>

<div class="modal" id="delete_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title">删除 SSH Key：</h4>
            </div>
            <div class="modal-body">
                <p>您确定要删除该 SSH Key 吗？</p>
                <h3 style="color: orangered;" id="delete_instance_desc"></h3>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-sm btn-primary" onclick="delete_at();">确定</button>
                <button type="button" class="btn btn-sm btn-default" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>

<div class="modal" id="add_ssh_key_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title">添加 SSH Key：</h4>
            </div>
            <div class="modal-body" style="padding-top: 0; padding-bottom: 0;">
                <div class="example-box-wrapper">
                    <form id="add_ssh_key_form" class="form-horizontal bordered-row" action="javascript:;">
                        <div class="form-group">
                            <div class="col-sm-2"></div>
                            <label class="col-sm-2 control-label"><span class="glyph-icon icon-elusive-compass-circled"></span>&nbsp;&nbsp;名称</label>
                            <div class="col-sm-6">
                                <input id="label" name="label" type="text" title="SSH Key 名称" class="form-control">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-2"></div>
                            <label class="col-sm-2 control-label"><span class="glyph-icon icon-key"></span>&nbsp;&nbsp;Public Key</label>
                            <div class="col-sm-6">
                                <textarea id="public_key" name="public_key" title="Public key" class="form-control"></textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-4"></div>
                            <div class="col-sm-6 pull-right">
                                <button type="submit" class="btn btn-blue-alt" style="width: 180px; height: 40px; font-size: 16px;" disabled>创建</button>
                                <button class="btn btn-default" style="width: 64px; height: 40px; font-size: 16px;" data-dismiss="modal">取消</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="modal" id="ssh_key_bind_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title">绑定 SSH Key：</h4>
            </div>
            <div class="modal-body" style="padding-top: 0; padding-bottom: 0;">
                <div class="example-box-wrapper">
                    <form id="ssh_key_bind_form" class="form-horizontal bordered-row" action="javascript;">
                        <div class="form-group">
                            <div class="col-sm-1"></div>
                            <div class="col-sm-10">
                                <select id='bind_multi_selector' multiple='multiple' title="绑定 SSH-Key">
                                </select>
                            </div>
                            <div class="col-sm-1"></div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-4"></div>
                            <div class="col-sm-6 pull-right">
                                <button id="ssh_key_bind_button" type="button" class="btn btn-blue-alt" style="width: 180px; height: 40px; font-size: 16px;" disabled onclick="ssh_key_bind(this);">绑定</button>
                                <button class="btn btn-default" style="width: 64px; height: 40px; font-size: 16px;" data-dismiss="modal">取消</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="modal" id="ssh_key_unbind_modal" tabindex="-1" role="dialog" style="margin-top: 100px;">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title">解绑 SSH Key：</h4>
            </div>
            <div class="modal-body" style="padding-top: 0; padding-bottom: 0;">
                <div class="example-box-wrapper">
                    <form id="ssh_key_unbind_form" class="form-horizontal bordered-row" action="javascript;">
                        <div class="form-group">
                            <div class="col-sm-1"></div>
                            <div class="col-sm-10">
                                <select id='unbind_multi_selector' multiple='multiple' title="解绑 SSH Key">
                                </select>
                            </div>
                            <div class="col-sm-1"></div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-4"></div>
                            <div class="col-sm-6 pull-right">
                                <button id="ssh_key_unbind_button" type="button" class="btn btn-blue-alt" style="width: 180px; height: 40px; font-size: 16px;" disabled onclick="ssh_key_unbind(this);">解绑</button>
                                <button class="btn btn-default" style="width: 64px; height: 40px; font-size: 16px;" data-dismiss="modal">取消</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock content %}
