diff --git a/src/cloud/occi/etc/occi-server.conf b/src/cloud/occi/etc/occi-server.conf
index f40470112e..ca272a763d 100644
--- a/src/cloud/occi/etc/occi-server.conf
+++ b/src/cloud/occi/etc/occi-server.conf
@@ -51,3 +51,6 @@
:template: large.erb
:cpu: 8
:memory: 8192
+
+# Default language setting for Self-Service UI
+:lang: en_US
diff --git a/src/cloud/occi/lib/occi-server.rb b/src/cloud/occi/lib/occi-server.rb
index 85df192ca9..1710cf16f3 100755
--- a/src/cloud/occi/lib/occi-server.rb
+++ b/src/cloud/occi/lib/occi-server.rb
@@ -50,6 +50,7 @@ require 'sinatra'
require 'yaml'
require 'erb'
require 'tempfile'
+require 'json'
require 'OCCIServer'
require 'CloudAuth'
@@ -166,16 +167,16 @@ helpers do
session[:user] = username
session[:remember] = params[:remember]
- if user['TEMPLATE/LANG']
- session[:lang] = user['TEMPLATE/LANG']
- else
- session[:lang] = settings.config[:lang]
- end
-
if params[:remember]
env['rack.session.options'][:expire_after] = 30*60*60*24
end
+ if params[:lang]
+ session[:lang] = params[:lang]
+ else
+ session[:lang] = settings.config[:lang]
+ end
+
return [204, ""]
end
end
@@ -311,6 +312,20 @@ end
## UI
##############################################
+post '/config' do
+ begin
+ body = JSON.parse(request.body.read)
+ rescue
+ [500, "POST Config: Error parsing configuration JSON"]
+ end
+
+ body.each do | key,value |
+ case key
+ when "lang" then session[:lang]=value
+ end
+ end
+end
+
get '/ui/login' do
File.read(File.dirname(__FILE__)+'/ui/templates/login.html')
end
diff --git a/src/cloud/occi/lib/ui/public/customize/custom.js b/src/cloud/occi/lib/ui/public/customize/custom.js
index d98ee3c6e0..e26e24fecc 100644
--- a/src/cloud/occi/lib/ui/public/customize/custom.js
+++ b/src/cloud/occi/lib/ui/public/customize/custom.js
@@ -78,24 +78,28 @@ var network_box_html = '
'+tr("Your compute resources connectivity is performe
//Compute tab
///////////////////////////////////////////////////////////
var compute_dashboard_image = "images/one-compute.png";
-var compute_dashboard_html = '
' + tr("This is a list of your current compute resources. Virtual Machines use previously defined images and networks. You can easily create a new compute element by cliking \"new\" and filling-in an easy wizard.")+'
\
+var compute_dashboard_html = '
' + tr("This is a list of your current compute resources. Virtual Machines use previously defined images and networks. You can easily create a new compute element by cliking \'new\' and filling-in an easy wizard.")+'
\
'+tr("You can also manage compute resources and perform actions such as stop, resume, shutdown or cancel.")+'
\
-
'+tr("Additionally, you can take a \"snapshot\" of the storage attached to these resources. They will be saved as new resources, visible from the Storage view and re-usable.")+'
\
-
'+tr("There are currently")+' '+$vm_count+' '+tr("virtual machines")+'.
';
+
'+tr("Additionally, you can take a \'snapshot\' of the storage attached to these resources. They will be saved as new resources, visible from the Storage view and re-usable.")+'
\
+
'+tr("There are currently")+' '+$vm_count+' '+
+ tr("virtual machines")+'.
';
///////////////////////////////////////////////////////////
//Storage tab
///////////////////////////////////////////////////////////
var storage_dashboard_image = "images/one-storage.png";
var storage_dashboard_html = '
'+tr("The Storage view offers you an overview of your current images. Storage elements are attached to compute resources at creation time. They can also be extracted from running virtual machines by taking an snapshot.")+'
\
-
'+tr("You can add new storages by clicking \"new\". Image files will be uploaded to OpenNebula and set ready to be used.")+'
\
+
'+tr("You can add new storages by clicking \'new\'. Image files will be uploaded to OpenNebula and set ready to be used.")+'
\
'+tr("Additionally, you can run several operations on defined storages, such as defining their persistance. Persistent images can only be used by 1 virtual machine, and the changes made by it have effect on the base image. Non-persistent images are cloned before being used in a Virtual Machine, therefore changes are lost unless a snapshot is taken prior to Virtual Machine shutdown.")+'
\
-
'+tr("There are currently")+' '+$storage_count+' '+tr("images")+'.
';
+
'+tr("There are currently")+' '+$storage_count+' '+
+ tr("images")+'.
'+tr("In this view you can easily manage OpenNebula Network resources. You can add, remove, publish or unpublish virtual networks.")+'
\
+var network_dashboard_html = '
'+tr("In this view you can easily manage OpenNebula Network resources. You can add or remove virtual networks.")+'
\
'+tr("Compute resources can be attached to these networks at creation time. Virtual machines will be provided with an IP and the correct parameters to ensure connectivity.")+'
\
-
'+tr("There are currently")+' '+$network_count+' '+tr("networks")+'.
';
\ No newline at end of file
+
'+
+ tr("There are currently")+' '+$network_count+' '+
+ tr("networks")+'.
';
\ No newline at end of file
diff --git a/src/cloud/occi/lib/ui/public/js/locale.js b/src/cloud/occi/lib/ui/public/js/locale.js
index 28628c96de..bfec7d8f4e 100644
--- a/src/cloud/occi/lib/ui/public/js/locale.js
+++ b/src/cloud/occi/lib/ui/public/js/locale.js
@@ -30,8 +30,7 @@ function tr(str){
//Pops up loading new language dialog. Retrieves the user template, updates the LANG variable.
//Updates template and session configuration and reloads the view.
function setLang(lang_str){
- var lang_tmp="";
- var dialog = $('
Loading new language... please wait '+spinner+'
').dialog({
+ var dialog = $('
'+tr("Loading new language... please wait")+' '+spinner+'
').dialog({
draggable:false,
modal:true,
resizable:false,
@@ -40,51 +39,14 @@ function setLang(lang_str){
minHeight: 50
});
-
- var updateUserTemplate = function(request,user_json){
- var template = user_json.USER.TEMPLATE;
- var template_str="";
- template["LANG"] = lang_tmp;
-
- //convert json to ONE template format - simple conversion
- $.each(template,function(key,value){
- template_str += (key + '=' + '"' + value + '"\n');
- });
-
- var obj = {
- data: {
- id: uid,
- extra_param: template_str
- },
- error: onError
- };
- OpenNebula.User.update(obj);
- $.post('config',JSON.stringify({lang:lang_tmp}),function(){window.location.href = "."});
-
- };
-
- lang_tmp = lang_str;
-
- if (whichUI() == "sunstone"){
- var obj = {
- data : {
- id: uid,
- },
- success: updateUserTemplate
- };
- OpenNebula.User.show(obj);
- } else {
- dialog.dialog('close');
+
+ if (('localStorage' in window) && (window['localStorage'] !== null)){
+ localStorage['lang']=lang_str;
};
+ $.post('config',JSON.stringify({lang:lang_str}),function(){window.location.href = "./ui"});
};
$(document).ready(function(){
- if (lang)
- $('#lang_sel option[value="'+lang+'"]').attr('selected','selected');
- $('#lang_sel').change(function(){
- setLang($(this).val());
- });
-
//Update static translations
$('#doc_link').text(tr("Documentation"));
$('#support_link').text(tr("Support"));
diff --git a/src/cloud/occi/lib/ui/public/js/login.js b/src/cloud/occi/lib/ui/public/js/login.js
index e760c781ac..13eff1f619 100644
--- a/src/cloud/occi/lib/ui/public/js/login.js
+++ b/src/cloud/occi/lib/ui/public/js/login.js
@@ -37,16 +37,21 @@ function auth_error(req, error){
function authenticate(){
var username = $("#username").val();
var password = $("#password").val();
+ password = Crypto.SHA1(password);
var remember = $("#check_remember").is(":checked");
- password = Crypto.SHA1(password);
+ var obj = { data: {username: username,
+ password: password},
+ remember: remember,
+ success: auth_success,
+ error: auth_error
+ };
- OCCI.Auth.login({ data: {username: username
- , password: password}
- , remember: remember
- , success: auth_success
- , error: auth_error
- });
+ if (('localStorage' in window) && (window['localStorage'] !== null) && (localStorage['lang'])){
+ obj['lang'] = localStorage['lang'];
+ };
+
+ OCCI.Auth.login(obj);
}
$(document).ready(function(){
diff --git a/src/cloud/occi/lib/ui/public/js/occi.js b/src/cloud/occi/lib/ui/public/js/occi.js
index fba3b39144..45cda58f7c 100644
--- a/src/cloud/occi/lib/ui/public/js/occi.js
+++ b/src/cloud/occi/lib/ui/public/js/occi.js
@@ -359,6 +359,7 @@ var OCCI = {
var username = params.data.username;
var password = params.data.password;
var remember = params.remember;
+ var lang = params.lang;
var resource = OCCI.Auth.resource;
var request = OCCI.Helper.request(resource,"login");
@@ -366,7 +367,7 @@ var OCCI = {
$.ajax({
url: "ui/login",
type: "POST",
- data: {remember: remember},
+ data: {remember: remember, lang: lang},
beforeSend : function(req) {
req.setRequestHeader( "Authorization",
"Basic " + btoa(username + ":" + password)
diff --git a/src/cloud/occi/lib/ui/public/js/plugins/compute.js b/src/cloud/occi/lib/ui/public/js/plugins/compute.js
index 6b4ceef514..ac6fd96681 100644
--- a/src/cloud/occi/lib/ui/public/js/plugins/compute.js
+++ b/src/cloud/occi/lib/ui/public/js/plugins/compute.js
@@ -308,7 +308,7 @@ var vm_buttons = {
"VM.shutdown" : {
type: "confirm",
text: tr("Shutdown"),
- tip: tr("This will initiate the shutdown process in the selected VMs")
+ tip: tr("This will shutdown the selected VMs")
},
"action_list" : {
@@ -317,12 +317,12 @@ var vm_buttons = {
"VM.suspend" : {
type: "confirm",
text: tr("Suspend"),
- tip: tr("This will suspend selected machines")
+ tip: tr("This will suspend the selected VMs")
},
"VM.resume" : {
type: "confirm",
text: tr("Resume"),
- tip: tr("This will resume selected stopped or suspended VMs")
+ tip: tr("This will resume the selected VMs in stopped or suspended states")
},
"VM.stop" : {
type: "confirm",
@@ -336,7 +336,7 @@ var vm_buttons = {
},
"VM.saveasmultiple" : {
type: "action",
- text: tr("Save as")
+ text: tr("Take snapshot")
}
}
},
@@ -744,7 +744,7 @@ function popUpCreateVMDialog(){
//Prepares a dialog to saveas a VM
function setupSaveasDialog(){
//Append to DOM
- dialogs_context.append('');
+ dialogs_context.append('');
$saveas_vm_dialog = $('#saveas_vm_dialog',dialogs_context);
var dialog = $saveas_vm_dialog;
diff --git a/src/cloud/occi/lib/ui/public/js/plugins/configuration.js b/src/cloud/occi/lib/ui/public/js/plugins/configuration.js
new file mode 100644
index 0000000000..97c5803b1c
--- /dev/null
+++ b/src/cloud/occi/lib/ui/public/js/plugins/configuration.js
@@ -0,0 +1,62 @@
+/* -------------------------------------------------------------------------- */
+/* Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) */
+/* */
+/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
+/* not use this file except in compliance with the License. You may obtain */
+/* a copy of the License at */
+/* */
+/* http://www.apache.org/licenses/LICENSE-2.0 */
+/* */
+/* Unless required by applicable law or agreed to in writing, software */
+/* distributed under the License is distributed on an "AS IS" BASIS, */
+/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
+/* See the License for the specific language governing permissions and */
+/* limitations under the License. */
+/* -------------------------------------------------------------------------- */
+
+var config_tab_content =
+'';
+
+var config_tab = {
+ title: tr("Configuration"),
+ content: config_tab_content
+}
+
+Sunstone.addMainTab('config_tab',config_tab);
+
+$(document).ready(function(){
+ if (lang)
+ $('table#config_table #lang_sel option[value="'+lang+'"]').attr('selected','selected');
+ $('table#config_table #lang_sel').change(function(){
+ setLang($(this).val());
+ });
+
+ $('#li_config_tab a').click(function(){
+ hideDialog();
+ });
+
+});
\ No newline at end of file
diff --git a/src/cloud/occi/lib/ui/public/js/plugins/dashboard.js b/src/cloud/occi/lib/ui/public/js/plugins/dashboard.js
index 024df21719..f73b25e709 100644
--- a/src/cloud/occi/lib/ui/public/js/plugins/dashboard.js
+++ b/src/cloud/occi/lib/ui/public/js/plugins/dashboard.js
@@ -78,8 +78,8 @@ var dashboard_tab_content =
'+
compute_box_html +
- '