123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234 |
- <div class="row">
- <div class="col-md-12">
- <div class="tile">
- <div class="tile-body">
- <table class="table table-hover table-bordered" id="sampleTable">
- <thead>
- <tr>
- <th>Id</th>
- <th>验证密钥</th>
- <th>客户端地址</th>
- <th>备注</th>
- <th>压缩方式</th>
- <th>加密</th>
- <th>多路复用</th>
- <th>用户名</th>
- <th>密码</th>
- <th>状态</th>
- <th>客户端连接状态</th>
- <th>出口流量</th>
- <th>入口流量</th>
- <th>操作</th>
- </tr>
- </thead>
- <tbody>
- </tbody>
- </table>
- </div>
- </div>
- </div>
- </div>
- </main>
- <script type="text/javascript">
- function del(id) {
- if (confirm("确定要删除数据吗?")) {
- $.ajax({
- type: "POST",
- url: "/client/del",
- data: {"id": id},
- success: function (res) {
- alert(res.msg)
- if (res.status) {
- document.location.reload();
- }
- }
- })
- }
- }
- function start(id) {
- if (confirm("确定要开始任务吗?")) {
- $.ajax({
- type: "POST",
- url: "/client/changestatus",
- data: {"id": id, "status": 1},
- success: function (res) {
- alert(res.msg)
- if (res.status) {
- document.location.reload();
- }
- }
- })
- }
- }
- function stop(id) {
- if (confirm("确定要暂停吗?")) {
- $.ajax({
- type: "POST",
- url: "/client/changestatus",
- data: {
- "id": id, "status": 0
- },
- success:
- function (res) {
- alert(res.msg)
- if (res.status) {
- document.location.reload();
- }
- }
- })
- }
- }
- function edit(id) {
- window.location.href = "/client/edit?id=" + id
- }
- function add() {
- window.location.href = "/client/add"
- }
- function show_tunnel_list(id) {
- window.location.href = "/index/all?client_id=" + id
- }
- function show_host_list(id) {
- window.location.href = "/index/hostlist?client_id=" + id
- }
- $(document)
- .ready(function () {
- var table = $('#sampleTable').DataTable({
- responsive: {
- details: {
- display: $.fn.dataTable.Responsive.display.childRowImmediate
- }
- },
- dom: 'Bfrtip',
- processing: true,
- serverSide: true,
- autoWidth: false,
- ordering: false,
- ajax: {
- url: '/client/client',
- type: 'POST'
- },
- dom: '<"top"fl><"toolbar">rt<"bottom"ip><"clear">',
- columns: [ //这个是显示到界面上的个数据 格式为 {data:'显示的字段名'}
- {data: 'Id'},
- {data: 'VerifyKey'},
- {data: "Addr"},
- {data: "Remark"},
- {data: "Addr"},
- {data: "Addr"},
- {data: "Addr"},
- {data: "Addr"},
- {data: "Remark"},
- {data: "Status"},
- {data: "IsConnect"},
- {data: "Addr"},
- {data: "Addr"},
- {data: ""},
- ],
- bFilter: false,
- columnDefs: [{
- targets: -1,
- render: function (data, type, row, meta) {
- if (row.Status == true) {
- btn = "<button onclick=\"stop('" + row.Id + "')\" class=\"btn btn-secondary btn-sm\" type=\"button\">关闭</button>"
- } else {
- btn = "<button onclick=\"start('" + row.Id + "')\" class=\"btn btn-success btn-sm\" type=\"button\">打开</button>"
- }
- btn_del = '<button onclick="del(\'' + row.Id + '\')" class="btn btn-danger btn-sm">删除</button> '
- btn_edit = '<button onclick="edit(\'' + row.Id + '\')" class="btn btn-primary btn-sm">查看编辑</button> '
- btn_list = '<button onclick="show_tunnel_list(\'' + row.Id + '\')" class="btn btn-info btn-sm">隧道</button> '
- btn_host = '<button onclick="show_host_list(\'' + row.Id + '\')" class="btn btn-info btn-sm">域名</button> '
- return '<div class="btn-group" role="group" aria-label="..."> ' + btn + btn_del + btn_edit + btn_host + btn_list + '</div>'
- }
- },
- {
- targets: -5,
- render: function (data, type, row, meta) {
- if (data == false) {
- return "<span class=\"badge badge-pill badge-secondary\">暂停</span>"
- } else {
- return "<span class=\"badge badge-pill badge-success\">正常</span>"
- }
- }
- },
- {
- targets: -4,
- render: function (data, type, row, meta) {
- if (data == false) {
- return "<span class=\"badge badge-pill badge-secondary\">未连接</span>"
- } else {
- return "<span class=\"badge badge-pill badge-success\">已连接</span>"
- }
- }
- },
- {
- targets: -2,
- render: function (data, type, row, meta) {
- return change(row.Flow.InletFlow)
- }
- },
- {
- targets: -3,
- render: function (data, type, row, meta) {
- return change(row.Flow.ExportFlow)
- }
- },
- {
- targets: -6,
- render: function (data, type, row, meta) {
- return row.Cnf.P
- }
- },
- {
- targets: -7,
- render: function (data, type, row, meta) {
- return row.Cnf.U
- }
- },
- {
- targets: -8,
- render: function (data, type, row, meta) {
- if (row.Cnf.Mux == "0") {
- return "不启用"
- } else {
- return "启用"
- }
- }
- }
- ,
- {
- targets: -9,
- render: function (data, type, row, meta) {
- if (row.Cnf.Crypt == "0") {
- return "不加密"
- } else {
- return "加密"
- }
- }
- }
- ,
- {
- targets: -10,
- render: function (data, type, row, meta) {
- return row.Cnf.Compress
- }
- }
- ],
- buttons: []
- });
- $("#sampleTable_length").html('<button class="btn btn-primary" onclick="add()" type="button">新增</button>')
- })
- ;
- </script>
|