mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
chore(cloudcmd) lint
This commit is contained in:
parent
f662ec0e67
commit
d4ff1f97a9
5 changed files with 63 additions and 48 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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])
|
||||
|
|
|
|||
|
|
@ -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 += '</ul>';
|
||||
|
||||
return fileTable;
|
||||
};
|
||||
|
||||
function updateField(file) {
|
||||
return {
|
||||
...file,
|
||||
date: file.date || '--.--.----',
|
||||
owner: file.owner || 'root',
|
||||
size: getSize(file),
|
||||
};
|
||||
}
|
||||
|
||||
function getAttribute(type) {
|
||||
if (type === 'directory')
|
||||
return '';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue