This is an automated email from the ASF dual-hosted git repository.

juzhiyuan pushed a commit to branch fe-refactor
in repository https://gitbox.apache.org/repos/asf/apisix-dashboard.git

commit 60e86f5010318e121d6f7dbc7137d020562a8349
Author: juzhiyuan <juzhiy...@apache.org>
AuthorDate: Sun Sep 27 18:42:42 2020 +0800

    feat: update Upstream List
---
 config/proxy.ts                |  2 +-
 src/pages/Upstream/List.tsx    |  4 ++--
 src/pages/Upstream/service.ts  | 18 +++++++-----------
 src/pages/Upstream/typing.d.ts |  1 +
 src/typings.d.ts               | 12 ++++++++++++
 5 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/config/proxy.ts b/config/proxy.ts
index 3932be6..21dab1c 100644
--- a/config/proxy.ts
+++ b/config/proxy.ts
@@ -18,7 +18,7 @@ export default {
   dev: {
     '/apisix/admin': {
       // NOTE: This is the manager-api pre-deployed in Azure just for preview, 
please refer to https://www.yuque.com/umijs/umi/proxy for more info.
-      target: 'http://139.217.185.221',
+      target: '40.73.92.163:8080',
       changeOrigin: true,
     },
   },
diff --git a/src/pages/Upstream/List.tsx b/src/pages/Upstream/List.tsx
index 5a073a8..d18c54d 100644
--- a/src/pages/Upstream/List.tsx
+++ b/src/pages/Upstream/List.tsx
@@ -30,7 +30,7 @@ const Page: React.FC = () => {
   const [search, setSearch] = useState('');
   const { formatMessage } = useIntl();
 
-  const columns: ProColumns<UpstreamModule.ResEntity>[] = [
+  const columns: ProColumns<UpstreamModule.Entity>[] = [
     {
       title: formatMessage({ id: 'upstream.list.name' }),
       dataIndex: 'name',
@@ -85,7 +85,7 @@ const Page: React.FC = () => {
 
   return (
     <PageContainer title={formatMessage({ id: 'upstream.list' })}>
-      <ProTable<UpstreamModule.ResEntity>
+      <ProTable<UpstreamModule.Entity>
         actionRef={ref}
         columns={columns}
         rowKey="id"
diff --git a/src/pages/Upstream/service.ts b/src/pages/Upstream/service.ts
index 21b37cd..fef33af 100644
--- a/src/pages/Upstream/service.ts
+++ b/src/pages/Upstream/service.ts
@@ -16,17 +16,13 @@
  */
 import { request } from 'umi';
 
-export const fetchList = ({ current = 1, pageSize = 10 }, search: string) =>
-  request('/upstreams', {
-    params: {
-      page: current,
-      size: pageSize,
-      search,
-    },
-  }).then(({ data, count }) => ({
-    data,
-    total: count,
-  }));
+export const fetchList = ({ current = 1, pageSize = 10 }, search: string) => {
+  // TODO: Use Cache and search on local
+  return 
request<Res<ResListData<UpstreamModule.Entity>>>('/upstreams').then(({ data }) 
=> ({
+    data: data.rows,
+    total: data.total_size,
+  }))
+}
 
 export const fetchOne = (id: string) => 
request<UpstreamModule.ResEntity>(`/upstreams/${id}`);
 
diff --git a/src/pages/Upstream/typing.d.ts b/src/pages/Upstream/typing.d.ts
index 25603d3..5ba1018 100644
--- a/src/pages/Upstream/typing.d.ts
+++ b/src/pages/Upstream/typing.d.ts
@@ -22,6 +22,7 @@ declare namespace UpstreamModule {
   };
 
   type Base = {
+    id?: string;
     name: string;
     timeout: {
       connect: number;
diff --git a/src/typings.d.ts b/src/typings.d.ts
index a8875a6..8af4561 100644
--- a/src/typings.d.ts
+++ b/src/typings.d.ts
@@ -54,3 +54,15 @@ declare let 
ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION: 'site' | undefine
 declare const REACT_APP_ENV: 'test' | 'dev' | 'pre' | false;
 
 type PageMode = 'CREATE' | 'EDIT' | 'VIEW';
+
+type Res<T> = {
+  code: number;
+  message: string;
+  request_id: string;
+  data: T;
+}
+
+type ResListData<T> = {
+  rows: T[];
+  total_size: number;
+}

Reply via email to