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/05/20 12:11:30 UTC
[incubator-apisix-dashboard] branch feat-access created (now
aedff9d)
This is an automated email from the ASF dual-hosted git repository.
juzhiyuan pushed a change to branch feat-access
in repository https://gitbox.apache.org/repos/asf/incubator-apisix-dashboard.git.
at aedff9d feat: added umi request
This branch includes the following new commits:
new 9a06153 feat: added API.d.ts
new aedff9d feat: added umi request
The 2 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] 02/02: feat: added umi request
Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
juzhiyuan pushed a commit to branch feat-access
in repository https://gitbox.apache.org/repos/asf/incubator-apisix-dashboard.git
commit aedff9d918eee7e89f894ed1a49c2e1193e62f9a
Author: juzhiyuan <jj...@gmail.com>
AuthorDate: Wed May 20 20:11:11 2020 +0800
feat: added umi request
---
src/services/login.ts | 2 +-
src/services/user.ts | 16 ++++++++--------
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/services/login.ts b/src/services/login.ts
index a033215..a4e081e 100644
--- a/src/services/login.ts
+++ b/src/services/login.ts
@@ -1,4 +1,4 @@
-import request from '@/utils/request';
+import { request } from 'umi';
export interface LoginParamsType {
userName: string;
diff --git a/src/services/user.ts b/src/services/user.ts
index de49698..870c4c7 100644
--- a/src/services/user.ts
+++ b/src/services/user.ts
@@ -1,19 +1,19 @@
-import request from '@/utils/request';
+import { request } from 'umi';
-export async function query(): Promise<any> {
- return request('/api/users');
+export async function query() {
+ return request<API.CurrentUser[]>('/api/users');
}
-export async function queryCurrent(): Promise<any> {
- // NOTE: APISIX doesnât support user login currently, we return fake data directly.
- return {
+export async function queryCurrent() {
+ // return request<API.CurrentUser>('/api/currentUser');
+ return Promise.resolve({
name: 'APISIX User',
avatar:
'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjxzdmcgdmlld0JveD0iMCAwIDUwMCA1MDAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+DQogIDxkZWZzPg0KICAgIDxsaW5lYXJHcmFkaWVudCBpZD0iaWQwIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjI1MTE5LjgiIHkxPSIxMTA1Mi41IiB4Mj0iMjE3MjUuNyIgeTI9IjIxNTUxLjciIGdyYWRpZW50VHJhbnNmb3JtPSJtYXRyaXgoMC4wMjgwOTUsIDAsIDAsIDAuMDI4MDk1LCAtNDkyLjg2NzA5NiwgLTE0NC43Njk4MjEpIj4NCiAgICAgIDxzdG9wIG9mZnNldD0iMCIgc3R5bGU9InN0b3AtY29 [...]
userid: '00000001',
- };
+ });
}
export async function queryNotices(): Promise<any> {
- return request('/api/notices');
+ return request<{ data: API.NoticeIconData[] }>('/api/notices');
}
[incubator-apisix-dashboard] 01/02: feat: added API.d.ts
Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
juzhiyuan pushed a commit to branch feat-access
in repository https://gitbox.apache.org/repos/asf/incubator-apisix-dashboard.git
commit 9a0615382d8d028792ca9f6f44676a178fa5115d
Author: juzhiyuan <jj...@gmail.com>
AuthorDate: Wed May 20 16:49:38 2020 +0800
feat: added API.d.ts
---
src/access.ts | 6 ++++++
src/services/API.d.ts | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 41 insertions(+)
diff --git a/src/access.ts b/src/access.ts
new file mode 100644
index 0000000..207bc4b
--- /dev/null
+++ b/src/access.ts
@@ -0,0 +1,6 @@
+export default function (initialState: { currentUser?: API.CurrentUser | undefined }) {
+ const { currentUser } = initialState || {};
+ return {
+ canAdmin: currentUser && currentUser.access === 'admin',
+ };
+}
diff --git a/src/services/API.d.ts b/src/services/API.d.ts
new file mode 100644
index 0000000..63cabec
--- /dev/null
+++ b/src/services/API.d.ts
@@ -0,0 +1,35 @@
+declare namespace API {
+ export interface CurrentUser {
+ avatar?: string;
+ name?: string;
+ title?: string;
+ group?: string;
+ signature?: string;
+ tags?: {
+ key: string;
+ label: string;
+ }[];
+ userid?: string;
+ access?: 'user' | 'guest' | 'admin';
+ unreadCount?: number;
+ }
+
+ export interface LoginStateType {
+ status?: 'ok' | 'error';
+ type?: string;
+ }
+
+ export interface NoticeIconData {
+ id: string;
+ key: string;
+ avatar: string;
+ title: string;
+ datetime: string;
+ type: string;
+ read?: boolean;
+ description: string;
+ clickClose?: boolean;
+ extra: any;
+ status: string;
+ }
+}