zhangjiangbin 8 лет назад
Родитель
Сommit
07bcd6eac3

+ 14 - 2
app/Http/Controllers/AdminController.php

@@ -21,7 +21,7 @@ class AdminController extends BaseController
         }
 
         $past = strtotime(date('Y-m-d', strtotime("-3 days")));
-        $online = time() - 600;
+        $online = time() - 3600;
 
         $view['userCount'] = User::count();
         $view['activeUserCount'] = User::where('t', '>=', $past)->count();
@@ -733,7 +733,19 @@ TXT;
             return Redirect::to('admin/userList');
         }
 
-        $view['traffic'] = '';
+        // 30天内的流量
+        $traffic = [];
+        $node_list = SsNode::get();
+        foreach ($node_list as $node) {
+            $trafficList = \DB::select("SELECT date(from_unixtime(log_time)) AS dd, SUM(u) AS u, SUM(d) AS d FROM `user_traffic_log` WHERE `user_id` = {$id} AND `node_id` = {$node->id} GROUP BY `dd`");
+            foreach ($trafficList as $key => &$val) {
+                $val->total = ($val->u + $val->d) / (1024 * 1024); // 以M为单位
+            }
+
+            $traffic[$node->id] = $trafficList;
+        }
+
+        $view['traffic'] = $traffic;
 
         return Response::view('admin/monitor', $view);
     }

+ 3 - 3
readme.md

@@ -20,7 +20,7 @@ telegram:https://t.me/ssrpanel
 建议小白用LNMP先傻瓜安装出php5.6 + mysql(5.5以上)
 然后再编译安装PHP7.1,搭建版本环境
 
