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

Added new admin interface supporting notifiers

This commit is contained in:
Adolfo Gómez García 2022-03-14 20:59:04 +01:00
parent d04068e19f
commit 1d62dbbacd
11 changed files with 81 additions and 89 deletions

View File

@ -76,7 +76,7 @@ class Notifiers(ModelHandler):
raise self.invalidItemException() raise self.invalidItemException()
field = self.addDefaultFields( field = self.addDefaultFields(
notifier.guiDescription(), ['name', 'comments', 'tags', 'priority', 'networks'] notifier.guiDescription(), ['name', 'comments', 'tags']
) )
return field return field

View File

@ -170,3 +170,21 @@ def validateMacRange(macRange: str) -> str:
) )
return macRange return macRange
def validateEmail(email: str) -> str:
"""
Validates that an email is valid
:param email: email to validate
:return: Raises Module.Validation exception if is invalid, else return the value "fixed"
"""
if len(email) > 254:
raise Module.ValidationException(
_('Email address is too long')
)
if not re.match(r"[^@]+@[^@]+\.[^@]+", email):
raise Module.ValidationException(
_('Email address is not valid')
)
return email

View File

@ -35,8 +35,10 @@ import logging
import typing import typing
from django.utils.translation import gettext_noop as _ from django.utils.translation import gettext_noop as _
from uds.core.messaging import Notifier from uds.core.messaging import Notifier
from uds.core.ui import gui from uds.core.ui import gui
from uds.core.util import validators
# Not imported at runtime, just for type checking # Not imported at runtime, just for type checking
@ -50,11 +52,11 @@ class EmailNotifier(Notifier):
Email notifier Email notifier
""" """
typeName = _('OpenStack Platform Provider') typeName = _('Email notifications')
# : Type used internally to identify this provider # : Type used internally to identify this provider
typeType = 'openStackPlatformNew' typeType = 'emailNotifications'
# : Description shown at administration interface for this provider # : Description shown at administration interface for this provider
typeDescription = _('OpenStack platform service provider') typeDescription = _('Email notifications')
# : Icon file used as icon for this provider. This string will be translated # : Icon file used as icon for this provider. This string will be translated
# : BEFORE sending it to administration interface, so don't forget to # : BEFORE sending it to administration interface, so don't forget to
# : mark it as _ (using gettext_noop) # : mark it as _ (using gettext_noop)
@ -69,7 +71,7 @@ class EmailNotifier(Notifier):
# but used for sample purposes # but used for sample purposes
# If we don't indicate an order, the output order of fields will be # If we don't indicate an order, the output order of fields will be
# "random" # "random"
host = gui.TextField( hostname = gui.TextField(
length=128, length=128,
label=_('SMTP Host'), label=_('SMTP Host'),
order=1, order=1,
@ -79,6 +81,7 @@ class EmailNotifier(Notifier):
'smtp.gmail.com:587' 'smtp.gmail.com:587'
), ),
required=True, required=True,
tab=_('SMTP Server'),
) )
security = gui.ChoiceField( security = gui.ChoiceField(
@ -91,21 +94,25 @@ class EmailNotifier(Notifier):
], ],
order=2, order=2,
required=True, required=True,
tab=_('SMTP Server'),
) )
username = gui.TextField( username = gui.TextField(
length=128, length=128,
label=_('Username'), label=_('Username'),
order=9, order=9,
tooltip=_('User with valid privileges on OpenStack'), tooltip=_('User with access to SMTP server'),
required=True, required=True,
defvalue='admin', defvalue='',
tab=_('SMTP Server'),
) )
password = gui.PasswordField( password = gui.PasswordField(
lenth=128, lenth=128,
label=_('Password'), label=_('Password'),
order=10, order=10,
tooltip=_('Password of the user of OpenStack'), tooltip=_('Password of the user with access to SMTP server'),
required=True, required=True,
defvalue='',
tab=_('SMTP Server'),
) )
fromEmail = gui.TextField( fromEmail = gui.TextField(
@ -114,6 +121,7 @@ class EmailNotifier(Notifier):
order=11, order=11,
tooltip=_('Email address that will be used as sender'), tooltip=_('Email address that will be used as sender'),
required=True, required=True,
tab=_('Config'),
) )
toEmail = gui.TextField( toEmail = gui.TextField(
@ -122,6 +130,7 @@ class EmailNotifier(Notifier):
order=12, order=12,
tooltip=_('Email address that will be used as recipient'), tooltip=_('Email address that will be used as recipient'),
required=True, required=True,
tab=_('Config'),
) )
enableHTML = gui.CheckBoxField( enableHTML = gui.CheckBoxField(
@ -129,11 +138,34 @@ class EmailNotifier(Notifier):
order=13, order=13,
tooltip=_('Enable HTML in emails'), tooltip=_('Enable HTML in emails'),
defvalue=True, defvalue=True,
tab=_('Config'),
) )
def initialize(self, values: 'Module.ValuesType' = None): def initialize(self, values: 'Module.ValuesType' = None):
""" """
We will use the "autosave" feature for form fields We will use the "autosave" feature for form fields
""" """
pass if not values:
return
# check hostname for stmp server si valid and is in the right format
# that is a hostname or ip address with optional port
# if hostname is not valid, we will raise an exception
hostname = self.hostname.cleanStr()
if not hostname:
raise Notifier.ValidationException(_('Invalid SMTP hostname'))
# Now check is valid format
if ':' in hostname:
host, port = validators.validateHostPortPair(hostname)
self.hostname.value = '{}:{}'.format(host, port)
else:
host = self.hostname.cleanStr()
self.hostname.value = validators.validateHostname(host, 128, asPattern=False)
# now check from email and to email
self.fromEmail.value = validators.validateEmail(self.fromEmail.value)
self.toEmail.value = validators.validateEmail(self.toEmail.value)
# Done

