From 2b7ad74f2ffcb6a211eabc5e8377728db2847cf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20G=C3=B3mez?= <dkmaster@dkmon.com> Date: Fri, 13 Dec 2013 01:15:25 +0000 Subject: [PATCH] Started deployed services part --- .../org.eclipse.core.resources.prefs | 1 + server/src/tools/minify.js | 1 + .../src/uds/REST/methods/deployedservices.py | 73 +++++++++++++++++++ server/src/uds/REST/methods/services.py | 5 +- .../uds/static/adm/css/jquery.dataTables.css | 14 +++- server/src/uds/static/adm/css/uds-admin.css | 7 -- server/src/uds/static/adm/js/api.js | 5 +- .../uds/static/adm/js/gui-d-connectivity.js | 4 - .../static/adm/js/gui-d-deployedservices.js | 17 +++++ .../src/uds/static/adm/js/gui-definition.js | 2 +- server/src/uds/static/adm/js/gui.js | 8 +- server/src/uds/templates/uds/admin/index.html | 5 ++ .../uds/admin/tmpl/deployedservices.html | 38 ++++++++++ 13 files changed, 151 insertions(+), 29 deletions(-) create mode 100644 server/src/uds/REST/methods/deployedservices.py create mode 100644 server/src/uds/static/adm/js/gui-d-deployedservices.js create mode 100644 server/src/uds/templates/uds/admin/tmpl/deployedservices.html diff --git a/server/.settings/org.eclipse.core.resources.prefs b/server/.settings/org.eclipse.core.resources.prefs index 4bcdc6ce..7475d619 100644 --- a/server/.settings/org.eclipse.core.resources.prefs +++ b/server/.settings/org.eclipse.core.resources.prefs @@ -12,6 +12,7 @@ encoding//src/uds/REST/__init__.py=utf-8 encoding//src/uds/REST/handlers.py=utf-8 encoding//src/uds/REST/methods/authenticators.py=utf-8 encoding//src/uds/REST/methods/cache.py=utf-8 +encoding//src/uds/REST/methods/deployedservices.py=utf-8 encoding//src/uds/REST/methods/gui_callback.py=utf-8 encoding//src/uds/REST/methods/login_logout.py=utf-8 encoding//src/uds/REST/methods/networks.py=utf-8 diff --git a/server/src/tools/minify.js b/server/src/tools/minify.js index 368ce4be..716f8265 100644 --- a/server/src/tools/minify.js +++ b/server/src/tools/minify.js @@ -45,6 +45,7 @@ function minify_admin() { 'gui-d-authenticators', 'gui-d-osmanagers', 'gui-d-connectivity', + 'gui-d-deployedservices', ]; var cssFiles = [ diff --git a/server/src/uds/REST/methods/deployedservices.py b/server/src/uds/REST/methods/deployedservices.py new file mode 100644 index 00000000..7966a80f --- /dev/null +++ b/server/src/uds/REST/methods/deployedservices.py @@ -0,0 +1,73 @@ +# -*- 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 as _ + + +from uds.models import DeployedService, Service + +from uds.core.util import log +from uds.core.Environment import Environment +from uds.REST.model import ModelHandler +from uds.REST import NotFound, ResponseError, RequestError +from django.db import IntegrityError + +import logging + +logger = logging.getLogger(__name__) + + +class DeployedServices(ModelHandler): + model = DeployedService + save_fields = ['name', 'comments', 'service', 'osmanager', 'initial_srvs', 'cache_l1_srvs', 'cache_l2_srvs', 'max_srvs'] + + table_title = _('Deployed services') + table_fields = [ + { 'name': {'title': _('Name'), 'visible': True, 'type': 'iconType' } }, + { 'comments': {'title': _('Comments')}}, + ] + + def item_as_dict(self, item): + type_ = item.getType() + return { 'id': item.id, + 'name': item.name, + 'comments': item.comments, + } + + # Gui related + def getGui(self, type_): + try: + return self.addDefaultFields(['name', 'comments']) + except: + raise NotFound('type not found') diff --git a/server/src/uds/REST/methods/services.py b/server/src/uds/REST/methods/services.py index f156063f..8ca9ac39 100644 --- a/server/src/uds/REST/methods/services.py +++ b/server/src/uds/REST/methods/services.py @@ -28,7 +28,7 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ''' -@provideror: Adolfo Gómez, dkmaster at dkmon dot com +@author: Adolfo Gómez, dkmaster at dkmon dot com ''' from __future__ import unicode_literals @@ -164,4 +164,5 @@ class Services(DetailHandler): logger.debug('Getting logs for {0}'.format(item)) return log.getLogs(item) except: - self.invalidItemException() \ No newline at end of file + self.invalidItemException() + \ No newline at end of file diff --git a/server/src/uds/static/adm/css/jquery.dataTables.css b/server/src/uds/static/adm/css/jquery.dataTables.css index 7760aa00..b183737a 100644 --- a/server/src/uds/static/adm/css/jquery.dataTables.css +++ b/server/src/uds/static/adm/css/jquery.dataTables.css @@ -31,15 +31,21 @@ table.dataTable td.dataTables_empty { text-align: center; } -table.dataTable tr.odd { background-color: #E2E4FF; } -table.dataTable tr.even { background-color: white; } +/*table.dataTable tr.odd { background-color: #F5F5F5; } +table.dataTable tr.even { background-color: white; }*/ -table.dataTable tr.odd td.sorting_1 { background-color: #D3D6FF; } +table.dataTable tr.odd td.sorting_1 { background-color: #E5E5E5; } +table.dataTable tr.even td.sorting_1 { background-color: #F5F5F5; } + +/* Overwrites all color selection on selected rows */ +.table tbody tr.active td { background-color: #0075B0 !important; } + +/*table.dataTable tr.odd td.sorting_1 { background-color: #D3D6FF; } table.dataTable tr.odd td.sorting_2 { background-color: #DADCFF; } table.dataTable tr.odd td.sorting_3 { background-color: #E0E2FF; } table.dataTable tr.even td.sorting_1 { background-color: #EAEBFF; } table.dataTable tr.even td.sorting_2 { background-color: #F2F3FF; } -table.dataTable tr.even td.sorting_3 { background-color: #F9F9FF; } +table.dataTable tr.even td.sorting_3 { background-color: #F9F9FF; } */ /* diff --git a/server/src/uds/static/adm/css/uds-admin.css b/server/src/uds/static/adm/css/uds-admin.css index 3fbaf3b3..78f81a46 100644 --- a/server/src/uds/static/adm/css/uds-admin.css +++ b/server/src/uds/static/adm/css/uds-admin.css @@ -35,13 +35,6 @@ body { display: none; } -/*table.dataTable tr.odd td.sorting_1 { background-color: red; } -table.dataTable tr.odd td.sorting_2 { background-color: red; } -table.dataTable tr.odd td.sorting_3 { background-color: red; } -table.dataTable tr.even td.sorting_1 { background-color: blue; } -table.dataTable tr.even td.sorting_2 { background-color: blue; } -table.dataTable tr.even td.sorting_3 { background-color: blue; }*/ - /* collapsable && closeable pannels */ .chevron:before { content: "\f139"; diff --git a/server/src/uds/static/adm/js/api.js b/server/src/uds/static/adm/js/api.js index a805ea1d..7bf84fa6 100644 --- a/server/src/uds/static/adm/js/api.js +++ b/server/src/uds/static/adm/js/api.js @@ -476,7 +476,4 @@ api.authenticators = new BasicModelRest('authenticators'); api.osmanagers = new BasicModelRest('osmanagers'); api.transports = new BasicModelRest('transports'); api.networks = new BasicModelRest('networks'); - -// Locale related -api.locale = new BasicModelRest('locale'); -api.locale.tableInfo = api.locale.types = undefined; \ No newline at end of file +api.deployedservices = new BasicModelRest('deployedservices'); diff --git a/server/src/uds/static/adm/js/gui-d-connectivity.js b/server/src/uds/static/adm/js/gui-d-connectivity.js index 3f7539d9..be418dfc 100644 --- a/server/src/uds/static/adm/js/gui-d-connectivity.js +++ b/server/src/uds/static/adm/js/gui-d-connectivity.js @@ -6,10 +6,6 @@ gui.connectivity = { gui.connectivity.link = function(event) { "use strict"; - // Cleans up memory used by other datatables - $.each($.fn.dataTable.fnTables(), function(undefined, tbl){ - $(tbl).dataTable().fnDestroy(); - }); api.templates.get('connectivity', function(tmpl) { gui.clearWorkspace(); gui.appendToWorkspace(api.templates.evaluate(tmpl, { diff --git a/server/src/uds/static/adm/js/gui-d-deployedservices.js b/server/src/uds/static/adm/js/gui-d-deployedservices.js new file mode 100644 index 00000000..acd68f2a --- /dev/null +++ b/server/src/uds/static/adm/js/gui-d-deployedservices.js @@ -0,0 +1,17 @@ +/* jshint strict: true */ +gui.deployedservices = new GuiElement(api.deployedservices, 'deployedservices'); + + +gui.deployedservices.link = function(event) { + "use strict"; + + api.templates.get('deployedservices', function(tmpl) { + gui.clearWorkspace(); + gui.appendToWorkspace(api.templates.evaluate(tmpl, { + deployed_services : 'deployed-services-placeholder', + })); + gui.setLinksEvents(); + }); + + +}; diff --git a/server/src/uds/static/adm/js/gui-definition.js b/server/src/uds/static/adm/js/gui-definition.js index 9d515a7b..19f3f753 100644 --- a/server/src/uds/static/adm/js/gui-definition.js +++ b/server/src/uds/static/adm/js/gui-definition.js @@ -1,6 +1,6 @@ /* jshint strict: true */ -// Compose gui elements +// Basic GUI components gui.dashboard = new BasicGuiElement('Dashboard'); gui.dashboard.link = function(event) { "use strict"; diff --git a/server/src/uds/static/adm/js/gui.js b/server/src/uds/static/adm/js/gui.js index 0300fae6..d83296ed 100644 --- a/server/src/uds/static/adm/js/gui.js +++ b/server/src/uds/static/adm/js/gui.js @@ -132,12 +132,6 @@ $(data).appendTo('#content'); }; - // Links methods - gui.deployed_services = function() { - gui.clearWorkspace(); - gui.appendToWorkspace(gui.breadcrumbs(gettext('Deployed services'))); - }; - // Clean up several "internal" data // I have discovered some "items" that are keep in memory, or that adds garbage to body (datatable && tabletools mainly) // Whenever we change "section", we clean up as much as we can, so we can keep things as clean as possible @@ -182,7 +176,7 @@ cleanup: true, }, { id : 'lnk-deployed_services', - exec : gui.deployed_services, + exec : gui.deployedservices.link, cleanup: true, }, { id : 'lnk-clear_cache', diff --git a/server/src/uds/templates/uds/admin/index.html b/server/src/uds/templates/uds/admin/index.html index 9e15160f..ba70d0c6 100644 --- a/server/src/uds/templates/uds/admin/index.html +++ b/server/src/uds/templates/uds/admin/index.html @@ -107,6 +107,8 @@ <script src="{% get_static_prefix %}adm/js/gui-d-authenticators.js"></script> <script src="{% get_static_prefix %}adm/js/gui-d-osmanagers.js"></script> <script src="{% get_static_prefix %}adm/js/gui-d-connectivity.js"></script> + <script src="{% get_static_prefix %}adm/js/gui-d-deployedservices.js"></script> + {% else %} <!-- minified js from: 'jquery.cookie', 'bootstrap.min', 'bootstrap-switch.min', 'bootstrap-select.min', 'jquery.validate.min', 'jquery.blockUI', 'jquery.dataTables.min', 'TableTools.min', 'Blob', 'FileSaver', 'ZeroClipboard', 'dataTables.bootstrap', 'handlebars-v1.1.2', UDS admin JS's --> @@ -126,7 +128,10 @@ <!-- preloading of templates --> <!-- page contents --> {% js_template 'dashboard' %} + {% js_template 'providers' %} {% js_template 'authenticators' %} + {% js_template 'connectivity' %} + {% js_template 'deployedservices' %} <!-- utility pages --> {% js_template 'request_failed' %} <!-- components --> diff --git a/server/src/uds/templates/uds/admin/tmpl/deployedservices.html b/server/src/uds/templates/uds/admin/tmpl/deployedservices.html new file mode 100644 index 00000000..7ea87204 --- /dev/null +++ b/server/src/uds/templates/uds/admin/tmpl/deployedservices.html @@ -0,0 +1,38 @@ +{% load i18n %} +<div class="row"> + <div class="col-xs-12"> + <h1>{% trans 'Deployed Services' %}</h1> + <ol class="breadcrumb"> + <li><a class="lnk-dashboard" href="#"><i class="fa fa-dashboard"></i> Dashboard</a></li> + <li>{% trans 'Deployed Services' %}</li> + </ol> + </div> +</div><!-- /.row --> +{% verbatim %} +<div class="row"> + <div id="{{ deployed_services }}" class="col-xs-12"></div> +</div> +<div id="detail-placeholder" class="row hidden"> + <div class="col-xs-12"> + <ul class="nav nav-tabs"> + <li class="active"><a href="#{{ users }}_tab" data-toggle="tab">{% endverbatim %}{% trans 'Users' %}{% verbatim %}</a></li> + <li><a href="#{{ groups }}" data-toggle="tab">{% endverbatim %}{% trans 'Groups' %}{% verbatim %}</a></li> + <li><a href="#{{ logs }}" data-toggle="tab">{% endverbatim %}{% trans 'Logs' %}{% verbatim %}</a></li> + </ul> + <div class="tab-content"> + <div class="tab-pane fade in active" id="{{ users }}_tab"> + <div class="row"> + <div class="col-xs-12" id="{{ users }}"> + </div> + </div> + <div class="row"> + <div class="col-xs-12" id="{{ users_log }}"> + </div> + </div> + </div> + <div class="tab-pane fade" id="{{ groups }}"></div> + <div class="tab-pane fade" id="{{ logs }}">...</div> + </div> + </div> +</div> +{% endverbatim %} \ No newline at end of file