-[编译安装PHP7.1.7环境(CentOS)](https://github.com/ssrpanel/ssrpanel/wiki/%E7%BC%96%E8%AF%91%E5%AE%89%E8%A3%85PHP7.1.7%E7%8E%AF%E5%A2%83%EF%BC%88CentOS%EF%BC%89)
+请看WIKI [编译安装PHP7.1.7环境(CentOS)]
 ````
 
 #### 拉取代码
@@ -39,7 +39,7 @@ chmod -R 777 storage/
 mysql 创建一个数据库,然后自行导入sql\db.sql
 config\app.php debug开始或者关闭调试模式
 config\database.php mysql选项自行配置数据库
-确保 storage/framework 下有 cache sessions views 三个目录,并且这个storage 777权限
+确保 storage/framework 下有 cache sessions views 三个目录,且 storage 有777权限
 ````
 
 #### NGINX配置文件加入
@@ -79,7 +79,7 @@ service nginx reload
 4.支持SS多用户json文件一键转换成SSR多用户json文件
 5.支持SSR多用户json文件一键导入数据库
 6.3天内使用过的都算活跃账号
-7.10分钟内使用过的都算在账号
+7.60分钟内使用过的都算在账号
 ````
 
 ![Markdown](http://i4.bvimg.com/1949/aac73bf589fbd785.png)

+ 1 - 1
resources/views/admin/export.blade.php

@@ -36,7 +36,7 @@
                                 <tbody>
                                     @foreach ($nodeList as $node)
                                     <tr>
-                                        <td> {{$node->name}} <small> {{$node->server}} </small> </td>
+                                        <td> {{$node->name}} </td>
                                         <td>
                                             <a class="btn btn-sm green btn-outline" data-toggle="modal" href="#txt_{{$node->id}}"> 文本 </a>
                                             <a class="btn btn-sm green btn-outline" data-toggle="modal" href="#json_{{$node->id}}"> JSON </a>

+ 10 - 5
resources/views/admin/index.blade.php

@@ -15,7 +15,7 @@
         <!-- BEGIN PAGE BASE CONTENT -->
         <div class="row">
             <div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
-                <div class="dashboard-stat2 bordered">
+                <div class="dashboard-stat2 bordered" onclick="skip('admin/userList');">
                     <div class="display">
                         <div class="number">
                             <h3 class="font-green-soft">
@@ -30,7 +30,7 @@
                 </div>
             </div>
             <div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
-                <div class="dashboard-stat2 bordered">
+                <div class="dashboard-stat2 bordered" onclick="skip('admin/userList');">
                     <div class="display">
                         <div class="number">
                             <h3 class="font-green-sharp">
@@ -45,7 +45,7 @@
                 </div>
             </div>
             <div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
-                <div class="dashboard-stat2 bordered">
+                <div class="dashboard-stat2 bordered" onclick="skip('admin/userList');">
                     <div class="display">
                         <div class="number">
                             <h3 class="font-green-sharp">
@@ -62,7 +62,7 @@
         </div>
         <div class="row">
             <div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
-                <div class="dashboard-stat2 bordered">
+                <div class="dashboard-stat2 bordered" onclick="skip('admin/nodeList');">
                     <div class="display">
                         <div class="number">
                             <h3 class="font-blue-sharp">
@@ -77,7 +77,7 @@
                 </div>
             </div>
             <div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
-                <div class="dashboard-stat2 bordered">
+                <div class="dashboard-stat2 bordered" onclick="skip('admin/trafficLog');">
                     <div class="display">
                         <div class="number">
                             <h3 class="font-blue-sharp"> {{$flowCount}} </h3>
@@ -97,4 +97,9 @@
 @section('script')
     <script src="/assets/global/plugins/counterup/jquery.waypoints.min.js" type="text/javascript"></script>
     <script src="/assets/global/plugins/counterup/jquery.counterup.min.js" type="text/javascript"></script>
+    <script type="text/javascript">
+        function skip(url) {
+            window.location.href = url;
+        }
+    </script>
 @endsection

+ 133 - 8
resources/views/admin/monitor.blade.php

@@ -1,9 +1,8 @@
 @extends('admin.layouts')
 
 @section('css')
-    <link href="/assets/global/plugins/datatables/datatables.min.css" rel="stylesheet" type="text/css" />
-    <link href="/assets/global/plugins/datatables/plugins/bootstrap/datatables.bootstrap.css" rel="stylesheet" type="text/css" />
 @endsection
+
 @section('title', '控制面板')
 @section('content')
     <!-- BEGIN CONTENT BODY -->
@@ -22,13 +21,17 @@
         <!-- BEGIN PAGE BASE CONTENT -->
         <div class="row">
             <div class="col-md-12">
-                <!-- BEGIN PORTLET-->
-                <div class="portlet light bordered">
+                <div class="portlet light portlet-fit bordered">
+                    <div class="portlet-title">
+                        <div class="caption">
+                            <i class="icon-settings font-dark"></i>
+                            <span class="caption-subject font-dark sbold uppercase">节点流量(近30天)</span>
+                        </div>
+                    </div>
                     <div class="portlet-body">
-                        、、、
+                        <div id="chart" class="chart"> </div>
                     </div>
                 </div>
-                <!-- END PORTLET-->
             </div>
         </div>
         <!-- END PAGE BASE CONTENT -->
@@ -36,11 +39,133 @@
     <!-- END CONTENT BODY -->
 @endsection
 @section('script')
-    <script src="/assets/global/plugins/jquery-qrcode/jquery.qrcode.min.js" type="text/javascript"></script>
+    <script src="/assets/global/plugins/flot/jquery.flot.min.js" type="text/javascript"></script>
     <script src="/assets/global/plugins/jquery-ui/jquery-ui.min.js" type="text/javascript"></script>
     <script src="/assets/global/plugins/bootbox/bootbox.min.js" type="text/javascript"></script>
 
     <script type="text/javascript">
-        //
+        var ChartsFlotcharts = function() {
+            return {
+                init: function() {
+                    App.addResizeHandler(function() {
+                        Charts.initPieCharts();
+                    });
+                },
+
+                initCharts: function() {
+                    if (!jQuery.plot) {
+                        return;
+                    }
+
+                    function chart() {
+                        if ($('#chart').size() != 1) {
+                            return;
+                        }
+
+                        @if (!empty($traffic))
+                            @foreach ($traffic as $node_id => $node_traffic_list)
+                                {{ 'var node_' . $node_id}} = [
+                                    @foreach ($node_traffic_list as $key => $vo)
+                                        [{{$key + 1}}, {{$vo->total}}],
+                                    @endforeach
+                                ];
+
+                            @endforeach
+                        @endif
+
+                        var plot = $.plot($("#chart"), [
+                            @if (!empty($traffic))
+                                @foreach($traffic as $node_id => $node_traffic_list)
+                                    {data: {{'node_' . $node_id}}, label: "节点{{$node_id}}", lines: {lineWidth: 1}, shadowSize: 0},
+                                @endforeach
+                            @endif
+                            ], {
+                            series: {
+                                lines: {
+                                    show: true,
+                                    lineWidth: 2,
+                                    fill: true,
+                                    fillColor: {
+                                        colors: [{
+                                            opacity: 0.05
+                                        }, {
+                                            opacity: 0.01
+                                        }]
+                                    }
+                                },
+                                points: {
+                                    show: true,
+                                    radius: 3,
+                                    lineWidth: 1
+                                },
+                                shadowSize: 2
+                            },
+                            grid: {
+                                hoverable: true,
+                                clickable: true,
+                                tickColor: "#eee",
+                                borderColor: "#eee",
+                                borderWidth: 1
+                            },
+                            colors: ["#d12610", "#37b7f3", "#52e136"],
+                            xaxis: {
+                                ticks: 11,
+                                tickDecimals: 0,
+                                tickColor: "#eee",
+                            },
+                            yaxis: {
+                                ticks: 11,
+                                tickDecimals: 0,
+                                tickColor: "#eee",
+                            }
+                        });
+
+
+                        function showTooltip(x, y, contents) {
+                            $('<div id="tooltip">' + contents + '</div>').css({
+                                position: 'absolute',
+                                display: 'none',
+                                top: y + 5,
+                                left: x + 15,
+                                border: '1px solid #333',
+                                padding: '4px',
+                                color: '#fff',
+                                'border-radius': '3px',
+                                'background-color': '#333',
+                                opacity: 0.80
+                            }).appendTo("body").fadeIn(200);
+                        }
+
+                        var previousPoint = null;
+                        $("#chart").bind("plothover", function(event, pos, item) {
+                            $("#x").text(pos.x.toFixed(2));
+                            $("#y").text(pos.y.toFixed(2));
+
+                            if (item) {
+                                if (previousPoint != item.dataIndex) {
+                                    previousPoint = item.dataIndex;
+
+                                    $("#tooltip").remove();
+                                    var x = item.datapoint[0].toFixed(2),
+                                        y = item.datapoint[1].toFixed(2);
+
+                                    showTooltip(item.pageX, item.pageY, item.series.label + ": " + y + 'M');
+                                }
+                            } else {
+                                $("#tooltip").remove();
+                                previousPoint = null;
+                            }
+                        });
+                    }
+
+                    chart();
+                }
+            };
+        }();
+
+        jQuery(document).ready(function() {
+            ChartsFlotcharts.init();
+            ChartsFlotcharts.initCharts();
+        });
     </script>
 @endsection