1
|
package eu.dnetlib.repo.manager.client.browsehistory;
|
2
|
|
3
|
import com.google.gwt.core.client.GWT;
|
4
|
import com.google.gwt.dom.client.Document;
|
5
|
import com.google.gwt.event.dom.client.ChangeEvent;
|
6
|
import com.google.gwt.event.dom.client.ChangeHandler;
|
7
|
import com.google.gwt.event.dom.client.ClickEvent;
|
8
|
import com.google.gwt.event.dom.client.ClickHandler;
|
9
|
import com.google.gwt.query.client.Function;
|
10
|
import com.google.gwt.user.client.Event;
|
11
|
import com.google.gwt.user.client.Window;
|
12
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
13
|
import com.google.gwt.user.client.ui.FlowPanel;
|
14
|
import com.google.gwt.user.client.ui.HTML;
|
15
|
import com.google.gwt.user.client.ui.Label;
|
16
|
import com.google.gwt.user.client.ui.Widget;
|
17
|
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
18
|
import eu.dnetlib.gwt.client.help.HelpService;
|
19
|
import eu.dnetlib.gwt.client.help.HelpServiceAsync;
|
20
|
import eu.dnetlib.repo.manager.client.AbstractRepositoryManagerWidget;
|
21
|
import eu.dnetlib.repo.manager.client.HelpCallback;
|
22
|
import eu.dnetlib.repo.manager.client.RepositoryManager;
|
23
|
import eu.dnetlib.repo.manager.client.RepositoryManagerWidget;
|
24
|
import eu.dnetlib.repo.manager.client.services.ValidationService;
|
25
|
import eu.dnetlib.repo.manager.client.services.ValidationServiceAsync;
|
26
|
import eu.dnetlib.repo.manager.shared.Constants;
|
27
|
import eu.dnetlib.repo.manager.shared.JobsOfUser;
|
28
|
import eu.dnetlib.repo.manager.shared.broker.EventsPage;
|
29
|
import org.gwtbootstrap3.client.ui.*;
|
30
|
import org.gwtbootstrap3.client.ui.constants.AlertType;
|
31
|
import org.gwtbootstrap3.client.ui.constants.IconType;
|
32
|
import org.gwtbootstrap3.client.ui.html.UnorderedList;
|
33
|
|
34
|
import java.util.ArrayList;
|
35
|
import java.util.List;
|
36
|
|
37
|
import static com.google.gwt.query.client.GQuery.$;
|
38
|
|
39
|
/**
|
40
|
* Created by stefania on 3/28/16.
|
41
|
*/
|
42
|
public class BrowseHistoryWidget extends AbstractRepositoryManagerWidget implements RepositoryManagerWidget {
|
43
|
|
44
|
private String parentToken = "";
|
45
|
private String restToken = "";
|
46
|
|
47
|
private Alert errorAlert = new Alert();
|
48
|
private Alert successAlert = new Alert();
|
49
|
private Alert warningAlert = new Alert();
|
50
|
|
51
|
private FlowPanel myHistoryListBoxContent = new FlowPanel();
|
52
|
private FlowPanel controlsPanel = new FlowPanel();
|
53
|
private FlowPanel contentAndPagerPanel = new FlowPanel();
|
54
|
|
55
|
private FlowPanel topPagerPanel = new FlowPanel();
|
56
|
private Pager resultsPagerTop = new Pager();
|
57
|
private Label pageNumberTop = new Label();
|
58
|
|
59
|
private FlowPanel jobsListContentPanel = new FlowPanel();
|
60
|
|
61
|
private FlowPanel bottomPagerPanel = new FlowPanel();
|
62
|
private Pager resultsPagerBottom = new Pager();
|
63
|
private Label pageNumberBottom = new Label();
|
64
|
|
65
|
private ListBox validationJobTypesListBox = new ListBox();
|
66
|
private ListBox jobsPerPageListBox = new ListBox();
|
67
|
|
68
|
private int jobTypeSelectedIndex = 0;
|
69
|
private int jobsPerPageSelectedIndex = 0;
|
70
|
private String jobStatusSelected = "all";
|
71
|
private int currentPage = 1;
|
72
|
|
73
|
private List<StoredJob> storedJobs = new ArrayList<StoredJob>();
|
74
|
private List<StoredJob> finishedStoredJobs = new ArrayList<StoredJob>();
|
75
|
private List<StoredJob> failedStoredJobs = new ArrayList<StoredJob>();
|
76
|
private List<StoredJob> pendingStoredJobs = new ArrayList<StoredJob>();
|
77
|
|
78
|
private JobsOfUser jobsOfUser = null;
|
79
|
|
80
|
private ValidationServiceAsync validationService = GWT.create(ValidationService.class);
|
81
|
private static HelpServiceAsync helpService = GWT.create(HelpService.class);
|
82
|
|
83
|
public BrowseHistoryWidget() {
|
84
|
|
85
|
super();
|
86
|
|
87
|
HTML title = new HTML("<h1 class=\"uk-article-title\">Previous validations</h1>");
|
88
|
title.addStyleName("uk-margin-medium-bottom");
|
89
|
contentPanel.add(title);
|
90
|
|
91
|
contentPanel.add(myHistoryListBoxContent);
|
92
|
|
93
|
errorAlert.setType(AlertType.DANGER);
|
94
|
errorAlert.setVisible(false);
|
95
|
errorAlert.setDismissable(false);
|
96
|
myHistoryListBoxContent.add(errorAlert);
|
97
|
|
98
|
successAlert.setType(AlertType.SUCCESS);
|
99
|
successAlert.setVisible(false);
|
100
|
successAlert.setDismissable(false);
|
101
|
myHistoryListBoxContent.add(successAlert);
|
102
|
|
103
|
warningAlert.setType(AlertType.WARNING);
|
104
|
warningAlert.setVisible(false);
|
105
|
warningAlert.setDismissable(false);
|
106
|
myHistoryListBoxContent.add(warningAlert);
|
107
|
|
108
|
myHistoryListBoxContent.add(controlsPanel);
|
109
|
myHistoryListBoxContent.add(contentAndPagerPanel);
|
110
|
|
111
|
contentAndPagerPanel.addStyleName("contentAndPagerPanel");
|
112
|
|
113
|
// topPagerPanel.addStyleName("marginTop40");
|
114
|
|
115
|
resultsPagerTop.addStyleName("resultsPager");
|
116
|
// resultsPagerTop.setAligned(true);
|
117
|
// resultsPagerTop.setArrows(true);
|
118
|
resultsPagerTop.setAlignToSides(true);
|
119
|
resultsPagerTop.setPreviousIcon(IconType.LONG_ARROW_LEFT);
|
120
|
resultsPagerTop.setNextIcon(IconType.LONG_ARROW_RIGHT);
|
121
|
// resultsPagerTop.setIPosition(IconPosition.RIGHT);
|
122
|
|
123
|
resultsPagerTop.addPreviousClickHandler(new ClickHandler() {
|
124
|
@Override
|
125
|
public void onClick(ClickEvent clickEvent) {
|
126
|
previousPage();
|
127
|
}
|
128
|
});
|
129
|
|
130
|
resultsPagerTop.addNextClickHandler(new ClickHandler() {
|
131
|
@Override
|
132
|
public void onClick(ClickEvent clickEvent) {
|
133
|
nextPage();
|
134
|
}
|
135
|
});
|
136
|
|
137
|
resultsPagerBottom.addStyleName("resultsPager");
|
138
|
// resultsPagerBottom.setAligned(true);
|
139
|
// resultsPagerBottom.setArrows(true);
|
140
|
resultsPagerBottom.setAlignToSides(true);
|
141
|
resultsPagerBottom.setPreviousIcon(IconType.LONG_ARROW_LEFT);
|
142
|
resultsPagerBottom.setNextIcon(IconType.LONG_ARROW_RIGHT);
|
143
|
// resultsPagerBottom.getRight().setIconPosition(IconPosition.RIGHT);
|
144
|
|
145
|
resultsPagerBottom.addPreviousClickHandler(new ClickHandler() {
|
146
|
@Override
|
147
|
public void onClick(ClickEvent clickEvent) {
|
148
|
previousPage();
|
149
|
}
|
150
|
});
|
151
|
|
152
|
resultsPagerBottom.addNextClickHandler(new ClickHandler() {
|
153
|
@Override
|
154
|
public void onClick(ClickEvent clickEvent) {
|
155
|
nextPage();
|
156
|
}
|
157
|
});
|
158
|
|
159
|
contentAndPagerPanel.add(topPagerPanel);
|
160
|
contentAndPagerPanel.add(jobsListContentPanel);
|
161
|
contentAndPagerPanel.add(bottomPagerPanel);
|
162
|
|
163
|
controlsPanel.addStyleName("uk-grid");
|
164
|
controlsPanel.addStyleName("page-controls");
|
165
|
|
166
|
validationJobTypesListBox.addItem("-- none selected --", "noneSelected");
|
167
|
validationJobTypesListBox.addItem(Constants.VALIDATION_JOB_TYPE_COMPATIBILITY_TEST, Constants.VALIDATION_JOB_TYPE_COMPATIBILITY_TEST);
|
168
|
validationJobTypesListBox.addItem(Constants.VALIDATION_JOB_TYPE_REGISTRATION_REQUEST, Constants.VALIDATION_JOB_TYPE_REGISTRATION_REQUEST);
|
169
|
validationJobTypesListBox.addItem(Constants.VALIDATION_JOB_TYPE_WORKFLOW_REQUEST, Constants.VALIDATION_JOB_TYPE_WORKFLOW_REQUEST);
|
170
|
validationJobTypesListBox.addChangeHandler(new ChangeHandler() {
|
171
|
@Override
|
172
|
public void onChange(ChangeEvent event) {
|
173
|
|
174
|
jobTypeSelectedIndex = validationJobTypesListBox.getSelectedIndex();
|
175
|
|
176
|
String validationType = null;
|
177
|
if(!validationJobTypesListBox.getSelectedValue().equals("noneSelected"))
|
178
|
validationType = validationJobTypesListBox.getSelectedValue();
|
179
|
|
180
|
String jobStatus = null;
|
181
|
if(!jobStatusSelected.equals("all"))
|
182
|
jobStatus = jobStatusSelected;
|
183
|
|
184
|
getStoredJobs(RepositoryManager.currentUser.getEmail(), validationType, 0,
|
185
|
Integer.parseInt(jobsPerPageListBox.getSelectedValue()), null, null, jobStatus, true);
|
186
|
|
187
|
currentPage = 1;
|
188
|
}
|
189
|
});
|
190
|
|
191
|
jobsPerPageListBox.addItem("10", "10");
|
192
|
jobsPerPageListBox.addItem("25", "25");
|
193
|
jobsPerPageListBox.addItem("50", "50");
|
194
|
jobsPerPageListBox.addItem("100", "100");
|
195
|
jobsPerPageListBox.addChangeHandler(new ChangeHandler() {
|
196
|
@Override
|
197
|
public void onChange(ChangeEvent event) {
|
198
|
|
199
|
jobsPerPageSelectedIndex = jobsPerPageListBox.getSelectedIndex();
|
200
|
|
201
|
String validationType = null;
|
202
|
if(!validationJobTypesListBox.getSelectedValue().equals("noneSelected"))
|
203
|
validationType = validationJobTypesListBox.getSelectedValue();
|
204
|
|
205
|
String jobStatus = null;
|
206
|
if(!jobStatusSelected.equals("all"))
|
207
|
jobStatus = jobStatusSelected;
|
208
|
|
209
|
getStoredJobs(RepositoryManager.currentUser.getEmail(), validationType, 0,
|
210
|
Integer.parseInt(jobsPerPageListBox.getSelectedValue()), null, null, jobStatus, true);
|
211
|
|
212
|
currentPage = 1;
|
213
|
}
|
214
|
});
|
215
|
}
|
216
|
|
217
|
@Override
|
218
|
public void clear() {
|
219
|
|
220
|
errorAlert.setVisible(false);
|
221
|
successAlert.setVisible(false);
|
222
|
warningAlert.setVisible(false);
|
223
|
|
224
|
controlsPanel.clear();
|
225
|
topPagerPanel.clear();
|
226
|
jobsListContentPanel.clear();
|
227
|
bottomPagerPanel.clear();
|
228
|
gridPanel.remove(helpPanel);
|
229
|
|
230
|
validationJobTypesListBox.setSelectedIndex(0);
|
231
|
jobsPerPageListBox.setSelectedIndex(0);
|
232
|
|
233
|
jobTypeSelectedIndex = 0;
|
234
|
jobsPerPageSelectedIndex = 0;
|
235
|
jobStatusSelected = "all";
|
236
|
currentPage = 1;
|
237
|
|
238
|
jobsOfUser = null;
|
239
|
}
|
240
|
|
241
|
@Override
|
242
|
public void reload() {
|
243
|
|
244
|
Document.get().getElementById("headerNoTransparent").removeClassName("tm-header-transparent");
|
245
|
helpService.getHelpById(parentToken, new HelpCallback(helpPanel, gridPanel));
|
246
|
|
247
|
getStoredJobs(RepositoryManager.currentUser.getEmail(), null, 0, 10, null, null, null, true);
|
248
|
}
|
249
|
|
250
|
@Override
|
251
|
public void setToken(String parentToken, String rest) {
|
252
|
this.parentToken = parentToken;
|
253
|
this.restToken = rest;
|
254
|
}
|
255
|
|
256
|
@Override
|
257
|
public void afterAdditionToRootPanel() {
|
258
|
|
259
|
}
|
260
|
|
261
|
private void getStoredJobs(String user, String jobType, Integer offset, Integer limit, String dateFrom, String dateTo,
|
262
|
String jobStatus, boolean includeJobsTotal) {
|
263
|
|
264
|
errorAlert.setVisible(false);
|
265
|
successAlert.setVisible(false);
|
266
|
warningAlert.setVisible(false);
|
267
|
|
268
|
final HTML loadingWheel = new HTML("<div class=\"loader-big\" style=\"text-align: center; padding-top: 170px; " +
|
269
|
"color: rgb(47, 64, 80); font-weight: bold;\">Retrieving validation history...</div>" +
|
270
|
"<div class=\"whiteFilm\"></div>");
|
271
|
myHistoryListBoxContent.addStyleName("loading-big");
|
272
|
myHistoryListBoxContent.add(loadingWheel);
|
273
|
|
274
|
validationService.getJobsOfUser(user, jobType, offset, limit, dateFrom, dateTo, jobStatus, includeJobsTotal,
|
275
|
new AsyncCallback<JobsOfUser>() {
|
276
|
|
277
|
@Override
|
278
|
public void onFailure(Throwable caught) {
|
279
|
|
280
|
jobsOfUser = null;
|
281
|
|
282
|
myHistoryListBoxContent.removeStyleName("loading-big");
|
283
|
myHistoryListBoxContent.remove(loadingWheel);
|
284
|
|
285
|
errorAlert.setText("System error retrieving validation history.");
|
286
|
errorAlert.setVisible(true);
|
287
|
}
|
288
|
|
289
|
@Override
|
290
|
public void onSuccess(JobsOfUser jobsOfUser) {
|
291
|
|
292
|
BrowseHistoryWidget.this.jobsOfUser = jobsOfUser;
|
293
|
|
294
|
myHistoryListBoxContent.removeStyleName("loading-big");
|
295
|
myHistoryListBoxContent.remove(loadingWheel);
|
296
|
|
297
|
FlowPanel titleRowPanel = new FlowPanel();
|
298
|
titleRowPanel.addStyleName("row");
|
299
|
myHistoryListBoxContent.add(titleRowPanel);
|
300
|
|
301
|
// updateStoredJobs(true, null, null);
|
302
|
updateControls(jobsOfUser);
|
303
|
drawPager(topPagerPanel);
|
304
|
// drawTopPager();
|
305
|
updateContents(jobsOfUser.getJobs());
|
306
|
drawPager(bottomPagerPanel);
|
307
|
// drawBottomPager();
|
308
|
|
309
|
Window.scrollTo(0, 0);
|
310
|
}
|
311
|
});
|
312
|
}
|
313
|
|
314
|
private void updateControls(JobsOfUser jobsOfUser) {
|
315
|
|
316
|
controlsPanel.clear();
|
317
|
|
318
|
FlowPanel firstRowFilters = new FlowPanel();
|
319
|
firstRowFilters.addStyleName("uk-margin-bottom uk-width-1-1");
|
320
|
firstRowFilters.addStyleName("filters");
|
321
|
|
322
|
controlsPanel.add(firstRowFilters);
|
323
|
|
324
|
FlowPanel jobTypeSelection = new FlowPanel();
|
325
|
jobTypeSelection.addStyleName("links");
|
326
|
|
327
|
firstRowFilters.add(jobTypeSelection);
|
328
|
|
329
|
Label jobTypeFilterLabel = new Label("Filter by job type:");
|
330
|
jobTypeFilterLabel.addStyleName("filterLabel");
|
331
|
jobTypeSelection.add(jobTypeFilterLabel);
|
332
|
|
333
|
FlowPanel jobTypeFilterListBoxPanel = new FlowPanel();
|
334
|
jobTypeFilterListBoxPanel.addStyleName("inlineBlock");
|
335
|
validationJobTypesListBox.setSelectedIndex(jobTypeSelectedIndex);
|
336
|
jobTypeFilterListBoxPanel.add(validationJobTypesListBox);
|
337
|
jobTypeSelection.add(jobTypeFilterListBoxPanel);
|
338
|
|
339
|
FlowPanel secondRowFilters = new FlowPanel();
|
340
|
secondRowFilters.addStyleName("uk-margin-bottom uk-width-1-1");
|
341
|
secondRowFilters.addStyleName("filters");
|
342
|
|
343
|
controlsPanel.add(secondRowFilters);
|
344
|
|
345
|
FlowPanel links = new FlowPanel();
|
346
|
links.addStyleName("links uk-inline");
|
347
|
|
348
|
secondRowFilters.add(links);
|
349
|
|
350
|
Label filterLabel = new Label("Filter validation jobs:");
|
351
|
filterLabel.addStyleName("filterLabel");
|
352
|
links.add(filterLabel);
|
353
|
|
354
|
final Anchor allJobsLink = new Anchor();
|
355
|
allJobsLink.setText("All Jobs (" + jobsOfUser.getTotalJobs() + ")");
|
356
|
if(jobStatusSelected.equals("all"))
|
357
|
allJobsLink.addStyleName("active");
|
358
|
links.add(allJobsLink);
|
359
|
|
360
|
final Anchor successfulQuestionsLink = new Anchor();
|
361
|
successfulQuestionsLink.setText(Constants.VALIDATION_JOB_STATUS_SUCCESSFUL + " (" + jobsOfUser.getTotalJobsSuccessful() + ")");
|
362
|
if(jobStatusSelected.equals(Constants.VALIDATION_JOB_STATUS_SUCCESSFUL))
|
363
|
successfulQuestionsLink.addStyleName("active");
|
364
|
links.add(successfulQuestionsLink);
|
365
|
|
366
|
final Anchor failedQuestionsLink = new Anchor();
|
367
|
failedQuestionsLink.setText(Constants.VALIDATION_JOB_STATUS_FAILED + " (" + jobsOfUser.getTotalJobsFailed() + ")");
|
368
|
if(jobStatusSelected.equals(Constants.VALIDATION_JOB_STATUS_FAILED))
|
369
|
failedQuestionsLink.addStyleName("active");
|
370
|
links.add(failedQuestionsLink);
|
371
|
|
372
|
final Anchor pendingQuestionsLink = new Anchor();
|
373
|
pendingQuestionsLink.setText(Constants.VALIDATION_JOB_STATUS_ONGOING + " (" + jobsOfUser.getTotalJobsOngoing() + ")");
|
374
|
if(jobStatusSelected.equals(Constants.VALIDATION_JOB_STATUS_ONGOING))
|
375
|
pendingQuestionsLink.addStyleName("active");
|
376
|
links.add(pendingQuestionsLink);
|
377
|
|
378
|
allJobsLink.addClickHandler(new ClickHandler() {
|
379
|
@Override
|
380
|
public void onClick(ClickEvent event) {
|
381
|
|
382
|
jobStatusSelected = "all";
|
383
|
|
384
|
allJobsLink.addStyleName("active");
|
385
|
successfulQuestionsLink.removeStyleName("active");
|
386
|
failedQuestionsLink.removeStyleName("active");
|
387
|
pendingQuestionsLink.removeStyleName("active");
|
388
|
|
389
|
String validationType = null;
|
390
|
if(!validationJobTypesListBox.getSelectedValue().equals("noneSelected"))
|
391
|
validationType = validationJobTypesListBox.getSelectedValue();
|
392
|
getStoredJobs(RepositoryManager.currentUser.getEmail(), validationType, 0,
|
393
|
Integer.parseInt(jobsPerPageListBox.getSelectedValue()), null, null, null, true);
|
394
|
|
395
|
currentPage = 1;
|
396
|
// updateContents(allMatchingNews);
|
397
|
}
|
398
|
});
|
399
|
|
400
|
successfulQuestionsLink.addClickHandler(new ClickHandler() {
|
401
|
@Override
|
402
|
public void onClick(ClickEvent event) {
|
403
|
|
404
|
jobStatusSelected = Constants.VALIDATION_JOB_STATUS_SUCCESSFUL;
|
405
|
|
406
|
allJobsLink.removeStyleName("active");
|
407
|
successfulQuestionsLink.addStyleName("active");
|
408
|
failedQuestionsLink.removeStyleName("active");
|
409
|
pendingQuestionsLink.removeStyleName("active");
|
410
|
|
411
|
String validationType = null;
|
412
|
if(!validationJobTypesListBox.getSelectedValue().equals("noneSelected"))
|
413
|
validationType = validationJobTypesListBox.getSelectedValue();
|
414
|
getStoredJobs(RepositoryManager.currentUser.getEmail(), validationType, 0,
|
415
|
Integer.parseInt(jobsPerPageListBox.getSelectedValue()), null, null, jobStatusSelected, true);
|
416
|
|
417
|
currentPage = 1;
|
418
|
// updateContents(inactiveMatchingNews);
|
419
|
}
|
420
|
});
|
421
|
|
422
|
failedQuestionsLink.addClickHandler(new ClickHandler() {
|
423
|
@Override
|
424
|
public void onClick(ClickEvent event) {
|
425
|
|
426
|
jobStatusSelected = Constants.VALIDATION_JOB_STATUS_FAILED;
|
427
|
|
428
|
allJobsLink.removeStyleName("active");
|
429
|
successfulQuestionsLink.removeStyleName("active");
|
430
|
failedQuestionsLink.addStyleName("active");
|
431
|
pendingQuestionsLink.removeStyleName("active");
|
432
|
|
433
|
String validationType = null;
|
434
|
if(!validationJobTypesListBox.getSelectedValue().equals("noneSelected"))
|
435
|
validationType = validationJobTypesListBox.getSelectedValue();
|
436
|
getStoredJobs(RepositoryManager.currentUser.getEmail(), validationType, 0,
|
437
|
Integer.parseInt(jobsPerPageListBox.getSelectedValue()), null, null, jobStatusSelected, true);
|
438
|
|
439
|
currentPage = 1;
|
440
|
// updateContents(activeMatchingNews);
|
441
|
}
|
442
|
});
|
443
|
|
444
|
pendingQuestionsLink.addClickHandler(new ClickHandler() {
|
445
|
@Override
|
446
|
public void onClick(ClickEvent event) {
|
447
|
|
448
|
jobStatusSelected = Constants.VALIDATION_JOB_STATUS_ONGOING;
|
449
|
|
450
|
allJobsLink.removeStyleName("active");
|
451
|
successfulQuestionsLink.removeStyleName("active");
|
452
|
failedQuestionsLink.removeStyleName("active");
|
453
|
pendingQuestionsLink.addStyleName("active");
|
454
|
|
455
|
String validationType = null;
|
456
|
if(!validationJobTypesListBox.getSelectedValue().equals("noneSelected"))
|
457
|
validationType = validationJobTypesListBox.getSelectedValue();
|
458
|
getStoredJobs(RepositoryManager.currentUser.getEmail(), validationType, 0,
|
459
|
Integer.parseInt(jobsPerPageListBox.getSelectedValue()), null, null, jobStatusSelected, true);
|
460
|
|
461
|
currentPage = 1;
|
462
|
// updateContents(inactiveMatchingNews);
|
463
|
}
|
464
|
});
|
465
|
|
466
|
FlowPanel actions = new FlowPanel();
|
467
|
actions.addStyleName("show-options uk-inline");
|
468
|
|
469
|
secondRowFilters.add(actions);
|
470
|
|
471
|
Label jobsPerPageFilterLabel = new Label("Jobs per page:");
|
472
|
jobsPerPageFilterLabel.addStyleName("filterLabel");
|
473
|
actions.add(jobsPerPageFilterLabel);
|
474
|
|
475
|
FlowPanel jobsPerPageListBoxPanel = new FlowPanel();
|
476
|
jobsPerPageListBoxPanel.addStyleName("inlineBlock");
|
477
|
jobsPerPageListBox.setSelectedIndex(jobsPerPageSelectedIndex);
|
478
|
jobsPerPageListBoxPanel.add(jobsPerPageListBox);
|
479
|
actions.add(jobsPerPageListBoxPanel);
|
480
|
|
481
|
}
|
482
|
|
483
|
// public void updateContents(List<StoredJob> storedJobs) {
|
484
|
//
|
485
|
// jobsListContentPanel.clear();
|
486
|
//
|
487
|
// String contents = "<div class=\"table-responsive jobs-table\"><table class=\"table jobs-list row\">" +
|
488
|
// "<tr class=\"row job\">" +
|
489
|
// "<th class=\"header\">Validation Type</th>" +
|
490
|
// "<th class=\"header\">Status</th>" +
|
491
|
// "<th class=\"header\">Score</th>" +
|
492
|
//// "<th class=\"header\">User</th>" +
|
493
|
// "<th class=\"header\">Started</th>" +
|
494
|
//// "<th class=\"header\">Duration</th>" +
|
495
|
// "<th class=\"header\">Repository</th>" +
|
496
|
// "<th class=\"header\">Guidelines</th>" +
|
497
|
// "<th class=\"header\">Actions</th>" +
|
498
|
// "<th class=\"header\"></th>" +
|
499
|
// "</tr>" ;
|
500
|
//
|
501
|
// if(storedJobs==null || storedJobs.size()==0) {
|
502
|
//
|
503
|
// contents += "<tr class=\"row job\">" +
|
504
|
// "<td colspan=\"10\"><div class=\"alert alert-warning\">No stored jobs found</div></td>" +
|
505
|
// "</tr>";
|
506
|
//
|
507
|
// } else {
|
508
|
//
|
509
|
// int counter = 1;
|
510
|
// for (StoredJob storedJob : storedJobs) {
|
511
|
//
|
512
|
// String parity = "";
|
513
|
// if(counter%2==1)
|
514
|
// parity = "odd";
|
515
|
// else
|
516
|
// parity = "even";
|
517
|
//
|
518
|
// if(storedJob.getValidationType().equals("CU")) {
|
519
|
//
|
520
|
// contents += "<tr class=\"row job " + parity + "\">" +
|
521
|
// "<td><div class=\"type\">OAI Content</div></td>" +
|
522
|
// "<td><div class=\"status\">" + storedJob.getContentJobStatus() + "</div></td>" +
|
523
|
// "<td><div class=\"score\">" + storedJob.getContentJobScore() + "</div></td>" +
|
524
|
//// "<td rowspan=\"2\"><div class=\"user\">" + storedJob.getUserEmail() + "</div></td>" +
|
525
|
// "<td rowspan=\"2\"><div class=\"started\">" + storedJob.getStarted() + "</div></td>" +
|
526
|
//// "<td rowspan=\"2\"><div class=\"duration\">" + storedJob.getDuration() + "</div></td>" +
|
527
|
// "<td rowspan=\"2\"><div class=\"repository\">" + storedJob.getBaseUrl() + "</div></td>" +
|
528
|
// "<td rowspan=\"2\"><div class=\"guidelines\">" + storedJob.getGuidelinesShortName() + "</div></td>";
|
529
|
//
|
530
|
//
|
531
|
// contents += "<td rowspan=\"2\"><div class=\"actions\" href=\"#\">" +
|
532
|
// "<div class=\"viewDetailsLinkWrapper\"><a href=\"#" + parentToken + "/" + storedJob.getId() + "\" id=\"" + storedJob.getId() +
|
533
|
// "#viewDetails\" class=\"viewDetails\">View Results<i class=\"fa fa-info\"></i><i class=\"fa fa-angle-right\"></i></a></div>" +
|
534
|
// "<div><a id=\"" + storedJob.getId() + "#resubmit\" class=\"uk-button uk-button-primary resubmitJob\"><i></i>Resubmit</a></div>" +
|
535
|
// "</div></td>";
|
536
|
//
|
537
|
// if(storedJob.getValidationStatus().equals(Constants.VALIDATION_JOB_STATUS_SUCCESSFUL))
|
538
|
// contents += "<td rowspan=\"2\"><input width=\"20\" type=\"image\" height=\"20\" " +
|
539
|
// "title=\"Successfull\" src=\"img/check-icon.png\"></td>";
|
540
|
// else if(storedJob.getValidationStatus().equals(Constants.VALIDATION_JOB_STATUS_FAILED))
|
541
|
// contents += "<td rowspan=\"2\"><input width=\"20\" type=\"image\" height=\"20\" " +
|
542
|
// "title=\"Successfull\" src=\"img/x-icon.png\"></td>";
|
543
|
//// else
|
544
|
//// contents += "<td rowspan=\"2\"><input width=\"20\" type=\"image\" height=\"20\" " +
|
545
|
//// "title=\"Successfull\" src=\"img/check-icon.png\"></td>";
|
546
|
//
|
547
|
// contents += "</tr>";
|
548
|
//
|
549
|
// contents += "<tr class=\"row job " + parity + "\">" +
|
550
|
// "<td><div class=\"type\">OAI Usage</div></td>" +
|
551
|
// "<td><div class=\"status\">" + storedJob.getUsageJobStatus() + "</div></td>" +
|
552
|
// "<td><div class=\"score\">" + storedJob.getUsageJobScore() + "</div></td></tr>" ;
|
553
|
//
|
554
|
// } else if(storedJob.getValidationType().equals("C")) {
|
555
|
//
|
556
|
// contents += "<tr class=\"row job " + parity + "\">" +
|
557
|
// "<td><div class=\"type\">OAI Content</div></td>" +
|
558
|
// "<td><div class=\"status\">" + storedJob.getContentJobStatus() + "</div></td>" +
|
559
|
// "<td><div class=\"score\">" + storedJob.getContentJobScore() + "</div></td>" +
|
560
|
//// "<td><div class=\"user\">" + storedJob.getUserEmail() + "</div></td>" +
|
561
|
// "<td><div class=\"started\">" + storedJob.getStarted() + "</div></td>" +
|
562
|
//// "<td><div class=\"duration\">" + storedJob.getDuration() + "</div></td>" +
|
563
|
// "<td><div class=\"repository\">" + storedJob.getBaseUrl() + "</div></td>" +
|
564
|
// "<td><div class=\"guidelines\">" + storedJob.getGuidelinesShortName() + "</div></td>";
|
565
|
//
|
566
|
//
|
567
|
// contents += "<td><div class=\"actions\" href=\"#\">" +
|
568
|
// "<div class=\"viewDetailsLinkWrapper\"><a href=\"#" + parentToken + "/" + storedJob.getId() + "\" id=\"" + storedJob.getId() +
|
569
|
// "#viewDetails\" class=\"viewDetails\">View Results<i class=\"fa fa-info\"></i><i class=\"fa fa-angle-right\"></i></a></div>" +
|
570
|
// "<div><a id=\"" + storedJob.getId() + "#resubmit\" class=\"uk-button uk-button-primary resubmitJob\"><i></i>Resubmit</a></div>" +
|
571
|
// "</div></td>";
|
572
|
//
|
573
|
// if(storedJob.getValidationStatus().equals(Constants.VALIDATION_JOB_STATUS_SUCCESSFUL))
|
574
|
// contents += "<td><input width=\"20\" type=\"image\" height=\"20\" " +
|
575
|
// "title=\"Successfull\" src=\"img/check-icon.png\"></td>";
|
576
|
// else if(storedJob.getValidationStatus().equals(Constants.VALIDATION_JOB_STATUS_FAILED))
|
577
|
// contents += "<td><input width=\"20\" type=\"image\" height=\"20\" " +
|
578
|
// "title=\"Successfull\" src=\"img/x-icon.png\"></td>";
|
579
|
//// else
|
580
|
//// contents += "<td><input width=\"20\" type=\"image\" height=\"20\" " +
|
581
|
//// "title=\"Successfull\" src=\"img/check-icon.png\"></td>";
|
582
|
//
|
583
|
// contents += "</tr>";
|
584
|
//
|
585
|
// } else {
|
586
|
//
|
587
|
// contents += "<tr class=\"row job " + parity + "\">" +
|
588
|
// "<td><div class=\"type\">OAI Usage</div></td>" +
|
589
|
// "<td><div class=\"status\">" + storedJob.getUsageJobStatus() + "</div></td>" +
|
590
|
// "<td><div class=\"score\">" + storedJob.getUsageJobScore() + "</div></td>" +
|
591
|
//// "<td><div class=\"user\">" + storedJob.getUserEmail() + "</div></td>" +
|
592
|
// "<td><div class=\"started\">" + storedJob.getStarted() + "</div></td>" +
|
593
|
//// "<td><div class=\"duration\">" + storedJob.getDuration() + "</div></td>" +
|
594
|
// "<td><div class=\"repository\">" + storedJob.getBaseUrl() + "</div></td>" +
|
595
|
// "<td><div class=\"guidelines\">" + storedJob.getGuidelinesShortName() + "</div></td>";
|
596
|
//
|
597
|
//
|
598
|
// contents += "<td><div class=\"actions\" href=\"#\">" +
|
599
|
// "<div class=\"viewDetailsLinkWrapper\"><a href=\"#" + parentToken + "/" + storedJob.getId() + "\" id=\"" + storedJob.getId() +
|
600
|
// "#viewDetails\" class=\"viewDetails\">View Results<i class=\"fa fa-info\"></i><i class=\"fa fa-angle-right\"></i></a></div>" +
|
601
|
// "<div><a id=\"" + storedJob.getId() + "#resubmit\" class=\"uk-button uk-button-primary resubmitJob\"><i></i>Resubmit</a></div>" +
|
602
|
// "</div></td>";
|
603
|
//
|
604
|
// if(storedJob.getValidationStatus().equals(Constants.VALIDATION_JOB_STATUS_SUCCESSFUL))
|
605
|
// contents += "<td><input width=\"20\" type=\"image\" height=\"20\" " +
|
606
|
// "title=\"Successfull\" src=\"img/check-icon.png\"></td>";
|
607
|
// else if(storedJob.getValidationStatus().equals(Constants.VALIDATION_JOB_STATUS_FAILED))
|
608
|
// contents += "<td><input width=\"20\" type=\"image\" height=\"20\" " +
|
609
|
// "title=\"Successfull\" src=\"img/x-icon.png\"></td>";
|
610
|
//// else
|
611
|
//// contents += "<td><input width=\"20\" type=\"image\" height=\"20\" " +
|
612
|
//// "title=\"Successfull\" src=\"img/check-icon.png\"></td>";
|
613
|
//
|
614
|
// contents += "</tr>";
|
615
|
// }
|
616
|
//
|
617
|
// counter++;
|
618
|
// }
|
619
|
// }
|
620
|
//
|
621
|
// contents += "</table></div>";
|
622
|
//
|
623
|
// HTML questionsList = new HTML();
|
624
|
// questionsList.setHTML(contents);
|
625
|
//
|
626
|
// jobsListContentPanel.add(questionsList);
|
627
|
//
|
628
|
// addHandlers();
|
629
|
//
|
630
|
// }
|
631
|
|
632
|
public void updateContents(List<StoredJob> storedJobs) {
|
633
|
|
634
|
jobsListContentPanel.clear();
|
635
|
|
636
|
String contents = "<div class=\"uk-overflow-auto uk-scrollspy-inview uk-animation-slide-top-medium uk-margin-top uk-margin-bottom\">" +
|
637
|
"<table class=\"uk-table uk-table-middle jobs-list\"><thead>" +
|
638
|
"<tr>" +
|
639
|
"<th class=\"\">Repository</th>" +
|
640
|
"<th class=\"\">Validation Type</th>" +
|
641
|
"<th class=\"\">Status</th>" +
|
642
|
"<th class=\"\">Score</th>" +
|
643
|
// "<th class=\"header\">User</th>" +
|
644
|
"<th class=\"\">Started</th>" +
|
645
|
// "<th class=\"header\">Duration</th>" +
|
646
|
"<th class=\"\">Guidelines</th>" +
|
647
|
"<th class=\"\">Actions</th>" +
|
648
|
"<th class=\"\"></th>" +
|
649
|
"</tr></thead>" ;
|
650
|
|
651
|
if(storedJobs==null || storedJobs.size()==0) {
|
652
|
|
653
|
contents += "<tbody><tr class=\"el-item\">" +
|
654
|
"<td colspan=\"10\"><div class=\"alert alert-warning\">No stored jobs found</div></td>" +
|
655
|
"</tr></tbody>";
|
656
|
|
657
|
} else {
|
658
|
|
659
|
contents += "<tbody>";
|
660
|
int counter = 1;
|
661
|
for (StoredJob storedJob : storedJobs) {
|
662
|
|
663
|
String parity = "";
|
664
|
if(counter%2==1)
|
665
|
parity = "odd";
|
666
|
else
|
667
|
parity = "even";
|
668
|
|
669
|
if(storedJob.getValidationType().equals("CU")) {
|
670
|
|
671
|
contents += "<tr class=\"el-item " + parity + "\">" +
|
672
|
"<td class=\"uk-table-shrink\" rowspan=\"2\"><div class=\"el-title\">" + storedJob.getBaseUrl() + "</div></td>" +
|
673
|
"<td class=\"uk-table-shrink\"><div class=\"el-title\">OAI Content</div></td>" +
|
674
|
"<td class=\"uk-table-shrink\"><div class=\"el-title\">" + storedJob.getContentJobStatus() + "</div></td>" +
|
675
|
"<td class=\"uk-table-shrink\"><div class=\"el-title\">" + storedJob.getContentJobScore() + "</div></td>" +
|
676
|
// "<td rowspan=\"2\"><div class=\"user\">" + storedJob.getUserEmail() + "</div></td>" +
|
677
|
"<td class=\"uk-table-shrink\" rowspan=\"2\"><div class=\"el-title\">" + storedJob.getStarted() + "</div></td>" +
|
678
|
// "<td rowspan=\"2\"><div class=\"duration\">" + storedJob.getDuration() + "</div></td>" +
|
679
|
"<td class=\"uk-table-shrink\" rowspan=\"2\"><div class=\"el-title\">" + storedJob.getGuidelinesShortName() + "</div></td>";
|
680
|
|
681
|
|
682
|
contents += "<td class=\"uk-table-shrink\" rowspan=\"2\"><div class=\"el-link actions\" href=\"#\">" +
|
683
|
"<div class=\"viewDetailsLinkWrapper\"><a href=\"#" + parentToken + "/" + storedJob.getId() + "\" id=\"" + storedJob.getId() +
|
684
|
"#viewDetails\" class=\"viewDetails\">View Results<i class=\"fa fa-angle-right\"></i></a></div>" +
|
685
|
"<div><a id=\"" + storedJob.getId() + "#resubmit\" class=\"resubmitJob\">Resubmit<i class=\"fa fa-repeat\" aria-hidden=\"true\"></i>" +
|
686
|
"</a></div>" +
|
687
|
"</div></td>";
|
688
|
|
689
|
if(storedJob.getValidationStatus().equals(Constants.VALIDATION_JOB_STATUS_SUCCESSFUL))
|
690
|
contents += "<td class=\"uk-table-shrink\" rowspan=\"2\"><input width=\"20\" type=\"image\" height=\"20\" " +
|
691
|
"title=\"Successfull\" src=\"img/icon_colours-check.jpg\"></td>";
|
692
|
else if(storedJob.getValidationStatus().equals(Constants.VALIDATION_JOB_STATUS_FAILED))
|
693
|
contents += "<td class=\"uk-table-shrink\" rowspan=\"2\"><input width=\"20\" type=\"image\" height=\"20\" " +
|
694
|
"title=\"Successfull\" src=\"img/icon_colours-x.jpg\"></td>";
|
695
|
else if(storedJob.getValidationStatus().equals(Constants.VALIDATION_JOB_STATUS_ONGOING))
|
696
|
contents += "<td class=\"uk-table-shrink\" rowspan=\"2\"><input width=\"20\" type=\"image\" height=\"20\" " +
|
697
|
"title=\"Ongoing\" src=\"img/icon_colours-question.jpg\"></td>";
|
698
|
// else
|
699
|
// contents += "<td rowspan=\"2\"><input width=\"20\" type=\"image\" height=\"20\" " +
|
700
|
// "title=\"Successfull\" src=\"img/check-icon.png\"></td>";
|
701
|
|
702
|
contents += "</tr>";
|
703
|
|
704
|
contents += "<tr class=\"el-item " + parity + "\">" +
|
705
|
"<td class=\"uk-table-shrink\"><div class=\"el-title\">OAI Usage</div></td>" +
|
706
|
"<td class=\"uk-table-shrink\"><div class=\"el-title\">" + storedJob.getUsageJobStatus() + "</div></td>" +
|
707
|
"<td class=\"uk-table-shrink\"><div class=\"el-title\">" + storedJob.getUsageJobScore() + "</div></td></tr>" ;
|
708
|
|
709
|
} else if(storedJob.getValidationType().equals("C")) {
|
710
|
|
711
|
contents += "<tr class=\"el-item " + parity + "\">" +
|
712
|
"<td class=\"uk-table-shrink\"><div class=\"el-title\">OAI Content</div></td>" +
|
713
|
"<td class=\"uk-table-shrink\"><div class=\"el-title\">" + storedJob.getContentJobStatus() + "</div></td>" +
|
714
|
"<td class=\"uk-table-shrink\"><div class=\"el-title\">" + storedJob.getContentJobScore() + "</div></td>" +
|
715
|
// "<td><div class=\"user\">" + storedJob.getUserEmail() + "</div></td>" +
|
716
|
"<td class=\"uk-table-shrink\"><div class=\"el-title\">" + storedJob.getStarted() + "</div></td>" +
|
717
|
// "<td><div class=\"duration\">" + storedJob.getDuration() + "</div></td>" +
|
718
|
"<td class=\"uk-table-shrink\"><div class=\"el-title\">" + storedJob.getBaseUrl() + "</div></td>" +
|
719
|
"<td class=\"uk-table-shrink\"><div class=\"el-title\">" + storedJob.getGuidelinesShortName() + "</div></td>";
|
720
|
|
721
|
|
722
|
contents += "<td class=\"uk-table-shrink\"><div class=\"el-link\" href=\"#\">" +
|
723
|
"<div class=\"viewDetailsLinkWrapper\"><a href=\"#" + parentToken + "/" + storedJob.getId() + "\" id=\"" + storedJob.getId() +
|
724
|
"#viewDetails\" class=\"viewDetails\">View Results<i class=\"fa fa-info\"></i><i class=\"fa fa-angle-right\"></i></a></div>" +
|
725
|
"<div><a id=\"" + storedJob.getId() + "#resubmit\" class=\"uk-button uk-button-primary resubmitJob\"><i></i>Resubmit</a></div>" +
|
726
|
"</div></td>";
|
727
|
|
728
|
if(storedJob.getValidationStatus().equals(Constants.VALIDATION_JOB_STATUS_SUCCESSFUL))
|
729
|
contents += "<td class=\"uk-table-shrink\"><input width=\"20\" type=\"image\" height=\"20\" " +
|
730
|
"title=\"Successfull\" src=\"img/check-icon.png\"></td>";
|
731
|
else if(storedJob.getValidationStatus().equals(Constants.VALIDATION_JOB_STATUS_FAILED))
|
732
|
contents += "<td class=\"uk-table-shrink\"><input width=\"20\" type=\"image\" height=\"20\" " +
|
733
|
"title=\"Successfull\" src=\"img/x-icon.png\"></td>";
|
734
|
// else
|
735
|
// contents += "<td><input width=\"20\" type=\"image\" height=\"20\" " +
|
736
|
// "title=\"Successfull\" src=\"img/check-icon.png\"></td>";
|
737
|
|
738
|
contents += "</tr>";
|
739
|
|
740
|
} else {
|
741
|
|
742
|
contents += "<tr class=\"el-item " + parity + "\">" +
|
743
|
"<td class=\"uk-table-shrink\"><div class=\"el-title\">OAI Usage</div></td>" +
|
744
|
"<td class=\"uk-table-shrink\"><div class=\"el-title\">" + storedJob.getUsageJobStatus() + "</div></td>" +
|
745
|
"<td class=\"uk-table-shrink\"><div class=\"el-title\">" + storedJob.getUsageJobScore() + "</div></td>" +
|
746
|
// "<td><div class=\"user\">" + storedJob.getUserEmail() + "</div></td>" +
|
747
|
"<td class=\"uk-table-shrink\"><div class=\"el-title\">" + storedJob.getStarted() + "</div></td>" +
|
748
|
// "<td><div class=\"duration\">" + storedJob.getDuration() + "</div></td>" +
|
749
|
"<td class=\"uk-table-shrink\"><div class=\"el-title\">" + storedJob.getBaseUrl() + "</div></td>" +
|
750
|
"<td class=\"uk-table-shrink\"><div class=\"el-title\">" + storedJob.getGuidelinesShortName() + "</div></td>";
|
751
|
|
752
|
|
753
|
contents += "<td class=\"uk-table-shrink\"><div class=\"el-link\" href=\"#\">" +
|
754
|
"<div class=\"viewDetailsLinkWrapper\"><a href=\"#" + parentToken + "/" + storedJob.getId() + "\" id=\"" + storedJob.getId() +
|
755
|
"#viewDetails\" class=\"viewDetails\">View Results<i class=\"fa fa-info\"></i><i class=\"fa fa-angle-right\"></i></a></div>" +
|
756
|
"<div><a id=\"" + storedJob.getId() + "#resubmit\" class=\"uk-button uk-button-primary resubmitJob\"><i></i>Resubmit</a></div>" +
|
757
|
"</div></td>";
|
758
|
|
759
|
if(storedJob.getValidationStatus().equals(Constants.VALIDATION_JOB_STATUS_SUCCESSFUL))
|
760
|
contents += "<td class=\"uk-table-shrink\"><input width=\"20\" type=\"image\" height=\"20\" " +
|
761
|
"title=\"Successfull\" src=\"img/check-icon.png\"></td>";
|
762
|
else if(storedJob.getValidationStatus().equals(Constants.VALIDATION_JOB_STATUS_FAILED))
|
763
|
contents += "<td class=\"uk-table-shrink\"><input width=\"20\" type=\"image\" height=\"20\" " +
|
764
|
"title=\"Successfull\" src=\"img/x-icon.png\"></td>";
|
765
|
// else
|
766
|
// contents += "<td><input width=\"20\" type=\"image\" height=\"20\" " +
|
767
|
// "title=\"Successfull\" src=\"img/check-icon.png\"></td>";
|
768
|
|
769
|
contents += "</tr>";
|
770
|
}
|
771
|
|
772
|
counter++;
|
773
|
}
|
774
|
|
775
|
contents += "</tbody>";
|
776
|
}
|
777
|
|
778
|
contents += "</table></div>";
|
779
|
|
780
|
HTML questionsList = new HTML();
|
781
|
questionsList.setHTML(contents);
|
782
|
|
783
|
jobsListContentPanel.add(questionsList);
|
784
|
|
785
|
addHandlers();
|
786
|
|
787
|
}
|
788
|
|
789
|
private void addHandlers() {
|
790
|
|
791
|
$(".resubmitJob").click(new Function() {
|
792
|
|
793
|
public boolean f(Event e) {
|
794
|
|
795
|
errorAlert.setVisible(false);
|
796
|
successAlert.setVisible(false);
|
797
|
warningAlert.setVisible(false);
|
798
|
|
799
|
String[] idParts = $(e).get(0).getId().split("#");
|
800
|
final String storedJobId = idParts[0];
|
801
|
|
802
|
validationService.reSubmitValidationJob(Integer.parseInt(storedJobId), new AsyncCallback<Void>() {
|
803
|
|
804
|
@Override
|
805
|
public void onFailure(Throwable caught) {
|
806
|
errorAlert.setText("System error resubmitting job with id = " + storedJobId);
|
807
|
errorAlert.setVisible(true);
|
808
|
}
|
809
|
|
810
|
@Override
|
811
|
public void onSuccess(Void result) {
|
812
|
successAlert.setText("Job with id = " + storedJobId + " has been resubmitted successfully");
|
813
|
successAlert.setVisible(true);
|
814
|
}
|
815
|
});
|
816
|
|
817
|
return true;
|
818
|
}
|
819
|
});
|
820
|
}
|
821
|
|
822
|
private void drawPager(FlowPanel pagerPanel) {
|
823
|
|
824
|
pagerPanel.clear();
|
825
|
|
826
|
int totalNoOfPages = 0;
|
827
|
if(jobStatusSelected.equals("all"))
|
828
|
totalNoOfPages = (int) Math.ceil(jobsOfUser.getTotalJobs() / (Integer.parseInt(jobsPerPageListBox.getSelectedValue())*1.0));
|
829
|
else if(jobStatusSelected.equals(Constants.VALIDATION_JOB_STATUS_SUCCESSFUL))
|
830
|
totalNoOfPages = (int) Math.ceil(jobsOfUser.getTotalJobsSuccessful() / (Integer.parseInt(jobsPerPageListBox.getSelectedValue())*1.0));
|
831
|
else if(jobStatusSelected.equals(Constants.VALIDATION_JOB_STATUS_FAILED))
|
832
|
totalNoOfPages = (int) Math.ceil(jobsOfUser.getTotalJobsFailed() / (Integer.parseInt(jobsPerPageListBox.getSelectedValue())*1.0));
|
833
|
else
|
834
|
totalNoOfPages = (int) Math.ceil(jobsOfUser.getTotalJobsOngoing() / (Integer.parseInt(jobsPerPageListBox.getSelectedValue())*1.0));
|
835
|
|
836
|
UnorderedList pager = new UnorderedList();
|
837
|
pager.addStyleName("uk-pagination");
|
838
|
|
839
|
final ListItem listItemPrevious = new ListItem();
|
840
|
Anchor previous = new Anchor();
|
841
|
previous.setHTML("<span class=\"uk-margin-small-right\" uk-pagination-previous></span> Previous");
|
842
|
previous.addClickHandler(new ClickHandler() {
|
843
|
@Override
|
844
|
public void onClick(ClickEvent event) {
|
845
|
previousPage();
|
846
|
}
|
847
|
});
|
848
|
listItemPrevious.add(previous);
|
849
|
pager.add(listItemPrevious);
|
850
|
|
851
|
ListItem listItemNext = new ListItem();
|
852
|
listItemNext.addStyleName("uk-margin-auto-left");
|
853
|
Anchor next = new Anchor();
|
854
|
next.setHTML("Next <span class=\"uk-margin-small-left\" uk-pagination-next></span>");
|
855
|
next.addClickHandler(new ClickHandler() {
|
856
|
@Override
|
857
|
public void onClick(ClickEvent event) {
|
858
|
nextPage();
|
859
|
}
|
860
|
});
|
861
|
listItemNext.add(next);
|
862
|
pager.add(listItemNext);
|
863
|
|
864
|
|
865
|
if((currentPage-1)==0) {
|
866
|
previous.setEnabled(false);
|
867
|
listItemPrevious.addStyleName("uk-disabled");
|
868
|
} else {
|
869
|
previous.setEnabled(true);
|
870
|
listItemPrevious.removeStyleName("uk-disabled");
|
871
|
}
|
872
|
|
873
|
if(currentPage==totalNoOfPages) {
|
874
|
next.setEnabled(false);
|
875
|
listItemNext.addStyleName("uk-disabled");
|
876
|
} else {
|
877
|
next.setEnabled(true);
|
878
|
listItemNext.removeStyleName("uk-disabled");
|
879
|
}
|
880
|
|
881
|
pagerPanel.add(pager);
|
882
|
|
883
|
Label pageNumber = new Label();
|
884
|
|
885
|
pageNumber.setText("page " + currentPage + " of " + totalNoOfPages);
|
886
|
pageNumber.addStyleName("resultsPageLabel");
|
887
|
pagerPanel.add(pageNumber);
|
888
|
}
|
889
|
|
890
|
// private void drawTopPager() {
|
891
|
//
|
892
|
// int totalNoOfPages = 0;
|
893
|
// if(jobStatusSelected.equals("all"))
|
894
|
// totalNoOfPages = (int) Math.ceil(jobsOfUser.getTotalJobs() / (Integer.parseInt(jobsPerPageListBox.getSelectedValue())*1.0));
|
895
|
// else if(jobStatusSelected.equals(Constants.VALIDATION_JOB_STATUS_SUCCESSFUL))
|
896
|
// totalNoOfPages = (int) Math.ceil(jobsOfUser.getTotalJobsSuccessful() / (Integer.parseInt(jobsPerPageListBox.getSelectedValue())*1.0));
|
897
|
// else if(jobStatusSelected.equals(Constants.VALIDATION_JOB_STATUS_FAILED))
|
898
|
// totalNoOfPages = (int) Math.ceil(jobsOfUser.getTotalJobsFailed() / (Integer.parseInt(jobsPerPageListBox.getSelectedValue())*1.0));
|
899
|
// else
|
900
|
// totalNoOfPages = (int) Math.ceil(jobsOfUser.getTotalJobsOngoing() / (Integer.parseInt(jobsPerPageListBox.getSelectedValue())*1.0));
|
901
|
//
|
902
|
// if(currentPage ==1)
|
903
|
// resultsPagerTop.setPreviousEnabled(false);
|
904
|
// else
|
905
|
// resultsPagerTop.setPreviousEnabled(true);
|
906
|
//
|
907
|
// if(currentPage ==totalNoOfPages)
|
908
|
// resultsPagerTop.setNextEnabled(false);
|
909
|
// else
|
910
|
// resultsPagerTop.setNextEnabled(true);
|
911
|
//
|
912
|
// topPagerPanel.add(resultsPagerTop);
|
913
|
//
|
914
|
// pageNumberTop.setText("page " + currentPage + " of " + totalNoOfPages);
|
915
|
// pageNumberTop.addStyleName("resultsPageLabel");
|
916
|
// topPagerPanel.add(pageNumberTop);
|
917
|
// }
|
918
|
//
|
919
|
// private void drawBottomPager() {
|
920
|
//
|
921
|
// int totalNoOfPages = 0;
|
922
|
// if(jobStatusSelected.equals("all"))
|
923
|
// totalNoOfPages = (int) Math.ceil(jobsOfUser.getTotalJobs() / (Integer.parseInt(jobsPerPageListBox.getSelectedValue())*1.0));
|
924
|
// else if(jobStatusSelected.equals(Constants.VALIDATION_JOB_STATUS_SUCCESSFUL))
|
925
|
// totalNoOfPages = (int) Math.ceil(jobsOfUser.getTotalJobsSuccessful() / (Integer.parseInt(jobsPerPageListBox.getSelectedValue())*1.0));
|
926
|
// else if(jobStatusSelected.equals(Constants.VALIDATION_JOB_STATUS_FAILED))
|
927
|
// totalNoOfPages = (int) Math.ceil(jobsOfUser.getTotalJobsFailed() / (Integer.parseInt(jobsPerPageListBox.getSelectedValue())*1.0));
|
928
|
// else
|
929
|
// totalNoOfPages = (int) Math.ceil(jobsOfUser.getTotalJobsOngoing() / (Integer.parseInt(jobsPerPageListBox.getSelectedValue())*1.0));
|
930
|
//
|
931
|
// if(currentPage==1)
|
932
|
// resultsPagerBottom.setPreviousEnabled(false);
|
933
|
// else
|
934
|
// resultsPagerBottom.setPreviousEnabled(true);
|
935
|
//
|
936
|
// if(currentPage==totalNoOfPages)
|
937
|
// resultsPagerBottom.setNextEnabled(false);
|
938
|
// else
|
939
|
// resultsPagerBottom.setNextEnabled(true);
|
940
|
//
|
941
|
// bottomPagerPanel.add(resultsPagerBottom);
|
942
|
//
|
943
|
// pageNumberBottom.setText("page " + currentPage + " of " + totalNoOfPages);
|
944
|
// pageNumberBottom.addStyleName("resultsPageLabel");
|
945
|
// bottomPagerPanel.add(pageNumberBottom);
|
946
|
// }
|
947
|
|
948
|
private void previousPage() {
|
949
|
|
950
|
String validationType = null;
|
951
|
if(!validationJobTypesListBox.getSelectedValue().equals("noneSelected"))
|
952
|
validationType = validationJobTypesListBox.getSelectedValue();
|
953
|
|
954
|
String jobStatus = null;
|
955
|
if(!jobStatusSelected.equals("all"))
|
956
|
jobStatus = jobStatusSelected;
|
957
|
|
958
|
currentPage--;
|
959
|
int limit = Integer.parseInt(jobsPerPageListBox.getSelectedValue());
|
960
|
int offset = (currentPage - 1) * limit;
|
961
|
|
962
|
getStoredJobs(RepositoryManager.currentUser.getEmail(), validationType, offset,
|
963
|
limit, null, null, jobStatus, true);
|
964
|
}
|
965
|
|
966
|
private void nextPage() {
|
967
|
|
968
|
String validationType = null;
|
969
|
if(!validationJobTypesListBox.getSelectedValue().equals("noneSelected"))
|
970
|
validationType = validationJobTypesListBox.getSelectedValue();
|
971
|
|
972
|
String jobStatus = null;
|
973
|
if(!jobStatusSelected.equals("all"))
|
974
|
jobStatus = jobStatusSelected;
|
975
|
|
976
|
currentPage++;
|
977
|
int limit = Integer.parseInt(jobsPerPageListBox.getSelectedValue());
|
978
|
int offset = (currentPage - 1) * limit;
|
979
|
|
980
|
getStoredJobs(RepositoryManager.currentUser.getEmail(), validationType, offset,
|
981
|
limit, null, null, jobStatus, true);
|
982
|
}
|
983
|
}
|