add runtime info to dashboard

This commit is contained in:
meeb 2020-12-13 16:24:47 +11:00
parent 902bb1f26f
commit 182d9d494a
5 changed files with 48 additions and 8 deletions

View File

@ -19,7 +19,7 @@
</div> </div>
</div> </div>
{% endif %} {% endif %}
<div class="row no-margin-bottom"> <div class="row">
<div class="col s12 m6 xl3"> <div class="col s12 m6 xl3">
<div class="card dashcard"> <div class="card dashcard">
<a href="{% url 'sync:sources' %}"> <a href="{% url 'sync:sources' %}">
@ -99,4 +99,31 @@
</div> </div>
</div> </div>
</div> </div>
<div class="row">
<div class="col s12">
<h2 class="truncate">Runtime infomation</h2>
</div>
</div>
<div class="row">
<div class="col s12">
<table class="striped">
<tr title="User ID TubeSync is running under">
<td class="hide-on-small-only">User ID</td>
<td><span class="hide-on-med-and-up">User ID<br></span><strong>{{ uid }}</strong></td>
</tr>
<tr title="Group ID TubeSync is running under">
<td class="hide-on-small-only">Group ID</td>
<td><span class="hide-on-med-and-up">Group ID<br></span><strong>{{ gid }}</strong></td>
</tr>
<tr title="Local directory where configuration data is stored">
<td class="hide-on-small-only">Config directory</td>
<td><span class="hide-on-med-and-up">Config directory<br></span><strong>{{ config_dir }}</strong></td>
</tr>
<tr title="Local directory where media will be downloaded to">
<td class="hide-on-small-only">Downloads directory</td>
<td><span class="hide-on-med-and-up">Downloads directory<br></span><strong>{{ downloads_dir }}</strong></td>
</tr>
</table>
</div>
</div>
{% endblock %} {% endblock %}

View File

@ -1,3 +1,4 @@
import os
import json import json
from base64 import b64decode from base64 import b64decode
from django.conf import settings from django.conf import settings
@ -71,6 +72,12 @@ class DashboardView(TemplateView):
data['largest_downloads'] = Media.objects.filter( data['largest_downloads'] = Media.objects.filter(
downloaded=True, downloaded_filesize__isnull=False downloaded=True, downloaded_filesize__isnull=False
).order_by('-downloaded_filesize')[:10] ).order_by('-downloaded_filesize')[:10]
# UID and GID
data['uid'] = os.getuid()
data['gid'] = os.getgid()
# Config and download locations
data['config_dir'] = str(settings.CONFIG_BASE_DIR)
data['downloads_dir'] = str(settings.DOWNLOAD_ROOT)
return data return data

View File

@ -5,6 +5,8 @@ from binascii import hexlify
BASE_DIR = Path(__file__).resolve().parent.parent BASE_DIR = Path(__file__).resolve().parent.parent
ROOT_DIR = Path('/') ROOT_DIR = Path('/')
CONFIG_BASE_DIR = ROOT_DIR / 'config'
DOWNLOADS_BASE_DIR = ROOT_DIR / 'downloads'
RANDOM_SECRET = hexlify(os.urandom(32)).decode() RANDOM_SECRET = hexlify(os.urandom(32)).decode()
@ -19,10 +21,10 @@ TIME_ZONE = os.getenv('TZ', 'UTC')
DATABASES = { DATABASES = {
'default': { 'default': {
'ENGINE': 'django.db.backends.sqlite3', 'ENGINE': 'django.db.backends.sqlite3',
'NAME': ROOT_DIR / 'config' / 'db.sqlite3', 'NAME': CONFIG_BASE_DIR / 'db.sqlite3',
} }
} }
MEDIA_ROOT = ROOT_DIR / 'config' / 'media' MEDIA_ROOT = CONFIG_BASE_DIR / 'media'
DOWNLOAD_ROOT = ROOT_DIR / 'downloads' DOWNLOAD_ROOT = DOWNLOADS_BASE_DIR

View File

@ -2,6 +2,8 @@ from pathlib import Path
BASE_DIR = Path(__file__).resolve().parent.parent BASE_DIR = Path(__file__).resolve().parent.parent
CONFIG_BASE_DIR = BASE_DIR
DOWNLOADS_BASE_DIR = BASE_DIR
SECRET_KEY = 'example-secret-key' SECRET_KEY = 'example-secret-key'
@ -11,9 +13,9 @@ DEBUG = False
DATABASES = { DATABASES = {
'default': { 'default': {
'ENGINE': 'django.db.backends.sqlite3', 'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3', 'NAME': CONFIG_BASE_DIR / 'db.sqlite3',
} }
} }
DOWNLOAD_ROOT = BASE_DIR / 'downloads' DOWNLOAD_ROOT = DOWNLOADS_BASE_DIR / 'downloads'

View File

@ -2,6 +2,8 @@ from pathlib import Path
BASE_DIR = Path(__file__).resolve().parent.parent BASE_DIR = Path(__file__).resolve().parent.parent
CONFIG_BASE_DIR = BASE_DIR
DOWNLOADS_BASE_DIR = BASE_DIR
VERSION = 0.1 VERSION = 0.1
@ -98,8 +100,8 @@ USE_TZ = True
STATIC_URL = '/static/' STATIC_URL = '/static/'
STATIC_ROOT = BASE_DIR / 'static' STATIC_ROOT = BASE_DIR / 'static'
#MEDIA_URL = '/media/' #MEDIA_URL = '/media/'
MEDIA_ROOT = BASE_DIR / 'media' MEDIA_ROOT = CONFIG_BASE_DIR / 'media'
DOWNLOAD_ROOT = BASE_DIR / 'downloads' DOWNLOAD_ROOT = DOWNLOADS_BASE_DIR / 'downloads'
DOWNLOAD_VIDEO_DIR = 'video' DOWNLOAD_VIDEO_DIR = 'video'
DOWNLOAD_AUDIO_DIR = 'audio' DOWNLOAD_AUDIO_DIR = 'audio'
SASS_PROCESSOR_ROOT = STATIC_ROOT SASS_PROCESSOR_ROOT = STATIC_ROOT