View File

@ -1,28 +1,3 @@
@angular-devkit/build-angular
MIT
The MIT License
Copyright (c) 2017 Google, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
@angular/animations @angular/animations
MIT MIT
@ -30,7 +5,7 @@ MIT
MIT MIT
The MIT License The MIT License
Copyright (c) 2021 Google LLC. Copyright (c) 2022 Google LLC.
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@ -64,7 +39,7 @@ MIT
MIT MIT
The MIT License The MIT License
Copyright (c) 2021 Google LLC. Copyright (c) 2022 Google LLC.
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@ -119,7 +94,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
core-js core-js
MIT MIT
Copyright (c) 2014-2021 Denis Pushkarev Copyright (c) 2014-2022 Denis Pushkarev
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@ -431,31 +406,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
resize-observer-polyfill
MIT
The MIT License (MIT)
Copyright (c) 2016 Denis Rul
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
rxjs rxjs
Apache-2.0 Apache-2.0
Apache License Apache License
@ -677,14 +627,11 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE. PERFORMANCE OF THIS SOFTWARE.
web-animations-js
Apache-2.0
zone.js zone.js
MIT MIT
The MIT License The MIT License
Copyright (c) 2010-2020 Google LLC. https://angular.io/license Copyright (c) 2010-2022 Google LLC. https://angular.io/license
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
!function(){"use strict";var e,s={},d={};function r(e){var t=d[e];if(void 0!==t)return t.exports;var n=d[e]={exports:{}};return s[e].call(n.exports,n,n.exports,r),n.exports}r.m=s,e=[],r.O=function(t,n,a,f){if(!n){var c=1/0;for(u=0;u<e.length;u++){n=e[u][0],a=e[u][1],f=e[u][2];for(var l=!0,o=0;o<n.length;o++)(!1&f||c>=f)&&Object.keys(r.O).every(function(b){return r.O[b](n[o])})?n.splice(o--,1):(l=!1,f<c&&(c=f));if(l){e.splice(u--,1);var i=a();void 0!==i&&(t=i)}}return t}f=f||0;for(var u=e.length;u>0&&e[u-1][2]>f;u--)e[u]=e[u-1];e[u]=[n,a,f]},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},function(){var e={666:0};r.O.j=function(a){return 0===e[a]};var t=function(a,f){var o,i,u=f[0],c=f[1],l=f[2],v=0;for(o in c)r.o(c,o)&&(r.m[o]=c[o]);if(l)var _=l(r);for(a&&a(f);v<u.length;v++)r.o(e,i=u[v])&&e[i]&&e[i][0](),e[u[v]]=0;return r.O(_)},n=self.webpackChunkuds_admin=self.webpackChunkuds_admin||[];n.forEach(t.bind(null,0)),n.push=t.bind(null,n.push.bind(n))}()}(); !function(){"use strict";var e,s={},d={};function r(e){var t=d[e];if(void 0!==t)return t.exports;var n=d[e]={exports:{}};return s[e].call(n.exports,n,n.exports,r),n.exports}r.m=s,e=[],r.O=function(t,n,c,f){if(!n){var i=1/0;for(u=0;u<e.length;u++){n=e[u][0],c=e[u][1],f=e[u][2];for(var l=!0,o=0;o<n.length;o++)(!1&f||i>=f)&&Object.keys(r.O).every(function(p){return r.O[p](n[o])})?n.splice(o--,1):(l=!1,f<i&&(i=f));if(l){e.splice(u--,1);var a=c();void 0!==a&&(t=a)}}return t}f=f||0;for(var u=e.length;u>0&&e[u-1][2]>f;u--)e[u]=e[u-1];e[u]=[n,c,f]},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},function(){var e={666:0};r.O.j=function(c){return 0===e[c]};var t=function(c,f){var o,a,u=f[0],i=f[1],l=f[2],v=0;if(u.some(function(_){return 0!==e[_]})){for(o in i)r.o(i,o)&&(r.m[o]=i[o]);if(l)var b=l(r)}for(c&&c(f);v<u.length;v++)r.o(e,a=u[v])&&e[a]&&e[a][0](),e[a]=0;return r.O(b)},n=self.webpackChunkuds=self.webpackChunkuds||[];n.forEach(t.bind(null,0)),n.push=t.bind(null,n.push.bind(n))}()}();

