Skip to content

Commit bde300e

Browse files
committed
#2238 add checkboxes to use filter and units via package download
1 parent a8c9ed3 commit bde300e

File tree

4 files changed

+131
-80
lines changed

4 files changed

+131
-80
lines changed

Console/BExIS.Web.Shell/Areas/DDM/BExIS.Modules.Ddm.UI/Controllers/Api/CitationsController.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ private DatasetCitationEntry CreateCitationEntry(long datasetId, CitationDataMod
374374
if (!String.IsNullOrEmpty(model.DOI))
375375
datasetCitationEntry.DOI = model.DOI;
376376
datasetCitationEntry.Authors = model.Authors;
377-
datasetCitationEntry.Year = getYear(model.Date);
377+
datasetCitationEntry.Year = getYear(model.Year);
378378

379379
//create authorname in the correct format
380380
List<string> authors = new List<string>();
@@ -401,7 +401,7 @@ private string generateCitation(string datasetId, CitationDataModel model, bool
401401
string publisher = settings.GetValueByKey("publisher").ToString();
402402
string instanceName = settings.GetValueByKey("instanceName").ToString();
403403

404-
string year = getYear(model.Date);
404+
string year = getYear(model.Year);
405405

406406
//create authorname in the correct format
407407
List<string> authors = new List<string>();
@@ -453,12 +453,12 @@ private CitationDataModel GetModel(DatasetVersion datasetVersion)
453453

454454
if (String.IsNullOrEmpty(model.Version))
455455
model.Version = datasetVersion.VersionNo.ToString();
456-
if (String.IsNullOrEmpty(model.Date))
456+
if (String.IsNullOrEmpty(model.Year))
457457
{
458458
if (String.IsNullOrEmpty(datasetVersion.PublicAccessDate.ToString()))
459-
model.Date = datasetVersion.PublicAccessDate.ToString();
459+
model.Year = datasetVersion.PublicAccessDate.ToString();
460460
else
461-
model.Date = datasetVersion.Timestamp.ToString();
461+
model.Year = datasetVersion.Timestamp.ToString();
462462
}
463463
if (String.IsNullOrEmpty(model.DOI))
464464
{

Console/BExIS.Web.Shell/Areas/DDM/BExIS.Modules.Ddm.UI/Controllers/DataController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -591,11 +591,11 @@ public ActionResult Reload(long id, int version = 0)
591591
}
592592

593593
[BExISEntityAuthorize(typeof(Dataset), "id", RightType.Read)]
594-
public ActionResult DownloadZip(long id, string format, long version = -1)
594+
public ActionResult DownloadZip(long id, string format, long version = -1,bool withFilter = false, bool withUnits=false)
595595
{
596596
if (this.IsAccessible("DIM", "Export", "GenerateZip"))
597597
{
598-
var actionresult = this.Run("DIM", "Export", "GenerateZip", new RouteValueDictionary() { { "id", id }, { "versionid", version }, { "format", format } });
598+
var actionresult = this.Run("DIM", "Export", "GenerateZip", new RouteValueDictionary() { { "id", id }, { "versionid", version }, { "format", format }, { "withFilter", withFilter }, { "withUnits", withUnits } });
599599

600600
return actionresult;
601601
}

Console/BExIS.Web.Shell/Areas/DDM/BExIS.Modules.Ddm.UI/Views/Data/ShowData.cshtml

Lines changed: 119 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
bool has_data = false;
1313
string data_aggreement = "none";
1414
bool aggrreement_checked = true;
15+
bool withFilter = false;
16+
bool withUnits = false;
1517

1618
if (ViewData["TabIndex"] != null)
1719
{
@@ -245,7 +247,7 @@
245247
</div>
246248

247249
<div class="datasetview_header-toggle flex">
248-
250+
249251
@if (Model.DownloadAccess)
250252
{
251253
/* data aggreement state: none, data policy, terms and conditions**/
@@ -254,8 +256,10 @@
254256
{
255257
<div class="data-aggreement">
256258
@Html.CheckBox("data_policy", false, new { @id = "data-policy" })
257-
<b>I accept the public regulations from the
258-
<a href="/footer/policy" target="_blank">privacy policy</a>.</b>
259+
<b>
260+
I accept the public regulations from the
261+
<a href="/footer/policy" target="_blank">privacy policy</a>.
262+
</b>
259263
</div>
260264
}
261265
else if (data_aggreement.Equals("terms and conditions"))
@@ -266,97 +270,108 @@
266270
I accept the public regulations from the
267271
<a href="/footer/termsandconditions" target="_blank">terms and conditions</a>.
268272
</b>
269-
</div>
273+
</div>
270274
}
271275

272276

273277

274278
if (Model.DataStructureType.ToLower().Equals("structured"))
275279
{
276-
<span class="dropdown">
277-
278-
<button class="bx-button function small" type="button" id="dropdownMenu1" data-toggle="dropdown" title="Download dataset with a selected dataformat for the primary data" aria-haspopup="true" aria-expanded="true">
279-
<span class="fa fa-download" style="padding-right: 5px;"></span>
280-
Download
281-
<span class="caret"></span>
282-
</button>
283-
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1" style="z-index:100000; margin-top:10px;">
284-
285-
@if (@total < 1048576) // hide Excel download for bigger datasets, which exceed the max number of rows in excel
286-
{
287-
<li>@*<a href="@Url.Action("DownloadZip", "Data", new { id = @Model.Id, format = "application/xlsm", version = Model.VersionId })">... with Template</a>*@</li>
288-
<li><a href="@Url.Action("DownloadZip", "Data", new { id = @Model.Id, format = "application/xlsx", version = Model.VersionId })">... with Excel</a></li>
289-
}
290-
<li><a href="@Url.Action("DownloadZip", "Data", new { id = @Model.Id, format = "text/csv", version = Model.VersionId })">... with CSV</a></li>
291-
<li><a href="@Url.Action("DownloadZip", "Data", new { id = @Model.Id, format = "text/tsv", version = Model.VersionId })">... with TSV</a></li>
292-
<li><a href="@Url.Action("DownloadZip", "Data", new { id = @Model.Id, format = "text/plain", version = Model.VersionId })">... with TXT</a></li>
293-
</ul>
294-
</span>
295-
}
296-
else
297-
{
298-
<a class="bx-button small function" href="@Url.Action("DownloadZip", "Data", new { id = @Model.Id, version = Model.VersionId, format = "" })"><span class="fa fa-download" style="padding-right: 5px;"></span>Download Dataset</a>
299-
}
300-
}
301-
else
302-
{
280+
<div class="padding-top-5 position-releative ">
281+
<span>
282+
@Html.CheckBox("WithFilter", false, new { text = "download filtered data", @id = "withFilter" })
283+
use filter
284+
</span>
285+
286+
<span>
287+
@Html.CheckBox("WithUnits", false, new { text = "download data with units", @id = "withUnits" })
288+
add units
289+
</span>
290+
</div>
291+
292+
<span class="dropdown">
293+
294+
<button class="bx-button function small" type="button" id="dropdownMenu1" data-toggle="dropdown" title="Download dataset with a selected dataformat for the primary data" aria-haspopup="true" aria-expanded="true">
295+
<span class="fa fa-download" style="padding-right: 5px;"></span>
296+
Download
297+
<span class="caret"></span>
298+
</button>
299+
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1" style="z-index:100000; margin-top:10px;">
300+
301+
@if (@total < 1048576) // hide Excel download for bigger datasets, which exceed the max number of rows in excel
302+
{
303+
<li>@*<a href="@Url.Action("DownloadZip", "Data", new { id = @Model.Id, format = "application/xlsm", version = Model.VersionId })">... with Template</a>*@</li>
304+
<li><a href="@Url.Action("DownloadZip", "Data", new { id = @Model.Id, format = "application/xlsx", version = Model.VersionId, withFilter, withUnits })">... with Excel</a></li>
305+
}
306+
<li><a id="csv-download" href="@Url.Action("DownloadZip", "Data", new { id = @Model.Id, format = "text/csv", version = Model.VersionId })" >... with CSV</a></li>
307+
<li><a href="@Url.Action("DownloadZip", "Data", new { id = @Model.Id, format = "text/tsv", version = Model.VersionId, withFilter,withUnits })">... with TSV</a></li>
308+
<li><a href="@Url.Action("DownloadZip", "Data", new { id = @Model.Id, format = "text/plain", version = Model.VersionId, withFilter,withUnits })">... with TXT</a></li>
309+
</ul>
310+
</span>
311+
}
312+
else
313+
{
314+
<a class="bx-button small function" href="@Url.Action("DownloadZip", "Data", new { id = @Model.Id, version = Model.VersionId, format = "" })"><span class="fa fa-download" style="padding-right: 5px;"></span>Download Dataset</a>
315+
}
316+
}
317+
else
318+
{
303319

304320

305-
if (Model.HasRequestRight)
306-
{
307-
if (Model.RequestAble)
308-
{
321+
if (Model.HasRequestRight)
322+
{
323+
if (Model.RequestAble)
324+
{
309325

310326
if (Model.RequestExist)
311327
{
312-
<button id="sendRequestBt" class="bx-button small function bx-disabled" title="Send request to the owner of the dataset for the rights to see and download the primary data." disabled="disabled">Request Pending</button>
328+
<button id="sendRequestBt" class="bx-button small function bx-disabled" title="Send request to the owner of the dataset for the rights to see and download the primary data." disabled="disabled">Request Pending</button>
313329
}
314330
else if (!has_data)
315331
{
316-
<!-- if dataset has no data-->
317-
332+
<!-- if dataset has no data-->
318333
}
319334
else
320335
{
321-
<div>
322-
@Html.TextArea("intention", new { @class = "bx-input", placeholder = "describe your intention " });
323-
</div>
324-
<button id="sendRequestBt" datasetId="@Model.Id" class="bx-button small function" title="Send request to the owner of the dataset for the rights to see and download the primary data.">
325-
<span class="fa fa-paper-plane" style="padding-right: 5px;"></span>
326-
Request Access
327-
</button>
336+
<div>
337+
@Html.TextArea("intention", new { @class = "bx-input", placeholder = "describe your intention " });
338+
</div>
339+
<button id="sendRequestBt" datasetId="@Model.Id" class="bx-button small function" title="Send request to the owner of the dataset for the rights to see and download the primary data.">
340+
<span class="fa fa-paper-plane" style="padding-right: 5px;"></span>
341+
Request Access
342+
</button>
328343
}
329344

330-
}
331-
else
332-
{
345+
}
346+
else
347+
{
333348
if (show_tabs["show_tabs_deactivated"] == "true")
334349
{
335-
<button id="sendRequestBt" class="bx-button small function bx-disabled" title="Send request to the owner of the dataset for the rights to see and download the primary data. If the function is not available, please contact the administrator." disabled="disabled">Currently not available</button>
350+
<button id="sendRequestBt" class="bx-button small function bx-disabled" title="Send request to the owner of the dataset for the rights to see and download the primary data. If the function is not available, please contact the administrator." disabled="disabled">Currently not available</button>
336351
}
337-
}
338-
}
339-
else
340-
{
341-
if (show_tabs["show_tabs_deactivated"] == "true")
342-
{
352+
}
353+
}
354+
else
355+
{
356+
if (show_tabs["show_tabs_deactivated"] == "true")
357+
{
343358
<button id="sendRequestBt" class="bx-button small function bx-disabled" title="You have no right to make requests." disabled="disabled">Currently not available</button>
344-
}
345-
}
346-
}
359+
}
360+
}
361+
}
347362

348-
@if (Model.HasEditRight && ViewData["state"].ToString() != "hidden")
349-
{
363+
@if (Model.HasEditRight && ViewData["state"].ToString() != "hidden")
364+
{
350365

351-
<button title="go to edit dataset" class="bx-button small function" type="button" onclick="toogleToEdit()">
352-
<span class="fa fa-pencil"></span>
353-
<span style="padding:5px;">
354-
Edit
355-
</span>
356-
</button>
366+
<button title="go to edit dataset" class="bx-button small function" type="button" onclick="toogleToEdit()">
367+
<span class="fa fa-pencil"></span>
368+
<span style="padding:5px;">
369+
Edit
370+
</span>
371+
</button>
357372

358-
}
359-
</div>
373+
}
374+
</div>
360375
</div>
361376

362377

@@ -515,6 +530,37 @@
515530
console.log("aggrreement_checked",'@aggrreement_checked')
516531
setDownloadBt('@aggrreement_checked');
517532
533+
534+
$("#csv-download").on("click", function (e) {
535+
// Prevent the default navigation initially
536+
e.preventDefault();
537+
538+
var withFilter = $("#withFilter");
539+
var withFilterIsChecked = withFilter.is(":checked"); // Check if the box is checked
540+
var withUnits = $("#withUnits");
541+
var withUnitsIsChecked = withUnits.is(":checked"); // Check if the box is checked
542+
543+
544+
var link = $(this);
545+
var originalHref = link.attr("href");
546+
var newHref = originalHref;
547+
548+
// Construct the query parameter, using the checkbox's name 'IsChecked'
549+
var param = "withFilter=" + withFilterIsChecked + "&&withUnits=" + withUnitsIsChecked;
550+
551+
// Check if the URL already contains query parameters
552+
if (originalHref.indexOf('?') > -1) {
553+
newHref += "&" + param;
554+
} else {
555+
newHref += "?" + param;
556+
}
557+
558+
console.log("newHref", newHref);
559+
560+
// Set the new URL and navigate
561+
window.location.href = newHref;
562+
});
563+
518564
});
519565
520566
function setDownloadBt(aggreed) {
@@ -760,6 +806,11 @@ else
760806
padding-top: 5px;
761807
}
762808
809+
810+
.position-releative {
811+
position: relative;
812+
}
813+
763814
#identifier-container {
764815
padding-left:2px;
765816
}

Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Controllers/ExportController.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public ActionResult SimpleDataStructure(long id)
192192
}
193193
}
194194

