feature(cloudcmd) add ability to disable console with "--no-console" (#65)

This commit is contained in:
coderaiser 2016-11-09 15:57:44 +02:00
parent 6b26b26115
commit c3c008ff72
12 changed files with 79 additions and 14 deletions

View file

@ -77,6 +77,7 @@ Cloud Commander supports command line parameters:
| `--open` | open web browser when server started
| `--one-panel-mode` | set one panel mode
`--config-dialog` | enable config dialog
`--console` | enable console
| `--no-server` | do not start server
| `--no-auth` | disable authorization
| `--no-online` | load scripts from local server
@ -85,6 +86,7 @@ Cloud Commander supports command line parameters:
| `--no-progress` | do not show progress of file operations
| `--no-one-panel-mode` | unset one panel mode
| `--no-config-dialog` | disable config dialog
| `--no-console` | disable console
If no parameters given Cloud Commander reads information from `~/.cloudcmd.json` and use
port from it (`8000` default). if port variables `PORT` or `VCAP_APP_PORT` isn't exist.
@ -233,7 +235,8 @@ Here is description of options:
"prefix" : "", /* url prefix */
"progress" : true, /* show progress of file operations */
"onePanelMode" : false, /* set one panel mode */
"configDialog" : true /* enable config dialog */
"configDialog" : true, /* enable config dialog */
"console" : true /* enable console */
}
```

View file

@ -32,6 +32,7 @@ var Info = require('../package'),
'open',
'minify',
'progress',
'console',
'config-dialog',
'one-panel-mode'
],
@ -47,6 +48,7 @@ var Info = require('../package'),
root : config('root') || '/',
prefix : config('prefix') || '',
progress : config('progress'),
console : defaultTrue(config('console')),
'config-dialog': defaultTrue(config('configDialog')),
'one-panel-mode': config('onePanelMode'),
@ -84,6 +86,7 @@ if (args.version) {
config('minify', args.minify);
config('username', args.username);
config('progress', args.progress);
config('console', args.console);
config('prefix', args.prefix);
config('root', args.root);
config('onePanelMode', args['one-panel-mode']);

View file

@ -21,5 +21,7 @@
"prefix": "",
"progress": true,
"onePanelMode": false,
"configDialog": true
"configDialog": true,
"console": true
}

View file

@ -15,6 +15,7 @@
"--progress ": "show progress of file operations",
"--one-panel-mode ": "set one panel mode",
"--config-dialog ": "enable config dialog",
"--console ": "enable console",
"--open ": "open web browser when server started",
"--no-server ": "do not start server",
"--no-auth ": "disable authorization",
@ -23,5 +24,6 @@
"--no-minify ": "disable minification",
"--no-progress ": "do not show progress of file operations",
"--no-one-panel-mode ": "unset one panel mode",
"--no-config-dialog ": "disable config dialog"
"--no-config-dialog ": "disable config dialog",
"--no-console ": "disable console"
}

View file

@ -333,13 +333,11 @@ var CloudCmd, Util, DOM;
break;
case Key.TRA:
DOM.Images.show.load('top');
CloudCmd.Konsole.show();
event.preventDefault();
break;
case KEY.BRACKET_CLOSE:
DOM.Images.show.load('top');
CloudCmd.Konsole.show();
event.preventDefault();
break;

View file

@ -110,7 +110,15 @@
Util.time(Name + ' load');
}
init();
DOM.Files.get('config', function(error, config) {
if (error)
return Dialog.alert(TITLE, error);
if (!config.console)
return;
init();
});
}
})(CloudCmd, Util, DOM);

View file

@ -108,12 +108,6 @@ function listen(prefix, socket) {
config.listen(socket, authCheck);
webconsole({
prefix: prefix + '/console',
socket: socket,
authCheck: authCheck
});
edward.listen(socket, {
size: size,
root: root,
@ -152,6 +146,12 @@ function listen(prefix, socket) {
prefix: prefix + '/ishtar',
authCheck: authCheck
});
config('console') && webconsole({
prefix: prefix + '/console',
socket: socket,
authCheck: authCheck
});
}
function cloudcmd(prefix) {

View file

@ -64,7 +64,8 @@ function indexProcessing(options) {
right = '',
keysPanel = '<div id="js-keyspanel" class="{{ className }}',
isOnePanel = config('onePanelMode'),
isConfig = config('configDialog'),
noConfig = !config('configDialog'),
noConsole = !config('console'),
data = options.data,
panel = options.panel;
@ -85,10 +86,14 @@ function indexProcessing(options) {
.replace('icon-move', 'icon-move none')
.replace('icon-copy', 'icon-copy none');
if (!isConfig)
if (noConfig)
data = data
.replace('icon-config', 'icon-config none');
if (noConsole)
data = data
.replace('icon-console', 'icon-console none');
left = rendy(Template.panel, {
side : 'left',
content : panel,

View file

@ -39,6 +39,7 @@ programs in browser from any computer, mobile or tablet device.
--open open web browser when server started
--one-panel-mode set one panel mode
--config-dialog enable config dialog
--console enable console
--no-auth disable authorization
--no-server do not start server
--no-online load scripts from local server
@ -47,6 +48,7 @@ programs in browser from any computer, mobile or tablet device.
--no-progress do not show progress of file operations
--no-one-panel-mode unset one panel mode
--no-config-dialog disable config dialog
--no-console disable console
.SH RESOURCES AND DOCUMENTATION

View file

@ -140,6 +140,7 @@
"redrun": "^5.0.0",
"request": "^2.76.0",
"shortdate": "^1.0.1",
"socket.io-client": "^1.5.1",
"stylelint": "^7.0.2",
"stylelint-config-standard": "^14.0.0",
"tape": "^4.4.0",

View file

@ -4,6 +4,7 @@ const http = require('http');
const os = require('os');
const express = require('express');
const io = require('socket.io');
const writejson = require('writejson');
const readjson = require('readjson');
@ -23,7 +24,10 @@ module.exports = (config, fn = config) => {
server.close();
};
const socket = io.listen(server);
app.use(cloudcmd({
socket,
config: assign(defaultConfig(), config)
}));

37
test/console.js Normal file
View file

@ -0,0 +1,37 @@
'use strict';
const test = require('tape');
const io = require('socket.io-client');
const before = require('./before');
test('cloudcmd: console: enabled', (t) => {
const config = {console: true};
before(config, (port, after) => {
const socket = io(`http://localhost:${port}/console`)
socket.once('data', (data) => {
socket.close();
t.equal(data, 'client #1 console connected\n', 'should emit data event');
after();
t.end();
});
});
});
test('cloudcmd: console: disabled', (t) => {
const config = {console: false};
before(config, (port, after) => {
const socket = io(`http://localhost:${port}/console`);
socket.on('error', (error) => {
t.equal(error, 'Invalid namespace', 'should emit error');
socket.close();
after();
t.end();
});
});
});