Skip to content

Commit 2660973

Browse files
authored
Merge pull request #1170 from NASA-IMPACT/3000-add-curated-urls-column-to-homepage
Add Curated URLs column to homepage
2 parents b507e37 + 5ac8432 commit 2660973

File tree

3 files changed

+75
-9
lines changed

3 files changed

+75
-9
lines changed

sde_collections/views.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ def get_queryset(self):
7171
super()
7272
.get_queryset()
7373
.filter(delete=False)
74-
.annotate(num_delta_urls=models.Count("delta_urls"))
74+
.annotate(
75+
num_delta_urls=models.Count("delta_urls", distinct=True),
76+
num_curated_urls=models.Count("curated_urls", distinct=True),
77+
)
7578
.order_by("-num_delta_urls")
7679
)
7780

sde_indexing_helper/static/js/collection_list.js

Lines changed: 59 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ const COLUMNS = {
44
URL: 1,
55
DIVISION: 2,
66
DELTA_URLS: 3,
7-
WORKFLOW_STATUS: 4,
8-
CURATOR: 5,
9-
CONNECTOR_TYPE: 6,
10-
REINDEXING_STATUS: 7,
11-
WORKFLOW_STATUS_RAW: 8,
12-
CURATOR_ID: 9,
13-
REINDEXING_STATUS_RAW: 10
7+
CURATED_URLS: 4,
8+
WORKFLOW_STATUS: 5,
9+
CURATOR: 6,
10+
CONNECTOR_TYPE: 7,
11+
REINDEXING_STATUS: 8,
12+
WORKFLOW_STATUS_RAW: 9,
13+
CURATOR_ID: 10,
14+
REINDEXING_STATUS_RAW: 11
1415
};
1516

1617
var uniqueId; //used for logic related to contents on column customization modal
@@ -178,6 +179,56 @@ let table = $("#collection_table").DataTable({
178179
targets: [COLUMNS.DELTA_URLS],
179180
type: "num-fmt",
180181
},
182+
{
183+
searchPanes: {
184+
options: [
185+
{
186+
label: "0 URLs",
187+
value: function (rowData, rowIdx) {
188+
return $(rowData[COLUMNS.CURATED_URLS]).text() == 0;
189+
},
190+
},
191+
{
192+
label: "1 solo URL",
193+
value: function (rowData, rowIdx) {
194+
return $(rowData[COLUMNS.CURATED_URLS]).text() == 1;
195+
},
196+
},
197+
{
198+
label: "1 to 100 URLs",
199+
value: function (rowData, rowIdx) {
200+
return $(rowData[COLUMNS.CURATED_URLS]).text() <= 100 && $(rowData[COLUMNS.CURATED_URLS]).text() > 1;
201+
},
202+
},
203+
{
204+
label: "100 to 1,000 URLs",
205+
value: function (rowData, rowIdx) {
206+
return $(rowData[COLUMNS.CURATED_URLS]).text() <= 1000 && $(rowData[COLUMNS.CURATED_URLS]).text() > 100;
207+
},
208+
},
209+
{
210+
label: "1,000 to 10,000 URLs",
211+
value: function (rowData, rowIdx) {
212+
return $(rowData[COLUMNS.CURATED_URLS]).text() <= 10000 && $(rowData[COLUMNS.CURATED_URLS]).text() > 1000;
213+
},
214+
},
215+
{
216+
label: "10,000 to 100,000 URLs",
217+
value: function (rowData, rowIdx) {
218+
return $(rowData[COLUMNS.CURATED_URLS]).text() <= 100000 && $(rowData[COLUMNS.CURATED_URLS]).text() > 10000;
219+
},
220+
},
221+
{
222+
label: "Over 100,000 URLs",
223+
value: function (rowData, rowIdx) {
224+
return $(rowData[COLUMNS.CURATED_URLS]).text() > 100000;
225+
},
226+
},
227+
],
228+
},
229+
targets: [COLUMNS.CURATED_URLS],
230+
type: "num-fmt",
231+
},
181232
// hide the data panes
182233
{
183234
searchPanes: {
@@ -442,6 +493,7 @@ $(document).ready(function () {
442493
null,
443494
"Division",
444495
"Delta URLs",
496+
"Curated URLs",
445497
"Workflow Status",
446498
"Curator",
447499
"Connector Type",

sde_indexing_helper/templates/sde_collections/collection_list.html

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ <h2 class="title">Welcome back!</h2>
2424
<th class="text-center noBorder url-th" style="padding-right:25px !important">Url</th>
2525
<th class="text-center noBorder" style="padding-right:25px !important">Division</th>
2626
<th class="text-center noBorder" style="padding-right:25px !important">Delta Urls</th>
27+
<th class="text-center noBorder" style="padding-right:25px !important">Curated Urls</th>
2728
<th class="text-center noBorder" style="padding-right:25px !important">Workflow Status</th>
2829
<th class="text-center noBorder" style="padding-right:25px !important">Curator</th>
2930
<th class="text-center noBorder" style="padding-right:25px !important">Connector Type</th>
@@ -64,6 +65,9 @@ <h2 class="title">Welcome back!</h2>
6465
<!-- Empty cell for Delta Urls (no filter) -->
6566
<td class="filterRowBottom"></td>
6667

68+
<!-- Empty cell for Curated Urls (no filter) -->
69+
<td class="filterRowBottom"></td>
70+
6771
<!-- Dropdown filter for Workflow Status -->
6872
<td class="filterRowBottom">
6973
<select id="collection-dropdown-4" class="select-dropdown selectStyling">
@@ -146,13 +150,20 @@ <h2 class="title">Welcome back!</h2>
146150
<!-- Division Column -->
147151
<td class="whiteText noBorder">{{ collection.get_division_display }}</td>
148152

149-
<!-- Delta URLs Column - Shows count and links if > 0 -->
153+
<!-- Delta URLs Column - Shows count and links if >= 0 -->
150154
<td class="noBorder centerAlign">
151155
<a href=" {% if collection.num_delta_urls >= 0 %} {% url 'sde_collections:delta_urls' collection.pk %} {% endif %} "
152156
class="btn btn-sm {% if collection.num_delta_urls >= 0 %}btn-primary {% else %}disabled{% endif %}candidateCount"
153157
role="button">{{ collection.num_delta_urls|intcomma }}</a>
154158
</td>
155159

160+
<!-- Curated URLs Column - Shows count and links if >= 0 -->
161+
<td class="noBorder centerAlign">
162+
<a href=" {% if collection.num_curated_urls >= 0 %} {% url 'sde_collections:delta_urls' collection.pk %} {% endif %} "
163+
class="btn btn-sm {% if collection.num_curated_urls >= 0 %}btn-primary {% else %}disabled{% endif %}candidateCount"
164+
role="button">{{ collection.num_curated_urls|intcomma }}</a>
165+
</td>
166+
156167
<!-- Workflow Status Dropdown -->
157168
<td class="noBorder">
158169
<div class="dropdown workflow_status_dropdown"

0 commit comments

Comments
 (0)