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

Fixed UserInterface new guiField acceptance of values

This commit is contained in:
Adolfo Gómez García 2022-09-12 12:37:21 +02:00
parent 88c3f9077b
commit f90f108869
No known key found for this signature in database
GPG Key ID: DD1ABF20724CDA23
4 changed files with 25 additions and 16 deletions

View File

@ -1,4 +0,0 @@
Linux:
python3-prctl (recommended, but not required in fact)
python3-pyqt5

View File

@ -217,7 +217,7 @@
<string>UDS Service Token</string>
</property>
<property name="whatsThis">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Administrator user on UDS Server.&lt;/p&gt;&lt;p&gt;Note: This credential will not be stored on client. Will be used to obtain an unique token for this image.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Token of the service on UDS platform&lt;/p&gt;&lt;p&gt;This token can be obtainend from the service configuration on UDS.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
@ -268,10 +268,10 @@
<item row="3" column="1">
<widget class="QLineEdit" name="restrictNet">
<property name="toolTip">
<string>UDS user with administration rights (Will not be stored on template)</string>
<string>Restrict valid detection of network interfaces to this network.</string>
</property>
<property name="whatsThis">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Administrator user on UDS Server.&lt;/p&gt;&lt;p&gt;Note: This credential will not be stored on client. Will be used to obtain an unique token for this image.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Restrics valid detection of network interfaces.&lt;/p&gt;&lt;p&gt;Note: Use this field only in case of several network interfaces, so UDS knows which one is the interface where the user will be connected..&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>

View File

@ -37,6 +37,7 @@ import pickle
import copy
import typing
import logging
from collections import abc
from django.utils.translation import get_language, ugettext as _, ugettext_noop
@ -112,19 +113,30 @@ class gui:
# Helpers
@staticmethod
def convertToChoices(
vals: typing.Union[typing.List[str], typing.MutableMapping[str, str]]
vals: typing.Union[typing.Iterable[typing.Union[str, typing.Dict[str, str]]], typing.Dict[str, str]]
) -> typing.List[typing.Dict[str, str]]:
"""
Helper to convert from array of strings to the same dict used in choice,
Helper to convert from array of strings (or dictionaries) to the same dict used in choice,
multichoice, ..
"""
if not vals:
return []
if isinstance(vals, (list, tuple)):
return [{'id': v, 'text': v} for v in vals]
# Helper to convert an item to a dict
def choiceFromValue(val: typing.Union[str, typing.Dict[str, str]]) -> typing.Dict[str, str]:
if isinstance(val, str):
return {'id': val, 'name': val}
# Return a deepcopy
return copy.deepcopy(val)
# If is an iterator
if isinstance(vals, abc.Iterable):
return [choiceFromValue(v) for v in vals]
# Dictionary
return [{'id': str(k), 'text': v} for k, v in vals.items()]
# If is a dict
if isinstance(vals, abc.Mapping):
return [{'id': str(k), 'text': v} for k, v in vals.items()]
raise ValueError('Invalid type for convertToChoices: {}'.format(type(vals)))
@staticmethod
def convertToList(vals: typing.Iterable[str]) -> typing.List[str]:
@ -770,7 +782,8 @@ class gui:
def __init__(self, **options):
super().__init__(**options)
if options.get('values') and isinstance(options.get('values'), (dict, list, tuple)):
vals = options.get('values')
if vals and isinstance(vals, (dict, list, tuple)):
options['values'] = gui.convertToChoices(options['values'])
self._data['values'] = options.get('values', [])
if 'fills' in options:
@ -782,7 +795,7 @@ class gui:
gui.callbacks[fills['callbackName']] = fnc
self._type(gui.InputField.CHOICE_TYPE)
def setValues(self, values: typing.List[typing.Any]):
def setValues(self, values: typing.List[typing.Dict[str, typing.Any]]):
"""
Set the values for this choice field
"""

View File

@ -173,7 +173,7 @@ class LinuxOsManager(osmanagers.OSManager):
pass
def loginNotified(self, userService, userName=None):
if '\\' not in userName:
if userName and '\\' not in userName:
osmanagers.OSManager.loggedIn(userService, userName)
def logoutNotified(self, userService, userName=None):