You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by ju...@apache.org on 2020/06/15 07:34:57 UTC

[incubator-apisix-dashboard] branch feat-ssl created (now 3324f8e)

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

juzhiyuan pushed a change to branch feat-ssl
in repository https://gitbox.apache.org/repos/asf/incubator-apisix-dashboard.git.


      at 3324f8e  feat: added SSL checked

This branch includes the following new commits:

     new 3324f8e  feat: added SSL checked

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[incubator-apisix-dashboard] 01/01: feat: added SSL checked

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 3324f8e45d1fd52efe382dc6c078f7f2392c312a
Author: juzhiyuan <jj...@gmail.com>
AuthorDate: Mon Jun 15 15:34:11 2020 +0800

    feat: added SSL checked
---
 src/pages/ssl/List.tsx   | 26 ++++++++++++++++++++++----
 src/pages/ssl/service.ts |  7 +++++++
 2 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/src/pages/ssl/List.tsx b/src/pages/ssl/List.tsx
index e356f6f..3f1a656 100644
--- a/src/pages/ssl/List.tsx
+++ b/src/pages/ssl/List.tsx
@@ -5,12 +5,25 @@ import { Button, Switch, Popconfirm, notification } from 'antd';
 import { history, useIntl } from 'umi';
 import { PlusOutlined } from '@ant-design/icons';
 
-import { fetchList as fetchSSLList, remove as removeSSL } from './service';
+import { fetchList as fetchSSLList, remove as removeSSL, update as updateSSL } from './service';
 
 const List: React.FC = () => {
   const tableRef = useRef<ActionType>();
   const { formatMessage } = useIntl();
 
+  const onEnableChange = (id: string, checked: boolean) => {
+    console.log({ id, checked });
+    updateSSL(id, checked)
+      .then(() => {
+        notification.success({ message: '更新证书启用状态成功' });
+      })
+      .catch(() => {
+        notification.error({ message: '更新证书启用状态失败' });
+        /* eslint-disable no-unused-expressions */
+        tableRef.current?.reload();
+      });
+  };
+
   const columns: ProColumns<SSLModule.ResSSL>[] = [
     {
       title: 'SNI',
@@ -24,10 +37,15 @@ const List: React.FC = () => {
     },
     {
       title: '是否启用',
-      valueType: 'option',
-      render: () => (
+      dataIndex: 'status',
+      render: (text, record) => (
         <>
-          <Switch defaultChecked />
+          <Switch
+            defaultChecked={Number(text) === 1}
+            onChange={(checked: boolean) => {
+              onEnableChange(record.id, checked);
+            }}
+          />
         </>
       ),
     },
diff --git a/src/pages/ssl/service.ts b/src/pages/ssl/service.ts
index bb7d514..9de9971 100644
--- a/src/pages/ssl/service.ts
+++ b/src/pages/ssl/service.ts
@@ -56,3 +56,10 @@ export const verifyKeyPaire = (cert = '', key = ''): Promise<VerifyKeyPaireProps
     method: 'POST',
     data: { cert, key },
   });
+
+export const update = (id: string, checked: boolean) =>
+  request(`/ssls/${id}`, {
+    data: {
+      status: Number(checked),
+    },
+  });