diff --git a/src/sunstone/etc/sunstone-views.yaml b/src/sunstone/etc/sunstone-views.yaml
index 5b322555db..af63c4b334 100644
--- a/src/sunstone/etc/sunstone-views.yaml
+++ b/src/sunstone/etc/sunstone-views.yaml
@@ -2,7 +2,6 @@
logo: images/opennebula-sunstone-v4.0.png
available_tabs:
- dashboard-tab
- - quotas-tab
- system-tab
- users-tab
- groups-tab
diff --git a/src/sunstone/etc/sunstone-views/admin.yaml b/src/sunstone/etc/sunstone-views/admin.yaml
index f55856d40b..7014b0b972 100644
--- a/src/sunstone/etc/sunstone-views/admin.yaml
+++ b/src/sunstone/etc/sunstone-views/admin.yaml
@@ -1,7 +1,6 @@
small_logo: images/opennebula-sunstone-v4.0-small.png
enabled_tabs:
dashboard-tab: true
- quotas-tab: false
system-tab: true
users-tab: true
groups-tab: true
@@ -25,6 +24,8 @@ tabs:
dashboard-tab:
panel_tabs:
actions:
+ Dashboard.refresh: false
+ Sunstone.toggle_top: false
widgets_three_per_row:
- storage
- users
@@ -35,10 +36,6 @@ tabs:
- hosts
widgets_one_footer:
# - quotas
- quotas-tab:
- panel_tabs:
- actions:
- Quotas.refresh: true
system-tab:
panel_tabs:
actions:
diff --git a/src/sunstone/etc/sunstone-views/user.yaml b/src/sunstone/etc/sunstone-views/user.yaml
index 8e154b3416..b532de7b7b 100644
--- a/src/sunstone/etc/sunstone-views/user.yaml
+++ b/src/sunstone/etc/sunstone-views/user.yaml
@@ -1,7 +1,6 @@
small_logo: images/opennebula-sunstone-v4.0-small.png
enabled_tabs:
dashboard-tab: true
- quotas-tab: true
system-tab: false
users-tab: false
groups-tab: false
@@ -24,6 +23,8 @@ tabs:
dashboard-tab:
panel_tabs:
actions:
+ Dashboard.refresh: false
+ Sunstone.toggle_top: false
widgets_three_per_row:
#- users
widgets_two_per_row:
@@ -35,10 +36,6 @@ tabs:
- vms
widgets_one_footer:
- quotas
- quotas-tab:
- panel_tabs:
- actions:
- Quotas.refresh: true
system-tab:
panel_tabs:
actions:
diff --git a/src/sunstone/etc/sunstone-views/vdcadmin.yaml b/src/sunstone/etc/sunstone-views/vdcadmin.yaml
index b9f6cff289..c6d8e815ed 100644
--- a/src/sunstone/etc/sunstone-views/vdcadmin.yaml
+++ b/src/sunstone/etc/sunstone-views/vdcadmin.yaml
@@ -1,7 +1,6 @@
small_logo: images/opennebula-sunstone-v4.0-small.png
enabled_tabs:
dashboard-tab: true
- quotas-tab: true
system-tab: true
users-tab: true
groups-tab: false
@@ -24,6 +23,8 @@ tabs:
dashboard-tab:
panel_tabs:
actions:
+ Dashboard.refresh: false
+ Sunstone.toggle_top: false
widgets_three_per_row:
- users
- network
@@ -35,10 +36,6 @@ tabs:
- vms
widgets_one_footer:
- quotas
- quotas-tab:
- panel_tabs:
- actions:
- Quotas.refresh: true
system-tab:
panel_tabs:
actions:
diff --git a/src/sunstone/public/js/plugins/dashboard-tab.js b/src/sunstone/public/js/plugins/dashboard-tab.js
index edeb9a4502..7695e910cf 100644
--- a/src/sunstone/public/js/plugins/dashboard-tab.js
+++ b/src/sunstone/public/js/plugins/dashboard-tab.js
@@ -228,13 +228,58 @@ var widgets = {
'
}
+var widget_refresh = {
+ "storage" : function(){
+ Sunstone.runAction("Datastore.list");
+ },
+ "users" : function(){
+ Sunstone.runAction("User.list");
+ },
+ "network" : function(){
+ Sunstone.runAction("Network.list");
+ },
+ "hosts" : function(){
+ Sunstone.runAction("Host.list");
+ },
+ "vms" : function(){
+ Sunstone.runAction("VM.list");
+ },
+ "quotas" : refreshDashboardQuotas
+}
+
+var dashboard_tab_actions = {
+ "Dashboard.refresh" : {
+ type: "custom",
+ call: refreshDashboard
+ },
+ "dashboard-tab.refresh" : {
+ type: "custom",
+ call: refreshDashboard
+ },
+}
+
+var quotas_tab_buttons = {
+ "Dashboard.refresh" : {
+ type: "action",
+ layout: "refresh",
+ alwaysActive: true
+ },
+ "Sunstone.toggle_top" : {
+ type: "custom",
+ layout: "top",
+ alwaysActive: true
+ }
+}
+
var dashboard_tab = {
title: ''+tr("Dashboard"),
+ buttons: quotas_tab_buttons,
content: dashboard_tab_content,
showOnTopMenu: false,
list_header: ' '+tr("Dashboard")
}
+Sunstone.addActions(dashboard_tab_actions);
Sunstone.addMainTab('dashboard-tab',dashboard_tab);
var $dashboard;
@@ -250,9 +295,13 @@ function fillUserQuotasInfo(){
});
}
+var dashboard_current_gid = "-1";
+
function updateUserQuotasInfo(request,user_json) {
var info = user_json.USER;
+ dashboard_current_gid = user_json.USER.GID;
+
var default_user_quotas = Quotas.default_quotas(info.DEFAULT_USER_QUOTAS)
var quotas_tab_html = Quotas.vms(info, default_user_quotas);
quotas_tab_html += Quotas.cpu(info, default_user_quotas);
@@ -304,13 +353,13 @@ function updateGroupQuotasInfo(request,group_json){
$("#quotas_tab_group_TabBody", $dashboard).html(quotas_tab_html);
}
-function refreshQuotasTab(){
+function refreshDashboardQuotas(){
fillUserQuotasInfo();
gid = $("#quotas_tab_group_sel .resource_list_select", $dashboard).val();
- if (gid == ""){
- gid = "-1";
+ if (gid == "" || gid == undefined){
+ gid = dashboard_current_gid;
}
fillGroupQuotasInfo(gid);
@@ -318,16 +367,16 @@ function refreshQuotasTab(){
insertSelectOptions('div#quotas_tab_group_sel', $dashboard, "Group", gid, false);
}
-$(document).ready(function(){
- $quotas_tab = $('#quotas-tab', main_tabs_context);
+function refreshDashboard(){
+ widget_types = ['widgets_three_per_row', 'widgets_two_per_row',
+ 'widgets_one_per_row', 'widgets_one_footer'];
-});
-
-
-
-// All monitoring calls and config are called from the Sunstone plugins.
-
-function dashboardQuotasHTML(){}
+ $.each(widget_types, function(index, widget_type){
+ $.each(Config.dashboardWidgets(widget_type), function(id, widget){
+ widget_refresh[widget]();
+ })
+ });
+}
$(document).ready(function(){
var tab_name = 'dashboard-tab';
@@ -364,19 +413,6 @@ $(document).ready(function(){
}
});
- fillUserQuotasInfo();
-
- OpenNebula.Group.show({
- data : {
- id: '-1'
- },
- success: function(request, group_json){
- updateGroupQuotasInfo(request, group_json);
-
- insertSelectOptions('div#quotas_tab_group_sel', $dashboard, "Group", group_json.GROUP.ID, false);
- }
- });
-
$(document).foundation();
}
});
diff --git a/src/sunstone/public/js/plugins/users-tab.js b/src/sunstone/public/js/plugins/users-tab.js
index 340f411944..609e12da64 100644
--- a/src/sunstone/public/js/plugins/users-tab.js
+++ b/src/sunstone/public/js/plugins/users-tab.js
@@ -611,9 +611,6 @@ function updateUsersView(request,users_list,quotas_list){
var user_list_array = [];
$.each(users_list,function(){
- //if (this.USER.ID == uid)
- // dashboardQuotasHTML(this.USER);
-
// Inject the VM user quota. This info is returned separately in the
// pool info call, but the userElementArray expects it inside the USER,
// as it is returned by the individual info call
diff --git a/src/sunstone/public/js/sunstone.js b/src/sunstone/public/js/sunstone.js
index 681753533e..4c2ced0591 100644
--- a/src/sunstone/public/js/sunstone.js
+++ b/src/sunstone/public/js/sunstone.js
@@ -3636,7 +3636,11 @@ function showTab(tabname,highlight_tab){
if (res){
Sunstone.runAction(res+".list");
} else {
-// $(".fa-refresh", $('#'+activeTab)).click();
+ var action = activeTab+".refresh";
+
+ if(SunstoneCfg["actions"][action]){
+ Sunstone.runAction(action);
+ }
}
}