ssr_degrade.hbs 2.79 KB
<div class="pageheader">
    <div class="media">
        <div class="pageicon pull-left">
            <i class="fa fa-th-list"></i>
        </div>
        <div class="media-body">
            <ul class="breadcrumb">
                <li><a href="/"><i class="glyphicon glyphicon-home"></i></a></li>
                <li>SSR自适应降级</li>
            </ul>
            <h4>配置列表</h4>
        </div>
    </div>
    <!-- media -->
</div>
<style>
  .degrades-ul {
    list-style: none;
    margin: 0;
    padding: 0;
  }
</style>
<!-- pageheader -->
<style>
  .li-degrade, .td-degrade {
    color: red;
  }
</style>
<div class="contentpanel servers-page">
    <button type="button" class="btn btn-success add">新增配置</button>
    <table class="table table-hover table-striped table-bordered" style="margin-top: 2rem">
        <thead>
            <tr>
                <th>应用名称</th>
                <th>降级条件</th>
                <th>状态</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            {{#list}}
                <tr>
                    <td>{{app}}</td>
                    <td>
                      <ul class="degrades-ul">
                        {{#degrades}}
                        <li class="{{#if status}}li-degrade{{/if}}">
                          {{time}}秒内平均qps大于{{tick}}{{delay}}分钟内未触发则恢复{{#if status}}-[已触发]{{/if}}
                        </li>
                        {{/degrades}}
                      </ul>
                    </td>
                    <td class="{{#if status}}td-degrade{{/if}}">{{#if status}}已降级{{^}}正常{{/if}}</td>
                    <td><button data-app="{{app}}" type="button" class="btn btn-success edit">编辑</button><button data-app="{{app}}" type="button" class="btn btn-danger ml10 del">删除</button></td>
                </tr>
            {{/list}}

            {{#if noData}}
                <tr>
                    <td colspan="4" class="text-center">无数据</td>
                </tr>
            {{/if}}
        </tbody>
    </table>
</div>

<script>
    $('.add').on('click', function() {
        location.href = '/ssr_degrade/edit';
    });

    $('.del').on('click', function() {
        var app = $(this).data('app');

        var confirmed = confirm('是否删除?')

        if (confirmed) {
          $.get('/ssr_degrade/delete', {
              app
          }, function(ret) {
              if (ret.code === 200) {
                  alert('删除成功!');
                  location.reload();
              } else {
                  alert('删除失败!');
              }
          });
        }
    });

    $('.edit').on('click', function() {
        var app = $(this).data('app');

        location.href = '/ssr_degrade/edit?app=' + app;
    });
</script>