feature(cloudcmd) readify: add support of links

This commit is contained in:
coderaiser 2018-10-10 12:54:27 +03:00
parent 03685ee390
commit 52ffc2ac28
5 changed files with 31 additions and 23 deletions

View file

@ -188,8 +188,8 @@ module.exports.buildFromJSON = (params) => {
const name = encode(file.name); const name = encode(file.name);
const link = prefix + FS + path + name; const link = prefix + FS + path + name;
const type = getType(file.size); const {type} = file;
const size = getSize(file.size); const size = getSize(file);
const date = file.date || '--.--.----'; const date = file.date || '--.--.----';
const owner = file.owner || 'root'; const owner = file.owner || 'root';
@ -199,7 +199,7 @@ module.exports.buildFromJSON = (params) => {
link, link,
title: name, title: name,
name, name,
attribute: getAttribute(file.size) attribute: getAttribute(file.type)
}); });
const dataName = getDataName(file.name); const dataName = getDataName(file.name);
@ -223,22 +223,20 @@ module.exports.buildFromJSON = (params) => {
return fileTable; return fileTable;
}; };
function getType(size) { function getAttribute(type) {
if (size === 'dir') if (type === 'directory')
return 'directory';
return 'text-file';
}
function getAttribute(size) {
if (size === 'dir')
return ''; return '';
return 'target="_blank" '; return 'target="_blank" ';
} }
function getSize(size) { function getSize(file) {
if (size === 'dir') const {
size,
type,
} = file;
if (type === 'directory')
return '<dir>'; return '<dir>';
return size; return size;

View file

@ -107,12 +107,12 @@
color: white; color: white;
} }
.text-file::before { .file::before, .file-link::before {
color: rgba(26, 224, 124, 0.56); color: rgba(26, 224, 124, 0.56);
content: '\e80d'; content: '\e80d';
} }
.current-file .text-file::before { .current-file .file::before, .file-link::before {
color: white; color: white;
} }
@ -133,11 +133,11 @@
display: inline-block; display: inline-block;
} }
.directory::before { .directory::before, .directory-link::before {
content: '\e807'; content: '\e807';
} }
.text-file { .file, .file-link {
background-image: none; background-image: none;
} }

View file

@ -37,7 +37,15 @@
background-image: url(../img/dir.png); background-image: url(../img/dir.png);
} }
.text-file { .directory-link {
background-image: url(../img/dir.png);
}
.file {
background-image: url(../img/txt.png);
}
.file-link {
background-image: url(../img/txt.png); background-image: url(../img/txt.png);
} }

View file

@ -20,7 +20,7 @@
<span data-name="js-owner" class="owner reduce-text">root</span> <span data-name="js-owner" class="owner reduce-text">root</span>
<span data-name="js-mode" class="mode reduce-text">rwx r-x r-x</span> <span data-name="js-mode" class="mode reduce-text">rwx r-x r-x</span>
</li><li draggable="true" data-name="js-file-JUQwJUIwJUQwJUI5" class=""> </li><li draggable="true" data-name="js-file-JUQwJUIwJUQwJUI5" class="">
<span data-name="js-type" class="mini-icon text-file"></span> <span data-name="js-type" class="mini-icon file"></span>
<span data-name="js-name" class="name reduce-text"><a href="/fs/etc/X11/ай" title="ай" target="_blank" draggable="true">ай</a></span> <span data-name="js-name" class="name reduce-text"><a href="/fs/etc/X11/ай" title="ай" target="_blank" draggable="true">ай</a></span>
<span data-name="js-size" class="size reduce-text">1.30kb</span> <span data-name="js-size" class="size reduce-text">1.30kb</span>
<span data-name="js-date" class="date reduce-text">--.--.----</span> <span data-name="js-date" class="date reduce-text">--.--.----</span>

View file

@ -41,16 +41,18 @@ const JSON_FILES = {
path : '/etc/X11/', path : '/etc/X11/',
files : [{ files : [{
name: 'applnk', name: 'applnk',
size: 'dir', size: '4.0.0kb',
date: '21.02.2016', date: '21.02.2016',
uid : 0, uid : 0,
mode: 'rwx r-x r-x' mode: 'rwx r-x r-x',
type: 'directory',
}, { }, {
name: 'ай', name: 'ай',
size: '1.30kb', size: '1.30kb',
date: 0, date: 0,
uid : 0, uid : 0,
mode: 'rwx r-x r-x' mode: 'rwx r-x r-x',
type: 'file',
}] }]
}; };