pull/109/head
Mr Chen 7 years ago
parent 10898c2de6
commit e87968aebc
  1. 2
      class/core/public.py
  2. 82
      route/files.py
  3. 42
      route/system.py
  4. 6
      static/js/files.js
  5. 22
      templates/default/files.html

@ -49,7 +49,7 @@ def getPage(args, result='1,2,3,4,5,8'):
info['p'] = 1
if args.has_key('p'):
info['p'] = int(get['p'])
info['p'] = int(args['p'])
info['uri'] = {}
info['return_js'] = ''
if args.has_key('tojs'):

@ -1,14 +1,15 @@
# coding:utf-8
from flask import Flask
from flask import Blueprint, render_template
from flask import jsonify
import os
import sys
sys.path.append("class/")
sys.path.append("class/core")
import public
from flask import Flask
from flask import Blueprint, render_template
from flask import jsonify
from flask import request
files = Blueprint('files', __name__, template_folder='templates')
@ -18,11 +19,70 @@ def index():
return render_template('default/files.html')
@files.route("/GetDiskInfo")
def GetDiskInfo():
return jsonify({'result': 'ok'})
@files.route('/get_dir', methods=['POST'])
def getDir():
path = request.form.get('path', '').encode('utf-8')
print path
path = "/"
info = {}
info['count'] = 10
info['row'] = 10
info['p'] = 1
if request.form.has_key('p'):
info['p'] = int(request.form.get('p'))
info['uri'] = {}
info['return_js'] = ''
if request.form.has_key('tojs'):
info['return_js'] = request.form.get('tojs')
if request.form.has_key('showRow'):
info['row'] = int(request.form.get('showRow'))
data = {}
data['PAGE'] = public.getPage(info, '1,2,3,4,5,6,7,8')
search = None
if request.form.has_key('search'):
search = request.form.get('search').strip().lower()
i = 0
n = 0
for filename in os.listdir(path):
if search:
if filename.lower().find(search) == -1:
continue
i += 1
if n >= 10:
break
if i < 0:
continue
try:
filePath = (path + '/' + filename).encode('utf8')
link = ''
if os.path.islink(filePath):
filePath = os.readlink(filePath)
link = ' -> ' + filePath
if not os.path.exists(filePath):
filePath = path + '/' + filePath
if not os.path.exists(filePath):
continue
@files.route('/GetExecLogs', methods=['POST'])
def GetExecLogs():
pass
stat = os.stat(filePath)
accept = str(oct(stat.st_mode)[-3:])
mtime = str(int(stat.st_mtime))
user = ''
try:
user = pwd.getpwuid(stat.st_uid).pw_name
except:
user = str(stat.st_uid)
size = str(stat.st_size)
if os.path.isdir(filePath):
dirnames.append(filename + ';' + size + ';' +
mtime + ';' + accept + ';' + user + ';' + link)
else:
filenames.append(filename + ';' + size + ';' +
mtime + ';' + accept + ';' + user + ';' + link)
n += 1
except:
continue
return public.getJson(data)

@ -157,3 +157,45 @@ def systemtotal():
data['isuser'] = public.M('users').where('username=?', ('admin',)).count()
data['version'] = '0.0.1'
return jsonify(data)
@system.route("/disk_info")
def diskInfo():
# 取磁盘分区信息
temp = public.execShell("df -h -P|grep '/'|grep -v tmpfs")[0]
tempInodes = public.execShell("df -i -P|grep '/'|grep -v tmpfs")[0]
temp1 = temp.split('\n')
tempInodes1 = tempInodes.split('\n')
diskInfo = []
n = 0
cuts = ['/mnt/cdrom', '/boot', '/boot/efi', '/dev',
'/dev/shm', '/run/lock', '/run', '/run/shm', '/run/user']
for tmp in temp1:
n += 1
inodes = tempInodes1[n - 1].split()
disk = tmp.split()
if len(disk) < 5:
continue
if disk[1].find('M') != -1:
continue
if disk[1].find('K') != -1:
continue
if len(disk[5].split('/')) > 4:
continue
if disk[5] in cuts:
continue
arr = {}
arr['path'] = disk[5]
tmp1 = [disk[1], disk[2], disk[3], disk[4]]
arr['size'] = tmp1
arr['inodes'] = [inodes[1], inodes[2], inodes[3], inodes[4]]
if disk[5] == '/':
bootLog = os.getcwd() + '/tmp/panelBoot.pl'
if disk[2].find('M') != -1:
if os.path.exists(bootLog):
os.system('rm -f ' + bootLog)
else:
if not os.path.exists(bootLog):
pass
diskInfo.append(arr)
return public.getJson(diskInfo)

