mirror of
https://github.com/dkmstr/openuds.git
synced 2025-01-25 06:03:51 +03:00
* 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:
parent
215c8f8f3e
commit
d5034c9971
@ -343,8 +343,7 @@ class UserServiceManager(object):
|
|||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
dsp.cachedDeployedService.filter(state__in=State.INFO_STATES).delete()
|
dsp.cachedDeployedService.filter(state__in=State.INFO_STATES).delete()
|
||||||
|
|
||||||
def getAssignationForUser(self, ds, user):
|
def getExistingAssignationForUser(self, ds, user):
|
||||||
# First, we try to locate an already assigned service
|
|
||||||
existing = ds.assignedUserServices().filter(user=user, state__in=State.VALID_STATES)
|
existing = ds.assignedUserServices().filter(user=user, state__in=State.VALID_STATES)
|
||||||
lenExisting = existing.count()
|
lenExisting = existing.count()
|
||||||
if lenExisting > 0: # Already has 1 assigned
|
if lenExisting > 0: # Already has 1 assigned
|
||||||
@ -355,6 +354,13 @@ class UserServiceManager(object):
|
|||||||
# return existing[1]
|
# return existing[1]
|
||||||
# else:
|
# else:
|
||||||
# return existing[0]
|
# 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)
|
# Now try to locate 1 from cache already "ready" (must be usable and at level 1)
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
__updated__ = '2015-01-26'
|
__updated__ = '2015-01-28'
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.db.models import signals
|
from django.db.models import signals
|
||||||
|
@ -9,7 +9,12 @@
|
|||||||
{% if ser.transports %}
|
{% if ser.transports %}
|
||||||
<div class="service-container">
|
<div class="service-container">
|
||||||
{% with trans=ser.transports|first numTransports=ser.transports|length %}
|
{% 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 %}">
|
data-url="{% url "uds.web.views.service" idService=ser.id idTransport=trans.id %}">
|
||||||
<div class="service-image">
|
<div class="service-image">
|
||||||
<img src="{% url "uds.web.views.serviceImage" idImage=ser.imageId %}" />
|
<img src="{% url "uds.web.views.serviceImage" idImage=ser.imageId %}" />
|
||||||
@ -31,7 +36,7 @@
|
|||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<ul>
|
<ul>
|
||||||
{% for trans in ser.transports %}
|
{% 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 %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
@ -49,6 +54,24 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% 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">×</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 %}
|
{% if not java %}
|
||||||
<div class="modal fade" id="no-java-dialog">
|
<div class="modal fade" id="no-java-dialog">
|
||||||
@ -58,7 +81,7 @@
|
|||||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||||
<h4 class="modal-title">{% trans "Java not found" %}</h4>
|
<h4 class="modal-title">{% trans "Java not found" %}</h4>
|
||||||
</div>
|
</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 "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>
|
<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>
|
</div>
|
||||||
@ -70,6 +93,8 @@
|
|||||||
</div><!-- /.modal -->
|
</div><!-- /.modal -->
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{% if user.isStaff %}
|
{% if user.isStaff %}
|
||||||
<div class="panel panel-warning">
|
<div class="panel panel-warning">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
@ -119,13 +144,23 @@
|
|||||||
filter: alpha(opacity=40);
|
filter: alpha(opacity=40);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div.service.maintenance {
|
||||||
|
opacity: 0.6;
|
||||||
|
filter: alpha(opacity=60);
|
||||||
|
}
|
||||||
|
|
||||||
|
div.service.inuse {
|
||||||
|
background-color: #DCDCFF;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
div.service-image {
|
div.service-image {
|
||||||
width: 128px;
|
width: 128px;
|
||||||
height: 128px;
|
height: 128px;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.service.over:not(.disabled) {
|
div.service.over:not(.disabled) {
|
||||||
background-color: #FFFFFF;
|
background-color: #F0F0F0;
|
||||||
animation: pulse 0.5s infinite alternate;
|
animation: pulse 0.5s infinite alternate;
|
||||||
-webkit-animation-name: pulse;
|
-webkit-animation-name: pulse;
|
||||||
-webkit-animation-duration: 0.8s;
|
-webkit-animation-duration: 0.8s;
|
||||||
@ -172,18 +207,12 @@
|
|||||||
{% block js %}
|
{% block js %}
|
||||||
<script>
|
<script>
|
||||||
$(function() {
|
$(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'});
|
$('.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'))
|
if($(this).hasClass('disabled'))
|
||||||
return;
|
return;
|
||||||
$('div.service').addClass('disabled');
|
$('div.service').addClass('disabled');
|
||||||
@ -193,11 +222,28 @@
|
|||||||
$(this).toggleClass('over');
|
$(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();
|
event.stopPropagation();
|
||||||
$(this).parent().parent().next().modal();
|
$(this).parent().parent().next().modal();
|
||||||
return false;
|
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>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -40,6 +40,7 @@ from uds.core.auths.auth import webLoginRequired
|
|||||||
from uds.models import DeployedService, Transport, UserService, Network
|
from uds.models import DeployedService, Transport, UserService, Network
|
||||||
from uds.core.util.Config import GlobalConfig
|
from uds.core.util.Config import GlobalConfig
|
||||||
from uds.core.ui import theme
|
from uds.core.ui import theme
|
||||||
|
from uds.core.managers.UserServiceManager import UserServiceManager
|
||||||
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
@ -89,8 +90,6 @@ def index(request):
|
|||||||
# Select assigned user services
|
# Select assigned user services
|
||||||
for svr in availUserServices:
|
for svr in availUserServices:
|
||||||
# Skip maintenance services...
|
# Skip maintenance services...
|
||||||
if svr.deployed_service.service.provider.maintenance_mode is True:
|
|
||||||
continue
|
|
||||||
trans = []
|
trans = []
|
||||||
for t in svr.transports.all().order_by('priority'):
|
for t in svr.transports.all().order_by('priority'):
|
||||||
typeTrans = t.getType()
|
typeTrans = t.getType()
|
||||||
@ -100,12 +99,18 @@ def index(request):
|
|||||||
imageId = svr.deployed_service.image.uuid
|
imageId = svr.deployed_service.image.uuid
|
||||||
else:
|
else:
|
||||||
imageId = 'x' # Invalid
|
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
|
# Now generic user service
|
||||||
for svr in availServices:
|
for svr in availServices:
|
||||||
if svr.service.provider.maintenance_mode is True:
|
|
||||||
continue
|
|
||||||
trans = []
|
trans = []
|
||||||
for t in svr.transports.all().order_by('priority'):
|
for t in svr.transports.all().order_by('priority'):
|
||||||
if t.validForIp(request.ip):
|
if t.validForIp(request.ip):
|
||||||
@ -116,7 +121,16 @@ def index(request):
|
|||||||
imageId = svr.image.uuid
|
imageId = svr.image.uuid
|
||||||
else:
|
else:
|
||||||
imageId = 'x'
|
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))
|
logger.debug('Services: {0}'.format(services))
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ from __future__ import unicode_literals
|
|||||||
from django.http import HttpResponse, HttpResponseRedirect
|
from django.http import HttpResponse, HttpResponseRedirect
|
||||||
from django.shortcuts import render_to_response
|
from django.shortcuts import render_to_response
|
||||||
from django.template import RequestContext
|
from django.template import RequestContext
|
||||||
|
from django.views.decorators.cache import cache_page
|
||||||
|
|
||||||
from uds.core.auths.auth import webLoginRequired, webPassword
|
from uds.core.auths.auth import webLoginRequired, webPassword
|
||||||
from uds.models import DeployedService, Transport, UserService, Image
|
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 uds.web.errors as errors
|
||||||
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
__updated__ = '2015-01-28'
|
||||||
|
|
||||||
|
|
||||||
@webLoginRequired
|
@webLoginRequired
|
||||||
def service(request, idService, idTransport):
|
def service(request, idService, idTransport):
|
||||||
@ -141,6 +143,7 @@ def transportIcon(request, idTrans):
|
|||||||
return HttpResponseRedirect('/static/img/unknown.png')
|
return HttpResponseRedirect('/static/img/unknown.png')
|
||||||
|
|
||||||
|
|
||||||
|
@cache_page(86400, key_prefix='img')
|
||||||
def serviceImage(request, idImage):
|
def serviceImage(request, idImage):
|
||||||
try:
|
try:
|
||||||
icon = Image.objects.get(uuid=idImage)
|
icon = Image.objects.get(uuid=idImage)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user