Skip to content

Commit

Permalink
APTrust reports now show in Dashboard if repo is correctly configured
Browse files Browse the repository at this point in the history
  • Loading branch information
diamondap committed Nov 28, 2023
1 parent 7a6afaa commit f7e8e6f
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 6 deletions.
6 changes: 4 additions & 2 deletions core/aptrust_client_v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,13 @@ func (client *APTrustClientV3) repoBaseUrl() string {
}

var workItemsTemplate = `
<h3>Recent Work Items</h3>
<table class="table table-hover">
<thead class="thead-inverse">
<tr>
<th>Name</th>
<th>Stage</th>
<th>Status</th>
<th>Last Updated</th>
</tr>
</thead>
<tbody>
Expand All @@ -235,19 +235,20 @@ var workItemsTemplate = `
<td><a href="{{ $repoBaseUrl }}/work_items/show/{{ $item.ID }}" target="_blank">{{ $item.Name }}</a></td>
<td>{{ $item.Stage }}</td>
<td>{{ $item.Status }}</td>
<td>{{ $item.UpdatedAt.Format "2006-01-02" }}</td>
</tr>
{{ end }}
</tbody>
</table>
`

var intellectualObjectsTemplate = `
<h3>Recently Ingested Objects</h3>
<table class="table table-hover">
<thead class="thead-inverse">
<tr>
<th>Identifier</th>
<th>Storage Option</th>
<th>Last Updated</th>
</tr>
</thead>
<tbody>
Expand All @@ -256,6 +257,7 @@ var intellectualObjectsTemplate = `
<tr>
<td><a href="{{ $repoBaseUrl }}/objects/show/{{ $item.ID }}" target="_blank">{{ $item.Identifier }}</a></td>
<td>{{ $item.StorageOption }}</td>
<td>{{ $item.UpdatedAt.Format "2006-01-02" }}</td>
</tr>
{{ end }}
</tbody>
Expand Down
12 changes: 10 additions & 2 deletions core/aptrust_client_v3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,13 +397,13 @@ var objectResponseJson = `
}`

var expectedWorkItemHTML = `
<h3>Recent Work Items</h3>
<table class="table table-hover">
<thead class="thead-inverse">
<tr>
<th>Name</th>
<th>Stage</th>
<th>Status</th>
<th>Last Updated</th>
</tr>
</thead>
<tbody>
Expand All @@ -413,36 +413,40 @@ var expectedWorkItemHTML = `
<td><a href="http://127.0.0.1/work_items/show/933127" target="_blank">KNOX_007565.tar</a></td>
<td>Cleanup</td>
<td>Success</td>
<td>2023-11-21</td>
</tr>
<tr>
<td><a href="http://127.0.0.1/work_items/show/933126" target="_blank">KNOX_007564.tar</a></td>
<td>Cleanup</td>
<td>Success</td>
<td>2023-11-21</td>
</tr>
<tr>
<td><a href="http://127.0.0.1/work_items/show/933125" target="_blank">KNOX_007563.tar</a></td>
<td>Cleanup</td>
<td>Success</td>
<td>2023-11-21</td>
</tr>
<tr>
<td><a href="http://127.0.0.1/work_items/show/933124" target="_blank">KNOX_007562.tar</a></td>
<td>Cleanup</td>
<td>Success</td>
<td>2023-11-21</td>
</tr>
</tbody>
</table>
`
var expectedObjectListHTML = `
<h3>Recently Ingested Objects</h3>
<table class="table table-hover">
<thead class="thead-inverse">
<tr>
<th>Identifier</th>
<th>Storage Option</th>
<th>Last Updated</th>
</tr>
</thead>
<tbody>
Expand All @@ -451,21 +455,25 @@ var expectedObjectListHTML = `
<tr>
<td><a href="http://127.0.0.1/objects/show/271255" target="_blank">knox.edu/KNOX_000089</a></td>
<td>Glacier-Deep-OH</td>
<td>2023-11-21</td>
</tr>
<tr>
<td><a href="http://127.0.0.1/objects/show/271254" target="_blank">knox.edu/KNOX_000088</a></td>
<td>Glacier-Deep-OH</td>
<td>2023-11-21</td>
</tr>
<tr>
<td><a href="http://127.0.0.1/objects/show/271253" target="_blank">knox.edu/KNOX_000080</a></td>
<td>Glacier-Deep-OH</td>
<td>2023-11-21</td>
</tr>
<tr>
<td><a href="http://127.0.0.1/objects/show/271252" target="_blank">knox.edu/KNOX_000087</a></td>
<td>Glacier-Deep-OH</td>
<td>2023-11-21</td>
</tr>
</tbody>
Expand Down
33 changes: 31 additions & 2 deletions server/views/dashboard/show.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{{ template "partials/page_header.html" .}}


<div class="row mb-3">
<div class="row mb-5">
<div class="col-md-12">
<div class="card">
<div class="card-header">Recent Jobs</div>
Expand Down Expand Up @@ -38,8 +38,37 @@

<script>
$(function(){
var reports = {{ .reportListJson }}
var reports = JSON.parse({{ .reportListJson }})

function runReport(report) {
let url = `/dashboard/report?RemoteRepoID=${encodeURIComponent(report.repositoryId)}&ReportName=${encodeURIComponent(report.reportName)}`
$.ajax({
url: url,
type: "get",
}).done(function (response) {
let displayName = `${report.reportName} from ${report.repositoryName}`
showReport(displayName, response.html)
}).fail(function (xhr, status, err) {
console.error(`URL: ${url}\nRepository: ${report.repositoryName}\nReport: ${report.reportName}\nResponse: ${xhr.responseText}`)
})
}

function showReport(displayName, html) {
let newReportDiv = `
<div class="row mb-5">
<div class="col-md-12">
<div class="card">
<div class="card-header">${displayName}</div>
<div class="card-body dashboard-card-body" id="cardRecentJobs">
${html}
</div>
</div>
</div>
</div>`
$('#reportsContainer').append(newReportDiv)
}

reports.forEach((report) => runReport(report))
})
</script>

Expand Down

0 comments on commit f7e8e6f

Please sign in to comment.