devmadhuu commented on code in PR #7168:
URL: https://github.com/apache/ozone/pull/7168#discussion_r1751213827


##########
hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/v2/components/decommissioningSummary/decommissioningSummary.tsx:
##########
@@ -0,0 +1,114 @@
+/*
+ * 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, { useEffect } from 'react';
+import { AxiosError } from 'axios';
+import { Descriptions, Popover, Result } from 'antd';
+import { Datanode, SummaryData } from '@/v2/types/datanode.types';
+import { AxiosGetHelper, cancelRequests } from '@/utils/axiosRequestHelper';
+import { showDataFetchError } from '@/utils/common';
+
+type DecommisioningSummaryProps = {
+  uuid: string;
+}
+
+type DecommisioningSummaryState = {
+  loading: boolean;
+  summaryData: SummaryData | Record<string, unknown>;
+};
+
+const DecommissionSummary: React.FC<DecommisioningSummaryProps> = ({
+  uuid = ''
+}) => {
+  const [state, setState] = React.useState<DecommisioningSummaryState>({
+    summaryData: {},
+    loading: false
+  });
+  const cancelSignal = React.useRef<AbortController>();
+
+  async function fetchDecommissionSummary(selectedUuid: string) {
+    setState({
+      ...state,
+      loading: true
+    });
+    try {
+      const { request, controller } = AxiosGetHelper(
+        `/api/v1/datanodes/decommission/info/datanode?uuid=${selectedUuid}`,
+        cancelSignal.current
+      );
+      cancelSignal.current = controller;
+      const datanodesInfoResponse = await request;
+      setState({
+        ...state,
+        loading: false,
+        summaryData: datanodesInfoResponse?.data?.DatanodesDecommissionInfo[0] 
?? {}
+      });
+    } catch (error) {
+      setState({
+        ...state,
+        loading: false,
+        summaryData: {}
+      });
+      showDataFetchError((error as AxiosError).toString());
+    }
+  }
+
+  useEffect(() => {
+    fetchDecommissionSummary(uuid);
+    return (() => {
+      cancelRequests([cancelSignal.current!]);
+    })
+  }, []);
+
+  let content = (
+    <Result
+      status='error'
+      title='Unable to fetch Decommission Summary data'
+      className='decommission-summary-result'/>
+  );
+
+  const { summaryData } = state;
+  if (summaryData?.datanodeDetails && summaryData?.metrics && 
summaryData?.containers) {
+    const {
+      datanodeDetails: { uuid, networkLocation, ipAddress, hostName },
+      containers: { UnderReplicated, UnClosed },
+      metrics: { decommissionStartTime, numOfUnclosedPipelines, 
numOfUnclosedContainers, numOfUnderReplicatedContainers }
+    } = summaryData as SummaryData;
+    content = (
+      <Descriptions size="small" bordered column={1} title={`Decommission 
Status: DECOMMISSIONING`}>

Review Comment:
   Can we move this whole `Description`  into its own function or component or 
clarity. Make it clumsy or less readable when nested inside main `if `block



##########
hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/v2/components/decommissioningSummary/decommissioningSummary.tsx:
##########
@@ -0,0 +1,114 @@
+/*
+ * 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, { useEffect } from 'react';
+import { AxiosError } from 'axios';
+import { Descriptions, Popover, Result } from 'antd';
+import { Datanode, SummaryData } from '@/v2/types/datanode.types';
+import { AxiosGetHelper, cancelRequests } from '@/utils/axiosRequestHelper';
+import { showDataFetchError } from '@/utils/common';
+
+type DecommisioningSummaryProps = {
+  uuid: string;
+}
+
+type DecommisioningSummaryState = {
+  loading: boolean;
+  summaryData: SummaryData | Record<string, unknown>;
+};
+
+const DecommissionSummary: React.FC<DecommisioningSummaryProps> = ({
+  uuid = ''
+}) => {
+  const [state, setState] = React.useState<DecommisioningSummaryState>({
+    summaryData: {},
+    loading: false
+  });
+  const cancelSignal = React.useRef<AbortController>();
+
+  async function fetchDecommissionSummary(selectedUuid: string) {
+    setState({
+      ...state,
+      loading: true
+    });
+    try {
+      const { request, controller } = AxiosGetHelper(
+        `/api/v1/datanodes/decommission/info/datanode?uuid=${selectedUuid}`,
+        cancelSignal.current
+      );
+      cancelSignal.current = controller;
+      const datanodesInfoResponse = await request;
+      setState({
+        ...state,
+        loading: false,
+        summaryData: datanodesInfoResponse?.data?.DatanodesDecommissionInfo[0] 
?? {}
+      });
+    } catch (error) {
+      setState({
+        ...state,
+        loading: false,
+        summaryData: {}
+      });
+      showDataFetchError((error as AxiosError).toString());
+    }
+  }
+
+  useEffect(() => {
+    fetchDecommissionSummary(uuid);
+    return (() => {
+      cancelRequests([cancelSignal.current!]);
+    })
+  }, []);
+
+  let content = (
+    <Result
+      status='error'
+      title='Unable to fetch Decommission Summary data'
+      className='decommission-summary-result'/>
+  );
+
+  const { summaryData } = state;
+  if (summaryData?.datanodeDetails && summaryData?.metrics && 
summaryData?.containers) {
+    const {
+      datanodeDetails: { uuid, networkLocation, ipAddress, hostName },
+      containers: { UnderReplicated, UnClosed },
+      metrics: { decommissionStartTime, numOfUnclosedPipelines, 
numOfUnclosedContainers, numOfUnderReplicatedContainers }
+    } = summaryData as SummaryData;
+    content = (
+      <Descriptions size="small" bordered column={1} title={`Decommission 
Status: DECOMMISSIONING`}>
+        <Descriptions.Item label="Datanode"> <b>{uuid}</b></Descriptions.Item>
+        <Descriptions.Item 
label="Location">({networkLocation}/{ipAddress}/{hostName})</Descriptions.Item>
+        <Descriptions.Item label="Decommissioning Started 
at">{decommissionStartTime}</Descriptions.Item>
+        <Descriptions.Item label="No. of Unclosed 
Pipelines">{numOfUnclosedPipelines}</Descriptions.Item>
+        <Descriptions.Item label="No. of Unclosed 
Containers">{numOfUnclosedContainers}</Descriptions.Item>
+        <Descriptions.Item label="No. of Under-Replicated 
Containers">{numOfUnderReplicatedContainers}</Descriptions.Item>
+        <Descriptions.Item 
label="Under-Replicated">{UnderReplicated}</Descriptions.Item>
+        <Descriptions.Item label="Unclosed">{UnClosed}</Descriptions.Item>
+      </Descriptions>
+    );
+  }
+  // Need to check summarydata is not empty 

Review Comment:
   This comment seems not in sync what code is doing actually. Can we make it 
more meaningful ?



##########
hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/v2/components/decommissioningSummary/decommissioningSummary.tsx:
##########
@@ -0,0 +1,114 @@
+/*
+ * 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, { useEffect } from 'react';
+import { AxiosError } from 'axios';
+import { Descriptions, Popover, Result } from 'antd';
+import { Datanode, SummaryData } from '@/v2/types/datanode.types';
+import { AxiosGetHelper, cancelRequests } from '@/utils/axiosRequestHelper';
+import { showDataFetchError } from '@/utils/common';
+
+type DecommisioningSummaryProps = {
+  uuid: string;
+}
+
+type DecommisioningSummaryState = {
+  loading: boolean;
+  summaryData: SummaryData | Record<string, unknown>;
+};
+
+const DecommissionSummary: React.FC<DecommisioningSummaryProps> = ({
+  uuid = ''
+}) => {
+  const [state, setState] = React.useState<DecommisioningSummaryState>({
+    summaryData: {},
+    loading: false
+  });
+  const cancelSignal = React.useRef<AbortController>();
+
+  async function fetchDecommissionSummary(selectedUuid: string) {

Review Comment:
   Not sure if it is feasible, but check if we can add a loading spinner or 
skeleton to the UI to indicate that data is being fetched:



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to