Revision 24a5c9e6

View differences:

src/oca/ruby/opennebula/group.rb
142 142

  
143 143
            if OpenNebula.is_error?(rc)
144 144
                self.delete
145
                error_msg =  "Error creating admin group: #{rc.message}"
145
                error_msg =  "Error creating admin user: #{rc.message}"
146 146
                return OpenNebula::Error.new(error_msg)
147 147
            end
148 148

  
149
            # Add default Sunstone views for the group
149
            str = ""
150
            update = false
151

  
152
            # Add Sunstone views for the group
150 153
            if group_hash[:views]
151
                str = "SUNSTONE_VIEWS=\"#{group_hash[:views].join(",")}\"\n"
154
                str += "SUNSTONE_VIEWS=\"#{group_hash[:views].join(",")}\"\n"
155
                update = true
156
            end
157

  
158
            # Add Sunstone views for the group
159
            if group_hash[:default_view]
160
                str += "DEFAULT_VIEW=\"#{group_hash[:default_view]}\"\n"
161
                update = true
162
            end
163

  
164
            if update
152 165
                self.update(str, true)
153 166
            end
154 167

  
......
319 332
                return rc
320 333
            end
321 334

  
335
            # Set the default admin view to vdcadmin
336
            group_admin.update("DEFAULT_VIEW=#{GROUP_ADMIN_SUNSTONE_VIEWS}", true)
337

  
322 338
            #Create admin group acls
323 339
            acls = Array.new
324 340

  
src/sunstone/public/js/plugins/groups-tab.js
67 67
        <div class="large-12 columns">\
68 68
          <p class="subheader">'
69 69
            +tr("Allow users in this group to use the following Sunstone views")+
70
            '&emsp;<span class="tip">'+tr("Views available to the group users. The default is set in sunstone-views.yaml")+'</span>\
70
            '&emsp;<span class="tip">'+tr("Views available to the group users")+'</span>\
71 71
          </p>\
72 72
        </div>\
73 73
      </div>\
......
76 76
            insert_views(dialog_name)
77 77
        +'</div>\
78 78
      </div>\
79
      <div class="row">\
80
        <div class="large-12 columns">\
81
          <p class="subheader">'
82
            +tr("Set the default Sunstone view")+
83
            '&emsp;<span class="tip">'+tr("Default view for the group users. If it is unset, the default is set in sunstone-views.yaml")+'</span>\
84
          </p>\
85
        </div>\
86
      </div>\
87
      <div class="row">\
88
        <div class="large-12 columns">'+
89
            insert_views_default(dialog_name)
90
        +'</div>\
91
      </div>\
79 92
    </div>\
80 93
    <div id="resource_providers" class="content">\
81 94
        <div class="row">\
......
448 461
Sunstone.addInfoPanel("group_info_panel",group_info_panel);
449 462

  
450 463
function insert_views(dialog_name){
451
  views_checks_str = ""
464
  var views_checks_str = "";
452 465
  var views_array = config['available_views'];
453 466
  for (var i = 0; i < views_array.length; i++)
454 467
  {
......
463 476
  return views_checks_str;
464 477
}
465 478

  
479
function insert_views_default(dialog_name){
480
  var views_checks_str = "";
481
  var views_array = config['available_views'];
482
  for (var i = 0; i < views_array.length; i++)
483
  {
484
    views_checks_str = views_checks_str +
485
             '<input type="radio" name="group_default_view_'+dialog_name+'" id="group_default_view_'+dialog_name+'_'+views_array[i]+
486
                '" value="'+views_array[i]+'"/>' +
487
             '<label for="group_default_view_'+dialog_name+'_'+views_array[i]+'">'+views_array[i]+
488
             '</label>'
489
  }
490
  return views_checks_str;
491
}
492

  
466 493
function groupElements(){
467 494
    return getSelectedNodes(dataTable_groups);
468 495
}
......
1160 1187
            group_json['group']['views'].push($(this).val());
1161 1188
        });
1162 1189

  
1190
        var default_view = $('[id^="group_default_view"]:checked', dialog).val();
1191
        if (default_view != undefined){
1192
            group_json['group']['default_view'] = default_view;
1193
        }
1163 1194

  
1164 1195
        Sunstone.runAction("Group.create",group_json);
1165 1196
        return false;
src/sunstone/sunstone-server.rb
193 193
            csrftoken_plain = Time.now.to_f.to_s + SecureRandom.base64
194 194
            session[:csrftoken] = Digest::MD5.hexdigest(csrftoken_plain)
195 195

  
196
            group = OpenNebula::Group.new_with_id(user['GID'], client)
197
            rc = group.info
198
            if OpenNebula.is_error?(rc)
199
                logger.error { rc.message }
200
                return [500, ""]
201
            end
202

  
196 203
            #User IU options initialization
197 204
            #Load options either from user settings or default config.
198 205
            # - LANG
......
222 229

  
223 230
            if user['TEMPLATE/DEFAULT_VIEW']
224 231
                session[:default_view] = user['TEMPLATE/DEFAULT_VIEW']
232
            elsif group['TEMPLATE/DEFAULT_VIEW']
233
                session[:default_view] = group['TEMPLATE/DEFAULT_VIEW']
225 234
            else
226 235
                session[:default_view] = $views_config.available_views(session[:user], session[:user_gname]).first
227 236
            end

Also available in: Unified diff