fixed console ouput error format and command title contains space

This commit is contained in:
liugq 2021-10-25 15:56:05 +08:00
parent 5fcaed73ff
commit 4b90b75a39
6 changed files with 26 additions and 16 deletions

View File

@ -94,15 +94,15 @@ export default [
]
},
//devtools
{
routes:[
{ path: '/', redirect: '/' },
],
path: '/dev_tool',
name: 'devtool',
icon: 'code',
component: './DevTool/Console',
},
// {
// routes:[
// { path: '/', redirect: '/' },
// ],
// path: '/dev_tool',
// name: 'devtool',
// icon: 'code',
// component: './DevTool/Console',
// },
//alerting
{

View File

@ -4,6 +4,7 @@ export const ResizeBar = () => {
return <div className="resize-bar">
<div>
<div className="dash"></div>
<div className="dash"></div>
</div>
</div>;
};

View File

@ -2,12 +2,13 @@
display: flex;
height: 10px;
background: #eee;
border-top: 1px solid #bbb;
// border-top: 1px solid #bbb;
align-items: center;
justify-content: center;
.dash{
height: 2px;
width: 24px;
background: #999;
height: 1px;
width: 16px;
background: #666;
margin-top: 1px;
}
}

View File

@ -83,6 +83,10 @@ function ConsoleOutput({clusterID}: props) {
} else if (error) {
const mode = modeForContentType(error.response.contentType);
if(mode == 'ace/mode/json'){
editor.update(JSON.stringify(JSON.parse(error.response.value), null, 2), mode);
return
}
editor.update(error.response.value as string, mode);
} else {
editor.update('');

View File

@ -60,9 +60,10 @@ export const useSendCurrentRequestToES = () => {
console.log('No request selected. Select a request by placing the cursor inside it.');
return;
}
const {url, method} = requests[0];
const {url, method, data} = requests[0];
if(method === 'LOAD'){
const cmd = getCommand(url);
const rawUrl = data[0].slice(4).trim();
const cmd = getCommand(rawUrl);
// const curPostion = editor.currentReqRange //(editor.getCoreEditor().getCurrentPosition());
const lineNumber = editor.getCoreEditor().getCurrentPosition().lineNumber;
let crange = await editor.getRequestRange(lineNumber)

View File

@ -119,8 +119,9 @@ export function sendRequestToES(args: EsRequestArgs): Promise<ESRequestResult[]>
} else {
let value;
let contentType: string;
let resObj:any = {};
if (xhr.responseText) {
const resObj = JSON.parse(xhr.responseText)
resObj = JSON.parse(xhr.responseText)
if(resObj.error){
value = resObj.error;
contentType = 'text/plain';
@ -143,11 +144,13 @@ export function sendRequestToES(args: EsRequestArgs): Promise<ESRequestResult[]>
timeMs: Date.now() - startTime,
statusCode: xhr.status,
statusText: xhr.statusText,
header: resObj.response_header,
},
request: {
data: esData,
method: esMethod,
path: esPath,
header: resObj.request_header,
},
});
}