Skip to content

Commit

Permalink
Refine store admin screens
Browse files Browse the repository at this point in the history
  • Loading branch information
terrywbrady committed Sep 15, 2021
1 parent 9d88e6a commit 0ea5c3d
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src-admintool/lambda_function.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def self.process(event:,context:)
config = Uc3Ssm::ConfigResolver.new.resolve_file_values(file: config_file, resolve_key: config_block, return_key: config_block)
collHandler = Handler.new(config)
respath = event.fetch("path", "")
return collHandler.redirect("/web#{respath}") if respath =~ %r[^/index.html.*]
return LambdaBase.redirect("/web#{respath}") if respath =~ %r[^/index.html.*]
myparams = collHandler.get_params_from_event(event)
return collHandler.web_assets("/web/favicon.ico", myparams) if respath =~ %r[^/favicon.ico.*]
return collHandler.web_assets(respath, myparams) if collHandler.web_asset?(respath)
Expand Down
29 changes: 29 additions & 0 deletions src-colladmin/lambda_function.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,34 @@ def self.process(event:,context:)
result = CognitoAction.new(config, path, myparams).get_data
elsif path == "cognito-add-user-to-group"
result = CognitoAction.new(config, path, myparams).get_data
elsif path == "unpause-ingest-for-collection"
result = LambdaBase.jsredirect("https://cdluc3.github.io/mrt-doc/diagrams/store-admin-pause-ing-for-coll")
elsif path == "pause-ingest-for-collection"
result = LambdaBase.jsredirect("https://cdluc3.github.io/mrt-doc/diagrams/store-admin-pause-ing-for-coll")
elsif path == "storage-force-audit-for-object"
result = LambdaBase.jsredirect("https://cdluc3.github.io/mrt-doc/diagrams/store-admin-force-audit")
elsif path == "storage-force-audit-for-collection"
result = LambdaBase.jsredirect("https://cdluc3.github.io/mrt-doc/diagrams/store-admin-force-audit")
elsif path == "storage-force-replic-for-object"
result = LambdaBase.jsredirect("https://cdluc3.github.io/mrt-doc/diagrams/store-admin-force-replic")
elsif path == "storage-force-replic-for-collection"
result = LambdaBase.jsredirect("https://cdluc3.github.io/mrt-doc/diagrams/store-admin-force-replic")
elsif path == "storage-add-node-for-collection"
result = LambdaBase.jsredirect("https://cdluc3.github.io/mrt-doc/diagrams/store-admin-add-node")
elsif path == "storage-del-node-for-collection"
result = LambdaBase.jsredirect("https://cdluc3.github.io/mrt-doc/diagrams/store-admin-del-node")
elsif path == "storage-del-node-for-object"
result = LambdaBase.jsredirect("https://cdluc3.github.io/mrt-doc/diagrams/store-admin-del-node-obj")
elsif path == "storage-change-primary-for-collection"
result = LambdaBase.jsredirect("https://cdluc3.github.io/mrt-doc/diagrams/store-admin-change-primary-node")
elsif path == "storage-reroute-ui-for-collection"
result = LambdaBase.jsredirect("https://cdluc3.github.io/mrt-doc/diagrams/store-admin-reroute-ui")
elsif path == "storage-scan-node"
result = LambdaBase.jsredirect("https://cdluc3.github.io/mrt-doc/diagrams/store-admin-scan-node")
elsif path == "storage-delete-node-key"
result = LambdaBase.jsredirect("https://cdluc3.github.io/mrt-doc/diagrams/store-admin-del-node-keys")
elsif path == "storage-delete-node-obj"
result = LambdaBase.jsredirect("https://cdluc3.github.io/mrt-doc/diagrams/store-admin-del-node-keys")
end

