|
4 | 4 | <input type="text" placeholder="Search..." ref="search" onkeyup="{ filter.bind(this, undefined) }"> |
5 | 5 | <i class="search icon"></i> |
6 | 6 | </div> |
7 | | - <button class="ui red right floated labeled icon button {disabled: marked_datasets.length === 0}" onclick="{delete_datasets}"> |
| 7 | + <button class="ui red right floated labeled icon button {disabled: marked_competition_bundles.length === 0}" onclick="{delete_competition_bundles}"> |
8 | 8 | <i class="icon delete"></i> |
9 | 9 | Delete Selected |
10 | 10 | </button> |
11 | 11 |
|
12 | 12 | <!-- Data Table --> |
13 | | - <table id="bundlesTable" class="ui {selectable: datasets.length > 0} celled compact sortable table"> |
| 13 | + <table id="bundlesTable" class="ui {selectable: competition_bundles.length > 0} celled compact sortable table"> |
14 | 14 | <thead> |
15 | 15 | <tr> |
16 | 16 | <th>File Name</th> |
|
23 | 23 | </thead> |
24 | 24 |
|
25 | 25 | <tbody> |
26 | | - <tr each="{ dataset, index in datasets }" |
| 26 | + <tr each="{ bundle, index in competition_bundles }" |
27 | 27 | class="dataset-row" |
28 | | - onclick="{show_info_modal.bind(this, dataset)}"> |
29 | | - <td>{ dataset.name }</td> |
| 28 | + onclick="{show_info_modal.bind(this, bundle)}"> |
| 29 | + <td>{ bundle.name }</td> |
30 | 30 | <td> |
31 | | - <div if="{dataset.competition}" class="ui fitted"> |
32 | | - <a id="competitionLink" href="{URLS.COMPETITION_DETAIL(dataset.competition.id)}" target="_blank">{dataset.competition.title}</a> |
| 31 | + <div if="{bundle.competition}" class="ui fitted"> |
| 32 | + <a id="competitionLink" href="{URLS.COMPETITION_DETAIL(bundle.competition.id)}" target="_blank">{bundle.competition.title}</a> |
33 | 33 | </div> |
34 | 34 | </td> |
35 | | - <td>{ pretty_bytes(dataset.file_size) }</td> |
36 | | - <td>{ timeSince(Date.parse(dataset.created_when)) } ago</td> |
| 35 | + <td>{ pretty_bytes(bundle.file_size) }</td> |
| 36 | + <td>{ timeSince(Date.parse(bundle.created_when)) } ago</td> |
37 | 37 | <td class="center aligned"> |
38 | | - <button show="{dataset.created_by === CODALAB.state.user.username}" class="ui mini button red icon" onclick="{ delete_dataset.bind(this, dataset) }"> |
| 38 | + <button show="{bundle.created_by === CODALAB.state.user.username}" class="ui mini button red icon" onclick="{ delete_competition_bundle.bind(this, bundle) }"> |
39 | 39 | <i class="icon delete"></i> |
40 | 40 | </button> |
41 | 41 | </td> |
42 | 42 | <td class="center aligned"> |
43 | | - <div show="{dataset.created_by === CODALAB.state.user.username}" class="ui fitted checkbox"> |
44 | | - <input type="checkbox" name="delete_checkbox" onclick="{ mark_dataset_for_deletion.bind(this, dataset) }"> |
| 43 | + <div show="{bundle.created_by === CODALAB.state.user.username}" class="ui fitted checkbox"> |
| 44 | + <input type="checkbox" name="delete_checkbox" onclick="{ mark_competition_bundle_for_deletion.bind(this, bundle) }"> |
45 | 45 | <label></label> |
46 | 46 | </div> |
47 | 47 | </td> |
48 | 48 | </tr> |
49 | | - <tr if="{datasets.length === 0}"> |
| 49 | + <tr if="{competition_bundles.length === 0}"> |
50 | 50 | <td class="center aligned" colspan="6"> |
51 | | - <em>No Datasets Yet!</em> |
| 51 | + <em>No Competition Bundles Yet!</em> |
52 | 52 | </td> |
53 | 53 | </tr> |
54 | 54 | </tbody> |
55 | 55 |
|
56 | 56 | <tfoot> |
57 | 57 | <!-- Pagination --> |
58 | 58 | <tr> |
59 | | - <th colspan="8" if="{datasets.length > 0}"> |
60 | | - <div class="ui right floated pagination menu" if="{datasets.length > 0}"> |
| 59 | + <th colspan="8" if="{competition_bundles.length > 0}"> |
| 60 | + <div class="ui right floated pagination menu" if="{competition_bundles.length > 0}"> |
61 | 61 | <a show="{!!_.get(pagination, 'previous')}" class="icon item" onclick="{previous_page}"> |
62 | 62 | <i class="left chevron icon"></i> |
63 | 63 | </a> |
|
125 | 125 | Init |
126 | 126 | ---------------------------------------------------------------------*/ |
127 | 127 |
|
128 | | - self.datasets = [] |
129 | | - self.marked_datasets = [] |
| 128 | + self.competition_bundles = [] |
| 129 | + self.marked_competition_bundles = [] |
130 | 130 | self.selected_row = {} |
131 | 131 | self.page = 1 |
132 | 132 |
|
133 | 133 | self.one("mount", function () { |
134 | 134 | $(".ui.dropdown", self.root).dropdown() |
135 | 135 | $(".ui.checkbox", self.root).checkbox() |
136 | 136 | $('#bundlesTable').tablesort() |
137 | | - self.update_datasets() |
| 137 | + self.update_competition_bundles() |
138 | 138 | }) |
139 | 139 |
|
140 | 140 | /*--------------------------------------------------------------------- |
|
150 | 150 | page: 1, |
151 | 151 | }) |
152 | 152 | self.page = filters.page |
153 | | - self.update_datasets(filters) |
| 153 | + self.update_competition_bundles(filters) |
154 | 154 | } |
155 | 155 |
|
156 | 156 | self.next_page = function () { |
|
171 | 171 | } |
172 | 172 | } |
173 | 173 |
|
174 | | - self.update_datasets = function (filters) { |
| 174 | + self.update_competition_bundles = function (filters) { |
175 | 175 | filters = filters || {} |
176 | 176 | filters._type = "bundle" |
177 | 177 | CODALAB.api.get_datasets(filters) |
178 | 178 | .done(function (data) { |
179 | | - self.datasets = data.results |
| 179 | + self.competition_bundles = data.results |
180 | 180 | self.pagination = { |
181 | 181 | "count": data.count, |
182 | 182 | "next": data.next, |
|
185 | 185 | self.update() |
186 | 186 | }) |
187 | 187 | .fail(function (response) { |
188 | | - toastr.error("Could not load datasets...") |
| 188 | + toastr.error("Could not load competition bundles...") |
189 | 189 | }) |
190 | 190 | } |
191 | 191 |
|
192 | | - self.delete_dataset = function (dataset, e) { |
193 | | - if (confirm(`Are you sure you want to delete '${dataset.name}'?`)) { |
194 | | - CODALAB.api.delete_dataset(dataset.id) |
| 192 | + self.delete_competition_bundle = function (bundle, e) { |
| 193 | + if (confirm(`Are you sure you want to delete '${bundle.name}'?`)) { |
| 194 | + CODALAB.api.delete_dataset(bundle.id) |
195 | 195 | .done(function () { |
196 | | - self.update_datasets() |
197 | | - toastr.success("Dataset deleted successfully!") |
| 196 | + self.update_competition_bundles() |
| 197 | + toastr.success("Competition bundle deleted successfully!") |
198 | 198 | CODALAB.events.trigger('reload_quota_cleanup') |
199 | 199 | }) |
200 | 200 | .fail(function (response) { |
|
204 | 204 | event.stopPropagation() |
205 | 205 | } |
206 | 206 |
|
207 | | - self.delete_datasets = function () { |
208 | | - if (confirm(`Are you sure you want to delete multiple datasets?`)) { |
209 | | - CODALAB.api.delete_datasets(self.marked_datasets) |
| 207 | + self.delete_competition_bundles = function () { |
| 208 | + if (confirm(`Are you sure you want to delete multiple competition bundles?`)) { |
| 209 | + CODALAB.api.delete_datasets(self.marked_competition_bundles) |
210 | 210 | .done(function () { |
211 | | - self.update_datasets() |
212 | | - toastr.success("Dataset deleted successfully!") |
213 | | - self.marked_datasets = [] |
| 211 | + self.update_competition_bundles() |
| 212 | + toastr.success("Competition bundles deleted successfully!") |
| 213 | + self.marked_competition_bundles = [] |
214 | 214 | CODALAB.events.trigger('reload_quota_cleanup') |
215 | 215 | }) |
216 | 216 | .fail(function (response) { |
|
222 | 222 | event.stopPropagation() |
223 | 223 | } |
224 | 224 |
|
225 | | - self.mark_dataset_for_deletion = function(dataset, e) { |
| 225 | + self.mark_competition_bundle_for_deletion = function(bundle, e) { |
226 | 226 | if (e.target.checked) { |
227 | | - self.marked_datasets.push(dataset.id) |
| 227 | + self.marked_competition_bundles.push(bundle.id) |
228 | 228 | } |
229 | 229 | else { |
230 | | - self.marked_datasets.splice(self.marked_datasets.indexOf(dataset.id), 1) |
| 230 | + self.marked_competition_bundles.splice(self.marked_competition_bundles.indexOf(bundle.id), 1) |
231 | 231 | } |
232 | 232 | } |
233 | 233 |
|
|
241 | 241 | $(self.refs.info_modal).modal('show') |
242 | 242 | } |
243 | 243 |
|
| 244 | + // Update bundles on unused bundles delete |
| 245 | + CODALAB.events.on('reload_competition_bundles', self.update_competition_bundles) |
| 246 | + |
244 | 247 |
|
245 | 248 | </script> |
246 | 249 |
|
|
0 commit comments