* Restored "missing" services that where in maintenance mode. Now they

got displayed but with some transparency & can't be clicked
* Added "slightly" blue color & tooptip to indicate that a service is
currently with an opened session
This commit is contained in:
Adolfo Gómez García 2015-01-28 08:16:48 +01:00
parent 215c8f8f3e
commit d5034c9971
5 changed files with 93 additions and 24 deletions

View File

@ -343,8 +343,7 @@ class UserServiceManager(object):
with transaction.atomic():
dsp.cachedDeployedService.filter(state__in=State.INFO_STATES).delete()
def getAssignationForUser(self, ds, user):
# First, we try to locate an already assigned service
def getExistingAssignationForUser(self, ds, user):
existing = ds.assignedUserServices().filter(user=user, state__in=State.VALID_STATES)
lenExisting = existing.count()
if lenExisting > 0: # Already has 1 assigned
@ -355,6 +354,13 @@ class UserServiceManager(object):
# return existing[1]
# else:
# return existing[0]
return None
def getAssignationForUser(self, ds, user):
assignedUserService = self.getExistingAssignationForUser(ds, user)
# If has an assigend user service, returns this without any more work
if assignedUserService is not None:
return assignedUserService
# Now try to locate 1 from cache already "ready" (must be usable and at level 1)
with transaction.atomic():

View File

@ -35,7 +35,7 @@
from __future__ import unicode_literals
__updated__ = '2015-01-26'
__updated__ = '2015-01-28'
from django.db import models
from django.db.models import signals

View File

