Commit a8ddc224 authored by Kostas Papadimitriou's avatar Kostas Papadimitriou
Browse files

Several ui improvements

- optionable glance api usage, Refs #1748
- display additional glance image metadata, Refs #1748
- dynamic api endpoint urls, Refs #1658
parent f8a7ba2b
......@@ -6,6 +6,9 @@
from admins import *
from site import *
# API URL
COMPUTE_API_URL = '/api/v1.1'
# base url for ui static files
# if not set, defaults to MEDIA_URL + 'snf-<latest_ui_version>/'
UI_MEDIA_URL = MEDIA_URL + 'snf/'
......@@ -117,3 +120,11 @@ UI_OS_DEFAULT_USER_MAP = {
'ubuntu': 'root', 'kubuntu': 'root', 'centos': 'root',
'windows': 'Administrator'
}
###############
# UI EXTENSIONS
###############
UI_ENABLE_GLANCE = True
UI_GLANCE_API_URL = '/plankton'
......@@ -5420,6 +5420,10 @@ table.list-machines .wave {
font-size: 0.9em;
}
.create-vm .select-image.wide .images-info-cont .description p {
height: 50px;
}
.create-vm .select-image.wide .images-info-cont .description {
width: 100% !important;
float: none !important;
......@@ -5428,7 +5432,7 @@ table.list-machines .wave {
font-size: 1.1em;
}
.create-vm .select-image.wide .images-info-cont .extra-details {
height: 190px;
height: 160px;
overflow-y: scroll;
padding-right: 15px;
}
......
......@@ -22,8 +22,12 @@
},
get_readable_size: function() {
return this.get_size() > 0 ? util.readablizeBytes(this.get_size()) : "unknown";
return this.get('size') > 0 ? util.readablizeBytes(this.get('size')) : "unknown";
},
display_size: function() {
return this.get_readable_size();
}
})
models.GlanceImages = snf.models.Images.extend({
......@@ -33,7 +37,8 @@
'shared': 'Shared with me',
'public': 'Public'},
type_selections_order: ['system', 'personal', 'shared', 'public'],
display_metadata: ['created_at', 'updated_at'],
display_metadata: ['created_at', 'updated_at', 'filename', 'format',
'size', 'status'],
read_method: 'head',
// custom glance api parser
......@@ -95,13 +100,16 @@
}
})
// storage initialization
snf.storage.glance = {};
snf.storage.glance.images = new models.GlanceImages();
// use glance images
snf.storage.images = snf.storage.glance.images;
// replace images storage collection
snf.glance.register = function() {
// storage initialization
snf.storage.glance = {};
snf.storage.glance.images = new models.GlanceImages();
// use glance images
snf.storage.images = snf.storage.glance.images;
}
})(this);
......@@ -360,8 +360,11 @@
_.each(meta_keys, function(key) {
var value;
var method = 'get_' + key.toLowerCase();
var display_method = 'display_' + key.toLowerCase();
if (image[method]) {
if (image[display_method]) {
value = image[display_method]();
} else if (image[method]) {
value = image[method]();
} else {
value = image.get(key);
......
......@@ -634,12 +634,15 @@
},
load: function() {
if (synnefo.config.use_glance) {
synnefo.glance.register();
}
this.error_view = new views.ErrorView();
this.feedback_view = new views.FeedbackView();
this.invitations_view = new views.InvitationsView();
this.public_keys_view = new views.PublicKeysOverlay();
if (snf.glance) {
if (synnefo.config.use_glance) {
this.custom_images_view = new views.CustomImagesOverlay();
}
......
......@@ -565,8 +565,8 @@ We welcome any suggestions, questions and bug reports you may have.{% endblocktr
synnefo.config.flavors_disk_templates_info = {{ flavors_disk_templates_info|safe }};
// TODO: make it dynamic
synnefo.config.api_urls = {
'compute': '/api/v1.1',
'glance':'/plankton'
'compute': {{ compute_api_url|safe }},
'glance': {{ glance_api_url|safe }}
};
// TODO: configurable userdata urls in models.js
synnefo.config.userdata_url = '/ui/userdata';
......@@ -577,6 +577,7 @@ We welcome any suggestions, questions and bug reports you may have.{% endblocktr
synnefo.config.media_url = '{{ UI_MEDIA_URL }}';
synnefo.config.js_url = '{{ SYNNEFO_JS_URL }}';
synnefo.config.images_url = '{{ SYNNEFO_IMAGES_URL }}';
synnefo.config.use_glance = {{ use_glance }};
synnefo.config.indicators_icons_url = '{{ SYNNEFO_IMAGES_URL }}icons/indicators/';
synnefo.config.machines_icons_url = '{{ SYNNEFO_IMAGES_URL }}icons/machines/';
synnefo.config.support_ssh_os_list = {{ support_ssh_os_list|safe }};
......@@ -589,7 +590,7 @@ We welcome any suggestions, questions and bug reports you may have.{% endblocktr
synnefo.config.system_images_owner = {{ system_images_owner|safe }};
synnefo.ui.init();
synnefo.ui.main.bind("initial", function(){
})
});
})
</script>
......
......@@ -49,9 +49,10 @@ from django.http import Http404
from synnefo import get_version
SYNNEFO_JS_LIB_VERSION = get_version()
IMAGE_ICONS = settings.IMAGE_ICONS
LOGOUT_URL = getattr(settings, "LOGOUT_URL", settings.LOGIN_URL)
INVITATIONS_PER_PAGE = getattr(settings, "INVITATIONS_PER_PAGE", 10)
# api configuration
COMPUTE_API_URL = getattr(settings, 'COMPUTE_API_URL', '/api/v1.1')
# UI preferences settings
TIMEOUT = getattr(settings, "TIMEOUT", 10000)
UPDATE_INTERVAL = getattr(settings, "UI_UPDATE_INTERVAL", 5000)
......@@ -61,6 +62,7 @@ UPDATE_INTERVAL_INCREASE_AFTER_CALLS_COUNT = getattr(settings,
3)
UPDATE_INTERVAL_FAST = getattr(settings, "UI_UPDATE_INTERVAL_FAST", 2500)
UPDATE_INTERVAL_MAX = getattr(settings, "UI_UPDATE_INTERVAL_MAX", 10000)
# predefined values settings
VM_IMAGE_COMMON_METADATA = getattr(settings, "VM_IMAGE_COMMON_METADATA", ["OS"])
SUGGESTED_FLAVORS_DEFAULT = {}
......@@ -70,19 +72,24 @@ SUGGESTED_ROLES_DEFAULT = ["Database server", "File server", "Mail server",
"Web server", "Proxy"]
SUGGESTED_ROLES = getattr(settings, "VM_CREATE_SUGGESTED_ROLES",
SUGGESTED_ROLES_DEFAULT)
IMAGE_ICONS = settings.IMAGE_ICONS
SUPPORT_SSH_OS_LIST = getattr(settings, "UI_SUPPORT_SSH_OS_LIST",)
OS_CREATED_USERS = getattr(settings, "UI_OS_DEFAULT_USER_MAP")
LOGOUT_URL = getattr(settings, "LOGOUT_URL", settings.LOGIN_URL)
# UI behaviour settings
DELAY_ON_BLUR = getattr(settings, "UI_DELAY_ON_BLUR", True)
UPDATE_HIDDEN_VIEWS = getattr(settings, "UI_UPDATE_HIDDEN_VIEWS", False)
HANDLE_WINDOW_EXCEPTIONS = getattr(settings, "UI_HANDLE_WINDOW_EXCEPTIONS", True)
SKIP_TIMEOUTS = getattr(settings, "UI_SKIP_TIMEOUTS", 1)
# Additional settings
VM_NAME_TEMPLATE = getattr(settings, "VM_CREATE_NAME_TPL", "My {0} server")
MAX_SSH_KEYS_PER_USER = getattr(settings, "USERDATA_MAX_SSH_KEYS_PER_USER")
FLAVORS_DISK_TEMPLATES_INFO = getattr(settings, "UI_FLAVORS_DISK_TEMPLATES_INFO", {})
SYSTEM_IMAGES_OWNER = getattr(settings, "UI_SYSTEM_IMAGES_OWNER", 'synnefo')
# MEDIA PATHS
UI_MEDIA_URL = getattr(settings, "UI_MEDIA_URL",
"%ssnf-%s/" % (settings.MEDIA_URL, SYNNEFO_JS_LIB_VERSION))
......@@ -98,6 +105,12 @@ UI_SYNNEFO_JS_WEB_URL = getattr(settings,
"UI_SYNNEFO_JS_WEB_URL",
UI_SYNNEFO_JS_URL + "ui/web/")
# extensions
ENABLE_GLANCE = getattr(settings, 'UI_ENABLE_GLANCE', True)
GLANCE_API_URL = getattr(settings, 'UI_GLANCE_API_URL', '/glance')
INVITATIONS_PER_PAGE = getattr(settings, "INVITATIONS_PER_PAGE", 10)
FEEDBACK_CONTACTS = getattr(settings, "FEEDBACK_CONTACTS", [])
FEEDBACK_EMAIL_FROM = settings.FEEDBACK_EMAIL_FROM
def template(name, context):
template_path = os.path.join(os.path.dirname(__file__), "templates/")
......@@ -121,6 +134,7 @@ def home(request):
'project': '+nefo',
'request': request,
'current_lang': get_language() or 'en',
'compute_api_url': json.dumps(COMPUTE_API_URL),
# update interval settings
'update_interval': UPDATE_INTERVAL,
'update_interval_increase': UPDATE_INTERVAL_INCREASE,
......@@ -144,7 +158,9 @@ def home(request):
'support_ssh_os_list': json.dumps(SUPPORT_SSH_OS_LIST),
'os_created_users': json.dumps(OS_CREATED_USERS),
'userdata_keys_limit': json.dumps(MAX_SSH_KEYS_PER_USER),
'system_images_owner': json.dumps(SYSTEM_IMAGES_OWNER)
'system_images_owner': json.dumps(SYSTEM_IMAGES_OWNER),
'use_glance': json.dumps(ENABLE_GLANCE),
'glance_api_url': json.dumps(GLANCE_API_URL)
}
return template('home', context)
......@@ -287,9 +303,6 @@ def machines_connect(request):
return response
FEEDBACK_CONTACTS = getattr(settings, "FEEDBACK_CONTACTS", [])
FEEDBACK_EMAIL_FROM = settings.FEEDBACK_EMAIL_FROM
def feedback_submit(request):
if not request.method == "POST":
raise Http404
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment