Skip to content

Commit 952da55

Browse files
committed
add links on summary-grid count cells
1 parent ab46042 commit 952da55

6 files changed

Lines changed: 90 additions & 0 deletions

File tree

resources/queries/targetedms/InstrumentUtilizationByDay.query.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010
</column>
1111
<column columnName="RunCount">
1212
<columnTitle>Skyline Document Count</columnTitle>
13+
<url>/targetedms-showInstrument.view?name=${InstrumentNickname}&amp;utilizationTab=samples&amp;SampleFile.AcquiredTime~dateeq=${AcquisitionDate:date('yyyy-MM-dd')}</url>
1314
</column>
1415
<column columnName="FileCount">
1516
<columnTitle>Replicate Count</columnTitle>
17+
<url>/targetedms-showInstrument.view?name=${InstrumentNickname}&amp;utilizationTab=samples&amp;SampleFile.AcquiredTime~dateeq=${AcquisitionDate:date('yyyy-MM-dd')}</url>
1618
</column>
1719
<column columnName="InstrumentNickname">
1820
<columnTitle>Instrument</columnTitle>

resources/queries/targetedms/InstrumentUtilizationByMonth.query.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010
</column>
1111
<column columnName="RunCount">
1212
<columnTitle>Skyline Document Count</columnTitle>
13+
<url>/targetedms-showInstrument.view?name=${InstrumentNickname}&amp;utilizationTab=samples&amp;SampleFile.AcquiredTime~dategte=${MonthStart:date('yyyy-MM-dd')}&amp;SampleFile.AcquiredTime~datelt=${MonthEnd:date('yyyy-MM-dd')}</url>
1314
</column>
1415
<column columnName="FileCount">
1516
<columnTitle>Replicate Count</columnTitle>
17+
<url>/targetedms-showInstrument.view?name=${InstrumentNickname}&amp;utilizationTab=samples&amp;SampleFile.AcquiredTime~dategte=${MonthStart:date('yyyy-MM-dd')}&amp;SampleFile.AcquiredTime~datelt=${MonthEnd:date('yyyy-MM-dd')}</url>
1618
</column>
1719
<column columnName="InstrumentNickname">
1820
<columnTitle>Instrument</columnTitle>

resources/queries/targetedms/InstrumentUtilizationByMonth.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
-- Consumed by the "Runs by Month" grid on the Show Instrument page.
99
SELECT
1010
CAST(MonthStart || '-01' AS TIMESTAMP) AS MonthStart,
11+
TIMESTAMPADD('SQL_TSI_MONTH', 1, CAST(MonthStart || '-01' AS TIMESTAMP)) AS MonthEnd,
1112
COUNT(*) AS FileCount,
1213
COUNT(DISTINCT RunId) AS RunCount,
1314
InstrumentNickname

src/org/labkey/targetedms/view/instrumentUtilization.jsp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@
4848
.content-left form[id^="lk-region-"] {
4949
overflow-x: auto;
5050
}
51+
/* Days with acquired samples drill into the Samples tab, so signal that they're clickable */
52+
#instrumentUtilizationCalendar .heatmap-shaded {
53+
cursor: pointer;
54+
}
5155
</style>
5256

5357
<ul class="nav nav-tabs" id="utilizationTabs" role="tablist">
@@ -140,6 +144,13 @@
140144
activate(link.getAttribute('data-utilization-tab'));
141145
});
142146
}
147+
148+
// Shared with the calendar script: activate the Samples tab. The summary-grid count cells and the
149+
// calendar days are ordinary links to this page with utilizationTab=samples plus an AcquiredTime
150+
// filter, so following one reloads the page filtered; this reveals the Samples tab once we're back.
151+
window.showInstrumentSamplesTab = function() {
152+
activate('samples');
153+
};
143154
})();
144155
</script>
145156

@@ -151,11 +162,25 @@
151162
152163
const instrumentName = LABKEY.ActionURL.getParameter('name');
153164
165+
// Following a drill-in link (a summary-grid count cell or a calendar day) reloads this page with
166+
// utilizationTab=samples and an AcquiredTime filter. Let the calendar render first (it needs to be
167+
// visible to size itself), then reveal the pre-filtered Samples tab the link was targeting.
168+
function honorRequestedTab() {
169+
if (LABKEY.ActionURL.getParameter('utilizationTab') === 'samples' && window.showInstrumentSamplesTab) {
170+
window.showInstrumentSamplesTab();
171+
}
172+
}
173+
154174
let dateOnly = function (d) {
155175
let dateTime = new Date(d);
156176
return new Date(dateTime.getFullYear(), dateTime.getMonth(), dateTime.getDate());
157177
};
158178
179+
let formatDate = function (d) {
180+
let pad = function (n) { return (n < 10 ? '0' : '') + n; };
181+
return d.getFullYear() + '-' + pad(d.getMonth() + 1) + '-' + pad(d.getDate());
182+
};
183+
159184
function addEvent(data, date) {
160185
data.push({
161186
startDate: new Date(date.getTime()),
@@ -253,6 +278,7 @@
253278
loadData(function (data) {
254279
if (!data.length) {
255280
$('#instrumentUtilizationCalendar').text('No samples acquired by this instrument.');
281+
honorRequestedTab();
256282
return;
257283
}
258284
@@ -297,6 +323,19 @@
297323
mouseOutDay: function (e) {
298324
$(e.element).popover('hide');
299325
},
326+
clickDay: function (e) {
327+
// Drill into the samples acquired on the clicked day, matching the summary-grid links:
328+
// navigate to this page on the Samples tab with a single-day AcquiredTime filter applied.
329+
let event = e.events && e.events.length > 0 ? e.events[0] : null;
330+
if (!event || !event.fileCount) {
331+
return;
332+
}
333+
window.location = LABKEY.ActionURL.buildURL('targetedms', 'showInstrument', null, {
334+
name: instrumentName,
335+
utilizationTab: 'samples',
336+
'SampleFile.AcquiredTime~dateeq': formatDate(dateOnly(e.date))
337+
});
338+
},
300339
dataSource: data
301340
});
302341
@@ -311,6 +350,8 @@
311350
}
312351
}
313352
});
353+
354+
honorRequestedTab();
314355
});
315356
})();
316357
</script>

test/src/org/labkey/test/components/targetedms/InstrumentUtilizationWebPart.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,20 @@ public DataRegionTable getSamplesTable()
116116
return new DataRegionTable(SAMPLE_FILE_REGION, getDriver());
117117
}
118118

119+
/**
120+
* Clicks the "Replicate Count" drill-in link in the given summary-grid row. The link reloads the page
121+
* on the Samples tab with the row's date-range filter applied, so this waits for the reload and returns
122+
* a fresh web part handle positioned on the (filtered) Samples tab.
123+
*/
124+
public InstrumentUtilizationWebPart drillIntoSamples(DataRegionTable summaryTable, int row)
125+
{
126+
getWrapper().clickAndWait(summaryTable.link(row, "Replicate Count"));
127+
InstrumentUtilizationWebPart reloaded = new InstrumentUtilizationWebPart(getDriver());
128+
WebDriverWrapper.waitFor(reloaded::isSamplesVisible,
129+
"Samples tab did not open after the drill-in navigation", reloaded.getWrapper().defaultWaitForPage);
130+
return reloaded;
131+
}
132+
119133
/** Sum of the (integer) "Files" column, i.e. the total number of sample files represented by the grid. */
120134
public int getTotalFiles(DataRegionTable table)
121135
{

test/src/org/labkey/test/tests/targetedms/TargetedMSInstrumentUtilizationTest.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,36 @@ public void testCrossFolderInstrumentUtilization() throws IOException, CommandEx
9393
InstrumentUtilizationWebPart utilization = new InstrumentUtilizationWebPart(getDriver());
9494
verifyCalendarTab(utilization);
9595
verifyRunsGrids(utilization, expectedCrossFolderFileCount);
96+
verifyDrillIntoSamples(utilization);
97+
}
98+
99+
/**
100+
* The Skyline Document Count / Replicate Count cells in the summary grids drill into the Samples tab
101+
* with a matching date filter applied. Verify the by-day and by-month links land on the Samples tab
102+
* and narrow the sample-file grid to exactly the replicates that row represents.
103+
*/
104+
private void verifyDrillIntoSamples(InstrumentUtilizationWebPart utilization)
105+
{
106+
log("Drilling into the Samples tab from a Summary by Day count link");
107+
DataRegionTable byDay = utilization.getByDayTable();
108+
int dayReplicates = Integer.parseInt(byDay.getDataAsText(0, "Replicate Count").trim());
109+
utilization = utilization.drillIntoSamples(byDay, 0);
110+
assertTrue("Samples tab should open when a day's count is clicked", utilization.isSamplesVisible());
111+
waitForSamplesRowCount(dayReplicates);
112+
113+
log("Drilling into the Samples tab from a Summary by Month count link");
114+
DataRegionTable byMonth = utilization.getByMonthTable();
115+
int monthReplicates = Integer.parseInt(byMonth.getDataAsText(0, "Replicate Count").trim());
116+
utilization = utilization.drillIntoSamples(byMonth, 0);
117+
assertTrue("Samples tab should open when a month's count is clicked", utilization.isSamplesVisible());
118+
waitForSamplesRowCount(monthReplicates);
119+
}
120+
121+
/** Waits for the sample-file grid to refresh to the expected filtered row count (rebuilt each poll to dodge staleness). */
122+
private void waitForSamplesRowCount(int expected)
123+
{
124+
waitFor(() -> new DataRegionTable(InstrumentUtilizationWebPart.SAMPLE_FILE_REGION, getDriver()).getDataRowCount() == expected,
125+
"Samples grid did not filter to the expected " + expected + " row(s)", 10_000);
96126
}
97127

98128
private void verifyCalendarTab(InstrumentUtilizationWebPart utilization)

0 commit comments

Comments
 (0)