forked from shaba/openuds
Updating dashboard to include accounts & proxy
This commit is contained in:
parent
9b0e1eb7ce
commit
a601220771
@ -58,7 +58,7 @@ class Accounts(ModelHandler):
|
||||
|
||||
table_title = _('Accounts')
|
||||
table_fields = [
|
||||
{'name': {'title': _('Name'), 'visible': True, 'type': 'iconType'}},
|
||||
{'name': {'title': _('Name'), 'visible': True}},
|
||||
{'comments': {'title': _('Comments')}},
|
||||
{'tags': {'title': _('tags'), 'visible': False}},
|
||||
]
|
||||
|
@ -66,15 +66,14 @@ class AccountsUsage(DetailHandler): # pylint: disable=too-many-public-methods
|
||||
:param full: If full is requested, add "extra" fields to complete information
|
||||
'''
|
||||
retVal = {
|
||||
'id': item.uuid,
|
||||
'name': item.name,
|
||||
'comments': item.comments,
|
||||
'uuid': item.uuid,
|
||||
'pool_uuid': item.pool_uuid,
|
||||
'pool_name': item.pool_name,
|
||||
'user_uuid': item.user_uuid,
|
||||
'user_name': item.user_name,
|
||||
'start': item.start,
|
||||
'end': item.end,
|
||||
'frequency': item.frequency,
|
||||
'interval': item.interval,
|
||||
'duration': item.duration,
|
||||
'duration_unit': item.duration_unit,
|
||||
'running': item.user_service is not None,
|
||||
'permission': perm
|
||||
}
|
||||
|
||||
@ -85,64 +84,35 @@ class AccountsUsage(DetailHandler): # pylint: disable=too-many-public-methods
|
||||
perm = permissions.getEffectivePermission(self._user, parent)
|
||||
try:
|
||||
if item is None:
|
||||
return [CalendarRules.usageToDict(k, perm) for k in parent.rules.all()]
|
||||
return [AccountsUsage.usageToDict(k, perm) for k in parent.usages.all()]
|
||||
else:
|
||||
k = parent.rules.get(uuid=processUuid(item))
|
||||
return CalendarRules.usageToDict(k, perm)
|
||||
k = parent.usages.get(uuid=processUuid(item))
|
||||
return AccountsUsage.usageToDict(k, perm)
|
||||
except Exception:
|
||||
logger.exception('itemId {}'.format(item))
|
||||
self.invalidItemException()
|
||||
|
||||
def getFields(self, parent):
|
||||
return [
|
||||
{'name': {'title': _('Rule name')}},
|
||||
{'pool_name': {'title': _('Pool name')}},
|
||||
{'user_name': {'title': _('User name')}},
|
||||
{'running': {'title': _('Running')}},
|
||||
{'start': {'title': _('Starts'), 'type': 'datetime'}},
|
||||
{'end': {'title': _('Ends'), 'type': 'date'}},
|
||||
{'frequency': {'title': _('Repeats'), 'type': 'dict', 'dict': dict((v[0], six.text_type(v[1])) for v in freqs) }},
|
||||
{'interval': {'title': _('Every'), 'type': 'callback'}},
|
||||
{'duration': {'title': _('Duration'), 'type': 'callback'}},
|
||||
{'comments': {'title': _('Comments')}},
|
||||
{'end': {'title': _('Ends'), 'type': 'datetime'}},
|
||||
]
|
||||
|
||||
def getRowStyle(self, parent):
|
||||
return {'field': 'running', 'prefix': 'row-running-'}
|
||||
|
||||
|
||||
def saveItem(self, parent, item):
|
||||
# Extract item db fields
|
||||
# We need this fields for all
|
||||
logger.debug('Saving rule {0} / {1}'.format(parent, item))
|
||||
fields = self.readFieldsFromParams(['name', 'comments', 'frequency', 'start', 'end', 'interval', 'duration', 'duration_unit'])
|
||||
|
||||
if int(fields['interval']) < 1:
|
||||
self.invalidItemException('Repeat must be greater than zero')
|
||||
|
||||
# Convert timestamps to datetimes
|
||||
fields['start'] = datetime.datetime.fromtimestamp(fields['start'])
|
||||
if fields['end'] != None:
|
||||
fields['end'] = datetime.datetime.fromtimestamp(fields['end'])
|
||||
|
||||
calRule = None
|
||||
try:
|
||||
if item is None: # Create new
|
||||
calRule = parent.rules.create(**fields)
|
||||
else:
|
||||
calRule = parent.rules.get(uuid=processUuid(item))
|
||||
calRule.__dict__.update(fields)
|
||||
calRule.save()
|
||||
except CalendarRule.DoesNotExist:
|
||||
self.invalidItemException()
|
||||
except IntegrityError: # Duplicate key probably
|
||||
raise RequestError(_('Element already exists (duplicate key error)'))
|
||||
except Exception as e:
|
||||
logger.exception('Saving calendar')
|
||||
raise RequestError('incorrect invocation to PUT: {0}'.format(e))
|
||||
|
||||
return self.getItems(parent, calRule.uuid)
|
||||
raise RequestError('Accounts usage cannot be edited')
|
||||
|
||||
def deleteItem(self, parent, item):
|
||||
logger.debug('Deleting rule {} from {}'.format(item, parent))
|
||||
logger.debug('Deleting account usage {} from {}'.format(item, parent))
|
||||
try:
|
||||
calRule = parent.rules.get(uuid=processUuid(item))
|
||||
calRule.calendar.modified = getSqlDatetime()
|
||||
calRule.calendar.save()
|
||||
calRule.delete()
|
||||
usage = parent.usages.get(uuid=processUuid(item))
|
||||
usage.delete()
|
||||
except Exception:
|
||||
logger.exception('Exception')
|
||||
self.invalidItemException()
|
||||
@ -151,6 +121,6 @@ class AccountsUsage(DetailHandler): # pylint: disable=too-many-public-methods
|
||||
|
||||
def getTitle(self, parent):
|
||||
try:
|
||||
return _('Rules of {0}').format(parent.name)
|
||||
return _('Usages of {0}').format(parent.name)
|
||||
except Exception:
|
||||
return _('Current rules')
|
||||
return _('Current usages')
|
||||
|
@ -48,7 +48,7 @@ import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
__updated__ = '2016-09-16'
|
||||
__updated__ = '2017-01-30'
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
@ -90,7 +90,7 @@ class User(UUIDModel):
|
||||
|
||||
@property
|
||||
def pretty_name(self):
|
||||
return self.manager.name + '@' + self.name
|
||||
return self.name + '@' + self.manager.name
|
||||
|
||||
def getManager(self):
|
||||
'''
|
||||
|
File diff suppressed because one or more lines are too long
@ -3,6 +3,8 @@ gui.accounts = new GuiElement(api.accounts, "accounts")
|
||||
gui.accounts.link = (event) ->
|
||||
"use strict"
|
||||
|
||||
|
||||
|
||||
useTable = undefined
|
||||
clearUsage = ->
|
||||
if useTable
|
||||
@ -36,20 +38,26 @@ gui.accounts.link = (event) ->
|
||||
$("#detail-placeholder").removeClass "hidden"
|
||||
# gui.tools.blockUI()
|
||||
id = selected[0].id
|
||||
usage = new GuiElement(api.accounts.detail(id, "usage", { permission: selected[0].permission }), "rules")
|
||||
usage = new GuiElement(api.accounts.detail(id, "usage", { permission: selected[0].permission }), "Usage")
|
||||
usageTable = usage.table(
|
||||
icon: 'calendars'
|
||||
icon: 'accounts'
|
||||
container: "usage-placeholder"
|
||||
rowSelect: "single"
|
||||
buttons: [
|
||||
"new"
|
||||
"edit"
|
||||
"delete"
|
||||
"xls"
|
||||
]
|
||||
onLoad: (k) ->
|
||||
# gui.tools.unblockUI()
|
||||
return # null return
|
||||
|
||||
onData: (data) ->
|
||||
gui.doLog 'Accounts data received'
|
||||
$.each data, (index, value) ->
|
||||
value.running = if value.running then gettext('Yes') else gettext('No')
|
||||
return
|
||||
return
|
||||
|
||||
)
|
||||
return
|
||||
|
||||
@ -63,8 +71,8 @@ gui.accounts.link = (event) ->
|
||||
"xls"
|
||||
"permissions"
|
||||
]
|
||||
onNew: gui.methods.typedNew(gui.calendars, gettext("New calendar"), gettext("Calendar creation error"))
|
||||
onEdit: gui.methods.typedEdit(gui.calendars, gettext("Edit calendar"), gettext("Calendar saving error"))
|
||||
onDelete: gui.methods.del(gui.calendars, gettext("Delete calendar"), gettext("Calendar deletion error"))
|
||||
onNew: gui.methods.typedNew(gui.accounts, gettext("New Account"), gettext("Account creation error"))
|
||||
onEdit: gui.methods.typedEdit(gui.accounts, gettext("Edit Account"), gettext("Account saving error"))
|
||||
onDelete: gui.methods.del(gui.accounts, gettext("Delete Account"), gettext("Account deletion error"))
|
||||
false
|
||||
false
|
||||
|
@ -231,6 +231,11 @@
|
||||
exec: gui.sPoolGroups.link
|
||||
cleanup: true
|
||||
}
|
||||
{
|
||||
id: "lnk-accounts"
|
||||
exec: gui.accounts.link
|
||||
cleanup: true
|
||||
}
|
||||
]
|
||||
$.each sidebarLinks, (index, value) ->
|
||||
gui.doLog "Adding " + value.id
|
||||
|
@ -26,21 +26,20 @@
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><img class="icon" src="{{ STATIC_URL }}/adm/img/icons/connectivity.png"/> <span class="menu-lnk">{% trans 'Connectivity' %} <b class="caret"></b></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="lnk-connectivity" href="#"><img class="icon" src="{{ STATIC_URL }}/adm/img/icons/transports.png"/> <span class="menu-lnk">{% trans 'Transports' %}</span></a></li>
|
||||
<li><a class="lnk-connectivity" href="#"><img class="icon" src="{{ STATIC_URL }}/adm/img/icons/proxy.png"/> <span class="menu-lnk">{% trans 'Proxies' %}</span></a></li>
|
||||
<li><a class="lnk-proxy" href="#"><img class="icon" src="{{ STATIC_URL }}/adm/img/icons/proxy.png"/> <span class="menu-lnk">{% trans 'Proxies' %}</span></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li><a class="lnk-deployed_services" href=""><img class="icon" src="{{ STATIC_URL }}/adm/img/icons/pools.png"/> <span class="menu-lnk">{% trans 'Service Pools' %}</span></a></li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><img class="icon" src="{{ STATIC_URL }}/adm/img/icons/miscellaneous.png"/> <span class="menu-lnk">{% trans 'Pools Config' %} <b class="caret"></b></span></a>
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><img class="icon" src="{{ STATIC_URL }}/adm/img/icons/miscellaneous.png"/> <span class="menu-lnk">{% trans 'Pools' %} <b class="caret"></b></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="lnk-deployed_services" href=""><img class="icon" src="{{ STATIC_URL }}/adm/img/icons/pools.png"/> <span class="menu-lnk">{% trans 'Service Pools' %}</span></a></li>
|
||||
{% if admin %}
|
||||
<li><a class="lnk-spoolsgroup" href="#"><img class="icon" src="{{ STATIC_URL }}/adm/img/icons/groups.png"/> <span class="menu-lnk">{% trans 'Groups' %}</span></a></li>
|
||||
<li><a class="lnk-gallery" href="#"><img class="icon" src="{{ STATIC_URL }}/adm/img/icons/gallery.png"/> <span class="menu-lnk">{% trans 'Gallery' %}</span></a></li>
|
||||
{% endif %}
|
||||
<li><a class="lnk-calendars" href="#"><img class="icon" src="{{ STATIC_URL }}/adm/img/icons/calendars.png"/> <span class="menu-lnk">{% trans 'Calendars' %}</span></a></li>
|
||||
<li><a class="lnk-accounts" href="#"><img class="icon" src="{{ STATIC_URL }}/adm/img/icons/miscellaneous.png"/> <span class="menu-lnk">{% trans 'Accounts' %}</span></a></li>
|
||||
<li><a class="lnk-accounts" href="#"><img class="icon" src="{{ STATIC_URL }}/adm/img/icons/accounts.png"/> <span class="menu-lnk">{% trans 'Accounts' %}</span></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
<div id="detail-placeholder" class="row hidden">
|
||||
<div class="col-xs-12">
|
||||
<ul class="bottom_tabs nav nav-tabs">
|
||||
<li class="active"><a href="#{{ usage }}_tab" data-toggle="tab">{% endverbatim %}{% trans 'Rules' %}{% verbatim %}</a></li>
|
||||
<li class="active"><a href="#{{ usage }}_tab" data-toggle="tab">{% endverbatim %}{% trans 'Usage' %}{% verbatim %}</a></li>
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane fade in active" id="{{ usage }}_tab">
|
||||
|
@ -73,6 +73,10 @@ This states displays as default
|
||||
color: gray;
|
||||
}
|
||||
|
||||
.row-running-Yes {
|
||||
color: green;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.label-tbl-button {
|
||||
display: none;
|
||||
@ -83,4 +87,3 @@ This states displays as default
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,2 +1,3 @@
|
||||
#!/bin/sh
|
||||
grunt build
|
||||
cp dist/css/main.css ../../src/uds/static/adm/css/uds.css
|
||||
|
Loading…
Reference in New Issue
Block a user