diff --git a/appsettings/migrations/0004_auto_20200716_0637.py b/appsettings/migrations/0004_auto_20200716_0637.py new file mode 100644 index 0000000..5feffa3 --- /dev/null +++ b/appsettings/migrations/0004_auto_20200716_0637.py @@ -0,0 +1,35 @@ +# Generated by Django 2.2.13 on 2020-07-16 06:37 + +from django.db import migrations +from django.utils.translation import ugettext_lazy as _ + + +def add_default_settings(apps, schema_editor): + setting = apps.get_model("appsettings", "AppSettings") + db_alias = schema_editor.connection.alias + setting.objects.using(db_alias).bulk_create([ + setting(27, _("Console Scale"), "CONSOLE_SCALE", "False", "True,False", _("Allow console to scaling view")), + setting(28, _("Console View-Only"), "CONSOLE_VIEW_ONLY", "False", "True,False", _("Allow only view not modify")), + setting(29, _("Console Resize Session"), "CONSOLE_RESIZE_SESSION", "False", "True,False", _("Allow to resize session for console")), + setting(30, _("Console Clip Viewport"), "CONSOLE_CLIP_VIEWPORT", "False", "True,False", _("Clip console viewport")), + ]) + + +def del_default_settings(apps, schema_editor): + setting = apps.get_model("appsettings", "AppSettings") + db_alias = schema_editor.connection.alias + setting.objects.using(db_alias).filter(key="CONSOLE_SCALE").delete() + setting.objects.using(db_alias).filter(key="CONSOLE_VIEW_ONLY").delete() + setting.objects.using(db_alias).filter(key="CONSOLE_RESIZE_SESSION").delete() + setting.objects.using(db_alias).filter(key="CONSOLE_CLIP_VIEWPORT").delete() + + +class Migration(migrations.Migration): + + dependencies = [ + ('appsettings', '0003_auto_20200615_0637'), + ] + + operations = [ + migrations.RunPython(add_default_settings, del_default_settings), + ] diff --git a/computes/templates/computes/instances.html b/computes/templates/computes/instances.html index d72ecbd..342d53d 100644 --- a/computes/templates/computes/instances.html +++ b/computes/templates/computes/instances.html @@ -112,10 +112,5 @@ {% endblock %} {% block script %} - {% endblock %} \ No newline at end of file diff --git a/console/templates/console-vnc-lite.html b/console/templates/console-vnc-lite.html index e3cad63..a76744e 100755 --- a/console/templates/console-vnc-lite.html +++ b/console/templates/console-vnc-lite.html @@ -202,10 +202,10 @@ rfb.addEventListener("capabilities", function () { updatePowerButtons(); }); // Set parameters that can be changed on an active connection - rfb.viewOnly = readQueryVariable('view_only', {{ view_only }}); - rfb.scaleViewport = readQueryVariable('scale', {{ scale }}); - rfb.resizeSession = readQueryVariable('resize', {{ resize_session }}); - rfb.clipViewport = readQueryVariable('clip_viewport', {{ clip_viewport }}); + rfb.scaleViewport = {{ scale }}; + rfb.viewOnly = {{ view_only }}; + rfb.resizeSession = {{ resize_session }}; + rfb.clipViewport = {{ clip_viewport }}; {% endblock %} diff --git a/console/views.py b/console/views.py index e1df4f2..8251526 100644 --- a/console/views.py +++ b/console/views.py @@ -1,9 +1,13 @@ import re + from django.shortcuts import render from libvirt import libvirtError + +from appsettings.settings import app_settings from instances.models import Instance from vrtManager.instance import wvmInstance -from webvirtcloud.settings import WS_PUBLIC_PATH, WS_PUBLIC_PORT, WS_PUBLIC_HOST +from webvirtcloud.settings import (WS_PUBLIC_HOST, WS_PUBLIC_PATH, + WS_PUBLIC_PORT) def console(request): @@ -16,10 +20,10 @@ def console(request): if request.method == 'GET': token = request.GET.get('token', '') view_type = request.GET.get('view', 'lite') - view_only = request.GET.get('view_only', 0) - scale = request.GET.get('scale', 0) - resize_session = request.GET.get('resize_session', 0) - clip_viewport = request.GET.get('clip_viewport', 0) + view_only = request.GET.get('view_only', app_settings.CONSOLE_VIEW_ONLY.lower()) + scale = request.GET.get('scale', app_settings.CONSOLE_SCALE.lower()) + resize_session = request.GET.get('resize_session', app_settings.CONSOLE_RESIZE_SESSION.lower()) + clip_viewport = request.GET.get('clip_viewport', app_settings.CONSOLE_CLIP_VIEWPORT.lower()) try: temptoken = token.split('-', 1) diff --git a/instances/templates/allinstances.html b/instances/templates/allinstances.html index d8c5a14..caaa932 100644 --- a/instances/templates/allinstances.html +++ b/instances/templates/allinstances.html @@ -38,11 +38,6 @@ {% endblock content %} {% block script %} - {% if request.user.is_superuser %} - +{% endblock script %} \ No newline at end of file diff --git a/instances/templates/instances/access_tab.html b/instances/templates/instances/access_tab.html index f5b4579..b32046e 100644 --- a/instances/templates/instances/access_tab.html +++ b/instances/templates/instances/access_tab.html @@ -4,13 +4,15 @@