Skip to content

Commit 6b12a14

Browse files
authored
Merge pull request #120 from bekk/sort-by-id-add-limit
Sort logs by ID instead of task_finished. Add customizable limit.
2 parents 8508368 + 2aece06 commit 6b12a14

File tree

11 files changed

+101
-156
lines changed

11 files changed

+101
-156
lines changed

README.md

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
# DB Scheduler UI
2+
23
![build status](https://github.com/bekk/db-scheduler-ui/workflows/Build/badge.svg)
34
[![License](http://img.shields.io/:license-apache-brightgreen.svg)](http://www.apache.org/licenses/LICENSE-2.0.html)
45

5-
6-
A UI extension for [db-scheduler](https://github.com/kagkarlsson/db-scheduler) that provides a browser accessible
6+
A UI extension for [db-scheduler](https://github.com/kagkarlsson/db-scheduler) that provides a browser accessible
77
dashboard for monitoring and basic administration of tasks.
88

9-
109
## Features
1110

1211
* **View tasks** that are Scheduled, Running or Failed.
@@ -33,79 +32,91 @@ dashboard for monitoring and basic administration of tasks.
3332
* Minimum Java 11 and SpringBoot 2.7
3433
* Optional (if you want task history): db-scheduler-log version 0.7.0
3534

36-
3735
## Getting started
36+
3837
1. Add the db-scheduler-ui spring boot starter maven dependency
38+
3939
```xml
40+
4041
<dependency>
4142
<groupId>no.bekk.db-scheduler-ui</groupId>
4243
<artifactId>db-scheduler-ui-starter</artifactId>
4344
<version>1.0.1</version>
4445
</dependency>
4546
```
4647

47-
2. Read the [db-scheduler](https://github.com/kagkarlsson/db-scheduler) readme and follow the getting started guide. The most important is to create the `scheduled_tasks` table correctly.
48+
2. Read the [db-scheduler](https://github.com/kagkarlsson/db-scheduler) readme and follow the getting started guide. The
49+
most important is to create the `scheduled_tasks` table correctly.
4850
You do not need to add db-scheduler as a dependency.
4951
3. Start your application. The db-scheduler UI can be reached at `<your-app-url>/db-scheduler`
5052

51-
5253
## Optional: task history
54+
5355
If you want to add task history to your UI you need to add the following dependency:
56+
5457
```xml
58+
5559
<dependency>
5660
<groupId>io.rocketbase.extension</groupId>
5761
<artifactId>db-scheduler-log-spring-boot-starter</artifactId>
5862
<version>0.7.0</version>
5963
</dependency>
6064
```
61-
Follow the [readme](https://github.com/rocketbase-io/db-scheduler-log) to create the correct database table.
6265

63-
You also need to set `db-scheduler-ui.history=true` in your application.properties file.
66+
Follow the [readme](https://github.com/rocketbase-io/db-scheduler-log) to create the correct database table.
6467

68+
You also need to set `db-scheduler-ui.history=true` in your application.properties file, and consider setting a limit to
69+
the number of logs fetched: `db-scheduler-ui.log-limit=1000`.
6570

6671
## How it works
67-
db-scheduler-ui adds a REST-api package that has a bundled frontend application.
72+
73+
db-scheduler-ui adds a REST-api package that has a bundled frontend application.
6874
Springboot is used to configure beans and handle dependencies within the library and your application.
69-
The user interface makes calls to the scheduler-client, where it can fetch, delete, run, and reschedule tasks.
70-
These tasks are then shown in the web application.
71-
An optional log module can also be added, making it possible to view the history of all your task executions.
75+
The user interface makes calls to the scheduler-client, where it can fetch, delete, run, and reschedule tasks.
76+
These tasks are then shown in the web application.
77+
An optional log module can also be added, making it possible to view the history of all your task executions.
7278

7379
## Configuration
7480

75-
db-scheduler-ui can be configured using the following options: <br>
81+
db-scheduler-ui can be configured using the following options:
7682

77-
Turns on db-scheduler-log, default value is false. See [Optional: task history](#optional-task-history)
78-
```
79-
db-scheduler-ui.history=false
80-
```
81-
<br>
82-
If you for some reason want to hide the task data you can set this to false. defaults to true
83+
`history`: Turns on db-scheduler-log, default value is `false`. You can also limit the number of logs to fetch
84+
with `log-limit`.
8385

8486
```
85-
db-scheduler-ui.task-data=true
87+
db-scheduler-ui.history=true
88+
db-scheduler-ui.log-limit=1000
8689
```
8790

91+
If you for some reason want to hide the task data you can set this to false. defaults to `true`
8892

93+
```
94+
db-scheduler-ui.task-data=false
95+
```
8996

9097
## Contributing
9198

92-
Feel free to create pull requests if there are features or improvements you want to add.
93-
PR's need to be approved by one of the maintainers. To publish a new version, create a release in Github and tag it with a SemVer version.
99+
Feel free to create pull requests if there are features or improvements you want to add.
100+
PR's need to be approved by one of the maintainers. To publish a new version, create a release in Github and tag it with
101+
a SemVer version.
94102
A new release will then be released to maven central by a github action using JReleaser.
95103

96104
Before submitting a PR make sure to run `mvn spotless:apply` to format the code correctly.
97105
Please use the prettier config when making frontend changes
98106

99-
100107
## Local development
108+
101109
Prerequisites:
110+
102111
* Maven
103112
* JDK11
104113
* Node
105114
* npm
106115

107116
There are two ways to run the frontend locally.
117+
108118
1. running `npm run dev` inside the db-scheduler-ui-frontend folder
109-
2. running `mvn install` will build the frontend and copy the output to the resources folder in the `db-scheduler-ui` module. The frontend will then be available at the same port as the example app.
119+
2. running `mvn install` will build the frontend and copy the output to the resources folder in the `db-scheduler-ui`
120+
module. The frontend will then be available at the same port as the example app.
110121

111122
To run the backend run `mvn clean install` and then run the example app.

db-scheduler-ui-starter/src/main/java/no/bekk/dbscheduler/uistarter/autoconfigure/UiApiAutoConfiguration.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,15 @@ LogLogic logLogic(
7777
Caching caching,
7878
DbSchedulerCustomizer customizer,
7979
DbSchedulerUiProperties properties,
80-
@Value("${db-scheduler-log.table-name:scheduled_execution_logs}") String logTableName) {
80+
@Value("${db-scheduler-log.table-name:scheduled_execution_logs}") String logTableName,
81+
@Value("${db-scheduler-ui.log-limit:0}") int logLimit) {
8182
return new LogLogic(
8283
dataSource,
8384
customizer.serializer().orElse(Serializer.DEFAULT_JAVA_SERIALIZER),
8485
caching,
8586
properties.isTaskData(),
86-
logTableName);
87+
logTableName,
88+
logLimit);
8789
}
8890

8991
@Bean

db-scheduler-ui-starter/src/main/java/no/bekk/dbscheduler/uistarter/config/DbSchedulerUiProperties.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
@Getter
2222
@ConfigurationProperties("db-scheduler-ui")
2323
public class DbSchedulerUiProperties {
24+
2425
private boolean enabled = true;
2526
private boolean taskData = true;
2627
private boolean history = false;
28+
private int logLimit = 0;
2729
}

db-scheduler-ui/src/main/java/no/bekk/dbscheduler/ui/model/GetLogsResponse.java

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@
1616
import com.fasterxml.jackson.annotation.JsonCreator;
1717
import com.fasterxml.jackson.annotation.JsonProperty;
1818
import java.util.List;
19+
import lombok.Getter;
1920

21+
@Getter
2022
public class GetLogsResponse {
23+
2124
private final int numberOfItems;
2225
private final int numberOfPages;
2326
private final List<LogModel> items;
@@ -31,16 +34,4 @@ public GetLogsResponse(
3134
this.numberOfPages = totalLogs == 0 ? 0 : (int) Math.ceil((double) totalLogs / pageSize);
3235
this.items = pagedLogs;
3336
}
34-
35-
public int getNumberOfItems() {
36-
return numberOfItems;
37-
}
38-
39-
public int getNumberOfPages() {
40-
return numberOfPages;
41-
}
42-
43-
public List<LogModel> getItems() {
44-
return items;
45-
}
4637
}

db-scheduler-ui/src/main/java/no/bekk/dbscheduler/ui/model/GetTasksResponse.java

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@
1616
import com.fasterxml.jackson.annotation.JsonCreator;
1717
import com.fasterxml.jackson.annotation.JsonProperty;
1818
import java.util.List;
19+
import lombok.Getter;
1920

21+
@Getter
2022
public class GetTasksResponse {
23+
2124
private final int numberOfItems;
2225
private final int numberOfPages;
2326
private final List<TaskModel> items;
@@ -31,16 +34,4 @@ public GetTasksResponse(
3134
this.numberOfPages = totalTasks == 0 ? 0 : (int) Math.ceil((double) totalTasks / pageSize);
3235
this.items = pagedTasks;
3336
}
34-
35-
public int getNumberOfItems() {
36-
return numberOfItems;
37-
}
38-
39-
public int getNumberOfPages() {
40-
return numberOfPages;
41-
}
42-
43-
public List<TaskModel> getItems() {
44-
return items;
45-
}
4637
}

db-scheduler-ui/src/main/java/no/bekk/dbscheduler/ui/model/LogPollResponse.java

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,16 @@
1313
*/
1414
package no.bekk.dbscheduler.ui.model;
1515

16+
import lombok.Getter;
17+
18+
@Getter
1619
public class LogPollResponse {
17-
public LogPollResponse(int newFailures, int newSucceeded) {
18-
this.newFailures = newFailures;
19-
this.newSucceeded = newSucceeded;
20-
}
2120

2221
private final int newFailures;
22+
private final int newSucceeded;
2323

24-
public int getNewFailures() {
25-
return newFailures;
26-
}
27-
28-
public int getNewSucceeded() {
29-
return newSucceeded;
24+
public LogPollResponse(int newFailures, int newSucceeded) {
25+
this.newFailures = newFailures;
26+
this.newSucceeded = newSucceeded;
3027
}
31-
32-
private final int newSucceeded;
3328
}

db-scheduler-ui/src/main/java/no/bekk/dbscheduler/ui/model/PollResponse.java

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313
*/
1414
package no.bekk.dbscheduler.ui.model;
1515

16+
import lombok.Getter;
17+
18+
@Getter
1619
public class PollResponse {
20+
1721
private final int newFailures;
1822
private final int newRunning;
1923
private final int newTasks;
@@ -28,24 +32,4 @@ public PollResponse(
2832
this.stoppedFailing = stoppedFailing;
2933
this.finishedRunning = finishedRunning;
3034
}
31-
32-
public int getNewFailures() {
33-
return newFailures;
34-
}
35-
36-
public int getNewRunning() {
37-
return newRunning;
38-
}
39-
40-
public int getNewTasks() {
41-
return newTasks;
42-
}
43-
44-
public int getStoppedFailing() {
45-
return stoppedFailing;
46-
}
47-
48-
public int getFinishedRunning() {
49-
return finishedRunning;
50-
}
5135
}

db-scheduler-ui/src/main/java/no/bekk/dbscheduler/ui/model/TaskDetailsRequestParams.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
package no.bekk.dbscheduler.ui.model;
1515

1616
import java.time.Instant;
17+
import lombok.Getter;
1718

19+
@Getter
1820
public class TaskDetailsRequestParams extends TaskRequestParams {
1921

2022
private final String taskId;
@@ -51,12 +53,4 @@ public TaskDetailsRequestParams(
5153
this.taskId = taskId;
5254
this.taskName = taskName;
5355
}
54-
55-
public String getTaskId() {
56-
return taskId;
57-
}
58-
59-
public String getTaskName() {
60-
return taskName;
61-
}
6256
}

db-scheduler-ui/src/main/java/no/bekk/dbscheduler/ui/model/TaskRequestParams.java

Lines changed: 5 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,23 @@
1414
package no.bekk.dbscheduler.ui.model;
1515

1616
import java.time.Instant;
17-
import java.time.temporal.ChronoUnit;
17+
import lombok.Getter;
1818

19+
@Getter
1920
public class TaskRequestParams {
2021

2122
private final TaskFilter filter;
2223
private final int pageNumber;
2324
private final int size;
2425
private final TaskSort sorting;
2526
private final boolean asc;
26-
private boolean refresh;
2727
private final String searchTermTaskName;
28-
2928
private final String searchTermTaskInstance;
30-
3129
private final boolean taskNameExactMatch;
32-
3330
private final boolean taskInstanceExactMatch;
3431
private final Instant startTime;
3532
private final Instant endTime;
33+
private final boolean refresh;
3634

3735
public TaskRequestParams(
3836
TaskFilter filter,
@@ -56,63 +54,11 @@ public TaskRequestParams(
5654
this.searchTermTaskInstance = searchTermTaskInstance;
5755
this.taskNameExactMatch = taskNameExactMatch != null ? taskNameExactMatch : false;
5856
this.taskInstanceExactMatch = taskInstanceExactMatch != null ? taskInstanceExactMatch : false;
59-
this.startTime = startTime != null ? startTime : Instant.now().minus(50, ChronoUnit.DAYS);
60-
this.endTime = endTime != null ? endTime : Instant.now().plus(50, ChronoUnit.DAYS);
57+
this.startTime = startTime;
58+
this.endTime = endTime;
6159
this.refresh = refresh != null ? refresh : true;
6260
}
6361

64-
public TaskFilter getFilter() {
65-
return filter;
66-
}
67-
68-
public int getPageNumber() {
69-
return pageNumber;
70-
}
71-
72-
public int getSize() {
73-
return size;
74-
}
75-
76-
public TaskSort getSorting() {
77-
return sorting;
78-
}
79-
80-
public boolean isAsc() {
81-
return asc;
82-
}
83-
84-
public boolean isRefresh() {
85-
return refresh;
86-
}
87-
88-
public String getSearchTermTaskName() {
89-
return searchTermTaskName;
90-
}
91-
92-
public String getSearchTermTaskInstance() {
93-
return searchTermTaskInstance;
94-
}
95-
96-
public boolean isTaskNameExactMatch() {
97-
return taskNameExactMatch;
98-
}
99-
100-
public boolean isTaskInstanceExactMatch() {
101-
return taskInstanceExactMatch;
102-
}
103-
104-
public void setRefresh(boolean refresh) {
105-
this.refresh = refresh;
106-
}
107-
108-
public Instant getStartTime() {
109-
return startTime;
110-
}
111-
112-
public Instant getEndTime() {
113-
return endTime;
114-
}
115-
11662
public enum TaskFilter {
11763
ALL,
11864
FAILED,

0 commit comments

Comments
 (0)