195-
public ActionResult GenerateZip(long id, long versionid, string format)
195+
public ActionResult GenerateZip(long id, long versionid, string format,bool withFilter = false, bool withUnits = false)
196196
{
197197
XmlDatasetHelper xmlDatasetHelper = new XmlDatasetHelper();
198198
DatasetManager dm = new DatasetManager();
@@ -237,26 +237,26 @@ public ActionResult GenerateZip(long id, long versionid, string format)
237237
//check wheter title is empty or not
238238
title = String.IsNullOrEmpty(datasetVersion.Title) ? "no title available" : datasetVersion.Title;
239239

240-
if (isFilterInUse)
240+
if (isFilterInUse && withFilter)
241241
{
242242
DataTable filteredData = getFilteredData(id);
243-
filteredFilePath = odm.GenerateAsciiFile("temp", filteredData, title, format, datasetVersion.Dataset.DataStructure.Id, false);
243+
filteredFilePath = odm.GenerateAsciiFile("temp", filteredData, title, format, datasetVersion.Dataset.DataStructure.Id, withUnits);
244244
}
245245
else
246246
{
247247

248248
switch (format)
249249
{
250250
case "application/xlsx":
251-
odm.GenerateExcelFile(id, datasetVersion.Id, false);
251+
odm.GenerateExcelFile(id, datasetVersion.Id, withUnits);
252252
break;
253253

254254
case "application/xlsm":
255255
odm.GenerateExcelFile(id, datasetVersion.Id, true);
256256
break;
257257

258258
default:
259-
odm.GenerateAsciiFile(id, datasetVersion.Id, format, false);
259+
odm.GenerateAsciiFile(id, datasetVersion.Id, format, withUnits);
260260
break;
261261
}
262262
}

0 commit comments

Comments
 (0)