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

Adding tags & tag edition to mayor elemets of uds administration (for filtering, etc..)

This commit is contained in:
Adolfo Gómez García 2016-02-10 03:53:51 +01:00
parent 134f2059dd
commit 6bb1109fe1
15 changed files with 68 additions and 10 deletions

View File

@ -89,6 +89,7 @@ class Authenticators(ModelHandler):
return { return {
'id': auth.uuid, 'id': auth.uuid,
'name': auth.name, 'name': auth.name,
'tags': [tag.tag for tag in auth.tags.all()],
'comments': auth.comments, 'comments': auth.comments,
'priority': auth.priority, 'priority': auth.priority,
'small_name': auth.small_name, 'small_name': auth.small_name,

View File

@ -66,6 +66,7 @@ class Calendars(ModelHandler):
return { return {
'id': calendar.uuid, 'id': calendar.uuid,
'name': calendar.name, 'name': calendar.name,
'tags': [tag.tag for tag in calendar.tags.all()],
'comments': calendar.comments, 'comments': calendar.comments,
'modified': calendar.modified, 'modified': calendar.modified,
'permission': permissions.getEffectivePermission(self._user, calendar) 'permission': permissions.getEffectivePermission(self._user, calendar)

View File

@ -88,6 +88,7 @@ class Networks(ModelHandler):
return { return {
'id': item.uuid, 'id': item.uuid,
'name': item.name, 'name': item.name,
'tags': [tag.tag for tag in item.tags.all()],
'net_string': item.net_string, 'net_string': item.net_string,
'networks_count': item.transports.count(), 'networks_count': item.transports.count(),
'permission': permissions.getEffectivePermission(self._user, item) 'permission': permissions.getEffectivePermission(self._user, item)

View File

@ -64,6 +64,7 @@ class OsManagers(ModelHandler):
return { return {
'id': osm.uuid, 'id': osm.uuid,
'name': osm.name, 'name': osm.name,
'tags': [tag.tag for tag in osm.tags.all()],
'deployed_count': osm.deployedServices.count(), 'deployed_count': osm.deployedServices.count(),
'type': type_.type(), 'type': type_.type(),
'servicesTypes': type_.servicesType, 'servicesTypes': type_.servicesType,

View File

@ -84,6 +84,7 @@ class Providers(ModelHandler):
return { return {
'id': provider.uuid, 'id': provider.uuid,
'name': provider.name, 'name': provider.name,
'tags': [tag.vtag for tag in provider.tags.all()],
'services_count': provider.services.count(), 'services_count': provider.services.count(),
'user_services_count': UserService.objects.filter(deployed_service__service__provider=provider).count(), 'user_services_count': UserService.objects.filter(deployed_service__service__provider=provider).count(),
'maintenance_mode': provider.maintenance_mode, 'maintenance_mode': provider.maintenance_mode,
@ -104,7 +105,7 @@ class Providers(ModelHandler):
# Gui related # Gui related
def getGui(self, type_): def getGui(self, type_):
try: try:
return self.addDefaultFields(services.factory().lookup(type_).guiDescription(), ['name', 'comments']) return self.addDefaultFields(services.factory().lookup(type_).guiDescription(), ['name', 'comments', 'tags'])
except Exception: except Exception:
raise NotFound('type not found') raise NotFound('type not found')

View File

@ -84,6 +84,7 @@ class Services(DetailHandler): # pylint: disable=too-many-public-methods
retVal = { retVal = {
'id': item.uuid, 'id': item.uuid,
'name': item.name, 'name': item.name,
'tags': [tag.tag for tag in item.tags.all()],
'comments': item.comments, 'comments': item.comments,
'type': item.data_type, 'type': item.data_type,
'type_name': _(itemType.name()), 'type_name': _(itemType.name()),

View File

@ -84,6 +84,7 @@ class ServicesPools(ModelHandler):
val = { val = {
'id': item.uuid, 'id': item.uuid,
'name': item.name, 'name': item.name,
'tags': [tag.tag for tag in item.tags.all()],
'parent': item.service.name, 'parent': item.service.name,
'parent_type': item.service.data_type, 'parent_type': item.service.data_type,
'comments': item.comments, 'comments': item.comments,

View File

@ -88,6 +88,7 @@ class Transports(ModelHandler):
return { return {
'id': item.uuid, 'id': item.uuid,
'name': item.name, 'name': item.name,
'tags': [tag.tag for tag in item.tags.all()],
'comments': item.comments, 'comments': item.comments,
'priority': item.priority, 'priority': item.priority,
'nets_positive': item.nets_positive, 'nets_positive': item.nets_positive,

View File

@ -52,7 +52,7 @@ import logging
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
__updated__ = '2015-10-23' __updated__ = '2016-02-10'
# a few constants # a few constants
@ -112,6 +112,14 @@ class BaseModelHandler(Handler):
:param gui: Gui list where the "default" fielsds will be added :param gui: Gui list where the "default" fielsds will be added
:param flds: List of fields names requested to be added. Valid values are 'name', 'comments', 'priority' and 'small_name' :param flds: List of fields names requested to be added. Valid values are 'name', 'comments', 'priority' and 'small_name'
''' '''
if 'tags' in flds:
self.addField(gui, {
'name': 'tags',
'label': _('Tags'),
'type': 'taglist',
'tooltip': _('Tags for this element'),
'order': 0 - 101,
})
if 'name' in flds: if 'name' in flds:
self.addField(gui, { self.addField(gui, {
'name': 'name', 'name': 'name',
@ -137,17 +145,17 @@ class BaseModelHandler(Handler):
'required': True, 'required': True,
'value': 1, 'value': 1,
'length': 4, 'length': 4,
'order': 0 - 98, 'order': 0 - 97,
}) })
if 'small_name' in flds: if 'small_name' in flds:
self.addField(gui, { self.addField(gui, {
'name': 'small_name', 'name': 'small_name',
'type': 'text', 'type': 'text',
'label': _('Tag'), 'label': _('Label'),
'tooltip': _('Tag for this element'), 'tooltip': _('Label for this element'),
'required': True, 'required': True,
'length': 128, 'length': 128,
'order': 0 - 97, 'order': 0 - 96,
}) })
return gui return gui

View File

@ -60,6 +60,10 @@ class Tag(UUIDModel):
db_table = 'uds_tag' db_table = 'uds_tag'
app_label = 'uds' app_label = 'uds'
@property
def vtag(self):
return self.tag.capitalize()
def __unicode__(self): def __unicode__(self):
return 'Tag: {} {}'.format(self.uuid, self.tag) return 'Tag: {} {}'.format(self.uuid, self.tag)

File diff suppressed because one or more lines are too long

View File

@ -225,6 +225,7 @@
{% js_template 'fld/text' %} {% js_template 'fld/text' %}
{% js_template 'fld/textbox' %} {% js_template 'fld/textbox' %}
{% js_template 'fld/date' %} {% js_template 'fld/date' %}
{% js_template 'fld/taglist' %}
</body> </body>
</html> </html>

View File

@ -14,8 +14,8 @@
(function(){ (function(){
"use strict"; "use strict";
var id = '{{ name }}_field_'; var id = '{{ name }}_field_';
var idTxt = '#' + id + 'txt'; var idTxt = 'input#' + id + 'txt';
var idHidden = '#' + id + 'hdn'; var idHidden = 'input#' + id + 'hdn';
$(idTxt).tooltip({ $(idTxt).tooltip({
placement: 'bottom', placement: 'bottom',
title: "{% endverbatim %}{% trans 'Click to edit list' %}{% verbatim %}", title: "{% endverbatim %}{% trans 'Click to edit list' %}{% verbatim %}",

View File

@ -0,0 +1,29 @@
{% extends "uds/admin/tmpl/fld/form-group.html" %}
{% load i18n %}
{% block field %}{% verbatim %}
{{# each value }}
<span class="label label-default"><i class="fa fa-close closeable tag_eliminator"></i> <b class="tag">{{ this }}</b></span>
{{/ each }}
</select>
{% endverbatim %}
{% comment %}<script>/*This is a little trick to make IDE recognize sintax hightlight, will not be show on render :-)*/{% endcomment %}
{% verbatim %}{{# javascript }}
(function(){
"use strict";
$('i.tag_eliminator').on('click', function() {
var $this = $(this);
var val = $this.parent().find('b.tag').text();
if(prompt(gettext('Remove') + val) == true) {
$(this).parent().html('');
}
})
}());
{{/ javascript }}{% endverbatim %}
{% comment %}</script>{% endcomment %}
{% endblock %}

View File

@ -338,6 +338,14 @@ body {
} }
} }
// tag elimicator (close)
.closeable {
&:hover {
cursor: pointer;
color: red;
}
}
/* theme */ /* theme */