mirror of
https://github.com/dkmstr/openuds.git
synced 2025-01-24 02:04:09 +03:00
Added tags to search filter on admin, and also added "tabindex" to input fields
This commit is contained in:
parent
07ed8b9762
commit
16c1aba3e7
@ -60,7 +60,8 @@ class Authenticators(ModelHandler):
|
||||
{'comments': {'title': _('Comments')}},
|
||||
{'priority': {'title': _('Priority'), 'type': 'numeric', 'width': '5em'}},
|
||||
{'small_name': {'title': _('Tag')}},
|
||||
{'users_count': {'title': _('Users'), 'type': 'numeric', 'width': '5em'}}
|
||||
{'users_count': {'title': _('Users'), 'type': 'numeric', 'width': '5em'}},
|
||||
{'tags': {'title': _('tags'), 'visible': False}},
|
||||
]
|
||||
|
||||
def enum_types(self):
|
||||
|
@ -60,6 +60,7 @@ class Calendars(ModelHandler):
|
||||
{'name': {'title': _('Name'), 'visible': True, 'type': 'icon', 'icon': 'fa fa-calendar text-success'}},
|
||||
{'comments': {'title': _('Comments')}},
|
||||
{'modified': {'title': _('Modified'), 'type': 'datetime'}},
|
||||
{'tags': {'title': _('tags'), 'visible': False}},
|
||||
]
|
||||
|
||||
def item_as_dict(self, calendar):
|
||||
|
@ -59,7 +59,8 @@ class Networks(ModelHandler):
|
||||
table_fields = [
|
||||
{'name': {'title': _('Name'), 'visible': True, 'type': 'icon', 'icon': 'fa fa-globe text-success'}},
|
||||
{'net_string': {'title': _('Range')}},
|
||||
{'networks_count': {'title': _('Used by'), 'type': 'numeric', 'width': '8em'}}
|
||||
{'networks_count': {'title': _('Used by'), 'type': 'numeric', 'width': '8em'}},
|
||||
{'tags': {'title': _('tags'), 'visible': False}},
|
||||
]
|
||||
|
||||
def beforeSave(self, fields):
|
||||
|
@ -56,7 +56,8 @@ class OsManagers(ModelHandler):
|
||||
table_fields = [
|
||||
{'name': {'title': _('Name'), 'visible': True, 'type': 'iconType'}},
|
||||
{'comments': {'title': _('Comments')}},
|
||||
{'deployed_count': {'title': _('Used by'), 'type': 'numeric', 'width': '8em'}}
|
||||
{'deployed_count': {'title': _('Used by'), 'type': 'numeric', 'width': '8em'}},
|
||||
{'tags': {'title': _('tags'), 'visible': False}},
|
||||
]
|
||||
|
||||
def osmToDict(self, osm):
|
||||
|
@ -67,6 +67,7 @@ class Providers(ModelHandler):
|
||||
{'maintenance_state': {'title': _('Status')}},
|
||||
{'services_count': {'title': _('Services'), 'type': 'numeric', 'width': '5em'}},
|
||||
{'user_services_count': {'title': _('User Services'), 'type': 'numeric', 'width': '8em'}},
|
||||
{'tags': {'title': _('tags'), 'visible': False}},
|
||||
]
|
||||
# Field from where to get "class" and prefix for that class, so this will generate "row-state-A, row-state-X, ....
|
||||
table_row_style = {'field': 'maintenance_mode', 'prefix': 'row-maintenance-'}
|
||||
|
@ -186,6 +186,7 @@ class Services(DetailHandler): # pylint: disable=too-many-public-methods
|
||||
{'type_name': {'title': _('Type')}},
|
||||
{'deployed_services_count': {'title': _('Deployed services'), 'type': 'numeric', 'width': '7em'}},
|
||||
{'user_services_count': {'title': _('User services'), 'type': 'numeric', 'width': '7em'}},
|
||||
{'tags': {'title': _('tags'), 'visible': False}},
|
||||
]
|
||||
|
||||
def getTypes(self, parent, forType):
|
||||
|
@ -73,7 +73,8 @@ class ServicesPools(ModelHandler):
|
||||
{'parent': {'title': _('Parent Service')}},
|
||||
{'state': {'title': _('status'), 'type': 'dict', 'dict': State.dictionary()}},
|
||||
{'show_transports': {'title': _('Shows transports'), 'type': 'callback'}},
|
||||
{'servicesPoolGroup': {'title': _('Services Pool Group')}},
|
||||
{'servicesPoolGroup': {'title': _('Pool Group')}},
|
||||
{'tags': {'title': _('tags'), 'visible': False}},
|
||||
]
|
||||
# Field from where to get "class" and prefix for that class, so this will generate "row-state-A, row-state-X, ....
|
||||
table_row_style = {'field': 'state', 'prefix': 'row-state-'}
|
||||
|
@ -55,7 +55,8 @@ class Transports(ModelHandler):
|
||||
{'priority': {'title': _('Priority'), 'type': 'numeric', 'width': '6em'}},
|
||||
{'name': {'title': _('Name'), 'visible': True, 'type': 'iconType'}},
|
||||
{'comments': {'title': _('Comments')}},
|
||||
{'deployed_count': {'title': _('Used by'), 'type': 'numeric', 'width': '8em'}}
|
||||
{'deployed_count': {'title': _('Used by'), 'type': 'numeric', 'width': '8em'}},
|
||||
{'tags': {'title': _('tags'), 'visible': False}},
|
||||
]
|
||||
|
||||
def enum_types(self):
|
||||
|
@ -42,6 +42,12 @@
|
||||
isEmpty: (obj) ->
|
||||
return $.isEmptyObject(obj)
|
||||
|
||||
random: () ->
|
||||
return Math.random().toString().split(".")[1]
|
||||
|
||||
cleanWhiteSpaces: (str) ->
|
||||
return str.split(' ').join('')
|
||||
|
||||
return
|
||||
) window.api = window.api or {}, jQuery
|
||||
|
||||
|
@ -164,7 +164,7 @@ gui.providers.link = (event) ->
|
||||
|
||||
val = vals[0]
|
||||
|
||||
gui.promptModal gettext("Maintenance Mode"), (if val.maintenance_mode is false then gettext("Enter Maintenance Mode?") else gettext("Exit Maintenance Mode?")),
|
||||
gui.forms.confirmModal gettext("Maintenance Mode"), (if val.maintenance_mode is false then gettext("Enter Maintenance Mode?") else gettext("Exit Maintenance Mode?")),
|
||||
onYes: ->
|
||||
gui.doLog 'Val: ', val
|
||||
api.providers.maintenance val.id, (->
|
||||
|
@ -449,7 +449,7 @@ gui.servicesPools.link = (event) ->
|
||||
disabled: true
|
||||
click: (val, value, btn, tbl, refreshFnc) ->
|
||||
gui.doLog val, val[0]
|
||||
gui.promptModal gettext("Publish"), gettext("Cancel publication?"),
|
||||
gui.forms.confirmModal gettext("Publish"), gettext("Cancel publication?"),
|
||||
onYes: ->
|
||||
pubApi.invoke val[0].id + "/cancel", ->
|
||||
refreshFnc()
|
||||
|
@ -177,7 +177,6 @@
|
||||
$.each data.fields, (index, value) ->
|
||||
for v of value
|
||||
opts = value[v]
|
||||
gui.doLog('***', opts, v, value)
|
||||
column = data: v
|
||||
column.title = opts.title
|
||||
column.render = renderEmptyCell
|
||||
@ -215,8 +214,6 @@
|
||||
columns.push column
|
||||
return
|
||||
|
||||
gui.doLog('** Colums', columns)
|
||||
|
||||
|
||||
# Responsive style for tables, using tables.css and this code generates the "titles" for vertical display on small sizes
|
||||
initTable = (data) ->
|
||||
|
@ -22,7 +22,9 @@
|
||||
fillers = [] # Fillers (callbacks)
|
||||
originalValues = {} # Initial stored values (defaults to "reset" form and also used on fillers callback to try to restore previous value)
|
||||
# itemGui is expected to have fields sorted by .gui.order (REST api returns them sorted)
|
||||
index = 0
|
||||
$.each itemGui, (index, f) ->
|
||||
index = index + 1
|
||||
# Not exactly a field, maybe some other info...
|
||||
gui.doLog "Processing ", f
|
||||
return if not f.gui?
|
||||
@ -47,6 +49,7 @@
|
||||
|
||||
originalValues[f.name] = value # Store original value
|
||||
html += api.templates.evaluate("tmpl_fld_" + f.gui.type,
|
||||
index: index
|
||||
id: id
|
||||
value: value # If no value present, use default value
|
||||
minValue: f.gui.minValue
|
||||
@ -200,7 +203,7 @@
|
||||
gui.forms.launchModal = (options, onSuccess) ->
|
||||
options = options or {}
|
||||
gui.doLog options
|
||||
id = "modal-" + Math.random().toString().split(".")[1] # Get a random ID for this modal
|
||||
id = "modal-" + api.tools.random() # Get a random ID for this modal
|
||||
ff = gui.forms.fromFields(options.fields, options.item)
|
||||
footer = ""
|
||||
clickEventHandlers = []
|
||||
@ -284,6 +287,58 @@
|
||||
|
||||
return
|
||||
|
||||
gui.forms.confirmModal = (title, question, options) ->
|
||||
options = options or {}
|
||||
options.actionButton = "<button type=\"button\" class=\"btn btn-primary button-yes\">" + (options.yesButton or gettext("yes")) + "</button>"
|
||||
options.closeButton = "<button type=\"button\" class=\"btn btn-danger button-no\">" + (options.noButton or gettext("no")) + "</button>"
|
||||
onYes = options.onYes or ->
|
||||
|
||||
onNo = options.onNo or ->
|
||||
|
||||
modalId = gui.launchModal(title, question, options)
|
||||
$(modalId + " .button-yes").on "click", (event) ->
|
||||
$(modalId).modal "hide"
|
||||
onYes()
|
||||
return
|
||||
|
||||
$(modalId + " .button-no").on "click", (event) ->
|
||||
$(modalId).modal "hide"
|
||||
onNo()
|
||||
return
|
||||
|
||||
return
|
||||
|
||||
gui.forms.promptModal = (title, message, options) ->
|
||||
options = options or {}
|
||||
options.actionButton = "<button type=\"button\" class=\"btn btn-primary button-yes\">" + (options.acceptButton or gettext("Accept")) + "</button>"
|
||||
options.closeButton = "<button type=\"button\" class=\"btn btn-danger button-no\">" + (options.closeButton or gettext("Close")) + "</button>"
|
||||
|
||||
onAccept = options.onAccept or ->
|
||||
onClose = options.onClose or ->
|
||||
|
||||
html = '<div class="row"><div class="col-sm-12">' + message + '</div></div><div class="row"><div class="col-sm-12"><input class="form-control" type="text" name="text" autofocus></div></div>'
|
||||
|
||||
modalId = gui.launchModal(title, html, options)
|
||||
|
||||
textField = $(modalId + ' input[name="text"]')
|
||||
setTimeout ()->
|
||||
textField.focus()
|
||||
, 100
|
||||
|
||||
$(modalId + " .button-yes").on "click", (event) ->
|
||||
text = textField.val()
|
||||
$(modalId).modal "hide"
|
||||
onAccept(text)
|
||||
return
|
||||
|
||||
$(modalId + " .button-no").on "click", (event) ->
|
||||
$(modalId).modal "hide"
|
||||
onClose()
|
||||
return
|
||||
gui.doLog "***** Datos ", modalId, textField
|
||||
|
||||
return
|
||||
|
||||
|
||||
# simple gui generators
|
||||
gui.forms.guiField = (name, type, label, tooltip, value, values, length, multiline, readonly, required) ->
|
||||
|
@ -136,27 +136,6 @@
|
||||
|
||||
return
|
||||
|
||||
gui.promptModal = (title, question, options) ->
|
||||
options = options or {}
|
||||
options.actionButton = "<button type=\"button\" class=\"btn btn-primary button-yes\">" + (options.yesButton or gettext("yes")) + "</button>"
|
||||
options.closeButton = "<button type=\"button\" class=\"btn btn-danger button-no\">" + (options.yesButton or gettext("no")) + "</button>"
|
||||
onYes = options.onYes or ->
|
||||
|
||||
onNo = options.onNo or ->
|
||||
|
||||
modalId = gui.launchModal(title, question, options)
|
||||
$(modalId + " .button-yes").on "click", (event) ->
|
||||
$(modalId).modal "hide"
|
||||
onYes()
|
||||
return
|
||||
|
||||
$(modalId + " .button-no").on "click", (event) ->
|
||||
$(modalId).modal "hide"
|
||||
onNo()
|
||||
return
|
||||
|
||||
return
|
||||
|
||||
gui.clearWorkspace = ->
|
||||
$("#content").empty()
|
||||
$("#minimized").empty()
|
||||
|
@ -1,6 +1,6 @@
|
||||
{% extends "uds/admin/tmpl/fld/form-group.html" %}
|
||||
{% block field %}
|
||||
{% verbatim %}
|
||||
<input type="{% endverbatim %}{% block type %}text{% endblock %}{% verbatim %}" class="form-control {{ css }}" name="{{ name }}" id="{{ name }}_field" placeholder="{{ tooltip }}" value="{{ value }}"{{# if readonly }} readonly{{/ if }} {{# if required }} required {{/ if }} data-minval="{{ minValue }}" data-maxVal="{{ maxValue }}">
|
||||
<input type="{% endverbatim %}{% block type %}text{% endblock %}{% verbatim %}" class="form-control {{ css }}" name="{{ name }}" id="{{ name }}_field" placeholder="{{ tooltip }}" value="{{ value }}"{{# if readonly }} readonly{{/ if }} {{# if required }} required {{/ if }} data-minval="{{ minValue }}" data-maxVal="{{ maxValue }}" tabindex="{{ index }}">
|
||||
{% endverbatim %}
|
||||
{% endblock %}
|
@ -7,7 +7,8 @@
|
||||
data-off-text="{% endverbatim %}{% trans 'No' %}{% verbatim %}"
|
||||
class="{{ css }}"
|
||||
name="{{ name }}"
|
||||
id="{{ name }}_field"{{# ifequals value true }} checked{{/ ifequals }}{{# if readonly }} disabled{{/ if }}>
|
||||
id="{{ name }}_field"{{# ifequals value true }} checked{{/ ifequals }}{{# if readonly }} disabled{{/ if }}
|
||||
tabindex="{{ index }}">
|
||||
|
||||
{% endverbatim %}
|
||||
{% endblock %}
|
@ -3,7 +3,7 @@
|
||||
{% comment %}The choice item MUST be a Select{% endcomment %}
|
||||
{% block field %}
|
||||
{% verbatim %}
|
||||
<select class="selectpicker show-menu-arrow show-tick {{ css }}" name="{{ name }}" data-style="btn-default" data-width="100%" id="{{ name }}_field" {{# if readonly }} disabled{{/ if }}{{# if required }} required{{/ if }}>
|
||||
<select class="selectpicker show-menu-arrow show-tick {{ css }}" name="{{ name }}" data-style="btn-default" data-width="100%" id="{{ name }}_field" {{# if readonly }} disabled{{/ if }}{{# if required }} required{{/ if }} tabindex="{{ index }}">
|
||||
{{#each values }}
|
||||
<option value="{{ id }}"{{# ifequals id ../value }}selected{{/ ifequals }}>{{ text }}</option>
|
||||
{{/each}}
|
||||
|
@ -3,7 +3,7 @@
|
||||
{% block field %}
|
||||
{% verbatim %}
|
||||
<div class="input-group date">
|
||||
<input type="date" class="form-control {{ css }}" name="{{ name }}" id="{{ name }}_field" placeholder="{{ tooltip }}" value="{{ value }}"{{# if readonly }} readonly{{/ if }} {{# if required }} required {{/ if }} data-minval="{{ minValue }}"><span class="input-group-addon"><i class="glyphicon glyphicon-th"></i></span>
|
||||
<input type="date" class="form-control {{ css }}" name="{{ name }}" id="{{ name }}_field" placeholder="{{ tooltip }}" value="{{ value }}"{{# if readonly }} readonly{{/ if }} {{# if required }} required {{/ if }} data-minval="{{ minValue }}" tabindex="{{ index }}"><span class="input-group-addon"><i class="glyphicon glyphicon-th"></i></span>
|
||||
</div>
|
||||
|
||||
{% endverbatim %}
|
||||
|
@ -1,7 +1,7 @@
|
||||
{% extends "uds/admin/tmpl/fld/form-group.html" %}
|
||||
{% load i18n %}
|
||||
{% block field %}{% verbatim %}
|
||||
<input name="{{ name }}_nonused1" type="text" id="{{ name }}_field_txt" class="form-control cursor-pointer" value="{{ truncatechars 64 value }}" readonly>
|
||||
<input name="{{ name }}_nonused1" type="text" id="{{ name }}_field_txt" class="form-control cursor-pointer" value="{{ truncatechars 64 value }}" readonly tabindex="{{ index }}">
|
||||
{{! We use a Select to get an array of selected values on ".val()" }}
|
||||
<select id="{{ name }}_field_hdn" class="{{ css }} hidden" name="{{ name }}" multiple>
|
||||
{{# each value }}
|
||||
|
@ -3,7 +3,7 @@
|
||||
{% comment %}The choice item MUST be a Select{% endcomment %}
|
||||
{% block field %}
|
||||
{% verbatim %}
|
||||
<select class="selectpicker show-menu-arrow show-tick {{ css }}" name="{{ name }}" data-style="btn-default" data-width="100%" id="{{ name }}_field" {{# if readonly }} disabled{{/ if }}{{# if required }} required{{/ if }}>
|
||||
<select class="selectpicker show-menu-arrow show-tick {{ css }}" name="{{ name }}" data-style="btn-default" data-width="100%" id="{{ name }}_field" {{# if readonly }} disabled{{/ if }}{{# if required }} required{{/ if }} tabindex="{{ index }}">
|
||||
{{#each values }}
|
||||
<option data-content="<img style='width: 24px; height: 24px;' src='data:image/png;base64,{{ img }}'/> {{ text }}" value="{{ id }}"{{# ifequals id ../value }}selected{{/ ifequals }}>{{ text }}</option>
|
||||
{{/each}}
|
||||
|
@ -3,7 +3,7 @@
|
||||
{% comment %}The choice item MUST be a Select.{% endcomment %}
|
||||
{% block field %}
|
||||
{% verbatim %}
|
||||
<select class="selectpicker show-menu-arrow {{ css }}" multiple data-style="btn-default" data-selected-text-format="count>3" data-width="100%" name="{{ name }}" id="{{ name }}_field" {{# if readonly }} disabled{{/ if }}{{# if required }} required{{/ if }}>
|
||||
<select class="selectpicker show-menu-arrow {{ css }}" multiple data-style="btn-default" data-selected-text-format="count>3" data-width="100%" name="{{ name }}" id="{{ name }}_field" {{# if readonly }} disabled{{/ if }}{{# if required }} required{{/ if }} tabindex="{{ index }}">
|
||||
{{#each values }}
|
||||
<option value="{{ id }}"{{# ifbelongs id ../value }}selected{{/ ifbelongs }}>{{ text }}</option>
|
||||
{{/each}}
|
||||
|
@ -1,7 +1,7 @@
|
||||
{% extends "uds/admin/tmpl/fld/form-group.html" %}
|
||||
{% load i18n %}
|
||||
{% block field %}{% verbatim %}
|
||||
<div id="tags{{ id }}">
|
||||
<div id="tags{{ id }}" tabindex="{{ index }}">
|
||||
</div>
|
||||
|
||||
{{# unless readonly }}
|
||||
@ -33,7 +33,7 @@
|
||||
$('i.tag_eliminator').on('click', function() {
|
||||
var $this = $(this);
|
||||
var val = $this.parent().find('b.tag').text();
|
||||
gui.promptModal(val, gettext('Are you sure to remove tag?'), {
|
||||
gui.forms.confirmModal(val, gettext('Are you sure to remove tag?'), {
|
||||
onYes: function() {
|
||||
removeTag(val);
|
||||
}
|
||||
@ -43,9 +43,16 @@
|
||||
|
||||
// Tagadder never gets destroyed, so we only set the event once
|
||||
$('#adder{{ id }}').on('click', function(){
|
||||
var text = prompt('Enter new tag');
|
||||
$.each( text.split(','), function (idx, value) {
|
||||
addTag(value);
|
||||
gui.forms.promptModal('Tag', gettext('Enter new tag'), {
|
||||
onAccept: function(text) {
|
||||
text = api.tools.cleanWhiteSpaces(text);
|
||||
if( text == '')
|
||||
return;
|
||||
|
||||
$.each( text.split(','), function (idx, value) {
|
||||
addTag(value);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{% extends "uds/admin/tmpl/fld/form-group.html" %}
|
||||
{% block field %}
|
||||
{% verbatim %}
|
||||
<textarea class="form-control {{ css }}" name="{{ name }}" id="{{ name }}_field" placeholder="{{ tooltip }}" {{# if readonly }} readonly{{/ if }}>{{ value }}</textarea>
|
||||
<textarea class="form-control {{ css }}" name="{{ name }}" id="{{ name }}_field" placeholder="{{ tooltip }}" {{# if readonly }} readonly{{/ if }} tabindex="{{ index }}">{{ value }}</textarea>
|
||||
{% endverbatim %}
|
||||
{% endblock %}
|
Loading…
x
Reference in New Issue
Block a user