From 5ec325018de1376cff188450ca13393f8d0babde Mon Sep 17 00:00:00 2001 From: Abel Coronado Date: Thu, 20 Apr 2017 12:24:30 +0200 Subject: [PATCH] F #5056 Added filter view and primary group (#267) * F #5056 Added filter view and primary group * F #5065 filter view configurable --- src/sunstone/etc/sunstone-views/admin.yaml | 1 + .../etc/sunstone-views/admin_vcenter.yaml | 1 + .../etc/sunstone-views/groupadmin.yaml | 1 + .../sunstone-views/groupadmin_vcenter.yaml | 1 + src/sunstone/etc/sunstone-views/user.yaml | 1 + src/sunstone/public/app/app.js | 38 ++++++++++++------- src/sunstone/public/app/sunstone-config.js | 1 + .../public/app/sunstone/user_and_zone.hbs | 8 ++++ 8 files changed, 38 insertions(+), 14 deletions(-) diff --git a/src/sunstone/etc/sunstone-views/admin.yaml b/src/sunstone/etc/sunstone-views/admin.yaml index 71a38c86c1..370a0ffde2 100644 --- a/src/sunstone/etc/sunstone-views/admin.yaml +++ b/src/sunstone/etc/sunstone-views/admin.yaml @@ -3,6 +3,7 @@ provision_logo: images/opennebula-5.0.png link_logo: text_link_logo: confirm_vms: false +filter-view: true enabled_tabs: - dashboard-tab - instances-top-tab diff --git a/src/sunstone/etc/sunstone-views/admin_vcenter.yaml b/src/sunstone/etc/sunstone-views/admin_vcenter.yaml index 75ef5ef014..298f1d73d4 100644 --- a/src/sunstone/etc/sunstone-views/admin_vcenter.yaml +++ b/src/sunstone/etc/sunstone-views/admin_vcenter.yaml @@ -3,6 +3,7 @@ provision_logo: images/opennebula-5.0.png link_logo: text_link_logo: confirm_vms: false +filter-view: true enabled_tabs: - dashboard-tab - instances-top-tab diff --git a/src/sunstone/etc/sunstone-views/groupadmin.yaml b/src/sunstone/etc/sunstone-views/groupadmin.yaml index 942acdc0bf..9156eeb5f5 100644 --- a/src/sunstone/etc/sunstone-views/groupadmin.yaml +++ b/src/sunstone/etc/sunstone-views/groupadmin.yaml @@ -3,6 +3,7 @@ provision_logo: images/opennebula-5.0.png link_logo: text_link_logo: confirm_vms: false +filter-view: true enabled_tabs: - dashboard-tab - instances-top-tab diff --git a/src/sunstone/etc/sunstone-views/groupadmin_vcenter.yaml b/src/sunstone/etc/sunstone-views/groupadmin_vcenter.yaml index bd8324a778..add261ea06 100644 --- a/src/sunstone/etc/sunstone-views/groupadmin_vcenter.yaml +++ b/src/sunstone/etc/sunstone-views/groupadmin_vcenter.yaml @@ -3,6 +3,7 @@ provision_logo: images/opennebula-5.0.png link_logo: text_link_logo: confirm_vms: false +filter-view: true enabled_tabs: - dashboard-tab - instances-top-tab diff --git a/src/sunstone/etc/sunstone-views/user.yaml b/src/sunstone/etc/sunstone-views/user.yaml index 389a1d7887..51abd88b9b 100644 --- a/src/sunstone/etc/sunstone-views/user.yaml +++ b/src/sunstone/etc/sunstone-views/user.yaml @@ -3,6 +3,7 @@ provision_logo: images/opennebula-5.0.png link_logo: text_link_logo: confirm_vms: false +filter-view: true enabled_tabs: - dashboard-tab - instances-top-tab diff --git a/src/sunstone/public/app/app.js b/src/sunstone/public/app/app.js index c293b59343..5fce883695 100644 --- a/src/sunstone/public/app/app.js +++ b/src/sunstone/public/app/app.js @@ -101,12 +101,14 @@ define(function(require) { Config.changeFilter(false); $(".user-zone-info").html(UserAndZoneTemplate({ + filterView: Config['filterView'], displayName: config['display_name'], settingsTabEnabled: Config.isTabEnabled(SETTINGS_TAB_ID), availableViews: config['available_views'], zoneName: config['zone_name'] })).foundation(); + $('#filter-view').hide(); groupsRefresh(); $('.quickconf_view[view="' + config['user_config']["default_view"] + '"] i').addClass('fa-check'); @@ -131,6 +133,7 @@ define(function(require) { }, success: function (request, obj_user) { var groups = obj_user.USER.GROUPS.ID; + this.primaryGroup = obj_user.USER.GID; var groupsHTML = "
  • \ " + Locale.tr("All") + "
  • "; if(this.idGroup == -2){ @@ -172,21 +175,28 @@ define(function(require) { $('#userselector').on('click', function(){ $('.groups-menu').empty(); $('.groups-menu').append(groupsHTML); + var primaryGroupChar = ''; + $('#'+ that.primaryGroup + ' a').append(primaryGroupChar); $('.groups').on('click', function(){ - that.idGroup = $(this).attr('value'); - if(that.idGroup != -2){ - Sunstone.runAction("User.chgrp", [parseInt(config['user_id'])], parseInt(that.idGroup)); - } - $('.groups-menu a i').removeClass('fa-check'); - $('a i', this).addClass('fa-check'); - groupsRefresh(); - if(that.idGroup != -2){ - Config.changeFilter(true); - } else { - Config.changeFilter(false); - } - $('.refresh').click(); - $('.refresh-table').click(); + that.idGroup = $(this).attr('value'); + if(that.idGroup != -2){ + $('#primary-char').remove(); + Sunstone.runAction("User.chgrp", [parseInt(config['user_id'])], parseInt(that.idGroup)); + $('a', this).append(primaryGroupChar); + Config.changeFilter(true); + var filterName = $(this).text(); + $('#filter-view').show(); + $('.filter-name').html(filterName); + } else { + $('#filter-view').hide(); + Config.changeFilter(false); + } + $('.groups-menu a i').removeClass('fa-check'); + $('a i', this).addClass('fa-check'); + groupsRefresh(); + $('.refresh').click(); + $('.refresh-table').click(); }); }); }, diff --git a/src/sunstone/public/app/sunstone-config.js b/src/sunstone/public/app/sunstone-config.js index 68d5899f66..6faef5f89c 100644 --- a/src/sunstone/public/app/sunstone-config.js +++ b/src/sunstone/public/app/sunstone-config.js @@ -157,6 +157,7 @@ define(function(require) { 'enabledTabs': _config['view']['enabled_tabs'], 'onedConf': _config['oned_conf'], 'confirmVMActions': _config['view']['confirm_vms'], + 'filterView': _config['view']['filter_view'], "allTabs": function() { return Object.keys(_config['view']['tabs']); diff --git a/src/sunstone/public/app/sunstone/user_and_zone.hbs b/src/sunstone/public/app/sunstone/user_and_zone.hbs index 59101ad5aa..91cd2a3a0c 100644 --- a/src/sunstone/public/app/sunstone/user_and_zone.hbs +++ b/src/sunstone/public/app/sunstone/user_and_zone.hbs @@ -15,6 +15,14 @@ {{! -------------------------------------------------------------------------- }}