@ -334,7 +334,7 @@ function GetFiles(Path) {
var data = 'path=' + Path;
var loadT = layer.load();
var totalSize = 0;
$.post('/files?action=GetDir&tojs=GetFiles&p=' + p + '&showRow=' + showRow + search, data, function(rdata) {
$.post('/files/get_dir?tojs=GetFiles&p=' + p + '&showRow=' + showRow + search, data, function(rdata) {
layer.close(loadT);
var rows = ['100','200','500','1000','2000'];
@ -781,14 +781,14 @@ function GetFileName(fileNameFull) {
//取磁盘
function GetDisk() {
var LBody = '';
$.get('/system?action=GetDiskInfo', function(rdata) {
$.get('/system/disk_info', function(rdata) {
for (var i = 0; i < rdata.length; i++) {
LBody += "<span onclick=\"GetFiles('" + rdata[i].path + "')\"><span class='glyphicon glyphicon-hdd'></span>&nbsp;" + (rdata[i].path=='/'?lan.files.path_root:rdata[i].path) + "(" + rdata[i].size[2] + ")</span>";
}
var trash = '<span id="recycle_bin" onclick="Recycle_bin(\'open\')" title="'+lan.files.recycle_bin_title+'" style="position: absolute; border-color: #ccc; right: 77px;"><span class="glyphicon glyphicon-trash"></span>&nbsp;'+lan.files.recycle_bin_title+'</span>';
$("#comlist").html(LBody+trash);
IsDiskWidth();
});
},'json');
}
//返回上一级

@ -52,10 +52,10 @@
<li onclick="javascript:Batch(3);"><a style="cursor: pointer;">$tData['lan']['L4']</a></li>
<li onclick="javascript:Batch(4);"><a style="cursor: pointer;">$tData['lan']['L5']</a></li>
</ul>
<script src="/static/js/jquery-ui.min.js"></script>
<script src="/static/js/jquery.contextify.min.js"></script>
<script src="/static/js/files.js?date=20180425"></script>
<script src="/static/js/upload.js?date=20171115"></script>
<script src="/static/js/jquery-ui.min.js?v={{config.version}}"></script>
<script src="/static/js/jquery.contextify.min.js?v={{config.version}}"></script>
<script src="/static/js/files.js?v={{config.version}}"></script>
<script src="/static/js/upload.js?v={{config.version}}"></script>
<script type="text/javascript">
setTimeout(function() {
GetDisk();
@ -70,19 +70,19 @@ setCookie('uploadSize', 1024 * 1024 * 1024);
if (getCookie('rank') == undefined || getCookie('rank') == null) {
setCookie('rank', 'a');
}
$$("#set_icon").click(function() {
$("#set_icon").click(function() {
setCookie('rank', 'b');
$$(this).addClass("active");
$$("#set_list").removeClass("active");
$(this).addClass("active");
$("#set_list").removeClass("active");
GetFiles(getCookie('Path'));
});
$$("#set_list").click(function() {
$("#set_list").click(function() {
setCookie('rank', 'a');
$$(this).addClass("active");
$$("#set_icon").removeClass("active");
$(this).addClass("active");
$("#set_icon").removeClass("active");
GetFiles(getCookie('Path'));
})
$$(".refreshBtn").click(function() {
$(".refreshBtn").click(function() {
GetFiles(getCookie('Path'));
})
</script>

Loading…
Cancel
Save