forked from shaba/openuds
Started "definitive" reporting system for dashboard
This commit is contained in:
parent
f7fbc5a0c4
commit
40641659a5
102
server/src/uds/REST/methods/reports.py
Normal file
102
server/src/uds/REST/methods/reports.py
Normal file
@ -0,0 +1,102 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#
|
||||
# Copyright (c) 2014 Virtual Cable S.L.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
# * Neither the name of Virtual Cable S.L. nor the names of its contributors
|
||||
# may be used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
'''
|
||||
@author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
'''
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.utils.translation import ugettext, ugettext_lazy as _
|
||||
|
||||
from uds.REST import model
|
||||
from uds.REST import RequestError, ResponseError
|
||||
from uds import reports
|
||||
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
VALID_PARAMS = ('authId', 'authSmallName', 'auth', 'username', 'realname', 'password', 'groups', 'servicePool', 'transport')
|
||||
|
||||
|
||||
# Enclosed methods under /actor path
|
||||
class Reports(model.BaseModelHandler):
|
||||
'''
|
||||
Processes actor requests
|
||||
'''
|
||||
needs_admin = True # By default, staff is lower level needed
|
||||
|
||||
table_title = _('Available reports')
|
||||
table_fields = [
|
||||
{'group': {'title': _('Group')}},
|
||||
{'name': {'title': _('Name')}}, # Will process this field on client in fact, not sent by server
|
||||
{'description': {'title': _('Description')}}, # Will process this field on client in fact, not sent by server
|
||||
]
|
||||
# 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-'}
|
||||
|
||||
def get(self):
|
||||
logger.debug('method GET for {0}, {1}'.format(self.__class__.__name__, self._args))
|
||||
nArgs = len(self._args)
|
||||
|
||||
if nArgs == 0:
|
||||
return list(self.getItems())
|
||||
|
||||
if nArgs == 1:
|
||||
if self._args[0] == model.OVERVIEW:
|
||||
return list(self.getItems())
|
||||
elif self._args[0] == model.TABLEINFO:
|
||||
return self.processTableFields(self.table_title, self.table_fields, self.table_row_style)
|
||||
|
||||
if nArgs == 2:
|
||||
if self._args[0] == model.GUI:
|
||||
return self.getGui(self._args[1])
|
||||
|
||||
# Gui related
|
||||
def getGui(self, uuid):
|
||||
found = None
|
||||
for i in reports.availableReports:
|
||||
if i.getUuid() == uuid:
|
||||
found = i
|
||||
break
|
||||
|
||||
if found is None:
|
||||
return self.invalidRequestException('Invalid report!')
|
||||
|
||||
return []
|
||||
|
||||
def getItems(self):
|
||||
return [
|
||||
{
|
||||
'id': i.getUuid(),
|
||||
'group': i.translated_group(),
|
||||
'name': i.translated_name(),
|
||||
'description': i.translated_description()
|
||||
} for i in reports.availableReports
|
||||
]
|
@ -51,7 +51,7 @@ import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
__updated__ = '2015-03-05'
|
||||
__updated__ = '2015-04-28'
|
||||
|
||||
|
||||
# a few constants
|
||||
|
106
server/src/uds/core/reports/BaseReport.py
Normal file
106
server/src/uds/core/reports/BaseReport.py
Normal file
@ -0,0 +1,106 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#
|
||||
# Copyright (c) 2015 Virtual Cable S.L.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
# * Neither the name of Virtual Cable S.L. nor the names of its contributors
|
||||
# may be used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
'''
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
'''
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.utils.translation import ugettext, ugettext_noop as _
|
||||
|
||||
from uds.core.ui.UserInterface import UserInterface
|
||||
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
__updated__ = '2015-04-28'
|
||||
|
||||
|
||||
class Report(UserInterface):
|
||||
mime_type = 'application/pdf' # Report returns pdfs by default, but could be anything else
|
||||
name = _('Base Report') # Report name
|
||||
description = _('Base report') # Report description
|
||||
group = '' # So we can "group" reports by kind?
|
||||
uuid = None
|
||||
|
||||
@classmethod
|
||||
def translated_name(cls):
|
||||
'''
|
||||
Helper to return translated report name
|
||||
'''
|
||||
return ugettext(cls.name)
|
||||
|
||||
@classmethod
|
||||
def translated_description(cls):
|
||||
'''
|
||||
Helper to return translated report description
|
||||
'''
|
||||
return ugettext(cls.description)
|
||||
|
||||
@classmethod
|
||||
def translated_group(cls):
|
||||
'''
|
||||
Helper to return translated report description
|
||||
'''
|
||||
return ugettext(cls.group)
|
||||
|
||||
@classmethod
|
||||
def getUuid(cls):
|
||||
if cls.uuid is None:
|
||||
raise Exception('Class does not includes an uuid!!!: {}'.format(cls))
|
||||
return cls.uuid
|
||||
|
||||
def __init__(self, values=None):
|
||||
'''
|
||||
Do not forget to invoke this in your derived class using
|
||||
"super(self.__class__, self).__init__(values)".
|
||||
|
||||
The values parameter is passed directly to UserInterface base.
|
||||
|
||||
Values are passed to __initialize__ method. It this is not None,
|
||||
the values contains a dictionary of values received from administration gui,
|
||||
that contains the form data requested from user.
|
||||
|
||||
If you override marshal, unmarshal and inherited UserInterface method
|
||||
valuesDict, you must also take account of values (dict) provided at the
|
||||
__init__ method of your class.
|
||||
'''
|
||||
#
|
||||
UserInterface.__init__(self, values)
|
||||
self.initialize()
|
||||
|
||||
def initialize(self):
|
||||
pass
|
||||
|
||||
def genReport(self):
|
||||
return ''
|
||||
|
||||
def __str__(self):
|
||||
return "Base Report"
|
37
server/src/uds/core/reports/__init__.py
Normal file
37
server/src/uds/core/reports/__init__.py
Normal file
@ -0,0 +1,37 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#
|
||||
# Copyright (c) 2015 Virtual Cable S.L.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
# * Neither the name of Virtual Cable S.L. nor the names of its contributors
|
||||
# may be used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
'''
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
'''
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from .BaseReport import Report
|
||||
|
||||
__updated__ = '2015-04-28'
|
@ -34,19 +34,19 @@ UDS Service modules interfaces and classes.
|
||||
'''
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from uds.core.services.BaseServiceProvider import ServiceProvider
|
||||
from uds.core.services.BaseService import Service
|
||||
from uds.core.services.BasePublication import Publication
|
||||
from uds.core.services.BaseDeployed import UserDeployment
|
||||
from .BaseServiceProvider import ServiceProvider
|
||||
from .BaseService import Service
|
||||
from .BasePublication import Publication
|
||||
from .BaseDeployed import UserDeployment
|
||||
|
||||
from uds.core.services.ClusteredServiceProvider import ClusteredServiceProvider
|
||||
from uds.core.services.ClusteredService import ClusteredService
|
||||
from uds.core.services.ClusteredPublication import ClusteredPublication
|
||||
from uds.core.services.ClusteredUserDeployment import ClusteredUserDeployment
|
||||
from .ClusteredServiceProvider import ClusteredServiceProvider
|
||||
from .ClusteredService import ClusteredService
|
||||
from .ClusteredPublication import ClusteredPublication
|
||||
from .ClusteredUserDeployment import ClusteredUserDeployment
|
||||
|
||||
import uds.core.services.Exceptions
|
||||
|
||||
__updated__ = '2014-11-12'
|
||||
__updated__ = '2015-04-27'
|
||||
|
||||
|
||||
def factory():
|
||||
|
@ -33,6 +33,7 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.utils.translation import get_language, ugettext as _
|
||||
import datetime
|
||||
import six
|
||||
import pickle
|
||||
import logging
|
||||
@ -208,6 +209,7 @@ class gui(object):
|
||||
EDITABLE_LIST = 'editlist'
|
||||
CHECKBOX_TYPE = 'checkbox'
|
||||
IMAGE_TYPE = 'image'
|
||||
DATE_TYPE = 'date'
|
||||
|
||||
DEFAULT_LENTGH = 32 # : If length of some fields are not especified, this value is used as default
|
||||
|
||||
@ -371,6 +373,35 @@ class gui(object):
|
||||
v = 0
|
||||
return v
|
||||
|
||||
class DateField(InputField):
|
||||
'''
|
||||
This represents a date field.
|
||||
|
||||
The values of parameres are inherited from :py:class:`InputField`
|
||||
|
||||
Example usage:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
# Declares an text form field, with label "Password",
|
||||
# tooltip "Password of the user", that is required,
|
||||
# with max length of 32 chars and order = 2, and is
|
||||
# editable after creation.
|
||||
passw = gui.DateField(label = _('Starting date'),
|
||||
order = 4, tooltip = _('Ending date'),
|
||||
required = True)
|
||||
|
||||
'''
|
||||
def __init__(self, **options):
|
||||
super(self.__class__, self).__init__(**options)
|
||||
self._type(gui.InputField.DATE_TYPE)
|
||||
|
||||
def date(self):
|
||||
try:
|
||||
return datetime.datetime.strptime(self.value, '%Y/%m/%d')
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
class PasswordField(InputField):
|
||||
'''
|
||||
This represents a password field. It appears with "*" at input, so the contents is not displayed
|
||||
|
@ -33,8 +33,6 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
__updated__ = '2015-03-23'
|
||||
|
||||
from django.db import models
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
|
||||
@ -45,6 +43,8 @@ import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
__updated__ = '2015-04-28'
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class UUIDModel(models.Model):
|
||||
|
72
server/src/uds/reports/__init__.py
Normal file
72
server/src/uds/reports/__init__.py
Normal file
@ -0,0 +1,72 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#
|
||||
# Copyright (c) 2012 Virtual Cable S.L.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
# * Neither the name of Virtual Cable S.L. nor the names of its contributors
|
||||
# may be used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
'''
|
||||
Transport modules for UDS are contained inside this package.
|
||||
To create a new rwpoer module, you will need to follow this steps:
|
||||
1.- Create the report module inside one of the existing (or new one) packages
|
||||
2.- Import the class of your report module at __init__. For example::
|
||||
from Report import SimpleReport
|
||||
3.- Done. At Server restart, the module will be recognized, loaded and treated
|
||||
|
||||
The registration of modules is done locating subclases of :py:class:`uds.core.auths.Authentication`
|
||||
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
'''
|
||||
|
||||
availableReports = []
|
||||
|
||||
|
||||
def __init__():
|
||||
'''
|
||||
This imports all packages that are descendant of this package, and, after that,
|
||||
'''
|
||||
import os.path
|
||||
import pkgutil
|
||||
import sys
|
||||
from uds.core import reports
|
||||
|
||||
def addReportCls(cls):
|
||||
availableReports.append(cls)
|
||||
|
||||
# Dinamycally import children of this package. The __init__.py files must import classes
|
||||
pkgpath = os.path.dirname(sys.modules[__name__].__file__)
|
||||
for _, name, _ in pkgutil.iter_modules([pkgpath]):
|
||||
__import__(name, globals(), locals(), [])
|
||||
|
||||
p = reports.Report
|
||||
for cls in p.__subclasses__():
|
||||
clsSubCls = cls.__subclasses__()
|
||||
if len(clsSubCls) == 0:
|
||||
addReportCls(cls)
|
||||
else:
|
||||
for l2 in clsSubCls:
|
||||
addReportCls(l2)
|
||||
|
||||
__init__()
|
34
server/src/uds/reports/lists/__init__.py
Normal file
34
server/src/uds/reports/lists/__init__.py
Normal file
@ -0,0 +1,34 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#
|
||||
# Copyright (c) 2015 Virtual Cable S.L.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
# * Neither the name of Virtual Cable S.L. nor the names of its contributors
|
||||
# may be used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
'''
|
||||
@author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
'''
|
||||
|
||||
from .users import ListReportUsers
|
42
server/src/uds/reports/lists/base.py
Normal file
42
server/src/uds/reports/lists/base.py
Normal file
@ -0,0 +1,42 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#
|
||||
# Copyright (c) 2015 Virtual Cable S.L.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
# * Neither the name of Virtual Cable S.L. nor the names of its contributors
|
||||
# may be used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
'''
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
'''
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from uds.core import reports
|
||||
|
||||
|
||||
__updated__ = '2015-04-28'
|
||||
|
||||
|
||||
class ListReport(reports.Report):
|
||||
group = 'Lists' # So we can make submenus with reports
|
46
server/src/uds/reports/lists/users.py
Normal file
46
server/src/uds/reports/lists/users.py
Normal file
@ -0,0 +1,46 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#
|
||||
# Copyright (c) 2015 Virtual Cable S.L.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
# * Neither the name of Virtual Cable S.L. nor the names of its contributors
|
||||
# may be used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
'''
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
'''
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.utils.translation import ugettext, ugettext_noop as _
|
||||
|
||||
from .base import ListReport
|
||||
|
||||
|
||||
__updated__ = '2015-04-28'
|
||||
|
||||
|
||||
class ListReportUsers(ListReport):
|
||||
name = _('Users list') # Report name
|
||||
description = _('List users of platform') # Report description
|
||||
uuid = '8cd1cfa6-ed48-11e4-83e5-10feed05884b'
|
34
server/src/uds/reports/stats/__init__.py
Normal file
34
server/src/uds/reports/stats/__init__.py
Normal file
@ -0,0 +1,34 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#
|
||||
# Copyright (c) 2015 Virtual Cable S.L.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
# * Neither the name of Virtual Cable S.L. nor the names of its contributors
|
||||
# may be used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
'''
|
||||
@author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
'''
|
||||
|
||||
from .usage import StatsReportUsage
|
42
server/src/uds/reports/stats/base.py
Normal file
42
server/src/uds/reports/stats/base.py
Normal file
@ -0,0 +1,42 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#
|
||||
# Copyright (c) 2015 Virtual Cable S.L.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
# * Neither the name of Virtual Cable S.L. nor the names of its contributors
|
||||
# may be used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
'''
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
'''
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from uds.core import reports
|
||||
|
||||
|
||||
__updated__ = '2015-04-28'
|
||||
|
||||
|
||||
class StatsReport(reports.Report):
|
||||
group = 'Statistics' # So we can make submenus with reports
|
46
server/src/uds/reports/stats/usage.py
Normal file
46
server/src/uds/reports/stats/usage.py
Normal file
@ -0,0 +1,46 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#
|
||||
# Copyright (c) 2015 Virtual Cable S.L.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
# * Neither the name of Virtual Cable S.L. nor the names of its contributors
|
||||
# may be used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
'''
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
'''
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.utils.translation import ugettext, ugettext_noop as _
|
||||
|
||||
from .base import StatsReport
|
||||
|
||||
|
||||
__updated__ = '2015-04-28'
|
||||
|
||||
|
||||
class StatsReportUsage(StatsReport):
|
||||
name = _('Usage stats') # Report name
|
||||
description = _('Statistics of platform use') # Report description
|
||||
uuid = '9ae54172-ed48-11e4-b8e1-10feed05884b'
|
@ -419,6 +419,7 @@ api.servicesPools = new BasicModelRest("servicespools")
|
||||
api.configuration = new BasicModelRest("config")
|
||||
api.gallery = new BasicModelRest("gallery/images")
|
||||
api.system = new BasicModelRest("system")
|
||||
api.reports = new BasicModelRest("reports") # Not fully used, but basic usage is common
|
||||
api.system.stats = (type, success_fnc, fail_fnc) ->
|
||||
@get
|
||||
id: "stats/" + type
|
||||
|
49
server/src/uds/static/adm/js/gui-d-reports.coffee
Normal file
49
server/src/uds/static/adm/js/gui-d-reports.coffee
Normal file
@ -0,0 +1,49 @@
|
||||
# jshint strict: true
|
||||
gui.reports = new GuiElement(api.reports, "reports")
|
||||
gui.reports.link = (event) ->
|
||||
"use strict"
|
||||
|
||||
api.templates.get "reports", (tmpl) ->
|
||||
gui.clearWorkspace()
|
||||
gui.appendToWorkspace api.templates.evaluate(tmpl,
|
||||
reports: "reports-placeholder"
|
||||
)
|
||||
gui.setLinksEvents()
|
||||
|
||||
tableId = gui.reports.table(
|
||||
container: "reports-placeholder"
|
||||
rowSelect: "single"
|
||||
buttons: [
|
||||
{
|
||||
permission: api.permissions.MANAGEMENT
|
||||
text: gettext("Generate report")
|
||||
css: "disabled"
|
||||
click: (val, value, btn, tbl, refreshFnc) ->
|
||||
gui.doLog val.id
|
||||
api.reports.gui val.id, ((guiDefinition) ->
|
||||
gui.doLog 'aqui'
|
||||
)
|
||||
return
|
||||
|
||||
return
|
||||
|
||||
select: (val, value, btn, tbl, refreshFnc) ->
|
||||
unless val
|
||||
$(btn).removeClass("btn3d-primary").addClass "disabled"
|
||||
return
|
||||
$(btn).removeClass("disabled").addClass "btn3d-primary"
|
||||
return
|
||||
}
|
||||
]
|
||||
onRowDeselect: ->
|
||||
return
|
||||
|
||||
onRowSelect: (selected) ->
|
||||
return
|
||||
|
||||
onRefresh: ->
|
||||
return
|
||||
)
|
||||
return
|
||||
|
||||
false
|
@ -225,7 +225,12 @@
|
||||
id: "lnk-gallery"
|
||||
exec: gui.gallery.link
|
||||
cleanup: false
|
||||
}
|
||||
}
|
||||
{
|
||||
id: "lnk-reports"
|
||||
exec: gui.reports.link
|
||||
cleanup: false
|
||||
}
|
||||
]
|
||||
$.each sidebarLinks, (index, value) ->
|
||||
gui.doLog "Adding " + value.id
|
||||
|
@ -128,6 +128,7 @@
|
||||
<script type="text/coffeescript" charset="utf-8" src="{% get_static_prefix %}adm/js/gui-d-servicespools.coffee"></script>
|
||||
<script type="text/coffeescript" charset="utf-8" src="{% get_static_prefix %}adm/js/gui-d-config.coffee"></script>
|
||||
<script type="text/coffeescript" charset="utf-8" src="{% get_static_prefix %}adm/js/gui-d-gallery.coffee"></script>
|
||||
<script type="text/coffeescript" charset="utf-8" src="{% get_static_prefix %}adm/js/gui-d-reports.coffee"></script>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
@ -155,6 +156,7 @@
|
||||
{% js_template 'gallery' %}
|
||||
{% js_template 'permissions' %}
|
||||
{% js_template 'permissions_add' %}
|
||||
{% js_template 'reports' %}
|
||||
|
||||
<!-- utility pages -->
|
||||
{% js_template 'request_failed' %}
|
||||
|
@ -21,12 +21,14 @@
|
||||
<li><a class="lnk-connectivity" href="#"><i class="fa fa-sitemap"></i> {% trans 'Connectivity' %}</a></li>
|
||||
<li><a class="lnk-deployed_services" href=""><i class="fa fa-puzzle-piece"></i> {% trans 'Service Pools' %}</a></li>
|
||||
{% if admin %}
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-caret-square-o-down"></i> Tools <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="lnk-configuration" href="#">{% trans 'Configuration' %}</a></li>
|
||||
<li><a class="lnk-gallery" href="#">{% trans 'Gallery' %}</a></li>
|
||||
<li><a class="lnk-clear_cache" href="#">{% trans 'Flush cache' %}</a></li>
|
||||
<li><a class="lnk-gallery" href="#"><i class="fa fa-file-image-o"></i> {% trans 'Gallery' %}</a></li>
|
||||
<li><a class="lnk-reports" href=""><i class="fa fa-list-alt"></i> {% trans 'Reports' %}</a></li>
|
||||
<li><a class="lnk-configuration" href="#"><i class="fa fa-database"></i> {% trans 'Configuration' %}</a></li>
|
||||
<li><a class="lnk-clear_cache" href="#"><i class="fa fa-exclamation-triangle"></i> {% trans 'Flush cache' %}</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
27
server/src/uds/templates/uds/admin/tmpl/reports.html
Normal file
27
server/src/uds/templates/uds/admin/tmpl/reports.html
Normal file
@ -0,0 +1,27 @@
|
||||
{% load i18n html5 %}
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<h1>{% trans 'Reports' %}</h1>
|
||||
<ol class="breadcrumb">
|
||||
<li><a class="lnk-dashboard" href="#"><i class="fa fa-dashboard"></i> Dashboard</a></li>
|
||||
<li>{% trans 'Reports' %}</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div><!-- /.row -->
|
||||
{% if messages %}
|
||||
<div class="row">
|
||||
<div class="col-md-offset-2 col-md-8">
|
||||
{% for message in messages %}
|
||||
<div class="alert alert-danger alert-dismissable">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||||
{{ message }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% verbatim %}
|
||||
<div class="row">
|
||||
<div id="{{ reports }}" class="col-xs-12"></div>
|
||||
</div>
|
||||
{% endverbatim %}
|
Loading…
Reference in New Issue
Block a user