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
|
|
@ -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