diff --git a/bin/cloudcmd.js b/bin/cloudcmd.js index 118ed390..59bc17f8 100755 --- a/bin/cloudcmd.js +++ b/bin/cloudcmd.js @@ -7,8 +7,6 @@ const DIR_SERVER = '../server/'; const {promisify} = require('util'); -const wraptile = require('wraptile'); - const exit = require(DIR_SERVER + 'exit'); const { createConfig, @@ -222,7 +220,7 @@ function main() { const caller = (fn) => fn(); importConfig(config) - .then(args.save ? caller(config.write) : noop) + .then(args.save ? caller(config.write) : noop); start(options, config); } diff --git a/client/client.js b/client/client.js index 5d7ac82f..6c9793c6 100644 --- a/client/client.js +++ b/client/client.js @@ -324,13 +324,15 @@ function CloudCmdProto(DOM) { options = {}; } - const panel = options.panel || Info.panel; + const { + panel = Info.panel, + currentName, + } = options; const path = DOM.getCurrentDirPath(panel); const isRefresh = true; const history = false; const noCurrent = options ? options.noCurrent : false; - const {currentName} = options; CloudCmd.loadDir({ path, diff --git a/client/dom/load.js b/client/dom/load.js index 513de732..5596a384 100644 --- a/client/dom/load.js +++ b/client/dom/load.js @@ -43,7 +43,9 @@ module.exports.ajax = (params) => { const isArray = itype.array(p.data); const isArrayBuf = itype(p.data) === 'arraybuffer'; const type = p.type || p.method || 'GET'; - const headers = p.headers || {}; + const { + headers = {}, + } = p; const xhr = new XMLHttpRequest(); xhr.open(type, p.url, true); diff --git a/client/load-module.js b/client/load-module.js index 17afdef7..bade6710 100644 --- a/client/load-module.js +++ b/client/load-module.js @@ -18,8 +18,10 @@ module.exports = function loadModule(params) { if (!params) return; - const {path} = params; - const name = params.name || path && noJS(pascalCase(path)); + const { + path, + name = path && noJS(pascalCase(path)), + } = params; const doBefore = params.dobefore; if (CloudCmd[name]) diff --git a/common/cloudfunc.js b/common/cloudfunc.js index d30460f5..95df933b 100644 --- a/common/cloudfunc.js +++ b/common/cloudfunc.js @@ -41,8 +41,10 @@ module.exports.formatMsg = (msg, name, status) => { module.exports.getTitle = (options) => { options = options || {}; - const path = options.path || Path(); - const {name} = options; + const { + path = Path(), + name, + } = options; const array = [ name || NAME, @@ -110,6 +112,8 @@ module.exports.buildFromJSON = (params) => { const { prefix, template, + sort = 'name', + order = 'asc', } = params; const templateFile = template.file; @@ -120,9 +124,6 @@ module.exports.buildFromJSON = (params) => { const {files} = json; - const sort = params.sort || 'name'; - const order = params.order || 'asc'; - /* * Строим путь каталога в котором мы находимся * со всеми подкаталогами @@ -189,47 +190,57 @@ module.exports.buildFromJSON = (params) => { }); } - fileTable += files.map((file) => { - const name = encode(file.name); - const link = prefix + FS + path + name; - - const { - type, - mode, - } = file; - const size = getSize(file); - - const date = file.date || '--.--.----'; - const owner = file.owner || 'root'; - - const linkResult = rendy(templateLink, { - link, - title: name, - name, - attribute: getAttribute(file.type), - }); - - const dataName = getDataName(file.name); - const attribute = `draggable="true" ${dataName}`; - - return rendy(templateFile, { - tag: 'li', - attribute, - className: '', - type, - name: linkResult, - size, - date, - owner, - mode, - }); - }).join(''); + fileTable += files + .map(updateField) + .map((file) => { + const name = encode(file.name); + const link = prefix + FS + path + name; + + const { + type, + mode, + date, + owner, + size, + } = file; + + const linkResult = rendy(templateLink, { + link, + title: name, + name, + attribute: getAttribute(file.type), + }); + + const dataName = getDataName(file.name); + const attribute = `draggable="true" ${dataName}`; + + return rendy(templateFile, { + tag: 'li', + attribute, + className: '', + type, + name: linkResult, + size, + date, + owner, + mode, + }); + }).join(''); fileTable += ''; return fileTable; }; +function updateField(file) { + return { + ...file, + date: file.date || '--.--.----', + owner: file.owner || 'root', + size: getSize(file), + }; +} + function getAttribute(type) { if (type === 'directory') return '';