From e18b55857be64e90f40f180b23efa5167b46e26b Mon Sep 17 00:00:00 2001 From: juzhiyuan Date: Thu, 13 Aug 2020 22:00:39 +0800 Subject: [PATCH 1/8] feat(Doc): added deploy doc for docker --- compose/README.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/compose/README.md b/compose/README.md index ef2bf96758..2d6eab2e9f 100644 --- a/compose/README.md +++ b/compose/README.md @@ -17,4 +17,21 @@ # --> -This folder stores the `docker-compose` file for `manager-api`. \ No newline at end of file +# docker-compose + +This folder stores the `docker-compose` file for `manager-api`. + +## Deploy + +1. Run docker-compose + +```sh +$ cd apisix-dashboard/compose + +$ sh gen-config-yaml.sh + +# For most users in China, please use some proxy services like https://www.daocloud.io/mirror to speed up your Docker images pulling. +$ docker-compose -p dashboard up -d +``` + +2. Visit `http://127.0.0.1/dashboard/` in the browser, and input the manager api `http://127.0.0.1:8080/apisix/admin` in the Setting page. From 1d4189668509cf9c1a7db06683da80a274ac1a44 Mon Sep 17 00:00:00 2001 From: juzhiyuan Date: Thu, 13 Aug 2020 22:04:44 +0800 Subject: [PATCH 2/8] feat: added CD --- .github/workflows/deploy.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000000..86cc48c74f --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,23 @@ +name: Deploy to Azure + +on: + push: + branches: [ master ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + + - uses: actions/checkout@v2 + + - uses: Azure/docker-login@v1 + with: + login-server: apisixacr.azurecr.cn + username: ${{ secrets.REGISTRY_USERNAME }} + password: ${{ secrets.REGISTRY_PASSWORD }} + + - run: | + docker build . -t apisixacr.azurecr.cn/dashboard:${{ github.sha }} + docker push apisixacr.azurecr.cn/dashboard:${{ github.sha }} \ No newline at end of file From 1b9766793dd3b7388f1c98091097d47235082a63 Mon Sep 17 00:00:00 2001 From: juzhiyuan Date: Thu, 13 Aug 2020 22:10:41 +0800 Subject: [PATCH 3/8] feat(Netlify): added proxy --- netlify.toml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/netlify.toml b/netlify.toml index cb87419ccc..9a08826ab7 100644 --- a/netlify.toml +++ b/netlify.toml @@ -20,4 +20,9 @@ [[redirects]] from = "/*" to = "/index.html" + status = 200 + +[[redirects]] + from = "/apisix/admin/*" + to = "https://api.apisix.dev/apisix/admin/:splat" status = 200 \ No newline at end of file From 7543eaaa58d8d052e03a6085ece58eff1000e8b6 Mon Sep 17 00:00:00 2001 From: juzhiyuan Date: Thu, 13 Aug 2020 22:11:11 +0800 Subject: [PATCH 4/8] feat: update API --- src/constants.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constants.ts b/src/constants.ts index f99da2811e..d7aaec42ea 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -33,4 +33,4 @@ export const codeMessage = { }; // NOTE: This is the Manager API Address, e.g http://127.0.0.1:8080/apisix/admin -export const DEFAULT_BASE_URL = 'https://api.apisix.dev/apisix/admin'; +export const DEFAULT_BASE_URL = '/apisix/admin'; From 2db53ebe675e74d9082d825f77618cec3e0af067 Mon Sep 17 00:00:00 2001 From: juzhiyuan Date: Thu, 13 Aug 2020 22:13:31 +0800 Subject: [PATCH 5/8] feat: remove console --- src/constants.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/constants.ts b/src/constants.ts index d7aaec42ea..76e5d0ada5 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -32,5 +32,4 @@ export const codeMessage = { 504: '网关超时。', }; -// NOTE: This is the Manager API Address, e.g http://127.0.0.1:8080/apisix/admin export const DEFAULT_BASE_URL = '/apisix/admin'; From b20d1f47dcdbc218aed39cb4a77d02acbd961452 Mon Sep 17 00:00:00 2001 From: juzhiyuan Date: Thu, 13 Aug 2020 22:25:32 +0800 Subject: [PATCH 6/8] feat(Netlify): update redirect rule --- netlify.toml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/netlify.toml b/netlify.toml index 9a08826ab7..4e69d5b28f 100644 --- a/netlify.toml +++ b/netlify.toml @@ -18,11 +18,11 @@ publish = "dist/" [[redirects]] - from = "/*" - to = "/index.html" + from = "/apisix/admin/*" + to = "https://api.apisix.dev/apisix/admin/:splat" status = 200 [[redirects]] - from = "/apisix/admin/*" - to = "https://api.apisix.dev/apisix/admin/:splat" + from = "/*" + to = "/index.html" status = 200 \ No newline at end of file From cfd3d620c91e6b62c3e354c8bd9ccc2805a89147 Mon Sep 17 00:00:00 2001 From: juzhiyuan Date: Thu, 13 Aug 2020 23:09:27 +0800 Subject: [PATCH 7/8] feat: update README --- README.md | 18 ++++++++++++++++-- config/proxy.ts | 20 +++----------------- src/app.tsx | 20 +++++--------------- src/constants.ts | 2 -- src/helpers.tsx | 6 +----- src/locales/en-US/setting.ts | 5 +---- src/locales/zh-CN/setting.ts | 13 +------------ src/pages/Setting/Setting.tsx | 21 +-------------------- src/pages/Setting/locales/en-US.ts | 1 - src/pages/Setting/locales/zh-CN.ts | 1 - src/pages/Setting/typingd.d.ts | 4 ---- src/services/user.ts | 18 ++++++------------ 12 files changed, 34 insertions(+), 95 deletions(-) diff --git a/README.md b/README.md index 774b416c10..db2e0eb5a5 100644 --- a/README.md +++ b/README.md @@ -85,8 +85,22 @@ $ yarn install $ yarn build ``` -5. The bundled files are under `/dist` folder if the step 4 is successful, then We recommend using `nginx` to handle those files: just move them to nginx's default html folder, then visit `http://127.0.0.1` in your browser. The default Setting page would be shown, and you should set the API field to the manager api's address, e.g `http://127.0.0.1:8080/apisix/admin` . +5. The bundled files are under `/dist` folder if the step 4 is successful, then We recommend using `nginx` to handle those files, please refer to the nginx conf under `docker/nginx.conf`. +6. Move files under `dist` folder to nginx's default html folder, then visit `http://127.0.0.1` in your browser. + +## Development + +1. Make sure you have `Node.js(version 8.10.0+)/Nginx` installed on your machine. +2. Install [yarn](https://yarnpkg.com/). +3. Install dependencies: +4. If we want to modify the API, please refer to the `config/proxy.ts` file. + +```sh +$ yarn install + +$ yarn start +``` ## Other -1. If you need the elder dashboard which is built with Vue.js, please refer to [master-vue](https://github.com/apache/apisix-dashboard/tree/master-vue). \ No newline at end of file +1. If you need the elder dashboard which is built with Vue.js, please refer to [master-vue](https://github.com/apache/apisix-dashboard/tree/master-vue). diff --git a/config/proxy.ts b/config/proxy.ts index 7de0befe1c..3932be628d 100644 --- a/config/proxy.ts +++ b/config/proxy.ts @@ -16,24 +16,10 @@ */ export default { dev: { - '/api/': { - target: 'https://apisix.iresty.com/apisix/admin/', + '/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', changeOrigin: true, - pathRewrite: { '^/api': '' }, - }, - }, - test: { - '/api/': { - target: 'https://preview.pro.ant.design', - changeOrigin: true, - pathRewrite: { '^': '' }, - }, - }, - pre: { - '/api/': { - target: 'your pre url', - changeOrigin: true, - pathRewrite: { '^': '' }, }, }, }; diff --git a/src/app.tsx b/src/app.tsx index 16d31cc7d1..d309fac513 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -15,7 +15,7 @@ * limitations under the License. */ import React from 'react'; -import { RequestConfig, history } from 'umi'; +import { RequestConfig } from 'umi'; import { BasicLayoutProps, Settings as LayoutSettings, @@ -25,26 +25,16 @@ import { import RightContent from '@/components/RightContent'; import Footer from '@/components/Footer'; import { queryCurrent } from '@/services/user'; -import { getMenuData, errorHandler, getBaseURL } from '@/helpers'; +import { getMenuData, errorHandler } from '@/helpers'; import defaultSettings from '../config/defaultSettings'; export async function getInitialState(): Promise<{ currentUser?: API.CurrentUser; settings?: LayoutSettings; }> { - // 如果是设置页面,不执行 - if (history.location.pathname !== '/settings') { - try { - const currentUser = await queryCurrent(); - return { - currentUser, - settings: defaultSettings, - }; - } catch (error) { - history.push('/settings'); - } - } + const currentUser = await queryCurrent(); return { + currentUser, settings: defaultSettings, }; } @@ -66,7 +56,7 @@ export const layout = ({ }; export const request: RequestConfig = { - prefix: getBaseURL(), + prefix: '/apisix/admin', errorHandler, credentials: 'same-origin', }; diff --git a/src/constants.ts b/src/constants.ts index 76e5d0ada5..71c75ede9d 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -31,5 +31,3 @@ export const codeMessage = { 503: '服务不可用,服务器暂时过载或维护。', 504: '网关超时。', }; - -export const DEFAULT_BASE_URL = '/apisix/admin'; diff --git a/src/helpers.tsx b/src/helpers.tsx index 0b2ea1fd29..f644c22c20 100644 --- a/src/helpers.tsx +++ b/src/helpers.tsx @@ -18,7 +18,7 @@ import React from 'react'; import { notification } from 'antd'; import { MenuDataItem } from '@ant-design/pro-layout'; -import { codeMessage, DEFAULT_BASE_URL } from './constants'; +import { codeMessage } from './constants'; import IconFont from './iconfont'; export const getMenuData = (): MenuDataItem[] => { @@ -84,7 +84,3 @@ export const errorHandler = (error: { response: Response; data: any }): Promise< } return Promise.reject(response); }; - -export const getBaseURL = () => - localStorage.getItem('GLOBAL_SETTING_API_BASE_URL') || DEFAULT_BASE_URL; -export const setBaseURL = (url = '') => localStorage.setItem('GLOBAL_SETTING_API_BASE_URL', url); diff --git a/src/locales/en-US/setting.ts b/src/locales/en-US/setting.ts index d45bf16d2d..86e904509b 100644 --- a/src/locales/en-US/setting.ts +++ b/src/locales/en-US/setting.ts @@ -14,7 +14,4 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -export default { - 'app.settings.admin-api': 'Admin API Config', - 'app.settings.item.baseURL': 'API base URL', -}; +export default {}; diff --git a/src/locales/zh-CN/setting.ts b/src/locales/zh-CN/setting.ts index 40127b7b26..86e904509b 100644 --- a/src/locales/zh-CN/setting.ts +++ b/src/locales/zh-CN/setting.ts @@ -14,15 +14,4 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -export default { - 'app.settings.admin-api': '管理 API 配置', - 'app.settings.item.baseURL': 'API 基础地址', - 'app.settings.item.admin-api-schema': '管理 API 协议', - 'app.settings.item.admin-api-host': '管理 API 地址', - 'app.settings.item.admin-api-path': '管理 API 路径', - 'app.settings.item.admin-api-key': '管理 API 密钥', - 'app.settings.item.admin-api-grafana': 'Grafana 地址', - 'app.settings.description.invalid-admin-api-schema': '非法的管理 API 协议', - 'app.settings.description.invalid-admin-api-host': '非法的管理 API 地址', - 'app.settings.description.invalid-admin-api-path': '非法的管理 API 路径', -}; +export default {}; diff --git a/src/pages/Setting/Setting.tsx b/src/pages/Setting/Setting.tsx index 3c9770fb12..6b9585978b 100644 --- a/src/pages/Setting/Setting.tsx +++ b/src/pages/Setting/Setting.tsx @@ -19,7 +19,6 @@ import { PageContainer } from '@ant-design/pro-layout'; import { Card, Form, Input, Row, Col, notification } from 'antd'; import { useIntl } from 'umi'; -import { setBaseURL, getBaseURL } from '@/helpers'; import ActionBar from '@/components/ActionBar'; import { getGrafanaURL } from '@/pages/Metrics/service'; @@ -35,10 +34,6 @@ const Setting: React.FC = () => { const { formatMessage } = useIntl(); useEffect(() => { - form.setFieldsValue({ - baseURL: getBaseURL(), - }); - if (!canFetchGrafana) { return; } @@ -50,7 +45,7 @@ const Setting: React.FC = () => { }, [canFetchGrafana]); const onSubmit = () => { - const { grafanaURL, baseURL } = form.getFieldsValue(); + const { grafanaURL } = form.getFieldsValue(); Promise.all([ new Promise((resolve) => { if (canFetchGrafana) { @@ -58,12 +53,6 @@ const Setting: React.FC = () => { } resolve(); }), - new Promise((resolve) => { - if (!isWorkspace) { - setBaseURL(baseURL); - } - resolve(); - }), ]).then(() => { notification.success({ message: formatMessage({ @@ -83,14 +72,6 @@ const Setting: React.FC = () => {
- {!isWorkspace && ( - - - - )} {canFetchGrafana && ( { - if (!localStorage.getItem('GLOBAL_SETTING_API_BASE_URL')) { - notification.error({ message: '请设置 API 地址' }); - throw new Error('Need Settings'); - } else { - return Promise.resolve({ - name: 'APISIX User', - avatar: logo, - userid: '00000001', - access: 'admin', - }); - } + return Promise.resolve({ + name: 'APISIX User', + avatar: logo, + userid: '00000001', + access: 'admin', + }); } export async function queryNotices(): Promise { From c93fd962c625391be56ab421e35c3861bd80f5b8 Mon Sep 17 00:00:00 2001 From: juzhiyuan Date: Thu, 13 Aug 2020 23:13:45 +0800 Subject: [PATCH 8/8] feat: update README --- README.md | 4 ++-- compose/README.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index db2e0eb5a5..e1e7be3a9f 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ $ yarn install $ yarn build ``` -5. The bundled files are under `/dist` folder if the step 4 is successful, then We recommend using `nginx` to handle those files, please refer to the nginx conf under `docker/nginx.conf`. +5. The bundled files are under `/dist` folder if the step 4 is successful, then we recommend using `nginx` to handle those files, please refer to the nginx conf `docker/nginx.conf`. 6. Move files under `dist` folder to nginx's default html folder, then visit `http://127.0.0.1` in your browser. ## Development @@ -103,4 +103,4 @@ $ yarn start ## Other -1. If you need the elder dashboard which is built with Vue.js, please refer to [master-vue](https://github.com/apache/apisix-dashboard/tree/master-vue). +1. If you need the dashboard-1.0 which is built with Vue.js, please refer to [master-vue](https://github.com/apache/apisix-dashboard/tree/master-vue). diff --git a/compose/README.md b/compose/README.md index 2d6eab2e9f..cb6fb95881 100644 --- a/compose/README.md +++ b/compose/README.md @@ -34,4 +34,4 @@ $ sh gen-config-yaml.sh $ docker-compose -p dashboard up -d ``` -2. Visit `http://127.0.0.1/dashboard/` in the browser, and input the manager api `http://127.0.0.1:8080/apisix/admin` in the Setting page. +2. Visit `http://127.0.0.1/` in the browser.