@ -9,7 +9,12 @@
{% if ser.transports %}
<div class="service-container">
{% with trans=ser.transports|first numTransports=ser.transports|length %}
<div class="service"{% if not java and trans.needsJava %} class="nojava"{% endif %}
<div class="service{% if not java and trans.needsJava %} nojava{% endif %}{% if ser.maintenance %} maintenance{% endif %}{% if ser.in_use %} inuse{% endif %}"
{% if ser.maintenance %}
data-content="{% trans "Under maintenance" %}"
{% elif ser.in_use %}
data-content="{%trans "Currently in use" %}"
{% endif %}
data-url="{% url "uds.web.views.service" idService=ser.id idTransport=trans.id %}">
<div class="service-image">
<img src="{% url "uds.web.views.serviceImage" idImage=ser.imageId %}" />
@ -31,7 +36,7 @@
<div class="modal-body">
<ul>
{% for trans in ser.transports %}
<p><a {% if not java and trans.needsJava %} class="nojava"{% endif %} href="{% url "uds.web.views.service" idService=ser.id idTransport=trans.id %}"><img src="{% url "uds.web.views.transportIcon" idTrans=trans.id %}" alt="{{ trans.name }}" />{{ trans.name }}</a></p>
<p><a href="{% url "uds.web.views.service" idService=ser.id idTransport=trans.id %}"><img src="{% url "uds.web.views.transportIcon" idTrans=trans.id %}" alt="{{ trans.name }}" />{{ trans.name }}</a></p>
{% endfor %}
</ul>
@ -49,6 +54,24 @@
{% endif %}
{% endfor %}
<div class="modal fade" id="maintenance-dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">{% trans "Service under maintenance" %}</h4>
</div>
<div class="modal-body text-center">
<p>{% trans "This service is in maintenance mode." %}</p>
<p>{% trans "Please, retry access in a while." %}</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
{% if not java %}
<div class="modal fade" id="no-java-dialog">
@ -58,7 +81,7 @@
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">{% trans "Java not found" %}</h4>
</div>
<div class="modal-body">
<div class="modal-body text-center">
<p>{% trans "Java is not available on your browser, and the selected transport needs it." %}</p>
<p>{% trans "Please, install latest version from" %} <a href="http://www.java.com" target="_blank">{% trans "Java website" %}</a> {% trans "and restart browser" %}</p>
</div>
@ -70,6 +93,8 @@
</div><!-- /.modal -->
{% endif %}
{% if user.isStaff %}
<div class="panel panel-warning">
<div class="panel-heading">
@ -119,13 +144,23 @@
filter: alpha(opacity=40);
}
div.service.maintenance {
opacity: 0.6;
filter: alpha(opacity=60);
}
div.service.inuse {
background-color: #DCDCFF;
}
div.service-image {
width: 128px;
height: 128px;
}
div.service.over:not(.disabled) {
background-color: #FFFFFF;
background-color: #F0F0F0;
animation: pulse 0.5s infinite alternate;
-webkit-animation-name: pulse;
-webkit-animation-duration: 0.8s;
@ -172,18 +207,12 @@
{% block js %}
<script>
$(function() {
{% if not java %}
$(".nojava").click( function() {
$('#no-java-dialog').modal({
keyboard: false
})
return false;
});
{% endif %}
$('.with-tooltip').popover({container: 'body', trigger: 'hover', delay: { show: 500, hide: 100 }, placement: 'auto bottom'});
$('div.service').on("click", function (event){
$('.inuse').popover({container: 'body', trigger: 'hover', delay: { show: 500, hide: 100 }, placement: 'auto top'});
$('div.service:not(.maintenance):not(.nojava)').on("click", function (event){
if($(this).hasClass('disabled'))
return;
$('div.service').addClass('disabled');
@ -193,11 +222,28 @@
$(this).toggleClass('over');
});
$('span.gear > span.fa').on("click", function (event) {
$('div.service:not(.maintenance):not(.nojava) > span.gear > span.fa').on("click", function (event) {
event.stopPropagation();
$(this).parent().parent().next().modal();
return false;
});
$(".maintenance").click( function(event) {
$('#maintenance-dialog').modal({
keyboard: false
})
return false;
});
{% if not java %}
$(".nojava").click( function(event) {
$('#no-java-dialog').modal({
keyboard: false
})
return false;
});
{% endif %}
});
</script>
{% endblock %}

View File

@ -40,6 +40,7 @@ from uds.core.auths.auth import webLoginRequired
from uds.models import DeployedService, Transport, UserService, Network
from uds.core.util.Config import GlobalConfig
from uds.core.ui import theme
from uds.core.managers.UserServiceManager import UserServiceManager
import logging
@ -89,8 +90,6 @@ def index(request):
# Select assigned user services
for svr in availUserServices:
# Skip maintenance services...
if svr.deployed_service.service.provider.maintenance_mode is True:
continue
trans = []
for t in svr.transports.all().order_by('priority'):
typeTrans = t.getType()
@ -100,12 +99,18 @@ def index(request):
imageId = svr.deployed_service.image.uuid
else:
imageId = 'x' # Invalid
services.append({'id': 'A' + svr.uuid, 'name': svr['name'], 'transports': trans, 'imageId': imageId, 'show_transports': svr.deployed_service.show_transports})
services.append({'id': 'A' + svr.uuid,
'name': svr['name'],
'transports': trans,
'imageId': imageId,
'show_transports': svr.deployed_service.show_transports,
'maintenance': svr.deployed_service.service.provider.maintenance_mode,
'in_use': svr.in_use})
logger.debug(services)
# Now generic user service
for svr in availServices:
if svr.service.provider.maintenance_mode is True:
continue
trans = []
for t in svr.transports.all().order_by('priority'):
if t.validForIp(request.ip):
@ -116,7 +121,16 @@ def index(request):
imageId = svr.image.uuid
else:
imageId = 'x'
services.append({'id': 'F' + svr.uuid, 'name': svr.name, 'transports': trans, 'imageId': imageId, 'show_transports': svr.show_transports})
ads = UserServiceManager.manager().getExistingAssignationForUser(svr, request.user)
services.append({'id': 'F' + svr.uuid,
'name': svr.name,
'transports': trans,
'imageId': imageId,
'show_transports': svr.show_transports,
'maintenance': svr.service.provider.maintenance_mode,
'in_use': ads.in_use})
logger.debug('Services: {0}'.format(services))

View File

@ -33,6 +33,7 @@ from __future__ import unicode_literals
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.views.decorators.cache import cache_page
from uds.core.auths.auth import webLoginRequired, webPassword
from uds.models import DeployedService, Transport, UserService, Image
@ -44,11 +45,12 @@ from uds.core.ui import theme
import uds.web.errors as errors
import logging
logger = logging.getLogger(__name__)
__updated__ = '2015-01-28'
@webLoginRequired
def service(request, idService, idTransport):
@ -141,6 +143,7 @@ def transportIcon(request, idTrans):
return HttpResponseRedirect('/static/img/unknown.png')
@cache_page(86400, key_prefix='img')
def serviceImage(request, idImage):
try:
icon = Image.objects.get(uuid=idImage)