1
0
mirror of https://github.com/dkmstr/openuds.git synced 2024-12-24 21:34:41 +03:00

Adding level to notifiers and fixed up admin angular

This commit is contained in:
Adolfo Gómez García 2022-05-15 22:25:17 +02:00
parent 12c32bde14
commit 801a4ef1a7
9 changed files with 33 additions and 12 deletions

View File

@ -34,7 +34,7 @@ import logging
import typing
from django.utils.translation import gettext_lazy as _, gettext
from uds.models import Notifier
from uds.models import Notifier, NotificationLevel
from uds.core import messaging
from uds.core.ui import gui
from uds.core.util import permissions
@ -54,6 +54,7 @@ class Notifiers(ModelHandler):
save_fields = [
'name',
'comments',
'level',
'tags',
]
@ -61,6 +62,7 @@ class Notifiers(ModelHandler):
table_fields = [
{'name': {'title': _('Name'), 'visible': True, 'type': 'iconType'}},
{'type_name': {'title': _('Type')}},
{'level': {'title': _('Level')}},
{'comments': {'title': _('Comments')}},
{'tags': {'title': _('tags'), 'visible': False}},
]
@ -74,17 +76,30 @@ class Notifiers(ModelHandler):
if not notifier:
raise self.invalidItemException()
field = self.addDefaultFields(
localGui = self.addDefaultFields(
notifier.guiDescription(), ['name', 'comments', 'tags']
)
return field
for field in [
{
'name': 'level',
'values': [gui.choiceItem(i[0], i[1]) for i in NotificationLevel.all()],
'label': gettext('Level'),
'tooltip': gettext('Level of notifications'),
'type': gui.InputField.CHOICE_TYPE,
'order': 102,
}
]:
self.addField(localGui, field)
return localGui
def item_as_dict(self, item: Notifier) -> typing.Dict[str, typing.Any]:
type_ = item.getType()
return {
'id': item.uuid,
'name': item.name,
'level': item.level,
'tags': [tag.tag for tag in item.tags.all()],
'comments': item.comments,
'type': type_.type(),

View File

@ -362,7 +362,7 @@ class SAMLAuthenticator(auths.Authenticator):
'entityId': self.entityID.value,
'assertionConsumerService': {
'url': self.manageUrl.value,
'binding': 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
'binding': 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST',
},
'singleLogoutService': {
'url': self.manageUrl.value + '?logout=true',

View File

@ -115,6 +115,6 @@ from .actor_token import ActorToken
from .tunnel_token import TunnelToken
# Notifications & Alerts
from .notifications import Notification, Notifier
from .notifications import Notification, Notifier, NotificationLevel
logger = logging.getLogger(__name__)

View File

@ -33,6 +33,7 @@ import logging
import typing
from django.db import models, transaction
from django.utils.translation import gettext as _
from .managed_object_model import ManagedObjectModel
@ -52,6 +53,11 @@ class NotificationLevel(IntEnum):
ERROR = 2
CRITICAL = 3
# Return all notification levels as tuples of (level, name)
@classmethod
def all(cls):
return [(level.value, level.name) for level in (cls.INFO, cls.WARNING, cls.ERROR, cls.CRITICAL)]
# This model will be available on local "persistent" storage and also on configured database
class Notification(models.Model):

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -205,7 +205,7 @@ urlpatterns = [
# REST API
re_path(r'^uds/rest/(?P<arguments>.*)$', REST.Dispatcher.as_view(), name="REST"),
# Web admin GUI
re_path(r'^uds/adm/.*$', uds.admin.views.index, name='uds.admin.views.index'),
re_path(r'^uds/adm/', uds.admin.views.index, name='uds.admin.views.index'),
]
# Append urls from special dispatchers