-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #122 from ebridges/feature/view-processor-status
Feature/view processor status
- Loading branch information
Showing
12 changed files
with
354 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,6 +70,7 @@ | |
'sharing', | ||
'request_id', | ||
'elektrum', | ||
'status', | ||
] | ||
|
||
if os.environ.get('OPERATING_ENV') == 'local': | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
.processor-log-header { | ||
font-family: Inter, sans-serif; | ||
font-size: 22px; | ||
text-emphasis: strong; | ||
padding-bottom: 10px; | ||
} | ||
|
||
.processor-log { | ||
width: 100%; | ||
border-spacing: 2px; | ||
caption-side: bottom; | ||
} | ||
|
||
.processor-log caption { | ||
font-size: 12px; | ||
text-align: left; | ||
padding: 4px; | ||
} | ||
|
||
.processor-log th { | ||
font-weight: bold; | ||
padding: 4px; | ||
text-align: left; | ||
border-bottom: 2px solid black; | ||
} | ||
|
||
.processor-log td { | ||
padding: 4px; | ||
font-size: 16px; | ||
border-bottom: 1px solid gray; | ||
line-height: 1.5em; | ||
vertical-align: top; | ||
} | ||
|
||
.tooltip { | ||
position: relative; | ||
display: inline-block; | ||
border-bottom: 1px dotted black; | ||
/* If you want dots under the hoverable text */ | ||
} | ||
|
||
.helptext { | ||
visibility: hidden; | ||
} | ||
|
||
button { | ||
background-color: #282828; | ||
border-color: #282828; | ||
border-radius: 5px; | ||
border: solid 1px #282828; | ||
box-sizing: border-box; | ||
color: #ffffff; | ||
cursor: pointer; | ||
display: inline-block; | ||
font-family: Inter, sans-serif; | ||
font-size: 14px; | ||
margin: 0; | ||
padding: 5px 15px; | ||
text-align: center; | ||
text-transform: capitalize; | ||
vertical-align: top; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# Generated by Django 3.0.8 on 2020-09-15 02:03 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import media_items.models | ||
import uuid | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='ProcessorLog', | ||
fields=[ | ||
( | ||
'id', | ||
models.UUIDField( | ||
default=uuid.uuid4, | ||
editable=False, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name='id', | ||
), | ||
), | ||
('event_date', models.DateTimeField(verbose_name='Event date.')), | ||
( | ||
'file_path', | ||
models.CharField( | ||
help_text='Required. Path to media item from the root of users archive.', | ||
max_length=4096, | ||
validators=[media_items.models.MediaItemPathValidator()], | ||
verbose_name='file path', | ||
), | ||
), | ||
( | ||
'error_code', | ||
models.CharField( | ||
help_text='Required. Classification of the error.', | ||
max_length=64, | ||
verbose_name='Error code', | ||
), | ||
), | ||
( | ||
'message', | ||
models.CharField( | ||
help_text='Required. Error message.', | ||
max_length=4096, | ||
verbose_name='Error message', | ||
), | ||
), | ||
( | ||
'reason', | ||
models.CharField( | ||
help_text='Optional. Reason for the error, e.g. stacktrace.', | ||
max_length=8192, | ||
null=True, | ||
verbose_name='Error message', | ||
), | ||
), | ||
( | ||
'original_file_path', | ||
models.CharField( | ||
help_text='Optional. Path to media item that was uploaded.', | ||
max_length=4096, | ||
null=True, | ||
verbose_name='original file path', | ||
), | ||
), | ||
( | ||
'owner', | ||
models.ForeignKey( | ||
help_text='Required. User that owns this media item', | ||
on_delete=django.db.models.deletion.CASCADE, | ||
to=settings.AUTH_USER_MODEL, | ||
), | ||
), | ||
], | ||
options={'abstract': False,}, | ||
), | ||
] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
from django import forms | ||
from django.db import models | ||
from django.contrib.auth import get_user_model | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
from base.models import BaseModel | ||
from media_items.models import MediaItemPathValidator | ||
|
||
|
||
class ProcessorLog(BaseModel): | ||
|
||
media_item_path_validator = MediaItemPathValidator() | ||
|
||
owner = models.ForeignKey( | ||
get_user_model(), | ||
help_text=_('Required. User that owns this media item'), | ||
null=False, | ||
blank=False, | ||
on_delete=models.CASCADE, | ||
) | ||
|
||
event_date = models.DateTimeField(_('Event date.'), null=False, blank=False) | ||
|
||
file_path = models.CharField( | ||
_('file path'), | ||
help_text=_('Required. Path to media item from the root of users archive.'), | ||
null=False, | ||
blank=False, | ||
validators=[media_item_path_validator], | ||
max_length=4096, | ||
) | ||
|
||
error_code = models.CharField( | ||
_('Error code'), | ||
help_text=_('Required. Classification of the error.'), | ||
null=False, | ||
blank=False, | ||
max_length=64, | ||
) | ||
|
||
message = models.CharField( | ||
_('Error message'), | ||
help_text=_('Required. Error message.'), | ||
null=False, | ||
blank=False, | ||
max_length=4096, | ||
) | ||
|
||
reason = models.CharField( | ||
_('Error reason'), | ||
help_text=_('Optional. Reason for the error, e.g. stacktrace.'), | ||
null=True, | ||
blank=True, | ||
max_length=8192, | ||
) | ||
|
||
original_file_path = models.CharField( | ||
_('Original file path'), | ||
help_text=_('Optional. Path to media item that was uploaded.'), | ||
null=True, | ||
blank=True, | ||
max_length=4096, | ||
) | ||
|
||
|
||
class ProcessorLogForm(forms.ModelForm): | ||
class Meta: | ||
model = ProcessorLog | ||
fields = '__all__' | ||
|
||
# event_date=widget=forms.DateTimeField(input_formats='%Y-%m-%dT%H:%M:%S') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{% extends 'base_protected.html' %} | ||
{% block title %}Processor Log{% endblock %} | ||
|
||
{% block nav_block %} | ||
<h2 class="subtitle"> | ||
<a href="{% url 'collections-view' user.id %}" class="subtitle_link"><span class="nav-home-icon">⌂</span></a> / Processor Log | ||
</h2> | ||
{% endblock %} | ||
|
||
|
||
{% block content %} | ||
{% if processor_log_list %} | ||
<table class="processor-log"> | ||
<caption>{{ processor_log_list|length }} Processor Events</caption> | ||
<thead> | ||
<tr> | ||
<th>Event Date</th> | ||
<th>Error Code</th> | ||
<th>Message</th> | ||
<th>Reason</th> | ||
<th>Image Key</th> | ||
<th>Original Path</th> | ||
<th style="text-align: center;">Delete</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for item in processor_log_list %} | ||
<tr> | ||
<td>{{ item.event_date }}</td> | ||
<td>{{ item.error_code }}</td> | ||
<td>{{ item.message }}</td> | ||
<td><pre>{{ item.reason }}</pre></td> | ||
<td>{{ item.file_path }}</td> | ||
<td>{{ item.original_file_path }}</td> | ||
<td style="text-align: center;"><a href="{% url 'processor-log-delete' id=item.id %}">❌</a></td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
{% else %} | ||
<p>No failed processor events.</p> | ||
{% endif %} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
from django.urls import path | ||
from . import views | ||
from status.views.ok import Ok | ||
from status.views.db_create import DBCreate | ||
from status.views.processor_status import processor_log, processor_log_delete, processor_log_item | ||
|
||
urlpatterns = [ | ||
path('ok/', views.Ok.as_view(), name='ok'), | ||
path('db/create/', views.DBCreate.as_view(), name='db-create'), | ||
path('ok/', Ok.as_view(), name='ok'), | ||
path('db/create/', DBCreate.as_view(), name='db-create'), | ||
path('processor-log/', processor_log, name='processor-log'), | ||
path('processor-log/delete/<uuid:id>/', processor_log_delete, name='processor-log-delete'), | ||
path('api/processor-log/item', processor_log_item, name='processor-log-item'), | ||
] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from io import StringIO | ||
|
||
from django.http import HttpResponse | ||
from django.views import View | ||
|
||
from elektrum.management.commands import create_initial_db | ||
from elektrum.log import getLogger | ||
|
||
|
||
class DBCreate(View): | ||
def get(self, request=None): | ||
# output = StringIO() | ||
# command = create_initial_db.Command(stdout=output, stderr=output) | ||
# command.handle(None, None) | ||
# result = output.getvalue() | ||
# logger = getLogger(__name__) | ||
# logger.info(result) | ||
result = 'Not implemented.' | ||
response = HttpResponse(result) | ||
response['Content-Type'] = 'text/plain' | ||
return response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.