From 5747809cf88cfd772cabdd89f5a66e35a14735ea Mon Sep 17 00:00:00 2001 From: srgooglo Date: Wed, 28 Oct 2020 18:08:42 +0100 Subject: [PATCH] removed v3api debbuger due to poor code quality --- src/debuggers/api.js | 350 --------------------------------------- src/debuggers/api.less | 39 ----- src/pages/debug/index.js | 2 - 3 files changed, 391 deletions(-) delete mode 100644 src/debuggers/api.js delete mode 100644 src/debuggers/api.less diff --git a/src/debuggers/api.js b/src/debuggers/api.js deleted file mode 100644 index f4a64983..00000000 --- a/src/debuggers/api.js +++ /dev/null @@ -1,350 +0,0 @@ -import React from 'react'; -import {api_request} from 'core/libs/v3_model' -import { - Row, - Col, - Select, - Form, - Input, - Button, - List, - Tag, - Checkbox, -} from 'antd'; -import classnames from 'classnames'; -import { CloseOutlined } from '@ant-design/icons'; -import endpoints_list from 'config/endpoints'; - -import styles from './api.less'; - -const { Option } = Select; -const InputGroup = Input.Group; -const methods = ['POST', 'GET', 'PUT', 'PATCH', 'DELETE']; - -const methodTagColor = { - GET: 'green', - POST: 'orange', - DELETE: 'red', - PUT: 'geekblue', -}; - -const requests = Object.values(endpoints_list).map(item => { - let url = item; - let method = 'GET'; - const paramsArray = item.split(' '); - if (paramsArray.length === 2) { - method = paramsArray[0]; - url = paramsArray[1]; - } - return { - method, - url, - }; -}); - -let uuid = 2; - -export default class RequestPage extends React.Component { - paramsForm = React.createRef(); - bodyDataForm = React.createRef(); - - state = { - // Default sets - method: 'GET', - url: '', - ParamsKeys: [1], - BodyKeys: [1], - result: null, - visible: true, - } - - handleRequest = () => { - const { method, url } = this.state; - let params = {}; - let body = {}; - - this.paramsForm.current - .validateFields() - .then(values => { - if (values) { - for (let i in values) { - if (i.startsWith('check')) { - const index = i.match(/check\[(\d+)\]/)[1]; - const key = values[`key[${index}]`]; - params[key] = values[`value[${index}]`]; - } - } - } - }) - .catch(errorInfo => { - console.log(errorInfo); - }); - - this.bodyDataForm.current - .validateFields() - .then(values => { - if (values) { - for (let i in values) { - if (i.startsWith('check')) { - const index = i.match(/check\[(\d+)\]/)[1]; - const key = values[`key[${index}]`]; - body[key] = values[`value[${index}]`]; - } - } - } - }) - .catch(errorInfo => { - console.log(errorInfo); - }); - const frame = { - method, - endpoint: `${method} ${url}`, - body - } - console.log(frame) - api_request(frame, (err, res) => { - this.setState({ - result: res, - }); - }) - }; - - handleClickListItem = ({ method, url }) => { - this.setState({ - method, - url, - keys: [uuid++], - result: null, - }); - }; - - handleInputChange = e => { - this.setState({ - url: e.target.value, - }); - }; - - handleSelectChange = method => { - this.setState({ - method, - }); - }; - - handleAddParam = () => { - const { ParamsKeys } = this.state; - const nextKeys = ParamsKeys.concat(uuid); - uuid++; - this.setState({ - ParamsKeys: nextKeys, - }); - }; - - handleAddBody = () => { - const { BodyKeys } = this.state; - const nextKeys = BodyKeys.concat(uuid); - uuid++; - this.setState({ - BodyKeys: nextKeys, - }); - }; - - handleRemoveParam = key => { - const { ParamsKeys } = this.state; - this.setState({ - ParamsKeys: ParamsKeys.filter(item => item !== key), - }); - }; - - handleRemoveBody = key => { - const { BodyKeys } = this.state; - this.setState({ - BodyKeys: BodyKeys.filter(item => item !== key), - }); - }; - - handleVisible = () => { - this.setState({ - visible: !this.state.visible, - }); - }; - - render() { - const { result, url, method, ParamsKeys, BodyKeys, visible } = this.state; - - return ( -
- - - ( - - - - {item.method} - - - {item.url} - - )} - /> - - - - - - - - - - - - - - -
-
- {ParamsKeys.map((key, index) => ( - - - - - - - - - - - - - - - - - - - - - ))} - - - - -
-
- - - -
-
- {BodyKeys.map((key, index) => ( - - - - - - - - - - - - - - - - - - - - - ))} - - - - -
-
- -
- -
{JSON.stringify(result)}
- -
-
- ); - } -} diff --git a/src/debuggers/api.less b/src/debuggers/api.less deleted file mode 100644 index 2e80470c..00000000 --- a/src/debuggers/api.less +++ /dev/null @@ -1,39 +0,0 @@ -@import '~theme/index.less'; - -.result { - height: 700px; - width: 100%; - background: @hover-color; - border-color: #ddd; - padding: 16px; - margin-top: 16px; - word-break: break-word; - line-height: 2; - overflow: scroll; -} - -.requestList { - padding-right: 24px; - margin-bottom: 24px; - .listItem { - cursor: pointer; - padding-left: 8px; - &.lstItemActive { - background-color: @hover-color; - } - .background-hover(); - } -} - -.paramsBlock { - overflow: visible; - opacity: 1; - height: auto; - transition: opacity 0.3s; - &.hideParams { - width: 0; - height: 0; - opacity: 0; - overflow: hidden; - } -} diff --git a/src/pages/debug/index.js b/src/pages/debug/index.js index 95cc3477..cc4fa23b 100644 --- a/src/pages/debug/index.js +++ b/src/pages/debug/index.js @@ -2,7 +2,6 @@ import React from 'react' import * as Icons from 'components/Icons' import { ListedMenu } from 'components' -import ApiDebug from 'debuggers/api' import CoreDebug from 'debuggers/core' import ThemeDebug from 'debuggers/theme' import SocketDebug from 'debuggers/socket' @@ -11,7 +10,6 @@ import InternalDebug from 'debuggers/internals' import ContextMenuDebug from 'debuggers/contextmenu.js' const Debuggers = { - api: , core: , theme: , socket: ,