-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(*): introduce custom dashboards (#6144)
closes kestra-io/kestra-ee#1711 Co-authored-by: MilosPaunovic <[email protected]>
- Loading branch information
1 parent
8212106
commit 4943f9a
Showing
127 changed files
with
4,387 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,6 @@ public enum SchemaType { | |
task, | ||
trigger, | ||
plugindefault, | ||
apps | ||
apps, | ||
dashboard | ||
} |
9 changes: 9 additions & 0 deletions
9
core/src/main/java/io/kestra/core/models/dashboards/AggregationType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package io.kestra.core.models.dashboards; | ||
|
||
public enum AggregationType { | ||
AVG, | ||
MAX, | ||
MIN, | ||
SUM, | ||
COUNT | ||
} |
27 changes: 27 additions & 0 deletions
27
core/src/main/java/io/kestra/core/models/dashboards/ChartOption.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package io.kestra.core.models.dashboards; | ||
|
||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.experimental.SuperBuilder; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
@SuperBuilder(toBuilder = true) | ||
@Getter | ||
@NoArgsConstructor | ||
@EqualsAndHashCode | ||
public class ChartOption { | ||
@NotNull | ||
@NotBlank | ||
private String displayName; | ||
|
||
private String description; | ||
|
||
public List<String> neededColumns() { | ||
return Collections.emptyList(); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
core/src/main/java/io/kestra/core/models/dashboards/ColumnDescriptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package io.kestra.core.models.dashboards; | ||
|
||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.experimental.SuperBuilder; | ||
|
||
@SuperBuilder(toBuilder = true) | ||
@Getter | ||
@NoArgsConstructor | ||
@EqualsAndHashCode | ||
public class ColumnDescriptor<F extends Enum<F>> { | ||
private F field; | ||
private String displayName; | ||
private AggregationType agg; | ||
private String labelKey; | ||
} |
90 changes: 90 additions & 0 deletions
90
core/src/main/java/io/kestra/core/models/dashboards/Dashboard.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package io.kestra.core.models.dashboards; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
import io.kestra.core.models.DeletedInterface; | ||
import io.kestra.core.models.HasUID; | ||
import io.kestra.core.models.dashboards.charts.Chart; | ||
import io.kestra.core.utils.IdUtils; | ||
import io.micronaut.core.annotation.Introspected; | ||
import io.swagger.v3.oas.annotations.Hidden; | ||
import jakarta.validation.Valid; | ||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Pattern; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.ToString; | ||
import lombok.experimental.SuperBuilder; | ||
|
||
import java.time.Instant; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
@SuperBuilder(toBuilder = true) | ||
@Getter | ||
@NoArgsConstructor | ||
@Introspected | ||
@ToString | ||
public class Dashboard implements HasUID, DeletedInterface { | ||
@Hidden | ||
@Pattern(regexp = "^[a-z0-9][a-z0-9_-]*") | ||
private String tenantId; | ||
|
||
@Hidden | ||
private String id; | ||
|
||
@NotNull | ||
@NotBlank | ||
private String title; | ||
|
||
private String description; | ||
|
||
@Valid | ||
@Builder.Default | ||
private TimeWindow timeWindow = TimeWindow.builder().build(); | ||
|
||
@Valid | ||
private List<Chart<?>> charts; | ||
|
||
@Hidden | ||
@NotNull | ||
@Builder.Default | ||
private boolean deleted = false; | ||
|
||
@Hidden | ||
private Instant created; | ||
|
||
@Hidden | ||
private Instant updated; | ||
|
||
private String sourceCode; | ||
|
||
@Override | ||
@JsonIgnore | ||
public String uid() { | ||
return IdUtils.fromParts( | ||
tenantId, | ||
id | ||
); | ||
} | ||
|
||
public Dashboard toDeleted() { | ||
return this.toBuilder() | ||
.deleted(true) | ||
.build(); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
Dashboard dashboard = (Dashboard) o; | ||
return deleted == dashboard.deleted && Objects.equals(tenantId, dashboard.tenantId) && Objects.equals(id, dashboard.id) && Objects.equals(title, dashboard.title) && Objects.equals(description, dashboard.description) && Objects.equals(timeWindow, dashboard.timeWindow) && Objects.equals(charts, dashboard.charts) && Objects.equals(sourceCode, dashboard.sourceCode); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(tenantId, id, title, description, timeWindow, charts, deleted, sourceCode); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
core/src/main/java/io/kestra/core/models/dashboards/DataFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package io.kestra.core.models.dashboards; | ||
|
||
import io.kestra.core.models.annotations.Plugin; | ||
import io.kestra.core.models.dashboards.filters.AbstractFilter; | ||
import io.kestra.core.repositories.QueryBuilderInterface; | ||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Pattern; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.experimental.SuperBuilder; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
@SuperBuilder(toBuilder = true) | ||
@Getter | ||
@NoArgsConstructor | ||
@Plugin | ||
@EqualsAndHashCode | ||
public abstract class DataFilter<F extends Enum<F>, C extends ColumnDescriptor<F>> implements io.kestra.core.models.Plugin { | ||
@NotNull | ||
@NotBlank | ||
@Pattern(regexp = "\\p{javaJavaIdentifierStart}\\p{javaJavaIdentifierPart}*(\\.\\p{javaJavaIdentifierStart}\\p{javaJavaIdentifierPart}*)*") | ||
private String type; | ||
|
||
private Map<String, C> columns; | ||
|
||
private List<AbstractFilter<F>> where; | ||
|
||
private List<OrderBy> orderBy; | ||
|
||
public Set<F> aggregationForbiddenFields() { | ||
return Collections.emptySet(); | ||
} | ||
|
||
public abstract Class<? extends QueryBuilderInterface<F>> repositoryClass(); | ||
} |
7 changes: 7 additions & 0 deletions
7
core/src/main/java/io/kestra/core/models/dashboards/GraphStyle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package io.kestra.core.models.dashboards; | ||
|
||
public enum GraphStyle { | ||
LINES, | ||
BARS, | ||
POINTS | ||
} |
6 changes: 6 additions & 0 deletions
6
core/src/main/java/io/kestra/core/models/dashboards/Order.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package io.kestra.core.models.dashboards; | ||
|
||
public enum Order { | ||
ASC, | ||
DESC | ||
} |
22 changes: 22 additions & 0 deletions
22
core/src/main/java/io/kestra/core/models/dashboards/OrderBy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package io.kestra.core.models.dashboards; | ||
|
||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.Builder; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.experimental.SuperBuilder; | ||
|
||
@SuperBuilder(toBuilder = true) | ||
@Getter | ||
@NoArgsConstructor | ||
@EqualsAndHashCode | ||
public class OrderBy { | ||
@NotNull | ||
@NotBlank | ||
private String column; | ||
|
||
@Builder.Default | ||
private Order order = Order.ASC; | ||
} |
28 changes: 28 additions & 0 deletions
28
core/src/main/java/io/kestra/core/models/dashboards/TimeWindow.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package io.kestra.core.models.dashboards; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import io.kestra.core.validations.DashboardWindowValidation; | ||
import io.micronaut.core.annotation.Introspected; | ||
import lombok.*; | ||
import lombok.experimental.SuperBuilder; | ||
import org.hibernate.validator.constraints.time.DurationMax; | ||
|
||
import java.time.Duration; | ||
|
||
@SuperBuilder(toBuilder = true) | ||
@Getter | ||
@NoArgsConstructor | ||
@Introspected | ||
@ToString | ||
@EqualsAndHashCode | ||
@DashboardWindowValidation | ||
public class TimeWindow { | ||
@DurationMax(days = 366L, message = "Time window can't be more than 1 year (366 days).") | ||
@JsonProperty("default") | ||
@Builder.Default | ||
private Duration defaultDuration = Duration.ofDays(30); | ||
|
||
@DurationMax(days = 366L, message = "Time window can't be more than 1 year (366 days).") | ||
@Builder.Default | ||
private Duration max = Duration.ofDays(366); | ||
} |
7 changes: 7 additions & 0 deletions
7
core/src/main/java/io/kestra/core/models/dashboards/WithLegend.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package io.kestra.core.models.dashboards; | ||
|
||
import io.kestra.core.models.dashboards.charts.LegendOption; | ||
|
||
public interface WithLegend { | ||
LegendOption getLegend(); | ||
} |
7 changes: 7 additions & 0 deletions
7
core/src/main/java/io/kestra/core/models/dashboards/WithTooltip.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package io.kestra.core.models.dashboards; | ||
|
||
import io.kestra.core.models.dashboards.charts.TooltipBehaviour; | ||
|
||
public interface WithTooltip { | ||
TooltipBehaviour getTooltip(); | ||
} |
32 changes: 32 additions & 0 deletions
32
core/src/main/java/io/kestra/core/models/dashboards/charts/Chart.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package io.kestra.core.models.dashboards.charts; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import io.kestra.core.models.annotations.Plugin; | ||
import io.kestra.core.models.dashboards.ChartOption; | ||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Pattern; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.experimental.SuperBuilder; | ||
|
||
@SuperBuilder(toBuilder = true) | ||
@Getter | ||
@NoArgsConstructor | ||
@Plugin | ||
@JsonInclude(JsonInclude.Include.NON_DEFAULT) | ||
@EqualsAndHashCode | ||
public abstract class Chart<P extends ChartOption> implements io.kestra.core.models.Plugin { | ||
@NotNull | ||
@NotBlank | ||
@Pattern(regexp = "^[a-zA-Z0-9][a-zA-Z0-9_-]*") | ||
private String id; | ||
|
||
@NotNull | ||
@NotBlank | ||
@Pattern(regexp = "\\p{javaJavaIdentifierStart}\\p{javaJavaIdentifierPart}*(\\.\\p{javaJavaIdentifierStart}\\p{javaJavaIdentifierPart}*)*") | ||
protected String type; | ||
|
||
private P chartOptions; | ||
} |
Oops, something went wrong.