From 10934b3ad9074e824b7f788ba1c6fe033cedd99a Mon Sep 17 00:00:00 2001 From: coderiaser Date: Fri, 20 Mar 2026 17:46:51 +0200 Subject: [PATCH] feature: cloudcmd: add ability to show modification time (#230) --- .webpack/js.js | 3 +++ client/modules/config/index.js | 7 +++++-- common/cloudfunc.js | 6 ++++++ css/columns/name-size-date-time.css | 26 ++++++++++++++++++++++++++ css/columns/name-size-date.css | 5 +++++ css/columns/name-size-time.css | 24 ++++++++++++++++++++++++ css/columns/name-size.css | 5 +++++ css/style.css | 5 +++++ test/common/cloudfunc.html | 6 +++++- test/common/cloudfunc.js | 2 +- tmpl/config.hbs | 1 + tmpl/fs/file.hbs | 1 + 12 files changed, 87 insertions(+), 4 deletions(-) create mode 100644 css/columns/name-size-date-time.css create mode 100644 css/columns/name-size-time.css diff --git a/.webpack/js.js b/.webpack/js.js index 4759741e..fdc88556 100644 --- a/.webpack/js.js +++ b/.webpack/js.js @@ -77,6 +77,8 @@ const splitChunks = { 'themes/light', 'columns/name-size', 'columns/name-size-date', + 'columns/name-size-time', + 'columns/name-size-date-time', ]; return !lazyChunks.includes(chunk.name); @@ -111,6 +113,7 @@ export default { 'themes/light': `${dirThemes}/light.css`, 'columns/name-size': `${dirColumns}/name-size.css`, 'columns/name-size-date': `${dirColumns}/name-size-date.css`, + 'columns/name-size-date-time': `${dirColumns}/name-size-date-time.css`, 'nojs': `${dirCss}/nojs.css`, 'help': `${dirCss}/help.css`, 'view': `${dirCss}/view.css`, diff --git a/client/modules/config/index.js b/client/modules/config/index.js index 4f3965c3..cbed9c74 100644 --- a/client/modules/config/index.js +++ b/client/modules/config/index.js @@ -1,4 +1,3 @@ -/* global CloudCmd, DOM, io */ import '../../../css/config.css'; import {rendy} from 'rendy'; import currify from 'currify'; @@ -14,6 +13,10 @@ import {getTitle} from '#common/cloudfunc'; import * as Images from '#dom/images'; import * as input from './input.js'; +const { + CloudCmd, + DOM, +} = globalThis; const {Dialog, setTitle} = DOM; const Name = 'Config'; @@ -78,7 +81,7 @@ function initSocket() { const ONE_MINUTE = 60 * 1000; - const socket = io.connect(href + prefixSocket + '/config', { + const socket = globalThis.io.connect(href + prefixSocket + '/config', { reconnectionAttempts: Infinity, reconnectionDelay: ONE_MINUTE, path: `${prefix}/socket.io`, diff --git a/common/cloudfunc.js b/common/cloudfunc.js index 9ea55133..37390db9 100644 --- a/common/cloudfunc.js +++ b/common/cloudfunc.js @@ -154,6 +154,7 @@ export const buildFromJSON = (params) => { const name = getFieldName('name'); const size = getFieldName('size'); const date = getFieldName('date'); + const time = getFieldName('time'); const header = rendy(templateFile, { tag: 'div', @@ -163,6 +164,7 @@ export const buildFromJSON = (params) => { name, size, date, + time, owner, mode, }); @@ -195,6 +197,7 @@ export const buildFromJSON = (params) => { name: linkResult, size: '<dir>', date: '--.--.----', + time: '--.--.----', owner: '.', mode: '--- --- ---', }); @@ -213,6 +216,7 @@ export const buildFromJSON = (params) => { type, mode, date, + time, owner, size, } = file; @@ -235,6 +239,7 @@ export const buildFromJSON = (params) => { name: linkResult, size, date: formatDate(date), + time, owner, mode, }); @@ -249,6 +254,7 @@ export const buildFromJSON = (params) => { const updateField = (file) => ({ ...file, date: file.date || '--.--.----', + time: file.time || '--.--.----', owner: file.owner || 'root', size: getSize(file), }); diff --git a/css/columns/name-size-date-time.css b/css/columns/name-size-date-time.css new file mode 100644 index 00000000..1d095490 --- /dev/null +++ b/css/columns/name-size-date-time.css @@ -0,0 +1,26 @@ +.name { + width: 40%; +} + +.size { + float: none; +} + +.owner { + display: none; +} + +.mode { + display: none; +} + +.date { + float: right; + width: 20%; +} + +.time { + display: inline; + float: right; + width: 20%; +} diff --git a/css/columns/name-size-date.css b/css/columns/name-size-date.css index 45c65c64..9248f700 100644 --- a/css/columns/name-size-date.css +++ b/css/columns/name-size-date.css @@ -18,3 +18,8 @@ float: right; width: 19%; } + +.time { + display: none; +} + diff --git a/css/columns/name-size-time.css b/css/columns/name-size-time.css new file mode 100644 index 00000000..1bbd59de --- /dev/null +++ b/css/columns/name-size-time.css @@ -0,0 +1,24 @@ +.name { + width: 55%; +} + +.size { + float: none; +} + +.owner { + display: none; +} + +.mode { + display: none; +} + +.date { + display: none; +} + +.time { + float: right; + width: 19%; +} diff --git a/css/columns/name-size.css b/css/columns/name-size.css index e58d1844..c02472a5 100644 --- a/css/columns/name-size.css +++ b/css/columns/name-size.css @@ -18,3 +18,8 @@ .date { display: none; } + +.time { + display: none; +} + diff --git a/css/style.css b/css/style.css index cd7122f7..333075ed 100644 --- a/css/style.css +++ b/css/style.css @@ -228,6 +228,11 @@ a:active { color: var(--column-color); } +.time { + color: var(--column-color); + display: none; +} + .owner { display: inline-block; width: 13%; diff --git a/test/common/cloudfunc.html b/test/common/cloudfunc.html index 8db8081a..572c689c 100644 --- a/test/common/cloudfunc.html +++ b/test/common/cloudfunc.html @@ -2,6 +2,7 @@ name size + time date owner mode @@ -9,6 +10,7 @@ .. <dir> + --.--.---- --.--.---- . --- --- --- @@ -16,6 +18,7 @@ applnk <dir> + --.--.---- 21.02.2016 root rwx r-x r-x @@ -23,7 +26,8 @@ ай 1.30kb + --.--.---- --.--.---- root rwx r-x r-x - \ No newline at end of file + diff --git a/test/common/cloudfunc.js b/test/common/cloudfunc.js index 1eef2147..51899a9a 100644 --- a/test/common/cloudfunc.js +++ b/test/common/cloudfunc.js @@ -68,7 +68,7 @@ test('cloudfunc: render', (t) => { template, }); - Expect += fs.readFileSync(EXPECT_PATH, 'utf8'); + Expect += fs.readFileSync(EXPECT_PATH, 'utf8').slice(0, -1); let i; const isNotOk = Expect diff --git a/tmpl/config.hbs b/tmpl/config.hbs index 9b10b1e0..26dc3251 100644 --- a/tmpl/config.hbs +++ b/tmpl/config.hbs @@ -52,6 +52,7 @@
  • diff --git a/tmpl/fs/file.hbs b/tmpl/fs/file.hbs index 0eaa6887..8b50494f 100644 --- a/tmpl/fs/file.hbs +++ b/tmpl/fs/file.hbs @@ -2,6 +2,7 @@ {{ name }} {{ size }} + {{ time }} {{ date }} {{ owner }} {{ mode }}