File diff suppressed because one or more lines are too long

View File

@ -111,15 +111,6 @@ gettext("Delete group");
gettext("New Authenticator"); gettext("New Authenticator");
gettext("Edit Authenticator"); gettext("Edit Authenticator");
gettext("Delete Authenticator"); gettext("Delete Authenticator");
gettext("New Network");
gettext("Edit Network");
gettext("Delete Network");
gettext("New Proxy");
gettext("Edit Proxy");
gettext("Delete Proxy");
gettext("New Transport");
gettext("Edit Transport");
gettext("Delete Transport");
gettext("New OS Manager"); gettext("New OS Manager");
gettext("Edit OS Manager"); gettext("Edit OS Manager");
gettext("Delete OS Manager"); gettext("Delete OS Manager");
@ -266,6 +257,15 @@ gettext("Report finished");
gettext("dismiss"); gettext("dismiss");
gettext("Generate report"); gettext("Generate report");
gettext("Delete tunnel token - USE WITH EXTREME CAUTION!!!"); gettext("Delete tunnel token - USE WITH EXTREME CAUTION!!!");
gettext("New Notifier");
gettext("Edit Notifier");
gettext("Delete actor token - USE WITH EXTREME CAUTION!!!");
gettext("New Network");
gettext("Edit Network");
gettext("Delete Network");
gettext("New Transport");
gettext("Edit Transport");
gettext("Delete Transport");
gettext("Error saving: "); gettext("Error saving: ");
gettext("Error saving element"); gettext("Error saving element");
gettext("Error handling your request"); gettext("Error handling your request");
@ -311,12 +311,10 @@ gettext("User mode");
gettext("Logout"); gettext("Logout");
gettext("Summary"); gettext("Summary");
gettext("Services"); gettext("Services");
gettext("Networks");
gettext("Authenticators"); gettext("Authenticators");
gettext("Os Managers"); gettext("Os Managers");
gettext("Connectivity");
gettext("Transports"); gettext("Transports");
gettext("Networks");
gettext("Proxies");
gettext("Pools"); gettext("Pools");
gettext("Service pools"); gettext("Service pools");
gettext("Meta pools"); gettext("Meta pools");
@ -326,6 +324,7 @@ gettext("Accounts");
gettext("Tools"); gettext("Tools");
gettext("Gallery"); gettext("Gallery");
gettext("Reports"); gettext("Reports");
gettext("Notifiers");
gettext("Tokens"); gettext("Tokens");
gettext("Actor"); gettext("Actor");
gettext("Tunnel"); gettext("Tunnel");

File diff suppressed because one or more lines are too long