{
Expand Down Expand Up @@ -219,6 +247,7 @@ def template_parameters(path, myparams)
elsif path == '/web/storeObjects.html'
objlist = CGI.unescape(myparams.fetch("objlist",""))
mode = myparams.fetch("mode","")
map['OWNERS'] = Owners.new(@config).objs_select
map['OBJLIST'] = objlist
map['ISARK'] = mode == "ark"
map['ISLOC'] = mode == "localid"
Expand Down
39 changes: 26 additions & 13 deletions src-colladmin/lib/storage_nodes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def initialize(config, collid, primary_id)
inio.role,
n.number,
n.description,
n.access_mode,
count(*)
from
inv_collections c
Expand All @@ -32,12 +33,14 @@ def initialize(config, collid, primary_id)
group by
inio.role,
n.number,
n.description
n.description,
n.access_mode
union
select
'primary' as role,
n.number,
n.description as description,
n.access_mode,
0
from
inv_collections c,
Expand Down Expand Up @@ -67,6 +70,7 @@ def initialize(config, collid, primary_id)
'secondary' as role,
n.number,
n.description,
n.access_mode,
0
from
inv_collections c
Expand Down Expand Up @@ -103,13 +107,14 @@ def initialize(config, collid, primary_id)
).each_with_index do |r, i|
percent = 100
if i > 0
percent = ((r[3] * 100.0)/@collnodes[0][:count]).to_i if @collnodes[0][:count] > 0
percent = ((r[4] * 100.0)/@collnodes[0][:count]).to_i if @collnodes[0][:count] > 0
end
@collnodes.push({
role: r[0],
number: r[1],
name: r[2],
count: r[3],
access_mode: r[3],
count: r[4],
percent: percent
})
end
Expand All @@ -132,7 +137,8 @@ def initialize(config)
when description is null then 'No description'
else description
end as description,
count(*) as pcount
access_mode,
count(inio.inv_object_id) as pcount
from
inv_nodes n
left join inv_nodes_inv_objects inio
Expand All @@ -146,7 +152,8 @@ def initialize(config)
).each do |r|
@nodes.push({
number: r[0],
description: "#{r[1]} (#{r[2]})"
description: "#{r[1]} (#{r[3]})",
access_mode: r[2]
})
end
end
Expand Down Expand Up @@ -191,14 +198,17 @@ def normalize(s)
def get_sql
%{
select
c.name,
c.name as coll,
own.name as owner,
o.id,
o.ark,
loc.local_id,
o.erc_what,
o.created
from
inv_objects o
inner join inv_owners own
on o.inv_owner_id = own.id
inner join inv_collections_inv_objects icio
on icio.inv_object_id = o.id
inner join inv_collections c
Expand All @@ -225,11 +235,12 @@ def search
).each do |r|
objects.push({
coll: r[0],
id: r[1],
ark: r[2],
localid: r[3],
title: r[4],
created: r[5]
owner: r[1],
id: r[2],
ark: r[3],
localid: r[4],
title: r[5],
created: r[6]
})
end
objects
Expand Down Expand Up @@ -300,7 +311,8 @@ def initialize(config, ark)
select
inio.role,
n.number,
n.description
n.description,
n.access_mode
from
inv_objects o
inner join inv_nodes_inv_objects inio
Expand All @@ -318,7 +330,8 @@ def initialize(config, ark)
@nodes.push({
role: r[0],
number: r[1],
name: r[2]
name: r[2],
access_mode: r[3]
})
end
end
Expand Down
4 changes: 3 additions & 1 deletion src-colladmin/web/storeCollNodes.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ <h2>Storage Nodes for Collection</h2>
<thead>
<tr>
<th>Role</th>
<th>Number</th>
<th>Node Num</th>
<th>Node Name</th>
<th>Access Mode</th>
<th>Count</th>
<th>% Repl</th>
<th>Actions</th>
Expand All @@ -84,6 +85,7 @@ <h2>Storage Nodes for Collection</h2>
<th>{{role}}</th>
<th>{{number}}</th>
<td>{{name}}</td>
<td>{{access_mode}}</td>
<td>{{count}}</td>
<td>{{percent}}</td>
<td>
Expand Down
8 changes: 6 additions & 2 deletions src-colladmin/web/storeNodes.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ <h1>Manage Storage Nodes</h1>
<thead>
<tr>
<th>Node Number</th>
<th>Node Description</th>
<th>Node Name</th>
<th>Access Mode</th>
<th>Last Scan</th>
<th>% Complete</th>
<th>Num Deletes</th>
<th>Num Untracked</th>
<th>Num to Delete</th>
<th>Actions</th>
</tr>
</thead>
Expand All @@ -32,6 +34,8 @@ <h1>Manage Storage Nodes</h1>
<tr>
<th>{{number}}</th>
<td>{{description}}</td>
<td>{{access_mode}}</td>
<td></td>
<td></td>
<td></td>
<td></td>
Expand Down
2 changes: 2 additions & 0 deletions src-colladmin/web/storeObjectNodes.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ <h1>Manage Object Storage Nodes for {{ARK}}</h1>
<th>Role</th>
<th>Node Num</th>
<th>Node Name</th>
<th>Access Mode</th>
<th>Actions</th>
</tr>
</thead>
Expand All @@ -30,6 +31,7 @@ <h1>Manage Object Storage Nodes for {{ARK}}</h1>
<th>{{role}}</th>
<td>{{number}}</td>
<td>{{name}}</td>
<td>{{access_mode}}</td>
<td>
<button title=""
onclick="javascript:document.location='https://cdluc3.github.io/mrt-doc/diagrams/store-admin-del-node-keys'"
Expand Down
31 changes: 21 additions & 10 deletions src-colladmin/web/storeObjects.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,25 @@ <h2>Locate Objects</h2>
<form method="POST">
<div>
<select name="mode">
<option value="ark" selected={{ISARK}}>Search by ark</option>
<option value="localid" selected={{ISLOC}}>Search by localid</option>
<option value="id" selected={{ISID}}>Search by object_id</option>
<option value="ark" {{#ISARK}}selected{{/ISARK}}>Search by ark</option>
<option value="localid" {{#ISLOC}}selected{{/ISLOC}}>Search by localid</option>
<option value="id" {{#ISID}}selected{{/ISID}}>Search by object_id</option>
</select>
</div>
<p class="proval">
<label for="owner">Owner</label>
<select id="owner" name="owner">
<option value="">--ANY Owner--</option>
{{#OWNERS}}
<option value="{{ark}}">{{name}}</option>
{{/OWNERS}}
</select>
</p>
<div>
<label for="object list">Object(s). Place one or more identifiers on each line below.</label>
</div>
<div>
<textarea id="objlist" name="objlist" rows="5" cols="40">{{OBJLIST}}</textarea>
<fieldset>
<legend>Object(s). Place one or more identifiers on each line below.</legend>
<textarea id="objlist" name="objlist" rows="5" cols="40">{{OBJLIST}}</textarea>
</fieldset>
</div>
<div>
<input type="submit" value="Search"/>
Expand All @@ -40,9 +49,10 @@ <h2>Objects</h2>
<table class="sortable results">
<thead>
<tr>
<th>Ark</th>
<th>Collection</th>
<th>Owner</th>
<th>Object Id</th>
<th>Ark</th>
<th>Local Id</th>
<th>Title</th>
<th>Created</th>
Expand All @@ -52,9 +62,10 @@ <h2>Objects</h2>
<tbody>
{{#OBJS}}
<tr>
<th>{{coll}}</th>
<th>{{ark}}</th>
<td>{{coll}}</td>
<td>{{owner}}</td>
<td>{{id}}</td>
<td>{{ark}}</td>
<td>{{localid}}</td>
<td>{{title}}</td>
<td>{{created}}</td>
Expand Down
12 changes: 11 additions & 1 deletion src-common/lambda_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def web_assets(path, myparams)
}
end

def redirect(path)
def self.redirect(path)
{
statusCode: 303,
headers: {
Expand All @@ -154,6 +154,16 @@ def redirect(path)
}
end

def self.jsredirect(path)
{
statusCode: 200,
headers: {
'Content-Type' => 'application/json'
},
body: {location: path}
}
end

def self.error(status, message, return_page = false)
if status != 200 && return_page
{
Expand Down

0 comments on commit 0ea5c3d

Please sign in to comment.