mirror of https://github.com/jumpserver/jumpserver
perf: 会话新增 error_reason 字段
parent
ca7d164034
commit
499eedd83e
|
@ -94,3 +94,9 @@ class TaskNameType(TextChoices):
|
|||
kill_session = "kill_session", _('Kill Session')
|
||||
lock_session = "lock_session", _('Lock Session')
|
||||
unlock_session = "unlock_session", _('Unlock Session')
|
||||
|
||||
|
||||
class SessionErrorReason(TextChoices):
|
||||
connect_failed = 'connect_failed', _('Connect Failed')
|
||||
replay_create_failed = 'replay_create_failed', _('Replay Create Failed')
|
||||
replay_upload_failed = 'replay_upload_failed', _('Replay Upload Failed')
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 4.1.10 on 2023-10-10 06:24
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('terminal', '0064_auto_20230728_1001'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='session',
|
||||
name='error_reason',
|
||||
field=models.CharField(blank=True, max_length=128, verbose_name='Error reason'),
|
||||
),
|
||||
]
|
|
@ -45,6 +45,7 @@ class Session(OrgModelMixin):
|
|||
date_end = models.DateTimeField(verbose_name=_("Date end"), null=True)
|
||||
comment = models.TextField(blank=True, null=True, verbose_name=_("Comment"))
|
||||
cmd_amount = models.IntegerField(default=-1, verbose_name=_("Command amount"))
|
||||
error_reason = models.CharField(max_length=128, blank=True, verbose_name=_("Error reason"))
|
||||
|
||||
upload_to = 'replay'
|
||||
ACTIVE_CACHE_KEY_PREFIX = 'SESSION_ACTIVE_{}'
|
||||
|
|
|
@ -5,7 +5,7 @@ from common.serializers.fields import LabeledChoiceField
|
|||
from common.utils import pretty_string
|
||||
from orgs.mixins.serializers import BulkOrgResourceModelSerializer
|
||||
from .terminal import TerminalSmallSerializer
|
||||
from ..const import SessionType
|
||||
from ..const import SessionType, SessionErrorReason
|
||||
from ..models import Session
|
||||
|
||||
__all__ = [
|
||||
|
@ -24,6 +24,9 @@ class SessionSerializer(BulkOrgResourceModelSerializer):
|
|||
can_join = serializers.BooleanField(read_only=True, label=_("Can join"))
|
||||
can_terminate = serializers.BooleanField(read_only=True, label=_("Can terminate"))
|
||||
asset = serializers.CharField(label=_("Asset"), style={'base_template': 'textarea.html'})
|
||||
error_reason = LabeledChoiceField(
|
||||
choices=SessionErrorReason.choices, label=_("Error reason"), required=False
|
||||
)
|
||||
|
||||
class Meta:
|
||||
model = Session
|
||||
|
@ -33,7 +36,7 @@ class SessionSerializer(BulkOrgResourceModelSerializer):
|
|||
"protocol", 'type', "login_from", "remote_addr",
|
||||
"is_success", "is_finished", "has_replay", "has_command",
|
||||
"date_start", "date_end", "comment", "terminal_display", "is_locked",
|
||||
'command_amount',
|
||||
'command_amount', 'error_reason'
|
||||
]
|
||||
fields_fk = ["terminal", ]
|
||||
fields_custom = ["can_replay", "can_join", "can_terminate"]
|
||||
|
|
Loading…
Reference in New Issue