1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-16 22:50:10 +03:00

Feature 5065 Use filter flag to implement group views (#265)

* F #5065 changed ruby to acept filter

* F #5065 added posibility to change group and filter the resources pool

* Bug resolved bug when change primary group

* F #5065 click refresh button when you select a group
This commit is contained in:
juanmont 2017-04-19 14:29:05 +02:00 committed by Tino Vázquez
parent 3dd7f49e93
commit 5681d03d86
8 changed files with 23 additions and 16 deletions

View File

@ -24,8 +24,6 @@ require 'OpenNebulaJSON/JSONUtils'
#include JSONUtils
class SunstoneServer < CloudServer
# FLAG that will filter the elements retrieved from the Pools
POOL_FILTER = Pool::INFO_ALL
# Secs to sleep between checks to see if image upload to repo is finished
IMAGE_POLL_SLEEP_TIME = 5
@ -38,14 +36,10 @@ class SunstoneServer < CloudServer
############################################################################
#
############################################################################
def get_pool(kind,gid, client=nil)
def get_pool(kind,user_flag, client=nil)
client = @client if !client
if gid == "0"
user_flag = Pool::INFO_ALL
else
user_flag = POOL_FILTER
end
user_flag = Integer(user_flag)
pool = case kind
when "group" then GroupPoolJSON.new(client)

View File

@ -37,8 +37,6 @@ define(function(require) {
var Notifier = require('utils/notifier');
var Menu = require('utils/menu');
var Locale = require('utils/locale');
var OpenNebulaGroup = require('opennebula/group');
var UserAndZoneTemplate = require('hbs!sunstone/user_and_zone');
var _commonDialogs = [
@ -176,6 +174,9 @@ define(function(require) {
$('.groups-menu').append(groupsHTML);
$('.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();
@ -184,6 +185,8 @@ define(function(require) {
} else {
Config.changeFilter(false);
}
$('.refresh').click();
$('.refresh-table').click();
});
});
},

View File

@ -17,6 +17,7 @@
define(function(require) {
var OpenNebulaHelper = require('./helper');
var OpenNebulaError = require('./error');
var Config = require('sunstone-config');
var listCache = {};
var listWaiting = {};
@ -162,13 +163,13 @@ define(function(require) {
}
listWaiting[cache_name] = true;
var pool_filter = Config.isChangedFilter()?-4:-2;
//console.log(cache_name+" list. NO cache, calling ajax");
$.ajax({
url: reqPath,
type: "GET",
data: {timeout: timeout},
data: {timeout: timeout, pool_filter: pool_filter},
dataType: "json",
success: function(response) {
var list;

View File

@ -131,7 +131,9 @@ define(function(require) {
return support;
},
"initMarketExportSupported": function(){
var pool_filter = Config.isChangedFilter()? -4 : -2;
this.list({
data : {pool_filter : pool_filter},
timeout: true,
success: function (request, obj_list) {},
//error: Notifier.onError

View File

@ -30,6 +30,10 @@ define(function(require) {
_config['pool_filter'] = bool;
},
"isChangedFilter": function(){
return _config['pool_filter'];
},
"isTabActionEnabled": function(tabName, actionName, panelName) {
var enabled = false;
var configTab = _config['view']['tabs'][tabName];

View File

@ -108,7 +108,7 @@ define(function(require) {
this.groupsTableEdit.selectResourceTableSelect({ids: this.groups});
$("#cancel_update_group").hide();
that = this;
var that = this;
context.off("click", "#update_group");
context.on("click", "#update_group", function() {
ResourceSelect.insert({

View File

@ -1231,16 +1231,17 @@ define(function(require) {
success_func(request, []);
Notifier.onError(request, error_json, container);
}
var pool_filter = SunstoneConfig.isChangedFilter()? -4 : -2;
if (that.selectOptions.zone_id == undefined) {
OpenNebula[that.resource].list({
data : {pool_filter : pool_filter},
timeout: true,
success: success_func,
error: error_func
});
} else {
OpenNebula[that.resource].list_in_zone({
data: {zone_id: that.selectOptions.zone_id},
data: {zone_id: that.selectOptions.zone_id, pool_filter : pool_filter},
timeout: true,
success: success_func,
error: error_func
@ -1251,7 +1252,9 @@ define(function(require) {
// TODO: This is probably duplicated somewhere
function _list() {
var that = this;
var pool_filter = SunstoneConfig.isChangedFilter()? -4 : -2;
OpenNebula[that.resource].list({
data : {pool_filter : pool_filter},
success: function(req, resp) {
that.updateView(req, resp);
},

View File

@ -702,7 +702,7 @@ get '/:pool' do
end
@SunstoneServer.get_pool(params[:pool],
session[:user_gid],
params[:pool_filter],
zone_client)
end