devabhishekpal commented on code in PR #7017:
URL: https://github.com/apache/ozone/pull/7017#discussion_r1705323072


##########
hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/v2/pages/overview/overview.tsx:
##########
@@ -0,0 +1,527 @@
+/*
+ * 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, useState } from 'react';
+import moment from 'moment';
+import filesize from 'filesize';
+import axios, { CanceledError } from 'axios';
+import { Row, Col, Button } from 'antd';
+import {
+  CheckCircleFilled,
+  WarningFilled
+} from '@ant-design/icons';
+import { Link } from 'react-router-dom';
+
+import AutoReloadPanel from '@/components/autoReloadPanel/autoReloadPanel';
+import OverviewTableCard from '@/v2/components/overviewCard/overviewTableCard';
+import OverviewStorageCard from 
'@/v2/components/overviewCard/overviewStorageCard';
+import OverviewCardSimple from 
'@/v2/components/overviewCard/overviewSimpleCard';
+
+import { AutoReloadHelper } from '@/utils/autoReloadHelper';
+import { showDataFetchError } from '@/utils/common';
+import { AxiosGetHelper, cancelRequests, PromiseAllSettledGetHelper } from 
'@/utils/axiosRequestHelper';
+
+import { ClusterStateResponse, OverviewState, StorageReport } from 
'@/v2/types/overview.types';
+
+import './overview.less';
+
+
+const size = filesize.partial({ round: 1 });
+
+const getHealthIcon = (value: string): React.ReactElement => {
+  const values = value.split('/');
+  if (values.length == 2 && values[0] < values[1]) {
+    return (
+      <>
+        <div className='icon-warning' style={{
+          fontSize: '20px',
+          alignItems: 'center'
+        }}>
+          <WarningFilled style={{
+            marginRight: '5px'
+          }} />
+          Unhealthy
+        </div>
+      </>
+    )
+  }
+  return (
+    <div className='icon-success' style={{
+      fontSize: '20px',
+      alignItems: 'center'
+    }}>
+      <CheckCircleFilled style={{
+        marginRight: '5px'
+      }} />
+      Healthy
+    </div>
+  )
+}
+
+const checkResponseError = (responses: Awaited<Promise<any>>[]) => {
+  const responseError = responses.filter(
+    (resp) => resp.status === 'rejected'
+  );
+
+  if (responseError.length !== 0) {
+    responseError.forEach((err) => {
+      if (err.reason.toString().includes("CanceledError")) {
+        throw new CanceledError('canceled', "ERR_CANCELED");
+      }
+      else {
+        const reqMethod = err.reason.config.method;
+        const reqURL = err.reason.config.url
+        showDataFetchError(
+          `Failed to ${reqMethod} URL ${reqURL}\n${err.reason.toString()}`
+        );
+      }
+    })
+  }
+}
+
+const Overview: React.FC<{}> = () => {
+
+  let cancelOverviewSignal: AbortController;
+  let cancelOMDBSyncSignal: AbortController;
+
+  const [state, setState] = useState<OverviewState>({
+    loading: false,
+    datanodes: '',
+    pipelines: 0,
+    containers: 0,
+    volumes: 0,
+    buckets: 0,
+    keys: 0,
+    missingContainersCount: 0,
+    lastRefreshed: 0,
+    lastUpdatedOMDBDelta: 0,
+    lastUpdatedOMDBFull: 0,
+    omStatus: '',
+    openContainers: 0,
+    deletedContainers: 0,
+    openSummarytotalUnrepSize: 0,
+    openSummarytotalRepSize: 0,
+    openSummarytotalOpenKeys: 0,
+    deletePendingSummarytotalUnrepSize: 0,
+    deletePendingSummarytotalRepSize: 0,
+    deletePendingSummarytotalDeletedKeys: 0,
+    scmServiceId: '',
+    omServiceId: ''
+  })
+  const [storageReport, setStorageReport] = useState<StorageReport>({
+    capacity: 0,
+    used: 0,
+    remaining: 0,
+    committed: 0
+  })
+
+  // Component mounted, fetch initial data
+  useEffect(() => {
+    loadOverviewPageData();
+    autoReloadHelper.startPolling();
+    return (() => {
+      // Component will Un-mount
+      autoReloadHelper.stopPolling();
+      cancelRequests([
+        cancelOMDBSyncSignal,
+        cancelOverviewSignal
+      ]);
+    })
+  }, [])
+
+  const loadOverviewPageData = () => {
+    setState({
+      ...state,
+      loading: true
+    });
+
+    // Cancel any previous pending requests
+    cancelRequests([
+      cancelOMDBSyncSignal,
+      cancelOverviewSignal
+    ]);
+
+    const { requests, controller } = PromiseAllSettledGetHelper([
+      '/api/v1/clusterState',
+      '/api/v1/task/status',
+      '/api/v1/keys/open/summary',
+      '/api/v1/keys/deletePending/summary'

Review Comment:
   Addressed in the latest commit



-- 
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: issues-unsubscr...@ozone.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@ozone.apache.org
For additional commands, e-mail: issues-h...@ozone.apache.org

Reply via email to