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