From e23f22d92d1a84786c1f66b8ac66dc666fe71139 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20G=C3=B3mez=20Garc=C3=ADa?= Date: Thu, 29 Oct 2015 06:57:02 +0100 Subject: [PATCH] Several fixes for dashboard && new command to clean up cache --- .../src/uds/core/util/UniqueGIDGenerator.py | 4 +- .../src/uds/management/commands/cleanUDS.py | 60 +++++++++++++++++++ .../uds/static/adm/js/gui-d-services.coffee | 5 +- .../static/adm/js/gui-d-servicespools.coffee | 10 ++-- .../src/uds/static/adm/js/gui-element.coffee | 2 +- 5 files changed, 72 insertions(+), 9 deletions(-) create mode 100644 server/src/uds/management/commands/cleanUDS.py diff --git a/server/src/uds/core/util/UniqueGIDGenerator.py b/server/src/uds/core/util/UniqueGIDGenerator.py index d2baadc8..36599150 100644 --- a/server/src/uds/core/util/UniqueGIDGenerator.py +++ b/server/src/uds/core/util/UniqueGIDGenerator.py @@ -32,7 +32,7 @@ ''' from __future__ import unicode_literals -from .UniqueIDGenerator import UniqueIDGenerator +from .UniqueIDGenerator import UniqueIDGenerator, MAX_SEQ import logging logger = logging.getLogger(__name__) @@ -48,5 +48,5 @@ class UniqueGIDGenerator(UniqueIDGenerator): raise KeyError('No more GIDS available.') return "%s%0*d" % (self._baseName, 8, seq) - def get(self): + def get(self, rangeStart=0, rangeEnd=MAX_SEQ): return self.__toName(super(UniqueGIDGenerator, self).get()) diff --git a/server/src/uds/management/commands/cleanUDS.py b/server/src/uds/management/commands/cleanUDS.py new file mode 100644 index 00000000..caecb2a3 --- /dev/null +++ b/server/src/uds/management/commands/cleanUDS.py @@ -0,0 +1,60 @@ +# -*- 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. + +''' +@author: Adolfo Gómez, dkmaster at dkmon dot com +''' +from __future__ import unicode_literals + +from django.core.management.base import BaseCommand +from django.core.cache import cache + +from uds.core.util.Config import GlobalConfig +from uds.core.util.Cache import Cache + +import logging +import sys + +logger = logging.getLogger(__name__) + + +class Command(BaseCommand): + args = "None" + help = "Clean up all uneeded data from UDS (cache, ...). This is mainly used for versions installations, so he have clean data" + + def handle(self, *args, **options): + sys.stdout.write("Cleaning up UDS\n") + GlobalConfig.initialize() + + # UDSs cache + Cache.cleanUp() + # Django caches + cache.clear() + + sys.stdout.write("UDS Cleaned UP\n") \ No newline at end of file diff --git a/server/src/uds/static/adm/js/gui-d-services.coffee b/server/src/uds/static/adm/js/gui-d-services.coffee index 0f4d2f49..e237546b 100644 --- a/server/src/uds/static/adm/js/gui-d-services.coffee +++ b/server/src/uds/static/adm/js/gui-d-services.coffee @@ -63,6 +63,7 @@ gui.providers.link = (event) -> true onRefresh: (tbl) -> + gui.doLog 'Invoked onRefresh for a provider' clearDetails() return @@ -178,7 +179,7 @@ gui.providers.link = (event) -> select: (vals, value, btn, tbl, refreshFnc) -> unless vals.length == 1 - $(btn).removeClass("btn-warning").removeClass("btn-info").addClass "disabled" + $(btn).removeClass("btn-warning").removeClass("btn-info").addClass("disabled").prop('disabled', true) $(btn).empty().append(maintenanceText('fa-ambulance', gettext("Maintenance"))) return val = vals[0] @@ -189,7 +190,7 @@ gui.providers.link = (event) -> content = maintenanceText('fa-truck',gettext('Exit Maintenance Mode')) cls = 'btn-info' - $(btn).removeClass("disabled").addClass(cls) + $(btn).removeClass("disabled").addClass(cls).prop('disabled', false) $(btn).empty().append(content) return } diff --git a/server/src/uds/static/adm/js/gui-d-servicespools.coffee b/server/src/uds/static/adm/js/gui-d-servicespools.coffee index 82c64f50..1eab5e83 100644 --- a/server/src/uds/static/adm/js/gui-d-servicespools.coffee +++ b/server/src/uds/static/adm/js/gui-d-servicespools.coffee @@ -153,6 +153,10 @@ gui.servicesPools.link = (event) -> "xls" "permissions" ] + onRefresh: () -> + clearDetails() + return + onRowDeselect: (deselected, dtable) -> gui.doLog "Selecteds: ", dtable.rows({selected: true}).length if dtable.rows({selected: true}).count() == 0 @@ -470,11 +474,9 @@ gui.servicesPools.link = (event) -> # Waiting for publication, Preparing or running gui.doLog "State: ", val.state if ["P", "W", "L", "K"].indexOf(val.state) != -1 - $(btn).removeClass("disabled") - $(btn).prop('disabled', false) + $(btn).removeClass("disabled").prop('disabled', false) else - $(btn).addClass("disabled") - $(btn).prop('disabled', true) + $(btn).addClass("disabled").prop('disabled', true) return } diff --git a/server/src/uds/static/adm/js/gui-element.coffee b/server/src/uds/static/adm/js/gui-element.coffee index 7d4b2ab6..ea4cdfeb 100644 --- a/server/src/uds/static/adm/js/gui-element.coffee +++ b/server/src/uds/static/adm/js/gui-element.coffee @@ -215,7 +215,7 @@ tblParams.onRefresh = (tbl) -> return - self.refresh = refreshFnc = () -> + self.refresh = refreshFnc = () -> # Refreshes table content tbl = $("#" + tableId).DataTable()