-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mccalluc/user files csv filtering (#2041)
* The files partial now includes the download link; download link uses a controller function * Params will be reused... pull into its own service * Checkpoint: url updates, but need to do it the right way * serialize url the right way
- Loading branch information
1 parent
9cf5019
commit 0139c1e
Showing
5 changed files
with
74 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 15 additions & 5 deletions
20
refinery/ui/source/js/user-file-browser/partials/user-file-browser-files.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,15 @@ | ||
<div | ||
ui-grid="$ctrl.gridOptions" | ||
ui-grid-resize-columns | ||
class="grid"> | ||
</div> | ||
<div class="col-lg-10 col-md-10 col-sm-9" id="main-area"> | ||
<div> | ||
<a href="/files_download?{{ $ctrl.downloadFilterQuery() }}"><i class="fa fa-arrow-circle-o-down"></i> Download as CSV</a> | ||
</div> | ||
<div class="m-r-1"> | ||
<!-- Bootstrap col classes are using the window width, not our inner div. | ||
#table-filter has a margin-left, so do something similar on the other side --> | ||
<!-- TODO: Why isn't it full height? --> | ||
<div | ||
ui-grid="$ctrl.gridOptions" | ||
ui-grid-resize-columns | ||
class="grid"> | ||
</div> | ||
</div> | ||
</div> |
45 changes: 45 additions & 0 deletions
45
refinery/ui/source/js/user-file-browser/services/user-file-params.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
(function () { | ||
'use strict'; | ||
angular | ||
.module('refineryApp') | ||
.factory('userFileParamsService', userFileParamsService); | ||
|
||
userFileParamsService.$inject = [ | ||
'userFileFiltersService', | ||
'userFileSortsService' | ||
]; | ||
|
||
function userFileParamsService ( | ||
userFileFiltersService, | ||
userFileSortsService | ||
) { | ||
var characterSuffix = '_Characteristics_generic_s'; | ||
var factorSuffix = '_Factor_Value_generic_s'; | ||
var params = { | ||
limit: 100, // Default is 100,000. Immutability make it hard in python. | ||
fq: function () { | ||
var filters = Object.keys(userFileFiltersService).map(function (key) { | ||
var values = userFileFiltersService[key]; | ||
// TODO: escaping! | ||
var orValues = values.map(function (value) { | ||
return '(' + | ||
key + characterSuffix + ':"' + value + '" OR ' + | ||
key + factorSuffix + ':"' + value + '")'; | ||
}).join(' OR '); | ||
return '(' + orValues + ')'; | ||
}); | ||
return filters.join(' AND '); | ||
}, | ||
sort: function () { | ||
return userFileSortsService.fields.map(function (field) { | ||
var name = field.name; | ||
var direction = field.direction; | ||
return [ | ||
name + characterSuffix + ' ' + direction, | ||
name + factorSuffix + ' ' + direction].join(', '); | ||
}).join(', '); | ||
} | ||
}; | ||
return params; | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters