Skip to content

Commit 3a8946e

Browse files
authored
Merge pull request #47 from clowder-framework/expose-extractor-catalog
Expose extractor list to authenticated users
2 parents 8cc9afa + d083cf8 commit 3a8946e

File tree

6 files changed

+73
-64
lines changed

6 files changed

+73
-64
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1212

1313
### Changed
1414
- Improved simple test to report all day success.
15+
- Expose a read-only list of extractors to all users.
1516

1617
## 1.10.1 - 2020-07-16
1718

app/controllers/Extractors.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class Extractors @Inject() (extractions: ExtractionService,
7171

7272

7373

74-
def showExtractorInfo(extractorName: String) = ServerAdminAction { implicit request =>
74+
def showExtractorInfo(extractorName: String) = AuthenticatedAction { implicit request =>
7575
implicit val user = request.user
7676
val targetExtractor = extractorService.listExtractorsInfo(List.empty).find(p => p.name == extractorName)
7777
targetExtractor match {

app/views/extractorDetails.scala.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@(extractor: ExtractorInfo)(implicit user: Option[models.User])
2+
@import api.Permission
23

34
@main("Extractor Details") {
45
<script src="@routes.Assets.at("javascripts/deleteUtils.js")" type="text/javascript"></script>
@@ -178,7 +179,7 @@
178179
<div class="col-sm-12">
179180
<!-- "Back" button -->
180181
<a class="btn btn-default" onclick="window.history.back()"><span class="glyphicon glyphicon-chevron-left" ></span> Back</a>
181-
<a class="btn btn-danger" onclick="confirmDeleteResource('extractor','extractor','@(extractor.name)','@(extractor.name.replace("'","&#39;"))', true, '@(routes.Extractors.selectExtractors())')">Delete</a>
182+
@if(Permission.checkServerAdmin(user)) {<a class="btn btn-danger" onclick="confirmDeleteResource('extractor','extractor','@(extractor.name)','@(extractor.name.replace("'","&#39;"))', true, '@(routes.Extractors.selectExtractors())')">Delete</a>}
182183
</div>
183184
</div>
184185
</div>

app/views/main.scala.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@
110110
}
111111
<li><a href="@routes.Datasets.list(showOnlyShared = play.Play.application().configuration().getBoolean("showOnlySharedInExplore"))"><span class="glyphicon glyphicon-briefcase"> </span> @Messages("datasets.title")</a></li>
112112
<li><a href="@routes.Collections.list(showOnlyShared = play.Play.application().configuration().getBoolean("showOnlySharedInExplore"))"><span class="glyphicon glyphicon-th-large"> </span> @Messages("collections.title")</a></li>
113+
<li><a href="@routes.Extractors.selectExtractors()"><span class="glyphicon glyphicon-th-large"> </span> @Messages("extractors.title")</a></li>
113114
@if(play.api.Play.current.plugin[services.StagingAreaPlugin].isDefined){
114115
<li><a href="@routes.CurationObjects.getPublishedData("")"><span class="glyphicon glyphicon-book"></span> Published Data</a></li>
115116
}

app/views/updateExtractors.scala.html

Lines changed: 66 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
@(runningExtractors: List[ExtractorInfo], selectedExtractors: List[String])(implicit user: Option[models.User])
22
@import _root_.util.Formatters._
33
@import helper._
4+
@import api.Permission
45

56
@main("Extractors") {
67
@if(runningExtractors.size == 0) {
@@ -13,74 +14,77 @@ <h1>Extractors</h1>
1314
</div>
1415
<div class="row">
1516
<div class="col-xs-12">
16-
<p>List of all extractors currently registered with the system. By enabling/disabling them the extractor will automatically
17+
<p>List of all extractors currently registered with the system. If enabled, the extractor will automatically
1718
execute on a resource when the process trigger is matched.</p>
1819
</div>
1920
</div>
2021
<div class="row top-padding">
2122
<div class="col-xs-12">
22-
@form(action = routes.Extractors.updateExtractors(), 'id -> "formOne", 'enctype -> "multipart/form-data", 'class -> "form-horizontal") {
23-
<table class="table">
24-
<thead>
25-
<tr>
26-
<th>Enabled</th>
27-
<th>Name</th>
28-
<th>Description</th>
29-
<th>Process Triggers</th>
30-
</tr>
31-
</thead>
32-
<tbody>
33-
<!-- Display all running extractors. If extractor already in this space, check the box. -->
34-
@runningExtractors.map { extractor =>
35-
<tr>
36-
<td><input type="checkbox" name="extractors" value="@extractor.name"
37-
@if(selectedExtractors.contains(extractor.name)) {checked} else {unchecked}></td>
38-
<td><a href="@routes.Extractors.showExtractorInfo(extractor.name)">@extractor.name</a></td>
39-
<td>@extractor.description</td>
40-
<td>
41-
<!-- TODO: Hide full text behind a modal? Possible to show truncated preview here? -->
42-
<p @if(extractor.process.dataset.isEmpty) {hidden}>
43-
Datasets:
44-
<span @if(extractor.process.dataset.length > 1) {hidden}>@extractor.process.dataset</span>
45-
<ul @if(extractor.process.dataset.length == 1) {hidden}>
46-
@extractor.process.dataset.map { eventName =>
47-
<li>@eventName</li>
48-
}
49-
</ul>
50-
</p>
51-
<p @if(extractor.process.file.isEmpty) {hidden}>
52-
Files:
53-
<span @if(extractor.process.file.length > 1) {hidden}>@extractor.process.file</span>
54-
<ul @if(extractor.process.file.length == 1) {hidden}>
55-
@extractor.process.file.map { fileType =>
56-
<li>@fileType</li>
57-
}
58-
</ul>
59-
</p>
60-
<p @if(extractor.process.metadata.isEmpty) {hidden}>
61-
Metadata:
62-
<span @if(extractor.process.metadata.length > 1) {hidden}>@extractor.process.metadata</span>
63-
<ul @if(extractor.process.metadata.length == 1) {hidden}>
64-
@extractor.process.metadata.map { eventName =>
65-
<li>@eventName</li>
66-
}
67-
</ul>
68-
</p>
69-
<p @if(!extractor.process.metadata.isEmpty
70-
|| !extractor.process.file.isEmpty
71-
|| !extractor.process.dataset.isEmpty) {hidden}>
72-
None
73-
</p>
74-
</td>
75-
</tr>
23+
@form(action = routes.Extractors.updateExtractors(), 'id -> "formOne", 'enctype -> "multipart/form-data", 'class -> "form-horizontal") {
24+
<table class="table">
25+
<thead>
26+
<tr>
27+
<th>Enabled</th>
28+
<th>Name</th>
29+
<th>Description</th>
30+
<th>Process Triggers</th>
31+
</tr>
32+
</thead>
33+
<tbody>
34+
<!-- Display all running extractors. If extractor already in this space, check the box. -->
35+
@runningExtractors.map { extractor =>
36+
<tr>
37+
<td><input type="checkbox" name="extractors" value="@extractor.name"
38+
@if(!Permission.checkServerAdmin(user)) {disabled="true"}
39+
@if(selectedExtractors.contains(extractor.name)) {checked} else {unchecked}></td>
40+
<td><a href="@routes.Extractors.showExtractorInfo(extractor.name)">@extractor.name</a></td>
41+
<td>@extractor.description</td>
42+
<td>
43+
<!-- TODO: Hide full text behind a modal? Possible to show truncated preview here? -->
44+
<p @if(extractor.process.dataset.isEmpty) {hidden}>
45+
Datasets:
46+
<span @if(extractor.process.dataset.length > 1) {hidden}>@extractor.process.dataset</span>
47+
<ul @if(extractor.process.dataset.length == 1) {hidden}>
48+
@extractor.process.dataset.map { eventName =>
49+
<li>@eventName</li>
50+
}
51+
</ul>
52+
</p>
53+
<p @if(extractor.process.file.isEmpty) {hidden}>
54+
Files:
55+
<span @if(extractor.process.file.length > 1) {hidden}>@extractor.process.file</span>
56+
<ul @if(extractor.process.file.length == 1) {hidden}>
57+
@extractor.process.file.map { fileType =>
58+
<li>@fileType</li>
59+
}
60+
</ul>
61+
</p>
62+
<p @if(extractor.process.metadata.isEmpty) {hidden}>
63+
Metadata:
64+
<span @if(extractor.process.metadata.length > 1) {hidden}>@extractor.process.metadata</span>
65+
<ul @if(extractor.process.metadata.length == 1) {hidden}>
66+
@extractor.process.metadata.map { eventName =>
67+
<li>@eventName</li>
68+
}
69+
</ul>
70+
</p>
71+
<p @if(!extractor.process.metadata.isEmpty
72+
|| !extractor.process.file.isEmpty
73+
|| !extractor.process.dataset.isEmpty) {hidden}>
74+
None
75+
</p>
76+
</td>
77+
</tr>
78+
}
79+
</tbody>
80+
</table>
81+
@if(Permission.checkServerAdmin(user)){
82+
<div class="form-actions">
83+
<button type="submit" class="btn btn-primary" name = "submitValue" value="Update"><span class='glyphicon glyphicon-send'></span> Update</button>
84+
<a class="btn btn-default" id="cancel_space"><span class="glyphicon glyphicon-remove" ></span> Cancel</a>
85+
</div>
7686
}
77-
</tbody>
78-
</table>
79-
<div class="form-actions">
80-
<button type="submit" class="btn btn-primary" name = "submitValue" value="Update"><span class='glyphicon glyphicon-send'></span> Update</button>
81-
<a class="btn btn-default" id="cancel_space"><span class="glyphicon glyphicon-remove" ></span> Cancel</a>
82-
</div>
83-
} <!-- end of form -->
87+
} <!-- end of form -->
8488
</div>
8589
</div>
8690
}

conf/messages

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ datasets.title=Datasets
2222
datasets.trashtitle=Datasets in Trash
2323
dataset.title=Dataset
2424
dataset.description=Description
25+
extractors.title=Extractors
26+
extractors.description=Description
2527
publicationrequest.description=Abstract
2628
collections.title=Collections
2729
collections.trashtitle=Collections in Trash

0 commit comments

Comments
 (0)