bbovenzi commented on code in PR #31123:
URL: https://github.com/apache/airflow/pull/31123#discussion_r1187661302


##########
airflow/www/static/js/api/useDagRuns.tsx:
##########
@@ -0,0 +1,50 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import axios, { AxiosResponse } from "axios";
+import { useQuery } from "react-query";
+import type { API } from "src/types";
+
+import { getMetaValue } from "src/utils";
+
+const useDagRuns = ({
+  dagId,
+  state,
+  limit,
+  orderBy,
+}: API.GetDagRunsVariables) => {
+  const dagRunsUrl = getMetaValue("dag_runs_url").replace("__DAG_ID__", dagId);
+
+  return useQuery(
+    ["dag", state, dagId, limit],

Review Comment:
   ```suggestion
       ["dagRuns", state, dagId, limit],
   ```



##########
airflow/www/static/js/dashboard/live-metrics/Pools.tsx:
##########
@@ -0,0 +1,121 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import React from "react";
+import {
+  Box,
+  BoxProps,
+  Card,
+  CardBody,
+  CardHeader,
+  Heading,
+  Spinner,
+} from "@chakra-ui/react";
+import { usePools } from "src/api";
+import ReactECharts, { ReactEChartsProps } from "src/components/ReactECharts";
+import type { API } from "src/types";
+
+const formatData = (
+  data?: API.PoolCollection
+): Array<[string, number, number, number, number]> =>
+  data?.pools?.map((pool) => [
+    pool.name || "",
+    pool.openSlots || 0,
+    pool.queuedSlots || 0,
+    pool.runningSlots || 0,
+    pool.scheduledSlots || 0,
+  ]) || [];
+
+const Pools = (props: BoxProps) => {
+  const { data, isSuccess } = usePools();
+
+  const option: ReactEChartsProps["option"] = {
+    dataset: {
+      source: [
+        ["pool", "open", "queued", "running", "scheduled"],
+        ...formatData(data),
+      ],
+    },
+    tooltip: {
+      trigger: "axis",
+      axisPointer: {
+        type: "shadow",
+      },
+    },
+    legend: {
+      data: ["open", "queued", "running", "scheduled"],
+    },
+    grid: {
+      left: "0%",
+      right: "5%",
+      top: "30%",
+      bottom: "0%",
+      containLabel: true,
+    },
+    xAxis: {
+      type: "value",
+    },
+    yAxis: {
+      type: "category",
+    },
+    series: [
+      {
+        type: "bar",
+        stack: "total",
+        barMaxWidth: 10,
+      },
+      {
+        type: "bar",
+        stack: "total",
+        barMaxWidth: 10,
+      },
+      {
+        type: "bar",
+        stack: "total",
+        barMaxWidth: 10,
+      },
+      {
+        type: "bar",
+        stack: "total",
+        barMaxWidth: 10,
+      },
+    ],
+  };
+
+  return (
+    <Box {...props}>
+      {isSuccess ? (
+        <Card>
+          <CardHeader textAlign="center" p={3}>
+            <Heading size="md">Pools Slots</Heading>
+          </CardHeader>
+          <CardBody>
+            <Box height="250px">
+              <ReactECharts option={option} />
+            </Box>
+          </CardBody>
+        </Card>
+      ) : (
+        <Spinner color="blue.500" speed="1s" mr="4px" size="xl" />

Review Comment:
   If there is an error a user will only get a spinner?



##########
airflow/www/static/js/dashboard/nav/FilterBar.tsx:
##########
@@ -0,0 +1,77 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* global moment */
+
+import { Box, Button, Flex, Input } from "@chakra-ui/react";
+import React from "react";
+
+import { useTimezone } from "src/context/timezone";
+import { isoFormatWithoutTZ } from "src/datetime_utils";
+import useFilters from "src/dashboard/useFilters";
+
+const FilterBar = () => {
+  const { filters, onStartDateChange, onEndDateChange, clearFilters } =
+    useFilters();
+
+  const { timezone } = useTimezone();
+  const startDate = moment(filters.startDate);
+  const endDate = moment(filters.endDate);
+  const formattedStartDate = startDate.tz(timezone).format(isoFormatWithoutTZ);
+  const formattedEndDate = endDate.tz(timezone).format(isoFormatWithoutTZ);
+
+  const inputStyles = { backgroundColor: "white", size: "lg" };
+
+  return (
+    <Flex backgroundColor="#f0f0f0" mb={4} p={4} 
justifyContent="space-between">

Review Comment:
   Do we want to make sure we use colors from theme instead of manual hex codes?



##########
airflow/www/static/js/dashboard/useFilters.tsx:
##########
@@ -0,0 +1,95 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* global moment */
+
+import { useSearchParams } from "react-router-dom";
+import URLSearchParamsWrapper from "src/utils/URLSearchParamWrapper";
+
+export interface Filters {
+  startDate: string;
+  endDate: string;
+}
+
+export interface UtilFunctions {
+  onStartDateChange: (value: string) => void;
+  onEndDateChange: (value: string) => void;
+  clearFilters: () => void;
+}
+
+export interface FilterHookReturn extends UtilFunctions {
+  filters: Filters;
+}
+
+// Params names
+export const START_DATE_PARAM = "start_date";
+export const END_DATE_PARAM = "end_date";
+
+const date = new Date();
+date.setMilliseconds(0);
+
+export const now = date.toISOString();
+
+const useFilters = (): FilterHookReturn => {
+  const [searchParams, setSearchParams] = useSearchParams();
+
+  const endDate = searchParams.get(END_DATE_PARAM) || now;
+  const startDate =
+    searchParams.get(START_DATE_PARAM) ||
+    moment(endDate).subtract(1, "d").toISOString();

Review Comment:
   I think it would be helpful to say the range in the filter bar. (Showing 
data for the past day, week, 6 hours, etc)



##########
airflow/www/static/js/api/useDagRuns.tsx:
##########
@@ -0,0 +1,50 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import axios, { AxiosResponse } from "axios";
+import { useQuery } from "react-query";
+import type { API } from "src/types";
+
+import { getMetaValue } from "src/utils";
+
+const useDagRuns = ({
+  dagId,
+  state,
+  limit,
+  orderBy,
+}: API.GetDagRunsVariables) => {
+  const dagRunsUrl = getMetaValue("dag_runs_url").replace("__DAG_ID__", dagId);
+
+  return useQuery(
+    ["dag", state, dagId, limit],

Review Comment:
   ```suggestion
       ["dagRuns", state, dagId, limit],
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to