Scott Seago
2008-May-15 21:44 UTC
[Ovirt-devel] [Patch] hook up some more ui components to the new style, including VMs and user permissions
This patch hooks up the new/add form and change role pulldown for user permissions. Delete works for vms, vm pools, and user permissions. Pulldown for vms is done on the UI side, but the controller method isn't filled out yet. This stuff still needs permissiosn checks and proper validation/confirmation. Darryl -- you should be able to use this patch as the basis for your changes to the permissions setting code. Scott
Scott Seago
2008-May-15 21:47 UTC
[Ovirt-devel] [Patch] hook up some more ui components to the new style, including VMs and user permissions
Scott Seago wrote:> This patch hooks up the new/add form and change role pulldown for user > permissions. Delete works for vms, vm pools, and user permissions. > Pulldown for vms is done on the UI side, but the controller method > isn't filled out yet. > > This stuff still needs permissiosn checks and proper > validation/confirmation. > > Darryl -- you should be able to use this patch as the basis for your > changes to the permissions setting code. > > Scott > ------------------------------------------------------------------------ > > _______________________________________________ > Ovirt-devel mailing list > Ovirt-devel at redhat.com > https://www.redhat.com/mailman/listinfo/ovirt-develTrying again. didn't like my patch even though I had stuff before it in the message. >
Scott Seago
2008-May-15 21:49 UTC
[Ovirt-devel] [Patch] hook up some more ui components to the new style, including VMs and user permissions
Scott Seago wrote:> This patch hooks up the new/add form and change role pulldown for user > permissions. Delete works for vms, vm pools, and user permissions. > Pulldown for vms is done on the UI side, but the controller method > isn't filled out yet. > > This stuff still needs permissiosn checks and proper > validation/confirmation. > > Darryl -- you should be able to use this patch as the basis for your > changes to the permissions setting code. > > ScottOK third try to attach the patch. This time I'll paste it into the message: From e704f854817ea081d78e75375129c18744afb950 Mon Sep 17 00:00:00 2001 From: Scott Seago <sseago at kodiak.boston.redhat.com> Date: Thu, 15 May 2008 17:42:59 -0400 Subject: [PATCH] This patch hooks up the new/add form and change role pulldown for user permissions. Delete works for vms, vm pools, and user permissions. Pulldown for vms is done on the UI side, but the controller method isn't filled out yet. This stuff still needs permissiosn checks and proper validation/confirmation. Signed-off-by: Scott Seago <sseago at kodiak.boston.redhat.com> --- wui/src/app/controllers/hardware_controller.rb | 2 +- wui/src/app/controllers/permission_controller.rb | 38 +++++++++++- wui/src/app/controllers/resources_controller.rb | 32 ++++++++-- wui/src/app/controllers/vm_controller.rb | 14 ++++ wui/src/app/views/hardware/show_users.rhtml | 33 +---------- wui/src/app/views/hardware/show_vms.rhtml | 27 ++++++++- wui/src/app/views/permission/new.rhtml | 70 ++++++++++------------ wui/src/app/views/resources/_form.rhtml | 6 +-- wui/src/app/views/resources/new.rhtml | 70 ++++++++++------------ wui/src/app/views/resources/show_users.rhtml | 33 +---------- wui/src/app/views/resources/show_vms.rhtml | 57 +++++++++--------- wui/src/app/views/user/_change_role_menu.rhtml | 5 +- wui/src/app/views/user/_grid.rhtml | 30 +++++++++ wui/src/app/views/user/_show.rhtml | 46 ++++++++++++++ wui/src/app/views/vm/_grid.rhtml | 34 +++++++++++ wui/src/public/stylesheets/components.css | 10 +++ 16 files changed, 320 insertions(+), 187 deletions(-) create mode 100644 wui/src/app/views/user/_grid.rhtml create mode 100644 wui/src/app/views/user/_show.rhtml create mode 100644 wui/src/app/views/vm/_grid.rhtml diff --git a/wui/src/app/controllers/hardware_controller.rb b/wui/src/app/controllers/hardware_controller.rb index 3379199..599d881 100644 --- a/wui/src/app/controllers/hardware_controller.rb +++ b/wui/src/app/controllers/hardware_controller.rb @@ -107,7 +107,7 @@ class HardwareController < ApplicationController def users_json json_list(@pool.permissions, - [:user, :user_role]) + [:id, :user, :user_role]) end def storage_pools_json diff --git a/wui/src/app/controllers/permission_controller.rb b/wui/src/app/controllers/permission_controller.rb index 68eb54d..9fe63d8 100644 --- a/wui/src/app/controllers/permission_controller.rb +++ b/wui/src/app/controllers/permission_controller.rb @@ -45,24 +45,58 @@ class PermissionController < ApplicationController flash[:notice] = 'You do not have permission to create this permission record' redirect_to_parent end + render :layout => 'popup' end def create @permission = Permission.new(params[:permission]) set_perms(@permission.pool) unless @can_set_perms + # FIXME: need to handle proper error messages w/ ajax flash[:notice] = 'You do not have permission to create this permission record' redirect_to_parent else if @permission.save - flash[:notice] = 'Permission was successfully created.' - redirect_to_parent + render :json => "created User Permissions for #{@permission.user}".to_json else + # FIXME: need to handle proper error messages w/ ajax render :action => 'new' end end end + #FIXME: we need permissions checks. user must have permission. We also need to fail + # for pools that aren't currently empty + def update_roles + role = params[:user_role] + permission_ids_str = params[:permission_ids] + permission_ids = permission_ids_str.split(",").collect {|x| x.to_i} + + Permission.transaction do + permissions = Permission.find(:all, :conditions => "id in (#{permission_ids.join(', ')})") + permissions.each do |permission| + permission.user_role = role + permission.save! + end + end + render :text => "deleted user permissions (#{permission_ids.join(', ')})" + end + + #FIXME: we need permissions checks. user must have permission. We also need to fail + # for pools that aren't currently empty + def delete + permission_ids_str = params[:permission_ids] + permission_ids = permission_ids_str.split(",").collect {|x| x.to_i} + + Permission.transaction do + permissions = Permission.find(:all, :conditions => "id in (#{permission_ids.join(', ')})") + permissions.each do |permission| + permission.destroy + end + end + render :text => "deleted user permissions (#{permission_ids.join(', ')})" + end + def destroy @permission = Permission.find(params[:id]) set_perms(@permission.pool) diff --git a/wui/src/app/controllers/resources_controller.rb b/wui/src/app/controllers/resources_controller.rb index 14499ab..68e3abe 100644 --- a/wui/src/app/controllers/resources_controller.rb +++ b/wui/src/app/controllers/resources_controller.rb @@ -58,7 +58,12 @@ class ResourcesController < ApplicationController # resource's vms list page def show_vms show - @actions = VmTask::ACTIONS.keys + @actions = [["Start", VmTask::ACTION_START_VM], + ["Shutdown", VmTask::ACTION_SHUTDOWN_VM, "break"], + ["Suspend", VmTask::ACTION_SUSPEND_VM], + ["Resume", VmTask::ACTION_RESUME_VM], + ["Save", VmTask::ACTION_SAVE_VM], + ["Restore", VmTask::ACTION_RESTORE_VM]] end # resource's users list page @@ -69,23 +74,23 @@ class ResourcesController < ApplicationController def vms_json json_list(@vm_resource_pool.vms, - [:description, :uuid, :num_vcpus_allocated, :memory_allocated_in_mb, :vnic_mac_addr, :state]) + [:id, :description, :uuid, :num_vcpus_allocated, :memory_allocated_in_mb, :vnic_mac_addr, :state]) end def users_json json_list(@vm_resource_pool.permissions, - [:user, :user_role]) + [:id, :user, :user_role]) end def new - @vm_resource_pools = @vm_resource_pool.self_and_like_siblings + render :layout => 'popup' end def create if @vm_resource_pool.create_with_parent(@parent) - flash[:notice] = 'VM Resource Pool was successfully created.' - redirect_to :controller => @vm_resource_pool.parent.get_controller, :action => 'show', :id => @vm_resource_pool.parent + render :json => "created new VM pool #{@vm_resource_pool.name}".to_json else + # FIXME: need to handle proper error messages w/ ajax render :action => 'new' end end @@ -102,6 +107,21 @@ class ResourcesController < ApplicationController end end + #FIXME: we need permissions checks. user must have permission. We also need to fail + # for pools that aren't currently empty + def delete + vm_pool_ids_str = params[:vm_pool_ids] + vm_pool_ids = vm_pool_ids_str.split(",").collect {|x| x.to_i} + + VmResourcePool.transaction do + pools = VmResourcePool.find(:all, :conditions => "id in (#{vm_pool_ids.join(', ')})") + pools.each do |pool| + pool.destroy + end + end + render :text => "deleted vm pools (#{vm_pool_ids.join(', ')})" + end + def destroy parent = @vm_resource_pool.parent @vm_resource_pool.destroy diff --git a/wui/src/app/controllers/vm_controller.rb b/wui/src/app/controllers/vm_controller.rb index ae6d437..4e4faf9 100644 --- a/wui/src/app/controllers/vm_controller.rb +++ b/wui/src/app/controllers/vm_controller.rb @@ -97,6 +97,20 @@ class VmController < ApplicationController end end + #FIXME: we need permissions checks. user must have permission. + def delete + vm_ids_str = params[:vm_ids] + vm_ids = vm_ids_str.split(",").collect {|x| x.to_i} + + Vm.transaction do + vms = Vm.find(:all, :conditions => "id in (#{vm_ids.join(', ')})") + vms.each do |vm| + vm.destroy + end + end + render :text => "deleted vms (#{vm_ids.join(', ')})" + end + def destroy vm_resource_pool = @vm.vm_resource_pool_id if ((@vm.state == Vm::STATE_STOPPED and @vm.get_pending_state == Vm::STATE_STOPPED) or diff --git a/wui/src/app/views/hardware/show_users.rhtml b/wui/src/app/views/hardware/show_users.rhtml index 2a5c9ee..abec65c 100644 --- a/wui/src/app/views/hardware/show_users.rhtml +++ b/wui/src/app/views/hardware/show_users.rhtml @@ -1,31 +1,2 @@ -<div id="toolbar_nav"> -<ul> - <li><a href="TODO"><%= image_tag "icon_adduser.png" %> Add User</a></li> - <li><%= render :partial => 'user/change_role_menu' %></li> - <li><a href="TODO"><%= image_tag "icon_delete_white.png" %> Remove</a></li> -</ul> -</div> - -<div class="panel_header"></div> -<div class="data_section"> -<table id="users_grid" style="display:none"></table> -</div> -<script type="text/javascript"> - $("#users_grid").flexigrid - ( - { - url: '<%= url_for :action => "users_json", :id => @pool.id %>', - dataType: 'json', - colModel : [ - {display: 'Name', name : 'user', width : 180, sortable : true, align: 'left'}, - {display: 'Role', name : 'user_role', width : 80, sortable : true, align: 'left'} - ], - sortname: "user", - sortorder: "asc", - usepager: true, - useRp: true, - rp: 10, - showTableToggleBtn: true - } - ); -</script> +<%= render :partial => "/user/show", :locals => { :parent_controller => "hardware", + :pool_id => @pool.id } %> diff --git a/wui/src/app/views/hardware/show_vms.rhtml b/wui/src/app/views/hardware/show_vms.rhtml index 0d91421..407b80c 100644 --- a/wui/src/app/views/hardware/show_vms.rhtml +++ b/wui/src/app/views/hardware/show_vms.rhtml @@ -1,9 +1,32 @@ <div id="toolbar_nav"> <ul> - <li><a href="dialogs/addvmpool.html" rel="facebox[.bolder]"><%= image_tag "icon_add_vmpool.png", :style => "vertical-align:middle;" %> New Virtual Machine Pool</a></li> - <li><a href="#"><%= image_tag "icon_delete_white.png", :style => "vertical-align:middle;" %> Delete</a></li> + <li><a href="<%= url_for :controller => 'resources', :action => 'new', :parent_id => @pool %>" rel="facebox[.bolder]"><%= image_tag "icon_add_vmpool.png", :style => "vertical-align:middle;" %> New Virtual Machine Pool</a></li> + <li><a href="#" onClick="delete_vm_pools()"><%= image_tag "icon_delete_white.png", :style => "vertical-align:middle;" %> Delete</a></li> </ul> </div> +<script type="text/javascript"> + function get_selected_vm_pools() + { + var vm_pools_array = new Array() + var vm_pools_index = 0 + for(var i=0; i < document.vmpools_grid_form.grid_checkbox.length; i++){ + if(document.vmpools_grid_form.grid_checkbox[i].checked) + { + vm_pools_array[vm_pools_index]= document.vmpools_grid_form.grid_checkbox[i].value + vm_pools_index++ + } + } + return vm_pools_array + } + function delete_vm_pools() + { + $.post('<%= url_for :controller => "resources", :action => "delete", :id => @pool %>', + { vm_pool_ids: get_selected_vm_pools().toString() }, + function(data,status){ + $("#vmpools_grid").flexReload() + }); + } +</script> <div class="panel_header"></div> <div class="data_section"> diff --git a/wui/src/app/views/permission/new.rhtml b/wui/src/app/views/permission/new.rhtml index f1b99f1..f2b129f 100644 --- a/wui/src/app/views/permission/new.rhtml +++ b/wui/src/app/views/permission/new.rhtml @@ -1,43 +1,35 @@ -<div id="data"> - <div class="inside"> +<div class="dialog_title_small"> + <div class="header">Add New User</div> + <div>Add a new user to <%= @permission.pool.name %> pool.</div> +</div> + +<form method="POST" action="<%= url_for :action => 'create' %>" id="new_permission_form" > +<div class="dialog_form"> + <%= render :partial => 'form' %> +</div> +<div style="background: url(<%= image_path "fb_footer.jpg" %>) repeat-x; height: 37px; text-align:right; padding: 9px 9px 0 0;"> + <div><input type="image" name="submitButton" value="Submit2" src="<%= image_path "btn_addstorage.png"%>" alt="Create User Permission" /> + <a href="#" onclick="jQuery(document).trigger('close.facebox')"><%=image_tag "btn_cancel.png", :title=>"Cancel" %></a> + </div> +</div> +</form> + <script type="text/javascript"> +$(function() { + var permissionoptions = { + target: '<%= url_for :action => 'create' %>', // target element to update + dataType: 'json', + success: afterNewPermission // post-submit callback + }; + + // bind form using 'ajaxForm' + $('#new_permission_form').ajaxForm(permissionoptions); +}); +function afterNewPermission(response, status){ + jQuery(document).trigger('close.facebox'); + $("#users_grid").flexReload() +} +</script> - <div id="dataTableWrapper"> - - <div class="dataTable"> - <div class="inside"> - - <div class="data-table-column"> - <% form_tag :action => 'create' do %> - <%= render :partial => 'form' %> - <%= submit_tag "Add User" %> - <% end %> - </div> - - <div class="data-table-column"> - <h3>Existing Users</h3> - <%= render :partial => "/permission/list", :locals => { :permissions => @perms, :show_object => false, :show_actions => @can_view } %> - </div> - - </div> <!-- end #data-table.inside --> - </div> <!-- end #dataTable --> - - </div> <!-- end #dataTableWrapper --> - - </div> <!-- end #data.inside --> - </div> <!-- end #data --> - - </td> - <td id="right"> - <div class="heading"> </div> - <div class="tools"> - - <h3>Actions</h3> - <div class="actions"> - <%= link_to "Back to #{@permission.pool.name}", { :controller => @permission.pool.get_controller, :action => 'show', :id => @permission.pool_id }, { :class => "show" } %> - </div> - </div> <!-- end #tools --> - - </td> <%- content_for :title do -%> <%= "Edit Permissions for #{@permission.pool.name}" %> <%- end -%> diff --git a/wui/src/app/views/resources/_form.rhtml b/wui/src/app/views/resources/_form.rhtml index 1a09872..0f9fa9f 100644 --- a/wui/src/app/views/resources/_form.rhtml +++ b/wui/src/app/views/resources/_form.rhtml @@ -1,11 +1,7 @@ <%= error_messages_for 'vm_resource_pool' %> <!--[form:vm_resource_pool]--> -<%= hidden_field_tag_with_label ((@parent[:type] == HardwarePool.name) ? - "Hardware Pool" : "Parent VM Resource Pool"), - 'parent_id', @parent.id, @parent.name %> - +<%= hidden_field_tag 'parent_id', @parent.id %> <%= text_field_with_label "Name", 'vm_resource_pool', 'name' %> - <!--[eoform:vm_resource_pool]--> diff --git a/wui/src/app/views/resources/new.rhtml b/wui/src/app/views/resources/new.rhtml index 0dbb165..c142fe7 100644 --- a/wui/src/app/views/resources/new.rhtml +++ b/wui/src/app/views/resources/new.rhtml @@ -1,42 +1,34 @@ - <div id="data"> - <div class="inside"> - - <div id="dataTableWrapper"> - - <div class="dataTable"> - <div class="inside"> - - <div class="data-table-column"> - <% form_tag :action => 'create' do %> - <%= render :partial => 'form' %> - <%= submit_tag "Create" %> - <% end %> - </div> - - <div class="data-table-column"> - <strong class="header">Current VM Resource Pools (<%= @vm_resource_pools.size %>)</strong> - <% for resource in @vm_resource_pools %> - <div class="hardware-item"><%= link_to resource.name, { :controller => "resources", :action => "show", :id => resource }, { } %></div> - <% end %> - </div> - - </div> <!-- end #dataTableWrapper --> - - </div> <!-- end #data.inside --> - </div> <!-- end #data --> - - </td> - <td id="right"> - <div class="heading"> </div> - <div class="tools"> - <h3>Actions</h3> - <div class="actions"> - <div><%= link_to "back to #{@parent.name}", { :controller => @parent.get_controller, :action => 'show', :id => @parent }, { :class => "" } %></div> - </div> - </div> - - </td> - +<div class="dialog_title_small"> + <div class="header">Add New Virtual Machine Pool</div> + <div>Add a new Virtual Machine Pool to the <%= @parent.name %> pool.</div> +</div> + +<form method="POST" action="<%= url_for :action => 'create' %>" id="new_vm_pool_form" > +<div class="dialog_form"> + <%= render :partial => 'form' %> +</div> +<div style="background: url(<%= image_path "fb_footer.jpg" %>) repeat-x; height: 37px; text-align:right; padding: 9px 9px 0 0;"> + <div><input type="image" name="submitButton" value="Submit2" src="<%= image_path "btn_addstorage.png"%>" alt="Create VM Pool" /> + <a href="#" onclick="jQuery(document).trigger('close.facebox')"><%=image_tag "btn_cancel.png", :title=>"Cancel" %></a> + </div> +</div> +</form> + <script type="text/javascript"> +$(function() { + var vmpooloptions = { + target: '<%= url_for :action => 'create' %>', // target element to update + dataType: 'json', + success: afterNewVmPool // post-submit callback + }; + + // bind form using 'ajaxForm' + $('#new_vm_pool_form').ajaxForm(vmpooloptions); +}); +function afterNewVmPool(response, status){ + jQuery(document).trigger('close.facebox'); + $("#vmpools_grid").flexReload() +} +</script> <%- content_for :title do -%> <%= _("New VM Resource Pool") %> diff --git a/wui/src/app/views/resources/show_users.rhtml b/wui/src/app/views/resources/show_users.rhtml index fb2fae9..02a1feb 100644 --- a/wui/src/app/views/resources/show_users.rhtml +++ b/wui/src/app/views/resources/show_users.rhtml @@ -1,31 +1,2 @@ -<div id="toolbar_nav"> -<ul> - <li><a href="dialogs/addhost.html" rel="facebox[.bolder]"><%= image_tag "icon_addhost.png", :style => "vertical-align:middle;" %> Add User</a></li> - <li><%= render :partial => 'user/change_role_menu' %></li> - <li><a href="#"><%= image_tag "icon_delete_white.png", :style => "vertical-align:middle;" %> Remove</a></li> -</ul> -</div> - - <div class="panel_header"></div> -<div class="data_section"> -<table id="users_grid" style="display:none"></table> -</div> -<script type="text/javascript"> - $("#users_grid").flexigrid - ( - { - url: '<%= url_for :action => "users_json", :id => @vm_resource_pool.id %>', - dataType: 'json', - colModel : [ - {display: 'Name', name : 'user', width : 180, sortable : true, align: 'left'}, - {display: 'Role', name : 'user_role', width : 80, sortable : true, align: 'left'} - ], - sortname: "user", - sortorder: "asc", - usepager: true, - useRp: true, - rp: 10, - showTableToggleBtn: true - } - ); -</script> +<%= render :partial => "/user/show", :locals => { :parent_controller => "resources", + :pool_id => @vm_resource_pool.id } %> diff --git a/wui/src/app/views/resources/show_vms.rhtml b/wui/src/app/views/resources/show_vms.rhtml index 98711cf..5f758aa 100644 --- a/wui/src/app/views/resources/show_vms.rhtml +++ b/wui/src/app/views/resources/show_vms.rhtml @@ -5,47 +5,48 @@ <%= image_tag "icon_move.png", :style => "vertical-align:middle;" %> Actions <%= image_tag "icon_toolbar_arrow.gif", :style => "vertical-align:middle;" %> <ul> <% @actions.each_index { |index| %> - <li - <% if index == @actions.length - 1 %> + <li onChange="vm_actions('<%=@actions[index][1]%>')" + <% if (index == @actions.length - 1) or @actions[index].length == 3 %> style="border-bottom: 1px solid black;" <% end %> > - <%= @actions[index] %> + <%=@actions[index][0]%> </li> <% } %> </ul> </li> - <li><a href="#"><%= image_tag "icon_delete_white.png", :style => "vertical-align:middle;" %> Delete</a></li> + <li><a href="#" onClick="delete_vms()"><%= image_tag "icon_delete_white.png", :style => "vertical-align:middle;" %> Delete</a></li> </ul> </div> +<script type="text/javascript"> + function get_selected_vms() + { + var vms_array = new Array() + var vms_index = 0 + for(var i=0; i < document.vms_grid_form.grid_checkbox.length; i++){ + if(document.vms_grid_form.grid_checkbox[i].checked) + { + vms_array[vms_index]= document.vms_grid_form.grid_checkbox[i].value + vms_index++ + } + } + return vms_array + } + function delete_vms() + { + $.post('<%= url_for :controller => "vm", :action => "delete", :id => @pool %>', + { vm_ids: get_selected_vms().toString() }, + function(data,status){ + $("#vms_grid").flexReload() + }); + } +</script> <div class="panel_header"></div> <div class="data_section"> -<table id="vms_grid" style="display:none"></table> + <%= render :partial => "/vm/grid", :locals => { :table_id => "vms_grid", + :pool_id => @vm_resource_pool.id } %> </div> -<script type="text/javascript"> - $("#vms_grid").flexigrid - ( - { - url: '<%= url_for :action => "vms_json", :id => @vm_resource_pool.id %>', - dataType: 'json', - colModel : [ - {display: 'Description', name : 'description', width : 180, sortable : true, align: 'left'}, - {display: 'UUID', name : 'uuid', width : 180, sortable : true, align: 'left'}, - {display: 'CPUs', name : 'num_vcpus_allocated', width : 40, sortable : true, align: 'left'}, - {display: 'Memory (MB)', name : 'memory_allocated', width : 60, sortable : true, align: 'right'}, - {display: 'vNIC Mac Addr', name : 'vnic_mac_addr', width : 60, sortable : true, align: 'right'}, - {display: 'State', name : 'state', width : 50, sortable : true, align: 'right'} - ], - sortname: "description", - sortorder: "asc", - usepager: true, - useRp: true, - rp: 10, - showTableToggleBtn: true - } - ); -</script> <div class="selection_detail"> <div style="font-size: 120%; font-weight:bold; line-height: 1.5;">Host Name</div> <div>Host description goes here if we allow a description.</div> diff --git a/wui/src/app/views/user/_change_role_menu.rhtml b/wui/src/app/views/user/_change_role_menu.rhtml index b33ba00..f35cd3b 100644 --- a/wui/src/app/views/user/_change_role_menu.rhtml +++ b/wui/src/app/views/user/_change_role_menu.rhtml @@ -1,13 +1,12 @@ <%= image_tag "icon_move.png", :style => "vertical-align:middle;" %> Change Role <%= image_tag "icon_toolbar_arrow.gif", :style => "vertical-align:middle;" %> <ul> <% @roles.each_index { |index| %> - <!-- FIXME point me at the right place --> - <li onclick="window.location='<%= url_for :action => 'foobar' %>'" + <li onClick="update_users('<%=@roles[index]%>')" <% if index == @roles.length - 1 %> style="border-bottom: 1px solid black;" <% end %> > - <%= @roles[index] %> + <%=@roles[index]%> </li> <% } %> </ul> diff --git a/wui/src/app/views/user/_grid.rhtml b/wui/src/app/views/user/_grid.rhtml new file mode 100644 index 0000000..24a7b86 --- /dev/null +++ b/wui/src/app/views/user/_grid.rhtml @@ -0,0 +1,30 @@ +<div id="<%= table_id %>_div"> +<form name="<%= table_id %>_form"> +<table id="<%= table_id %>" style="display:none"></table> +</form> +</div> +<script type="text/javascript"> + $("#<%= table_id %>").flexigrid + ( + { + url: '<%= url_for :controller => parent_controller, :action => "users_json", :id => pool_id %>', + dataType: 'json', + colModel : [ + {display: '', name : 'id', width : 20, sortable : false, align: 'left', process: <%= table_id %>checkbox}, + {display: 'Name', name : 'user', width : 180, sortable : true, align: 'left'}, + {display: 'Role', name : 'user_role', width : 80, sortable : true, align: 'left'} + ], + sortname: "user", + sortorder: "asc", + usepager: true, + useRp: true, + rp: 10, + showTableToggleBtn: true + } + ); + function <%= table_id %>checkbox(celDiv) + { + $(celDiv).html('<input type="checkbox" name="grid_checkbox" value="'+$(celDiv).html()+'"/>'); + } + +</script> diff --git a/wui/src/app/views/user/_show.rhtml b/wui/src/app/views/user/_show.rhtml new file mode 100644 index 0000000..348e47b --- /dev/null +++ b/wui/src/app/views/user/_show.rhtml @@ -0,0 +1,46 @@ +<div id="toolbar_nav"> +<ul> + <li><a href="<%= url_for :controller => 'permission', :action => 'new', :pool_id => pool_id %>" rel="facebox[.bolder]"><%= image_tag "icon_addhost.png", :style => "vertical-align:middle;" %> Add User</a></li> + <li><%= render :partial => 'user/change_role_menu' %></li> + <li><a href="#" onClick="delete_users()"><%= image_tag "icon_delete_white.png", :style => "vertical-align:middle;" %> Remove</a></li> +</ul> +</div> +<script type="text/javascript"> + function get_selected_users() + { + var users_array = new Array() + var users_index = 0 + for(var i=0; i < document.users_grid_form.grid_checkbox.length; i++){ + if(document.users_grid_form.grid_checkbox[i].checked) + { + users_array[users_index]= document.users_grid_form.grid_checkbox[i].value + users_index++ + } + } + return users_array + } + function delete_users() + { + $.post('<%= url_for :controller => "permission", :action => "delete", :id => pool_id %>', + { permission_ids: get_selected_users().toString() }, + function(data,status){ + $("#users_grid").flexReload() + }); + } + function update_users(role) + { + $.post('<%= url_for :controller => "permission", :action => "update_roles" %>', + { permission_ids: get_selected_users().toString(), user_role: role }, + function(data,status){ + $("#users_grid").flexReload() + }); + } +</script> + + <div class="panel_header"></div> +<div class="data_section"> + <%= render :partial => "/user/grid", :locals => { :table_id => "users_grid", + :parent_controller => parent_controller, + :pool_id => pool_id } %> +<table id="users_grid" style="display:none"></table> +</div> diff --git a/wui/src/app/views/vm/_grid.rhtml b/wui/src/app/views/vm/_grid.rhtml new file mode 100644 index 0000000..55f9d9b --- /dev/null +++ b/wui/src/app/views/vm/_grid.rhtml @@ -0,0 +1,34 @@ +<div id="<%= table_id %>_div"> +<form name="<%= table_id %>_form"> +<table id="<%= table_id %>" style="display:none"></table> +</form> +</div> +<script type="text/javascript"> + $("#<%= table_id %>").flexigrid + ( + { + url: '<%= url_for :controller => "resources", :action => "vms_json", :id => pool_id %>', + dataType: 'json', + colModel : [ + {display: '', name : 'id', width : 20, sortable : false, align: 'left', process: <%= table_id %>checkbox}, + {display: 'Description', name : 'description', width : 180, sortable : true, align: 'left'}, + {display: 'UUID', name : 'uuid', width : 180, sortable : true, align: 'left'}, + {display: 'CPUs', name : 'num_vcpus_allocated', width : 40, sortable : true, align: 'left'}, + {display: 'Memory (MB)', name : 'memory_allocated', width : 60, sortable : true, align: 'right'}, + {display: 'vNIC Mac Addr', name : 'vnic_mac_addr', width : 60, sortable : true, align: 'right'}, + {display: 'State', name : 'state', width : 50, sortable : true, align: 'right'} + ], + sortname: "description", + sortorder: "asc", + usepager: true, + useRp: true, + rp: 10, + showTableToggleBtn: true + } + ); + function <%= table_id %>checkbox(celDiv) + { + $(celDiv).html('<input type="checkbox" name="grid_checkbox" value="'+$(celDiv).html()+'"/>'); + } + +</script> diff --git a/wui/src/public/stylesheets/components.css b/wui/src/public/stylesheets/components.css index bef30a2..489dd48 100644 --- a/wui/src/public/stylesheets/components.css +++ b/wui/src/public/stylesheets/components.css @@ -111,3 +111,13 @@ text-align: left; cursor: pointer; } +#toolbar_nav ul ul li a{ + width: 200px; + background: #E5F1FD; + color: #000000; + text-align: left; + cursor: pointer; +} +#toolbar_nav ul ul li:hover a { + background: #1E99DF; +} -- 1.5.4.1
Darryl L. Pierce
2008-May-16 12:56 UTC
[Ovirt-devel] [Patch] hook up some more ui components to the new style, including VMs and user permissions
On Thursday 15 May 2008 05:44:22 pm Scott Seago wrote:> Darryl -- you should be able to use this patch as the basis for your > changes to the permissions setting code.ACK I imported the patch and the only change needed to run it in one place in hardware_controller.rb to work for me. I'll release that update with my changes. -- Darryl L. Pierce <dpierce at redhat.com> - Phone: (919) 754-4383 "In matters of style, swim with the current; In matters of principle, stand like a rock." - Thomas Jefferson -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part. URL: <http://listman.redhat.com/archives/ovirt-devel/attachments/20080516/0aaa067d/attachment.sig>