feature(get-json-from-file-table) mv out from client

This commit is contained in:
coderaiser 2020-04-04 12:48:55 +03:00
parent b483481c81
commit 0098fb9975
2 changed files with 50 additions and 44 deletions

View file

@ -15,6 +15,7 @@ const isDev = process.env.NODE_ENV === 'development';
const Images = require('./dom/images');
const {unregisterSW} = require('./sw/register');
const getJsonFromFileTable = require('./get-json-from-file-table');
const currify = require('currify');
@ -269,7 +270,7 @@ function CloudCmdProto(DOM) {
const data = await Storage.get(dirPath);
if (!data)
await Storage.set(dirPath, getJSONfromFileTable());
await Storage.set(dirPath, getJsonFromFileTable());
}
function getPanels() {
@ -449,49 +450,6 @@ function CloudCmdProto(DOM) {
}
}
/**
* Функция генерирует JSON из html-таблицы файлов и
* используеться при первом заходе в корень
*/
function getJSONfromFileTable() {
const path = DOM.getCurrentDirPath();
const infoFiles = Info.files || [];
const notParent = (current) => {
const name = DOM.getCurrentName(current);
return name !== '..';
};
const parse = (current) => {
const name = DOM.getCurrentName(current);
const size = DOM.getCurrentSize(current);
const owner = DOM.getCurrentOwner(current);
const mode = DOM.getCurrentMode(current);
const date = DOM.getCurrentDate(current);
const type = DOM.getCurrentType(current);
return {
name,
size,
mode,
owner,
date,
type,
};
};
const files = infoFiles
.filter(notParent)
.map(parse);
const fileTable = {
path,
files,
};
return fileTable;
}
this.goToParentDir = async () => {
const {
dir,

View file

@ -0,0 +1,48 @@
'use strict';
/* global DOM */
/* global Info */
/**
* Функция генерирует JSON из html-таблицы файлов и
* используеться при первом заходе в корень
*/
module.exports = () => {
const path = DOM.getCurrentDirPath();
const infoFiles = Info.files || [];
const notParent = (current) => {
const name = DOM.getCurrentName(current);
return name !== '..';
};
const parse = (current) => {
const name = DOM.getCurrentName(current);
const size = DOM.getCurrentSize(current);
const owner = DOM.getCurrentOwner(current);
const mode = DOM.getCurrentMode(current);
const date = DOM.getCurrentDate(current);
const type = DOM.getCurrentType(current);
return {
name,
size,
mode,
owner,
date,
type,
};
};
const files = infoFiles
.filter(notParent)
.map(parse);
const fileTable = {
path,
files,
};
return fileTable;
};