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 //devtools
{ // {
routes:[ // routes:[
{ path: '/', redirect: '/' }, // { path: '/', redirect: '/' },
], // ],
path: '/dev_tool', // path: '/dev_tool',
name: 'devtool', // name: 'devtool',
icon: 'code', // icon: 'code',
component: './DevTool/Console', // component: './DevTool/Console',
}, // },
//alerting //alerting
{ {

View File

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

View File

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

View File

@ -83,6 +83,10 @@ function ConsoleOutput({clusterID}: props) {
} else if (error) { } else if (error) {
const mode = modeForContentType(error.response.contentType); 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); editor.update(error.response.value as string, mode);
} else { } else {
editor.update(''); 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.'); console.log('No request selected. Select a request by placing the cursor inside it.');
return; return;
} }
const {url, method} = requests[0]; const {url, method, data} = requests[0];
if(method === 'LOAD'){ 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 curPostion = editor.currentReqRange //(editor.getCoreEditor().getCurrentPosition());
const lineNumber = editor.getCoreEditor().getCurrentPosition().lineNumber; const lineNumber = editor.getCoreEditor().getCurrentPosition().lineNumber;
let crange = await editor.getRequestRange(lineNumber) let crange = await editor.getRequestRange(lineNumber)

View File

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