Repository: kestra-io/kestra
File: ui/src/components/dashboard/composables/charts.ts (TypeScript)

Code before:
    if (route.query.q) {
        query.q = route.query.q;
    }

    if (event.namespace && event.flowId) {
        router.push({
            name: "flows/update",
            params: {
                namespace: event.namespace,
                id: event.flowId,
                tab: "executions",
                tenant: route.params.tenant,
            },
            query: query,
        });
    } else {
        if (event.namespace) {
            query.namespace = event.namespace;
        }

        router.push({
            name: "executions/list",
            params: {
                tenant: route.params.tenant,
            },
            query: {...query, ...filters, "filters[timeRange][EQUALS]": "P30D"},
        });
    }
}

export function backgroundFromState(state: string, alpha = 1) {
    const hex = State.color()[state];
    if (!hex) {
        return null;
    }

    const [r, g, b] = hex.match(/\w\w/g)?.map((x) => parseInt(x, 16)) ?? [0, 0, 0];
    return `rgba(${r},${g},${b},${alpha})`;
}

export function getConsistentHEXColor(_theme: "light" | "dark", value: string) {
    // TODO: This was added as part of https://github.com/kestra-io/kestra/issues/10055
    // Idea is to separate the value to parts and only use the status
    // Needs to be made more generic and robust as part of the https://github.com/kestra-io/kestra/issues/9149#issuecomment-2969506266
    const result = value.includes(",") ? value.split(",").pop()?.trim() : value;

    let hex;

    hex = getSchemeValue(result as any, "executions");
    if (hex && hex !== "transparent") {
        return hex;

Review comment (suggestion):
Could we add flexibility of interval from config as well ?  `miscStore.configs?.chartDefaultDuration ?? "P30D"`

Code after:
    }

    if (route.query.q) {
        query.q = route.query.q;
    }

    if (event.namespace && event.flowId) {
        router.push({
            name: "flows/update",
            params: {
                namespace: event.namespace,
                id: event.flowId,
                tab: "executions",
                tenant: route.params.tenant,
            },
            query: query,
        });
    } else {
        if (event.namespace) {
            query.namespace = event.namespace;
        }

        router.push({
            name: "executions/list",
            params: {
                tenant: route.params.tenant,
            },
            query: {
                ...query,
                ...filters,
                "filters[timeRange][EQUALS]":useMiscStore()?.configs?.chartDefaultDuration ?? "P30D"
            },
        });
    }
}

export function backgroundFromState(state: string, alpha = 1) {
    const hex = State.color()[state];
    if (!hex) {
        return null;
    }

    const [r, g, b] = hex.match(/\w\w/g)?.map((x) => parseInt(x, 16)) ?? [0, 0, 0];
    return `rgba(${r},${g},${b},${alpha})`;
}

export function getConsistentHEXColor(_theme: "light" | "dark", value: string) {
    // TODO: This was added as part of https://github.com/kestra-io/kestra/issues/10055
    // Idea is to separate the value to parts and only use the status
    // Needs to be made more generic and robust as part of the https://github.com/kestra-io/kestra/issues/9149#issuecomment-2969506266
    const result = value.includes(",") ? value.split(",").pop()?.trim() : value;