mirror of
https://github.com/kestra-io/kestra.git
synced 2025-12-25 11:12:12 -05:00
Compare commits
2 Commits
fix/remove
...
add-scope-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7b99950694 | ||
|
|
192ea5e522 |
@@ -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">
|
||||
|
||||
@@ -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"),
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user