Commit be709b97 authored by o's avatar o

update to api changes

parent 48476883
Pipeline #4129 failed with stages
in 12 seconds
......@@ -336,12 +336,12 @@ module ApiBackend
get ['acl', 'show']
end
def resources()
get ['resource']
def my_resources()
get ['resource', 'mine']
end
def resources_admin(what)
get ['resource', what]
def resource_list(what, deleted=false)
get ['resource', 'list'], {resource_type: what, deleted: deleted}
end
def resource_create(what, owner, data)
......@@ -349,6 +349,10 @@ module ApiBackend
{resource_type: what, owner: owner, data: data})
end
def resource_purge(uid)
post(['resource', 'purge'], {uid: uid})
end
def resource_delete(uid)
post(['resource', 'delete'], {uid: uid})
end
......
......@@ -18,7 +18,8 @@ class ResourcesAdminController < ApplicationController
@resource_name = params['resource_name']
if resource_list.include? @resource_name
begin
@resources = api.resources_admin(@resource_name)['data']
@resources = api.resource_list(@resource_name)['data']
@deleted_resources = api.resource_list(@resource_name, true)['deleted']
rescue ApiBackend::ApiError
flash[:danger] = :failed
redirect_to root_path
......@@ -33,6 +34,8 @@ class ResourcesAdminController < ApplicationController
case params[:commit]
when 'delete'
@res = api.resource_delete(uid)
when 'purge'
@res = api.resource_purge(uid)
when 'create'
@resource_name = params[:resource_name]
if resource_list.include? @resource_name
......
......@@ -3,7 +3,7 @@ class ResourcesController < ApplicationController
def show
begin
res = api.resources
res = api.my_resources
@resources = res['data']
rescue ApiBackend::ApiError
flash[:danger] = :failed
......
......@@ -44,4 +44,19 @@
<hr />
<% end %>
<h3>Deleted:</h3>
<% @deleted_resources.each do |res| %>
<%= form_tag do %>
<%= hidden_field_tag 'uid', res['uid'] %>
<div class="tooltipsummary"><%= res['resource']['email'] %>
<span class="tooltiptext"><%= res['resource'].to_json %></span>
</div>,
<%= res['deleted_at'] %> <br />
<%= submit_tag 'purge' %>
<% end %>
<hr />
<% end %>
<% end %>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment