Skip to content

Commit

Permalink
Optimized the service type data model and its corresponding Admin mod…
Browse files Browse the repository at this point in the history
…el, db model.

Signed-off-by: Sadam·Sadik <1903249375@qq.com>
  • Loading branch information
Haoke98 committed Apr 16, 2024
1 parent ec5d95c commit 4be5f9e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
11 changes: 8 additions & 3 deletions jumpService/admin/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@

@admin.register(ServiceType)
class ServiceTypeAdmin(BaseAdmin):
list_display = ['id', 'name', 'remark', 'defaultPort', 'defaultSuperUsername', 'defaultSuperUserPwd', 'official',
list_display = ['id', 'name', 'remark', 'port', 'dashboardPort', 'defaultSuperUsername', 'defaultSuperUserPwd',
'official',
'code', 'doc', 'updatedAt', 'createdAt',
'deletedAt']
search_fields = ['name', 'remark']
list_filter = ['defaultPort']
list_filter = ['port', 'dashboardPort', ]
actions = ['migrate']
ordering = ('-updatedAt',)

Expand Down Expand Up @@ -64,10 +65,14 @@ def formatter(self, obj, field_name, value):
'align': 'center'
},
'name': FieldOptions.IP_ADDRESS,
'defaultPort': {
'port': {
'min_width': "110px",
'align': 'center'
},
'dashboardPort': {
'min_width': "180px",
'align': 'center'
},
'rootUsername': {
'min_width': '180px',
'align': 'center'
Expand Down
2 changes: 1 addition & 1 deletion jumpService/models/services/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __str__(self):
for a, b in self.typeOpts:
if self.ttype == a:
ttype = b
return f"{b}({self.server.ip}:{self.port})"
return f"{b}({self.server}:{self.port})"


class DbServiceUser(AbstractBaseServiceUserModel):
Expand Down
6 changes: 4 additions & 2 deletions jumpService/models/services/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class Meta:

class ServiceType(BaseAccountModel):
name = fields.CharField(max_length=50, verbose_name="名称")
defaultPort = fields.IntegerField(verbose_name="默认端口", null=True, blank=True)
port = fields.IntegerField(verbose_name="默认端口", null=True, blank=True)
dashboardPort = fields.IntegerField(verbose_name="默认Dashboard端口", null=True, blank=True)
defaultSuperUsername = fields.CharField(max_length=50, verbose_name="默认超级用户名", null=True, blank=True)
defaultSuperUserPwd = fields.CharField(max_length=50, verbose_name="默认超级用户密码", null=True, blank=True)
doc = fields.CharField(max_length=500, verbose_name="文档地址", null=True, blank=True)
Expand All @@ -48,7 +49,8 @@ class Service(BaseAccountModel):
blank=False)
port = models.PositiveIntegerField(verbose_name="端口", null=True, blank=True, db_index=True)
sslOn = models.BooleanField(verbose_name="SSL", default=False)
dashboardPort = models.PositiveIntegerField(verbose_name="Dashboard/Console端口", null=True, blank=True, db_index=True)
dashboardPort = models.PositiveIntegerField(verbose_name="Dashboard/Console端口", null=True, blank=True,
db_index=True)
dashboardPath = models.TextField(verbose_name="路径", null=True, blank=True)

# TODO: 确定单用户服务和多用户服务之间的关系的处理, 要分开还是统一处理?
Expand Down

0 comments on commit 4be5f9e

Please sign in to comment.