Skip to content

Commit e76928f

Browse files
authored
DEV-1242 Add report export functionality to OTIS (#222)
* DEV-1242 Add report export functionality to OTIS - Add `popper_js` gem to add support for Bootstrap dropdown menus. - Move institutions CSV download button to top of page. - Move users CSV download button to top of page and add option to exclude ATRS users. - Add `role_filter` option to `ht_users` controller for CSV requests. * TIDY: replace obsolete 'docker-compose' invocations (addresses issue #218) * Address CVE-2024-39908 in rexml gem
1 parent 7bc35cc commit e76928f

File tree

13 files changed

+66
-22
lines changed

13 files changed

+66
-22
lines changed

Gemfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby]
8181
#
8282
##############################################################################
8383
gem "autoprefixer-rails"
84+
gem "popper_js"
8485
gem "bootstrap-sass"
8586
gem "jquery-rails"
8687
gem "ckeditor"
@@ -107,6 +108,8 @@ gem "sequel", "5.52.0"
107108
group :development, :test do
108109
gem "byebug"
109110
gem "standard"
111+
# parser should be >= the current Ruby version to avoid warnings
112+
gem "parser", ">= 3.1.6"
110113
gem "pry"
111114
gem "pry-byebug", ">= 3.9.0"
112115
gem "sqlite3"

Gemfile.lock

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,10 @@ GEM
226226
version_gem (~> 1.1)
227227
orm_adapter (0.5.0)
228228
parallel (1.22.1)
229-
parser (3.1.2.1)
229+
parser (3.3.4.0)
230230
ast (~> 2.4.1)
231+
racc
232+
popper_js (2.11.8)
231233
pry (0.14.1)
232234
coderay (~> 1.1)
233235
method_source (~> 1.0)
@@ -282,8 +284,8 @@ GEM
282284
rb-inotify (0.10.1)
283285
ffi (~> 1.0)
284286
regexp_parser (2.6.0)
285-
rexml (3.2.8)
286-
strscan (>= 3.0.9)
287+
rexml (3.3.2)
288+
strscan
287289
rubocop (1.35.1)
288290
json (~> 2.3)
289291
parallel (~> 1.10)
@@ -411,6 +413,8 @@ DEPENDENCIES
411413
net-imap
412414
net-pop
413415
net-smtp
416+
parser (>= 3.1.6)
417+
popper_js
414418
pry
415419
pry-byebug (>= 3.9.0)
416420
puma (~> 5.6)

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
```
1111
$ git clone https://github.com/hathitrust/otis.git
1212
$ cd otis
13-
$ docker-compose build
14-
$ docker-compose run web bundle install
13+
$ docker compose build
14+
$ docker compose run --rm web bundle install
1515
```
1616

1717
### 2. Trying it out
1818

1919
```
20-
docker-compose up -d web
20+
docker compose up -d web
2121
```
2222

2323
Development mode uses mysql via Docker with generated data from the `db:seed`
@@ -32,24 +32,24 @@ administrative power.
3232
### 3. Running tests
3333

3434
```
35-
docker-compose run test
35+
docker compose run --rm test
3636
```
3737

3838
To enable W3C HTML validation of OTIS pages, use the following.
3939
These tests are not run by default since they rely on an external service.
4040

4141
```
42-
docker-compose run -e W3C_VALIDATION=1 test
42+
docker compose run --rm -e W3C_VALIDATION=1 test
4343
```
4444

4545
To run a single test class use an invocation along these lines:
4646

4747
```
48-
docker-compose run test bundle exec ruby -I test test/controllers/ht_users_controller_test.rb
48+
docker compose run --rm test bundle exec ruby -I test test/controllers/ht_users_controller_test.rb
4949
```
5050

5151
System tests, as usual, are not run by default.
5252

5353
```
54-
docker-compose run system-test
54+
docker compose run --rm system-test
5555
```

app/assets/javascripts/application.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
// about supported directives.
1212
//
1313
//= require jquery3
14+
//= require popper
1415
//= require bootstrap
1516
//= require rails-ujs
1617
//= require activestorage

app/controllers/ht_institutions_controller.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ def index
3838
@other_institutions = HTInstitution.other.order("name").map { |i| presenter i }
3939
respond_to do |format|
4040
format.html
41-
format.csv { send_data institutions_csv }
41+
format.csv do
42+
file_name = (params[:file_name] || "ht_institutions") + ".csv"
43+
send_data institutions_csv, filename: file_name
44+
end
4245
end
4346
end
4447

app/controllers/ht_users_controller.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ def index
1313
@all_users = users.map { |u| presenter u }
1414
respond_to do |format|
1515
format.html
16-
format.csv { send_data users_csv }
16+
format.csv do
17+
file_name = (params[:file_name] || "ht_users") + ".csv"
18+
send_data users_csv, filename: file_name
19+
end
1720
end
1821
end
1922

@@ -65,6 +68,9 @@ def users_csv
6568
CSV.generate do |csv|
6669
csv << @all_users.first.csv_cols
6770
@all_users.each do |user|
71+
if params[:role_filter]&.include?(user.role)
72+
next
73+
end
6874
csv << user.csv_vals
6975
end
7076
end

app/views/ht_institutions/index.html.erb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
<% fields = HTInstitutionPresenter::INDEX_FIELDS %>
44

5+
<%= link_to t(".download_csv"), ht_institutions_url(format: :csv), class: 'btn btn-info' %>
6+
<br/>
7+
58
<h2 class="pull-left"><%= t ".enabled_institutions" %></h2>
69

710
<table id="active_institutions" class="table table-striped" data-toggle="table" data-height="460" data-virtual-scroll="true"
@@ -45,10 +48,6 @@
4548
<% end %>
4649
</table>
4750

48-
<br />
49-
<%= link_to t(".download_csv"), ht_institutions_url(format: :csv), class: 'btn btn-info' %>
50-
<br />
51-
5251
<% if can?(:create, HTInstitution) %>
5352
<h2><%= t ".add" %></h2>
5453

app/views/ht_users/index.html.erb

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,22 @@
44
<% fields = HTUserPresenter::INDEX_FIELDS %>
55
<%= form_tag(ht_approval_requests_path, method: :post) do %>
66

7+
<div class="dropdown">
8+
<button class="btn btn-info dropdown-toggle" type="button" id="download-menu"
9+
data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
10+
<%= t(".download_csv") %>
11+
<span class="caret"></span>
12+
</button>
13+
<ul class="dropdown-menu" aria-labelledby="download-menu">
14+
<li>
15+
<%= link_to t(".download_csv_non_atrs"), ht_users_url(format: :csv, role_filter: [:ssd, :ssdproxy], file_name: "non_atrs_users") %>
16+
</li>
17+
<li>
18+
<%= link_to t(".download_csv_all"), ht_users_url(format: :csv, file_name: "all_users") %>
19+
</li>
20+
</ul>
21+
</div>
22+
723
<h2 class="pull-left"><%= t ".active_users" %></h2>
824
<table id="active_users" class="table table-striped" data-toggle="table" data-height="460" data-virtual-scroll="true"
925
data-search="true" data-show-search-clear-button="true">
@@ -37,7 +53,7 @@
3753
<% if can?(:edit, HTUser) %>
3854
<%= button_tag t(".renew_selected_users"), type: 'submit', name: 'submit_renewals', class: 'btn btn-primary' %>
3955
<% end %>
40-
<%= link_to t(".download_csv"), ht_users_url(format: :csv), class: 'btn btn-info' %>
56+
4157
<% end # form_tag %>
4258
4359
<h2 class="pull-left"><%= t ".expired_users" %></h2>

config/locales/en.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,8 @@ en:
394394
active_users: Active Users
395395
create_approval_requests: Create Approval Requests
396396
download_csv: Download CSV
397+
download_csv_all: All Users
398+
download_csv_non_atrs: Non-ATRS Users
397399
expired_users: Expired Users
398400
renew_selected_users: Renew Selected Users
399401
select: Select

config/locales/ja.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,8 @@ ja:
394394
active_users: アクティブユーザー
395395
create_approval_requests: 承認リクエストを作成する
396396
download_csv: CSVをダウンロード
397+
download_csv_all: 全てのユーザー
398+
download_csv_non_atrs: 非ATRSのユーザー
397399
expired_users: 期限切れのユーザー
398400
renew_selected_users: 選択したユーザーを更新する
399401
select: 選択

0 commit comments

Comments
 (0)