diff --git a/auto_pt/urls.py b/auto_pt/urls.py index 939ae21..1061b21 100644 --- a/auto_pt/urls.py +++ b/auto_pt/urls.py @@ -27,6 +27,9 @@ urlpatterns = [ path(r'sign_in_api', views.sign_in_api, name='sign_in_api'), path(r'update_site_api', views.update_site_api, name='update_site_api'), path(r'edit_site_api', views.edit_site_api, name='edit_site_api'), + path(r'get_log_list', views.get_log_list, name='get_log_list'), + path(r'show_log_list', views.show_log_list, name='show_log_list'), + path(r'get_log_content', views.get_log_content, name='get_log_content'), path(r'downloading_status', views.downloading_status, name='downloading_status'), path(r'do_sql', views.do_sql, name='do_sql'), ] diff --git a/auto_pt/views.py b/auto_pt/views.py index 902c90a..a2186b9 100644 --- a/auto_pt/views.py +++ b/auto_pt/views.py @@ -18,6 +18,7 @@ from pt_site.UtilityTool import MessageTemplate, FileSizeConvert from pt_site.models import SiteStatus, MySite, Site, Downloader, TorrentInfo from pt_site.views import scheduler, pt_spider from ptools.base import CommonResponse, StatusCodeEnum, DownloaderCategory +from ptools.settings import BASE_DIR logger = logging.getLogger('ptools') @@ -778,3 +779,37 @@ def edit_site_api(request): return JsonResponse(data=CommonResponse.success( msg='ok' ).to_dict(), safe=False) + + +def get_log_list(request): + path = os.path.join(BASE_DIR, 'db') + print(path) + print(os.listdir(path)) + + names = [name for name in os.listdir(path) + if os.path.isfile(os.path.join(path, name)) and name.startswith('logs')] + print(names) + return JsonResponse(data=CommonResponse.success( + data={ + 'path': path, + 'names': names + } + ).to_dict(), safe=False) + + +def get_log_content(request): + name = request.GET.get('name') + path = os.path.join(BASE_DIR, 'db/' + name) + with open(path, 'r') as f: + logs = f.readlines() + print(logs) + return JsonResponse(data=CommonResponse.success( + data={ + 'path': path, + 'logs': logs, + } + ).to_dict(), safe=False) + + +def show_log_list(request): + return render(request, 'auto_pt/showlog.html') diff --git a/ptools/settings.py b/ptools/settings.py index 6ffaac5..695dfad 100644 --- a/ptools/settings.py +++ b/ptools/settings.py @@ -275,6 +275,10 @@ SIMPLEUI_CONFIG = { 'name': '站点导入', 'icon': 'el-icon-s-open', 'url': '/tasks/import_from_ptpp' + }, { + 'name': '日志查看', + 'icon': 'el-icon-s-open', + 'url': '/tasks/show_log_list' }, ] }] } diff --git a/templates/auto_pt/showlog.html b/templates/auto_pt/showlog.html new file mode 100644 index 0000000..0c2833a --- /dev/null +++ b/templates/auto_pt/showlog.html @@ -0,0 +1,149 @@ +{% load static %} + + + + + + + Title + {% include 'admin/includes/css-part.html' %} + + + +
+ + + + {# #} + {# #} + + + + + + {# #} + + + + + {# #} + {# #} + {# #} + {# #} + {# 查看#} + {# 新增#} + {# 删除#} + {# #} + {# #} + {# 王小虎#} + {# #} + + +
+ +
+
+
+
+
+ + +{% include 'admin/includes/js-part.html' %} + + + + \ No newline at end of file diff --git a/templates/auto_pt/status.html b/templates/auto_pt/status.html index 296ac7b..bc6e566 100644 --- a/templates/auto_pt/status.html +++ b/templates/auto_pt/status.html @@ -353,7 +353,6 @@ showLogo: true, showLegend: true, shuffle: false, - } }, beforeMount() { diff --git a/templates/auto_pt/userdata.html b/templates/auto_pt/userdata.html index 566549b..77b48e3 100644 --- a/templates/auto_pt/userdata.html +++ b/templates/auto_pt/userdata.html @@ -1,10 +1,17 @@ +{% load static %} + - + + Title + {% include 'admin/includes/css-part.html' %} + +{% include 'admin/includes/js-part.html' %} + \ No newline at end of file diff --git a/templates/auto_pt/userinfo.html b/templates/auto_pt/userinfo.html index f12918b..77b48e3 100644 --- a/templates/auto_pt/userinfo.html +++ b/templates/auto_pt/userinfo.html @@ -1,10 +1,17 @@ +{% load static %} + - + + - 用户数据 + Title + {% include 'admin/includes/css-part.html' %} + +{% include 'admin/includes/js-part.html' %} + \ No newline at end of file