From cc861e70573b1f1079b44b8e0aa599bfe36328d7 Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Tue, 25 Sep 2018 16:37:56 +0800 Subject: [PATCH] up --- README.md | 1 + main.py | 3 +- models/index.html | 1 + plugins/index.html | 1 + requirements.txt | 3 +- static/js/files.js | 2 +- templates/default/files.html | 155 ++++++++++++++++++----------------- templates/default/index.html | 39 ++++----- test/index.html | 1 + views/__init__.py | 1 + views/dashboard.py | 31 ++++++- views/files.py | 16 ++++ 12 files changed, 152 insertions(+), 102 deletions(-) create mode 100644 models/index.html create mode 100644 plugins/index.html create mode 100644 test/index.html create mode 100644 views/files.py diff --git a/README.md b/README.md index a32abc4c8..74eb866c3 100644 --- a/README.md +++ b/README.md @@ -10,4 +10,5 @@ curl -fsSL https://raw.githubusercontent.com/midoks/mdweb/master/install/instal - pip install pip==9.0.3 - pip install flask - pip install gunicorn +- pip install psutil - pip install -r requirements.txt diff --git a/main.py b/main.py index 062704129..9518f82c7 100644 --- a/main.py +++ b/main.py @@ -2,7 +2,7 @@ from flask import Flask from flask import Blueprint,render_template -from views import dashboard,site +from views import dashboard,site,files app = Flask(__name__) app.debug = True @@ -10,6 +10,7 @@ app.debug = True DEFAULT_MODULES = ( (dashboard, "/"), (site, "/site"), + (files, "/files"), ) def setting_modules(app, modules): diff --git a/models/index.html b/models/index.html new file mode 100644 index 000000000..b2d525b29 --- /dev/null +++ b/models/index.html @@ -0,0 +1 @@ +index \ No newline at end of file diff --git a/plugins/index.html b/plugins/index.html new file mode 100644 index 000000000..b2d525b29 --- /dev/null +++ b/plugins/index.html @@ -0,0 +1 @@ +index \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index f163f4d22..a2478b34f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ flask -gunicorn \ No newline at end of file +gunicorn +psutil \ No newline at end of file diff --git a/static/js/files.js b/static/js/files.js index 0fac35880..faf3a432d 100755 --- a/static/js/files.js +++ b/static/js/files.js @@ -781,7 +781,7 @@ function GetFileName(fileNameFull) { //取磁盘 function GetDisk() { var LBody = ''; - $.get('/system?action=GetDiskInfo', function(rdata) { + $.get('/files/GetDiskInfo', function(rdata) { for (var i = 0; i < rdata.length; i++) { LBody += " " + (rdata[i].path=='/'?lan.files.path_root:rdata[i].path) + "(" + rdata[i].size[2] + ")"; } diff --git a/templates/default/files.html b/templates/default/files.html index c6be288be..19de9f628 100755 --- a/templates/default/files.html +++ b/templates/default/files.html @@ -1,88 +1,89 @@ -$def with (tData) +{% extends "default/layout.html" %} {% block content %}
-
-
-
-
-
-
- - - - -
-
- -
-
-
- - - - - -
- - -
-
-
-
- -
-
+
+
+
+
+
+
+ + + + +
+
+ +
+
+
+ + + + + +
+ + +
+
+
+
+ +
+
\ No newline at end of file +setTimeout(function() { + GetFiles((xPath != undefined ? xPath : '/www/wwwroot')); +}, 800); + +PathPlaceBtn((xPath != undefined ? xPath : '/www/wwwroot')); +setCookie('uploadSize', 1024 * 1024 * 1024); +if (getCookie('rank') == undefined || getCookie('rank') == null) { + setCookie('rank', 'a'); +} +$$("#set_icon").click(function() { + setCookie('rank', 'b'); + $$(this).addClass("active"); + $$("#set_list").removeClass("active"); + GetFiles(getCookie('Path')); +}); +$$("#set_list").click(function() { + setCookie('rank', 'a'); + $$(this).addClass("active"); + $$("#set_icon").removeClass("active"); + GetFiles(getCookie('Path')); +}) +$$(".refreshBtn").click(function() { + GetFiles(getCookie('Path')); +}) + +{% endblock %} \ No newline at end of file diff --git a/templates/default/index.html b/templates/default/index.html index 4e16f3e9b..d8bcc32e7 100755 --- a/templates/default/index.html +++ b/templates/default/index.html @@ -1,7 +1,4 @@ -{% extends "default/layout.html" %} - - -{% block content %} +{% extends "default/layout.html" %} {% block content %}
@@ -9,7 +6,7 @@ 首页/服务器状态
- 免费版 0.0.1 + 免费版 0.0.1 检查更新
@@ -27,33 +24,33 @@
-

