Compare commits

...

2 Commits

Author SHA1 Message Date
Piyush Bhaskar
7b99950694 minor tweak 2025-10-30 12:18:10 +05:30
Piyush Bhaskar
192ea5e522 feat(core): add ui part for scope filter on chart overview page 2025-10-30 12:11:33 +05:30
3 changed files with 71 additions and 2 deletions

View File

@@ -18,7 +18,7 @@
</template>
<script setup lang="ts">
import {computed, onBeforeMount, ref, useTemplateRef} from "vue";
import {computed, onBeforeMount, onMounted, ref, useTemplateRef} from "vue";
import {stringify, parse} from "@kestra-io/ui-libs/flow-yaml-utils";
import type {Dashboard, Chart} from "./composables/useDashboards";
@@ -105,6 +105,28 @@
if (props.isFlow && ID === "default") load("default", processFlowYaml(YAML_FLOW, route.params.namespace as string, route.params.id as string));
else if (props.isNamespace && ID === "default") load("default", YAML_NAMESPACE);
});
onMounted(() => {
const query = {...route.query};
let queryHasChanged = false;
const queryKeys = Object.keys(query);
const dateTimeKeys = ["startDate", "endDate", "timeRange"];
if (!queryKeys.some((key) => dateTimeKeys.some((dateTimeKey) => key.includes(dateTimeKey)))) {
query["filters[timeRange][EQUALS]"] = "PT168H";
queryHasChanged = true;
}
if (!queryKeys.some(key => key.startsWith("filters[scope]"))) {
query["filters[scope][EQUALS]"] = "USER";
queryHasChanged = true;
}
if (queryHasChanged) {
router.replace({query});
}
});
</script>
<style scoped lang="scss">

View File

@@ -68,6 +68,18 @@ export const useDashboardFilter = (): ComputedRef<FilterConfiguration> => comput
},
showComparatorSelection: true
},
{
key: "scope",
label: t("filter.scope.label"),
description: t("filter.scope.description"),
comparators: [Comparators.EQUALS, Comparators.NOT_EQUALS],
valueType: "radio",
valueProvider: async () => {
const {VALUES} = useValues("executions");
return VALUES.SCOPES;
},
showComparatorSelection: false
},
{
key: "labels",
label: t("filter.labels.label"),
@@ -117,6 +129,18 @@ export const useNamespaceDashboardFilter = (): ComputedRef<FilterConfiguration>
return VALUES.RELATIVE_DATE;
}
},
{
key: "scope",
label: t("filter.scope.label"),
description: t("filter.scope.description"),
comparators: [Comparators.EQUALS, Comparators.NOT_EQUALS],
valueType: "radio",
valueProvider: async () => {
const {VALUES} = useValues("executions");
return VALUES.SCOPES;
},
showComparatorSelection: false
},
{
key: "labels",
label: t("filter.labels.label"),
@@ -146,6 +170,18 @@ export const useFlowDashboardFilter = (): ComputedRef<FilterConfiguration> => co
return VALUES.RELATIVE_DATE;
}
},
{
key: "scope",
label: t("filter.scope.label"),
description: t("filter.scope.description"),
comparators: [Comparators.EQUALS, Comparators.NOT_EQUALS],
valueType: "radio",
valueProvider: async () => {
const {VALUES} = useValues("executions");
return VALUES.SCOPES;
},
showComparatorSelection: false
},
{
key: "labels",
label: t("filter.labels.label"),

View File

@@ -21,6 +21,17 @@ function maybeAddTimeRangeFilter(to) {
return false;
}
function maybeAddDefaultFilters(to) {
const timeRangeChanged = maybeAddTimeRangeFilter(to);
const scopeChanged = to.name === "home" && !Object.keys(to.query).some((key) => key.startsWith("filters[scope]"));
if (scopeChanged) {
to.query["filters[scope][EQUALS]"] = "USER";
}
return timeRangeChanged || scopeChanged;
}
export default [
//Initial
{name: "root", path: "/", redirect: {name: "home"}, meta: {layout: {template: "<div />"}}},
@@ -32,7 +43,7 @@ export default [
path: "/:tenant?/dashboards/:dashboard?",
component: () => import("../components/dashboard/Dashboard.vue"),
beforeEnter: (to, from, next) => {
if (maybeAddTimeRangeFilter(to)) {
if (maybeAddDefaultFilters(to)) {
next({
name: to.name,
params: to.params,