mirror of
https://github.com/dkmstr/openuds.git
synced 2024-12-22 13:34:04 +03:00
* Fixed a bunch of javascript things
* Added "gui" method to api, so we can get a description of what fields are needed for an specific item. Added REST capacity to process gui requests Updated translations
This commit is contained in:
parent
805b225552
commit
2bf0c3e59a
@ -37,7 +37,7 @@ from django.views.decorators.csrf import csrf_exempt
|
|||||||
from django.utils.decorators import method_decorator
|
from django.utils.decorators import method_decorator
|
||||||
from django.utils.translation import ugettext as _, activate
|
from django.utils.translation import ugettext as _, activate
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from handlers import Handler, HandlerError, AccessDenied
|
from handlers import Handler, HandlerError, AccessDenied, NotFound
|
||||||
|
|
||||||
import time
|
import time
|
||||||
import logging
|
import logging
|
||||||
@ -150,6 +150,10 @@ class Dispatcher(View):
|
|||||||
return response
|
return response
|
||||||
except HandlerError as e:
|
except HandlerError as e:
|
||||||
return http.HttpResponseBadRequest(unicode(e))
|
return http.HttpResponseBadRequest(unicode(e))
|
||||||
|
except AccessDenied as e:
|
||||||
|
return http.HttpResponseForbidden(unicode(e))
|
||||||
|
except NotFound as e:
|
||||||
|
return http.Http404(unicode(e))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.exception('Error processing request')
|
logger.exception('Error processing request')
|
||||||
return http.HttpResponseServerError(unicode(e))
|
return http.HttpResponseServerError(unicode(e))
|
||||||
|
@ -46,6 +46,9 @@ AUTH_TOKEN_HEADER = 'HTTP_X_AUTH_TOKEN'
|
|||||||
class HandlerError(Exception):
|
class HandlerError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class NotFound(HandlerError):
|
||||||
|
pass
|
||||||
|
|
||||||
class AccessDenied(HandlerError):
|
class AccessDenied(HandlerError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ from uds.core import auths
|
|||||||
|
|
||||||
|
|
||||||
from users import Users
|
from users import Users
|
||||||
from uds.REST import Handler, HandlerError
|
from uds.REST import Handler, NotFound
|
||||||
from uds.REST.mixins import ModelHandlerMixin, ModelTypeHandlerMixin, ModelTableHandlerMixin
|
from uds.REST.mixins import ModelHandlerMixin, ModelTypeHandlerMixin, ModelTableHandlerMixin
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
@ -65,6 +65,13 @@ class Types(ModelTypeHandlerMixin, Handler):
|
|||||||
|
|
||||||
def enum_types(self):
|
def enum_types(self):
|
||||||
return auths.factory().providers().values()
|
return auths.factory().providers().values()
|
||||||
|
|
||||||
|
def getGui(self, type_):
|
||||||
|
try:
|
||||||
|
return auths.factory().lookup(type_).guiDescription()
|
||||||
|
except:
|
||||||
|
raise NotFound('type not found')
|
||||||
|
|
||||||
|
|
||||||
class TableInfo(ModelTableHandlerMixin, Handler):
|
class TableInfo(ModelTableHandlerMixin, Handler):
|
||||||
path = 'authenticators'
|
path = 'authenticators'
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
'''
|
'''
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from handlers import NotFound
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
@ -85,7 +86,7 @@ class ModelHandlerMixin(object):
|
|||||||
detail = detailCls(self, path, parent = item)
|
detail = detailCls(self, path, parent = item)
|
||||||
return getattr(detail, self._operation)()
|
return getattr(detail, self._operation)()
|
||||||
except:
|
except:
|
||||||
return {'error': 'method not found' }
|
raise NotFound('method not found')
|
||||||
|
|
||||||
def get(self):
|
def get(self):
|
||||||
logger.debug('method GET for {0}, {1}'.format(self.__class__.__name__, self._args))
|
logger.debug('method GET for {0}, {1}'.format(self.__class__.__name__, self._args))
|
||||||
@ -97,10 +98,9 @@ class ModelHandlerMixin(object):
|
|||||||
return self.processDetail()
|
return self.processDetail()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
item = list(self.getItems(pk=self._args[0]))[0]
|
return list(self.getItems(pk=self._args[0]))[0]
|
||||||
except:
|
except:
|
||||||
return {'error': 'not found' }
|
raise NotFound('item not found')
|
||||||
|
|
||||||
|
|
||||||
class ModelTypeHandlerMixin(object):
|
class ModelTypeHandlerMixin(object):
|
||||||
'''
|
'''
|
||||||
@ -122,13 +122,31 @@ class ModelTypeHandlerMixin(object):
|
|||||||
|
|
||||||
def getTypes(self, *args, **kwargs):
|
def getTypes(self, *args, **kwargs):
|
||||||
for type_ in self.enum_types():
|
for type_ in self.enum_types():
|
||||||
try:
|
yield self.type_as_dict(type_)
|
||||||
yield self.type_as_dict(type_)
|
|
||||||
except:
|
|
||||||
logger.exception('Exception enumerating types')
|
|
||||||
|
|
||||||
def get(self):
|
def get(self):
|
||||||
return list(self.getTypes())
|
logger.debug(self._args)
|
||||||
|
nArgs = len(self._args)
|
||||||
|
if nArgs == 0:
|
||||||
|
return list(self.getTypes())
|
||||||
|
|
||||||
|
found = None
|
||||||
|
for v in self.getTypes():
|
||||||
|
if v['type'] == self._args[0]:
|
||||||
|
found = v
|
||||||
|
break
|
||||||
|
|
||||||
|
if found is None:
|
||||||
|
raise NotFound('type not found')
|
||||||
|
|
||||||
|
logger.debug('Found type {0}'.format(v))
|
||||||
|
if nArgs == 1:
|
||||||
|
return found
|
||||||
|
|
||||||
|
if self._args[1] == 'gui':
|
||||||
|
gui = self.getGui(self._args[0])
|
||||||
|
logger.debug("GUI: {0}".format(gui))
|
||||||
|
return gui
|
||||||
|
|
||||||
|
|
||||||
class ModelTableHandlerMixin(object):
|
class ModelTableHandlerMixin(object):
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
'''
|
'''
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import get_language, ugettext as _
|
||||||
import cPickle
|
import cPickle
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@ -255,8 +255,8 @@ class gui(object):
|
|||||||
alter original values.
|
alter original values.
|
||||||
'''
|
'''
|
||||||
data = self._data.copy()
|
data = self._data.copy()
|
||||||
data['label'] = _(data['label'])
|
data['label'] = data['label'] != '' and _(data['label']) or ''
|
||||||
data['tooltip'] = _(data['tooltip'])
|
data['tooltip'] = data['tooltip'] != '' and _(data['tooltip']) or ''
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -816,6 +816,7 @@ class UserInterface(object):
|
|||||||
object: If not none, object that will get its "initGui" invoked
|
object: If not none, object that will get its "initGui" invoked
|
||||||
This will only happen (not to be None) in Services.
|
This will only happen (not to be None) in Services.
|
||||||
'''
|
'''
|
||||||
|
logger.debug('Active languaje for gui translation: {0}'.format(get_language()))
|
||||||
if obj is not None:
|
if obj is not None:
|
||||||
obj.initGui() # We give the "oportunity" to fill necesary gui data before providing it to client
|
obj.initGui() # We give the "oportunity" to fill necesary gui data before providing it to client
|
||||||
|
|
||||||
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -8,7 +8,7 @@ msgid ""
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2013-11-17 04:21+0100\n"
|
"POT-Creation-Date: 2013-11-20 04:05+0100\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
@ -18,14 +18,10 @@ msgstr ""
|
|||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||||
|
|
||||||
#: static/adm/js/gui-elements.js:7
|
#: static/adm/js/gui-elements.js:33
|
||||||
msgid "Service Providers"
|
msgid "Service Providers"
|
||||||
msgstr "Service-Provider"
|
msgstr "Service-Provider"
|
||||||
|
|
||||||
#: static/adm/js/gui-elements.js:81
|
|
||||||
msgid "Connectivity"
|
|
||||||
msgstr "Konnektivität"
|
|
||||||
|
|
||||||
#: static/adm/js/gui.js:18
|
#: static/adm/js/gui.js:18
|
||||||
msgid "_MENU_ records per page"
|
msgid "_MENU_ records per page"
|
||||||
msgstr "_MENU_ Datensätze pro Seite"
|
msgstr "_MENU_ Datensätze pro Seite"
|
||||||
@ -70,19 +66,19 @@ msgstr "Nächste"
|
|||||||
msgid "Previous"
|
msgid "Previous"
|
||||||
msgstr "Vorherige"
|
msgstr "Vorherige"
|
||||||
|
|
||||||
#: static/adm/js/gui.js:80
|
#: static/adm/js/gui.js:75
|
||||||
msgid "Deployed services"
|
msgid "Deployed services"
|
||||||
msgstr "Bereitgestellten Dienste"
|
msgstr "Bereitgestellten Dienste"
|
||||||
|
|
||||||
#: static/adm/js/gui.js:349
|
#: static/adm/js/gui.js:360
|
||||||
msgid "Edit"
|
msgid "Edit"
|
||||||
msgstr "Bearbeiten"
|
msgstr "Bearbeiten"
|
||||||
|
|
||||||
#: static/adm/js/gui.js:358
|
#: static/adm/js/gui.js:369
|
||||||
msgid "Delete"
|
msgid "Delete"
|
||||||
msgstr "Löschen"
|
msgstr "Löschen"
|
||||||
|
|
||||||
#: static/adm/js/gui.js:367
|
#: static/adm/js/gui.js:378
|
||||||
msgid "Refresh"
|
msgid "Refresh"
|
||||||
msgstr "Aktualisieren"
|
msgstr "Aktualisieren"
|
||||||
|
|
||||||
@ -161,3 +157,7 @@ msgstr "November"
|
|||||||
#: static/adm/js/strftime.js:35
|
#: static/adm/js/strftime.js:35
|
||||||
msgid "December"
|
msgid "December"
|
||||||
msgstr "Dezember"
|
msgstr "Dezember"
|
||||||
|
|
||||||
|
#: static/adm/js/tools.js:46
|
||||||
|
msgid "Just a moment..."
|
||||||
|
msgstr "Einen Moment..."
|
||||||
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -8,7 +8,7 @@ msgid ""
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2013-11-17 04:21+0100\n"
|
"POT-Creation-Date: 2013-11-20 04:05+0100\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
@ -18,14 +18,10 @@ msgstr ""
|
|||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||||
|
|
||||||
#: static/adm/js/gui-elements.js:7
|
#: static/adm/js/gui-elements.js:33
|
||||||
msgid "Service Providers"
|
msgid "Service Providers"
|
||||||
msgstr "Proveedores de servicios"
|
msgstr "Proveedores de servicios"
|
||||||
|
|
||||||
#: static/adm/js/gui-elements.js:81
|
|
||||||
msgid "Connectivity"
|
|
||||||
msgstr "Conectividad"
|
|
||||||
|
|
||||||
#: static/adm/js/gui.js:18
|
#: static/adm/js/gui.js:18
|
||||||
msgid "_MENU_ records per page"
|
msgid "_MENU_ records per page"
|
||||||
msgstr "Registros _MENU_ por página"
|
msgstr "Registros _MENU_ por página"
|
||||||
@ -70,19 +66,19 @@ msgstr "Próxima"
|
|||||||
msgid "Previous"
|
msgid "Previous"
|
||||||
msgstr "Anterior"
|
msgstr "Anterior"
|
||||||
|
|
||||||
#: static/adm/js/gui.js:80
|
#: static/adm/js/gui.js:75
|
||||||
msgid "Deployed services"
|
msgid "Deployed services"
|
||||||
msgstr "Servicios desplegados"
|
msgstr "Servicios desplegados"
|
||||||
|
|
||||||
#: static/adm/js/gui.js:349
|
#: static/adm/js/gui.js:360
|
||||||
msgid "Edit"
|
msgid "Edit"
|
||||||
msgstr "Editar"
|
msgstr "Editar"
|
||||||
|
|
||||||
#: static/adm/js/gui.js:358
|
#: static/adm/js/gui.js:369
|
||||||
msgid "Delete"
|
msgid "Delete"
|
||||||
msgstr "Borrar"
|
msgstr "Borrar"
|
||||||
|
|
||||||
#: static/adm/js/gui.js:367
|
#: static/adm/js/gui.js:378
|
||||||
msgid "Refresh"
|
msgid "Refresh"
|
||||||
msgstr "Actualización"
|
msgstr "Actualización"
|
||||||
|
|
||||||
@ -161,3 +157,7 @@ msgstr "Noviembre"
|
|||||||
#: static/adm/js/strftime.js:35
|
#: static/adm/js/strftime.js:35
|
||||||
msgid "December"
|
msgid "December"
|
||||||
msgstr "Diciembre"
|
msgstr "Diciembre"
|
||||||
|
|
||||||
|
#: static/adm/js/tools.js:46
|
||||||
|
msgid "Just a moment..."
|
||||||
|
msgstr "Un momento..."
|
||||||
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -8,7 +8,7 @@ msgid ""
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2013-11-17 04:21+0100\n"
|
"POT-Creation-Date: 2013-11-20 04:05+0100\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
@ -18,14 +18,10 @@ msgstr ""
|
|||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||||
|
|
||||||
#: static/adm/js/gui-elements.js:7
|
#: static/adm/js/gui-elements.js:33
|
||||||
msgid "Service Providers"
|
msgid "Service Providers"
|
||||||
msgstr "Fournisseurs de services"
|
msgstr "Fournisseurs de services"
|
||||||
|
|
||||||
#: static/adm/js/gui-elements.js:81
|
|
||||||
msgid "Connectivity"
|
|
||||||
msgstr "Connectivité"
|
|
||||||
|
|
||||||
#: static/adm/js/gui.js:18
|
#: static/adm/js/gui.js:18
|
||||||
msgid "_MENU_ records per page"
|
msgid "_MENU_ records per page"
|
||||||
msgstr "Documents _MENU_ par page"
|
msgstr "Documents _MENU_ par page"
|
||||||
@ -70,19 +66,19 @@ msgstr "Prochaine"
|
|||||||
msgid "Previous"
|
msgid "Previous"
|
||||||
msgstr "Précédent"
|
msgstr "Précédent"
|
||||||
|
|
||||||
#: static/adm/js/gui.js:80
|
#: static/adm/js/gui.js:75
|
||||||
msgid "Deployed services"
|
msgid "Deployed services"
|
||||||
msgstr "Services déployés"
|
msgstr "Services déployés"
|
||||||
|
|
||||||
#: static/adm/js/gui.js:349
|
#: static/adm/js/gui.js:360
|
||||||
msgid "Edit"
|
msgid "Edit"
|
||||||
msgstr "Edit"
|
msgstr "Edit"
|
||||||
|
|
||||||
#: static/adm/js/gui.js:358
|
#: static/adm/js/gui.js:369
|
||||||
msgid "Delete"
|
msgid "Delete"
|
||||||
msgstr "Supprimer"
|
msgstr "Supprimer"
|
||||||
|
|
||||||
#: static/adm/js/gui.js:367
|
#: static/adm/js/gui.js:378
|
||||||
msgid "Refresh"
|
msgid "Refresh"
|
||||||
msgstr "Actualisation"
|
msgstr "Actualisation"
|
||||||
|
|
||||||
@ -161,3 +157,7 @@ msgstr "Novembre"
|
|||||||
#: static/adm/js/strftime.js:35
|
#: static/adm/js/strftime.js:35
|
||||||
msgid "December"
|
msgid "December"
|
||||||
msgstr "Décembre"
|
msgstr "Décembre"
|
||||||
|
|
||||||
|
#: static/adm/js/tools.js:46
|
||||||
|
msgid "Just a moment..."
|
||||||
|
msgstr "Un instant..."
|
||||||
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -8,7 +8,7 @@ msgid ""
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2013-11-17 04:21+0100\n"
|
"POT-Creation-Date: 2013-11-20 04:05+0100\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
@ -18,14 +18,10 @@ msgstr ""
|
|||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||||
|
|
||||||
#: static/adm/js/gui-elements.js:7
|
#: static/adm/js/gui-elements.js:33
|
||||||
msgid "Service Providers"
|
msgid "Service Providers"
|
||||||
msgstr "Fornitori di servizi"
|
msgstr "Fornitori di servizi"
|
||||||
|
|
||||||
#: static/adm/js/gui-elements.js:81
|
|
||||||
msgid "Connectivity"
|
|
||||||
msgstr "Connettività"
|
|
||||||
|
|
||||||
#: static/adm/js/gui.js:18
|
#: static/adm/js/gui.js:18
|
||||||
msgid "_MENU_ records per page"
|
msgid "_MENU_ records per page"
|
||||||
msgstr "Record _MENU_ per pagina"
|
msgstr "Record _MENU_ per pagina"
|
||||||
@ -70,19 +66,19 @@ msgstr "Prossimo"
|
|||||||
msgid "Previous"
|
msgid "Previous"
|
||||||
msgstr "Precedente"
|
msgstr "Precedente"
|
||||||
|
|
||||||
#: static/adm/js/gui.js:80
|
#: static/adm/js/gui.js:75
|
||||||
msgid "Deployed services"
|
msgid "Deployed services"
|
||||||
msgstr "Servizi distribuiti"
|
msgstr "Servizi distribuiti"
|
||||||
|
|
||||||
#: static/adm/js/gui.js:349
|
#: static/adm/js/gui.js:360
|
||||||
msgid "Edit"
|
msgid "Edit"
|
||||||
msgstr "Modifica"
|
msgstr "Modifica"
|
||||||
|
|
||||||
#: static/adm/js/gui.js:358
|
#: static/adm/js/gui.js:369
|
||||||
msgid "Delete"
|
msgid "Delete"
|
||||||
msgstr "Eliminare"
|
msgstr "Eliminare"
|
||||||
|
|
||||||
#: static/adm/js/gui.js:367
|
#: static/adm/js/gui.js:378
|
||||||
msgid "Refresh"
|
msgid "Refresh"
|
||||||
msgstr "Aggiornamento"
|
msgstr "Aggiornamento"
|
||||||
|
|
||||||
@ -161,3 +157,7 @@ msgstr "Novembre"
|
|||||||
#: static/adm/js/strftime.js:35
|
#: static/adm/js/strftime.js:35
|
||||||
msgid "December"
|
msgid "December"
|
||||||
msgstr "Dicembre"
|
msgstr "Dicembre"
|
||||||
|
|
||||||
|
#: static/adm/js/tools.js:46
|
||||||
|
msgid "Just a moment..."
|
||||||
|
msgstr "Solo un momento..."
|
||||||
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -8,7 +8,7 @@ msgid ""
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2013-11-17 04:21+0100\n"
|
"POT-Creation-Date: 2013-11-20 04:05+0100\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
@ -18,14 +18,10 @@ msgstr ""
|
|||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||||
|
|
||||||
#: static/adm/js/gui-elements.js:7
|
#: static/adm/js/gui-elements.js:33
|
||||||
msgid "Service Providers"
|
msgid "Service Providers"
|
||||||
msgstr "Prestadores de serviços"
|
msgstr "Prestadores de serviços"
|
||||||
|
|
||||||
#: static/adm/js/gui-elements.js:81
|
|
||||||
msgid "Connectivity"
|
|
||||||
msgstr "Conectividade"
|
|
||||||
|
|
||||||
#: static/adm/js/gui.js:18
|
#: static/adm/js/gui.js:18
|
||||||
msgid "_MENU_ records per page"
|
msgid "_MENU_ records per page"
|
||||||
msgstr "Registros _MENU_ por página"
|
msgstr "Registros _MENU_ por página"
|
||||||
@ -70,19 +66,19 @@ msgstr "Próxima"
|
|||||||
msgid "Previous"
|
msgid "Previous"
|
||||||
msgstr "Anterior"
|
msgstr "Anterior"
|
||||||
|
|
||||||
#: static/adm/js/gui.js:80
|
#: static/adm/js/gui.js:75
|
||||||
msgid "Deployed services"
|
msgid "Deployed services"
|
||||||
msgstr "Serviços implantados"
|
msgstr "Serviços implantados"
|
||||||
|
|
||||||
#: static/adm/js/gui.js:349
|
#: static/adm/js/gui.js:360
|
||||||
msgid "Edit"
|
msgid "Edit"
|
||||||
msgstr "Editar"
|
msgstr "Editar"
|
||||||
|
|
||||||
#: static/adm/js/gui.js:358
|
#: static/adm/js/gui.js:369
|
||||||
msgid "Delete"
|
msgid "Delete"
|
||||||
msgstr "Excluir"
|
msgstr "Excluir"
|
||||||
|
|
||||||
#: static/adm/js/gui.js:367
|
#: static/adm/js/gui.js:378
|
||||||
msgid "Refresh"
|
msgid "Refresh"
|
||||||
msgstr "Atualização"
|
msgstr "Atualização"
|
||||||
|
|
||||||
@ -161,3 +157,7 @@ msgstr "Novembro"
|
|||||||
#: static/adm/js/strftime.js:35
|
#: static/adm/js/strftime.js:35
|
||||||
msgid "December"
|
msgid "December"
|
||||||
msgstr "Dezembro de"
|
msgstr "Dezembro de"
|
||||||
|
|
||||||
|
#: static/adm/js/tools.js:46
|
||||||
|
msgid "Just a moment..."
|
||||||
|
msgstr "Só um momento..."
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
|
/* jshint strict: true */
|
||||||
(function(api, $, undefined) {
|
(function(api, $, undefined) {
|
||||||
|
"use strict";
|
||||||
// "public" methods
|
// "public" methods
|
||||||
api.doLog = function(data) {
|
api.doLog = function(data) {
|
||||||
if (api.debug) {
|
if (api.debug) {
|
||||||
@ -17,8 +18,11 @@
|
|||||||
return new Cache(cacheName);
|
return new Cache(cacheName);
|
||||||
};
|
};
|
||||||
|
|
||||||
api.getJson = function(path, success_fnc) {
|
api.getJson = function(path, options) {
|
||||||
url = api.url_for(path);
|
options = options || {};
|
||||||
|
var success_fnc = options.success || function(){};
|
||||||
|
|
||||||
|
var url = api.url_for(path);
|
||||||
api.doLog('Ajax GET Json for "' + url + '"');
|
api.doLog('Ajax GET Json for "' + url + '"');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url : url,
|
url : url,
|
||||||
@ -27,10 +31,7 @@
|
|||||||
success : function(data) {
|
success : function(data) {
|
||||||
api.doLog('Success on "' + url + '".');
|
api.doLog('Success on "' + url + '".');
|
||||||
api.doLog('Received ' + JSON.stringify(data));
|
api.doLog('Received ' + JSON.stringify(data));
|
||||||
if (success_fnc !== undefined) {
|
success_fnc(data);
|
||||||
api.doLog('Executing success method');
|
|
||||||
success_fnc(data);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
beforeSend : function(request) {
|
beforeSend : function(request) {
|
||||||
request.setRequestHeader(api.auth_header, api.token);
|
request.setRequestHeader(api.auth_header, api.token);
|
||||||
@ -39,12 +40,13 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Public attributes
|
// Public attributes
|
||||||
api.debug = false;
|
api.debug = true;
|
||||||
}(window.api = window.api || {}, jQuery));
|
}(window.api = window.api || {}, jQuery));
|
||||||
|
|
||||||
|
|
||||||
// Cache related
|
// Cache related
|
||||||
function Cache(cacheName) {
|
function Cache(cacheName) {
|
||||||
|
"use strict";
|
||||||
api.cacheTable = api.cacheTable || {};
|
api.cacheTable = api.cacheTable || {};
|
||||||
|
|
||||||
api.cacheTable[cacheName] = api.cacheTable[cacheName] || {};
|
api.cacheTable[cacheName] = api.cacheTable[cacheName] || {};
|
||||||
@ -55,6 +57,7 @@ function Cache(cacheName) {
|
|||||||
|
|
||||||
Cache.prototype = {
|
Cache.prototype = {
|
||||||
get: function(key, not_found_fnc){
|
get: function(key, not_found_fnc){
|
||||||
|
"use strict";
|
||||||
not_found_fnc = not_found_fnc || function() { return undefined; };
|
not_found_fnc = not_found_fnc || function() { return undefined; };
|
||||||
|
|
||||||
if( this.cache[key] === undefined ) {
|
if( this.cache[key] === undefined ) {
|
||||||
@ -64,7 +67,8 @@ Cache.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
put: function(key, value) {
|
put: function(key, value) {
|
||||||
this.cache[key] = value;
|
"use strict";
|
||||||
|
this.cache[key] = value;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -74,6 +78,7 @@ Cache.prototype = {
|
|||||||
// code :-)
|
// code :-)
|
||||||
|
|
||||||
function BasicModelRest(path, options) {
|
function BasicModelRest(path, options) {
|
||||||
|
"use strict";
|
||||||
options = options || {};
|
options = options || {};
|
||||||
path = path || '';
|
path = path || '';
|
||||||
// Requests paths
|
// Requests paths
|
||||||
@ -85,34 +90,70 @@ function BasicModelRest(path, options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BasicModelRest.prototype = {
|
BasicModelRest.prototype = {
|
||||||
|
// options:
|
||||||
|
// cacheKey: '.' --> do not cache
|
||||||
|
// undefined -- > use path as key
|
||||||
|
// success: success fnc to execute in case of success
|
||||||
|
_requestPath: function(path, options) {
|
||||||
|
"use strict";
|
||||||
|
options = options || {};
|
||||||
|
var success_fnc = options.success || function(){api.doLog('success not provided for '+path);};
|
||||||
|
var cacheKey = options.cacheKey || path;
|
||||||
|
|
||||||
|
if( path == '.' ) {
|
||||||
|
success_fnc({});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cacheKey != '.' && this.cache.get(cacheKey)) {
|
||||||
|
success_fnc(this.cache.get(cacheKey));
|
||||||
|
} else {
|
||||||
|
var $this = this;
|
||||||
|
api.getJson(path, {
|
||||||
|
success: function(data) {
|
||||||
|
if( cacheKey != '.' ) {
|
||||||
|
$this.cache.put(cacheKey, data);
|
||||||
|
}
|
||||||
|
success_fnc(data);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
get : function(options) {
|
get : function(options) {
|
||||||
|
"use strict";
|
||||||
options = options || {};
|
options = options || {};
|
||||||
|
|
||||||
var path = this.getPath;
|
var path = this.getPath;
|
||||||
if (options.id !== undefined)
|
if (options.id !== undefined)
|
||||||
path += '/' + options.id;
|
path += '/' + options.id;
|
||||||
api.getJson(path, options.success);
|
return this._requestPath(path, {
|
||||||
|
cacheKey: '.', // Right now, do not cache this
|
||||||
|
success: options.success,
|
||||||
|
|
||||||
|
});
|
||||||
},
|
},
|
||||||
types : function(success_fnc) {
|
types : function(options) {
|
||||||
// Cache types locally, will not change unless new broker version
|
"use strict";
|
||||||
sucess_fnc = success_fnc || function(data){};
|
options = options || {};
|
||||||
if( this.typesPath == '.' ) {
|
return this._requestPath(this.typesPath, {
|
||||||
success_fnc({});
|
cacheKey: 'type',
|
||||||
return;
|
success: options.success,
|
||||||
}
|
});
|
||||||
if (this.cache.get('types')) {
|
|
||||||
success_fnc(this.cache.get('types'));
|
|
||||||
} else {
|
|
||||||
var $this = this;
|
|
||||||
var path = this.typesPath;
|
|
||||||
api.getJson(path, function(data) {
|
|
||||||
$this.cache.put('types', data);
|
|
||||||
success_fnc(data);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
gui: function(typeName, options) {
|
||||||
tableInfo : function(success_fnc) {
|
"use strict";
|
||||||
|
options = options || {};
|
||||||
|
var path = [this.typesPath, typeName, 'gui'].join('/');
|
||||||
|
return this._requestPath(path, {
|
||||||
|
cacheKey: typeName + '-gui',
|
||||||
|
success: options.success,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
tableInfo : function(options) {
|
||||||
|
"use strict";
|
||||||
|
options = options || {};
|
||||||
|
var success_fnc = options.success || function(){api.doLog('success not provided for tableInfo');};
|
||||||
|
|
||||||
var path = this.tableInfoPath;
|
var path = this.tableInfoPath;
|
||||||
// Cache types locally, will not change unless new broker version
|
// Cache types locally, will not change unless new broker version
|
||||||
if( this.cache.get(path) ) {
|
if( this.cache.get(path) ) {
|
||||||
@ -123,14 +164,17 @@ BasicModelRest.prototype = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var $this = this;
|
var $this = this;
|
||||||
api.getJson(path, function(data) {
|
api.getJson(path, {
|
||||||
$this.cache.put(path, data);
|
success: function(data) {
|
||||||
success_fnc(data);
|
$this.cache.put(path, data);
|
||||||
|
success_fnc(data);
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
detail: function(id, child) {
|
detail: function(id, child) {
|
||||||
|
"use strict";
|
||||||
return new DetailModelRestApi(this, id, child);
|
return new DetailModelRestApi(this, id, child);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,6 +182,7 @@ BasicModelRest.prototype = {
|
|||||||
|
|
||||||
// For REST of type /auth/[id]/users, /services/[id]/users, ...
|
// For REST of type /auth/[id]/users, /services/[id]/users, ...
|
||||||
function DetailModelRestApi(parentApi, parentId, model) {
|
function DetailModelRestApi(parentApi, parentId, model) {
|
||||||
|
"use strict";
|
||||||
this.base = new BasicModelRest(undefined, {
|
this.base = new BasicModelRest(undefined, {
|
||||||
getPath: [parentApi.path, parentId, model].join('/'),
|
getPath: [parentApi.path, parentId, model].join('/'),
|
||||||
typesPath: '.', // We do not has this on details
|
typesPath: '.', // We do not has this on details
|
||||||
@ -148,13 +193,16 @@ function DetailModelRestApi(parentApi, parentId, model) {
|
|||||||
DetailModelRestApi.prototype = {
|
DetailModelRestApi.prototype = {
|
||||||
// Generates a basic model with fixed methods for "detail" models
|
// Generates a basic model with fixed methods for "detail" models
|
||||||
get: function(options) {
|
get: function(options) {
|
||||||
|
"use strict";
|
||||||
return this.base.get(options);
|
return this.base.get(options);
|
||||||
},
|
},
|
||||||
types: function(success_fnc) {
|
types: function(options) {
|
||||||
return this.base.types(success_fnc);
|
"use strict";
|
||||||
|
return this.base.types(options);
|
||||||
},
|
},
|
||||||
tableInfo: function(success_fnc) {
|
tableInfo: function(options) {
|
||||||
return this.base.tableInfo(success_fnc);
|
"use strict";
|
||||||
|
return this.base.tableInfo(options);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
(function(api, $, undefined) {
|
|
||||||
|
|
||||||
api.cache = function(cacheName) {
|
|
||||||
return new Cache(cacheName);
|
|
||||||
};
|
|
||||||
|
|
||||||
}(window.api = window.api || {}, jQuery));
|
|
||||||
|
|
||||||
function Cache(cacheName) {
|
|
||||||
api.cacheTable = api.cacheTable || {};
|
|
||||||
|
|
||||||
api.cacheTable[cacheName] = api.cacheTable[cacheName] || {};
|
|
||||||
|
|
||||||
this.name = cacheName;
|
|
||||||
this.cache = api.cacheTable[cacheName];
|
|
||||||
}
|
|
||||||
|
|
||||||
Cache.prototype = {
|
|
||||||
get: function(key, not_found_fnc){
|
|
||||||
not_found_fnc = not_found_fnc || function() { return undefined; };
|
|
||||||
|
|
||||||
if( this.cache[key] === undefined ) {
|
|
||||||
this.cache[key] = not_found_fnc();
|
|
||||||
}
|
|
||||||
return this.cache[key];
|
|
||||||
},
|
|
||||||
|
|
||||||
put: function(key, value) {
|
|
||||||
this.cache[key] = value;
|
|
||||||
},
|
|
||||||
};
|
|
@ -136,24 +136,26 @@ GuiElement.prototype = {
|
|||||||
"use strict";
|
"use strict";
|
||||||
gui.doLog('Initializing ' + this.name);
|
gui.doLog('Initializing ' + this.name);
|
||||||
var $this = this;
|
var $this = this;
|
||||||
this.rest.types(function(data) {
|
this.rest.types({
|
||||||
var styles = '';
|
success: function(data) {
|
||||||
$.each(data, function(index, value) {
|
var styles = '';
|
||||||
var className = $this.name + '-' + value.type;
|
$.each(data, function(index, value) {
|
||||||
$this.types[value.type] = {
|
var className = $this.name + '-' + value.type;
|
||||||
css : className,
|
$this.types[value.type] = {
|
||||||
name : value.name || '',
|
css : className,
|
||||||
description : value.description || ''
|
name : value.name || '',
|
||||||
};
|
description : value.description || ''
|
||||||
gui.doLog('Creating style for ' + className);
|
};
|
||||||
var style = '.' + className + ' { display:inline-block; background: url(data:image/png;base64,' +
|
gui.doLog('Creating style for ' + className);
|
||||||
value.icon + '); ' + 'width: 16px; height: 16px; vertical-align: middle; } ';
|
var style = '.' + className + ' { display:inline-block; background: url(data:image/png;base64,' +
|
||||||
styles += style;
|
value.icon + '); ' + 'width: 16px; height: 16px; vertical-align: middle; } ';
|
||||||
});
|
styles += style;
|
||||||
if (styles !== '') {
|
});
|
||||||
styles = '<style media="screen">' + styles + '</style>';
|
if (styles !== '') {
|
||||||
$(styles).appendTo('head');
|
styles = '<style media="screen">' + styles + '</style>';
|
||||||
}
|
$(styles).appendTo('head');
|
||||||
|
}
|
||||||
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
table : function(options) {
|
table : function(options) {
|
||||||
@ -211,287 +213,267 @@ GuiElement.prototype = {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
this.rest.tableInfo(function(data) {
|
this.rest.tableInfo({
|
||||||
var title = data.title;
|
success: function(data) {
|
||||||
var columns = [];
|
var title = data.title;
|
||||||
$.each(data.fields, function(index, value) {
|
var columns = [];
|
||||||
for ( var v in value) {
|
$.each(data.fields, function(index, value) {
|
||||||
var options = value[v];
|
for ( var v in value) {
|
||||||
var column = {
|
var options = value[v];
|
||||||
mData : v,
|
var column = {
|
||||||
};
|
mData : v,
|
||||||
column.sTitle = options.title;
|
};
|
||||||
column.mRender = renderEmptyCell;
|
column.sTitle = options.title;
|
||||||
if (options.type !== undefined) {
|
column.mRender = renderEmptyCell;
|
||||||
switch(options.type) {
|
if (options.type !== undefined) {
|
||||||
case 'date':
|
switch(options.type) {
|
||||||
column.sType = 'date';
|
case 'date':
|
||||||
column.mRender = renderDate(djangoFormat(get_format('SHORT_DATE_FORMAT')));
|
column.sType = 'date';
|
||||||
break;
|
column.mRender = renderDate(djangoFormat(get_format('SHORT_DATE_FORMAT')));
|
||||||
case 'datetime':
|
break;
|
||||||
column.sType = 'date';
|
case 'datetime':
|
||||||
column.mRender = renderDate(djangoFormat(get_format('SHORT_DATETIME_FORMAT')));
|
column.sType = 'date';
|
||||||
break;
|
column.mRender = renderDate(djangoFormat(get_format('SHORT_DATETIME_FORMAT')));
|
||||||
case 'time':
|
break;
|
||||||
column.mRender = renderDate(djangoFormat(get_format('TIME_FORMAT')));
|
case 'time':
|
||||||
break;
|
column.mRender = renderDate(djangoFormat(get_format('TIME_FORMAT')));
|
||||||
case 'iconType':
|
break;
|
||||||
//columnt.sType = 'html'; // html is default, so this is not needed
|
case 'iconType':
|
||||||
column.mRender = renderTypeIcon;
|
//columnt.sType = 'html'; // html is default, so this is not needed
|
||||||
break;
|
column.mRender = renderTypeIcon;
|
||||||
case 'icon':
|
break;
|
||||||
if( options.icon !== undefined ) {
|
case 'icon':
|
||||||
column.mRender = renderIcon(options.icon);
|
if( options.icon !== undefined ) {
|
||||||
}
|
column.mRender = renderIcon(options.icon);
|
||||||
break;
|
}
|
||||||
case 'dict':
|
break;
|
||||||
if( options.dict !== undefined ) {
|
case 'dict':
|
||||||
column.mRender = renderTextTransform(options.dict);
|
if( options.dict !== undefined ) {
|
||||||
}
|
column.mRender = renderTextTransform(options.dict);
|
||||||
break;
|
}
|
||||||
default:
|
break;
|
||||||
column.sType = options.type;
|
default:
|
||||||
|
column.sType = options.type;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (options.width)
|
||||||
|
column.sWidth = options.width;
|
||||||
|
if (options.visible !== undefined)
|
||||||
|
column.bVisible = options.visible;
|
||||||
|
if (options.sortable !== undefined)
|
||||||
|
column.bSortable = options.sortable;
|
||||||
|
if (options.searchable !== undefined)
|
||||||
|
column.bSearchable = options.searchable;
|
||||||
|
columns.push(column);
|
||||||
}
|
}
|
||||||
if (options.width)
|
});
|
||||||
column.sWidth = options.width;
|
// Generate styles for responsibe table, just the name of fields
|
||||||
if (options.visible !== undefined)
|
var respStyles = [];
|
||||||
column.bVisible = options.visible;
|
var counter = 0;
|
||||||
if (options.sortable !== undefined)
|
$.each(columns, function(col, value) {
|
||||||
column.bSortable = options.sortable;
|
if( value.bVisible === false )
|
||||||
if (options.searchable !== undefined)
|
return;
|
||||||
column.bSearchable = options.searchable;
|
counter += 1;
|
||||||
columns.push(column);
|
respStyles.push('#' + tableId + ' td:nth-of-type(' + counter + '):before { content: "' +
|
||||||
}
|
(value.sTitle || '') + '";}\n');
|
||||||
});
|
respStyles.push('#' + tableId + ' td:nth-of-type(' + counter + '):empty { background-color: red ;}\n');
|
||||||
// Generate styles for responsibe table, just the name of fields
|
});
|
||||||
var respStyles = [];
|
// If styles already exists, remove them before adding new ones
|
||||||
var counter = 0;
|
$('style-' + tableId).remove();
|
||||||
$.each(columns, function(col, value) {
|
$('<style id="style-' + tableId + '" media="screen">@media (max-width: 979px) { ' + respStyles.join('') + '};</style>').appendTo('head');
|
||||||
if( value.bVisible === false )
|
|
||||||
return;
|
$this.rest.get({
|
||||||
counter += 1;
|
success : function(data) {
|
||||||
respStyles.push('#' + tableId + ' td:nth-of-type(' + counter + '):before { content: "' +
|
var table = gui.table(title, tableId);
|
||||||
(value.sTitle || '') + '";}\n');
|
if (options.container === undefined) {
|
||||||
respStyles.push('#' + tableId + ' td:nth-of-type(' + counter + '):empty { background-color: red ;}\n');
|
gui.appendToWorkspace('<div class="row"><div class="col-lg-12">' + table + '</div></div>');
|
||||||
});
|
} else {
|
||||||
// If styles already exists, remove them before adding new ones
|
$('#' + options.container).empty();
|
||||||
$('style-' + tableId).remove();
|
$('#' + options.container).append(table);
|
||||||
$('<style id="style-' + tableId + '" media="screen">@media (max-width: 979px) { ' + respStyles.join('') + '};</style>').appendTo('head');
|
}
|
||||||
|
|
||||||
$this.rest.get({
|
var btns = [];
|
||||||
success : function(data) {
|
|
||||||
var table = gui.table(title, tableId);
|
if (options.buttons) {
|
||||||
if (options.container === undefined) {
|
|
||||||
gui.appendToWorkspace('<div class="row"><div class="col-lg-12">' + table + '</div></div>');
|
// methods for buttons click
|
||||||
} else {
|
var editFnc = function() {
|
||||||
$('#' + options.container).empty();
|
gui.doLog('Edit');
|
||||||
$('#' + options.container).append(table);
|
gui.doLog(this);
|
||||||
}
|
};
|
||||||
|
var deleteFnc = function() {
|
||||||
var btns = [];
|
gui.doLog('Delete');
|
||||||
|
gui.doLog(this);
|
||||||
if (options.buttons) {
|
};
|
||||||
|
|
||||||
// methods for buttons click
|
|
||||||
var editFnc = function() {
|
|
||||||
gui.doLog('Edit');
|
|
||||||
gui.doLog(this);
|
|
||||||
};
|
|
||||||
var deleteFnc = function() {
|
|
||||||
gui.doLog('Delete');
|
|
||||||
gui.doLog(this);
|
|
||||||
};
|
|
||||||
|
|
||||||
// What execute on refresh button push
|
|
||||||
var onRefresh = options.onRefresh || function(){};
|
|
||||||
|
|
||||||
var refreshFnc = function(btn) {
|
|
||||||
// Refreshes table content
|
|
||||||
var tbl = $('#' + tableId).dataTable();
|
|
||||||
/*var width = $(btn).width();
|
|
||||||
var saved = $(btn).html();
|
|
||||||
$(btn).addClass('disabled').html('<span class="fa fa-spinner fa-spin"></span>')
|
|
||||||
.width(width);*/
|
|
||||||
if( data.length > 1000 )
|
|
||||||
api.tools.blockUI();
|
|
||||||
|
|
||||||
onRefresh($this);
|
// What execute on refresh button push
|
||||||
|
var onRefresh = options.onRefresh || function(){};
|
||||||
$this.rest.get({
|
|
||||||
success : function(data) {
|
var refreshFnc = function(btn) {
|
||||||
/*$(btn).removeClass('disabled').width('').html(saved);*/
|
// Refreshes table content
|
||||||
setTimeout( function() {
|
var tbl = $('#' + tableId).dataTable();
|
||||||
tbl.fnClearTable();
|
/*var width = $(btn).width();
|
||||||
tbl.fnAddData(data);
|
var saved = $(btn).html();
|
||||||
api.tools.unblockUI();
|
$(btn).addClass('disabled').html('<span class="fa fa-spinner fa-spin"></span>')
|
||||||
}, 0);
|
.width(width);*/
|
||||||
|
if( data.length > 1000 )
|
||||||
|
api.tools.blockUI();
|
||||||
|
|
||||||
|
onRefresh($this);
|
||||||
|
|
||||||
|
$this.rest.get({
|
||||||
|
success : function(data) {
|
||||||
|
/*$(btn).removeClass('disabled').width('').html(saved);*/
|
||||||
|
setTimeout( function() {
|
||||||
|
tbl.fnClearTable();
|
||||||
|
tbl.fnAddData(data);
|
||||||
|
api.tools.unblockUI();
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// methods for buttons on row select
|
||||||
|
var editSelected = function(btn, obj, node) {
|
||||||
|
var sel = this.fnGetSelectedData();
|
||||||
|
if (sel.length == 1) {
|
||||||
|
$(btn).removeClass('disabled').addClass('btn3d-success');
|
||||||
|
} else {
|
||||||
|
$(btn).removeClass('btn3d-success').addClass('disabled');
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
};
|
var deleteSelected = function(btn, obj, node) {
|
||||||
|
var sel = this.fnGetSelectedData();
|
||||||
// methods for buttons on row select
|
if (sel.length > 0) {
|
||||||
var editSelected = function(btn, obj, node) {
|
$(btn).removeClass('disabled').addClass('btn3d-warning');
|
||||||
var sel = this.fnGetSelectedData();
|
} else {
|
||||||
if (sel.length == 1) {
|
$(btn).removeClass('btn3d-warning').addClass('disabled');
|
||||||
$(btn).removeClass('disabled').addClass('btn3d-success');
|
}
|
||||||
} else {
|
};
|
||||||
$(btn).removeClass('btn3d-success').addClass('disabled');
|
|
||||||
}
|
$.each(options.buttons, function(index, value) {
|
||||||
};
|
var btn;
|
||||||
var deleteSelected = function(btn, obj, node) {
|
switch (value) {
|
||||||
var sel = this.fnGetSelectedData();
|
case 'edit':
|
||||||
if (sel.length > 0) {
|
btn = {
|
||||||
$(btn).removeClass('disabled').addClass('btn3d-warning');
|
"sExtends" : "text",
|
||||||
} else {
|
"sButtonText" : gettext('Edit'),
|
||||||
$(btn).removeClass('btn3d-warning').addClass('disabled');
|
"fnSelect" : editSelected,
|
||||||
}
|
"fnClick" : editFnc,
|
||||||
};
|
"sButtonClass" : "disabled btn3d btn3d-tables"
|
||||||
|
};
|
||||||
$.each(options.buttons, function(index, value) {
|
break;
|
||||||
var btn;
|
case 'delete':
|
||||||
switch (value) {
|
btn = {
|
||||||
case 'edit':
|
"sExtends" : "text",
|
||||||
btn = {
|
"sButtonText" : gettext('Delete'),
|
||||||
"sExtends" : "text",
|
"fnSelect" : deleteSelected,
|
||||||
"sButtonText" : gettext('Edit'),
|
"fnClick" : deleteFnc,
|
||||||
"fnSelect" : editSelected,
|
"sButtonClass" : "disabled btn3d btn3d-tables"
|
||||||
"fnClick" : editFnc,
|
};
|
||||||
"sButtonClass" : "disabled btn3d btn3d-tables"
|
break;
|
||||||
};
|
case 'refresh':
|
||||||
break;
|
btn = {
|
||||||
case 'delete':
|
"sExtends" : "text",
|
||||||
btn = {
|
"sButtonText" : gettext('Refresh'),
|
||||||
"sExtends" : "text",
|
"fnClick" : refreshFnc,
|
||||||
"sButtonText" : gettext('Delete'),
|
"sButtonClass" : "btn3d-primary btn3d btn3d-tables"
|
||||||
"fnSelect" : deleteSelected,
|
};
|
||||||
"fnClick" : deleteFnc,
|
break;
|
||||||
"sButtonClass" : "disabled btn3d btn3d-tables"
|
case 'xls':
|
||||||
};
|
btn = {
|
||||||
break;
|
"sExtends" : "text",
|
||||||
case 'refresh':
|
"sButtonText" : 'xls',
|
||||||
btn = {
|
"fnClick" : function(){
|
||||||
"sExtends" : "text",
|
api.templates.get('spreadsheet', function(tmpl) {
|
||||||
"sButtonText" : gettext('Refresh'),
|
var styles = { 'bold': 's21', };
|
||||||
"fnClick" : refreshFnc,
|
var uri = 'data:application/vnd.ms-excel;base64,',
|
||||||
"sButtonClass" : "btn3d-primary btn3d btn3d-tables"
|
base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))); };
|
||||||
};
|
|
||||||
break;
|
var headings = [], rows = [];
|
||||||
case 'xls':
|
$.each(columns, function(index, heading){
|
||||||
btn = {
|
if( heading.bVisible === false ) {
|
||||||
"sExtends" : "text",
|
|
||||||
"sButtonText" : 'xls',
|
|
||||||
"fnClick" : function(){
|
|
||||||
api.templates.get('spreadsheet', function(tmpl) {
|
|
||||||
var styles = { 'bold': 's21', };
|
|
||||||
var uri = 'data:application/vnd.ms-excel;base64,',
|
|
||||||
base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))); };
|
|
||||||
|
|
||||||
var headings = [], rows = [];
|
|
||||||
$.each(columns, function(index, heading){
|
|
||||||
if( heading.bVisible === false ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
headings.push(api.spreadsheet.cell(heading.sTitle, 'String', styles.bold));
|
|
||||||
});
|
|
||||||
rows.push(api.spreadsheet.row(headings));
|
|
||||||
$.each(data, function(index, row) {
|
|
||||||
var cells = [];
|
|
||||||
$.each(columns, function(index, col){
|
|
||||||
if( col.bVisible === false ) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var type = col.sType == 'numeric' ? 'Number':'String';
|
headings.push(api.spreadsheet.cell(heading.sTitle, 'String', styles.bold));
|
||||||
cells.push(api.spreadsheet.cell(row[col.mData], type));
|
|
||||||
});
|
});
|
||||||
rows.push(api.spreadsheet.row(cells));
|
rows.push(api.spreadsheet.row(headings));
|
||||||
|
$.each(data, function(index, row) {
|
||||||
|
var cells = [];
|
||||||
|
$.each(columns, function(index, col){
|
||||||
|
if( col.bVisible === false ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var type = col.sType == 'numeric' ? 'Number':'String';
|
||||||
|
cells.push(api.spreadsheet.cell(row[col.mData], type));
|
||||||
|
});
|
||||||
|
rows.push(api.spreadsheet.row(cells));
|
||||||
|
});
|
||||||
|
|
||||||
|
var ctx = {
|
||||||
|
creation_date: (new Date()).toISOString(),
|
||||||
|
worksheet: title,
|
||||||
|
columns_count: headings.length,
|
||||||
|
rows_count: rows.length,
|
||||||
|
rows: rows.join('\n')
|
||||||
|
};
|
||||||
|
// window.location.href = uri + base64(api.templates.evaluate(tmpl, ctx));
|
||||||
|
setTimeout( function() {
|
||||||
|
saveAs(new Blob([api.templates.evaluate(tmpl, ctx)],
|
||||||
|
{type: 'application/vnd.ms-excel'} ), title + '.xls');
|
||||||
|
}, 20);
|
||||||
});
|
});
|
||||||
|
},
|
||||||
var ctx = {
|
"sButtonClass" : "btn3d-info btn3d btn3d-tables"
|
||||||
creation_date: (new Date()).toISOString(),
|
};
|
||||||
worksheet: title,
|
}
|
||||||
columns_count: headings.length,
|
|
||||||
rows_count: rows.length,
|
if (btn !== undefined)
|
||||||
rows: rows.join('\n')
|
btns.push(btn);
|
||||||
};
|
});
|
||||||
// window.location.href = uri + base64(api.templates.evaluate(tmpl, ctx));
|
}
|
||||||
setTimeout( function() {
|
|
||||||
saveAs(new Blob([api.templates.evaluate(tmpl, ctx)],
|
// Initializes oTableTools
|
||||||
{type: 'application/vnd.ms-excel'} ), title + '.xls')
|
var oTableTools = {
|
||||||
}, 20);
|
"aButtons" : btns
|
||||||
});
|
};
|
||||||
},
|
if (options.rowSelect) {
|
||||||
"sButtonClass" : "btn3d-info btn3d btn3d-tables"
|
oTableTools.sRowSelect = options.rowSelect;
|
||||||
};
|
}
|
||||||
/*case 'csv':
|
if (options.onRowSelect) {
|
||||||
btn = {
|
oTableTools.fnRowSelected = options.onRowSelect;
|
||||||
"sExtends" : "csv",
|
}
|
||||||
"sTitle" : title,
|
if (options.onRowDeselect) {
|
||||||
"sFileName" : title + '.csv',
|
oTableTools.fnRowDeselected = options.onRowDeselect;
|
||||||
};
|
}
|
||||||
break;*/
|
|
||||||
/*case 'pdf':
|
$('#' + tableId).dataTable({
|
||||||
btn = {
|
"aaData" : data,
|
||||||
"sExtends" : "pdf",
|
"aoColumns" : columns,
|
||||||
"sTitle" : title,
|
"oLanguage" : gui.dataTablesLanguage,
|
||||||
"sPdfMessage" : "Summary Info",
|
"oTableTools" : oTableTools,
|
||||||
"fnCellRender": function(value, col, node, dattaIndex) {
|
// First is upper row,
|
||||||
// All tables handled by this needs an "id" on col 0
|
// second row is lower
|
||||||
// So, we return empty values for col 0
|
// (pagination) row
|
||||||
if(col === 0)
|
"sDom" : "<'row'<'col-xs-8'T><'col-xs-4'f>r>t<'row'<'col-xs-5'i><'col-xs-7'p>>",
|
||||||
return '';
|
|
||||||
return value.toString().replace(/(<([^>]+)>)/ig, '');
|
|
||||||
},
|
|
||||||
"sFileName" : title + '.pdf',
|
|
||||||
"sPdfOrientation" : "portrait"
|
|
||||||
};
|
|
||||||
break;*/
|
|
||||||
}
|
|
||||||
|
|
||||||
if (btn !== undefined)
|
|
||||||
btns.push(btn);
|
|
||||||
});
|
});
|
||||||
|
// Fix 3dbuttons
|
||||||
|
api.tools.fix3dButtons('#' + tableId + '_wrapper .btn-group-3d');
|
||||||
|
// Fix form
|
||||||
|
//$('#' + tableId + '_filter input').addClass('form-control');
|
||||||
|
if (options.scroll !== undefined ) {
|
||||||
|
var tableTop = $('#' + tableId).offset().top;
|
||||||
|
$('html, body').scrollTop(tableTop);
|
||||||
|
}
|
||||||
|
// if table rendered event
|
||||||
|
if( options.onLoad ) {
|
||||||
|
options.onLoad($this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
// Initializes oTableTools
|
},
|
||||||
var oTableTools = {
|
|
||||||
"aButtons" : btns
|
|
||||||
};
|
|
||||||
if (options.rowSelect) {
|
|
||||||
oTableTools.sRowSelect = options.rowSelect;
|
|
||||||
}
|
|
||||||
if (options.onRowSelect) {
|
|
||||||
oTableTools.fnRowSelected = options.onRowSelect;
|
|
||||||
}
|
|
||||||
if (options.onRowDeselect) {
|
|
||||||
oTableTools.fnRowDeselected = options.onRowDeselect;
|
|
||||||
}
|
|
||||||
|
|
||||||
$('#' + tableId).dataTable({
|
|
||||||
"aaData" : data,
|
|
||||||
"aoColumns" : columns,
|
|
||||||
"oLanguage" : gui.dataTablesLanguage,
|
|
||||||
"oTableTools" : oTableTools,
|
|
||||||
// First is upper row,
|
|
||||||
// second row is lower
|
|
||||||
// (pagination) row
|
|
||||||
"sDom" : "<'row'<'col-xs-8'T><'col-xs-4'f>r>t<'row'<'col-xs-5'i><'col-xs-7'p>>",
|
|
||||||
|
|
||||||
});
|
|
||||||
// Fix 3dbuttons
|
|
||||||
api.tools.fix3dButtons('#' + tableId + '_wrapper .btn-group-3d');
|
|
||||||
// Fix form
|
|
||||||
//$('#' + tableId + '_filter input').addClass('form-control');
|
|
||||||
if (options.scroll !== undefined ) {
|
|
||||||
var tableTop = $('#' + tableId).offset().top;
|
|
||||||
$('html, body').scrollTop(tableTop);
|
|
||||||
}
|
|
||||||
// if table rendered event
|
|
||||||
if( options.onLoad ) {
|
|
||||||
options.onLoad($this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
return '#' + tableId;
|
return '#' + tableId;
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
tools.blockUI = function(message) {
|
tools.blockUI = function(message) {
|
||||||
message = message || '<h1><span class="fa fa-spinner fa-spin"></span> ' + gettext('Just a moment...') + '</h1>'
|
message = message || '<h1><span class="fa fa-spinner fa-spin"></span> ' + gettext('Just a moment...') + '</h1>';
|
||||||
$.blockUI({ message: message });
|
$.blockUI({ message: message });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user