$data['lan']['T1']

- $data['lan']['T2'] - $data['lan']['T3'] +

服务器状态

+ 连接管理 + 进程管理
    @@ -83,7 +80,7 @@

    获取中:

  • -

    $data['lan']['P1']

    +

    CPU使用率

    @@ -96,7 +93,7 @@

    $data['lan']['S2']

  • -

    $data['lan']['P2']

    +

    内存使用率

    @@ -116,7 +113,7 @@
    -
    $data['lan']['P4']
    +
    软件
    @@ -129,7 +126,7 @@
    -
    $data['lan']['NET1']
    +
    网络流量
    • $data['lan']['NET2']$data['lan']['S2']
    • diff --git a/test/index.html b/test/index.html new file mode 100644 index 000000000..b2d525b29 --- /dev/null +++ b/test/index.html @@ -0,0 +1 @@ +index \ No newline at end of file diff --git a/views/__init__.py b/views/__init__.py index fc82c6661..8cd2bb2bc 100644 --- a/views/__init__.py +++ b/views/__init__.py @@ -1,3 +1,4 @@ from dashboard import * from site import * +from files import * diff --git a/views/dashboard.py b/views/dashboard.py index 8ddd18035..8cf0e0b4b 100644 --- a/views/dashboard.py +++ b/views/dashboard.py @@ -2,10 +2,39 @@ from flask import Flask from flask import Blueprint,render_template +from flask import jsonify +import psutil,time + dashboard = Blueprint('dashboard', __name__, template_folder='templates') @dashboard.route("/") def index(): - return render_template('default/index.html') \ No newline at end of file + return render_template('default/index.html') + +@dashboard.route("getnetwork") +def getnetwork(): + #取网络流量信息 + networkIo = psutil.net_io_counters()[:4] + # if not hasattr(web.ctx.session,'otime'): + # web.ctx.session.up = networkIo[0] + # web.ctx.session.down = networkIo[1] + # web.ctx.session.otime = time.time(); + + ntime = time.time(); + networkInfo = {} + networkInfo['upTotal'] = networkIo[0] + networkInfo['downTotal'] = networkIo[1] + # networkInfo['up'] = round(float(networkIo[0] - web.ctx.session.up) / 1024 / (ntime - web.ctx.session.otime),2) + # networkInfo['down'] = round(float(networkIo[1] - web.ctx.session.down) / 1024 / (ntime - web.ctx.session.otime),2) + networkInfo['downPackets'] =networkIo[3] + networkInfo['upPackets'] =networkIo[2] + + # web.ctx.session.up = networkIo[0] + # web.ctx.session.down = networkIo[1] + # web.ctx.session.otime = ntime; + + # networkInfo['cpu'] = self.GetCpuInfo() + # networkInfo['load'] = self.GetLoadAverage(get); + return jsonify(networkInfo) \ No newline at end of file diff --git a/views/files.py b/views/files.py new file mode 100644 index 000000000..06f8177fd --- /dev/null +++ b/views/files.py @@ -0,0 +1,16 @@ +# coding:utf-8 + +from flask import Flask +from flask import Blueprint,render_template +from flask import jsonify + + +files = Blueprint('files', __name__, template_folder='templates') + +@files.route("/") +def index(): + return render_template('default/files.html') + +@files.route("/GetDiskInfo") +def GetDiskInfo(): + return jsonify({'result':'ok'}) \ No newline at end of file