diff --git a/HELP.md b/HELP.md
index 7b3153bf..cd1639ce 100644
--- a/HELP.md
+++ b/HELP.md
@@ -92,6 +92,7 @@ Cloud Commander supports command line parameters:
| `--terminal` | enable terminal
| `--terminal-path` | set terminal path
| `--vim` | enable vim hot keys
+| `--columns` | set visible columns
| `--no-server` | do not start server
| `--no-auth` | disable authorization
| `--no-online` | load scripts from local server
@@ -107,7 +108,7 @@ Cloud Commander supports command line parameters:
| `--no-console` | disable console
| `--no-terminal` | disable terminal
| `--no-vim` | disable vim hot keys
-
+| `--no-columns` | set visible default columns
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.
@@ -378,6 +379,7 @@ Here is description of options:
"terminal" : false, /* disable terminal */
"terminalPath" : '', /* path of a terminal */
"vim" : false, /* disable vim hot keys */
+ "columns" : "name-size-date-owner-mode", /* set visible columns */
}
```
@@ -387,6 +389,7 @@ Some config options can be overridden with `environment variables` such:
- `CLOUDCMD_NAME` - set tab name in web browser
- `CLOUDCMD_EDITOR` - set editor
+- `CLOUDCMD_COLUMNS` - set visible columns
- `CLOUDCMD_CONTACT` - enable contact
- `CLOUDCMD_CONFIG_DIALOG` - enable config dialog
- `CLOUDCMD_CONSOLE` - enable console
diff --git a/bin/cloudcmd.js b/bin/cloudcmd.js
index e4f49bd5..a1f590a5 100755
--- a/bin/cloudcmd.js
+++ b/bin/cloudcmd.js
@@ -29,6 +29,7 @@ const args = require('minimist')(argv.slice(2), {
'root',
'prefix',
'terminal-path',
+ 'columns',
],
boolean: [
'auth',
@@ -74,6 +75,7 @@ const args = require('minimist')(argv.slice(2), {
'confirm-move': choose(env.bool('confirm_move'), config('confirmMove')),
'html-dialogs': config('htmlDialogs'),
'vim': choose(env.bool('vim'), config('vim')),
+ 'columns': env('columns') || config('columns') || '',
},
alias: {
v: 'version',
@@ -119,6 +121,7 @@ function main() {
config('prefix', args.prefix);
config('root', args.root);
config('vim', args.vim);
+ config('columns', args.columns);
config('htmlDialogs', args['html-dialogs']);
config('confirmCopy', args['confirm-copy']);
config('confirmMove', args['confirm-move']);
@@ -131,7 +134,8 @@ function main() {
root: args.root || '/', /* --no-root */
editor: args.editor,
packer: args.packer,
- prefix: args.prefix
+ prefix: args.prefix,
+ columns: args.columns,
};
const password = env('password') || args.password;
diff --git a/client/cloudcmd.js b/client/cloudcmd.js
index d1cea5b0..2c21fbf4 100644
--- a/client/cloudcmd.js
+++ b/client/cloudcmd.js
@@ -2,6 +2,7 @@
require('../css/main.css');
require('../css/nojs.css');
+require('../css/columns/name-size-date.css');
// prevent additional loading of exec by spero, remedy, ishtar, salam, omnes
window.exec = require('execon');
diff --git a/client/dom/load.js b/client/dom/load.js
index b8007b71..f429e594 100644
--- a/client/dom/load.js
+++ b/client/dom/load.js
@@ -358,3 +358,4 @@ load.style = (params) => {
element,
});
};
+
diff --git a/client/modules/config.js b/client/modules/config.js
index ad3e5574..8f2c54da 100644
--- a/client/modules/config.js
+++ b/client/modules/config.js
@@ -165,6 +165,9 @@ function fillTemplate(error, template) {
obj[obj.packer + '-selected'] = 'selected';
delete obj.packer;
+ obj[obj.columns + '-selected'] = 'selected';
+ delete obj.columns;
+
const inner = rendy(Template, obj);
Element = DOM.load({
diff --git a/css/columns/name-size-date.css b/css/columns/name-size-date.css
new file mode 100644
index 00000000..a57dc305
--- /dev/null
+++ b/css/columns/name-size-date.css
@@ -0,0 +1,12 @@
+.name {
+ width: 59%;
+}
+
+.owner {
+ display: none;
+}
+
+.mode {
+ display: none;
+}
+
diff --git a/html/index.html b/html/index.html
index 56a11406..758a4627 100644
--- a/html/index.html
+++ b/html/index.html
@@ -7,12 +7,14 @@
-
{{ title }}
+
{{ fm }}
diff --git a/img/screen/config.png b/img/screen/config.png
index 3cf4f1ea..b9e0ce7b 100644
Binary files a/img/screen/config.png and b/img/screen/config.png differ
diff --git a/json/config.json b/json/config.json
index 8fde9c83..3067282f 100644
--- a/json/config.json
+++ b/json/config.json
@@ -30,6 +30,7 @@
"terminal": false,
"terminalPath": "",
"showConfig": false,
- "vim": false
+ "vim": false,
+ "columns": "name-size-date-owner-mode"
}
diff --git a/json/help.json b/json/help.json
index 56cd46fd..9060f1e5 100644
--- a/json/help.json
+++ b/json/help.json
@@ -26,6 +26,7 @@
"--terminal ": "enable terminal",
"--terminal-path ": "set terminal path",
"--vim ": "enable vim hot keys",
+ "--columns ": "set visible columns",
"--no-server ": "do not start server",
"--no-auth ": "disable authorization",
"--no-online ": "load scripts from local server",
@@ -40,5 +41,6 @@
"--no-console ": "disable console",
"--no-contact ": "disable contact",
"--no-terminal ": "disable terminal",
- "--no-vim ": "disable vim hot keys"
+ "--no-vim ": "disable vim hot keys",
+ "--no-columns ": "set default visible columns"
}
diff --git a/man/cloudcmd.1 b/man/cloudcmd.1
index 3157d1e7..cd6a31d0 100644
--- a/man/cloudcmd.1
+++ b/man/cloudcmd.1
@@ -49,6 +49,7 @@ programs in browser from any computer, mobile or tablet device.
--terminal enable terminal
--terminal-path set terminal path
--vim enable vim hot keys
+ --columns` set visible columns
--no-auth disable authorization
--no-server do not start server
--no-online load scripts from local server
@@ -64,6 +65,7 @@ programs in browser from any computer, mobile or tablet device.
--no-console disable console
--no-terminal disable terminal
--no-vim disable vim hot keys
+ --no-columns set visible default columns
.SH RESOURCES AND DOCUMENTATION
diff --git a/server/cloudcmd.js b/server/cloudcmd.js
index 50e6683a..c9cb2602 100644
--- a/server/cloudcmd.js
+++ b/server/cloudcmd.js
@@ -54,19 +54,8 @@ module.exports = (params) => {
keys.forEach((name) => {
const value = options[name];
- switch(name) {
- case 'root':
- validate.root(value);
- break;
-
- case 'editor':
- validate.editor(value);
- break;
-
- case 'packer':
- validate.packer(value);
- break;
- }
+ if (/root|editor|packer|columns/.test(name))
+ validate[name](value);
config(name, value);
});
diff --git a/server/columns.js b/server/columns.js
new file mode 100644
index 00000000..fa1433ed
--- /dev/null
+++ b/server/columns.js
@@ -0,0 +1,17 @@
+'use strict';
+
+const fs = require('fs');
+const isDev = process.NODE_ENV === 'development';
+const dir = getDirPath(isDev);
+
+module.exports = {
+ '': '',
+ 'name-size-date': fs.readFileSync(`${dir}/name-size-date.css`, 'utf8'),
+ 'name-size-date-owner-mode': '',
+};
+
+function getDirPath (isDev) {
+ const dist = isDev ? 'dist-dev' : 'dist';
+ return `${__dirname}/../${dist}/columns`;
+}
+
diff --git a/server/route.js b/server/route.js
index 3425ae11..0a85b827 100644
--- a/server/route.js
+++ b/server/route.js
@@ -14,6 +14,7 @@ const format = require('format-io');
const squad = require('squad/legacy');
const apart = require('apart');
+const columns = require(DIR_SERVER + 'columns');
const config = require(DIR_SERVER + 'config');
const root = require(DIR_SERVER + 'root');
const prefixer = require(DIR_SERVER + 'prefixer');
@@ -99,6 +100,7 @@ function indexProcessing(options) {
fm: left + right,
prefix: prefix(),
config: JSON.stringify(config('*')),
+ columns: columns[config('columns')],
});
return data;
diff --git a/server/validate.js b/server/validate.js
index 518e4079..e76c707f 100644
--- a/server/validate.js
+++ b/server/validate.js
@@ -1,12 +1,9 @@
'use strict';
const exit = require('./exit');
+const columns = require('./columns');
-module.exports.root = root;
-module.exports.editor = editor;
-module.exports.packer = packer;
-
-function root(dir, fn) {
+module.exports.root = (dir, fn) => {
if (typeof dir !== 'string')
throw Error('dir should be a string');
@@ -22,19 +19,28 @@ function root(dir, fn) {
if (typeof fn === 'function')
fn('root:', dir);
});
-}
+};
-function editor(name) {
+module.exports.editor = (name) => {
const reg = /^(dword|edward|deepword)$/;
if (!reg.test(name))
exit('cloudcmd --editor: could be "dword", "edward" or "deepword" only');
-}
+};
-function packer(name) {
+module.exports.packer = (name) => {
const reg = /^(tar|zip)$/;
if (!reg.test(name))
exit('cloudcmd --packer: could be "tar" or "zip" only');
-}
+};
+
+module.exports.columns = (type) => {
+ const all = Object
+ .keys(columns)
+ .concat('');
+
+ if (!~all.indexOf(type))
+ exit('cloudcmd --columns: could be "name-size-date" or "name-size-date-owner-mode"');
+};
diff --git a/test/server/validate.js b/test/server/validate.js
index 866c5080..3f52b577 100644
--- a/test/server/validate.js
+++ b/test/server/validate.js
@@ -107,6 +107,37 @@ test('validate: editor: not valid', (t) => {
t.end();
});
+test('validate: columns', (t) => {
+ const fn = sinon.stub();
+
+ clean();
+ require(exitPath);
+ stub(exitPath, fn);
+
+ const {columns} = require(validatePath);
+
+ columns('name-size-date');
+
+ t.notOk(fn.called, 'should not call exit');
+ t.end();
+});
+
+test('validate: columns: wrong', (t) => {
+ const fn = sinon.stub();
+
+ clean();
+ require(exitPath);
+ stub(exitPath, fn);
+
+ const {columns} = require(validatePath);
+ const msg = 'cloudcmd --columns: could be "name-size-date" or "name-size-date-owner-mode"';
+
+ columns('hello');
+
+ t.ok(fn.calledWith(msg), 'should call exit');
+ t.end();
+});
+
function clean() {
clear(validatePath);
clear(exitPath);
diff --git a/tmpl/config.hbs b/tmpl/config.hbs
index 6dbae009..317f7f08 100644
--- a/tmpl/config.hbs
+++ b/tmpl/config.hbs
@@ -43,6 +43,12 @@
Zip
+
+
+