mirror of
https://github.com/embarklabs/embark.git
synced 2025-01-11 14:24:24 +00:00
revert console to only show cockpit results in cockpit
This commit is contained in:
parent
6662731898
commit
fac29e1601
@ -1,3 +1,6 @@
|
|||||||
|
import {EMBARK_PROCESS_NAME} from '../constants';
|
||||||
|
import {ansiToHtml} from '../utils/utils';
|
||||||
|
|
||||||
export const REQUEST = 'REQUEST';
|
export const REQUEST = 'REQUEST';
|
||||||
export const SUCCESS = 'SUCCESS';
|
export const SUCCESS = 'SUCCESS';
|
||||||
export const FAILURE = 'FAILURE';
|
export const FAILURE = 'FAILURE';
|
||||||
@ -118,7 +121,17 @@ export const COMMANDS = createRequestTypes('COMMANDS');
|
|||||||
export const commands = {
|
export const commands = {
|
||||||
post: (command) => action(COMMANDS[REQUEST], {command}),
|
post: (command) => action(COMMANDS[REQUEST], {command}),
|
||||||
success: (command, payload) => {
|
success: (command, payload) => {
|
||||||
return action(COMMANDS[SUCCESS], {});
|
return action(COMMANDS[SUCCESS], {
|
||||||
|
processLogs: [
|
||||||
|
{
|
||||||
|
timestamp: new Date().getTime(),
|
||||||
|
name: EMBARK_PROCESS_NAME,
|
||||||
|
msg: `${ansiToHtml(command.result || '')}`,
|
||||||
|
command: `console> ${payload.command}<br>`,
|
||||||
|
result: command.result
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
},
|
},
|
||||||
failure: (error) => action(COMMANDS[FAILURE], {error})
|
failure: (error) => action(COMMANDS[FAILURE], {error})
|
||||||
};
|
};
|
||||||
|
@ -96,7 +96,6 @@ class Console {
|
|||||||
private registerApi() {
|
private registerApi() {
|
||||||
const plugin = this.plugins.createPlugin("consoleApi", {});
|
const plugin = this.plugins.createPlugin("consoleApi", {});
|
||||||
plugin.registerAPICall("post", "/embark-api/command", (req: any, res: any) => {
|
plugin.registerAPICall("post", "/embark-api/command", (req: any, res: any) => {
|
||||||
this.logger.info(`Cockpit> ${req.body.command}`.cyan);
|
|
||||||
this.executeCmd(req.body.command, (err: any, result: any) => {
|
this.executeCmd(req.body.command, (err: any, result: any) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return res.send({ result: err.message || err });
|
return res.send({ result: err.message || err });
|
||||||
@ -104,10 +103,8 @@ class Console {
|
|||||||
let response = result;
|
let response = result;
|
||||||
if (typeof result !== "string") {
|
if (typeof result !== "string") {
|
||||||
response = stringify(result, utils.jsonFunctionReplacer, 2);
|
response = stringify(result, utils.jsonFunctionReplacer, 2);
|
||||||
this.logger.info(response);
|
|
||||||
} else {
|
} else {
|
||||||
// Avoid HTML injection in the Cockpit
|
// Avoid HTML injection in the Cockpit
|
||||||
this.logger.info(response);
|
|
||||||
response = escapeHtml(response);
|
response = escapeHtml(response);
|
||||||
}
|
}
|
||||||
return res.send({ result: response });
|
return res.send({ result: response });
|
||||||
|
Loading…
x
Reference in New Issue
Block a user