| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314 |
- {% extends "layout.html" %}
- {% block title %} Guest {% endblock %}
- {% block head %}
- {{ super() }}
- <style type="text/css">
- .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: #6d6e6f;
- }
- .table-bordered > tbody > tr {
- padding-top: 10px;
- padding-bottom: 10px;
- height: 106px;
- }
- .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;
- }
- </style>
- {% endblock head %}
- {% block content %}
- <script type="text/javascript">
- var page = 1;
- var page_size = 10;
- var keyword = '';
- var cur_url = '/guests';
- $(document).ready(function() {
- page_size = $('#page_size').val();
- cur_url = '/guests?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 = '/guests?page=' + page + '&page_size=' + page_size;
- if (keyword.length > 0) {
- cur_url = '/guests?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 = '/guests?page=' + page + '&page_size=' + page_size;
- if (keyword.length > 0) {
- cur_url = '/guests?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);
- }
- });
- $("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);
- }
- });
- $('body').addClass('add-transition');
- $('.add-page-transition').on('click', function(){
- var transAttr = $(this).attr('data-transition');
- $('.add-transition').attr('class', 'add-transition');
- $('.add-transition').addClass(transAttr);
- });
- $('#edit_remark_modal').on('show.bs.modal', function (me) {
- $('#instance_uuid').val($(me.relatedTarget).parent().parent().prev().prev().text());
- $('#edit_remark').val($(me.relatedTarget).prev().text());
- })
- });
- function refresh() {
- keyword = $('#content_search').val();
- page = $('#pagination li.active a').text();
- page_size = $('#page_size').val();
- cur_url = '/guests?page=' + page + '&page_size=' + page_size;
- if (keyword.length > 0) {
- cur_url = '/guests?page=' + page + '&page_size=' + page_size + '&keyword=' + keyword;
- }
- window.location.href=cur_url;
- }
- function row_onmouseover(me) {
- $(me).find(".edit_remark_trigger").css('display','inline-flex');
- }
- function row_onmouseout(me) {
- $(me).find(".edit_remark_trigger").css('display','none');
- }
- function remark_update(me) {
- var uuid = $('#instance_uuid').val();
- var remark = $('#edit_remark').val();
- $('#edit_remark_modal').modal('hide');
- $.ajax({
- url : '/api/guest/' + uuid,
- type : 'PATCH',
- contentType: "application/json; charset=utf-8",
- data : JSON.stringify({
- remark: remark
- }),
- error : function() {
- insert_warning_window($('#header'), '<strong>更新用户信失败, 请联系管理员! </strong>');
- },
- success : function() {
- $('#guest_list tbody').find('td:contains(' + uuid + ')').next().next().find('label').text(remark)
- }
- });
- }
- </script>
- <div class="panel">
- <div class="panel-body">
- <h3 class="title-hero" style="font-size: 24px;">
- 虚拟机实例
- </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 add-page-transition" href="/guests/create" data-transition="pt-page-moveFromRight-init" style="border-radius: 0; padding-left: 40px; padding-right: 40px;">创建实例</a>
- </div>
- </div>
- </div>
- <table id="guest_list" class="table table-bordered table-hover" cellspacing="0" width="100%" role="grid"
- style="width: 100%; margin-bottom: 0; border-bottom-width: 0;">
- <thead>
- <tr role="row">
- <th style="display: none;">UUID</th>
- <th><input class="all_selector" title="选取所有" type="checkbox"></th>
- <th width="180px;">名称</th>
- <th></th>
- <th>状态</th>
- <th>计算节点</th>
- <th>配置</th>
- <th>IP</th>
- <th>密码</th>
- <th>创建时间</th>
- <th>操作</th>
- </tr>
- </thead>
- <tbody>
- {% for item in guests_ret.data %}
- <tr role="row" class="odd" onmouseover="row_onmouseover(this);" onmouseout="row_onmouseout(this);">
- <td style="display: none;">{{ item.uuid }}</td>
- <td><input title="选中" type="checkbox"></td>
- <td>
- <div>
- <a href="javascript:;">{{ item.name }}</a>
- </div>
- <div>
- <label style="display: inline-block;">{{ item.remark }}</label>
- <a href="javascript:;" class="edit_remark_trigger" data-toggle="modal" data-target="#edit_remark_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><span class="{{ os_template_mapping_by_id[item.os_template_id].icon }}"></span></td>
- <td>{{ format_guest_status(item.status)|safe }}</td>
- <td>{{ item.on_host }}</td>
- <td>CPU : {{ item.cpu }} 核<br />内存 : {{ item.memory }} GB</td>
- <td>{{ item.ip }}</td>
- <td>{{ item.password }}</td>
- <td>{{ format_datetime_by_tus(item.create_time) }}</td>
- <td>
- <div class="dropdown inline-block">
- <a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown">
- 更多
- </a>
- <ul class="dropdown-menu">
- <li>
- <a href="javascript:;">
- <span>启用</span>
- </a>
- </li>
- <li>
- <a href="javascript:;">
- <span>禁用</span>
- </a>
- </li>
- <li class="">
- <a href="javascript:;">
- <span>编辑</span>
- </a>
- </li>
- <li class="">
- <a href="javascript:;">
- <span>密码重置</span>
- </a>
- </li>
- <li class="">
- <a href="javascript:;">
- <span>删除</span>
- </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>
- <th><input type="checkbox" title="选取所有" class="all_selector"></th>
- <th>
- <div class="row">
- <div class="col-sm-8" style="font-size: 12px; padding-top: 5px; text-align: right;">
- 共有{{ guests_ret.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="1" {% if page_size == 1 %} selected {% endif %}>1</option>
- <option value="2" {% if page_size == 2 %} selected {% endif %}>2</option>
- <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> 条
- </div>
- <div class="col-sm-4" 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="/guests?page={{ page - 1 }}&page_size={{ page_size }}{% if keyword %} &keyword={{ keyword }} {% endif %}">«</a>
- </li>
- {% for item in pages %}
- <li class="{% if item == page %} active {% endif %}">
- <a href="/guests?page={{ item }}&page_size={{ page_size }}{% if keyword %} &keyword={{ keyword }} {% endif %}">{{ item }}</a>
- </li>
- {% endfor %}
- <li class="{% if page == last_page %} disabled {% endif %}">
- <a href="/guests?page={{ page + 1 }}&page_size={{ page_size }}{% if keyword %} &keyword={{ keyword }} {% endif %}">»</a>
- </li>
- </ul>
- </div>
- </div>
- </div>
- </th>
- </tr>
- </tfoot>
- </table>
- </div>
- </div>
- </div>
- </div>
- <div class="modal" id="edit_remark_modal" tabindex="-1" role="dialog">
- <div class="modal-dialog modal-sm">
- <div class="modal-content">
- <div class="modal-header">
- <h4 class="modal-title">编辑实例名称:</h4>
- </div>
- <div class="modal-body">
- <input id="instance_uuid" title="实例 UUID" class="form-control" name="uuid" hidden>
- <input id="edit_remark" title="实例名称" class="form-control" name="remark">
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-sm btn-primary" onclick="remark_update();">确定</button>
- <button type="button" class="btn btn-sm btn-default" data-dismiss="modal">取消</button>
- </div>
- </div>
- </div>
- </div>
- {% endblock content %}
|